18d623946Smrg#! /usr/bin/env sh 2fe24f8a2Smrg## DO NOT EDIT - This file generated from ./build-aux/ltmain.in 38d623946Smrg## by inline-source v2019-02-19.15 434977a2fSmrg 58d623946Smrg# libtool (GNU libtool) 2.4.7 6fe24f8a2Smrg# Provide generalized library-building support services. 734977a2fSmrg# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 834977a2fSmrg 98d623946Smrg# Copyright (C) 1996-2019, 2021-2022 Free Software Foundation, Inc. 1034977a2fSmrg# This is free software; see the source for copying conditions. There is NO 1134977a2fSmrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 1234977a2fSmrg 1334977a2fSmrg# GNU Libtool is free software; you can redistribute it and/or modify 14ee3138f1Smrg# it under the terms of the GNU General Public License as published by 15ee3138f1Smrg# the Free Software Foundation; either version 2 of the License, or 16ee3138f1Smrg# (at your option) any later version. 17ee3138f1Smrg# 1834977a2fSmrg# As a special exception to the GNU General Public License, 1934977a2fSmrg# if you distribute this file as part of a program or library that 2034977a2fSmrg# is built using GNU Libtool, you may include this file under the 2134977a2fSmrg# same distribution terms that you use for the rest of that program. 2234977a2fSmrg# 2334977a2fSmrg# GNU Libtool is distributed in the hope that it will be useful, but 24ee3138f1Smrg# WITHOUT ANY WARRANTY; without even the implied warranty of 25ee3138f1Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 26ee3138f1Smrg# General Public License for more details. 27ee3138f1Smrg# 28ee3138f1Smrg# You should have received a copy of the GNU General Public License 29fe24f8a2Smrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 3079a8a9c6Smrg 31ee3138f1Smrg 32b425557eSmrgPROGRAM=libtool 33ee3138f1SmrgPACKAGE=libtool 348d623946SmrgVERSION=2.4.7 358d623946Smrgpackage_revision=2.4.7 36ee3138f1Smrg 37fe24f8a2Smrg 38fe24f8a2Smrg## ------ ## 39fe24f8a2Smrg## Usage. ## 40fe24f8a2Smrg## ------ ## 41fe24f8a2Smrg 42fe24f8a2Smrg# Run './libtool --help' for help with using this script from the 43fe24f8a2Smrg# command line. 44fe24f8a2Smrg 45fe24f8a2Smrg 46fe24f8a2Smrg## ------------------------------- ## 47fe24f8a2Smrg## User overridable command paths. ## 48fe24f8a2Smrg## ------------------------------- ## 49fe24f8a2Smrg 50fe24f8a2Smrg# After configure completes, it has a better idea of some of the 51fe24f8a2Smrg# shell tools we need than the defaults used by the functions shared 52fe24f8a2Smrg# with bootstrap, so set those here where they can still be over- 53fe24f8a2Smrg# ridden by the user, but otherwise take precedence. 54fe24f8a2Smrg 55fe24f8a2Smrg: ${AUTOCONF="autoconf"} 56fe24f8a2Smrg: ${AUTOMAKE="automake"} 57fe24f8a2Smrg 58fe24f8a2Smrg 59fe24f8a2Smrg## -------------------------- ## 60fe24f8a2Smrg## Source external libraries. ## 61fe24f8a2Smrg## -------------------------- ## 62fe24f8a2Smrg 63fe24f8a2Smrg# Much of our low-level functionality needs to be sourced from external 64fe24f8a2Smrg# libraries, which are installed to $pkgauxdir. 65fe24f8a2Smrg 66fe24f8a2Smrg# Set a version string for this script. 678d623946Smrgscriptversion=2019-02-19.15; # UTC 68fe24f8a2Smrg 69fe24f8a2Smrg# General shell script boiler plate, and helper functions. 70fe24f8a2Smrg# Written by Gary V. Vaughan, 2004 71fe24f8a2Smrg 728d623946Smrg# This is free software. There is NO warranty; not even for 738d623946Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 748d623946Smrg# 758d623946Smrg# Copyright (C) 2004-2019, 2021 Bootstrap Authors 768d623946Smrg# 778d623946Smrg# This file is dual licensed under the terms of the MIT license 788d623946Smrg# <https://opensource.org/license/MIT>, and GPL version 2 or later 798d623946Smrg# <http://www.gnu.org/licenses/gpl-2.0.html>. You must apply one of 808d623946Smrg# these licenses when using or redistributing this software or any of 818d623946Smrg# the files within it. See the URLs above, or the file `LICENSE` 828d623946Smrg# included in the Bootstrap distribution for the full license texts. 83fe24f8a2Smrg 848d623946Smrg# Please report bugs or propose patches to: 858d623946Smrg# <https://github.com/gnulib-modules/bootstrap/issues> 86fe24f8a2Smrg 87fe24f8a2Smrg 88fe24f8a2Smrg## ------ ## 89fe24f8a2Smrg## Usage. ## 90fe24f8a2Smrg## ------ ## 91fe24f8a2Smrg 92fe24f8a2Smrg# Evaluate this file near the top of your script to gain access to 93fe24f8a2Smrg# the functions and variables defined here: 94fe24f8a2Smrg# 95fe24f8a2Smrg# . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh 96fe24f8a2Smrg# 97fe24f8a2Smrg# If you need to override any of the default environment variable 98fe24f8a2Smrg# settings, do that before evaluating this file. 99fe24f8a2Smrg 100fe24f8a2Smrg 101fe24f8a2Smrg## -------------------- ## 102fe24f8a2Smrg## Shell normalisation. ## 103fe24f8a2Smrg## -------------------- ## 104fe24f8a2Smrg 105fe24f8a2Smrg# Some shells need a little help to be as Bourne compatible as possible. 106fe24f8a2Smrg# Before doing anything else, make sure all that help has been provided! 107fe24f8a2Smrg 108fe24f8a2SmrgDUALCASE=1; export DUALCASE # for MKS sh 109fe24f8a2Smrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : 110ee3138f1Smrg emulate sh 111ee3138f1Smrg NULLCMD=: 112fe24f8a2Smrg # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which 113ee3138f1Smrg # is contrary to our usage. Disable this feature. 114ee3138f1Smrg alias -g '${1+"$@"}'='"$@"' 115ee3138f1Smrg setopt NO_GLOB_SUBST 116ee3138f1Smrgelse 117fe24f8a2Smrg case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac 118ee3138f1Smrgfi 119b425557eSmrg 120fe24f8a2Smrg# NLS nuisances: We save the old values in case they are required later. 121fe24f8a2Smrg_G_user_locale= 122fe24f8a2Smrg_G_safe_locale= 123fe24f8a2Smrgfor _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 124ee3138f1Smrgdo 125fe24f8a2Smrg eval "if test set = \"\${$_G_var+set}\"; then 126fe24f8a2Smrg save_$_G_var=\$$_G_var 127fe24f8a2Smrg $_G_var=C 128fe24f8a2Smrg export $_G_var 129fe24f8a2Smrg _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\" 130fe24f8a2Smrg _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\" 131ee3138f1Smrg fi" 132ee3138f1Smrgdone 1338d623946Smrg# These NLS vars are set unconditionally (bootstrap issue #24). Unset those 1348d623946Smrg# in case the environment reset is needed later and the $save_* variant is not 1358d623946Smrg# defined (see the code above). 1368d623946SmrgLC_ALL=C 1378d623946SmrgLANGUAGE=C 1388d623946Smrgexport LANGUAGE LC_ALL 13934977a2fSmrg 140fe24f8a2Smrg# Make sure IFS has a sensible default 141fe24f8a2Smrgsp=' ' 142fe24f8a2Smrgnl=' 143fe24f8a2Smrg' 144fe24f8a2SmrgIFS="$sp $nl" 145fe24f8a2Smrg 146fe24f8a2Smrg# There are apparently some retarded systems that use ';' as a PATH separator! 147fe24f8a2Smrgif test "${PATH_SEPARATOR+set}" != set; then 148fe24f8a2Smrg PATH_SEPARATOR=: 149fe24f8a2Smrg (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { 150fe24f8a2Smrg (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || 151fe24f8a2Smrg PATH_SEPARATOR=';' 152fe24f8a2Smrg } 153fe24f8a2Smrgfi 15434977a2fSmrg 15534977a2fSmrg 1568d623946Smrg# func_unset VAR 1578d623946Smrg# -------------- 1588d623946Smrg# Portably unset VAR. 1598d623946Smrg# In some shells, an 'unset VAR' statement leaves a non-zero return 1608d623946Smrg# status if VAR is already unset, which might be problematic if the 1618d623946Smrg# statement is used at the end of a function (thus poisoning its return 1628d623946Smrg# value) or when 'set -e' is active (causing even a spurious abort of 1638d623946Smrg# the script in this case). 1648d623946Smrgfunc_unset () 1658d623946Smrg{ 1668d623946Smrg { eval $1=; (eval unset $1) >/dev/null 2>&1 && eval unset $1 || : ; } 1678d623946Smrg} 1688d623946Smrg 1698d623946Smrg 1708d623946Smrg# Make sure CDPATH doesn't cause `cd` commands to output the target dir. 1718d623946Smrgfunc_unset CDPATH 1728d623946Smrg 1738d623946Smrg# Make sure ${,E,F}GREP behave sanely. 1748d623946Smrgfunc_unset GREP_OPTIONS 1758d623946Smrg 17634977a2fSmrg 177fe24f8a2Smrg## ------------------------- ## 178fe24f8a2Smrg## Locate command utilities. ## 179fe24f8a2Smrg## ------------------------- ## 180fe24f8a2Smrg 181fe24f8a2Smrg 182fe24f8a2Smrg# func_executable_p FILE 183fe24f8a2Smrg# ---------------------- 184fe24f8a2Smrg# Check that FILE is an executable regular file. 185fe24f8a2Smrgfunc_executable_p () 186fe24f8a2Smrg{ 187fe24f8a2Smrg test -f "$1" && test -x "$1" 188fe24f8a2Smrg} 189fe24f8a2Smrg 190fe24f8a2Smrg 191fe24f8a2Smrg# func_path_progs PROGS_LIST CHECK_FUNC [PATH] 192fe24f8a2Smrg# -------------------------------------------- 193fe24f8a2Smrg# Search for either a program that responds to --version with output 194fe24f8a2Smrg# containing "GNU", or else returned by CHECK_FUNC otherwise, by 195fe24f8a2Smrg# trying all the directories in PATH with each of the elements of 196fe24f8a2Smrg# PROGS_LIST. 197fe24f8a2Smrg# 198fe24f8a2Smrg# CHECK_FUNC should accept the path to a candidate program, and 199fe24f8a2Smrg# set $func_check_prog_result if it truncates its output less than 200fe24f8a2Smrg# $_G_path_prog_max characters. 201fe24f8a2Smrgfunc_path_progs () 202fe24f8a2Smrg{ 203fe24f8a2Smrg _G_progs_list=$1 204fe24f8a2Smrg _G_check_func=$2 205fe24f8a2Smrg _G_PATH=${3-"$PATH"} 206fe24f8a2Smrg 207fe24f8a2Smrg _G_path_prog_max=0 208fe24f8a2Smrg _G_path_prog_found=false 209fe24f8a2Smrg _G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:} 210fe24f8a2Smrg for _G_dir in $_G_PATH; do 211fe24f8a2Smrg IFS=$_G_save_IFS 212fe24f8a2Smrg test -z "$_G_dir" && _G_dir=. 213fe24f8a2Smrg for _G_prog_name in $_G_progs_list; do 214fe24f8a2Smrg for _exeext in '' .EXE; do 215fe24f8a2Smrg _G_path_prog=$_G_dir/$_G_prog_name$_exeext 216fe24f8a2Smrg func_executable_p "$_G_path_prog" || continue 217fe24f8a2Smrg case `"$_G_path_prog" --version 2>&1` in 218fe24f8a2Smrg *GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;; 219fe24f8a2Smrg *) $_G_check_func $_G_path_prog 220fe24f8a2Smrg func_path_progs_result=$func_check_prog_result 221fe24f8a2Smrg ;; 222fe24f8a2Smrg esac 223fe24f8a2Smrg $_G_path_prog_found && break 3 224fe24f8a2Smrg done 225fe24f8a2Smrg done 226fe24f8a2Smrg done 227fe24f8a2Smrg IFS=$_G_save_IFS 228fe24f8a2Smrg test -z "$func_path_progs_result" && { 229fe24f8a2Smrg echo "no acceptable sed could be found in \$PATH" >&2 230fe24f8a2Smrg exit 1 231fe24f8a2Smrg } 232fe24f8a2Smrg} 233fe24f8a2Smrg 234fe24f8a2Smrg 235fe24f8a2Smrg# We want to be able to use the functions in this file before configure 236fe24f8a2Smrg# has figured out where the best binaries are kept, which means we have 237fe24f8a2Smrg# to search for them ourselves - except when the results are already set 238fe24f8a2Smrg# where we skip the searches. 239fe24f8a2Smrg 240fe24f8a2Smrg# Unless the user overrides by setting SED, search the path for either GNU 241fe24f8a2Smrg# sed, or the sed that truncates its output the least. 242fe24f8a2Smrgtest -z "$SED" && { 243fe24f8a2Smrg _G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ 244fe24f8a2Smrg for _G_i in 1 2 3 4 5 6 7; do 245fe24f8a2Smrg _G_sed_script=$_G_sed_script$nl$_G_sed_script 246fe24f8a2Smrg done 247fe24f8a2Smrg echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed 248fe24f8a2Smrg _G_sed_script= 249fe24f8a2Smrg 250fe24f8a2Smrg func_check_prog_sed () 251fe24f8a2Smrg { 252fe24f8a2Smrg _G_path_prog=$1 253fe24f8a2Smrg 254fe24f8a2Smrg _G_count=0 255fe24f8a2Smrg printf 0123456789 >conftest.in 256fe24f8a2Smrg while : 257fe24f8a2Smrg do 258fe24f8a2Smrg cat conftest.in conftest.in >conftest.tmp 259fe24f8a2Smrg mv conftest.tmp conftest.in 260fe24f8a2Smrg cp conftest.in conftest.nl 261fe24f8a2Smrg echo '' >> conftest.nl 262fe24f8a2Smrg "$_G_path_prog" -f conftest.sed <conftest.nl >conftest.out 2>/dev/null || break 263fe24f8a2Smrg diff conftest.out conftest.nl >/dev/null 2>&1 || break 264fe24f8a2Smrg _G_count=`expr $_G_count + 1` 265fe24f8a2Smrg if test "$_G_count" -gt "$_G_path_prog_max"; then 266fe24f8a2Smrg # Best one so far, save it but keep looking for a better one 267fe24f8a2Smrg func_check_prog_result=$_G_path_prog 268fe24f8a2Smrg _G_path_prog_max=$_G_count 269fe24f8a2Smrg fi 270fe24f8a2Smrg # 10*(2^10) chars as input seems more than enough 271fe24f8a2Smrg test 10 -lt "$_G_count" && break 272fe24f8a2Smrg done 273fe24f8a2Smrg rm -f conftest.in conftest.tmp conftest.nl conftest.out 274fe24f8a2Smrg } 275fe24f8a2Smrg 2768d623946Smrg func_path_progs "sed gsed" func_check_prog_sed "$PATH:/usr/xpg4/bin" 277fe24f8a2Smrg rm -f conftest.sed 278fe24f8a2Smrg SED=$func_path_progs_result 279fe24f8a2Smrg} 280fe24f8a2Smrg 281fe24f8a2Smrg 282fe24f8a2Smrg# Unless the user overrides by setting GREP, search the path for either GNU 283fe24f8a2Smrg# grep, or the grep that truncates its output the least. 284fe24f8a2Smrgtest -z "$GREP" && { 285fe24f8a2Smrg func_check_prog_grep () 286fe24f8a2Smrg { 287fe24f8a2Smrg _G_path_prog=$1 288fe24f8a2Smrg 289fe24f8a2Smrg _G_count=0 290fe24f8a2Smrg _G_path_prog_max=0 291fe24f8a2Smrg printf 0123456789 >conftest.in 292fe24f8a2Smrg while : 293fe24f8a2Smrg do 294fe24f8a2Smrg cat conftest.in conftest.in >conftest.tmp 295fe24f8a2Smrg mv conftest.tmp conftest.in 296fe24f8a2Smrg cp conftest.in conftest.nl 297fe24f8a2Smrg echo 'GREP' >> conftest.nl 298fe24f8a2Smrg "$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' <conftest.nl >conftest.out 2>/dev/null || break 299fe24f8a2Smrg diff conftest.out conftest.nl >/dev/null 2>&1 || break 300fe24f8a2Smrg _G_count=`expr $_G_count + 1` 301fe24f8a2Smrg if test "$_G_count" -gt "$_G_path_prog_max"; then 302fe24f8a2Smrg # Best one so far, save it but keep looking for a better one 303fe24f8a2Smrg func_check_prog_result=$_G_path_prog 304fe24f8a2Smrg _G_path_prog_max=$_G_count 305fe24f8a2Smrg fi 306fe24f8a2Smrg # 10*(2^10) chars as input seems more than enough 307fe24f8a2Smrg test 10 -lt "$_G_count" && break 308fe24f8a2Smrg done 309fe24f8a2Smrg rm -f conftest.in conftest.tmp conftest.nl conftest.out 310fe24f8a2Smrg } 311fe24f8a2Smrg 3128d623946Smrg func_path_progs "grep ggrep" func_check_prog_grep "$PATH:/usr/xpg4/bin" 313fe24f8a2Smrg GREP=$func_path_progs_result 314fe24f8a2Smrg} 315fe24f8a2Smrg 316fe24f8a2Smrg 317fe24f8a2Smrg## ------------------------------- ## 318fe24f8a2Smrg## User overridable command paths. ## 319fe24f8a2Smrg## ------------------------------- ## 320fe24f8a2Smrg 321fe24f8a2Smrg# All uppercase variable names are used for environment variables. These 322fe24f8a2Smrg# variables can be overridden by the user before calling a script that 323fe24f8a2Smrg# uses them if a suitable command of that name is not already available 324fe24f8a2Smrg# in the command search PATH. 32534977a2fSmrg 32634977a2fSmrg: ${CP="cp -f"} 327fe24f8a2Smrg: ${ECHO="printf %s\n"} 328fe24f8a2Smrg: ${EGREP="$GREP -E"} 329fe24f8a2Smrg: ${FGREP="$GREP -F"} 330fe24f8a2Smrg: ${LN_S="ln -s"} 33134977a2fSmrg: ${MAKE="make"} 33234977a2fSmrg: ${MKDIR="mkdir"} 33334977a2fSmrg: ${MV="mv -f"} 33434977a2fSmrg: ${RM="rm -f"} 33534977a2fSmrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"} 336ee3138f1Smrg 33734977a2fSmrg 338fe24f8a2Smrg## -------------------- ## 339fe24f8a2Smrg## Useful sed snippets. ## 340fe24f8a2Smrg## -------------------- ## 3413e72ca8cSmrg 342fe24f8a2Smrgsed_dirname='s|/[^/]*$||' 343fe24f8a2Smrgsed_basename='s|^.*/||' 3443e72ca8cSmrg 345fe24f8a2Smrg# Sed substitution that helps us do robust quoting. It backslashifies 346fe24f8a2Smrg# metacharacters that are still active within double-quoted strings. 347fe24f8a2Smrgsed_quote_subst='s|\([`"$\\]\)|\\\1|g' 3483e72ca8cSmrg 349fe24f8a2Smrg# Same as above, but do not quote variable references. 350fe24f8a2Smrgsed_double_quote_subst='s/\(["`\\]\)/\\\1/g' 3513e72ca8cSmrg 352fe24f8a2Smrg# Sed substitution that turns a string into a regex matching for the 353fe24f8a2Smrg# string literally. 354fe24f8a2Smrgsed_make_literal_regex='s|[].[^$\\*\/]|\\&|g' 3553e72ca8cSmrg 356fe24f8a2Smrg# Sed substitution that converts a w32 file name or path 357fe24f8a2Smrg# that contains forward slashes, into one that contains 358fe24f8a2Smrg# (escaped) backslashes. A very naive implementation. 359fe24f8a2Smrgsed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' 360fe24f8a2Smrg 361fe24f8a2Smrg# Re-'\' parameter expansions in output of sed_double_quote_subst that 362fe24f8a2Smrg# were '\'-ed in input to the same. If an odd number of '\' preceded a 363fe24f8a2Smrg# '$' in input to sed_double_quote_subst, that '$' was protected from 364fe24f8a2Smrg# expansion. Since each input '\' is now two '\'s, look for any number 365fe24f8a2Smrg# of runs of four '\'s followed by two '\'s and then a '$'. '\' that '$'. 366fe24f8a2Smrg_G_bs='\\' 367fe24f8a2Smrg_G_bs2='\\\\' 368fe24f8a2Smrg_G_bs4='\\\\\\\\' 369fe24f8a2Smrg_G_dollar='\$' 370fe24f8a2Smrgsed_double_backslash="\ 371fe24f8a2Smrg s/$_G_bs4/&\\ 372fe24f8a2Smrg/g 373fe24f8a2Smrg s/^$_G_bs2$_G_dollar/$_G_bs&/ 374fe24f8a2Smrg s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g 375fe24f8a2Smrg s/\n//g" 3763e72ca8cSmrg 3778d623946Smrg# require_check_ifs_backslash 3788d623946Smrg# --------------------------- 3798d623946Smrg# Check if we can use backslash as IFS='\' separator, and set 3808d623946Smrg# $check_ifs_backshlash_broken to ':' or 'false'. 3818d623946Smrgrequire_check_ifs_backslash=func_require_check_ifs_backslash 3828d623946Smrgfunc_require_check_ifs_backslash () 3838d623946Smrg{ 3848d623946Smrg _G_save_IFS=$IFS 3858d623946Smrg IFS='\' 3868d623946Smrg _G_check_ifs_backshlash='a\\b' 3878d623946Smrg for _G_i in $_G_check_ifs_backshlash 3888d623946Smrg do 3898d623946Smrg case $_G_i in 3908d623946Smrg a) 3918d623946Smrg check_ifs_backshlash_broken=false 3928d623946Smrg ;; 3938d623946Smrg '') 3948d623946Smrg break 3958d623946Smrg ;; 3968d623946Smrg *) 3978d623946Smrg check_ifs_backshlash_broken=: 3988d623946Smrg break 3998d623946Smrg ;; 4008d623946Smrg esac 4018d623946Smrg done 4028d623946Smrg IFS=$_G_save_IFS 4038d623946Smrg require_check_ifs_backslash=: 4048d623946Smrg} 4058d623946Smrg 406ee3138f1Smrg 407fe24f8a2Smrg## ----------------- ## 408fe24f8a2Smrg## Global variables. ## 409fe24f8a2Smrg## ----------------- ## 41034977a2fSmrg 411fe24f8a2Smrg# Except for the global variables explicitly listed below, the following 412fe24f8a2Smrg# functions in the '^func_' namespace, and the '^require_' namespace 413fe24f8a2Smrg# variables initialised in the 'Resource management' section, sourcing 414fe24f8a2Smrg# this file will not pollute your global namespace with anything 415fe24f8a2Smrg# else. There's no portable way to scope variables in Bourne shell 416fe24f8a2Smrg# though, so actually running these functions will sometimes place 417fe24f8a2Smrg# results into a variable named after the function, and often use 418fe24f8a2Smrg# temporary variables in the '^_G_' namespace. If you are careful to 419fe24f8a2Smrg# avoid using those namespaces casually in your sourcing script, things 420fe24f8a2Smrg# should continue to work as you expect. And, of course, you can freely 421fe24f8a2Smrg# overwrite any of the functions or variables defined here before 422fe24f8a2Smrg# calling anything to customize them. 423b425557eSmrg 424fe24f8a2SmrgEXIT_SUCCESS=0 425fe24f8a2SmrgEXIT_FAILURE=1 426fe24f8a2SmrgEXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. 427fe24f8a2SmrgEXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. 428b425557eSmrg 429fe24f8a2Smrg# Allow overriding, eg assuming that you follow the convention of 430fe24f8a2Smrg# putting '$debug_cmd' at the start of all your functions, you can get 431fe24f8a2Smrg# bash to show function call trace with: 432fe24f8a2Smrg# 433fe24f8a2Smrg# debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name 434fe24f8a2Smrgdebug_cmd=${debug_cmd-":"} 435fe24f8a2Smrgexit_cmd=: 436b425557eSmrg 437fe24f8a2Smrg# By convention, finish your script with: 438fe24f8a2Smrg# 439fe24f8a2Smrg# exit $exit_status 440fe24f8a2Smrg# 441fe24f8a2Smrg# so that you can set exit_status to non-zero if you want to indicate 442fe24f8a2Smrg# something went wrong during execution without actually bailing out at 443fe24f8a2Smrg# the point of failure. 444fe24f8a2Smrgexit_status=$EXIT_SUCCESS 445b425557eSmrg 446fe24f8a2Smrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh 447fe24f8a2Smrg# is ksh but when the shell is invoked as "sh" and the current value of 448fe24f8a2Smrg# the _XPG environment variable is not equal to 1 (one), the special 449fe24f8a2Smrg# positional parameter $0, within a function call, is the name of the 450fe24f8a2Smrg# function. 451fe24f8a2Smrgprogpath=$0 45234977a2fSmrg 453fe24f8a2Smrg# The name of this program. 454fe24f8a2Smrgprogname=`$ECHO "$progpath" |$SED "$sed_basename"` 45534977a2fSmrg 456fe24f8a2Smrg# Make sure we have an absolute progpath for reexecution: 45734977a2fSmrgcase $progpath in 45834977a2fSmrg [\\/]*|[A-Za-z]:\\*) ;; 45934977a2fSmrg *[\\/]*) 460fe24f8a2Smrg progdir=`$ECHO "$progpath" |$SED "$sed_dirname"` 46134977a2fSmrg progdir=`cd "$progdir" && pwd` 462fe24f8a2Smrg progpath=$progdir/$progname 46334977a2fSmrg ;; 46434977a2fSmrg *) 465fe24f8a2Smrg _G_IFS=$IFS 4663e72ca8cSmrg IFS=${PATH_SEPARATOR-:} 46734977a2fSmrg for progdir in $PATH; do 468fe24f8a2Smrg IFS=$_G_IFS 46934977a2fSmrg test -x "$progdir/$progname" && break 47034977a2fSmrg done 471fe24f8a2Smrg IFS=$_G_IFS 47234977a2fSmrg test -n "$progdir" || progdir=`pwd` 473fe24f8a2Smrg progpath=$progdir/$progname 47434977a2fSmrg ;; 47534977a2fSmrgesac 47634977a2fSmrg 47734977a2fSmrg 478fe24f8a2Smrg## ----------------- ## 479fe24f8a2Smrg## Standard options. ## 480fe24f8a2Smrg## ----------------- ## 4813e72ca8cSmrg 482fe24f8a2Smrg# The following options affect the operation of the functions defined 483fe24f8a2Smrg# below, and should be set appropriately depending on run-time para- 484fe24f8a2Smrg# meters passed on the command line. 48534977a2fSmrg 48634977a2fSmrgopt_dry_run=false 48734977a2fSmrgopt_quiet=false 48834977a2fSmrgopt_verbose=false 48934977a2fSmrg 490fe24f8a2Smrg# Categories 'all' and 'none' are always available. Append any others 491fe24f8a2Smrg# you will pass as the first argument to func_warning from your own 492fe24f8a2Smrg# code. 493fe24f8a2Smrgwarning_categories= 49434977a2fSmrg 495fe24f8a2Smrg# By default, display warnings according to 'opt_warning_types'. Set 496fe24f8a2Smrg# 'warning_func' to ':' to elide all warnings, or func_fatal_error to 497fe24f8a2Smrg# treat the next displayed warning as a fatal error. 498fe24f8a2Smrgwarning_func=func_warn_and_continue 49934977a2fSmrg 500fe24f8a2Smrg# Set to 'all' to display all warnings, 'none' to suppress all 501fe24f8a2Smrg# warnings, or a space delimited list of some subset of 502fe24f8a2Smrg# 'warning_categories' to display only the listed warnings. 503fe24f8a2Smrgopt_warning_types=all 50434977a2fSmrg 505b425557eSmrg 506fe24f8a2Smrg## -------------------- ## 507fe24f8a2Smrg## Resource management. ## 508fe24f8a2Smrg## -------------------- ## 50934977a2fSmrg 510fe24f8a2Smrg# This section contains definitions for functions that each ensure a 511fe24f8a2Smrg# particular resource (a file, or a non-empty configuration variable for 512fe24f8a2Smrg# example) is available, and if appropriate to extract default values 513fe24f8a2Smrg# from pertinent package files. Call them using their associated 514fe24f8a2Smrg# 'require_*' variable to ensure that they are executed, at most, once. 515fe24f8a2Smrg# 516fe24f8a2Smrg# It's entirely deliberate that calling these functions can set 517fe24f8a2Smrg# variables that don't obey the namespace limitations obeyed by the rest 518fe24f8a2Smrg# of this file, in order that that they be as useful as possible to 519fe24f8a2Smrg# callers. 52034977a2fSmrg 52134977a2fSmrg 522fe24f8a2Smrg# require_term_colors 523fe24f8a2Smrg# ------------------- 524fe24f8a2Smrg# Allow display of bold text on terminals that support it. 525fe24f8a2Smrgrequire_term_colors=func_require_term_colors 526fe24f8a2Smrgfunc_require_term_colors () 52734977a2fSmrg{ 528fe24f8a2Smrg $debug_cmd 529fe24f8a2Smrg 530fe24f8a2Smrg test -t 1 && { 531fe24f8a2Smrg # COLORTERM and USE_ANSI_COLORS environment variables take 532fe24f8a2Smrg # precedence, because most terminfo databases neglect to describe 533fe24f8a2Smrg # whether color sequences are supported. 534fe24f8a2Smrg test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"} 535fe24f8a2Smrg 536fe24f8a2Smrg if test 1 = "$USE_ANSI_COLORS"; then 537fe24f8a2Smrg # Standard ANSI escape sequences 538fe24f8a2Smrg tc_reset='[0m' 539fe24f8a2Smrg tc_bold='[1m'; tc_standout='[7m' 540fe24f8a2Smrg tc_red='[31m'; tc_green='[32m' 541fe24f8a2Smrg tc_blue='[34m'; tc_cyan='[36m' 542fe24f8a2Smrg else 543fe24f8a2Smrg # Otherwise trust the terminfo database after all. 544fe24f8a2Smrg test -n "`tput sgr0 2>/dev/null`" && { 545fe24f8a2Smrg tc_reset=`tput sgr0` 546fe24f8a2Smrg test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold` 547fe24f8a2Smrg tc_standout=$tc_bold 548fe24f8a2Smrg test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso` 549fe24f8a2Smrg test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1` 550fe24f8a2Smrg test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2` 551fe24f8a2Smrg test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4` 552fe24f8a2Smrg test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5` 553fe24f8a2Smrg } 554fe24f8a2Smrg fi 555fe24f8a2Smrg } 55634977a2fSmrg 557fe24f8a2Smrg require_term_colors=: 55834977a2fSmrg} 55934977a2fSmrg 56034977a2fSmrg 561fe24f8a2Smrg## ----------------- ## 562fe24f8a2Smrg## Function library. ## 563fe24f8a2Smrg## ----------------- ## 564fe24f8a2Smrg 565fe24f8a2Smrg# This section contains a variety of useful functions to call in your 566fe24f8a2Smrg# scripts. Take note of the portable wrappers for features provided by 567fe24f8a2Smrg# some modern shells, which will fall back to slower equivalents on 568fe24f8a2Smrg# less featureful shells. 569fe24f8a2Smrg 570fe24f8a2Smrg 571fe24f8a2Smrg# func_append VAR VALUE 572fe24f8a2Smrg# --------------------- 573fe24f8a2Smrg# Append VALUE onto the existing contents of VAR. 574fe24f8a2Smrg 575fe24f8a2Smrg # We should try to minimise forks, especially on Windows where they are 576fe24f8a2Smrg # unreasonably slow, so skip the feature probes when bash or zsh are 577fe24f8a2Smrg # being used: 578fe24f8a2Smrg if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then 579fe24f8a2Smrg : ${_G_HAVE_ARITH_OP="yes"} 580fe24f8a2Smrg : ${_G_HAVE_XSI_OPS="yes"} 581fe24f8a2Smrg # The += operator was introduced in bash 3.1 582fe24f8a2Smrg case $BASH_VERSION in 583fe24f8a2Smrg [12].* | 3.0 | 3.0*) ;; 584fe24f8a2Smrg *) 585fe24f8a2Smrg : ${_G_HAVE_PLUSEQ_OP="yes"} 586fe24f8a2Smrg ;; 587fe24f8a2Smrg esac 588fe24f8a2Smrg fi 589fe24f8a2Smrg 590fe24f8a2Smrg # _G_HAVE_PLUSEQ_OP 591fe24f8a2Smrg # Can be empty, in which case the shell is probed, "yes" if += is 592fe24f8a2Smrg # useable or anything else if it does not work. 593fe24f8a2Smrg test -z "$_G_HAVE_PLUSEQ_OP" \ 594fe24f8a2Smrg && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \ 595fe24f8a2Smrg && _G_HAVE_PLUSEQ_OP=yes 596fe24f8a2Smrg 597fe24f8a2Smrgif test yes = "$_G_HAVE_PLUSEQ_OP" 598fe24f8a2Smrgthen 599fe24f8a2Smrg # This is an XSI compatible shell, allowing a faster implementation... 600fe24f8a2Smrg eval 'func_append () 601fe24f8a2Smrg { 602fe24f8a2Smrg $debug_cmd 603fe24f8a2Smrg 604fe24f8a2Smrg eval "$1+=\$2" 605fe24f8a2Smrg }' 606fe24f8a2Smrgelse 607fe24f8a2Smrg # ...otherwise fall back to using expr, which is often a shell builtin. 608fe24f8a2Smrg func_append () 609fe24f8a2Smrg { 610fe24f8a2Smrg $debug_cmd 611fe24f8a2Smrg 612fe24f8a2Smrg eval "$1=\$$1\$2" 613fe24f8a2Smrg } 614fe24f8a2Smrgfi 615fe24f8a2Smrg 616fe24f8a2Smrg 617fe24f8a2Smrg# func_append_quoted VAR VALUE 618fe24f8a2Smrg# ---------------------------- 619fe24f8a2Smrg# Quote VALUE and append to the end of shell variable VAR, separated 620fe24f8a2Smrg# by a space. 621fe24f8a2Smrgif test yes = "$_G_HAVE_PLUSEQ_OP"; then 622fe24f8a2Smrg eval 'func_append_quoted () 623fe24f8a2Smrg { 624fe24f8a2Smrg $debug_cmd 625fe24f8a2Smrg 6268d623946Smrg func_quote_arg pretty "$2" 6278d623946Smrg eval "$1+=\\ \$func_quote_arg_result" 628fe24f8a2Smrg }' 629fe24f8a2Smrgelse 630fe24f8a2Smrg func_append_quoted () 631fe24f8a2Smrg { 632fe24f8a2Smrg $debug_cmd 633fe24f8a2Smrg 6348d623946Smrg func_quote_arg pretty "$2" 6358d623946Smrg eval "$1=\$$1\\ \$func_quote_arg_result" 636fe24f8a2Smrg } 637fe24f8a2Smrgfi 638fe24f8a2Smrg 639fe24f8a2Smrg 640fe24f8a2Smrg# func_append_uniq VAR VALUE 641fe24f8a2Smrg# -------------------------- 642fe24f8a2Smrg# Append unique VALUE onto the existing contents of VAR, assuming 643fe24f8a2Smrg# entries are delimited by the first character of VALUE. For example: 644fe24f8a2Smrg# 645fe24f8a2Smrg# func_append_uniq options " --another-option option-argument" 646fe24f8a2Smrg# 647fe24f8a2Smrg# will only append to $options if " --another-option option-argument " 648fe24f8a2Smrg# is not already present somewhere in $options already (note spaces at 649fe24f8a2Smrg# each end implied by leading space in second argument). 650fe24f8a2Smrgfunc_append_uniq () 651fe24f8a2Smrg{ 652fe24f8a2Smrg $debug_cmd 653fe24f8a2Smrg 654fe24f8a2Smrg eval _G_current_value='`$ECHO $'$1'`' 655fe24f8a2Smrg _G_delim=`expr "$2" : '\(.\)'` 656fe24f8a2Smrg 657fe24f8a2Smrg case $_G_delim$_G_current_value$_G_delim in 658fe24f8a2Smrg *"$2$_G_delim"*) ;; 659fe24f8a2Smrg *) func_append "$@" ;; 660fe24f8a2Smrg esac 661fe24f8a2Smrg} 662fe24f8a2Smrg 663fe24f8a2Smrg 664fe24f8a2Smrg# func_arith TERM... 665fe24f8a2Smrg# ------------------ 666fe24f8a2Smrg# Set func_arith_result to the result of evaluating TERMs. 667fe24f8a2Smrg test -z "$_G_HAVE_ARITH_OP" \ 668fe24f8a2Smrg && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \ 669fe24f8a2Smrg && _G_HAVE_ARITH_OP=yes 670fe24f8a2Smrg 671fe24f8a2Smrgif test yes = "$_G_HAVE_ARITH_OP"; then 672fe24f8a2Smrg eval 'func_arith () 673fe24f8a2Smrg { 674fe24f8a2Smrg $debug_cmd 675fe24f8a2Smrg 676fe24f8a2Smrg func_arith_result=$(( $* )) 677fe24f8a2Smrg }' 678fe24f8a2Smrgelse 679fe24f8a2Smrg func_arith () 680fe24f8a2Smrg { 681fe24f8a2Smrg $debug_cmd 682fe24f8a2Smrg 683fe24f8a2Smrg func_arith_result=`expr "$@"` 684fe24f8a2Smrg } 685fe24f8a2Smrgfi 686fe24f8a2Smrg 687fe24f8a2Smrg 688fe24f8a2Smrg# func_basename FILE 689fe24f8a2Smrg# ------------------ 690fe24f8a2Smrg# Set func_basename_result to FILE with everything up to and including 691fe24f8a2Smrg# the last / stripped. 692fe24f8a2Smrgif test yes = "$_G_HAVE_XSI_OPS"; then 693fe24f8a2Smrg # If this shell supports suffix pattern removal, then use it to avoid 694fe24f8a2Smrg # forking. Hide the definitions single quotes in case the shell chokes 695fe24f8a2Smrg # on unsupported syntax... 696fe24f8a2Smrg _b='func_basename_result=${1##*/}' 697fe24f8a2Smrg _d='case $1 in 698fe24f8a2Smrg */*) func_dirname_result=${1%/*}$2 ;; 699fe24f8a2Smrg * ) func_dirname_result=$3 ;; 700fe24f8a2Smrg esac' 701fe24f8a2Smrg 702fe24f8a2Smrgelse 703fe24f8a2Smrg # ...otherwise fall back to using sed. 704fe24f8a2Smrg _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`' 705fe24f8a2Smrg _d='func_dirname_result=`$ECHO "$1" |$SED "$sed_dirname"` 706fe24f8a2Smrg if test "X$func_dirname_result" = "X$1"; then 707fe24f8a2Smrg func_dirname_result=$3 708fe24f8a2Smrg else 709fe24f8a2Smrg func_append func_dirname_result "$2" 710fe24f8a2Smrg fi' 711fe24f8a2Smrgfi 712fe24f8a2Smrg 713fe24f8a2Smrgeval 'func_basename () 714fe24f8a2Smrg{ 715fe24f8a2Smrg $debug_cmd 716fe24f8a2Smrg 717fe24f8a2Smrg '"$_b"' 718fe24f8a2Smrg}' 719fe24f8a2Smrg 720fe24f8a2Smrg 721fe24f8a2Smrg# func_dirname FILE APPEND NONDIR_REPLACEMENT 722fe24f8a2Smrg# ------------------------------------------- 723fe24f8a2Smrg# Compute the dirname of FILE. If nonempty, add APPEND to the result, 724fe24f8a2Smrg# otherwise set result to NONDIR_REPLACEMENT. 725fe24f8a2Smrgeval 'func_dirname () 726fe24f8a2Smrg{ 727fe24f8a2Smrg $debug_cmd 728fe24f8a2Smrg 729fe24f8a2Smrg '"$_d"' 730fe24f8a2Smrg}' 731fe24f8a2Smrg 732fe24f8a2Smrg 733fe24f8a2Smrg# func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT 734fe24f8a2Smrg# -------------------------------------------------------- 735fe24f8a2Smrg# Perform func_basename and func_dirname in a single function 736fe24f8a2Smrg# call: 737fe24f8a2Smrg# dirname: Compute the dirname of FILE. If nonempty, 738fe24f8a2Smrg# add APPEND to the result, otherwise set result 739fe24f8a2Smrg# to NONDIR_REPLACEMENT. 740fe24f8a2Smrg# value returned in "$func_dirname_result" 741fe24f8a2Smrg# basename: Compute filename of FILE. 742fe24f8a2Smrg# value retuned in "$func_basename_result" 743fe24f8a2Smrg# For efficiency, we do not delegate to the functions above but instead 744fe24f8a2Smrg# duplicate the functionality here. 745fe24f8a2Smrgeval 'func_dirname_and_basename () 746fe24f8a2Smrg{ 747fe24f8a2Smrg $debug_cmd 748fe24f8a2Smrg 749fe24f8a2Smrg '"$_b"' 750fe24f8a2Smrg '"$_d"' 751fe24f8a2Smrg}' 752fe24f8a2Smrg 753fe24f8a2Smrg 754fe24f8a2Smrg# func_echo ARG... 755fe24f8a2Smrg# ---------------- 756fe24f8a2Smrg# Echo program name prefixed message. 757fe24f8a2Smrgfunc_echo () 758fe24f8a2Smrg{ 759fe24f8a2Smrg $debug_cmd 760fe24f8a2Smrg 761fe24f8a2Smrg _G_message=$* 762fe24f8a2Smrg 763fe24f8a2Smrg func_echo_IFS=$IFS 764fe24f8a2Smrg IFS=$nl 765fe24f8a2Smrg for _G_line in $_G_message; do 766fe24f8a2Smrg IFS=$func_echo_IFS 767fe24f8a2Smrg $ECHO "$progname: $_G_line" 768fe24f8a2Smrg done 769fe24f8a2Smrg IFS=$func_echo_IFS 770fe24f8a2Smrg} 771fe24f8a2Smrg 772fe24f8a2Smrg 773fe24f8a2Smrg# func_echo_all ARG... 774fe24f8a2Smrg# -------------------- 775fe24f8a2Smrg# Invoke $ECHO with all args, space-separated. 776fe24f8a2Smrgfunc_echo_all () 777fe24f8a2Smrg{ 778fe24f8a2Smrg $ECHO "$*" 779fe24f8a2Smrg} 780fe24f8a2Smrg 781fe24f8a2Smrg 782fe24f8a2Smrg# func_echo_infix_1 INFIX ARG... 783fe24f8a2Smrg# ------------------------------ 784fe24f8a2Smrg# Echo program name, followed by INFIX on the first line, with any 785fe24f8a2Smrg# additional lines not showing INFIX. 786fe24f8a2Smrgfunc_echo_infix_1 () 787fe24f8a2Smrg{ 788fe24f8a2Smrg $debug_cmd 789fe24f8a2Smrg 790fe24f8a2Smrg $require_term_colors 791fe24f8a2Smrg 792fe24f8a2Smrg _G_infix=$1; shift 793fe24f8a2Smrg _G_indent=$_G_infix 794fe24f8a2Smrg _G_prefix="$progname: $_G_infix: " 795fe24f8a2Smrg _G_message=$* 796fe24f8a2Smrg 797fe24f8a2Smrg # Strip color escape sequences before counting printable length 798fe24f8a2Smrg for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan" 799fe24f8a2Smrg do 800fe24f8a2Smrg test -n "$_G_tc" && { 801fe24f8a2Smrg _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"` 802fe24f8a2Smrg _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"` 803fe24f8a2Smrg } 804fe24f8a2Smrg done 805fe24f8a2Smrg _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`" " ## exclude from sc_prohibit_nested_quotes 806fe24f8a2Smrg 807fe24f8a2Smrg func_echo_infix_1_IFS=$IFS 808fe24f8a2Smrg IFS=$nl 809fe24f8a2Smrg for _G_line in $_G_message; do 810fe24f8a2Smrg IFS=$func_echo_infix_1_IFS 811fe24f8a2Smrg $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2 812fe24f8a2Smrg _G_prefix=$_G_indent 813fe24f8a2Smrg done 814fe24f8a2Smrg IFS=$func_echo_infix_1_IFS 815fe24f8a2Smrg} 816fe24f8a2Smrg 817fe24f8a2Smrg 818fe24f8a2Smrg# func_error ARG... 819fe24f8a2Smrg# ----------------- 820fe24f8a2Smrg# Echo program name prefixed message to standard error. 821fe24f8a2Smrgfunc_error () 822fe24f8a2Smrg{ 823fe24f8a2Smrg $debug_cmd 824fe24f8a2Smrg 825fe24f8a2Smrg $require_term_colors 826fe24f8a2Smrg 827fe24f8a2Smrg func_echo_infix_1 " $tc_standout${tc_red}error$tc_reset" "$*" >&2 828fe24f8a2Smrg} 829fe24f8a2Smrg 830fe24f8a2Smrg 831fe24f8a2Smrg# func_fatal_error ARG... 832fe24f8a2Smrg# ----------------------- 833fe24f8a2Smrg# Echo program name prefixed message to standard error, and exit. 834fe24f8a2Smrgfunc_fatal_error () 835fe24f8a2Smrg{ 836fe24f8a2Smrg $debug_cmd 837fe24f8a2Smrg 838fe24f8a2Smrg func_error "$*" 839fe24f8a2Smrg exit $EXIT_FAILURE 840fe24f8a2Smrg} 841fe24f8a2Smrg 842fe24f8a2Smrg 843fe24f8a2Smrg# func_grep EXPRESSION FILENAME 844fe24f8a2Smrg# ----------------------------- 84534977a2fSmrg# Check whether EXPRESSION matches any line of FILENAME, without output. 84634977a2fSmrgfunc_grep () 84734977a2fSmrg{ 848fe24f8a2Smrg $debug_cmd 849fe24f8a2Smrg 85034977a2fSmrg $GREP "$1" "$2" >/dev/null 2>&1 85134977a2fSmrg} 85234977a2fSmrg 85334977a2fSmrg 854fe24f8a2Smrg# func_len STRING 855fe24f8a2Smrg# --------------- 856fe24f8a2Smrg# Set func_len_result to the length of STRING. STRING may not 857fe24f8a2Smrg# start with a hyphen. 858fe24f8a2Smrg test -z "$_G_HAVE_XSI_OPS" \ 859fe24f8a2Smrg && (eval 'x=a/b/c; 860fe24f8a2Smrg test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ 861fe24f8a2Smrg && _G_HAVE_XSI_OPS=yes 862fe24f8a2Smrg 863fe24f8a2Smrgif test yes = "$_G_HAVE_XSI_OPS"; then 864fe24f8a2Smrg eval 'func_len () 865fe24f8a2Smrg { 866fe24f8a2Smrg $debug_cmd 867fe24f8a2Smrg 868fe24f8a2Smrg func_len_result=${#1} 869fe24f8a2Smrg }' 870fe24f8a2Smrgelse 871fe24f8a2Smrg func_len () 872fe24f8a2Smrg { 873fe24f8a2Smrg $debug_cmd 874fe24f8a2Smrg 875fe24f8a2Smrg func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len` 876fe24f8a2Smrg } 877fe24f8a2Smrgfi 878fe24f8a2Smrg 879fe24f8a2Smrg 880fe24f8a2Smrg# func_mkdir_p DIRECTORY-PATH 881fe24f8a2Smrg# --------------------------- 88234977a2fSmrg# Make sure the entire path to DIRECTORY-PATH is available. 88334977a2fSmrgfunc_mkdir_p () 88434977a2fSmrg{ 885fe24f8a2Smrg $debug_cmd 88634977a2fSmrg 887fe24f8a2Smrg _G_directory_path=$1 888fe24f8a2Smrg _G_dir_list= 88934977a2fSmrg 890fe24f8a2Smrg if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then 891fe24f8a2Smrg 892fe24f8a2Smrg # Protect directory names starting with '-' 893fe24f8a2Smrg case $_G_directory_path in 894fe24f8a2Smrg -*) _G_directory_path=./$_G_directory_path ;; 89534977a2fSmrg esac 89634977a2fSmrg 89734977a2fSmrg # While some portion of DIR does not yet exist... 898fe24f8a2Smrg while test ! -d "$_G_directory_path"; do 89934977a2fSmrg # ...make a list in topmost first order. Use a colon delimited 90034977a2fSmrg # list incase some portion of path contains whitespace. 901fe24f8a2Smrg _G_dir_list=$_G_directory_path:$_G_dir_list 90234977a2fSmrg 90334977a2fSmrg # If the last portion added has no slash in it, the list is done 904fe24f8a2Smrg case $_G_directory_path in */*) ;; *) break ;; esac 90534977a2fSmrg 90634977a2fSmrg # ...otherwise throw away the child directory and loop 907fe24f8a2Smrg _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"` 90834977a2fSmrg done 909fe24f8a2Smrg _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'` 91034977a2fSmrg 911fe24f8a2Smrg func_mkdir_p_IFS=$IFS; IFS=: 912fe24f8a2Smrg for _G_dir in $_G_dir_list; do 913fe24f8a2Smrg IFS=$func_mkdir_p_IFS 914fe24f8a2Smrg # mkdir can fail with a 'File exist' error if two processes 91534977a2fSmrg # try to create one of the directories concurrently. Don't 91634977a2fSmrg # stop in that case! 917fe24f8a2Smrg $MKDIR "$_G_dir" 2>/dev/null || : 91834977a2fSmrg done 919fe24f8a2Smrg IFS=$func_mkdir_p_IFS 92034977a2fSmrg 92134977a2fSmrg # Bail out if we (or some other process) failed to create a directory. 922fe24f8a2Smrg test -d "$_G_directory_path" || \ 923fe24f8a2Smrg func_fatal_error "Failed to create '$1'" 92434977a2fSmrg fi 92534977a2fSmrg} 926ee3138f1Smrg 927ee3138f1Smrg 928fe24f8a2Smrg# func_mktempdir [BASENAME] 929fe24f8a2Smrg# ------------------------- 930ee3138f1Smrg# Make a temporary directory that won't clash with other running 931ee3138f1Smrg# libtool processes, and avoids race conditions if possible. If 932fe24f8a2Smrg# given, BASENAME is the basename for that directory. 933ee3138f1Smrgfunc_mktempdir () 934ee3138f1Smrg{ 935fe24f8a2Smrg $debug_cmd 936fe24f8a2Smrg 937fe24f8a2Smrg _G_template=${TMPDIR-/tmp}/${1-$progname} 938ee3138f1Smrg 939fe24f8a2Smrg if test : = "$opt_dry_run"; then 940ee3138f1Smrg # Return a directory name, but don't create it in dry-run mode 941fe24f8a2Smrg _G_tmpdir=$_G_template-$$ 942ee3138f1Smrg else 943ee3138f1Smrg 944ee3138f1Smrg # If mktemp works, use that first and foremost 945fe24f8a2Smrg _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null` 946ee3138f1Smrg 947fe24f8a2Smrg if test ! -d "$_G_tmpdir"; then 94834977a2fSmrg # Failing that, at least try and use $RANDOM to avoid a race 949fe24f8a2Smrg _G_tmpdir=$_G_template-${RANDOM-0}$$ 950ee3138f1Smrg 951fe24f8a2Smrg func_mktempdir_umask=`umask` 95234977a2fSmrg umask 0077 953fe24f8a2Smrg $MKDIR "$_G_tmpdir" 954fe24f8a2Smrg umask $func_mktempdir_umask 955ee3138f1Smrg fi 956ee3138f1Smrg 957ee3138f1Smrg # If we're not in dry-run mode, bomb out on failure 958fe24f8a2Smrg test -d "$_G_tmpdir" || \ 959fe24f8a2Smrg func_fatal_error "cannot create temporary directory '$_G_tmpdir'" 960fe24f8a2Smrg fi 961fe24f8a2Smrg 962fe24f8a2Smrg $ECHO "$_G_tmpdir" 963fe24f8a2Smrg} 964fe24f8a2Smrg 965fe24f8a2Smrg 966fe24f8a2Smrg# func_normal_abspath PATH 967fe24f8a2Smrg# ------------------------ 968fe24f8a2Smrg# Remove doubled-up and trailing slashes, "." path components, 969fe24f8a2Smrg# and cancel out any ".." path components in PATH after making 970fe24f8a2Smrg# it an absolute path. 971fe24f8a2Smrgfunc_normal_abspath () 972fe24f8a2Smrg{ 973fe24f8a2Smrg $debug_cmd 974fe24f8a2Smrg 975fe24f8a2Smrg # These SED scripts presuppose an absolute path with a trailing slash. 976fe24f8a2Smrg _G_pathcar='s|^/\([^/]*\).*$|\1|' 977fe24f8a2Smrg _G_pathcdr='s|^/[^/]*||' 978fe24f8a2Smrg _G_removedotparts=':dotsl 979fe24f8a2Smrg s|/\./|/|g 980fe24f8a2Smrg t dotsl 981fe24f8a2Smrg s|/\.$|/|' 982fe24f8a2Smrg _G_collapseslashes='s|/\{1,\}|/|g' 983fe24f8a2Smrg _G_finalslash='s|/*$|/|' 984fe24f8a2Smrg 985fe24f8a2Smrg # Start from root dir and reassemble the path. 986fe24f8a2Smrg func_normal_abspath_result= 987fe24f8a2Smrg func_normal_abspath_tpath=$1 988fe24f8a2Smrg func_normal_abspath_altnamespace= 989fe24f8a2Smrg case $func_normal_abspath_tpath in 990fe24f8a2Smrg "") 991fe24f8a2Smrg # Empty path, that just means $cwd. 992fe24f8a2Smrg func_stripname '' '/' "`pwd`" 993fe24f8a2Smrg func_normal_abspath_result=$func_stripname_result 994fe24f8a2Smrg return 995fe24f8a2Smrg ;; 996fe24f8a2Smrg # The next three entries are used to spot a run of precisely 997fe24f8a2Smrg # two leading slashes without using negated character classes; 998fe24f8a2Smrg # we take advantage of case's first-match behaviour. 999fe24f8a2Smrg ///*) 1000fe24f8a2Smrg # Unusual form of absolute path, do nothing. 1001fe24f8a2Smrg ;; 1002fe24f8a2Smrg //*) 1003fe24f8a2Smrg # Not necessarily an ordinary path; POSIX reserves leading '//' 1004fe24f8a2Smrg # and for example Cygwin uses it to access remote file shares 1005fe24f8a2Smrg # over CIFS/SMB, so we conserve a leading double slash if found. 1006fe24f8a2Smrg func_normal_abspath_altnamespace=/ 1007fe24f8a2Smrg ;; 1008fe24f8a2Smrg /*) 1009fe24f8a2Smrg # Absolute path, do nothing. 1010fe24f8a2Smrg ;; 1011fe24f8a2Smrg *) 1012fe24f8a2Smrg # Relative path, prepend $cwd. 1013fe24f8a2Smrg func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath 1014fe24f8a2Smrg ;; 1015fe24f8a2Smrg esac 1016fe24f8a2Smrg 1017fe24f8a2Smrg # Cancel out all the simple stuff to save iterations. We also want 1018fe24f8a2Smrg # the path to end with a slash for ease of parsing, so make sure 1019fe24f8a2Smrg # there is one (and only one) here. 1020fe24f8a2Smrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 1021fe24f8a2Smrg -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"` 1022fe24f8a2Smrg while :; do 1023fe24f8a2Smrg # Processed it all yet? 1024fe24f8a2Smrg if test / = "$func_normal_abspath_tpath"; then 1025fe24f8a2Smrg # If we ascended to the root using ".." the result may be empty now. 1026fe24f8a2Smrg if test -z "$func_normal_abspath_result"; then 1027fe24f8a2Smrg func_normal_abspath_result=/ 1028fe24f8a2Smrg fi 1029fe24f8a2Smrg break 1030fe24f8a2Smrg fi 1031fe24f8a2Smrg func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ 1032fe24f8a2Smrg -e "$_G_pathcar"` 1033fe24f8a2Smrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 1034fe24f8a2Smrg -e "$_G_pathcdr"` 1035fe24f8a2Smrg # Figure out what to do with it 1036fe24f8a2Smrg case $func_normal_abspath_tcomponent in 1037fe24f8a2Smrg "") 1038fe24f8a2Smrg # Trailing empty path component, ignore it. 1039fe24f8a2Smrg ;; 1040fe24f8a2Smrg ..) 1041fe24f8a2Smrg # Parent dir; strip last assembled component from result. 1042fe24f8a2Smrg func_dirname "$func_normal_abspath_result" 1043fe24f8a2Smrg func_normal_abspath_result=$func_dirname_result 1044fe24f8a2Smrg ;; 1045fe24f8a2Smrg *) 1046fe24f8a2Smrg # Actual path component, append it. 1047fe24f8a2Smrg func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent" 1048fe24f8a2Smrg ;; 1049fe24f8a2Smrg esac 1050fe24f8a2Smrg done 1051fe24f8a2Smrg # Restore leading double-slash if one was found on entry. 1052fe24f8a2Smrg func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result 1053fe24f8a2Smrg} 1054fe24f8a2Smrg 1055fe24f8a2Smrg 1056fe24f8a2Smrg# func_notquiet ARG... 1057fe24f8a2Smrg# -------------------- 1058fe24f8a2Smrg# Echo program name prefixed message only when not in quiet mode. 1059fe24f8a2Smrgfunc_notquiet () 1060fe24f8a2Smrg{ 1061fe24f8a2Smrg $debug_cmd 1062fe24f8a2Smrg 1063fe24f8a2Smrg $opt_quiet || func_echo ${1+"$@"} 1064fe24f8a2Smrg 1065fe24f8a2Smrg # A bug in bash halts the script if the last line of a function 1066fe24f8a2Smrg # fails when set -e is in force, so we need another command to 1067fe24f8a2Smrg # work around that: 1068fe24f8a2Smrg : 1069fe24f8a2Smrg} 1070fe24f8a2Smrg 1071fe24f8a2Smrg 1072fe24f8a2Smrg# func_relative_path SRCDIR DSTDIR 1073fe24f8a2Smrg# -------------------------------- 1074fe24f8a2Smrg# Set func_relative_path_result to the relative path from SRCDIR to DSTDIR. 1075fe24f8a2Smrgfunc_relative_path () 1076fe24f8a2Smrg{ 1077fe24f8a2Smrg $debug_cmd 1078fe24f8a2Smrg 1079fe24f8a2Smrg func_relative_path_result= 1080fe24f8a2Smrg func_normal_abspath "$1" 1081fe24f8a2Smrg func_relative_path_tlibdir=$func_normal_abspath_result 1082fe24f8a2Smrg func_normal_abspath "$2" 1083fe24f8a2Smrg func_relative_path_tbindir=$func_normal_abspath_result 1084fe24f8a2Smrg 1085fe24f8a2Smrg # Ascend the tree starting from libdir 1086fe24f8a2Smrg while :; do 1087fe24f8a2Smrg # check if we have found a prefix of bindir 1088fe24f8a2Smrg case $func_relative_path_tbindir in 1089fe24f8a2Smrg $func_relative_path_tlibdir) 1090fe24f8a2Smrg # found an exact match 1091fe24f8a2Smrg func_relative_path_tcancelled= 1092fe24f8a2Smrg break 1093fe24f8a2Smrg ;; 1094fe24f8a2Smrg $func_relative_path_tlibdir*) 1095fe24f8a2Smrg # found a matching prefix 1096fe24f8a2Smrg func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" 1097fe24f8a2Smrg func_relative_path_tcancelled=$func_stripname_result 1098fe24f8a2Smrg if test -z "$func_relative_path_result"; then 1099fe24f8a2Smrg func_relative_path_result=. 1100fe24f8a2Smrg fi 1101fe24f8a2Smrg break 1102fe24f8a2Smrg ;; 1103fe24f8a2Smrg *) 1104fe24f8a2Smrg func_dirname $func_relative_path_tlibdir 1105fe24f8a2Smrg func_relative_path_tlibdir=$func_dirname_result 1106fe24f8a2Smrg if test -z "$func_relative_path_tlibdir"; then 1107fe24f8a2Smrg # Have to descend all the way to the root! 1108fe24f8a2Smrg func_relative_path_result=../$func_relative_path_result 1109fe24f8a2Smrg func_relative_path_tcancelled=$func_relative_path_tbindir 1110fe24f8a2Smrg break 1111fe24f8a2Smrg fi 1112fe24f8a2Smrg func_relative_path_result=../$func_relative_path_result 1113fe24f8a2Smrg ;; 1114fe24f8a2Smrg esac 1115fe24f8a2Smrg done 1116fe24f8a2Smrg 1117fe24f8a2Smrg # Now calculate path; take care to avoid doubling-up slashes. 1118fe24f8a2Smrg func_stripname '' '/' "$func_relative_path_result" 1119fe24f8a2Smrg func_relative_path_result=$func_stripname_result 1120fe24f8a2Smrg func_stripname '/' '/' "$func_relative_path_tcancelled" 1121fe24f8a2Smrg if test -n "$func_stripname_result"; then 1122fe24f8a2Smrg func_append func_relative_path_result "/$func_stripname_result" 1123fe24f8a2Smrg fi 1124fe24f8a2Smrg 1125fe24f8a2Smrg # Normalisation. If bindir is libdir, return '.' else relative path. 1126fe24f8a2Smrg if test -n "$func_relative_path_result"; then 1127fe24f8a2Smrg func_stripname './' '' "$func_relative_path_result" 1128fe24f8a2Smrg func_relative_path_result=$func_stripname_result 1129ee3138f1Smrg fi 1130ee3138f1Smrg 1131fe24f8a2Smrg test -n "$func_relative_path_result" || func_relative_path_result=. 1132fe24f8a2Smrg 1133fe24f8a2Smrg : 1134fe24f8a2Smrg} 1135fe24f8a2Smrg 1136fe24f8a2Smrg 11378d623946Smrg# func_quote_portable EVAL ARG 11388d623946Smrg# ---------------------------- 11398d623946Smrg# Internal function to portably implement func_quote_arg. Note that we still 11408d623946Smrg# keep attention to performance here so we as much as possible try to avoid 11418d623946Smrg# calling sed binary (so far O(N) complexity as long as func_append is O(1)). 11428d623946Smrgfunc_quote_portable () 1143fe24f8a2Smrg{ 1144fe24f8a2Smrg $debug_cmd 1145fe24f8a2Smrg 11468d623946Smrg $require_check_ifs_backslash 11478d623946Smrg 11488d623946Smrg func_quote_portable_result=$2 11498d623946Smrg 11508d623946Smrg # one-time-loop (easy break) 11518d623946Smrg while true 11528d623946Smrg do 11538d623946Smrg if $1; then 11548d623946Smrg func_quote_portable_result=`$ECHO "$2" | $SED \ 11558d623946Smrg -e "$sed_double_quote_subst" -e "$sed_double_backslash"` 11568d623946Smrg break 1157fe24f8a2Smrg fi 1158fe24f8a2Smrg 11598d623946Smrg # Quote for eval. 11608d623946Smrg case $func_quote_portable_result in 11618d623946Smrg *[\\\`\"\$]*) 11628d623946Smrg # Fallback to sed for $func_check_bs_ifs_broken=:, or when the string 11638d623946Smrg # contains the shell wildcard characters. 11648d623946Smrg case $check_ifs_backshlash_broken$func_quote_portable_result in 11658d623946Smrg :*|*[\[\*\?]*) 11668d623946Smrg func_quote_portable_result=`$ECHO "$func_quote_portable_result" \ 11678d623946Smrg | $SED "$sed_quote_subst"` 11688d623946Smrg break 11698d623946Smrg ;; 11708d623946Smrg esac 11718d623946Smrg 11728d623946Smrg func_quote_portable_old_IFS=$IFS 11738d623946Smrg for _G_char in '\' '`' '"' '$' 11748d623946Smrg do 11758d623946Smrg # STATE($1) PREV($2) SEPARATOR($3) 11768d623946Smrg set start "" "" 11778d623946Smrg func_quote_portable_result=dummy"$_G_char$func_quote_portable_result$_G_char"dummy 11788d623946Smrg IFS=$_G_char 11798d623946Smrg for _G_part in $func_quote_portable_result 11808d623946Smrg do 11818d623946Smrg case $1 in 11828d623946Smrg quote) 11838d623946Smrg func_append func_quote_portable_result "$3$2" 11848d623946Smrg set quote "$_G_part" "\\$_G_char" 11858d623946Smrg ;; 11868d623946Smrg start) 11878d623946Smrg set first "" "" 11888d623946Smrg func_quote_portable_result= 11898d623946Smrg ;; 11908d623946Smrg first) 11918d623946Smrg set quote "$_G_part" "" 11928d623946Smrg ;; 11938d623946Smrg esac 11948d623946Smrg done 11958d623946Smrg done 11968d623946Smrg IFS=$func_quote_portable_old_IFS 1197fe24f8a2Smrg ;; 11988d623946Smrg *) ;; 1199fe24f8a2Smrg esac 12008d623946Smrg break 1201fe24f8a2Smrg done 12028d623946Smrg 12038d623946Smrg func_quote_portable_unquoted_result=$func_quote_portable_result 12048d623946Smrg case $func_quote_portable_result in 12058d623946Smrg # double-quote args containing shell metacharacters to delay 12068d623946Smrg # word splitting, command substitution and variable expansion 12078d623946Smrg # for a subsequent eval. 12088d623946Smrg # many bourne shells cannot handle close brackets correctly 12098d623946Smrg # in scan sets, so we specify it separately. 12108d623946Smrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 12118d623946Smrg func_quote_portable_result=\"$func_quote_portable_result\" 12128d623946Smrg ;; 12138d623946Smrg esac 1214fe24f8a2Smrg} 1215fe24f8a2Smrg 1216fe24f8a2Smrg 12178d623946Smrg# func_quotefast_eval ARG 12188d623946Smrg# ----------------------- 12198d623946Smrg# Quote one ARG (internal). This is equivalent to 'func_quote_arg eval ARG', 12208d623946Smrg# but optimized for speed. Result is stored in $func_quotefast_eval. 12218d623946Smrgif test xyes = `(x=; printf -v x %q yes; echo x"$x") 2>/dev/null`; then 12228d623946Smrg printf -v _GL_test_printf_tilde %q '~' 12238d623946Smrg if test '\~' = "$_GL_test_printf_tilde"; then 12248d623946Smrg func_quotefast_eval () 12258d623946Smrg { 12268d623946Smrg printf -v func_quotefast_eval_result %q "$1" 12278d623946Smrg } 12288d623946Smrg else 12298d623946Smrg # Broken older Bash implementations. Make those faster too if possible. 12308d623946Smrg func_quotefast_eval () 12318d623946Smrg { 12328d623946Smrg case $1 in 12338d623946Smrg '~'*) 12348d623946Smrg func_quote_portable false "$1" 12358d623946Smrg func_quotefast_eval_result=$func_quote_portable_result 12368d623946Smrg ;; 12378d623946Smrg *) 12388d623946Smrg printf -v func_quotefast_eval_result %q "$1" 12398d623946Smrg ;; 12408d623946Smrg esac 12418d623946Smrg } 12428d623946Smrg fi 12438d623946Smrgelse 12448d623946Smrg func_quotefast_eval () 12458d623946Smrg { 12468d623946Smrg func_quote_portable false "$1" 12478d623946Smrg func_quotefast_eval_result=$func_quote_portable_result 12488d623946Smrg } 12498d623946Smrgfi 1250fe24f8a2Smrg 12518d623946Smrg 12528d623946Smrg# func_quote_arg MODEs ARG 12538d623946Smrg# ------------------------ 12548d623946Smrg# Quote one ARG to be evaled later. MODEs argument may contain zero or more 12558d623946Smrg# specifiers listed below separated by ',' character. This function returns two 12568d623946Smrg# values: 12578d623946Smrg# i) func_quote_arg_result 12588d623946Smrg# double-quoted (when needed), suitable for a subsequent eval 12598d623946Smrg# ii) func_quote_arg_unquoted_result 12608d623946Smrg# has all characters that are still active within double 12618d623946Smrg# quotes backslashified. Available only if 'unquoted' is specified. 12628d623946Smrg# 12638d623946Smrg# Available modes: 12648d623946Smrg# ---------------- 12658d623946Smrg# 'eval' (default) 12668d623946Smrg# - escape shell special characters 12678d623946Smrg# 'expand' 12688d623946Smrg# - the same as 'eval'; but do not quote variable references 12698d623946Smrg# 'pretty' 12708d623946Smrg# - request aesthetic output, i.e. '"a b"' instead of 'a\ b'. This might 12718d623946Smrg# be used later in func_quote to get output like: 'echo "a b"' instead 12728d623946Smrg# of 'echo a\ b'. This is slower than default on some shells. 12738d623946Smrg# 'unquoted' 12748d623946Smrg# - produce also $func_quote_arg_unquoted_result which does not contain 12758d623946Smrg# wrapping double-quotes. 12768d623946Smrg# 12778d623946Smrg# Examples for 'func_quote_arg pretty,unquoted string': 12788d623946Smrg# 12798d623946Smrg# string | *_result | *_unquoted_result 12808d623946Smrg# ------------+-----------------------+------------------- 12818d623946Smrg# " | \" | \" 12828d623946Smrg# a b | "a b" | a b 12838d623946Smrg# "a b" | "\"a b\"" | \"a b\" 12848d623946Smrg# * | "*" | * 12858d623946Smrg# z="${x-$y}" | "z=\"\${x-\$y}\"" | z=\"\${x-\$y}\" 12868d623946Smrg# 12878d623946Smrg# Examples for 'func_quote_arg pretty,unquoted,expand string': 12888d623946Smrg# 12898d623946Smrg# string | *_result | *_unquoted_result 12908d623946Smrg# --------------+---------------------+-------------------- 12918d623946Smrg# z="${x-$y}" | "z=\"${x-$y}\"" | z=\"${x-$y}\" 12928d623946Smrgfunc_quote_arg () 12938d623946Smrg{ 12948d623946Smrg _G_quote_expand=false 12958d623946Smrg case ,$1, in 12968d623946Smrg *,expand,*) 12978d623946Smrg _G_quote_expand=: 12988d623946Smrg ;; 1299fe24f8a2Smrg esac 1300fe24f8a2Smrg 13018d623946Smrg case ,$1, in 13028d623946Smrg *,pretty,*|*,expand,*|*,unquoted,*) 13038d623946Smrg func_quote_portable $_G_quote_expand "$2" 13048d623946Smrg func_quote_arg_result=$func_quote_portable_result 13058d623946Smrg func_quote_arg_unquoted_result=$func_quote_portable_unquoted_result 13068d623946Smrg ;; 13078d623946Smrg *) 13088d623946Smrg # Faster quote-for-eval for some shells. 13098d623946Smrg func_quotefast_eval "$2" 13108d623946Smrg func_quote_arg_result=$func_quotefast_eval_result 1311fe24f8a2Smrg ;; 1312fe24f8a2Smrg esac 13138d623946Smrg} 13148d623946Smrg 1315fe24f8a2Smrg 13168d623946Smrg# func_quote MODEs ARGs... 13178d623946Smrg# ------------------------ 13188d623946Smrg# Quote all ARGs to be evaled later and join them into single command. See 13198d623946Smrg# func_quote_arg's description for more info. 13208d623946Smrgfunc_quote () 13218d623946Smrg{ 13228d623946Smrg $debug_cmd 13238d623946Smrg _G_func_quote_mode=$1 ; shift 13248d623946Smrg func_quote_result= 13258d623946Smrg while test 0 -lt $#; do 13268d623946Smrg func_quote_arg "$_G_func_quote_mode" "$1" 13278d623946Smrg if test -n "$func_quote_result"; then 13288d623946Smrg func_append func_quote_result " $func_quote_arg_result" 13298d623946Smrg else 13308d623946Smrg func_append func_quote_result "$func_quote_arg_result" 13318d623946Smrg fi 13328d623946Smrg shift 13338d623946Smrg done 1334fe24f8a2Smrg} 1335fe24f8a2Smrg 1336fe24f8a2Smrg 1337fe24f8a2Smrg# func_stripname PREFIX SUFFIX NAME 1338fe24f8a2Smrg# --------------------------------- 1339fe24f8a2Smrg# strip PREFIX and SUFFIX from NAME, and store in func_stripname_result. 1340fe24f8a2Smrg# PREFIX and SUFFIX must not contain globbing or regex special 1341fe24f8a2Smrg# characters, hashes, percent signs, but SUFFIX may contain a leading 1342fe24f8a2Smrg# dot (in which case that matches only a dot). 1343fe24f8a2Smrgif test yes = "$_G_HAVE_XSI_OPS"; then 1344fe24f8a2Smrg eval 'func_stripname () 1345fe24f8a2Smrg { 1346fe24f8a2Smrg $debug_cmd 1347fe24f8a2Smrg 1348fe24f8a2Smrg # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are 1349fe24f8a2Smrg # positional parameters, so assign one to ordinary variable first. 1350fe24f8a2Smrg func_stripname_result=$3 1351fe24f8a2Smrg func_stripname_result=${func_stripname_result#"$1"} 1352fe24f8a2Smrg func_stripname_result=${func_stripname_result%"$2"} 1353fe24f8a2Smrg }' 1354fe24f8a2Smrgelse 1355fe24f8a2Smrg func_stripname () 1356fe24f8a2Smrg { 1357fe24f8a2Smrg $debug_cmd 1358fe24f8a2Smrg 1359fe24f8a2Smrg case $2 in 1360fe24f8a2Smrg .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;; 1361fe24f8a2Smrg *) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;; 1362fe24f8a2Smrg esac 1363fe24f8a2Smrg } 1364fe24f8a2Smrgfi 1365fe24f8a2Smrg 1366fe24f8a2Smrg 1367fe24f8a2Smrg# func_show_eval CMD [FAIL_EXP] 1368fe24f8a2Smrg# ----------------------------- 1369fe24f8a2Smrg# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is 1370fe24f8a2Smrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 1371fe24f8a2Smrg# is given, then evaluate it. 1372fe24f8a2Smrgfunc_show_eval () 1373fe24f8a2Smrg{ 1374fe24f8a2Smrg $debug_cmd 1375fe24f8a2Smrg 1376fe24f8a2Smrg _G_cmd=$1 1377fe24f8a2Smrg _G_fail_exp=${2-':'} 1378fe24f8a2Smrg 13798d623946Smrg func_quote_arg pretty,expand "$_G_cmd" 13808d623946Smrg eval "func_notquiet $func_quote_arg_result" 1381fe24f8a2Smrg 1382fe24f8a2Smrg $opt_dry_run || { 1383fe24f8a2Smrg eval "$_G_cmd" 1384fe24f8a2Smrg _G_status=$? 1385fe24f8a2Smrg if test 0 -ne "$_G_status"; then 1386fe24f8a2Smrg eval "(exit $_G_status); $_G_fail_exp" 1387fe24f8a2Smrg fi 1388fe24f8a2Smrg } 1389fe24f8a2Smrg} 1390fe24f8a2Smrg 1391fe24f8a2Smrg 1392fe24f8a2Smrg# func_show_eval_locale CMD [FAIL_EXP] 1393fe24f8a2Smrg# ------------------------------------ 1394fe24f8a2Smrg# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is 1395fe24f8a2Smrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 1396fe24f8a2Smrg# is given, then evaluate it. Use the saved locale for evaluation. 1397fe24f8a2Smrgfunc_show_eval_locale () 1398fe24f8a2Smrg{ 1399fe24f8a2Smrg $debug_cmd 1400fe24f8a2Smrg 1401fe24f8a2Smrg _G_cmd=$1 1402fe24f8a2Smrg _G_fail_exp=${2-':'} 1403fe24f8a2Smrg 1404fe24f8a2Smrg $opt_quiet || { 14058d623946Smrg func_quote_arg expand,pretty "$_G_cmd" 14068d623946Smrg eval "func_echo $func_quote_arg_result" 1407fe24f8a2Smrg } 1408fe24f8a2Smrg 1409fe24f8a2Smrg $opt_dry_run || { 1410fe24f8a2Smrg eval "$_G_user_locale 1411fe24f8a2Smrg $_G_cmd" 1412fe24f8a2Smrg _G_status=$? 1413fe24f8a2Smrg eval "$_G_safe_locale" 1414fe24f8a2Smrg if test 0 -ne "$_G_status"; then 1415fe24f8a2Smrg eval "(exit $_G_status); $_G_fail_exp" 1416fe24f8a2Smrg fi 1417fe24f8a2Smrg } 1418fe24f8a2Smrg} 1419fe24f8a2Smrg 1420fe24f8a2Smrg 1421fe24f8a2Smrg# func_tr_sh 1422fe24f8a2Smrg# ---------- 1423fe24f8a2Smrg# Turn $1 into a string suitable for a shell variable name. 1424fe24f8a2Smrg# Result is stored in $func_tr_sh_result. All characters 1425fe24f8a2Smrg# not in the set a-zA-Z0-9_ are replaced with '_'. Further, 1426fe24f8a2Smrg# if $1 begins with a digit, a '_' is prepended as well. 1427fe24f8a2Smrgfunc_tr_sh () 1428fe24f8a2Smrg{ 1429fe24f8a2Smrg $debug_cmd 1430fe24f8a2Smrg 1431fe24f8a2Smrg case $1 in 1432fe24f8a2Smrg [0-9]* | *[!a-zA-Z0-9_]*) 1433fe24f8a2Smrg func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'` 1434fe24f8a2Smrg ;; 1435fe24f8a2Smrg * ) 1436fe24f8a2Smrg func_tr_sh_result=$1 1437fe24f8a2Smrg ;; 1438fe24f8a2Smrg esac 1439fe24f8a2Smrg} 1440fe24f8a2Smrg 1441fe24f8a2Smrg 1442fe24f8a2Smrg# func_verbose ARG... 1443fe24f8a2Smrg# ------------------- 1444fe24f8a2Smrg# Echo program name prefixed message in verbose mode only. 1445fe24f8a2Smrgfunc_verbose () 1446fe24f8a2Smrg{ 1447fe24f8a2Smrg $debug_cmd 1448fe24f8a2Smrg 1449fe24f8a2Smrg $opt_verbose && func_echo "$*" 1450fe24f8a2Smrg 1451fe24f8a2Smrg : 1452fe24f8a2Smrg} 1453fe24f8a2Smrg 1454fe24f8a2Smrg 1455fe24f8a2Smrg# func_warn_and_continue ARG... 1456fe24f8a2Smrg# ----------------------------- 1457fe24f8a2Smrg# Echo program name prefixed warning message to standard error. 1458fe24f8a2Smrgfunc_warn_and_continue () 1459fe24f8a2Smrg{ 1460fe24f8a2Smrg $debug_cmd 1461fe24f8a2Smrg 1462fe24f8a2Smrg $require_term_colors 1463fe24f8a2Smrg 1464fe24f8a2Smrg func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2 1465fe24f8a2Smrg} 1466fe24f8a2Smrg 1467fe24f8a2Smrg 1468fe24f8a2Smrg# func_warning CATEGORY ARG... 1469fe24f8a2Smrg# ---------------------------- 1470fe24f8a2Smrg# Echo program name prefixed warning message to standard error. Warning 1471fe24f8a2Smrg# messages can be filtered according to CATEGORY, where this function 1472fe24f8a2Smrg# elides messages where CATEGORY is not listed in the global variable 1473fe24f8a2Smrg# 'opt_warning_types'. 1474fe24f8a2Smrgfunc_warning () 1475fe24f8a2Smrg{ 1476fe24f8a2Smrg $debug_cmd 1477fe24f8a2Smrg 1478fe24f8a2Smrg # CATEGORY must be in the warning_categories list! 1479fe24f8a2Smrg case " $warning_categories " in 1480fe24f8a2Smrg *" $1 "*) ;; 1481fe24f8a2Smrg *) func_internal_error "invalid warning category '$1'" ;; 1482fe24f8a2Smrg esac 1483fe24f8a2Smrg 1484fe24f8a2Smrg _G_category=$1 1485fe24f8a2Smrg shift 1486fe24f8a2Smrg 1487fe24f8a2Smrg case " $opt_warning_types " in 1488fe24f8a2Smrg *" $_G_category "*) $warning_func ${1+"$@"} ;; 1489fe24f8a2Smrg esac 1490fe24f8a2Smrg} 1491fe24f8a2Smrg 1492fe24f8a2Smrg 1493fe24f8a2Smrg# func_sort_ver VER1 VER2 1494fe24f8a2Smrg# ----------------------- 1495fe24f8a2Smrg# 'sort -V' is not generally available. 1496fe24f8a2Smrg# Note this deviates from the version comparison in automake 1497fe24f8a2Smrg# in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a 1498fe24f8a2Smrg# but this should suffice as we won't be specifying old 1499fe24f8a2Smrg# version formats or redundant trailing .0 in bootstrap.conf. 1500fe24f8a2Smrg# If we did want full compatibility then we should probably 1501fe24f8a2Smrg# use m4_version_compare from autoconf. 1502fe24f8a2Smrgfunc_sort_ver () 1503fe24f8a2Smrg{ 1504fe24f8a2Smrg $debug_cmd 1505fe24f8a2Smrg 1506fe24f8a2Smrg printf '%s\n%s\n' "$1" "$2" \ 1507fe24f8a2Smrg | 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 1508fe24f8a2Smrg} 1509fe24f8a2Smrg 1510fe24f8a2Smrg# func_lt_ver PREV CURR 1511fe24f8a2Smrg# --------------------- 1512fe24f8a2Smrg# Return true if PREV and CURR are in the correct order according to 1513fe24f8a2Smrg# func_sort_ver, otherwise false. Use it like this: 1514fe24f8a2Smrg# 1515fe24f8a2Smrg# func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..." 1516fe24f8a2Smrgfunc_lt_ver () 1517fe24f8a2Smrg{ 1518fe24f8a2Smrg $debug_cmd 1519fe24f8a2Smrg 1520fe24f8a2Smrg test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q` 1521fe24f8a2Smrg} 1522fe24f8a2Smrg 1523fe24f8a2Smrg 1524fe24f8a2Smrg# Local variables: 1525fe24f8a2Smrg# mode: shell-script 1526fe24f8a2Smrg# sh-indentation: 2 1527fe24f8a2Smrg# eval: (add-hook 'before-save-hook 'time-stamp) 1528fe24f8a2Smrg# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" 1529fe24f8a2Smrg# time-stamp-time-zone: "UTC" 1530fe24f8a2Smrg# End: 1531fe24f8a2Smrg#! /bin/sh 1532fe24f8a2Smrg 1533fe24f8a2Smrg# A portable, pluggable option parser for Bourne shell. 1534fe24f8a2Smrg# Written by Gary V. Vaughan, 2010 1535fe24f8a2Smrg 15368d623946Smrg# This is free software. There is NO warranty; not even for 15378d623946Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 15388d623946Smrg# 15398d623946Smrg# Copyright (C) 2010-2019, 2021 Bootstrap Authors 15408d623946Smrg# 15418d623946Smrg# This file is dual licensed under the terms of the MIT license 15428d623946Smrg# <https://opensource.org/license/MIT>, and GPL version 2 or later 15438d623946Smrg# <http://www.gnu.org/licenses/gpl-2.0.html>. You must apply one of 15448d623946Smrg# these licenses when using or redistributing this software or any of 15458d623946Smrg# the files within it. See the URLs above, or the file `LICENSE` 15468d623946Smrg# included in the Bootstrap distribution for the full license texts. 1547fe24f8a2Smrg 15488d623946Smrg# Please report bugs or propose patches to: 15498d623946Smrg# <https://github.com/gnulib-modules/bootstrap/issues> 1550fe24f8a2Smrg 15518d623946Smrg# Set a version string for this script. 15528d623946Smrgscriptversion=2019-02-19.15; # UTC 1553fe24f8a2Smrg 1554fe24f8a2Smrg 1555fe24f8a2Smrg## ------ ## 1556fe24f8a2Smrg## Usage. ## 1557fe24f8a2Smrg## ------ ## 1558fe24f8a2Smrg 1559fe24f8a2Smrg# This file is a library for parsing options in your shell scripts along 1560fe24f8a2Smrg# with assorted other useful supporting features that you can make use 1561fe24f8a2Smrg# of too. 1562fe24f8a2Smrg# 1563fe24f8a2Smrg# For the simplest scripts you might need only: 1564fe24f8a2Smrg# 1565fe24f8a2Smrg# #!/bin/sh 1566fe24f8a2Smrg# . relative/path/to/funclib.sh 1567fe24f8a2Smrg# . relative/path/to/options-parser 1568fe24f8a2Smrg# scriptversion=1.0 1569fe24f8a2Smrg# func_options ${1+"$@"} 1570fe24f8a2Smrg# eval set dummy "$func_options_result"; shift 1571fe24f8a2Smrg# ...rest of your script... 1572fe24f8a2Smrg# 1573fe24f8a2Smrg# In order for the '--version' option to work, you will need to have a 1574fe24f8a2Smrg# suitably formatted comment like the one at the top of this file 15758d623946Smrg# starting with '# Written by ' and ending with '# Copyright'. 1576fe24f8a2Smrg# 1577fe24f8a2Smrg# For '-h' and '--help' to work, you will also need a one line 1578fe24f8a2Smrg# description of your script's purpose in a comment directly above the 1579fe24f8a2Smrg# '# Written by ' line, like the one at the top of this file. 1580fe24f8a2Smrg# 1581fe24f8a2Smrg# The default options also support '--debug', which will turn on shell 1582fe24f8a2Smrg# execution tracing (see the comment above debug_cmd below for another 1583fe24f8a2Smrg# use), and '--verbose' and the func_verbose function to allow your script 1584fe24f8a2Smrg# to display verbose messages only when your user has specified 1585fe24f8a2Smrg# '--verbose'. 1586fe24f8a2Smrg# 15878d623946Smrg# After sourcing this file, you can plug in processing for additional 1588fe24f8a2Smrg# options by amending the variables from the 'Configuration' section 1589fe24f8a2Smrg# below, and following the instructions in the 'Option parsing' 1590fe24f8a2Smrg# section further down. 1591fe24f8a2Smrg 1592fe24f8a2Smrg## -------------- ## 1593fe24f8a2Smrg## Configuration. ## 1594fe24f8a2Smrg## -------------- ## 1595fe24f8a2Smrg 1596fe24f8a2Smrg# You should override these variables in your script after sourcing this 1597fe24f8a2Smrg# file so that they reflect the customisations you have added to the 1598fe24f8a2Smrg# option parser. 1599fe24f8a2Smrg 1600fe24f8a2Smrg# The usage line for option parsing errors and the start of '-h' and 1601fe24f8a2Smrg# '--help' output messages. You can embed shell variables for delayed 1602fe24f8a2Smrg# expansion at the time the message is displayed, but you will need to 1603fe24f8a2Smrg# quote other shell meta-characters carefully to prevent them being 1604fe24f8a2Smrg# expanded when the contents are evaled. 1605fe24f8a2Smrgusage='$progpath [OPTION]...' 1606fe24f8a2Smrg 1607fe24f8a2Smrg# Short help message in response to '-h' and '--help'. Add to this or 1608fe24f8a2Smrg# override it after sourcing this library to reflect the full set of 1609fe24f8a2Smrg# options your script accepts. 1610fe24f8a2Smrgusage_message="\ 1611fe24f8a2Smrg --debug enable verbose shell tracing 1612fe24f8a2Smrg -W, --warnings=CATEGORY 1613fe24f8a2Smrg report the warnings falling in CATEGORY [all] 1614fe24f8a2Smrg -v, --verbose verbosely report processing 1615fe24f8a2Smrg --version print version information and exit 1616fe24f8a2Smrg -h, --help print short or long help message and exit 1617fe24f8a2Smrg" 1618fe24f8a2Smrg 1619fe24f8a2Smrg# Additional text appended to 'usage_message' in response to '--help'. 1620fe24f8a2Smrglong_help_message=" 1621fe24f8a2SmrgWarning categories include: 1622fe24f8a2Smrg 'all' show all warnings 1623fe24f8a2Smrg 'none' turn off all the warnings 1624fe24f8a2Smrg 'error' warnings are treated as fatal errors" 1625fe24f8a2Smrg 1626fe24f8a2Smrg# Help message printed before fatal option parsing errors. 1627fe24f8a2Smrgfatal_help="Try '\$progname --help' for more information." 1628fe24f8a2Smrg 1629fe24f8a2Smrg 1630fe24f8a2Smrg 1631fe24f8a2Smrg## ------------------------- ## 1632fe24f8a2Smrg## Hook function management. ## 1633fe24f8a2Smrg## ------------------------- ## 1634fe24f8a2Smrg 1635fe24f8a2Smrg# This section contains functions for adding, removing, and running hooks 16368d623946Smrg# in the main code. A hook is just a list of function names that can be 16378d623946Smrg# run in order later on. 1638fe24f8a2Smrg 1639fe24f8a2Smrg# func_hookable FUNC_NAME 1640fe24f8a2Smrg# ----------------------- 1641fe24f8a2Smrg# Declare that FUNC_NAME will run hooks added with 1642fe24f8a2Smrg# 'func_add_hook FUNC_NAME ...'. 1643fe24f8a2Smrgfunc_hookable () 1644fe24f8a2Smrg{ 1645fe24f8a2Smrg $debug_cmd 1646fe24f8a2Smrg 1647fe24f8a2Smrg func_append hookable_fns " $1" 1648fe24f8a2Smrg} 1649fe24f8a2Smrg 1650fe24f8a2Smrg 1651fe24f8a2Smrg# func_add_hook FUNC_NAME HOOK_FUNC 1652fe24f8a2Smrg# --------------------------------- 1653fe24f8a2Smrg# Request that FUNC_NAME call HOOK_FUNC before it returns. FUNC_NAME must 1654fe24f8a2Smrg# first have been declared "hookable" by a call to 'func_hookable'. 1655fe24f8a2Smrgfunc_add_hook () 1656fe24f8a2Smrg{ 1657fe24f8a2Smrg $debug_cmd 1658fe24f8a2Smrg 1659fe24f8a2Smrg case " $hookable_fns " in 1660fe24f8a2Smrg *" $1 "*) ;; 1661fe24f8a2Smrg *) func_fatal_error "'$1' does not accept hook functions." ;; 1662fe24f8a2Smrg esac 1663fe24f8a2Smrg 1664fe24f8a2Smrg eval func_append ${1}_hooks '" $2"' 1665fe24f8a2Smrg} 1666fe24f8a2Smrg 1667fe24f8a2Smrg 1668fe24f8a2Smrg# func_remove_hook FUNC_NAME HOOK_FUNC 1669fe24f8a2Smrg# ------------------------------------ 16708d623946Smrg# Remove HOOK_FUNC from the list of hook functions to be called by 16718d623946Smrg# FUNC_NAME. 1672fe24f8a2Smrgfunc_remove_hook () 1673fe24f8a2Smrg{ 1674fe24f8a2Smrg $debug_cmd 1675fe24f8a2Smrg 1676fe24f8a2Smrg eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`' 1677fe24f8a2Smrg} 1678fe24f8a2Smrg 1679fe24f8a2Smrg 16808d623946Smrg# func_propagate_result FUNC_NAME_A FUNC_NAME_B 16818d623946Smrg# --------------------------------------------- 16828d623946Smrg# If the *_result variable of FUNC_NAME_A _is set_, assign its value to 16838d623946Smrg# *_result variable of FUNC_NAME_B. 16848d623946Smrgfunc_propagate_result () 16858d623946Smrg{ 16868d623946Smrg $debug_cmd 16878d623946Smrg 16888d623946Smrg func_propagate_result_result=: 16898d623946Smrg if eval "test \"\${${1}_result+set}\" = set" 16908d623946Smrg then 16918d623946Smrg eval "${2}_result=\$${1}_result" 16928d623946Smrg else 16938d623946Smrg func_propagate_result_result=false 16948d623946Smrg fi 16958d623946Smrg} 16968d623946Smrg 16978d623946Smrg 1698fe24f8a2Smrg# func_run_hooks FUNC_NAME [ARG]... 1699fe24f8a2Smrg# --------------------------------- 1700fe24f8a2Smrg# Run all hook functions registered to FUNC_NAME. 17018d623946Smrg# It's assumed that the list of hook functions contains nothing more 1702fe24f8a2Smrg# than a whitespace-delimited list of legal shell function names, and 1703fe24f8a2Smrg# no effort is wasted trying to catch shell meta-characters or preserve 1704fe24f8a2Smrg# whitespace. 1705fe24f8a2Smrgfunc_run_hooks () 1706fe24f8a2Smrg{ 1707fe24f8a2Smrg $debug_cmd 1708fe24f8a2Smrg 1709fe24f8a2Smrg case " $hookable_fns " in 1710fe24f8a2Smrg *" $1 "*) ;; 17118d623946Smrg *) func_fatal_error "'$1' does not support hook functions." ;; 1712fe24f8a2Smrg esac 1713fe24f8a2Smrg 1714fe24f8a2Smrg eval _G_hook_fns=\$$1_hooks; shift 1715fe24f8a2Smrg 1716fe24f8a2Smrg for _G_hook in $_G_hook_fns; do 17178d623946Smrg func_unset "${_G_hook}_result" 17188d623946Smrg eval $_G_hook '${1+"$@"}' 17198d623946Smrg func_propagate_result $_G_hook func_run_hooks 17208d623946Smrg if $func_propagate_result_result; then 17218d623946Smrg eval set dummy "$func_run_hooks_result"; shift 17228d623946Smrg fi 1723fe24f8a2Smrg done 1724fe24f8a2Smrg} 1725fe24f8a2Smrg 1726fe24f8a2Smrg 1727fe24f8a2Smrg 1728fe24f8a2Smrg## --------------- ## 1729fe24f8a2Smrg## Option parsing. ## 1730fe24f8a2Smrg## --------------- ## 1731fe24f8a2Smrg 1732fe24f8a2Smrg# In order to add your own option parsing hooks, you must accept the 17338d623946Smrg# full positional parameter list from your hook function. You may remove 17348d623946Smrg# or edit any options that you action, and then pass back the remaining 17358d623946Smrg# unprocessed options in '<hooked_function_name>_result', escaped 17368d623946Smrg# suitably for 'eval'. 17378d623946Smrg# 17388d623946Smrg# The '<hooked_function_name>_result' variable is automatically unset 17398d623946Smrg# before your hook gets called; for best performance, only set the 17408d623946Smrg# *_result variable when necessary (i.e. don't call the 'func_quote' 17418d623946Smrg# function unnecessarily because it can be an expensive operation on some 17428d623946Smrg# machines). 17438d623946Smrg# 17448d623946Smrg# Like this: 1745fe24f8a2Smrg# 1746fe24f8a2Smrg# my_options_prep () 1747fe24f8a2Smrg# { 1748fe24f8a2Smrg# $debug_cmd 1749fe24f8a2Smrg# 1750fe24f8a2Smrg# # Extend the existing usage message. 1751fe24f8a2Smrg# usage_message=$usage_message' 1752fe24f8a2Smrg# -s, --silent don'\''t print informational messages 1753fe24f8a2Smrg# ' 17548d623946Smrg# # No change in '$@' (ignored completely by this hook). Leave 17558d623946Smrg# # my_options_prep_result variable intact. 1756fe24f8a2Smrg# } 1757fe24f8a2Smrg# func_add_hook func_options_prep my_options_prep 1758fe24f8a2Smrg# 1759fe24f8a2Smrg# 1760fe24f8a2Smrg# my_silent_option () 1761fe24f8a2Smrg# { 1762fe24f8a2Smrg# $debug_cmd 1763fe24f8a2Smrg# 17648d623946Smrg# args_changed=false 17658d623946Smrg# 17668d623946Smrg# # Note that, for efficiency, we parse as many options as we can 1767fe24f8a2Smrg# # recognise in a loop before passing the remainder back to the 1768fe24f8a2Smrg# # caller on the first unrecognised argument we encounter. 1769fe24f8a2Smrg# while test $# -gt 0; do 1770fe24f8a2Smrg# opt=$1; shift 1771fe24f8a2Smrg# case $opt in 17728d623946Smrg# --silent|-s) opt_silent=: 17738d623946Smrg# args_changed=: 17748d623946Smrg# ;; 1775fe24f8a2Smrg# # Separate non-argument short options: 1776fe24f8a2Smrg# -s*) func_split_short_opt "$_G_opt" 1777fe24f8a2Smrg# set dummy "$func_split_short_opt_name" \ 1778fe24f8a2Smrg# "-$func_split_short_opt_arg" ${1+"$@"} 1779fe24f8a2Smrg# shift 17808d623946Smrg# args_changed=: 1781fe24f8a2Smrg# ;; 17828d623946Smrg# *) # Make sure the first unrecognised option "$_G_opt" 17838d623946Smrg# # is added back to "$@" in case we need it later, 17848d623946Smrg# # if $args_changed was set to 'true'. 17858d623946Smrg# set dummy "$_G_opt" ${1+"$@"}; shift; break ;; 1786fe24f8a2Smrg# esac 1787fe24f8a2Smrg# done 1788fe24f8a2Smrg# 17898d623946Smrg# # Only call 'func_quote' here if we processed at least one argument. 17908d623946Smrg# if $args_changed; then 17918d623946Smrg# func_quote eval ${1+"$@"} 17928d623946Smrg# my_silent_option_result=$func_quote_result 17938d623946Smrg# fi 1794fe24f8a2Smrg# } 1795fe24f8a2Smrg# func_add_hook func_parse_options my_silent_option 1796fe24f8a2Smrg# 1797fe24f8a2Smrg# 1798fe24f8a2Smrg# my_option_validation () 1799fe24f8a2Smrg# { 1800fe24f8a2Smrg# $debug_cmd 1801fe24f8a2Smrg# 1802fe24f8a2Smrg# $opt_silent && $opt_verbose && func_fatal_help "\ 1803fe24f8a2Smrg# '--silent' and '--verbose' options are mutually exclusive." 1804fe24f8a2Smrg# } 1805fe24f8a2Smrg# func_add_hook func_validate_options my_option_validation 1806fe24f8a2Smrg# 18078d623946Smrg# You'll also need to manually amend $usage_message to reflect the extra 1808fe24f8a2Smrg# options you parse. It's preferable to append if you can, so that 1809fe24f8a2Smrg# multiple option parsing hooks can be added safely. 1810fe24f8a2Smrg 1811fe24f8a2Smrg 18128d623946Smrg# func_options_finish [ARG]... 18138d623946Smrg# ---------------------------- 18148d623946Smrg# Finishing the option parse loop (call 'func_options' hooks ATM). 18158d623946Smrgfunc_options_finish () 18168d623946Smrg{ 18178d623946Smrg $debug_cmd 18188d623946Smrg 18198d623946Smrg func_run_hooks func_options ${1+"$@"} 18208d623946Smrg func_propagate_result func_run_hooks func_options_finish 18218d623946Smrg} 18228d623946Smrg 18238d623946Smrg 1824fe24f8a2Smrg# func_options [ARG]... 1825fe24f8a2Smrg# --------------------- 1826fe24f8a2Smrg# All the functions called inside func_options are hookable. See the 1827fe24f8a2Smrg# individual implementations for details. 1828fe24f8a2Smrgfunc_hookable func_options 1829fe24f8a2Smrgfunc_options () 1830fe24f8a2Smrg{ 1831fe24f8a2Smrg $debug_cmd 1832fe24f8a2Smrg 18338d623946Smrg _G_options_quoted=false 1834fe24f8a2Smrg 18358d623946Smrg for my_func in options_prep parse_options validate_options options_finish 18368d623946Smrg do 18378d623946Smrg func_unset func_${my_func}_result 18388d623946Smrg func_unset func_run_hooks_result 18398d623946Smrg eval func_$my_func '${1+"$@"}' 18408d623946Smrg func_propagate_result func_$my_func func_options 18418d623946Smrg if $func_propagate_result_result; then 18428d623946Smrg eval set dummy "$func_options_result"; shift 18438d623946Smrg _G_options_quoted=: 18448d623946Smrg fi 18458d623946Smrg done 1846fe24f8a2Smrg 18478d623946Smrg $_G_options_quoted || { 18488d623946Smrg # As we (func_options) are top-level options-parser function and 18498d623946Smrg # nobody quoted "$@" for us yet, we need to do it explicitly for 18508d623946Smrg # caller. 18518d623946Smrg func_quote eval ${1+"$@"} 18528d623946Smrg func_options_result=$func_quote_result 18538d623946Smrg } 1854ee3138f1Smrg} 1855ee3138f1Smrg 1856ee3138f1Smrg 1857fe24f8a2Smrg# func_options_prep [ARG]... 1858fe24f8a2Smrg# -------------------------- 1859fe24f8a2Smrg# All initialisations required before starting the option parse loop. 1860fe24f8a2Smrg# Note that when calling hook functions, we pass through the list of 1861fe24f8a2Smrg# positional parameters. If a hook function modifies that list, and 18628d623946Smrg# needs to propagate that back to rest of this script, then the complete 18638d623946Smrg# modified list must be put in 'func_run_hooks_result' before returning. 1864fe24f8a2Smrgfunc_hookable func_options_prep 1865fe24f8a2Smrgfunc_options_prep () 1866ee3138f1Smrg{ 1867fe24f8a2Smrg $debug_cmd 186834977a2fSmrg 1869fe24f8a2Smrg # Option defaults: 1870fe24f8a2Smrg opt_verbose=false 1871fe24f8a2Smrg opt_warning_types= 1872fe24f8a2Smrg 1873fe24f8a2Smrg func_run_hooks func_options_prep ${1+"$@"} 18748d623946Smrg func_propagate_result func_run_hooks func_options_prep 1875ee3138f1Smrg} 1876ee3138f1Smrg 1877ee3138f1Smrg 1878fe24f8a2Smrg# func_parse_options [ARG]... 1879fe24f8a2Smrg# --------------------------- 1880fe24f8a2Smrg# The main option parsing loop. 1881fe24f8a2Smrgfunc_hookable func_parse_options 1882fe24f8a2Smrgfunc_parse_options () 1883ee3138f1Smrg{ 1884fe24f8a2Smrg $debug_cmd 188534977a2fSmrg 18868d623946Smrg _G_parse_options_requote=false 1887fe24f8a2Smrg # this just eases exit handling 1888fe24f8a2Smrg while test $# -gt 0; do 1889fe24f8a2Smrg # Defer to hook functions for initial option parsing, so they 1890fe24f8a2Smrg # get priority in the event of reusing an option name. 1891fe24f8a2Smrg func_run_hooks func_parse_options ${1+"$@"} 18928d623946Smrg func_propagate_result func_run_hooks func_parse_options 18938d623946Smrg if $func_propagate_result_result; then 18948d623946Smrg eval set dummy "$func_parse_options_result"; shift 18958d623946Smrg # Even though we may have changed "$@", we passed the "$@" array 18968d623946Smrg # down into the hook and it quoted it for us (because we are in 18978d623946Smrg # this if-branch). No need to quote it again. 18988d623946Smrg _G_parse_options_requote=false 18998d623946Smrg fi 1900ee3138f1Smrg 1901fe24f8a2Smrg # Break out of the loop if we already parsed every option. 1902fe24f8a2Smrg test $# -gt 0 || break 1903ee3138f1Smrg 19048d623946Smrg # We expect that one of the options parsed in this function matches 19058d623946Smrg # and thus we remove _G_opt from "$@" and need to re-quote. 19068d623946Smrg _G_match_parse_options=: 1907fe24f8a2Smrg _G_opt=$1 1908fe24f8a2Smrg shift 1909fe24f8a2Smrg case $_G_opt in 1910fe24f8a2Smrg --debug|-x) debug_cmd='set -x' 19118d623946Smrg func_echo "enabling shell trace mode" >&2 1912fe24f8a2Smrg $debug_cmd 1913fe24f8a2Smrg ;; 1914fe24f8a2Smrg 1915fe24f8a2Smrg --no-warnings|--no-warning|--no-warn) 1916fe24f8a2Smrg set dummy --warnings none ${1+"$@"} 1917fe24f8a2Smrg shift 1918fe24f8a2Smrg ;; 191934977a2fSmrg 1920fe24f8a2Smrg --warnings|--warning|-W) 19218d623946Smrg if test $# = 0 && func_missing_arg $_G_opt; then 19228d623946Smrg _G_parse_options_requote=: 19238d623946Smrg break 19248d623946Smrg fi 1925fe24f8a2Smrg case " $warning_categories $1" in 1926fe24f8a2Smrg *" $1 "*) 1927fe24f8a2Smrg # trailing space prevents matching last $1 above 1928fe24f8a2Smrg func_append_uniq opt_warning_types " $1" 1929fe24f8a2Smrg ;; 1930fe24f8a2Smrg *all) 1931fe24f8a2Smrg opt_warning_types=$warning_categories 1932fe24f8a2Smrg ;; 1933fe24f8a2Smrg *none) 1934fe24f8a2Smrg opt_warning_types=none 1935fe24f8a2Smrg warning_func=: 1936fe24f8a2Smrg ;; 1937fe24f8a2Smrg *error) 1938fe24f8a2Smrg opt_warning_types=$warning_categories 1939fe24f8a2Smrg warning_func=func_fatal_error 1940fe24f8a2Smrg ;; 1941fe24f8a2Smrg *) 1942fe24f8a2Smrg func_fatal_error \ 1943fe24f8a2Smrg "unsupported warning category: '$1'" 1944fe24f8a2Smrg ;; 1945fe24f8a2Smrg esac 1946fe24f8a2Smrg shift 1947fe24f8a2Smrg ;; 1948fe24f8a2Smrg 1949fe24f8a2Smrg --verbose|-v) opt_verbose=: ;; 1950fe24f8a2Smrg --version) func_version ;; 1951fe24f8a2Smrg -\?|-h) func_usage ;; 1952fe24f8a2Smrg --help) func_help ;; 1953fe24f8a2Smrg 1954fe24f8a2Smrg # Separate optargs to long options (plugins may need this): 1955fe24f8a2Smrg --*=*) func_split_equals "$_G_opt" 1956fe24f8a2Smrg set dummy "$func_split_equals_lhs" \ 1957fe24f8a2Smrg "$func_split_equals_rhs" ${1+"$@"} 1958fe24f8a2Smrg shift 1959fe24f8a2Smrg ;; 1960fe24f8a2Smrg 1961fe24f8a2Smrg # Separate optargs to short options: 1962fe24f8a2Smrg -W*) 1963fe24f8a2Smrg func_split_short_opt "$_G_opt" 1964fe24f8a2Smrg set dummy "$func_split_short_opt_name" \ 1965fe24f8a2Smrg "$func_split_short_opt_arg" ${1+"$@"} 1966fe24f8a2Smrg shift 1967fe24f8a2Smrg ;; 1968fe24f8a2Smrg 1969fe24f8a2Smrg # Separate non-argument short options: 1970fe24f8a2Smrg -\?*|-h*|-v*|-x*) 1971fe24f8a2Smrg func_split_short_opt "$_G_opt" 1972fe24f8a2Smrg set dummy "$func_split_short_opt_name" \ 1973fe24f8a2Smrg "-$func_split_short_opt_arg" ${1+"$@"} 1974fe24f8a2Smrg shift 1975fe24f8a2Smrg ;; 1976fe24f8a2Smrg 19778d623946Smrg --) _G_parse_options_requote=: ; break ;; 1978fe24f8a2Smrg -*) func_fatal_help "unrecognised option: '$_G_opt'" ;; 19798d623946Smrg *) set dummy "$_G_opt" ${1+"$@"}; shift 19808d623946Smrg _G_match_parse_options=false 19818d623946Smrg break 19828d623946Smrg ;; 1983fe24f8a2Smrg esac 19848d623946Smrg 19858d623946Smrg if $_G_match_parse_options; then 19868d623946Smrg _G_parse_options_requote=: 19878d623946Smrg fi 1988fe24f8a2Smrg done 1989fe24f8a2Smrg 19908d623946Smrg if $_G_parse_options_requote; then 19918d623946Smrg # save modified positional parameters for caller 19928d623946Smrg func_quote eval ${1+"$@"} 19938d623946Smrg func_parse_options_result=$func_quote_result 19948d623946Smrg fi 1995ee3138f1Smrg} 1996ee3138f1Smrg 199734977a2fSmrg 1998fe24f8a2Smrg# func_validate_options [ARG]... 1999fe24f8a2Smrg# ------------------------------ 2000fe24f8a2Smrg# Perform any sanity checks on option settings and/or unconsumed 2001fe24f8a2Smrg# arguments. 2002fe24f8a2Smrgfunc_hookable func_validate_options 2003fe24f8a2Smrgfunc_validate_options () 2004ee3138f1Smrg{ 2005fe24f8a2Smrg $debug_cmd 200634977a2fSmrg 2007fe24f8a2Smrg # Display all warnings if -W was not given. 2008fe24f8a2Smrg test -n "$opt_warning_types" || opt_warning_types=" $warning_categories" 200934977a2fSmrg 2010fe24f8a2Smrg func_run_hooks func_validate_options ${1+"$@"} 20118d623946Smrg func_propagate_result func_run_hooks func_validate_options 2012ee3138f1Smrg 2013fe24f8a2Smrg # Bail if the options were screwed! 2014fe24f8a2Smrg $exit_cmd $EXIT_FAILURE 20153e72ca8cSmrg} 20163e72ca8cSmrg 2017ee3138f1Smrg 20183e72ca8cSmrg 2019fe24f8a2Smrg## ----------------- ## 2020fe24f8a2Smrg## Helper functions. ## 2021fe24f8a2Smrg## ----------------- ## 2022ee3138f1Smrg 2023fe24f8a2Smrg# This section contains the helper functions used by the rest of the 2024fe24f8a2Smrg# hookable option parser framework in ascii-betical order. 2025fe24f8a2Smrg 2026fe24f8a2Smrg 2027fe24f8a2Smrg# func_fatal_help ARG... 2028fe24f8a2Smrg# ---------------------- 2029fe24f8a2Smrg# Echo program name prefixed message to standard error, followed by 2030fe24f8a2Smrg# a help hint, and exit. 2031fe24f8a2Smrgfunc_fatal_help () 203234977a2fSmrg{ 2033fe24f8a2Smrg $debug_cmd 20343e72ca8cSmrg 2035fe24f8a2Smrg eval \$ECHO \""Usage: $usage"\" 2036fe24f8a2Smrg eval \$ECHO \""$fatal_help"\" 2037fe24f8a2Smrg func_error ${1+"$@"} 2038fe24f8a2Smrg exit $EXIT_FAILURE 203934977a2fSmrg} 2040ee3138f1Smrg 2041fe24f8a2Smrg 2042fe24f8a2Smrg# func_help 2043fe24f8a2Smrg# --------- 2044fe24f8a2Smrg# Echo long help message to standard output and exit. 204534977a2fSmrgfunc_help () 204634977a2fSmrg{ 2047fe24f8a2Smrg $debug_cmd 2048fe24f8a2Smrg 2049fe24f8a2Smrg func_usage_message 2050fe24f8a2Smrg $ECHO "$long_help_message" 2051fe24f8a2Smrg exit 0 205234977a2fSmrg} 2053ee3138f1Smrg 2054fe24f8a2Smrg 2055fe24f8a2Smrg# func_missing_arg ARGNAME 2056fe24f8a2Smrg# ------------------------ 205734977a2fSmrg# Echo program name prefixed message to standard error and set global 205834977a2fSmrg# exit_cmd. 205934977a2fSmrgfunc_missing_arg () 206034977a2fSmrg{ 2061fe24f8a2Smrg $debug_cmd 20623e72ca8cSmrg 2063fe24f8a2Smrg func_error "Missing argument for '$1'." 206434977a2fSmrg exit_cmd=exit 206534977a2fSmrg} 206634977a2fSmrg 206734977a2fSmrg 2068fe24f8a2Smrg# func_split_equals STRING 2069fe24f8a2Smrg# ------------------------ 20708d623946Smrg# Set func_split_equals_lhs and func_split_equals_rhs shell variables 20718d623946Smrg# after splitting STRING at the '=' sign. 2072fe24f8a2Smrgtest -z "$_G_HAVE_XSI_OPS" \ 2073fe24f8a2Smrg && (eval 'x=a/b/c; 2074fe24f8a2Smrg test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ 2075fe24f8a2Smrg && _G_HAVE_XSI_OPS=yes 2076fe24f8a2Smrg 2077fe24f8a2Smrgif test yes = "$_G_HAVE_XSI_OPS" 2078fe24f8a2Smrgthen 2079fe24f8a2Smrg # This is an XSI compatible shell, allowing a faster implementation... 2080fe24f8a2Smrg eval 'func_split_equals () 2081fe24f8a2Smrg { 2082fe24f8a2Smrg $debug_cmd 2083fe24f8a2Smrg 2084fe24f8a2Smrg func_split_equals_lhs=${1%%=*} 2085fe24f8a2Smrg func_split_equals_rhs=${1#*=} 20868d623946Smrg if test "x$func_split_equals_lhs" = "x$1"; then 20878d623946Smrg func_split_equals_rhs= 20888d623946Smrg fi 2089fe24f8a2Smrg }' 2090fe24f8a2Smrgelse 2091fe24f8a2Smrg # ...otherwise fall back to using expr, which is often a shell builtin. 2092fe24f8a2Smrg func_split_equals () 2093fe24f8a2Smrg { 2094fe24f8a2Smrg $debug_cmd 2095fe24f8a2Smrg 2096fe24f8a2Smrg func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'` 2097fe24f8a2Smrg func_split_equals_rhs= 20988d623946Smrg test "x$func_split_equals_lhs=" = "x$1" \ 2099fe24f8a2Smrg || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'` 2100fe24f8a2Smrg } 2101fe24f8a2Smrgfi #func_split_equals 2102fe24f8a2Smrg 2103fe24f8a2Smrg 2104fe24f8a2Smrg# func_split_short_opt SHORTOPT 2105fe24f8a2Smrg# ----------------------------- 21063e72ca8cSmrg# Set func_split_short_opt_name and func_split_short_opt_arg shell 21073e72ca8cSmrg# variables after splitting SHORTOPT after the 2nd character. 2108fe24f8a2Smrgif test yes = "$_G_HAVE_XSI_OPS" 2109fe24f8a2Smrgthen 2110fe24f8a2Smrg # This is an XSI compatible shell, allowing a faster implementation... 2111fe24f8a2Smrg eval 'func_split_short_opt () 2112fe24f8a2Smrg { 2113fe24f8a2Smrg $debug_cmd 2114fe24f8a2Smrg 2115fe24f8a2Smrg func_split_short_opt_arg=${1#??} 2116fe24f8a2Smrg func_split_short_opt_name=${1%"$func_split_short_opt_arg"} 2117fe24f8a2Smrg }' 2118fe24f8a2Smrgelse 2119fe24f8a2Smrg # ...otherwise fall back to using expr, which is often a shell builtin. 2120fe24f8a2Smrg func_split_short_opt () 2121fe24f8a2Smrg { 2122fe24f8a2Smrg $debug_cmd 2123fe24f8a2Smrg 21248d623946Smrg func_split_short_opt_name=`expr "x$1" : 'x\(-.\)'` 2125fe24f8a2Smrg func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'` 2126fe24f8a2Smrg } 2127fe24f8a2Smrgfi #func_split_short_opt 2128fe24f8a2Smrg 2129fe24f8a2Smrg 2130fe24f8a2Smrg# func_usage 2131fe24f8a2Smrg# ---------- 2132fe24f8a2Smrg# Echo short help message to standard output and exit. 2133fe24f8a2Smrgfunc_usage () 21343e72ca8cSmrg{ 2135fe24f8a2Smrg $debug_cmd 21363e72ca8cSmrg 2137fe24f8a2Smrg func_usage_message 2138fe24f8a2Smrg $ECHO "Run '$progname --help |${PAGER-more}' for full usage" 2139fe24f8a2Smrg exit 0 2140fe24f8a2Smrg} 21413e72ca8cSmrg 21423e72ca8cSmrg 2143fe24f8a2Smrg# func_usage_message 2144fe24f8a2Smrg# ------------------ 2145fe24f8a2Smrg# Echo short help message to standard output. 2146fe24f8a2Smrgfunc_usage_message () 21473e72ca8cSmrg{ 2148fe24f8a2Smrg $debug_cmd 21493e72ca8cSmrg 2150fe24f8a2Smrg eval \$ECHO \""Usage: $usage"\" 2151fe24f8a2Smrg echo 2152fe24f8a2Smrg $SED -n 's|^# || 2153fe24f8a2Smrg /^Written by/{ 2154fe24f8a2Smrg x;p;x 2155fe24f8a2Smrg } 2156fe24f8a2Smrg h 2157fe24f8a2Smrg /^Written by/q' < "$progpath" 2158fe24f8a2Smrg echo 2159fe24f8a2Smrg eval \$ECHO \""$usage_message"\" 2160fe24f8a2Smrg} 21613e72ca8cSmrg 216234977a2fSmrg 2163fe24f8a2Smrg# func_version 2164fe24f8a2Smrg# ------------ 2165fe24f8a2Smrg# Echo version message to standard output and exit. 21668d623946Smrg# The version message is extracted from the calling file's header 21678d623946Smrg# comments, with leading '# ' stripped: 21688d623946Smrg# 1. First display the progname and version 21698d623946Smrg# 2. Followed by the header comment line matching /^# Written by / 21708d623946Smrg# 3. Then a blank line followed by the first following line matching 21718d623946Smrg# /^# Copyright / 21728d623946Smrg# 4. Immediately followed by any lines between the previous matches, 21738d623946Smrg# except lines preceding the intervening completely blank line. 21748d623946Smrg# For example, see the header comments of this file. 2175fe24f8a2Smrgfunc_version () 2176fe24f8a2Smrg{ 2177fe24f8a2Smrg $debug_cmd 217834977a2fSmrg 2179fe24f8a2Smrg printf '%s\n' "$progname $scriptversion" 2180fe24f8a2Smrg $SED -n ' 21818d623946Smrg /^# Written by /!b 21828d623946Smrg s|^# ||; p; n 21838d623946Smrg 21848d623946Smrg :fwd2blnk 21858d623946Smrg /./ { 21868d623946Smrg n 21878d623946Smrg b fwd2blnk 2188fe24f8a2Smrg } 21898d623946Smrg p; n 21908d623946Smrg 21918d623946Smrg :holdwrnt 21928d623946Smrg s|^# || 21938d623946Smrg s|^# *$|| 21948d623946Smrg /^Copyright /!{ 21958d623946Smrg /./H 21968d623946Smrg n 21978d623946Smrg b holdwrnt 2198fe24f8a2Smrg } 21998d623946Smrg 22008d623946Smrg s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2| 22018d623946Smrg G 22028d623946Smrg s|\(\n\)\n*|\1|g 22038d623946Smrg p; q' < "$progpath" 220434977a2fSmrg 2205fe24f8a2Smrg exit $? 2206fe24f8a2Smrg} 220734977a2fSmrg 2208ee3138f1Smrg 2209fe24f8a2Smrg# Local variables: 2210fe24f8a2Smrg# mode: shell-script 2211fe24f8a2Smrg# sh-indentation: 2 2212fe24f8a2Smrg# eval: (add-hook 'before-save-hook 'time-stamp) 22138d623946Smrg# time-stamp-pattern: "30/scriptversion=%:y-%02m-%02d.%02H; # UTC" 2214fe24f8a2Smrg# time-stamp-time-zone: "UTC" 2215fe24f8a2Smrg# End: 2216ee3138f1Smrg 2217fe24f8a2Smrg# Set a version string. 22188d623946Smrgscriptversion='(GNU libtool) 2.4.7' 2219ee3138f1Smrg 222034977a2fSmrg 2221fe24f8a2Smrg# func_echo ARG... 2222fe24f8a2Smrg# ---------------- 2223fe24f8a2Smrg# Libtool also displays the current mode in messages, so override 2224fe24f8a2Smrg# funclib.sh func_echo with this custom definition. 2225fe24f8a2Smrgfunc_echo () 22263e72ca8cSmrg{ 2227fe24f8a2Smrg $debug_cmd 22283e72ca8cSmrg 2229fe24f8a2Smrg _G_message=$* 22303e72ca8cSmrg 2231fe24f8a2Smrg func_echo_IFS=$IFS 2232fe24f8a2Smrg IFS=$nl 2233fe24f8a2Smrg for _G_line in $_G_message; do 2234fe24f8a2Smrg IFS=$func_echo_IFS 2235fe24f8a2Smrg $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line" 2236fe24f8a2Smrg done 2237fe24f8a2Smrg IFS=$func_echo_IFS 2238fe24f8a2Smrg} 22393e72ca8cSmrg 2240fe24f8a2Smrg 2241fe24f8a2Smrg# func_warning ARG... 2242fe24f8a2Smrg# ------------------- 2243fe24f8a2Smrg# Libtool warnings are not categorized, so override funclib.sh 2244fe24f8a2Smrg# func_warning with this simpler definition. 2245fe24f8a2Smrgfunc_warning () 22463e72ca8cSmrg{ 2247fe24f8a2Smrg $debug_cmd 22483e72ca8cSmrg 2249fe24f8a2Smrg $warning_func ${1+"$@"} 2250fe24f8a2Smrg} 22513e72ca8cSmrg 22523e72ca8cSmrg 2253fe24f8a2Smrg## ---------------- ## 2254fe24f8a2Smrg## Options parsing. ## 2255fe24f8a2Smrg## ---------------- ## 2256fe24f8a2Smrg 2257fe24f8a2Smrg# Hook in the functions to make sure our own options are parsed during 2258fe24f8a2Smrg# the option parsing loop. 2259fe24f8a2Smrg 2260fe24f8a2Smrgusage='$progpath [OPTION]... [MODE-ARG]...' 2261fe24f8a2Smrg 2262fe24f8a2Smrg# Short help message in response to '-h'. 2263fe24f8a2Smrgusage_message="Options: 2264fe24f8a2Smrg --config show all configuration variables 2265fe24f8a2Smrg --debug enable verbose shell tracing 2266fe24f8a2Smrg -n, --dry-run display commands without modifying any files 2267fe24f8a2Smrg --features display basic configuration information and exit 2268fe24f8a2Smrg --mode=MODE use operation mode MODE 2269fe24f8a2Smrg --no-warnings equivalent to '-Wnone' 2270fe24f8a2Smrg --preserve-dup-deps don't remove duplicate dependency libraries 2271fe24f8a2Smrg --quiet, --silent don't print informational messages 2272fe24f8a2Smrg --tag=TAG use configuration variables from tag TAG 2273fe24f8a2Smrg -v, --verbose print more informational messages than default 2274fe24f8a2Smrg --version print version information 2275fe24f8a2Smrg -W, --warnings=CATEGORY report the warnings falling in CATEGORY [all] 2276fe24f8a2Smrg -h, --help, --help-all print short, long, or detailed help message 2277fe24f8a2Smrg" 22783e72ca8cSmrg 2279fe24f8a2Smrg# Additional text appended to 'usage_message' in response to '--help'. 2280fe24f8a2Smrgfunc_help () 22813e72ca8cSmrg{ 2282fe24f8a2Smrg $debug_cmd 2283fe24f8a2Smrg 2284fe24f8a2Smrg func_usage_message 2285fe24f8a2Smrg $ECHO "$long_help_message 2286fe24f8a2Smrg 2287fe24f8a2SmrgMODE must be one of the following: 2288fe24f8a2Smrg 2289fe24f8a2Smrg clean remove files from the build directory 2290fe24f8a2Smrg compile compile a source file into a libtool object 2291fe24f8a2Smrg execute automatically set library path, then run a program 2292fe24f8a2Smrg finish complete the installation of libtool libraries 2293fe24f8a2Smrg install install libraries or executables 2294fe24f8a2Smrg link create a library or an executable 2295fe24f8a2Smrg uninstall remove libraries from an installed directory 2296fe24f8a2Smrg 2297fe24f8a2SmrgMODE-ARGS vary depending on the MODE. When passed as first option, 2298fe24f8a2Smrg'--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that. 2299fe24f8a2SmrgTry '$progname --help --mode=MODE' for a more detailed description of MODE. 2300fe24f8a2Smrg 2301fe24f8a2SmrgWhen reporting a bug, please describe a test case to reproduce it and 2302fe24f8a2Smrginclude the following information: 2303fe24f8a2Smrg 2304fe24f8a2Smrg host-triplet: $host 2305fe24f8a2Smrg shell: $SHELL 2306fe24f8a2Smrg compiler: $LTCC 2307fe24f8a2Smrg compiler flags: $LTCFLAGS 2308fe24f8a2Smrg linker: $LD (gnu? $with_gnu_ld) 23098d623946Smrg version: $progname (GNU libtool) 2.4.7 2310fe24f8a2Smrg automake: `($AUTOMAKE --version) 2>/dev/null |$SED 1q` 2311fe24f8a2Smrg autoconf: `($AUTOCONF --version) 2>/dev/null |$SED 1q` 2312fe24f8a2Smrg 2313fe24f8a2SmrgReport bugs to <bug-libtool@gnu.org>. 2314fe24f8a2SmrgGNU libtool home page: <http://www.gnu.org/software/libtool/>. 2315fe24f8a2SmrgGeneral help using GNU software: <http://www.gnu.org/gethelp/>." 2316fe24f8a2Smrg exit 0 2317fe24f8a2Smrg} 23183e72ca8cSmrg 23193e72ca8cSmrg 2320fe24f8a2Smrg# func_lo2o OBJECT-NAME 2321fe24f8a2Smrg# --------------------- 2322fe24f8a2Smrg# Transform OBJECT-NAME from a '.lo' suffix to the platform specific 2323fe24f8a2Smrg# object suffix. 2324fe24f8a2Smrg 2325fe24f8a2Smrglo2o=s/\\.lo\$/.$objext/ 2326fe24f8a2Smrgo2lo=s/\\.$objext\$/.lo/ 2327fe24f8a2Smrg 2328fe24f8a2Smrgif test yes = "$_G_HAVE_XSI_OPS"; then 2329fe24f8a2Smrg eval 'func_lo2o () 2330fe24f8a2Smrg { 2331fe24f8a2Smrg case $1 in 2332fe24f8a2Smrg *.lo) func_lo2o_result=${1%.lo}.$objext ;; 2333fe24f8a2Smrg * ) func_lo2o_result=$1 ;; 2334fe24f8a2Smrg esac 2335fe24f8a2Smrg }' 2336fe24f8a2Smrg 2337fe24f8a2Smrg # func_xform LIBOBJ-OR-SOURCE 2338fe24f8a2Smrg # --------------------------- 2339fe24f8a2Smrg # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise) 2340fe24f8a2Smrg # suffix to a '.lo' libtool-object suffix. 2341fe24f8a2Smrg eval 'func_xform () 2342fe24f8a2Smrg { 2343fe24f8a2Smrg func_xform_result=${1%.*}.lo 2344fe24f8a2Smrg }' 2345fe24f8a2Smrgelse 2346fe24f8a2Smrg # ...otherwise fall back to using sed. 2347fe24f8a2Smrg func_lo2o () 2348fe24f8a2Smrg { 2349fe24f8a2Smrg func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"` 2350fe24f8a2Smrg } 2351fe24f8a2Smrg 2352fe24f8a2Smrg func_xform () 2353fe24f8a2Smrg { 2354fe24f8a2Smrg func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'` 2355fe24f8a2Smrg } 2356fe24f8a2Smrgfi 23573e72ca8cSmrg 23583e72ca8cSmrg 2359fe24f8a2Smrg# func_fatal_configuration ARG... 2360fe24f8a2Smrg# ------------------------------- 236134977a2fSmrg# Echo program name prefixed message to standard error, followed by 236234977a2fSmrg# a configuration failure hint, and exit. 236334977a2fSmrgfunc_fatal_configuration () 236434977a2fSmrg{ 23658d623946Smrg func_fatal_error ${1+"$@"} \ 2366fe24f8a2Smrg "See the $PACKAGE documentation for more information." \ 2367fe24f8a2Smrg "Fatal configuration error." 236834977a2fSmrg} 2369ee3138f1Smrg 2370ee3138f1Smrg 237134977a2fSmrg# func_config 2372fe24f8a2Smrg# ----------- 237334977a2fSmrg# Display the configuration for all the tags in this script. 237434977a2fSmrgfunc_config () 237534977a2fSmrg{ 237634977a2fSmrg re_begincf='^# ### BEGIN LIBTOOL' 237734977a2fSmrg re_endcf='^# ### END LIBTOOL' 237834977a2fSmrg 237934977a2fSmrg # Default configuration. 238034977a2fSmrg $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" 2381ee3138f1Smrg 2382ee3138f1Smrg # Now print the configurations for the tags. 2383ee3138f1Smrg for tagname in $taglist; do 238434977a2fSmrg $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" 2385ee3138f1Smrg done 2386ee3138f1Smrg 238734977a2fSmrg exit $? 238834977a2fSmrg} 2389ee3138f1Smrg 2390fe24f8a2Smrg 239134977a2fSmrg# func_features 2392fe24f8a2Smrg# ------------- 239334977a2fSmrg# Display the features supported by this script. 239434977a2fSmrgfunc_features () 239534977a2fSmrg{ 2396b425557eSmrg echo "host: $host" 2397fe24f8a2Smrg if test yes = "$build_libtool_libs"; then 2398b425557eSmrg echo "enable shared libraries" 2399ee3138f1Smrg else 2400b425557eSmrg echo "disable shared libraries" 2401ee3138f1Smrg fi 2402fe24f8a2Smrg if test yes = "$build_old_libs"; then 2403b425557eSmrg echo "enable static libraries" 2404ee3138f1Smrg else 2405b425557eSmrg echo "disable static libraries" 2406ee3138f1Smrg fi 240734977a2fSmrg 2408ee3138f1Smrg exit $? 240934977a2fSmrg} 2410ee3138f1Smrg 2411fe24f8a2Smrg 2412fe24f8a2Smrg# func_enable_tag TAGNAME 2413fe24f8a2Smrg# ----------------------- 241434977a2fSmrg# Verify that TAGNAME is valid, and either flag an error and exit, or 241534977a2fSmrg# enable the TAGNAME tag. We also add TAGNAME to the global $taglist 241634977a2fSmrg# variable here. 241734977a2fSmrgfunc_enable_tag () 241834977a2fSmrg{ 2419fe24f8a2Smrg # Global variable: 2420fe24f8a2Smrg tagname=$1 2421ee3138f1Smrg 2422fe24f8a2Smrg re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" 2423fe24f8a2Smrg re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" 2424fe24f8a2Smrg sed_extractcf=/$re_begincf/,/$re_endcf/p 2425ee3138f1Smrg 2426fe24f8a2Smrg # Validate tagname. 2427fe24f8a2Smrg case $tagname in 2428fe24f8a2Smrg *[!-_A-Za-z0-9,/]*) 2429fe24f8a2Smrg func_fatal_error "invalid tag name: $tagname" 2430fe24f8a2Smrg ;; 2431fe24f8a2Smrg esac 2432ee3138f1Smrg 2433fe24f8a2Smrg # Don't test for the "default" C tag, as we know it's 2434fe24f8a2Smrg # there but not specially marked. 2435fe24f8a2Smrg case $tagname in 2436fe24f8a2Smrg CC) ;; 243734977a2fSmrg *) 2438fe24f8a2Smrg if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then 2439fe24f8a2Smrg taglist="$taglist $tagname" 2440fe24f8a2Smrg 2441fe24f8a2Smrg # Evaluate the configuration. Be careful to quote the path 2442fe24f8a2Smrg # and the sed script, to avoid splitting on whitespace, but 2443fe24f8a2Smrg # also don't use non-portable quotes within backquotes within 2444fe24f8a2Smrg # quotes we have to do it in 2 steps: 2445fe24f8a2Smrg extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` 2446fe24f8a2Smrg eval "$extractedcf" 2447fe24f8a2Smrg else 2448fe24f8a2Smrg func_error "ignoring unknown tag $tagname" 2449fe24f8a2Smrg fi 2450fe24f8a2Smrg ;; 2451fe24f8a2Smrg esac 245234977a2fSmrg} 245334977a2fSmrg 2454fe24f8a2Smrg 24553e72ca8cSmrg# func_check_version_match 2456fe24f8a2Smrg# ------------------------ 24573e72ca8cSmrg# Ensure that we are using m4 macros, and libtool script from the same 24583e72ca8cSmrg# release of libtool. 24593e72ca8cSmrgfunc_check_version_match () 246034977a2fSmrg{ 2461fe24f8a2Smrg if test "$package_revision" != "$macro_revision"; then 2462fe24f8a2Smrg if test "$VERSION" != "$macro_version"; then 2463fe24f8a2Smrg if test -z "$macro_version"; then 2464fe24f8a2Smrg cat >&2 <<_LT_EOF 24653e72ca8cSmrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 24663e72ca8cSmrg$progname: definition of this LT_INIT comes from an older release. 24673e72ca8cSmrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 24683e72ca8cSmrg$progname: and run autoconf again. 24693e72ca8cSmrg_LT_EOF 2470fe24f8a2Smrg else 2471fe24f8a2Smrg cat >&2 <<_LT_EOF 24723e72ca8cSmrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 24733e72ca8cSmrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version. 24743e72ca8cSmrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 24753e72ca8cSmrg$progname: and run autoconf again. 24763e72ca8cSmrg_LT_EOF 2477fe24f8a2Smrg fi 2478fe24f8a2Smrg else 2479fe24f8a2Smrg cat >&2 <<_LT_EOF 24803e72ca8cSmrg$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, 24813e72ca8cSmrg$progname: but the definition of this LT_INIT comes from revision $macro_revision. 24823e72ca8cSmrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision 24833e72ca8cSmrg$progname: of $PACKAGE $VERSION and run autoconf again. 24843e72ca8cSmrg_LT_EOF 2485fe24f8a2Smrg fi 24863e72ca8cSmrg 2487fe24f8a2Smrg exit $EXIT_MISMATCH 2488fe24f8a2Smrg fi 24893e72ca8cSmrg} 24903e72ca8cSmrg 24913e72ca8cSmrg 2492fe24f8a2Smrg# libtool_options_prep [ARG]... 2493fe24f8a2Smrg# ----------------------------- 2494fe24f8a2Smrg# Preparation for options parsed by libtool. 2495fe24f8a2Smrglibtool_options_prep () 2496fe24f8a2Smrg{ 2497fe24f8a2Smrg $debug_mode 24983e72ca8cSmrg 2499fe24f8a2Smrg # Option defaults: 2500fe24f8a2Smrg opt_config=false 2501fe24f8a2Smrg opt_dlopen= 2502fe24f8a2Smrg opt_dry_run=false 2503fe24f8a2Smrg opt_help=false 2504fe24f8a2Smrg opt_mode= 2505fe24f8a2Smrg opt_preserve_dup_deps=false 2506fe24f8a2Smrg opt_quiet=false 25073e72ca8cSmrg 2508fe24f8a2Smrg nonopt= 2509fe24f8a2Smrg preserve_args= 25103e72ca8cSmrg 25118d623946Smrg _G_rc_lt_options_prep=: 25128d623946Smrg 2513fe24f8a2Smrg # Shorthand for --mode=foo, only valid as the first argument 2514fe24f8a2Smrg case $1 in 2515fe24f8a2Smrg clean|clea|cle|cl) 2516fe24f8a2Smrg shift; set dummy --mode clean ${1+"$@"}; shift 2517fe24f8a2Smrg ;; 2518fe24f8a2Smrg compile|compil|compi|comp|com|co|c) 2519fe24f8a2Smrg shift; set dummy --mode compile ${1+"$@"}; shift 2520fe24f8a2Smrg ;; 2521fe24f8a2Smrg execute|execut|execu|exec|exe|ex|e) 2522fe24f8a2Smrg shift; set dummy --mode execute ${1+"$@"}; shift 2523fe24f8a2Smrg ;; 2524fe24f8a2Smrg finish|finis|fini|fin|fi|f) 2525fe24f8a2Smrg shift; set dummy --mode finish ${1+"$@"}; shift 2526fe24f8a2Smrg ;; 2527fe24f8a2Smrg install|instal|insta|inst|ins|in|i) 2528fe24f8a2Smrg shift; set dummy --mode install ${1+"$@"}; shift 2529fe24f8a2Smrg ;; 2530fe24f8a2Smrg link|lin|li|l) 2531fe24f8a2Smrg shift; set dummy --mode link ${1+"$@"}; shift 2532fe24f8a2Smrg ;; 2533fe24f8a2Smrg uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) 2534fe24f8a2Smrg shift; set dummy --mode uninstall ${1+"$@"}; shift 2535fe24f8a2Smrg ;; 25368d623946Smrg *) 25378d623946Smrg _G_rc_lt_options_prep=false 25388d623946Smrg ;; 2539fe24f8a2Smrg esac 2540fe24f8a2Smrg 25418d623946Smrg if $_G_rc_lt_options_prep; then 25428d623946Smrg # Pass back the list of options. 25438d623946Smrg func_quote eval ${1+"$@"} 25448d623946Smrg libtool_options_prep_result=$func_quote_result 25458d623946Smrg fi 2546fe24f8a2Smrg} 2547fe24f8a2Smrgfunc_add_hook func_options_prep libtool_options_prep 2548ee3138f1Smrg 2549ee3138f1Smrg 2550fe24f8a2Smrg# libtool_parse_options [ARG]... 2551fe24f8a2Smrg# --------------------------------- 2552fe24f8a2Smrg# Provide handling for libtool specific options. 2553fe24f8a2Smrglibtool_parse_options () 25543e72ca8cSmrg{ 2555fe24f8a2Smrg $debug_cmd 255634977a2fSmrg 25578d623946Smrg _G_rc_lt_parse_options=false 25588d623946Smrg 2559fe24f8a2Smrg # Perform our own loop to consume as many options as possible in 2560fe24f8a2Smrg # each iteration. 2561fe24f8a2Smrg while test $# -gt 0; do 25628d623946Smrg _G_match_lt_parse_options=: 2563fe24f8a2Smrg _G_opt=$1 2564fe24f8a2Smrg shift 2565fe24f8a2Smrg case $_G_opt in 2566fe24f8a2Smrg --dry-run|--dryrun|-n) 2567fe24f8a2Smrg opt_dry_run=: 2568fe24f8a2Smrg ;; 2569fe24f8a2Smrg 2570fe24f8a2Smrg --config) func_config ;; 2571fe24f8a2Smrg 2572fe24f8a2Smrg --dlopen|-dlopen) 2573fe24f8a2Smrg opt_dlopen="${opt_dlopen+$opt_dlopen 2574fe24f8a2Smrg}$1" 2575fe24f8a2Smrg shift 2576fe24f8a2Smrg ;; 2577fe24f8a2Smrg 2578fe24f8a2Smrg --preserve-dup-deps) 2579fe24f8a2Smrg opt_preserve_dup_deps=: ;; 2580fe24f8a2Smrg 2581fe24f8a2Smrg --features) func_features ;; 2582fe24f8a2Smrg 2583fe24f8a2Smrg --finish) set dummy --mode finish ${1+"$@"}; shift ;; 2584fe24f8a2Smrg 2585fe24f8a2Smrg --help) opt_help=: ;; 2586fe24f8a2Smrg 2587fe24f8a2Smrg --help-all) opt_help=': help-all' ;; 2588fe24f8a2Smrg 2589fe24f8a2Smrg --mode) test $# = 0 && func_missing_arg $_G_opt && break 2590fe24f8a2Smrg opt_mode=$1 2591fe24f8a2Smrg case $1 in 2592fe24f8a2Smrg # Valid mode arguments: 2593fe24f8a2Smrg clean|compile|execute|finish|install|link|relink|uninstall) ;; 2594fe24f8a2Smrg 2595fe24f8a2Smrg # Catch anything else as an error 2596fe24f8a2Smrg *) func_error "invalid argument for $_G_opt" 2597fe24f8a2Smrg exit_cmd=exit 2598fe24f8a2Smrg break 2599fe24f8a2Smrg ;; 2600fe24f8a2Smrg esac 2601fe24f8a2Smrg shift 2602fe24f8a2Smrg ;; 2603fe24f8a2Smrg 2604fe24f8a2Smrg --no-silent|--no-quiet) 2605fe24f8a2Smrg opt_quiet=false 2606fe24f8a2Smrg func_append preserve_args " $_G_opt" 2607fe24f8a2Smrg ;; 2608fe24f8a2Smrg 2609fe24f8a2Smrg --no-warnings|--no-warning|--no-warn) 2610fe24f8a2Smrg opt_warning=false 2611fe24f8a2Smrg func_append preserve_args " $_G_opt" 2612fe24f8a2Smrg ;; 2613fe24f8a2Smrg 2614fe24f8a2Smrg --no-verbose) 2615fe24f8a2Smrg opt_verbose=false 2616fe24f8a2Smrg func_append preserve_args " $_G_opt" 2617fe24f8a2Smrg ;; 2618fe24f8a2Smrg 2619fe24f8a2Smrg --silent|--quiet) 2620fe24f8a2Smrg opt_quiet=: 2621fe24f8a2Smrg opt_verbose=false 2622fe24f8a2Smrg func_append preserve_args " $_G_opt" 2623fe24f8a2Smrg ;; 2624fe24f8a2Smrg 2625fe24f8a2Smrg --tag) test $# = 0 && func_missing_arg $_G_opt && break 2626fe24f8a2Smrg opt_tag=$1 2627fe24f8a2Smrg func_append preserve_args " $_G_opt $1" 2628fe24f8a2Smrg func_enable_tag "$1" 2629fe24f8a2Smrg shift 2630fe24f8a2Smrg ;; 2631fe24f8a2Smrg 2632fe24f8a2Smrg --verbose|-v) opt_quiet=false 2633fe24f8a2Smrg opt_verbose=: 2634fe24f8a2Smrg func_append preserve_args " $_G_opt" 2635fe24f8a2Smrg ;; 2636fe24f8a2Smrg 26378d623946Smrg # An option not handled by this hook function: 26388d623946Smrg *) set dummy "$_G_opt" ${1+"$@"} ; shift 26398d623946Smrg _G_match_lt_parse_options=false 26408d623946Smrg break 26418d623946Smrg ;; 2642fe24f8a2Smrg esac 26438d623946Smrg $_G_match_lt_parse_options && _G_rc_lt_parse_options=: 2644fe24f8a2Smrg done 26453e72ca8cSmrg 26468d623946Smrg if $_G_rc_lt_parse_options; then 26478d623946Smrg # save modified positional parameters for caller 26488d623946Smrg func_quote eval ${1+"$@"} 26498d623946Smrg libtool_parse_options_result=$func_quote_result 26508d623946Smrg fi 2651fe24f8a2Smrg} 2652fe24f8a2Smrgfunc_add_hook func_parse_options libtool_parse_options 265334977a2fSmrg 2654ee3138f1Smrg 265534977a2fSmrg 2656fe24f8a2Smrg# libtool_validate_options [ARG]... 2657fe24f8a2Smrg# --------------------------------- 2658fe24f8a2Smrg# Perform any sanity checks on option settings and/or unconsumed 2659fe24f8a2Smrg# arguments. 2660fe24f8a2Smrglibtool_validate_options () 2661fe24f8a2Smrg{ 2662fe24f8a2Smrg # save first non-option argument 2663fe24f8a2Smrg if test 0 -lt $#; then 2664fe24f8a2Smrg nonopt=$1 2665fe24f8a2Smrg shift 266634977a2fSmrg fi 266734977a2fSmrg 2668fe24f8a2Smrg # preserve --debug 2669fe24f8a2Smrg test : = "$debug_cmd" || func_append preserve_args " --debug" 267034977a2fSmrg 2671fe24f8a2Smrg case $host in 2672fe24f8a2Smrg # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452 2673fe24f8a2Smrg # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788 2674fe24f8a2Smrg *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*) 2675fe24f8a2Smrg # don't eliminate duplications in $postdeps and $predeps 2676fe24f8a2Smrg opt_duplicate_compiler_generated_deps=: 2677fe24f8a2Smrg ;; 2678fe24f8a2Smrg *) 2679fe24f8a2Smrg opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps 2680fe24f8a2Smrg ;; 2681fe24f8a2Smrg esac 268234977a2fSmrg 2683fe24f8a2Smrg $opt_help || { 2684fe24f8a2Smrg # Sanity checks first: 2685fe24f8a2Smrg func_check_version_match 2686fe24f8a2Smrg 2687fe24f8a2Smrg test yes != "$build_libtool_libs" \ 2688fe24f8a2Smrg && test yes != "$build_old_libs" \ 2689fe24f8a2Smrg && func_fatal_configuration "not configured to build any kind of library" 2690fe24f8a2Smrg 2691fe24f8a2Smrg # Darwin sucks 2692fe24f8a2Smrg eval std_shrext=\"$shrext_cmds\" 2693fe24f8a2Smrg 2694fe24f8a2Smrg # Only execute mode is allowed to have -dlopen flags. 2695fe24f8a2Smrg if test -n "$opt_dlopen" && test execute != "$opt_mode"; then 2696fe24f8a2Smrg func_error "unrecognized option '-dlopen'" 2697fe24f8a2Smrg $ECHO "$help" 1>&2 2698fe24f8a2Smrg exit $EXIT_FAILURE 2699fe24f8a2Smrg fi 270034977a2fSmrg 2701fe24f8a2Smrg # Change the help message to a mode-specific one. 2702fe24f8a2Smrg generic_help=$help 2703fe24f8a2Smrg help="Try '$progname --help --mode=$opt_mode' for more information." 2704fe24f8a2Smrg } 270534977a2fSmrg 2706fe24f8a2Smrg # Pass back the unparsed argument list 27078d623946Smrg func_quote eval ${1+"$@"} 27088d623946Smrg libtool_validate_options_result=$func_quote_result 27093e72ca8cSmrg} 2710fe24f8a2Smrgfunc_add_hook func_validate_options libtool_validate_options 271134977a2fSmrg 2712ee3138f1Smrg 2713fe24f8a2Smrg# Process options as early as possible so that --help and --version 2714fe24f8a2Smrg# can return quickly. 2715fe24f8a2Smrgfunc_options ${1+"$@"} 2716fe24f8a2Smrgeval set dummy "$func_options_result"; shift 2717fe24f8a2Smrg 2718ee3138f1Smrg 2719ee3138f1Smrg 27203e72ca8cSmrg## ----------- ## 27213e72ca8cSmrg## Main. ## 27223e72ca8cSmrg## ----------- ## 2723ee3138f1Smrg 2724fe24f8a2Smrgmagic='%%%MAGIC variable%%%' 2725fe24f8a2Smrgmagic_exe='%%%MAGIC EXE variable%%%' 2726fe24f8a2Smrg 2727fe24f8a2Smrg# Global variables. 2728fe24f8a2Smrgextracted_archives= 2729fe24f8a2Smrgextracted_serial=0 2730fe24f8a2Smrg 2731fe24f8a2Smrg# If this variable is set in any of the actions, the command in it 2732fe24f8a2Smrg# will be execed at the end. This prevents here-documents from being 2733fe24f8a2Smrg# left over by shells. 2734fe24f8a2Smrgexec_cmd= 2735fe24f8a2Smrg 2736fe24f8a2Smrg 2737fe24f8a2Smrg# A function that is used when there is no print builtin or printf. 2738fe24f8a2Smrgfunc_fallback_echo () 2739fe24f8a2Smrg{ 2740fe24f8a2Smrg eval 'cat <<_LTECHO_EOF 2741fe24f8a2Smrg$1 2742fe24f8a2Smrg_LTECHO_EOF' 2743fe24f8a2Smrg} 2744fe24f8a2Smrg 2745fe24f8a2Smrg# func_generated_by_libtool 2746fe24f8a2Smrg# True iff stdin has been generated by Libtool. This function is only 2747fe24f8a2Smrg# a basic sanity check; it will hardly flush out determined imposters. 2748fe24f8a2Smrgfunc_generated_by_libtool_p () 2749fe24f8a2Smrg{ 2750fe24f8a2Smrg $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 2751fe24f8a2Smrg} 2752fe24f8a2Smrg 275334977a2fSmrg# func_lalib_p file 2754fe24f8a2Smrg# True iff FILE is a libtool '.la' library or '.lo' object file. 275534977a2fSmrg# This function is only a basic sanity check; it will hardly flush out 275634977a2fSmrg# determined imposters. 275734977a2fSmrgfunc_lalib_p () 275834977a2fSmrg{ 275934977a2fSmrg test -f "$1" && 2760fe24f8a2Smrg $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p 276134977a2fSmrg} 2762ee3138f1Smrg 276334977a2fSmrg# func_lalib_unsafe_p file 2764fe24f8a2Smrg# True iff FILE is a libtool '.la' library or '.lo' object file. 276534977a2fSmrg# This function implements the same check as func_lalib_p without 276634977a2fSmrg# resorting to external programs. To this end, it redirects stdin and 276734977a2fSmrg# closes it afterwards, without saving the original file descriptor. 276834977a2fSmrg# As a safety measure, use it only where a negative result would be 2769fe24f8a2Smrg# fatal anyway. Works if 'file' does not exist. 277034977a2fSmrgfunc_lalib_unsafe_p () 277134977a2fSmrg{ 277234977a2fSmrg lalib_p=no 277334977a2fSmrg if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then 277434977a2fSmrg for lalib_p_l in 1 2 3 4 277534977a2fSmrg do 277634977a2fSmrg read lalib_p_line 2777fe24f8a2Smrg case $lalib_p_line in 277834977a2fSmrg \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; 277934977a2fSmrg esac 278034977a2fSmrg done 278134977a2fSmrg exec 0<&5 5<&- 278234977a2fSmrg fi 2783fe24f8a2Smrg test yes = "$lalib_p" 278434977a2fSmrg} 2785ee3138f1Smrg 278634977a2fSmrg# func_ltwrapper_script_p file 278734977a2fSmrg# True iff FILE is a libtool wrapper script 278834977a2fSmrg# This function is only a basic sanity check; it will hardly flush out 278934977a2fSmrg# determined imposters. 279034977a2fSmrgfunc_ltwrapper_script_p () 279134977a2fSmrg{ 2792fe24f8a2Smrg test -f "$1" && 2793fe24f8a2Smrg $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p 279434977a2fSmrg} 2795ee3138f1Smrg 279634977a2fSmrg# func_ltwrapper_executable_p file 279734977a2fSmrg# True iff FILE is a libtool wrapper executable 279834977a2fSmrg# This function is only a basic sanity check; it will hardly flush out 279934977a2fSmrg# determined imposters. 280034977a2fSmrgfunc_ltwrapper_executable_p () 280134977a2fSmrg{ 280234977a2fSmrg func_ltwrapper_exec_suffix= 280334977a2fSmrg case $1 in 280434977a2fSmrg *.exe) ;; 280534977a2fSmrg *) func_ltwrapper_exec_suffix=.exe ;; 280634977a2fSmrg esac 280734977a2fSmrg $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 280834977a2fSmrg} 280934977a2fSmrg 281034977a2fSmrg# func_ltwrapper_scriptname file 281134977a2fSmrg# Assumes file is an ltwrapper_executable 281234977a2fSmrg# uses $file to determine the appropriate filename for a 281334977a2fSmrg# temporary ltwrapper_script. 281434977a2fSmrgfunc_ltwrapper_scriptname () 281534977a2fSmrg{ 28163e72ca8cSmrg func_dirname_and_basename "$1" "" "." 28173e72ca8cSmrg func_stripname '' '.exe' "$func_basename_result" 2818fe24f8a2Smrg func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper 281934977a2fSmrg} 282034977a2fSmrg 282134977a2fSmrg# func_ltwrapper_p file 282234977a2fSmrg# True iff FILE is a libtool wrapper script or wrapper executable 282334977a2fSmrg# This function is only a basic sanity check; it will hardly flush out 282434977a2fSmrg# determined imposters. 282534977a2fSmrgfunc_ltwrapper_p () 282634977a2fSmrg{ 282734977a2fSmrg func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" 282834977a2fSmrg} 282934977a2fSmrg 283034977a2fSmrg 283134977a2fSmrg# func_execute_cmds commands fail_cmd 283234977a2fSmrg# Execute tilde-delimited COMMANDS. 283334977a2fSmrg# If FAIL_CMD is given, eval that upon failure. 283434977a2fSmrg# FAIL_CMD may read-access the current command in variable CMD! 283534977a2fSmrgfunc_execute_cmds () 283634977a2fSmrg{ 2837fe24f8a2Smrg $debug_cmd 2838fe24f8a2Smrg 283934977a2fSmrg save_ifs=$IFS; IFS='~' 284034977a2fSmrg for cmd in $1; do 2841fe24f8a2Smrg IFS=$sp$nl 284234977a2fSmrg eval cmd=\"$cmd\" 2843fe24f8a2Smrg IFS=$save_ifs 284434977a2fSmrg func_show_eval "$cmd" "${2-:}" 284534977a2fSmrg done 284634977a2fSmrg IFS=$save_ifs 284734977a2fSmrg} 284834977a2fSmrg 284934977a2fSmrg 285034977a2fSmrg# func_source file 285134977a2fSmrg# Source FILE, adding directory component if necessary. 285234977a2fSmrg# Note that it is not necessary on cygwin/mingw to append a dot to 285334977a2fSmrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe 285434977a2fSmrg# behavior happens only for exec(3), not for open(2)! Also, sourcing 2855fe24f8a2Smrg# 'FILE.' does not work on cygwin managed mounts. 285634977a2fSmrgfunc_source () 285734977a2fSmrg{ 2858fe24f8a2Smrg $debug_cmd 2859fe24f8a2Smrg 286034977a2fSmrg case $1 in 286134977a2fSmrg */* | *\\*) . "$1" ;; 286234977a2fSmrg *) . "./$1" ;; 286334977a2fSmrg esac 286434977a2fSmrg} 286534977a2fSmrg 286634977a2fSmrg 28673e72ca8cSmrg# func_resolve_sysroot PATH 28683e72ca8cSmrg# Replace a leading = in PATH with a sysroot. Store the result into 28693e72ca8cSmrg# func_resolve_sysroot_result 28703e72ca8cSmrgfunc_resolve_sysroot () 28713e72ca8cSmrg{ 28723e72ca8cSmrg func_resolve_sysroot_result=$1 28733e72ca8cSmrg case $func_resolve_sysroot_result in 28743e72ca8cSmrg =*) 28753e72ca8cSmrg func_stripname '=' '' "$func_resolve_sysroot_result" 28763e72ca8cSmrg func_resolve_sysroot_result=$lt_sysroot$func_stripname_result 28773e72ca8cSmrg ;; 28783e72ca8cSmrg esac 28793e72ca8cSmrg} 28803e72ca8cSmrg 28813e72ca8cSmrg# func_replace_sysroot PATH 28823e72ca8cSmrg# If PATH begins with the sysroot, replace it with = and 28833e72ca8cSmrg# store the result into func_replace_sysroot_result. 28843e72ca8cSmrgfunc_replace_sysroot () 28853e72ca8cSmrg{ 2886fe24f8a2Smrg case $lt_sysroot:$1 in 28873e72ca8cSmrg ?*:"$lt_sysroot"*) 28883e72ca8cSmrg func_stripname "$lt_sysroot" '' "$1" 2889fe24f8a2Smrg func_replace_sysroot_result='='$func_stripname_result 28903e72ca8cSmrg ;; 28913e72ca8cSmrg *) 28923e72ca8cSmrg # Including no sysroot. 28933e72ca8cSmrg func_replace_sysroot_result=$1 28943e72ca8cSmrg ;; 28953e72ca8cSmrg esac 28963e72ca8cSmrg} 28973e72ca8cSmrg 289834977a2fSmrg# func_infer_tag arg 289934977a2fSmrg# Infer tagged configuration to use if any are available and 290034977a2fSmrg# if one wasn't chosen via the "--tag" command line option. 290134977a2fSmrg# Only attempt this if the compiler in the base compile 290234977a2fSmrg# command doesn't match the default compiler. 290334977a2fSmrg# arg is usually of the form 'gcc ...' 290434977a2fSmrgfunc_infer_tag () 290534977a2fSmrg{ 2906fe24f8a2Smrg $debug_cmd 2907fe24f8a2Smrg 290834977a2fSmrg if test -n "$available_tags" && test -z "$tagname"; then 290934977a2fSmrg CC_quoted= 291034977a2fSmrg for arg in $CC; do 29113e72ca8cSmrg func_append_quoted CC_quoted "$arg" 291234977a2fSmrg done 2913b425557eSmrg CC_expanded=`func_echo_all $CC` 2914b425557eSmrg CC_quoted_expanded=`func_echo_all $CC_quoted` 291534977a2fSmrg case $@ in 291634977a2fSmrg # Blanks in the command may have been stripped by the calling shell, 291734977a2fSmrg # but not from the CC environment variable when configure was run. 2918b425557eSmrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 2919b425557eSmrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; 292034977a2fSmrg # Blanks at the start of $base_compile will cause this to fail 292134977a2fSmrg # if we don't check for them as well. 292234977a2fSmrg *) 292334977a2fSmrg for z in $available_tags; do 292434977a2fSmrg if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then 292534977a2fSmrg # Evaluate the configuration. 2926fe24f8a2Smrg eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" 292734977a2fSmrg CC_quoted= 292834977a2fSmrg for arg in $CC; do 292934977a2fSmrg # Double-quote args containing other shell metacharacters. 29303e72ca8cSmrg func_append_quoted CC_quoted "$arg" 293134977a2fSmrg done 2932b425557eSmrg CC_expanded=`func_echo_all $CC` 2933b425557eSmrg CC_quoted_expanded=`func_echo_all $CC_quoted` 293434977a2fSmrg case "$@ " in 2935b425557eSmrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 2936b425557eSmrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) 293734977a2fSmrg # The compiler in the base compile command matches 293834977a2fSmrg # the one in the tagged configuration. 293934977a2fSmrg # Assume this is the tagged configuration we want. 294034977a2fSmrg tagname=$z 294134977a2fSmrg break 294234977a2fSmrg ;; 294334977a2fSmrg esac 294434977a2fSmrg fi 294534977a2fSmrg done 294634977a2fSmrg # If $tagname still isn't set, then no tagged configuration 294734977a2fSmrg # was found and let the user know that the "--tag" command 294834977a2fSmrg # line option must be used. 294934977a2fSmrg if test -z "$tagname"; then 295034977a2fSmrg func_echo "unable to infer tagged configuration" 2951fe24f8a2Smrg func_fatal_error "specify a tag with '--tag'" 295234977a2fSmrg# else 295334977a2fSmrg# func_verbose "using $tagname tagged configuration" 295434977a2fSmrg fi 295534977a2fSmrg ;; 295634977a2fSmrg esac 295734977a2fSmrg fi 295834977a2fSmrg} 295934977a2fSmrg 296034977a2fSmrg 29613e72ca8cSmrg 29623e72ca8cSmrg# func_write_libtool_object output_name pic_name nonpic_name 29633e72ca8cSmrg# Create a libtool object file (analogous to a ".la" file), 29643e72ca8cSmrg# but don't create it if we're doing a dry run. 29653e72ca8cSmrgfunc_write_libtool_object () 29663e72ca8cSmrg{ 2967fe24f8a2Smrg write_libobj=$1 2968fe24f8a2Smrg if test yes = "$build_libtool_libs"; then 2969fe24f8a2Smrg write_lobj=\'$2\' 29703e72ca8cSmrg else 29713e72ca8cSmrg write_lobj=none 29723e72ca8cSmrg fi 29733e72ca8cSmrg 2974fe24f8a2Smrg if test yes = "$build_old_libs"; then 2975fe24f8a2Smrg write_oldobj=\'$3\' 29763e72ca8cSmrg else 29773e72ca8cSmrg write_oldobj=none 29783e72ca8cSmrg fi 29793e72ca8cSmrg 29803e72ca8cSmrg $opt_dry_run || { 29813e72ca8cSmrg cat >${write_libobj}T <<EOF 29823e72ca8cSmrg# $write_libobj - a libtool object file 2983fe24f8a2Smrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 29843e72ca8cSmrg# 29853e72ca8cSmrg# Please DO NOT delete this file! 29863e72ca8cSmrg# It is necessary for linking the library. 29873e72ca8cSmrg 29883e72ca8cSmrg# Name of the PIC object. 29893e72ca8cSmrgpic_object=$write_lobj 29903e72ca8cSmrg 29913e72ca8cSmrg# Name of the non-PIC object 29923e72ca8cSmrgnon_pic_object=$write_oldobj 29933e72ca8cSmrg 29943e72ca8cSmrgEOF 2995fe24f8a2Smrg $MV "${write_libobj}T" "$write_libobj" 29963e72ca8cSmrg } 29973e72ca8cSmrg} 29983e72ca8cSmrg 29993e72ca8cSmrg 30003e72ca8cSmrg################################################## 30013e72ca8cSmrg# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS # 30023e72ca8cSmrg################################################## 30033e72ca8cSmrg 30043e72ca8cSmrg# func_convert_core_file_wine_to_w32 ARG 30053e72ca8cSmrg# Helper function used by file name conversion functions when $build is *nix, 30063e72ca8cSmrg# and $host is mingw, cygwin, or some other w32 environment. Relies on a 30073e72ca8cSmrg# correctly configured wine environment available, with the winepath program 30083e72ca8cSmrg# in $build's $PATH. 30093e72ca8cSmrg# 30103e72ca8cSmrg# ARG is the $build file name to be converted to w32 format. 30113e72ca8cSmrg# Result is available in $func_convert_core_file_wine_to_w32_result, and will 30123e72ca8cSmrg# be empty on error (or when ARG is empty) 30133e72ca8cSmrgfunc_convert_core_file_wine_to_w32 () 30143e72ca8cSmrg{ 3015fe24f8a2Smrg $debug_cmd 3016fe24f8a2Smrg 3017fe24f8a2Smrg func_convert_core_file_wine_to_w32_result=$1 30183e72ca8cSmrg if test -n "$1"; then 30193e72ca8cSmrg # Unfortunately, winepath does not exit with a non-zero error code, so we 30203e72ca8cSmrg # are forced to check the contents of stdout. On the other hand, if the 30213e72ca8cSmrg # command is not found, the shell will set an exit code of 127 and print 30223e72ca8cSmrg # *an error message* to stdout. So we must check for both error code of 30233e72ca8cSmrg # zero AND non-empty stdout, which explains the odd construction: 30243e72ca8cSmrg func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null` 3025fe24f8a2Smrg if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then 30263e72ca8cSmrg func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | 3027fe24f8a2Smrg $SED -e "$sed_naive_backslashify"` 30283e72ca8cSmrg else 30293e72ca8cSmrg func_convert_core_file_wine_to_w32_result= 30303e72ca8cSmrg fi 30313e72ca8cSmrg fi 30323e72ca8cSmrg} 30333e72ca8cSmrg# end: func_convert_core_file_wine_to_w32 30343e72ca8cSmrg 30353e72ca8cSmrg 30363e72ca8cSmrg# func_convert_core_path_wine_to_w32 ARG 30373e72ca8cSmrg# Helper function used by path conversion functions when $build is *nix, and 30383e72ca8cSmrg# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly 30393e72ca8cSmrg# configured wine environment available, with the winepath program in $build's 30403e72ca8cSmrg# $PATH. Assumes ARG has no leading or trailing path separator characters. 30413e72ca8cSmrg# 30423e72ca8cSmrg# ARG is path to be converted from $build format to win32. 30433e72ca8cSmrg# Result is available in $func_convert_core_path_wine_to_w32_result. 30443e72ca8cSmrg# Unconvertible file (directory) names in ARG are skipped; if no directory names 30453e72ca8cSmrg# are convertible, then the result may be empty. 30463e72ca8cSmrgfunc_convert_core_path_wine_to_w32 () 30473e72ca8cSmrg{ 3048fe24f8a2Smrg $debug_cmd 3049fe24f8a2Smrg 30503e72ca8cSmrg # unfortunately, winepath doesn't convert paths, only file names 3051fe24f8a2Smrg func_convert_core_path_wine_to_w32_result= 30523e72ca8cSmrg if test -n "$1"; then 30533e72ca8cSmrg oldIFS=$IFS 30543e72ca8cSmrg IFS=: 30553e72ca8cSmrg for func_convert_core_path_wine_to_w32_f in $1; do 30563e72ca8cSmrg IFS=$oldIFS 30573e72ca8cSmrg func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" 3058fe24f8a2Smrg if test -n "$func_convert_core_file_wine_to_w32_result"; then 30593e72ca8cSmrg if test -z "$func_convert_core_path_wine_to_w32_result"; then 3060fe24f8a2Smrg func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result 30613e72ca8cSmrg else 30623e72ca8cSmrg func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" 30633e72ca8cSmrg fi 30643e72ca8cSmrg fi 30653e72ca8cSmrg done 30663e72ca8cSmrg IFS=$oldIFS 30673e72ca8cSmrg fi 30683e72ca8cSmrg} 30693e72ca8cSmrg# end: func_convert_core_path_wine_to_w32 30703e72ca8cSmrg 30713e72ca8cSmrg 30723e72ca8cSmrg# func_cygpath ARGS... 30733e72ca8cSmrg# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when 30743e72ca8cSmrg# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) 30753e72ca8cSmrg# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or 30763e72ca8cSmrg# (2), returns the Cygwin file name or path in func_cygpath_result (input 30773e72ca8cSmrg# file name or path is assumed to be in w32 format, as previously converted 30783e72ca8cSmrg# from $build's *nix or MSYS format). In case (3), returns the w32 file name 30793e72ca8cSmrg# or path in func_cygpath_result (input file name or path is assumed to be in 30803e72ca8cSmrg# Cygwin format). Returns an empty string on error. 30813e72ca8cSmrg# 30823e72ca8cSmrg# ARGS are passed to cygpath, with the last one being the file name or path to 30833e72ca8cSmrg# be converted. 30843e72ca8cSmrg# 30853e72ca8cSmrg# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH 30863e72ca8cSmrg# environment variable; do not put it in $PATH. 30873e72ca8cSmrgfunc_cygpath () 30883e72ca8cSmrg{ 3089fe24f8a2Smrg $debug_cmd 3090fe24f8a2Smrg 30913e72ca8cSmrg if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then 30923e72ca8cSmrg func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` 30933e72ca8cSmrg if test "$?" -ne 0; then 30943e72ca8cSmrg # on failure, ensure result is empty 30953e72ca8cSmrg func_cygpath_result= 30963e72ca8cSmrg fi 30973e72ca8cSmrg else 30983e72ca8cSmrg func_cygpath_result= 3099fe24f8a2Smrg func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'" 31003e72ca8cSmrg fi 31013e72ca8cSmrg} 31023e72ca8cSmrg#end: func_cygpath 31033e72ca8cSmrg 31043e72ca8cSmrg 31053e72ca8cSmrg# func_convert_core_msys_to_w32 ARG 31063e72ca8cSmrg# Convert file name or path ARG from MSYS format to w32 format. Return 31073e72ca8cSmrg# result in func_convert_core_msys_to_w32_result. 31083e72ca8cSmrgfunc_convert_core_msys_to_w32 () 31093e72ca8cSmrg{ 3110fe24f8a2Smrg $debug_cmd 3111fe24f8a2Smrg 31123e72ca8cSmrg # awkward: cmd appends spaces to result 31133e72ca8cSmrg func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | 3114fe24f8a2Smrg $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"` 31153e72ca8cSmrg} 31163e72ca8cSmrg#end: func_convert_core_msys_to_w32 31173e72ca8cSmrg 31183e72ca8cSmrg 31193e72ca8cSmrg# func_convert_file_check ARG1 ARG2 31203e72ca8cSmrg# Verify that ARG1 (a file name in $build format) was converted to $host 31213e72ca8cSmrg# format in ARG2. Otherwise, emit an error message, but continue (resetting 31223e72ca8cSmrg# func_to_host_file_result to ARG1). 31233e72ca8cSmrgfunc_convert_file_check () 31243e72ca8cSmrg{ 3125fe24f8a2Smrg $debug_cmd 3126fe24f8a2Smrg 3127fe24f8a2Smrg if test -z "$2" && test -n "$1"; then 31283e72ca8cSmrg func_error "Could not determine host file name corresponding to" 3129fe24f8a2Smrg func_error " '$1'" 31303e72ca8cSmrg func_error "Continuing, but uninstalled executables may not work." 31313e72ca8cSmrg # Fallback: 3132fe24f8a2Smrg func_to_host_file_result=$1 31333e72ca8cSmrg fi 31343e72ca8cSmrg} 31353e72ca8cSmrg# end func_convert_file_check 31363e72ca8cSmrg 31373e72ca8cSmrg 31383e72ca8cSmrg# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH 31393e72ca8cSmrg# Verify that FROM_PATH (a path in $build format) was converted to $host 31403e72ca8cSmrg# format in TO_PATH. Otherwise, emit an error message, but continue, resetting 31413e72ca8cSmrg# func_to_host_file_result to a simplistic fallback value (see below). 31423e72ca8cSmrgfunc_convert_path_check () 31433e72ca8cSmrg{ 3144fe24f8a2Smrg $debug_cmd 3145fe24f8a2Smrg 31463e72ca8cSmrg if test -z "$4" && test -n "$3"; then 31473e72ca8cSmrg func_error "Could not determine the host path corresponding to" 3148fe24f8a2Smrg func_error " '$3'" 31493e72ca8cSmrg func_error "Continuing, but uninstalled executables may not work." 31503e72ca8cSmrg # Fallback. This is a deliberately simplistic "conversion" and 31513e72ca8cSmrg # should not be "improved". See libtool.info. 31523e72ca8cSmrg if test "x$1" != "x$2"; then 31533e72ca8cSmrg lt_replace_pathsep_chars="s|$1|$2|g" 31543e72ca8cSmrg func_to_host_path_result=`echo "$3" | 31553e72ca8cSmrg $SED -e "$lt_replace_pathsep_chars"` 31563e72ca8cSmrg else 3157fe24f8a2Smrg func_to_host_path_result=$3 31583e72ca8cSmrg fi 31593e72ca8cSmrg fi 31603e72ca8cSmrg} 31613e72ca8cSmrg# end func_convert_path_check 31623e72ca8cSmrg 31633e72ca8cSmrg 31643e72ca8cSmrg# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG 31653e72ca8cSmrg# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT 31663e72ca8cSmrg# and appending REPL if ORIG matches BACKPAT. 31673e72ca8cSmrgfunc_convert_path_front_back_pathsep () 31683e72ca8cSmrg{ 3169fe24f8a2Smrg $debug_cmd 3170fe24f8a2Smrg 31713e72ca8cSmrg case $4 in 3172fe24f8a2Smrg $1 ) func_to_host_path_result=$3$func_to_host_path_result 31733e72ca8cSmrg ;; 31743e72ca8cSmrg esac 31753e72ca8cSmrg case $4 in 31763e72ca8cSmrg $2 ) func_append func_to_host_path_result "$3" 31773e72ca8cSmrg ;; 31783e72ca8cSmrg esac 31793e72ca8cSmrg} 31803e72ca8cSmrg# end func_convert_path_front_back_pathsep 31813e72ca8cSmrg 31823e72ca8cSmrg 31833e72ca8cSmrg################################################## 31843e72ca8cSmrg# $build to $host FILE NAME CONVERSION FUNCTIONS # 31853e72ca8cSmrg################################################## 3186fe24f8a2Smrg# invoked via '$to_host_file_cmd ARG' 31873e72ca8cSmrg# 31883e72ca8cSmrg# In each case, ARG is the path to be converted from $build to $host format. 31893e72ca8cSmrg# Result will be available in $func_to_host_file_result. 31903e72ca8cSmrg 31913e72ca8cSmrg 31923e72ca8cSmrg# func_to_host_file ARG 31933e72ca8cSmrg# Converts the file name ARG from $build format to $host format. Return result 31943e72ca8cSmrg# in func_to_host_file_result. 31953e72ca8cSmrgfunc_to_host_file () 31963e72ca8cSmrg{ 3197fe24f8a2Smrg $debug_cmd 3198fe24f8a2Smrg 31993e72ca8cSmrg $to_host_file_cmd "$1" 32003e72ca8cSmrg} 32013e72ca8cSmrg# end func_to_host_file 32023e72ca8cSmrg 32033e72ca8cSmrg 32043e72ca8cSmrg# func_to_tool_file ARG LAZY 32053e72ca8cSmrg# converts the file name ARG from $build format to toolchain format. Return 32063e72ca8cSmrg# result in func_to_tool_file_result. If the conversion in use is listed 32073e72ca8cSmrg# in (the comma separated) LAZY, no conversion takes place. 32083e72ca8cSmrgfunc_to_tool_file () 32093e72ca8cSmrg{ 3210fe24f8a2Smrg $debug_cmd 3211fe24f8a2Smrg 32123e72ca8cSmrg case ,$2, in 32133e72ca8cSmrg *,"$to_tool_file_cmd",*) 32143e72ca8cSmrg func_to_tool_file_result=$1 32153e72ca8cSmrg ;; 32163e72ca8cSmrg *) 32173e72ca8cSmrg $to_tool_file_cmd "$1" 32183e72ca8cSmrg func_to_tool_file_result=$func_to_host_file_result 32193e72ca8cSmrg ;; 32203e72ca8cSmrg esac 32213e72ca8cSmrg} 32223e72ca8cSmrg# end func_to_tool_file 32233e72ca8cSmrg 32243e72ca8cSmrg 32253e72ca8cSmrg# func_convert_file_noop ARG 32263e72ca8cSmrg# Copy ARG to func_to_host_file_result. 32273e72ca8cSmrgfunc_convert_file_noop () 32283e72ca8cSmrg{ 3229fe24f8a2Smrg func_to_host_file_result=$1 32303e72ca8cSmrg} 32313e72ca8cSmrg# end func_convert_file_noop 32323e72ca8cSmrg 32333e72ca8cSmrg 32343e72ca8cSmrg# func_convert_file_msys_to_w32 ARG 32353e72ca8cSmrg# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic 32363e72ca8cSmrg# conversion to w32 is not available inside the cwrapper. Returns result in 32373e72ca8cSmrg# func_to_host_file_result. 32383e72ca8cSmrgfunc_convert_file_msys_to_w32 () 32393e72ca8cSmrg{ 3240fe24f8a2Smrg $debug_cmd 3241fe24f8a2Smrg 3242fe24f8a2Smrg func_to_host_file_result=$1 32433e72ca8cSmrg if test -n "$1"; then 32443e72ca8cSmrg func_convert_core_msys_to_w32 "$1" 3245fe24f8a2Smrg func_to_host_file_result=$func_convert_core_msys_to_w32_result 32463e72ca8cSmrg fi 32473e72ca8cSmrg func_convert_file_check "$1" "$func_to_host_file_result" 32483e72ca8cSmrg} 32493e72ca8cSmrg# end func_convert_file_msys_to_w32 32503e72ca8cSmrg 32513e72ca8cSmrg 32523e72ca8cSmrg# func_convert_file_cygwin_to_w32 ARG 32533e72ca8cSmrg# Convert file name ARG from Cygwin to w32 format. Returns result in 32543e72ca8cSmrg# func_to_host_file_result. 32553e72ca8cSmrgfunc_convert_file_cygwin_to_w32 () 32563e72ca8cSmrg{ 3257fe24f8a2Smrg $debug_cmd 3258fe24f8a2Smrg 3259fe24f8a2Smrg func_to_host_file_result=$1 32603e72ca8cSmrg if test -n "$1"; then 32613e72ca8cSmrg # because $build is cygwin, we call "the" cygpath in $PATH; no need to use 32623e72ca8cSmrg # LT_CYGPATH in this case. 32633e72ca8cSmrg func_to_host_file_result=`cygpath -m "$1"` 32643e72ca8cSmrg fi 32653e72ca8cSmrg func_convert_file_check "$1" "$func_to_host_file_result" 32663e72ca8cSmrg} 32673e72ca8cSmrg# end func_convert_file_cygwin_to_w32 32683e72ca8cSmrg 32693e72ca8cSmrg 32703e72ca8cSmrg# func_convert_file_nix_to_w32 ARG 32713e72ca8cSmrg# Convert file name ARG from *nix to w32 format. Requires a wine environment 32723e72ca8cSmrg# and a working winepath. Returns result in func_to_host_file_result. 32733e72ca8cSmrgfunc_convert_file_nix_to_w32 () 32743e72ca8cSmrg{ 3275fe24f8a2Smrg $debug_cmd 3276fe24f8a2Smrg 3277fe24f8a2Smrg func_to_host_file_result=$1 32783e72ca8cSmrg if test -n "$1"; then 32793e72ca8cSmrg func_convert_core_file_wine_to_w32 "$1" 3280fe24f8a2Smrg func_to_host_file_result=$func_convert_core_file_wine_to_w32_result 32813e72ca8cSmrg fi 32823e72ca8cSmrg func_convert_file_check "$1" "$func_to_host_file_result" 32833e72ca8cSmrg} 32843e72ca8cSmrg# end func_convert_file_nix_to_w32 32853e72ca8cSmrg 32863e72ca8cSmrg 32873e72ca8cSmrg# func_convert_file_msys_to_cygwin ARG 32883e72ca8cSmrg# Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 32893e72ca8cSmrg# Returns result in func_to_host_file_result. 32903e72ca8cSmrgfunc_convert_file_msys_to_cygwin () 32913e72ca8cSmrg{ 3292fe24f8a2Smrg $debug_cmd 3293fe24f8a2Smrg 3294fe24f8a2Smrg func_to_host_file_result=$1 32953e72ca8cSmrg if test -n "$1"; then 32963e72ca8cSmrg func_convert_core_msys_to_w32 "$1" 32973e72ca8cSmrg func_cygpath -u "$func_convert_core_msys_to_w32_result" 3298fe24f8a2Smrg func_to_host_file_result=$func_cygpath_result 32993e72ca8cSmrg fi 33003e72ca8cSmrg func_convert_file_check "$1" "$func_to_host_file_result" 33013e72ca8cSmrg} 33023e72ca8cSmrg# end func_convert_file_msys_to_cygwin 33033e72ca8cSmrg 33043e72ca8cSmrg 33053e72ca8cSmrg# func_convert_file_nix_to_cygwin ARG 33063e72ca8cSmrg# Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed 33073e72ca8cSmrg# in a wine environment, working winepath, and LT_CYGPATH set. Returns result 33083e72ca8cSmrg# in func_to_host_file_result. 33093e72ca8cSmrgfunc_convert_file_nix_to_cygwin () 33103e72ca8cSmrg{ 3311fe24f8a2Smrg $debug_cmd 3312fe24f8a2Smrg 3313fe24f8a2Smrg func_to_host_file_result=$1 33143e72ca8cSmrg if test -n "$1"; then 33153e72ca8cSmrg # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. 33163e72ca8cSmrg func_convert_core_file_wine_to_w32 "$1" 33173e72ca8cSmrg func_cygpath -u "$func_convert_core_file_wine_to_w32_result" 3318fe24f8a2Smrg func_to_host_file_result=$func_cygpath_result 33193e72ca8cSmrg fi 33203e72ca8cSmrg func_convert_file_check "$1" "$func_to_host_file_result" 33213e72ca8cSmrg} 33223e72ca8cSmrg# end func_convert_file_nix_to_cygwin 33233e72ca8cSmrg 33243e72ca8cSmrg 33253e72ca8cSmrg############################################# 33263e72ca8cSmrg# $build to $host PATH CONVERSION FUNCTIONS # 33273e72ca8cSmrg############################################# 3328fe24f8a2Smrg# invoked via '$to_host_path_cmd ARG' 33293e72ca8cSmrg# 33303e72ca8cSmrg# In each case, ARG is the path to be converted from $build to $host format. 33313e72ca8cSmrg# The result will be available in $func_to_host_path_result. 33323e72ca8cSmrg# 33333e72ca8cSmrg# Path separators are also converted from $build format to $host format. If 33343e72ca8cSmrg# ARG begins or ends with a path separator character, it is preserved (but 33353e72ca8cSmrg# converted to $host format) on output. 33363e72ca8cSmrg# 33373e72ca8cSmrg# All path conversion functions are named using the following convention: 33383e72ca8cSmrg# file name conversion function : func_convert_file_X_to_Y () 33393e72ca8cSmrg# path conversion function : func_convert_path_X_to_Y () 33403e72ca8cSmrg# where, for any given $build/$host combination the 'X_to_Y' value is the 33413e72ca8cSmrg# same. If conversion functions are added for new $build/$host combinations, 33423e72ca8cSmrg# the two new functions must follow this pattern, or func_init_to_host_path_cmd 33433e72ca8cSmrg# will break. 33443e72ca8cSmrg 33453e72ca8cSmrg 33463e72ca8cSmrg# func_init_to_host_path_cmd 33473e72ca8cSmrg# Ensures that function "pointer" variable $to_host_path_cmd is set to the 33483e72ca8cSmrg# appropriate value, based on the value of $to_host_file_cmd. 33493e72ca8cSmrgto_host_path_cmd= 33503e72ca8cSmrgfunc_init_to_host_path_cmd () 33513e72ca8cSmrg{ 3352fe24f8a2Smrg $debug_cmd 3353fe24f8a2Smrg 33543e72ca8cSmrg if test -z "$to_host_path_cmd"; then 33553e72ca8cSmrg func_stripname 'func_convert_file_' '' "$to_host_file_cmd" 3356fe24f8a2Smrg to_host_path_cmd=func_convert_path_$func_stripname_result 33573e72ca8cSmrg fi 33583e72ca8cSmrg} 33593e72ca8cSmrg 33603e72ca8cSmrg 33613e72ca8cSmrg# func_to_host_path ARG 33623e72ca8cSmrg# Converts the path ARG from $build format to $host format. Return result 33633e72ca8cSmrg# in func_to_host_path_result. 33643e72ca8cSmrgfunc_to_host_path () 33653e72ca8cSmrg{ 3366fe24f8a2Smrg $debug_cmd 3367fe24f8a2Smrg 33683e72ca8cSmrg func_init_to_host_path_cmd 33693e72ca8cSmrg $to_host_path_cmd "$1" 33703e72ca8cSmrg} 33713e72ca8cSmrg# end func_to_host_path 33723e72ca8cSmrg 33733e72ca8cSmrg 33743e72ca8cSmrg# func_convert_path_noop ARG 33753e72ca8cSmrg# Copy ARG to func_to_host_path_result. 33763e72ca8cSmrgfunc_convert_path_noop () 33773e72ca8cSmrg{ 3378fe24f8a2Smrg func_to_host_path_result=$1 33793e72ca8cSmrg} 33803e72ca8cSmrg# end func_convert_path_noop 33813e72ca8cSmrg 33823e72ca8cSmrg 33833e72ca8cSmrg# func_convert_path_msys_to_w32 ARG 33843e72ca8cSmrg# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic 33853e72ca8cSmrg# conversion to w32 is not available inside the cwrapper. Returns result in 33863e72ca8cSmrg# func_to_host_path_result. 33873e72ca8cSmrgfunc_convert_path_msys_to_w32 () 33883e72ca8cSmrg{ 3389fe24f8a2Smrg $debug_cmd 3390fe24f8a2Smrg 3391fe24f8a2Smrg func_to_host_path_result=$1 33923e72ca8cSmrg if test -n "$1"; then 33933e72ca8cSmrg # Remove leading and trailing path separator characters from ARG. MSYS 33943e72ca8cSmrg # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; 33953e72ca8cSmrg # and winepath ignores them completely. 33963e72ca8cSmrg func_stripname : : "$1" 33973e72ca8cSmrg func_to_host_path_tmp1=$func_stripname_result 33983e72ca8cSmrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 3399fe24f8a2Smrg func_to_host_path_result=$func_convert_core_msys_to_w32_result 34003e72ca8cSmrg func_convert_path_check : ";" \ 34013e72ca8cSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 34023e72ca8cSmrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 34033e72ca8cSmrg fi 34043e72ca8cSmrg} 34053e72ca8cSmrg# end func_convert_path_msys_to_w32 34063e72ca8cSmrg 34073e72ca8cSmrg 34083e72ca8cSmrg# func_convert_path_cygwin_to_w32 ARG 34093e72ca8cSmrg# Convert path ARG from Cygwin to w32 format. Returns result in 34103e72ca8cSmrg# func_to_host_file_result. 34113e72ca8cSmrgfunc_convert_path_cygwin_to_w32 () 34123e72ca8cSmrg{ 3413fe24f8a2Smrg $debug_cmd 3414fe24f8a2Smrg 3415fe24f8a2Smrg func_to_host_path_result=$1 34163e72ca8cSmrg if test -n "$1"; then 34173e72ca8cSmrg # See func_convert_path_msys_to_w32: 34183e72ca8cSmrg func_stripname : : "$1" 34193e72ca8cSmrg func_to_host_path_tmp1=$func_stripname_result 34203e72ca8cSmrg func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` 34213e72ca8cSmrg func_convert_path_check : ";" \ 34223e72ca8cSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 34233e72ca8cSmrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 34243e72ca8cSmrg fi 34253e72ca8cSmrg} 34263e72ca8cSmrg# end func_convert_path_cygwin_to_w32 34273e72ca8cSmrg 34283e72ca8cSmrg 34293e72ca8cSmrg# func_convert_path_nix_to_w32 ARG 34303e72ca8cSmrg# Convert path ARG from *nix to w32 format. Requires a wine environment and 34313e72ca8cSmrg# a working winepath. Returns result in func_to_host_file_result. 34323e72ca8cSmrgfunc_convert_path_nix_to_w32 () 343334977a2fSmrg{ 3434fe24f8a2Smrg $debug_cmd 3435fe24f8a2Smrg 3436fe24f8a2Smrg func_to_host_path_result=$1 34373e72ca8cSmrg if test -n "$1"; then 34383e72ca8cSmrg # See func_convert_path_msys_to_w32: 34393e72ca8cSmrg func_stripname : : "$1" 34403e72ca8cSmrg func_to_host_path_tmp1=$func_stripname_result 34413e72ca8cSmrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 3442fe24f8a2Smrg func_to_host_path_result=$func_convert_core_path_wine_to_w32_result 34433e72ca8cSmrg func_convert_path_check : ";" \ 34443e72ca8cSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 34453e72ca8cSmrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 34463e72ca8cSmrg fi 34473e72ca8cSmrg} 34483e72ca8cSmrg# end func_convert_path_nix_to_w32 344934977a2fSmrg 345034977a2fSmrg 34513e72ca8cSmrg# func_convert_path_msys_to_cygwin ARG 34523e72ca8cSmrg# Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 34533e72ca8cSmrg# Returns result in func_to_host_file_result. 34543e72ca8cSmrgfunc_convert_path_msys_to_cygwin () 34553e72ca8cSmrg{ 3456fe24f8a2Smrg $debug_cmd 3457fe24f8a2Smrg 3458fe24f8a2Smrg func_to_host_path_result=$1 34593e72ca8cSmrg if test -n "$1"; then 34603e72ca8cSmrg # See func_convert_path_msys_to_w32: 34613e72ca8cSmrg func_stripname : : "$1" 34623e72ca8cSmrg func_to_host_path_tmp1=$func_stripname_result 34633e72ca8cSmrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 34643e72ca8cSmrg func_cygpath -u -p "$func_convert_core_msys_to_w32_result" 3465fe24f8a2Smrg func_to_host_path_result=$func_cygpath_result 34663e72ca8cSmrg func_convert_path_check : : \ 34673e72ca8cSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 34683e72ca8cSmrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 34693e72ca8cSmrg fi 34703e72ca8cSmrg} 34713e72ca8cSmrg# end func_convert_path_msys_to_cygwin 347234977a2fSmrg 347334977a2fSmrg 34743e72ca8cSmrg# func_convert_path_nix_to_cygwin ARG 34753e72ca8cSmrg# Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a 34763e72ca8cSmrg# a wine environment, working winepath, and LT_CYGPATH set. Returns result in 34773e72ca8cSmrg# func_to_host_file_result. 34783e72ca8cSmrgfunc_convert_path_nix_to_cygwin () 34793e72ca8cSmrg{ 3480fe24f8a2Smrg $debug_cmd 3481fe24f8a2Smrg 3482fe24f8a2Smrg func_to_host_path_result=$1 34833e72ca8cSmrg if test -n "$1"; then 34843e72ca8cSmrg # Remove leading and trailing path separator characters from 34853e72ca8cSmrg # ARG. msys behavior is inconsistent here, cygpath turns them 34863e72ca8cSmrg # into '.;' and ';.', and winepath ignores them completely. 34873e72ca8cSmrg func_stripname : : "$1" 34883e72ca8cSmrg func_to_host_path_tmp1=$func_stripname_result 34893e72ca8cSmrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 34903e72ca8cSmrg func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" 3491fe24f8a2Smrg func_to_host_path_result=$func_cygpath_result 34923e72ca8cSmrg func_convert_path_check : : \ 34933e72ca8cSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 34943e72ca8cSmrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 34953e72ca8cSmrg fi 349634977a2fSmrg} 34973e72ca8cSmrg# end func_convert_path_nix_to_cygwin 34983e72ca8cSmrg 349934977a2fSmrg 3500fe24f8a2Smrg# func_dll_def_p FILE 3501fe24f8a2Smrg# True iff FILE is a Windows DLL '.def' file. 3502fe24f8a2Smrg# Keep in sync with _LT_DLL_DEF_P in libtool.m4 3503fe24f8a2Smrgfunc_dll_def_p () 3504fe24f8a2Smrg{ 3505fe24f8a2Smrg $debug_cmd 3506fe24f8a2Smrg 3507fe24f8a2Smrg func_dll_def_p_tmp=`$SED -n \ 3508fe24f8a2Smrg -e 's/^[ ]*//' \ 3509fe24f8a2Smrg -e '/^\(;.*\)*$/d' \ 3510fe24f8a2Smrg -e 's/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p' \ 3511fe24f8a2Smrg -e q \ 3512fe24f8a2Smrg "$1"` 3513fe24f8a2Smrg test DEF = "$func_dll_def_p_tmp" 3514fe24f8a2Smrg} 3515fe24f8a2Smrg 3516fe24f8a2Smrg 351734977a2fSmrg# func_mode_compile arg... 351834977a2fSmrgfunc_mode_compile () 351934977a2fSmrg{ 3520fe24f8a2Smrg $debug_cmd 3521fe24f8a2Smrg 352234977a2fSmrg # Get the compilation command and the source file. 352334977a2fSmrg base_compile= 3524fe24f8a2Smrg srcfile=$nonopt # always keep a non-empty value in "srcfile" 352534977a2fSmrg suppress_opt=yes 352634977a2fSmrg suppress_output= 352734977a2fSmrg arg_mode=normal 352834977a2fSmrg libobj= 352934977a2fSmrg later= 353034977a2fSmrg pie_flag= 353134977a2fSmrg 353234977a2fSmrg for arg 353334977a2fSmrg do 353434977a2fSmrg case $arg_mode in 353534977a2fSmrg arg ) 353634977a2fSmrg # do not "continue". Instead, add this to base_compile 3537fe24f8a2Smrg lastarg=$arg 353834977a2fSmrg arg_mode=normal 353934977a2fSmrg ;; 354034977a2fSmrg 354134977a2fSmrg target ) 3542fe24f8a2Smrg libobj=$arg 354334977a2fSmrg arg_mode=normal 354434977a2fSmrg continue 354534977a2fSmrg ;; 354634977a2fSmrg 354734977a2fSmrg normal ) 354834977a2fSmrg # Accept any command-line options. 354934977a2fSmrg case $arg in 355034977a2fSmrg -o) 355134977a2fSmrg test -n "$libobj" && \ 3552fe24f8a2Smrg func_fatal_error "you cannot specify '-o' more than once" 355334977a2fSmrg arg_mode=target 355434977a2fSmrg continue 355534977a2fSmrg ;; 355634977a2fSmrg 355734977a2fSmrg -pie | -fpie | -fPIE) 35583e72ca8cSmrg func_append pie_flag " $arg" 355934977a2fSmrg continue 356034977a2fSmrg ;; 356134977a2fSmrg 356234977a2fSmrg -shared | -static | -prefer-pic | -prefer-non-pic) 35633e72ca8cSmrg func_append later " $arg" 356434977a2fSmrg continue 356534977a2fSmrg ;; 3566ee3138f1Smrg 3567ee3138f1Smrg -no-suppress) 3568ee3138f1Smrg suppress_opt=no 3569ee3138f1Smrg continue 3570ee3138f1Smrg ;; 3571ee3138f1Smrg 3572ee3138f1Smrg -Xcompiler) 3573ee3138f1Smrg arg_mode=arg # the next one goes into the "base_compile" arg list 3574ee3138f1Smrg continue # The current "srcfile" will either be retained or 3575ee3138f1Smrg ;; # replaced later. I would guess that would be a bug. 3576ee3138f1Smrg 3577ee3138f1Smrg -Wc,*) 357834977a2fSmrg func_stripname '-Wc,' '' "$arg" 357934977a2fSmrg args=$func_stripname_result 3580ee3138f1Smrg lastarg= 3581fe24f8a2Smrg save_ifs=$IFS; IFS=, 358234977a2fSmrg for arg in $args; do 3583fe24f8a2Smrg IFS=$save_ifs 35843e72ca8cSmrg func_append_quoted lastarg "$arg" 3585ee3138f1Smrg done 3586fe24f8a2Smrg IFS=$save_ifs 358734977a2fSmrg func_stripname ' ' '' "$lastarg" 358834977a2fSmrg lastarg=$func_stripname_result 3589ee3138f1Smrg 3590ee3138f1Smrg # Add the arguments to base_compile. 35913e72ca8cSmrg func_append base_compile " $lastarg" 3592ee3138f1Smrg continue 3593ee3138f1Smrg ;; 3594ee3138f1Smrg 359534977a2fSmrg *) 3596ee3138f1Smrg # Accept the current argument as the source file. 3597ee3138f1Smrg # The previous "srcfile" becomes the current argument. 3598ee3138f1Smrg # 3599fe24f8a2Smrg lastarg=$srcfile 3600fe24f8a2Smrg srcfile=$arg 3601ee3138f1Smrg ;; 3602ee3138f1Smrg esac # case $arg 3603ee3138f1Smrg ;; 3604ee3138f1Smrg esac # case $arg_mode 3605ee3138f1Smrg 3606ee3138f1Smrg # Aesthetically quote the previous argument. 36073e72ca8cSmrg func_append_quoted base_compile "$lastarg" 3608ee3138f1Smrg done # for arg 3609ee3138f1Smrg 3610ee3138f1Smrg case $arg_mode in 3611ee3138f1Smrg arg) 361234977a2fSmrg func_fatal_error "you must specify an argument for -Xcompile" 3613ee3138f1Smrg ;; 3614ee3138f1Smrg target) 3615fe24f8a2Smrg func_fatal_error "you must specify a target with '-o'" 3616ee3138f1Smrg ;; 3617ee3138f1Smrg *) 3618ee3138f1Smrg # Get the name of the library object. 361934977a2fSmrg test -z "$libobj" && { 362034977a2fSmrg func_basename "$srcfile" 3621fe24f8a2Smrg libobj=$func_basename_result 362234977a2fSmrg } 3623ee3138f1Smrg ;; 3624ee3138f1Smrg esac 3625ee3138f1Smrg 3626ee3138f1Smrg # Recognize several different file suffixes. 3627ee3138f1Smrg # If the user specifies -o file.o, it is replaced with file.lo 3628ee3138f1Smrg case $libobj in 362934977a2fSmrg *.[cCFSifmso] | \ 363034977a2fSmrg *.ada | *.adb | *.ads | *.asm | \ 363134977a2fSmrg *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ 36323e72ca8cSmrg *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup) 363334977a2fSmrg func_xform "$libobj" 363434977a2fSmrg libobj=$func_xform_result 363534977a2fSmrg ;; 3636ee3138f1Smrg esac 3637ee3138f1Smrg 3638ee3138f1Smrg case $libobj in 363934977a2fSmrg *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; 3640ee3138f1Smrg *) 3641fe24f8a2Smrg func_fatal_error "cannot determine name of library object from '$libobj'" 3642ee3138f1Smrg ;; 3643ee3138f1Smrg esac 3644ee3138f1Smrg 3645ee3138f1Smrg func_infer_tag $base_compile 3646ee3138f1Smrg 3647ee3138f1Smrg for arg in $later; do 3648ee3138f1Smrg case $arg in 364934977a2fSmrg -shared) 3650fe24f8a2Smrg test yes = "$build_libtool_libs" \ 3651fe24f8a2Smrg || func_fatal_configuration "cannot build a shared library" 365234977a2fSmrg build_old_libs=no 365334977a2fSmrg continue 365434977a2fSmrg ;; 365534977a2fSmrg 3656ee3138f1Smrg -static) 365734977a2fSmrg build_libtool_libs=no 3658ee3138f1Smrg build_old_libs=yes 3659ee3138f1Smrg continue 3660ee3138f1Smrg ;; 3661ee3138f1Smrg 3662ee3138f1Smrg -prefer-pic) 3663ee3138f1Smrg pic_mode=yes 3664ee3138f1Smrg continue 3665ee3138f1Smrg ;; 3666ee3138f1Smrg 3667ee3138f1Smrg -prefer-non-pic) 3668ee3138f1Smrg pic_mode=no 3669ee3138f1Smrg continue 3670ee3138f1Smrg ;; 3671ee3138f1Smrg esac 3672ee3138f1Smrg done 3673ee3138f1Smrg 36748d623946Smrg func_quote_arg pretty "$libobj" 36758d623946Smrg test "X$libobj" != "X$func_quote_arg_result" \ 367634977a2fSmrg && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ 3677fe24f8a2Smrg && func_warning "libobj name '$libobj' may not contain shell special characters." 367834977a2fSmrg func_dirname_and_basename "$obj" "/" "" 3679fe24f8a2Smrg objname=$func_basename_result 3680fe24f8a2Smrg xdir=$func_dirname_result 3681fe24f8a2Smrg lobj=$xdir$objdir/$objname 3682ee3138f1Smrg 368334977a2fSmrg test -z "$base_compile" && \ 368434977a2fSmrg func_fatal_help "you must specify a compilation command" 3685ee3138f1Smrg 3686ee3138f1Smrg # Delete any leftover library objects. 3687fe24f8a2Smrg if test yes = "$build_old_libs"; then 3688ee3138f1Smrg removelist="$obj $lobj $libobj ${libobj}T" 3689ee3138f1Smrg else 3690ee3138f1Smrg removelist="$lobj $libobj ${libobj}T" 3691ee3138f1Smrg fi 3692ee3138f1Smrg 3693ee3138f1Smrg # On Cygwin there's no "real" PIC flag so we must build both object types 3694ee3138f1Smrg case $host_os in 369534977a2fSmrg cygwin* | mingw* | pw32* | os2* | cegcc*) 3696ee3138f1Smrg pic_mode=default 3697ee3138f1Smrg ;; 3698ee3138f1Smrg esac 3699fe24f8a2Smrg if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then 3700ee3138f1Smrg # non-PIC code in shared libraries is not supported 3701ee3138f1Smrg pic_mode=default 3702ee3138f1Smrg fi 3703ee3138f1Smrg 3704ee3138f1Smrg # Calculate the filename of the output object if compiler does 3705ee3138f1Smrg # not support -o with -c 3706fe24f8a2Smrg if test no = "$compiler_c_o"; then 3707fe24f8a2Smrg output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext 3708fe24f8a2Smrg lockfile=$output_obj.lock 3709ee3138f1Smrg else 3710ee3138f1Smrg output_obj= 3711ee3138f1Smrg need_locks=no 3712ee3138f1Smrg lockfile= 3713ee3138f1Smrg fi 3714ee3138f1Smrg 3715ee3138f1Smrg # Lock this critical section if it is needed 3716ee3138f1Smrg # We use this script file to make the link, it avoids creating a new file 3717fe24f8a2Smrg if test yes = "$need_locks"; then 371834977a2fSmrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 371934977a2fSmrg func_echo "Waiting for $lockfile to be removed" 3720ee3138f1Smrg sleep 2 3721ee3138f1Smrg done 3722fe24f8a2Smrg elif test warn = "$need_locks"; then 3723ee3138f1Smrg if test -f "$lockfile"; then 372434977a2fSmrg $ECHO "\ 3725ee3138f1Smrg*** ERROR, $lockfile exists and contains: 3726ee3138f1Smrg`cat $lockfile 2>/dev/null` 3727ee3138f1Smrg 3728ee3138f1SmrgThis indicates that another process is trying to use the same 3729ee3138f1Smrgtemporary object file, and libtool could not work around it because 3730fe24f8a2Smrgyour compiler does not support '-c' and '-o' together. If you 3731ee3138f1Smrgrepeat this compilation, it may succeed, by chance, but you had better 3732ee3138f1Smrgavoid parallel builds (make -j) in this platform, or get a better 3733ee3138f1Smrgcompiler." 3734ee3138f1Smrg 373534977a2fSmrg $opt_dry_run || $RM $removelist 3736ee3138f1Smrg exit $EXIT_FAILURE 3737ee3138f1Smrg fi 37383e72ca8cSmrg func_append removelist " $output_obj" 373934977a2fSmrg $ECHO "$srcfile" > "$lockfile" 3740ee3138f1Smrg fi 3741ee3138f1Smrg 374234977a2fSmrg $opt_dry_run || $RM $removelist 37433e72ca8cSmrg func_append removelist " $lockfile" 374434977a2fSmrg trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 374534977a2fSmrg 37463e72ca8cSmrg func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 37473e72ca8cSmrg srcfile=$func_to_tool_file_result 37488d623946Smrg func_quote_arg pretty "$srcfile" 37498d623946Smrg qsrcfile=$func_quote_arg_result 3750ee3138f1Smrg 3751ee3138f1Smrg # Only build a PIC object if we are building libtool libraries. 3752fe24f8a2Smrg if test yes = "$build_libtool_libs"; then 3753ee3138f1Smrg # Without this assignment, base_compile gets emptied. 3754ee3138f1Smrg fbsd_hideous_sh_bug=$base_compile 3755ee3138f1Smrg 3756fe24f8a2Smrg if test no != "$pic_mode"; then 3757ee3138f1Smrg command="$base_compile $qsrcfile $pic_flag" 3758ee3138f1Smrg else 3759ee3138f1Smrg # Don't build PIC code 3760ee3138f1Smrg command="$base_compile $qsrcfile" 3761ee3138f1Smrg fi 3762ee3138f1Smrg 376334977a2fSmrg func_mkdir_p "$xdir$objdir" 3764ee3138f1Smrg 3765ee3138f1Smrg if test -z "$output_obj"; then 3766ee3138f1Smrg # Place PIC objects in $objdir 37673e72ca8cSmrg func_append command " -o $lobj" 3768ee3138f1Smrg fi 3769ee3138f1Smrg 377034977a2fSmrg func_show_eval_locale "$command" \ 377134977a2fSmrg 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' 3772ee3138f1Smrg 3773fe24f8a2Smrg if test warn = "$need_locks" && 3774ee3138f1Smrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 377534977a2fSmrg $ECHO "\ 3776ee3138f1Smrg*** ERROR, $lockfile contains: 3777ee3138f1Smrg`cat $lockfile 2>/dev/null` 3778ee3138f1Smrg 3779ee3138f1Smrgbut it should contain: 3780ee3138f1Smrg$srcfile 3781ee3138f1Smrg 3782ee3138f1SmrgThis indicates that another process is trying to use the same 3783ee3138f1Smrgtemporary object file, and libtool could not work around it because 3784fe24f8a2Smrgyour compiler does not support '-c' and '-o' together. If you 3785ee3138f1Smrgrepeat this compilation, it may succeed, by chance, but you had better 3786ee3138f1Smrgavoid parallel builds (make -j) in this platform, or get a better 3787ee3138f1Smrgcompiler." 3788ee3138f1Smrg 378934977a2fSmrg $opt_dry_run || $RM $removelist 3790ee3138f1Smrg exit $EXIT_FAILURE 3791ee3138f1Smrg fi 3792ee3138f1Smrg 3793ee3138f1Smrg # Just move the object if needed, then go on to compile the next one 3794ee3138f1Smrg if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then 379534977a2fSmrg func_show_eval '$MV "$output_obj" "$lobj"' \ 379634977a2fSmrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 3797ee3138f1Smrg fi 3798ee3138f1Smrg 3799ee3138f1Smrg # Allow error messages only from the first compilation. 3800fe24f8a2Smrg if test yes = "$suppress_opt"; then 380134977a2fSmrg suppress_output=' >/dev/null 2>&1' 3802ee3138f1Smrg fi 3803ee3138f1Smrg fi 3804ee3138f1Smrg 3805ee3138f1Smrg # Only build a position-dependent object if we build old libraries. 3806fe24f8a2Smrg if test yes = "$build_old_libs"; then 3807fe24f8a2Smrg if test yes != "$pic_mode"; then 3808ee3138f1Smrg # Don't build PIC code 380934977a2fSmrg command="$base_compile $qsrcfile$pie_flag" 3810ee3138f1Smrg else 3811ee3138f1Smrg command="$base_compile $qsrcfile $pic_flag" 3812ee3138f1Smrg fi 3813fe24f8a2Smrg if test yes = "$compiler_c_o"; then 38143e72ca8cSmrg func_append command " -o $obj" 3815ee3138f1Smrg fi 3816ee3138f1Smrg 3817ee3138f1Smrg # Suppress compiler output if we already did a PIC compilation. 38183e72ca8cSmrg func_append command "$suppress_output" 381934977a2fSmrg func_show_eval_locale "$command" \ 382034977a2fSmrg '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 3821ee3138f1Smrg 3822fe24f8a2Smrg if test warn = "$need_locks" && 3823ee3138f1Smrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 382434977a2fSmrg $ECHO "\ 3825ee3138f1Smrg*** ERROR, $lockfile contains: 3826ee3138f1Smrg`cat $lockfile 2>/dev/null` 3827ee3138f1Smrg 3828ee3138f1Smrgbut it should contain: 3829ee3138f1Smrg$srcfile 3830ee3138f1Smrg 3831ee3138f1SmrgThis indicates that another process is trying to use the same 3832ee3138f1Smrgtemporary object file, and libtool could not work around it because 3833fe24f8a2Smrgyour compiler does not support '-c' and '-o' together. If you 3834ee3138f1Smrgrepeat this compilation, it may succeed, by chance, but you had better 3835ee3138f1Smrgavoid parallel builds (make -j) in this platform, or get a better 3836ee3138f1Smrgcompiler." 3837ee3138f1Smrg 383834977a2fSmrg $opt_dry_run || $RM $removelist 3839ee3138f1Smrg exit $EXIT_FAILURE 3840ee3138f1Smrg fi 3841ee3138f1Smrg 3842ee3138f1Smrg # Just move the object if needed 3843ee3138f1Smrg if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then 384434977a2fSmrg func_show_eval '$MV "$output_obj" "$obj"' \ 384534977a2fSmrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 3846ee3138f1Smrg fi 3847ee3138f1Smrg fi 3848ee3138f1Smrg 384934977a2fSmrg $opt_dry_run || { 385034977a2fSmrg func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" 3851ee3138f1Smrg 385234977a2fSmrg # Unlock the critical section if it was locked 3853fe24f8a2Smrg if test no != "$need_locks"; then 385434977a2fSmrg removelist=$lockfile 385534977a2fSmrg $RM "$lockfile" 385634977a2fSmrg fi 385734977a2fSmrg } 3858ee3138f1Smrg 3859ee3138f1Smrg exit $EXIT_SUCCESS 386034977a2fSmrg} 3861ee3138f1Smrg 386234977a2fSmrg$opt_help || { 3863fe24f8a2Smrg test compile = "$opt_mode" && func_mode_compile ${1+"$@"} 386434977a2fSmrg} 3865ee3138f1Smrg 386634977a2fSmrgfunc_mode_help () 386734977a2fSmrg{ 386834977a2fSmrg # We need to display help for each of the modes. 38693e72ca8cSmrg case $opt_mode in 387034977a2fSmrg "") 387134977a2fSmrg # Generic help is extracted from the usage comments 387234977a2fSmrg # at the start of this file. 387334977a2fSmrg func_help 387434977a2fSmrg ;; 3875ee3138f1Smrg 387634977a2fSmrg clean) 387734977a2fSmrg $ECHO \ 387834977a2fSmrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... 3879ee3138f1Smrg 388034977a2fSmrgRemove files from the build directory. 3881ee3138f1Smrg 388234977a2fSmrgRM is the name of the program to use to delete files associated with each FILE 3883fe24f8a2Smrg(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 388434977a2fSmrgto RM. 3885ee3138f1Smrg 388634977a2fSmrgIf FILE is a libtool library, object or program, all the files associated 388734977a2fSmrgwith it are deleted. Otherwise, only FILE itself is deleted using RM." 388834977a2fSmrg ;; 3889ee3138f1Smrg 389034977a2fSmrg compile) 389134977a2fSmrg $ECHO \ 389234977a2fSmrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE 3893ee3138f1Smrg 389434977a2fSmrgCompile a source file into a libtool library object. 3895ee3138f1Smrg 389634977a2fSmrgThis mode accepts the following additional options: 3897ee3138f1Smrg 389834977a2fSmrg -o OUTPUT-FILE set the output file name to OUTPUT-FILE 389934977a2fSmrg -no-suppress do not suppress compiler output for multiple passes 3900b425557eSmrg -prefer-pic try to build PIC objects only 3901b425557eSmrg -prefer-non-pic try to build non-PIC objects only 3902fe24f8a2Smrg -shared do not build a '.o' file suitable for static linking 3903fe24f8a2Smrg -static only build a '.o' file suitable for static linking 39048d623946Smrg -Wc,FLAG 39058d623946Smrg -Xcompiler FLAG pass FLAG directly to the compiler 3906ee3138f1Smrg 3907fe24f8a2SmrgCOMPILE-COMMAND is a command to be used in creating a 'standard' object file 390834977a2fSmrgfrom the given SOURCEFILE. 3909ee3138f1Smrg 391034977a2fSmrgThe output file name is determined by removing the directory component from 3911fe24f8a2SmrgSOURCEFILE, then substituting the C source code suffix '.c' with the 3912fe24f8a2Smrglibrary object suffix, '.lo'." 391334977a2fSmrg ;; 3914ee3138f1Smrg 391534977a2fSmrg execute) 391634977a2fSmrg $ECHO \ 391734977a2fSmrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... 3918ee3138f1Smrg 391934977a2fSmrgAutomatically set library path, then run a program. 3920ee3138f1Smrg 392134977a2fSmrgThis mode accepts the following additional options: 3922ee3138f1Smrg 392334977a2fSmrg -dlopen FILE add the directory containing FILE to the library path 3924ee3138f1Smrg 3925fe24f8a2SmrgThis mode sets the library path environment variable according to '-dlopen' 392634977a2fSmrgflags. 3927ee3138f1Smrg 392834977a2fSmrgIf any of the ARGS are libtool executable wrappers, then they are translated 392934977a2fSmrginto their corresponding uninstalled binary, and any of their required library 393034977a2fSmrgdirectories are added to the library path. 3931ee3138f1Smrg 393234977a2fSmrgThen, COMMAND is executed, with ARGS as arguments." 393334977a2fSmrg ;; 3934ee3138f1Smrg 393534977a2fSmrg finish) 393634977a2fSmrg $ECHO \ 393734977a2fSmrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]... 3938ee3138f1Smrg 393934977a2fSmrgComplete the installation of libtool libraries. 3940ee3138f1Smrg 394134977a2fSmrgEach LIBDIR is a directory that contains libtool libraries. 3942ee3138f1Smrg 394334977a2fSmrgThe commands that this mode executes may require superuser privileges. Use 3944fe24f8a2Smrgthe '--dry-run' option if you just want to see what would be executed." 394534977a2fSmrg ;; 3946ee3138f1Smrg 394734977a2fSmrg install) 394834977a2fSmrg $ECHO \ 394934977a2fSmrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... 3950ee3138f1Smrg 395134977a2fSmrgInstall executables or libraries. 3952ee3138f1Smrg 395334977a2fSmrgINSTALL-COMMAND is the installation command. The first component should be 3954fe24f8a2Smrgeither the 'install' or 'cp' program. 3955ee3138f1Smrg 395634977a2fSmrgThe following components of INSTALL-COMMAND are treated specially: 3957ee3138f1Smrg 3958b425557eSmrg -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation 3959ee3138f1Smrg 396034977a2fSmrgThe rest of the components are interpreted as arguments to that command (only 396134977a2fSmrgBSD-compatible install options are recognized)." 396234977a2fSmrg ;; 3963ee3138f1Smrg 396434977a2fSmrg link) 396534977a2fSmrg $ECHO \ 396634977a2fSmrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND... 3967ee3138f1Smrg 396834977a2fSmrgLink object files or libraries together to form another library, or to 396934977a2fSmrgcreate an executable program. 3970ee3138f1Smrg 397134977a2fSmrgLINK-COMMAND is a command using the C compiler that you would use to create 397234977a2fSmrga program from several object files. 3973ee3138f1Smrg 397434977a2fSmrgThe following components of LINK-COMMAND are treated specially: 3975ee3138f1Smrg 397634977a2fSmrg -all-static do not do any dynamic linking at all 397734977a2fSmrg -avoid-version do not add a version suffix if possible 3978b425557eSmrg -bindir BINDIR specify path to binaries directory (for systems where 3979b425557eSmrg libraries must be found in the PATH setting at runtime) 3980fe24f8a2Smrg -dlopen FILE '-dlpreopen' FILE if it cannot be dlopened at runtime 398134977a2fSmrg -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols 398234977a2fSmrg -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) 398334977a2fSmrg -export-symbols SYMFILE 398434977a2fSmrg try to export only the symbols listed in SYMFILE 398534977a2fSmrg -export-symbols-regex REGEX 398634977a2fSmrg try to export only the symbols matching REGEX 398734977a2fSmrg -LLIBDIR search LIBDIR for required installed libraries 398834977a2fSmrg -lNAME OUTPUT-FILE requires the installed library libNAME 398934977a2fSmrg -module build a library that can dlopened 399034977a2fSmrg -no-fast-install disable the fast-install mode 399134977a2fSmrg -no-install link a not-installable executable 399234977a2fSmrg -no-undefined declare that a library does not refer to external symbols 399334977a2fSmrg -o OUTPUT-FILE create OUTPUT-FILE from the specified objects 3994fe24f8a2Smrg -objectlist FILE use a list of object files found in FILE to specify objects 3995fe24f8a2Smrg -os2dllname NAME force a short DLL name on OS/2 (no effect on other OSes) 399634977a2fSmrg -precious-files-regex REGEX 399734977a2fSmrg don't remove output files matching REGEX 399834977a2fSmrg -release RELEASE specify package release information 399934977a2fSmrg -rpath LIBDIR the created library will eventually be installed in LIBDIR 400034977a2fSmrg -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries 400134977a2fSmrg -shared only do dynamic linking of libtool libraries 400234977a2fSmrg -shrext SUFFIX override the standard shared library file extension 400334977a2fSmrg -static do not do any dynamic linking of uninstalled libtool libraries 400434977a2fSmrg -static-libtool-libs 400534977a2fSmrg do not do any dynamic linking of libtool libraries 400634977a2fSmrg -version-info CURRENT[:REVISION[:AGE]] 400734977a2fSmrg specify library version info [each variable defaults to 0] 400834977a2fSmrg -weak LIBNAME declare that the target provides the LIBNAME interface 4009b425557eSmrg -Wc,FLAG 4010b425557eSmrg -Xcompiler FLAG pass linker-specific FLAG directly to the compiler 40118d623946Smrg -Wa,FLAG 40128d623946Smrg -Xassembler FLAG pass linker-specific FLAG directly to the assembler 4013b425557eSmrg -Wl,FLAG 4014b425557eSmrg -Xlinker FLAG pass linker-specific FLAG directly to the linker 4015b425557eSmrg -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) 4016ee3138f1Smrg 4017fe24f8a2SmrgAll other options (arguments beginning with '-') are ignored. 4018ee3138f1Smrg 4019fe24f8a2SmrgEvery other argument is treated as a filename. Files ending in '.la' are 402034977a2fSmrgtreated as uninstalled libtool libraries, other files are standard or library 402134977a2fSmrgobject files. 402279a8a9c6Smrg 4023fe24f8a2SmrgIf the OUTPUT-FILE ends in '.la', then a libtool library is created, 4024fe24f8a2Smrgonly library objects ('.lo' files) may be specified, and '-rpath' is 402534977a2fSmrgrequired, except when creating a convenience library. 4026ee3138f1Smrg 4027fe24f8a2SmrgIf OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created 4028fe24f8a2Smrgusing 'ar' and 'ranlib', or on Windows using 'lib'. 4029ee3138f1Smrg 4030fe24f8a2SmrgIf OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file 403134977a2fSmrgis created, otherwise an executable program is created." 4032ee3138f1Smrg ;; 4033ee3138f1Smrg 403434977a2fSmrg uninstall) 403534977a2fSmrg $ECHO \ 403634977a2fSmrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... 4037ee3138f1Smrg 403834977a2fSmrgRemove libraries from an installation directory. 4039ee3138f1Smrg 404034977a2fSmrgRM is the name of the program to use to delete files associated with each FILE 4041fe24f8a2Smrg(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 404234977a2fSmrgto RM. 4043ee3138f1Smrg 404434977a2fSmrgIf FILE is a libtool library, all the files associated with it are deleted. 404534977a2fSmrgOtherwise, only FILE itself is deleted using RM." 404634977a2fSmrg ;; 4047ee3138f1Smrg 404834977a2fSmrg *) 4049fe24f8a2Smrg func_fatal_help "invalid operation mode '$opt_mode'" 405034977a2fSmrg ;; 405134977a2fSmrg esac 4052ee3138f1Smrg 4053b425557eSmrg echo 4054fe24f8a2Smrg $ECHO "Try '$progname --help' for more information about other modes." 405534977a2fSmrg} 4056ee3138f1Smrg 4057b425557eSmrg# Now that we've collected a possible --mode arg, show help if necessary 4058b425557eSmrgif $opt_help; then 4059fe24f8a2Smrg if test : = "$opt_help"; then 4060b425557eSmrg func_mode_help 4061b425557eSmrg else 4062b425557eSmrg { 4063b425557eSmrg func_help noexit 40643e72ca8cSmrg for opt_mode in compile link execute install finish uninstall clean; do 4065b425557eSmrg func_mode_help 4066b425557eSmrg done 4067fe24f8a2Smrg } | $SED -n '1p; 2,$s/^Usage:/ or: /p' 4068b425557eSmrg { 4069b425557eSmrg func_help noexit 40703e72ca8cSmrg for opt_mode in compile link execute install finish uninstall clean; do 4071b425557eSmrg echo 4072b425557eSmrg func_mode_help 4073b425557eSmrg done 4074b425557eSmrg } | 4075fe24f8a2Smrg $SED '1d 4076b425557eSmrg /^When reporting/,/^Report/{ 4077b425557eSmrg H 4078b425557eSmrg d 4079b425557eSmrg } 4080b425557eSmrg $x 4081b425557eSmrg /information about other modes/d 4082b425557eSmrg /more detailed .*MODE/d 4083b425557eSmrg s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' 4084b425557eSmrg fi 4085b425557eSmrg exit $? 4086b425557eSmrgfi 4087ee3138f1Smrg 4088ee3138f1Smrg 408934977a2fSmrg# func_mode_execute arg... 409034977a2fSmrgfunc_mode_execute () 409134977a2fSmrg{ 4092fe24f8a2Smrg $debug_cmd 4093fe24f8a2Smrg 409434977a2fSmrg # The first argument is the command name. 4095fe24f8a2Smrg cmd=$nonopt 409634977a2fSmrg test -z "$cmd" && \ 409734977a2fSmrg func_fatal_help "you must specify a COMMAND" 4098ee3138f1Smrg 409934977a2fSmrg # Handle -dlopen flags immediately. 41003e72ca8cSmrg for file in $opt_dlopen; do 410134977a2fSmrg test -f "$file" \ 4102fe24f8a2Smrg || func_fatal_help "'$file' is not a file" 4103ee3138f1Smrg 410434977a2fSmrg dir= 410534977a2fSmrg case $file in 410634977a2fSmrg *.la) 41073e72ca8cSmrg func_resolve_sysroot "$file" 41083e72ca8cSmrg file=$func_resolve_sysroot_result 41093e72ca8cSmrg 411034977a2fSmrg # Check to see that this really is a libtool archive. 411134977a2fSmrg func_lalib_unsafe_p "$file" \ 4112fe24f8a2Smrg || func_fatal_help "'$lib' is not a valid libtool archive" 4113ee3138f1Smrg 411434977a2fSmrg # Read the libtool library. 411534977a2fSmrg dlname= 411634977a2fSmrg library_names= 411734977a2fSmrg func_source "$file" 4118ee3138f1Smrg 411934977a2fSmrg # Skip this library if it cannot be dlopened. 412034977a2fSmrg if test -z "$dlname"; then 412134977a2fSmrg # Warn if it was a shared library. 412234977a2fSmrg test -n "$library_names" && \ 4123fe24f8a2Smrg func_warning "'$file' was not linked with '-export-dynamic'" 412434977a2fSmrg continue 412534977a2fSmrg fi 4126ee3138f1Smrg 412734977a2fSmrg func_dirname "$file" "" "." 4128fe24f8a2Smrg dir=$func_dirname_result 4129ee3138f1Smrg 413034977a2fSmrg if test -f "$dir/$objdir/$dlname"; then 41313e72ca8cSmrg func_append dir "/$objdir" 413234977a2fSmrg else 413334977a2fSmrg if test ! -f "$dir/$dlname"; then 4134fe24f8a2Smrg func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'" 413534977a2fSmrg fi 413634977a2fSmrg fi 4137ee3138f1Smrg ;; 4138ee3138f1Smrg 413934977a2fSmrg *.lo) 414034977a2fSmrg # Just add the directory containing the .lo file. 414134977a2fSmrg func_dirname "$file" "" "." 4142fe24f8a2Smrg dir=$func_dirname_result 4143ee3138f1Smrg ;; 4144ee3138f1Smrg 414534977a2fSmrg *) 4146fe24f8a2Smrg func_warning "'-dlopen' is ignored for non-libtool libraries and objects" 4147ee3138f1Smrg continue 4148ee3138f1Smrg ;; 414934977a2fSmrg esac 4150ee3138f1Smrg 415134977a2fSmrg # Get the absolute pathname. 415234977a2fSmrg absdir=`cd "$dir" && pwd` 4153fe24f8a2Smrg test -n "$absdir" && dir=$absdir 4154ee3138f1Smrg 415534977a2fSmrg # Now add the directory to shlibpath_var. 415634977a2fSmrg if eval "test -z \"\$$shlibpath_var\""; then 415734977a2fSmrg eval "$shlibpath_var=\"\$dir\"" 415834977a2fSmrg else 415934977a2fSmrg eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" 416034977a2fSmrg fi 416134977a2fSmrg done 4162ee3138f1Smrg 416334977a2fSmrg # This variable tells wrapper scripts just to set shlibpath_var 416434977a2fSmrg # rather than running their programs. 4165fe24f8a2Smrg libtool_execute_magic=$magic 4166ee3138f1Smrg 416734977a2fSmrg # Check if any of the arguments is a wrapper script. 416834977a2fSmrg args= 416934977a2fSmrg for file 417034977a2fSmrg do 417134977a2fSmrg case $file in 4172b425557eSmrg -* | *.la | *.lo ) ;; 417334977a2fSmrg *) 417434977a2fSmrg # Do a test to see if this is really a libtool program. 417534977a2fSmrg if func_ltwrapper_script_p "$file"; then 417634977a2fSmrg func_source "$file" 417734977a2fSmrg # Transform arg to wrapped name. 4178fe24f8a2Smrg file=$progdir/$program 417934977a2fSmrg elif func_ltwrapper_executable_p "$file"; then 418034977a2fSmrg func_ltwrapper_scriptname "$file" 418134977a2fSmrg func_source "$func_ltwrapper_scriptname_result" 418234977a2fSmrg # Transform arg to wrapped name. 4183fe24f8a2Smrg file=$progdir/$program 418434977a2fSmrg fi 418534977a2fSmrg ;; 418634977a2fSmrg esac 418734977a2fSmrg # Quote arguments (to preserve shell metacharacters). 41883e72ca8cSmrg func_append_quoted args "$file" 418934977a2fSmrg done 4190ee3138f1Smrg 4191fe24f8a2Smrg if $opt_dry_run; then 4192fe24f8a2Smrg # Display what would be done. 4193fe24f8a2Smrg if test -n "$shlibpath_var"; then 4194fe24f8a2Smrg eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" 4195fe24f8a2Smrg echo "export $shlibpath_var" 4196fe24f8a2Smrg fi 4197fe24f8a2Smrg $ECHO "$cmd$args" 4198fe24f8a2Smrg exit $EXIT_SUCCESS 4199fe24f8a2Smrg else 420034977a2fSmrg if test -n "$shlibpath_var"; then 420134977a2fSmrg # Export the shlibpath_var. 420234977a2fSmrg eval "export $shlibpath_var" 420334977a2fSmrg fi 4204ee3138f1Smrg 420534977a2fSmrg # Restore saved environment variables 420634977a2fSmrg for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 420734977a2fSmrg do 420834977a2fSmrg eval "if test \"\${save_$lt_var+set}\" = set; then 420934977a2fSmrg $lt_var=\$save_$lt_var; export $lt_var 4210ee3138f1Smrg else 421134977a2fSmrg $lt_unset $lt_var 421234977a2fSmrg fi" 421334977a2fSmrg done 4214ee3138f1Smrg 421534977a2fSmrg # Now prepare to actually exec the command. 4216fe24f8a2Smrg exec_cmd=\$cmd$args 421734977a2fSmrg fi 421834977a2fSmrg} 4219ee3138f1Smrg 4220fe24f8a2Smrgtest execute = "$opt_mode" && func_mode_execute ${1+"$@"} 4221ee3138f1Smrg 4222ee3138f1Smrg 422334977a2fSmrg# func_mode_finish arg... 422434977a2fSmrgfunc_mode_finish () 422534977a2fSmrg{ 4226fe24f8a2Smrg $debug_cmd 4227fe24f8a2Smrg 42283e72ca8cSmrg libs= 42293e72ca8cSmrg libdirs= 423034977a2fSmrg admincmds= 4231ee3138f1Smrg 42323e72ca8cSmrg for opt in "$nonopt" ${1+"$@"} 42333e72ca8cSmrg do 42343e72ca8cSmrg if test -d "$opt"; then 42353e72ca8cSmrg func_append libdirs " $opt" 42363e72ca8cSmrg 42373e72ca8cSmrg elif test -f "$opt"; then 42383e72ca8cSmrg if func_lalib_unsafe_p "$opt"; then 42393e72ca8cSmrg func_append libs " $opt" 42403e72ca8cSmrg else 4241fe24f8a2Smrg func_warning "'$opt' is not a valid libtool archive" 42423e72ca8cSmrg fi 42433e72ca8cSmrg 42443e72ca8cSmrg else 4245fe24f8a2Smrg func_fatal_error "invalid argument '$opt'" 42463e72ca8cSmrg fi 42473e72ca8cSmrg done 42483e72ca8cSmrg 42493e72ca8cSmrg if test -n "$libs"; then 42503e72ca8cSmrg if test -n "$lt_sysroot"; then 42513e72ca8cSmrg sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` 42523e72ca8cSmrg sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" 42533e72ca8cSmrg else 42543e72ca8cSmrg sysroot_cmd= 42553e72ca8cSmrg fi 42563e72ca8cSmrg 42573e72ca8cSmrg # Remove sysroot references 42583e72ca8cSmrg if $opt_dry_run; then 42593e72ca8cSmrg for lib in $libs; do 4260fe24f8a2Smrg echo "removing references to $lt_sysroot and '=' prefixes from $lib" 42613e72ca8cSmrg done 42623e72ca8cSmrg else 42633e72ca8cSmrg tmpdir=`func_mktempdir` 42643e72ca8cSmrg for lib in $libs; do 4265fe24f8a2Smrg $SED -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ 42663e72ca8cSmrg > $tmpdir/tmp-la 42673e72ca8cSmrg mv -f $tmpdir/tmp-la $lib 42683e72ca8cSmrg done 42693e72ca8cSmrg ${RM}r "$tmpdir" 42703e72ca8cSmrg fi 42713e72ca8cSmrg fi 4272ee3138f1Smrg 42733e72ca8cSmrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 427434977a2fSmrg for libdir in $libdirs; do 427534977a2fSmrg if test -n "$finish_cmds"; then 427634977a2fSmrg # Do each command in the finish commands. 427734977a2fSmrg func_execute_cmds "$finish_cmds" 'admincmds="$admincmds 427834977a2fSmrg'"$cmd"'"' 4279ee3138f1Smrg fi 428034977a2fSmrg if test -n "$finish_eval"; then 428134977a2fSmrg # Do the single finish_eval. 428234977a2fSmrg eval cmds=\"$finish_eval\" 42833e72ca8cSmrg $opt_dry_run || eval "$cmds" || func_append admincmds " 428434977a2fSmrg $cmds" 428534977a2fSmrg fi 428634977a2fSmrg done 428734977a2fSmrg fi 4288ee3138f1Smrg 428934977a2fSmrg # Exit here if they wanted silent mode. 4290fe24f8a2Smrg $opt_quiet && exit $EXIT_SUCCESS 4291ee3138f1Smrg 42923e72ca8cSmrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 42933e72ca8cSmrg echo "----------------------------------------------------------------------" 42943e72ca8cSmrg echo "Libraries have been installed in:" 42953e72ca8cSmrg for libdir in $libdirs; do 42963e72ca8cSmrg $ECHO " $libdir" 42973e72ca8cSmrg done 42983e72ca8cSmrg echo 42993e72ca8cSmrg echo "If you ever happen to want to link against installed libraries" 43003e72ca8cSmrg echo "in a given directory, LIBDIR, you must either use libtool, and" 4301fe24f8a2Smrg echo "specify the full pathname of the library, or use the '-LLIBDIR'" 43023e72ca8cSmrg echo "flag during linking and do at least one of the following:" 43033e72ca8cSmrg if test -n "$shlibpath_var"; then 4304fe24f8a2Smrg echo " - add LIBDIR to the '$shlibpath_var' environment variable" 43053e72ca8cSmrg echo " during execution" 43063e72ca8cSmrg fi 43073e72ca8cSmrg if test -n "$runpath_var"; then 4308fe24f8a2Smrg echo " - add LIBDIR to the '$runpath_var' environment variable" 43093e72ca8cSmrg echo " during linking" 43103e72ca8cSmrg fi 43113e72ca8cSmrg if test -n "$hardcode_libdir_flag_spec"; then 43123e72ca8cSmrg libdir=LIBDIR 43133e72ca8cSmrg eval flag=\"$hardcode_libdir_flag_spec\" 4314ee3138f1Smrg 4315fe24f8a2Smrg $ECHO " - use the '$flag' linker flag" 43163e72ca8cSmrg fi 43173e72ca8cSmrg if test -n "$admincmds"; then 43183e72ca8cSmrg $ECHO " - have your system administrator run these commands:$admincmds" 43193e72ca8cSmrg fi 43203e72ca8cSmrg if test -f /etc/ld.so.conf; then 4321fe24f8a2Smrg echo " - have your system administrator add LIBDIR to '/etc/ld.so.conf'" 43223e72ca8cSmrg fi 43233e72ca8cSmrg echo 432434977a2fSmrg 43253e72ca8cSmrg echo "See any operating system documentation about shared libraries for" 43263e72ca8cSmrg case $host in 43273e72ca8cSmrg solaris2.[6789]|solaris2.1[0-9]) 43283e72ca8cSmrg echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" 43293e72ca8cSmrg echo "pages." 43303e72ca8cSmrg ;; 43313e72ca8cSmrg *) 43323e72ca8cSmrg echo "more information, such as the ld(1) and ld.so(8) manual pages." 43333e72ca8cSmrg ;; 43343e72ca8cSmrg esac 43353e72ca8cSmrg echo "----------------------------------------------------------------------" 43363e72ca8cSmrg fi 433734977a2fSmrg exit $EXIT_SUCCESS 433834977a2fSmrg} 4339ee3138f1Smrg 4340fe24f8a2Smrgtest finish = "$opt_mode" && func_mode_finish ${1+"$@"} 4341ee3138f1Smrg 434279a8a9c6Smrg 434334977a2fSmrg# func_mode_install arg... 434434977a2fSmrgfunc_mode_install () 434534977a2fSmrg{ 4346fe24f8a2Smrg $debug_cmd 4347fe24f8a2Smrg 434834977a2fSmrg # There may be an optional sh(1) argument at the beginning of 434934977a2fSmrg # install_prog (especially on Windows NT). 4350fe24f8a2Smrg if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" || 435134977a2fSmrg # Allow the use of GNU shtool's install command. 4352fe24f8a2Smrg case $nonopt in *shtool*) :;; *) false;; esac 4353fe24f8a2Smrg then 435434977a2fSmrg # Aesthetically quote it. 43558d623946Smrg func_quote_arg pretty "$nonopt" 43568d623946Smrg install_prog="$func_quote_arg_result " 435734977a2fSmrg arg=$1 435834977a2fSmrg shift 435934977a2fSmrg else 436034977a2fSmrg install_prog= 436134977a2fSmrg arg=$nonopt 4362ee3138f1Smrg fi 4363ee3138f1Smrg 436434977a2fSmrg # The real first argument should be the name of the installation program. 436534977a2fSmrg # Aesthetically quote it. 43668d623946Smrg func_quote_arg pretty "$arg" 43678d623946Smrg func_append install_prog "$func_quote_arg_result" 4368b425557eSmrg install_shared_prog=$install_prog 4369b425557eSmrg case " $install_prog " in 4370b425557eSmrg *[\\\ /]cp\ *) install_cp=: ;; 4371b425557eSmrg *) install_cp=false ;; 4372b425557eSmrg esac 4373ee3138f1Smrg 437434977a2fSmrg # We need to accept at least all the BSD install flags. 437534977a2fSmrg dest= 437634977a2fSmrg files= 437734977a2fSmrg opts= 437834977a2fSmrg prev= 437934977a2fSmrg install_type= 4380fe24f8a2Smrg isdir=false 438134977a2fSmrg stripme= 4382b425557eSmrg no_mode=: 438334977a2fSmrg for arg 438434977a2fSmrg do 4385b425557eSmrg arg2= 438634977a2fSmrg if test -n "$dest"; then 43873e72ca8cSmrg func_append files " $dest" 438834977a2fSmrg dest=$arg 438934977a2fSmrg continue 439034977a2fSmrg fi 4391ee3138f1Smrg 439234977a2fSmrg case $arg in 4393fe24f8a2Smrg -d) isdir=: ;; 439434977a2fSmrg -f) 4395b425557eSmrg if $install_cp; then :; else 4396b425557eSmrg prev=$arg 4397b425557eSmrg fi 439834977a2fSmrg ;; 439934977a2fSmrg -g | -m | -o) 440034977a2fSmrg prev=$arg 440134977a2fSmrg ;; 440234977a2fSmrg -s) 440334977a2fSmrg stripme=" -s" 440434977a2fSmrg continue 440534977a2fSmrg ;; 440634977a2fSmrg -*) 440734977a2fSmrg ;; 440834977a2fSmrg *) 440934977a2fSmrg # If the previous option needed an argument, then skip it. 441034977a2fSmrg if test -n "$prev"; then 4411fe24f8a2Smrg if test X-m = "X$prev" && test -n "$install_override_mode"; then 4412b425557eSmrg arg2=$install_override_mode 4413b425557eSmrg no_mode=false 4414b425557eSmrg fi 441534977a2fSmrg prev= 441634977a2fSmrg else 441734977a2fSmrg dest=$arg 441834977a2fSmrg continue 441934977a2fSmrg fi 442034977a2fSmrg ;; 442134977a2fSmrg esac 4422ee3138f1Smrg 442334977a2fSmrg # Aesthetically quote the argument. 44248d623946Smrg func_quote_arg pretty "$arg" 44258d623946Smrg func_append install_prog " $func_quote_arg_result" 4426b425557eSmrg if test -n "$arg2"; then 44278d623946Smrg func_quote_arg pretty "$arg2" 4428b425557eSmrg fi 44298d623946Smrg func_append install_shared_prog " $func_quote_arg_result" 443034977a2fSmrg done 443134977a2fSmrg 443234977a2fSmrg test -z "$install_prog" && \ 443334977a2fSmrg func_fatal_help "you must specify an install program" 443434977a2fSmrg 443534977a2fSmrg test -n "$prev" && \ 4436fe24f8a2Smrg func_fatal_help "the '$prev' option requires an argument" 443734977a2fSmrg 4438b425557eSmrg if test -n "$install_override_mode" && $no_mode; then 4439b425557eSmrg if $install_cp; then :; else 44408d623946Smrg func_quote_arg pretty "$install_override_mode" 44418d623946Smrg func_append install_shared_prog " -m $func_quote_arg_result" 4442b425557eSmrg fi 4443b425557eSmrg fi 4444b425557eSmrg 444534977a2fSmrg if test -z "$files"; then 444634977a2fSmrg if test -z "$dest"; then 444734977a2fSmrg func_fatal_help "no file or destination specified" 444834977a2fSmrg else 444934977a2fSmrg func_fatal_help "you must specify a destination" 4450ee3138f1Smrg fi 4451ee3138f1Smrg fi 4452ee3138f1Smrg 445334977a2fSmrg # Strip any trailing slash from the destination. 445434977a2fSmrg func_stripname '' '/' "$dest" 445534977a2fSmrg dest=$func_stripname_result 4456ee3138f1Smrg 445734977a2fSmrg # Check to see that the destination is a directory. 4458fe24f8a2Smrg test -d "$dest" && isdir=: 4459fe24f8a2Smrg if $isdir; then 4460fe24f8a2Smrg destdir=$dest 446134977a2fSmrg destname= 446234977a2fSmrg else 446334977a2fSmrg func_dirname_and_basename "$dest" "" "." 4464fe24f8a2Smrg destdir=$func_dirname_result 4465fe24f8a2Smrg destname=$func_basename_result 446634977a2fSmrg 446734977a2fSmrg # Not a directory, so check to see that there is only one file specified. 446834977a2fSmrg set dummy $files; shift 446934977a2fSmrg test "$#" -gt 1 && \ 4470fe24f8a2Smrg func_fatal_help "'$dest' is not a directory" 447134977a2fSmrg fi 447234977a2fSmrg case $destdir in 447334977a2fSmrg [\\/]* | [A-Za-z]:[\\/]*) ;; 4474ee3138f1Smrg *) 447534977a2fSmrg for file in $files; do 447634977a2fSmrg case $file in 447734977a2fSmrg *.lo) ;; 447834977a2fSmrg *) 4479fe24f8a2Smrg func_fatal_help "'$destdir' must be an absolute directory name" 448034977a2fSmrg ;; 448134977a2fSmrg esac 448234977a2fSmrg done 4483ee3138f1Smrg ;; 4484ee3138f1Smrg esac 4485ee3138f1Smrg 448634977a2fSmrg # This variable tells wrapper scripts just to set variables rather 448734977a2fSmrg # than running their programs. 4488fe24f8a2Smrg libtool_install_magic=$magic 4489ee3138f1Smrg 449034977a2fSmrg staticlibs= 449134977a2fSmrg future_libdirs= 449234977a2fSmrg current_libdirs= 449334977a2fSmrg for file in $files; do 4494ee3138f1Smrg 449534977a2fSmrg # Do each installation. 449634977a2fSmrg case $file in 449734977a2fSmrg *.$libext) 449834977a2fSmrg # Do the static libraries later. 44993e72ca8cSmrg func_append staticlibs " $file" 450034977a2fSmrg ;; 450134977a2fSmrg 450234977a2fSmrg *.la) 45033e72ca8cSmrg func_resolve_sysroot "$file" 45043e72ca8cSmrg file=$func_resolve_sysroot_result 45053e72ca8cSmrg 450634977a2fSmrg # Check to see that this really is a libtool archive. 450734977a2fSmrg func_lalib_unsafe_p "$file" \ 4508fe24f8a2Smrg || func_fatal_help "'$file' is not a valid libtool archive" 450934977a2fSmrg 451034977a2fSmrg library_names= 451134977a2fSmrg old_library= 451234977a2fSmrg relink_command= 451334977a2fSmrg func_source "$file" 451434977a2fSmrg 451534977a2fSmrg # Add the libdir to current_libdirs if it is the destination. 451634977a2fSmrg if test "X$destdir" = "X$libdir"; then 451734977a2fSmrg case "$current_libdirs " in 451834977a2fSmrg *" $libdir "*) ;; 45193e72ca8cSmrg *) func_append current_libdirs " $libdir" ;; 4520ee3138f1Smrg esac 452134977a2fSmrg else 452234977a2fSmrg # Note the libdir as a future libdir. 452334977a2fSmrg case "$future_libdirs " in 452434977a2fSmrg *" $libdir "*) ;; 45253e72ca8cSmrg *) func_append future_libdirs " $libdir" ;; 452634977a2fSmrg esac 452734977a2fSmrg fi 4528ee3138f1Smrg 452934977a2fSmrg func_dirname "$file" "/" "" 4530fe24f8a2Smrg dir=$func_dirname_result 45313e72ca8cSmrg func_append dir "$objdir" 453234977a2fSmrg 453334977a2fSmrg if test -n "$relink_command"; then 453434977a2fSmrg # Determine the prefix the user has applied to our future dir. 4535b425557eSmrg inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` 453634977a2fSmrg 453734977a2fSmrg # Don't allow the user to place us outside of our expected 453834977a2fSmrg # location b/c this prevents finding dependent libraries that 453934977a2fSmrg # are installed to the same prefix. 454034977a2fSmrg # At present, this check doesn't affect windows .dll's that 454134977a2fSmrg # are installed into $libdir/../bin (currently, that works fine) 454234977a2fSmrg # but it's something to keep an eye on. 454334977a2fSmrg test "$inst_prefix_dir" = "$destdir" && \ 4544fe24f8a2Smrg func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir" 454534977a2fSmrg 454634977a2fSmrg if test -n "$inst_prefix_dir"; then 454734977a2fSmrg # Stick the inst_prefix_dir data into the link command. 4548b425557eSmrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` 454934977a2fSmrg else 4550b425557eSmrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` 455134977a2fSmrg fi 455234977a2fSmrg 4553fe24f8a2Smrg func_warning "relinking '$file'" 455434977a2fSmrg func_show_eval "$relink_command" \ 4555fe24f8a2Smrg 'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"' 455634977a2fSmrg fi 455734977a2fSmrg 455834977a2fSmrg # See the names of the shared library. 455934977a2fSmrg set dummy $library_names; shift 456034977a2fSmrg if test -n "$1"; then 4561fe24f8a2Smrg realname=$1 456234977a2fSmrg shift 456334977a2fSmrg 4564fe24f8a2Smrg srcname=$realname 4565fe24f8a2Smrg test -n "$relink_command" && srcname=${realname}T 456634977a2fSmrg 456734977a2fSmrg # Install the shared library and build the symlinks. 4568b425557eSmrg func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ 456934977a2fSmrg 'exit $?' 4570fe24f8a2Smrg tstripme=$stripme 457134977a2fSmrg case $host_os in 457234977a2fSmrg cygwin* | mingw* | pw32* | cegcc*) 457334977a2fSmrg case $realname in 457434977a2fSmrg *.dll.a) 4575fe24f8a2Smrg tstripme= 4576fe24f8a2Smrg ;; 4577fe24f8a2Smrg esac 4578fe24f8a2Smrg ;; 4579fe24f8a2Smrg os2*) 4580fe24f8a2Smrg case $realname in 4581fe24f8a2Smrg *_dll.a) 4582fe24f8a2Smrg tstripme= 458334977a2fSmrg ;; 458434977a2fSmrg esac 4585ee3138f1Smrg ;; 4586ee3138f1Smrg esac 458734977a2fSmrg if test -n "$tstripme" && test -n "$striplib"; then 458834977a2fSmrg func_show_eval "$striplib $destdir/$realname" 'exit $?' 458979a8a9c6Smrg fi 459034977a2fSmrg 459134977a2fSmrg if test "$#" -gt 0; then 459234977a2fSmrg # Delete the old symlinks, and create new ones. 4593fe24f8a2Smrg # Try 'ln -sf' first, because the 'ln' binary might depend on 459434977a2fSmrg # the symlink we replace! Solaris /bin/ln does not understand -f, 459534977a2fSmrg # so we also need to try rm && ln -s. 459634977a2fSmrg for linkname 459734977a2fSmrg do 459834977a2fSmrg test "$linkname" != "$realname" \ 459934977a2fSmrg && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" 4600ee3138f1Smrg done 4601ee3138f1Smrg fi 4602ee3138f1Smrg 460334977a2fSmrg # Do each command in the postinstall commands. 4604fe24f8a2Smrg lib=$destdir/$realname 460534977a2fSmrg func_execute_cmds "$postinstall_cmds" 'exit $?' 4606ee3138f1Smrg fi 4607ee3138f1Smrg 460834977a2fSmrg # Install the pseudo-library for information purposes. 460934977a2fSmrg func_basename "$file" 4610fe24f8a2Smrg name=$func_basename_result 4611fe24f8a2Smrg instname=$dir/${name}i 461234977a2fSmrg func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' 4613ee3138f1Smrg 461434977a2fSmrg # Maybe install the static library, too. 46153e72ca8cSmrg test -n "$old_library" && func_append staticlibs " $dir/$old_library" 461634977a2fSmrg ;; 4617ee3138f1Smrg 461834977a2fSmrg *.lo) 461934977a2fSmrg # Install (i.e. copy) a libtool object. 4620ee3138f1Smrg 462134977a2fSmrg # Figure out destination file name, if it wasn't already specified. 462234977a2fSmrg if test -n "$destname"; then 4623fe24f8a2Smrg destfile=$destdir/$destname 462434977a2fSmrg else 462534977a2fSmrg func_basename "$file" 4626fe24f8a2Smrg destfile=$func_basename_result 4627fe24f8a2Smrg destfile=$destdir/$destfile 462834977a2fSmrg fi 462934977a2fSmrg 463034977a2fSmrg # Deduce the name of the destination old-style object file. 463134977a2fSmrg case $destfile in 463234977a2fSmrg *.lo) 463334977a2fSmrg func_lo2o "$destfile" 463434977a2fSmrg staticdest=$func_lo2o_result 463534977a2fSmrg ;; 463634977a2fSmrg *.$objext) 4637fe24f8a2Smrg staticdest=$destfile 463834977a2fSmrg destfile= 463934977a2fSmrg ;; 464034977a2fSmrg *) 4641fe24f8a2Smrg func_fatal_help "cannot copy a libtool object to '$destfile'" 464234977a2fSmrg ;; 4643ee3138f1Smrg esac 4644ee3138f1Smrg 464534977a2fSmrg # Install the libtool object if requested. 464634977a2fSmrg test -n "$destfile" && \ 464734977a2fSmrg func_show_eval "$install_prog $file $destfile" 'exit $?' 464834977a2fSmrg 464934977a2fSmrg # Install the old object if enabled. 4650fe24f8a2Smrg if test yes = "$build_old_libs"; then 465134977a2fSmrg # Deduce the name of the old-style object file. 465234977a2fSmrg func_lo2o "$file" 465334977a2fSmrg staticobj=$func_lo2o_result 465434977a2fSmrg func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' 4655ee3138f1Smrg fi 465634977a2fSmrg exit $EXIT_SUCCESS 465734977a2fSmrg ;; 4658ee3138f1Smrg 465934977a2fSmrg *) 466034977a2fSmrg # Figure out destination file name, if it wasn't already specified. 466134977a2fSmrg if test -n "$destname"; then 4662fe24f8a2Smrg destfile=$destdir/$destname 466334977a2fSmrg else 466434977a2fSmrg func_basename "$file" 4665fe24f8a2Smrg destfile=$func_basename_result 4666fe24f8a2Smrg destfile=$destdir/$destfile 466734977a2fSmrg fi 4668ee3138f1Smrg 466934977a2fSmrg # If the file is missing, and there is a .exe on the end, strip it 467034977a2fSmrg # because it is most likely a libtool script we actually want to 467134977a2fSmrg # install 4672fe24f8a2Smrg stripped_ext= 467334977a2fSmrg case $file in 467434977a2fSmrg *.exe) 467534977a2fSmrg if test ! -f "$file"; then 467634977a2fSmrg func_stripname '' '.exe' "$file" 467734977a2fSmrg file=$func_stripname_result 4678fe24f8a2Smrg stripped_ext=.exe 467934977a2fSmrg fi 468034977a2fSmrg ;; 468134977a2fSmrg esac 4682ee3138f1Smrg 468334977a2fSmrg # Do a test to see if this is really a libtool program. 468434977a2fSmrg case $host in 468534977a2fSmrg *cygwin* | *mingw*) 468634977a2fSmrg if func_ltwrapper_executable_p "$file"; then 468734977a2fSmrg func_ltwrapper_scriptname "$file" 468834977a2fSmrg wrapper=$func_ltwrapper_scriptname_result 468934977a2fSmrg else 469034977a2fSmrg func_stripname '' '.exe' "$file" 469134977a2fSmrg wrapper=$func_stripname_result 469234977a2fSmrg fi 469334977a2fSmrg ;; 469434977a2fSmrg *) 469534977a2fSmrg wrapper=$file 469634977a2fSmrg ;; 469734977a2fSmrg esac 469834977a2fSmrg if func_ltwrapper_script_p "$wrapper"; then 469934977a2fSmrg notinst_deplibs= 470034977a2fSmrg relink_command= 4701ee3138f1Smrg 470234977a2fSmrg func_source "$wrapper" 470334977a2fSmrg 470434977a2fSmrg # Check the variables that should have been set. 470534977a2fSmrg test -z "$generated_by_libtool_version" && \ 4706fe24f8a2Smrg func_fatal_error "invalid libtool wrapper script '$wrapper'" 470734977a2fSmrg 4708fe24f8a2Smrg finalize=: 470934977a2fSmrg for lib in $notinst_deplibs; do 471034977a2fSmrg # Check to see that each library is installed. 471134977a2fSmrg libdir= 471234977a2fSmrg if test -f "$lib"; then 471334977a2fSmrg func_source "$lib" 471434977a2fSmrg fi 4715fe24f8a2Smrg libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'` 471634977a2fSmrg if test -n "$libdir" && test ! -f "$libfile"; then 4717fe24f8a2Smrg func_warning "'$lib' has not been installed in '$libdir'" 4718fe24f8a2Smrg finalize=false 471934977a2fSmrg fi 472034977a2fSmrg done 472134977a2fSmrg 472234977a2fSmrg relink_command= 472334977a2fSmrg func_source "$wrapper" 472434977a2fSmrg 472534977a2fSmrg outputname= 4726fe24f8a2Smrg if test no = "$fast_install" && test -n "$relink_command"; then 472734977a2fSmrg $opt_dry_run || { 4728fe24f8a2Smrg if $finalize; then 472934977a2fSmrg tmpdir=`func_mktempdir` 473034977a2fSmrg func_basename "$file$stripped_ext" 4731fe24f8a2Smrg file=$func_basename_result 4732fe24f8a2Smrg outputname=$tmpdir/$file 473334977a2fSmrg # Replace the output file specification. 4734b425557eSmrg relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` 473534977a2fSmrg 4736fe24f8a2Smrg $opt_quiet || { 47378d623946Smrg func_quote_arg expand,pretty "$relink_command" 47388d623946Smrg eval "func_echo $func_quote_arg_result" 473934977a2fSmrg } 474034977a2fSmrg if eval "$relink_command"; then : 474134977a2fSmrg else 4742fe24f8a2Smrg func_error "error: relink '$file' with the above command before installing it" 474334977a2fSmrg $opt_dry_run || ${RM}r "$tmpdir" 474434977a2fSmrg continue 474534977a2fSmrg fi 4746fe24f8a2Smrg file=$outputname 474734977a2fSmrg else 4748fe24f8a2Smrg func_warning "cannot relink '$file'" 474934977a2fSmrg fi 475034977a2fSmrg } 4751ee3138f1Smrg else 475234977a2fSmrg # Install the binary that we compiled earlier. 4753b425557eSmrg file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` 4754ee3138f1Smrg fi 475534977a2fSmrg fi 4756ee3138f1Smrg 475734977a2fSmrg # remove .exe since cygwin /usr/bin/install will append another 475834977a2fSmrg # one anyway 475934977a2fSmrg case $install_prog,$host in 476034977a2fSmrg */usr/bin/install*,*cygwin*) 476134977a2fSmrg case $file:$destfile in 476234977a2fSmrg *.exe:*.exe) 476334977a2fSmrg # this is ok 476434977a2fSmrg ;; 476534977a2fSmrg *.exe:*) 476634977a2fSmrg destfile=$destfile.exe 476734977a2fSmrg ;; 476834977a2fSmrg *:*.exe) 476934977a2fSmrg func_stripname '' '.exe' "$destfile" 477034977a2fSmrg destfile=$func_stripname_result 477134977a2fSmrg ;; 477234977a2fSmrg esac 4773ee3138f1Smrg ;; 4774ee3138f1Smrg esac 477534977a2fSmrg func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' 477634977a2fSmrg $opt_dry_run || if test -n "$outputname"; then 477734977a2fSmrg ${RM}r "$tmpdir" 477834977a2fSmrg fi 477934977a2fSmrg ;; 478034977a2fSmrg esac 478134977a2fSmrg done 4782ee3138f1Smrg 478334977a2fSmrg for file in $staticlibs; do 478434977a2fSmrg func_basename "$file" 4785fe24f8a2Smrg name=$func_basename_result 478634977a2fSmrg 478734977a2fSmrg # Set up the ranlib parameters. 4788fe24f8a2Smrg oldlib=$destdir/$name 47893e72ca8cSmrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 47903e72ca8cSmrg tool_oldlib=$func_to_tool_file_result 479134977a2fSmrg 479234977a2fSmrg func_show_eval "$install_prog \$file \$oldlib" 'exit $?' 479334977a2fSmrg 479434977a2fSmrg if test -n "$stripme" && test -n "$old_striplib"; then 47953e72ca8cSmrg func_show_eval "$old_striplib $tool_oldlib" 'exit $?' 479634977a2fSmrg fi 479734977a2fSmrg 479834977a2fSmrg # Do each command in the postinstall commands. 479934977a2fSmrg func_execute_cmds "$old_postinstall_cmds" 'exit $?' 480034977a2fSmrg done 480134977a2fSmrg 480234977a2fSmrg test -n "$future_libdirs" && \ 4803fe24f8a2Smrg func_warning "remember to run '$progname --finish$future_libdirs'" 480434977a2fSmrg 480534977a2fSmrg if test -n "$current_libdirs"; then 480634977a2fSmrg # Maybe just do a dry run. 480734977a2fSmrg $opt_dry_run && current_libdirs=" -n$current_libdirs" 4808fe24f8a2Smrg exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs' 480934977a2fSmrg else 481034977a2fSmrg exit $EXIT_SUCCESS 481134977a2fSmrg fi 481234977a2fSmrg} 481334977a2fSmrg 4814fe24f8a2Smrgtest install = "$opt_mode" && func_mode_install ${1+"$@"} 481534977a2fSmrg 481634977a2fSmrg 481734977a2fSmrg# func_generate_dlsyms outputname originator pic_p 481834977a2fSmrg# Extract symbols from dlprefiles and create ${outputname}S.o with 481934977a2fSmrg# a dlpreopen symbol table. 482034977a2fSmrgfunc_generate_dlsyms () 482134977a2fSmrg{ 4822fe24f8a2Smrg $debug_cmd 4823fe24f8a2Smrg 4824fe24f8a2Smrg my_outputname=$1 4825fe24f8a2Smrg my_originator=$2 4826fe24f8a2Smrg my_pic_p=${3-false} 4827fe24f8a2Smrg my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'` 482834977a2fSmrg my_dlsyms= 482934977a2fSmrg 4830fe24f8a2Smrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 483134977a2fSmrg if test -n "$NM" && test -n "$global_symbol_pipe"; then 4832fe24f8a2Smrg my_dlsyms=${my_outputname}S.c 483334977a2fSmrg else 483434977a2fSmrg func_error "not configured to extract global symbols from dlpreopened files" 483534977a2fSmrg fi 483634977a2fSmrg fi 483734977a2fSmrg 483834977a2fSmrg if test -n "$my_dlsyms"; then 483934977a2fSmrg case $my_dlsyms in 484034977a2fSmrg "") ;; 484134977a2fSmrg *.c) 484234977a2fSmrg # Discover the nlist of each of the dlfiles. 4843fe24f8a2Smrg nlist=$output_objdir/$my_outputname.nm 484434977a2fSmrg 484534977a2fSmrg func_show_eval "$RM $nlist ${nlist}S ${nlist}T" 484634977a2fSmrg 484734977a2fSmrg # Parse the name list into a source file. 484834977a2fSmrg func_verbose "creating $output_objdir/$my_dlsyms" 484934977a2fSmrg 485034977a2fSmrg $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ 4851fe24f8a2Smrg/* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */ 4852fe24f8a2Smrg/* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */ 485334977a2fSmrg 485434977a2fSmrg#ifdef __cplusplus 485534977a2fSmrgextern \"C\" { 485634977a2fSmrg#endif 485734977a2fSmrg 4858fe24f8a2Smrg#if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) 4859b425557eSmrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\" 4860b425557eSmrg#endif 4861b425557eSmrg 48623e72ca8cSmrg/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ 4863fe24f8a2Smrg#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE 4864fe24f8a2Smrg/* DATA imports from DLLs on WIN32 can't be const, because runtime 48653e72ca8cSmrg relocations are performed -- see ld's documentation on pseudo-relocs. */ 48663e72ca8cSmrg# define LT_DLSYM_CONST 4867fe24f8a2Smrg#elif defined __osf__ 48683e72ca8cSmrg/* This system does not cope well with relocations in const data. */ 48693e72ca8cSmrg# define LT_DLSYM_CONST 48703e72ca8cSmrg#else 48713e72ca8cSmrg# define LT_DLSYM_CONST const 48723e72ca8cSmrg#endif 48733e72ca8cSmrg 4874fe24f8a2Smrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 4875fe24f8a2Smrg 487634977a2fSmrg/* External symbol declarations for the compiler. */\ 487734977a2fSmrg" 487834977a2fSmrg 4879fe24f8a2Smrg if test yes = "$dlself"; then 4880fe24f8a2Smrg func_verbose "generating symbol list for '$output'" 488134977a2fSmrg 488234977a2fSmrg $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" 488334977a2fSmrg 488434977a2fSmrg # Add our own program objects to the symbol list. 4885b425557eSmrg progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` 488634977a2fSmrg for progfile in $progfiles; do 48873e72ca8cSmrg func_to_tool_file "$progfile" func_convert_file_msys_to_w32 4888fe24f8a2Smrg func_verbose "extracting global C symbols from '$func_to_tool_file_result'" 48893e72ca8cSmrg $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" 489034977a2fSmrg done 489134977a2fSmrg 489234977a2fSmrg if test -n "$exclude_expsyms"; then 489334977a2fSmrg $opt_dry_run || { 489434977a2fSmrg eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' 489534977a2fSmrg eval '$MV "$nlist"T "$nlist"' 489634977a2fSmrg } 4897ee3138f1Smrg fi 489834977a2fSmrg 489934977a2fSmrg if test -n "$export_symbols_regex"; then 490034977a2fSmrg $opt_dry_run || { 490134977a2fSmrg eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' 490234977a2fSmrg eval '$MV "$nlist"T "$nlist"' 490334977a2fSmrg } 490434977a2fSmrg fi 490534977a2fSmrg 490634977a2fSmrg # Prepare the list of exported symbols 490734977a2fSmrg if test -z "$export_symbols"; then 4908fe24f8a2Smrg export_symbols=$output_objdir/$outputname.exp 490934977a2fSmrg $opt_dry_run || { 491034977a2fSmrg $RM $export_symbols 4911fe24f8a2Smrg eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' 491234977a2fSmrg case $host in 491334977a2fSmrg *cygwin* | *mingw* | *cegcc* ) 491434977a2fSmrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 491534977a2fSmrg eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' 491634977a2fSmrg ;; 491734977a2fSmrg esac 491834977a2fSmrg } 4919ee3138f1Smrg else 492034977a2fSmrg $opt_dry_run || { 4921fe24f8a2Smrg eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' 492234977a2fSmrg eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' 492334977a2fSmrg eval '$MV "$nlist"T "$nlist"' 492434977a2fSmrg case $host in 4925b425557eSmrg *cygwin* | *mingw* | *cegcc* ) 492634977a2fSmrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 492734977a2fSmrg eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' 492834977a2fSmrg ;; 492934977a2fSmrg esac 493034977a2fSmrg } 4931ee3138f1Smrg fi 493234977a2fSmrg fi 4933ee3138f1Smrg 493434977a2fSmrg for dlprefile in $dlprefiles; do 4935fe24f8a2Smrg func_verbose "extracting global C symbols from '$dlprefile'" 493634977a2fSmrg func_basename "$dlprefile" 4937fe24f8a2Smrg name=$func_basename_result 49383e72ca8cSmrg case $host in 49393e72ca8cSmrg *cygwin* | *mingw* | *cegcc* ) 49403e72ca8cSmrg # if an import library, we need to obtain dlname 49413e72ca8cSmrg if func_win32_import_lib_p "$dlprefile"; then 49423e72ca8cSmrg func_tr_sh "$dlprefile" 49433e72ca8cSmrg eval "curr_lafile=\$libfile_$func_tr_sh_result" 4944fe24f8a2Smrg dlprefile_dlbasename= 49453e72ca8cSmrg if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then 49463e72ca8cSmrg # Use subshell, to avoid clobbering current variable values 49473e72ca8cSmrg dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` 4948fe24f8a2Smrg if test -n "$dlprefile_dlname"; then 49493e72ca8cSmrg func_basename "$dlprefile_dlname" 4950fe24f8a2Smrg dlprefile_dlbasename=$func_basename_result 49513e72ca8cSmrg else 49523e72ca8cSmrg # no lafile. user explicitly requested -dlpreopen <import library>. 49533e72ca8cSmrg $sharedlib_from_linklib_cmd "$dlprefile" 49543e72ca8cSmrg dlprefile_dlbasename=$sharedlib_from_linklib_result 49553e72ca8cSmrg fi 49563e72ca8cSmrg fi 49573e72ca8cSmrg $opt_dry_run || { 4958fe24f8a2Smrg if test -n "$dlprefile_dlbasename"; then 49593e72ca8cSmrg eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' 49603e72ca8cSmrg else 49613e72ca8cSmrg func_warning "Could not compute DLL name from $name" 49623e72ca8cSmrg eval '$ECHO ": $name " >> "$nlist"' 49633e72ca8cSmrg fi 49643e72ca8cSmrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 49653e72ca8cSmrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | 49663e72ca8cSmrg $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" 49673e72ca8cSmrg } 49683e72ca8cSmrg else # not an import lib 49693e72ca8cSmrg $opt_dry_run || { 49703e72ca8cSmrg eval '$ECHO ": $name " >> "$nlist"' 49713e72ca8cSmrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 49723e72ca8cSmrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 49733e72ca8cSmrg } 49743e72ca8cSmrg fi 49753e72ca8cSmrg ;; 49763e72ca8cSmrg *) 49773e72ca8cSmrg $opt_dry_run || { 49783e72ca8cSmrg eval '$ECHO ": $name " >> "$nlist"' 49793e72ca8cSmrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 49803e72ca8cSmrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 49813e72ca8cSmrg } 49823e72ca8cSmrg ;; 49833e72ca8cSmrg esac 498434977a2fSmrg done 498534977a2fSmrg 498634977a2fSmrg $opt_dry_run || { 498734977a2fSmrg # Make sure we have at least an empty file. 498834977a2fSmrg test -f "$nlist" || : > "$nlist" 498934977a2fSmrg 499034977a2fSmrg if test -n "$exclude_expsyms"; then 499134977a2fSmrg $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T 499234977a2fSmrg $MV "$nlist"T "$nlist" 4993ee3138f1Smrg fi 499434977a2fSmrg 499534977a2fSmrg # Try sorting and uniquifying the output. 499634977a2fSmrg if $GREP -v "^: " < "$nlist" | 499734977a2fSmrg if sort -k 3 </dev/null >/dev/null 2>&1; then 499834977a2fSmrg sort -k 3 499934977a2fSmrg else 500034977a2fSmrg sort +2 500134977a2fSmrg fi | 500234977a2fSmrg uniq > "$nlist"S; then 500334977a2fSmrg : 5004ee3138f1Smrg else 500534977a2fSmrg $GREP -v "^: " < "$nlist" > "$nlist"S 5006ee3138f1Smrg fi 5007ee3138f1Smrg 500834977a2fSmrg if test -f "$nlist"S; then 500934977a2fSmrg eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' 5010ee3138f1Smrg else 5011b425557eSmrg echo '/* NONE */' >> "$output_objdir/$my_dlsyms" 5012ee3138f1Smrg fi 5013ee3138f1Smrg 5014fe24f8a2Smrg func_show_eval '$RM "${nlist}I"' 5015fe24f8a2Smrg if test -n "$global_symbol_to_import"; then 5016fe24f8a2Smrg eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I' 5017fe24f8a2Smrg fi 5018fe24f8a2Smrg 5019b425557eSmrg echo >> "$output_objdir/$my_dlsyms" "\ 5020ee3138f1Smrg 502134977a2fSmrg/* The mapping between symbol names and symbols. */ 502234977a2fSmrgtypedef struct { 502334977a2fSmrg const char *name; 502434977a2fSmrg void *address; 502534977a2fSmrg} lt_dlsymlist; 50263e72ca8cSmrgextern LT_DLSYM_CONST lt_dlsymlist 5027fe24f8a2Smrglt_${my_prefix}_LTX_preloaded_symbols[];\ 5028fe24f8a2Smrg" 5029fe24f8a2Smrg 5030fe24f8a2Smrg if test -s "$nlist"I; then 5031fe24f8a2Smrg echo >> "$output_objdir/$my_dlsyms" "\ 5032fe24f8a2Smrgstatic void lt_syminit(void) 5033fe24f8a2Smrg{ 5034fe24f8a2Smrg LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols; 5035fe24f8a2Smrg for (; symbol->name; ++symbol) 5036fe24f8a2Smrg {" 5037fe24f8a2Smrg $SED 's/.*/ if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms" 5038fe24f8a2Smrg echo >> "$output_objdir/$my_dlsyms" "\ 5039fe24f8a2Smrg } 5040fe24f8a2Smrg}" 5041fe24f8a2Smrg fi 5042fe24f8a2Smrg echo >> "$output_objdir/$my_dlsyms" "\ 50433e72ca8cSmrgLT_DLSYM_CONST lt_dlsymlist 504434977a2fSmrglt_${my_prefix}_LTX_preloaded_symbols[] = 5045fe24f8a2Smrg{ {\"$my_originator\", (void *) 0}," 5046fe24f8a2Smrg 5047fe24f8a2Smrg if test -s "$nlist"I; then 5048fe24f8a2Smrg echo >> "$output_objdir/$my_dlsyms" "\ 5049fe24f8a2Smrg {\"@INIT@\", (void *) <_syminit}," 5050fe24f8a2Smrg fi 5051ee3138f1Smrg 505234977a2fSmrg case $need_lib_prefix in 505334977a2fSmrg no) 505434977a2fSmrg eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" 505534977a2fSmrg ;; 505634977a2fSmrg *) 505734977a2fSmrg eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" 505834977a2fSmrg ;; 505934977a2fSmrg esac 5060b425557eSmrg echo >> "$output_objdir/$my_dlsyms" "\ 506134977a2fSmrg {0, (void *) 0} 506234977a2fSmrg}; 5063ee3138f1Smrg 506434977a2fSmrg/* This works around a problem in FreeBSD linker */ 506534977a2fSmrg#ifdef FREEBSD_WORKAROUND 506634977a2fSmrgstatic const void *lt_preloaded_setup() { 506734977a2fSmrg return lt_${my_prefix}_LTX_preloaded_symbols; 506834977a2fSmrg} 506934977a2fSmrg#endif 507034977a2fSmrg 507134977a2fSmrg#ifdef __cplusplus 507234977a2fSmrg} 507334977a2fSmrg#endif\ 507434977a2fSmrg" 507534977a2fSmrg } # !$opt_dry_run 507634977a2fSmrg 507734977a2fSmrg pic_flag_for_symtable= 507834977a2fSmrg case "$compile_command " in 507934977a2fSmrg *" -static "*) ;; 508034977a2fSmrg *) 508134977a2fSmrg case $host in 508234977a2fSmrg # compiling the symbol table file with pic_flag works around 508334977a2fSmrg # a FreeBSD bug that causes programs to crash when -lm is 508434977a2fSmrg # linked before any other PIC object. But we must not use 508534977a2fSmrg # pic_flag when linking with -static. The problem exists in 508634977a2fSmrg # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. 50873e72ca8cSmrg *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) 508834977a2fSmrg pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; 508934977a2fSmrg *-*-hpux*) 509034977a2fSmrg pic_flag_for_symtable=" $pic_flag" ;; 509134977a2fSmrg *) 5092fe24f8a2Smrg $my_pic_p && pic_flag_for_symtable=" $pic_flag" 509334977a2fSmrg ;; 509434977a2fSmrg esac 509534977a2fSmrg ;; 509634977a2fSmrg esac 509734977a2fSmrg symtab_cflags= 509834977a2fSmrg for arg in $LTCFLAGS; do 509934977a2fSmrg case $arg in 510034977a2fSmrg -pie | -fpie | -fPIE) ;; 51013e72ca8cSmrg *) func_append symtab_cflags " $arg" ;; 510234977a2fSmrg esac 510334977a2fSmrg done 5104ee3138f1Smrg 510534977a2fSmrg # Now compile the dynamic symbol file. 510634977a2fSmrg func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' 5107ee3138f1Smrg 510834977a2fSmrg # Clean up the generated files. 5109fe24f8a2Smrg func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"' 5110ee3138f1Smrg 511134977a2fSmrg # Transform the symbol file into the correct name. 5112fe24f8a2Smrg symfileobj=$output_objdir/${my_outputname}S.$objext 511334977a2fSmrg case $host in 511434977a2fSmrg *cygwin* | *mingw* | *cegcc* ) 511534977a2fSmrg if test -f "$output_objdir/$my_outputname.def"; then 5116b425557eSmrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 5117b425557eSmrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 511834977a2fSmrg else 5119b425557eSmrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 5120b425557eSmrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 5121ee3138f1Smrg fi 512234977a2fSmrg ;; 512334977a2fSmrg *) 5124b425557eSmrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 5125b425557eSmrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 512634977a2fSmrg ;; 512734977a2fSmrg esac 512834977a2fSmrg ;; 512934977a2fSmrg *) 5130fe24f8a2Smrg func_fatal_error "unknown suffix for '$my_dlsyms'" 513134977a2fSmrg ;; 513234977a2fSmrg esac 513334977a2fSmrg else 513434977a2fSmrg # We keep going just in case the user didn't refer to 513534977a2fSmrg # lt_preloaded_symbols. The linker will fail if global_symbol_pipe 513634977a2fSmrg # really was required. 5137ee3138f1Smrg 513834977a2fSmrg # Nullify the symbol file. 5139b425557eSmrg compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` 5140b425557eSmrg finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` 514134977a2fSmrg fi 514234977a2fSmrg} 5143ee3138f1Smrg 5144fe24f8a2Smrg# func_cygming_gnu_implib_p ARG 5145fe24f8a2Smrg# This predicate returns with zero status (TRUE) if 5146fe24f8a2Smrg# ARG is a GNU/binutils-style import library. Returns 5147fe24f8a2Smrg# with nonzero status (FALSE) otherwise. 5148fe24f8a2Smrgfunc_cygming_gnu_implib_p () 5149fe24f8a2Smrg{ 5150fe24f8a2Smrg $debug_cmd 5151fe24f8a2Smrg 5152fe24f8a2Smrg func_to_tool_file "$1" func_convert_file_msys_to_w32 5153fe24f8a2Smrg 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)$'` 5154fe24f8a2Smrg test -n "$func_cygming_gnu_implib_tmp" 5155fe24f8a2Smrg} 5156fe24f8a2Smrg 5157fe24f8a2Smrg# func_cygming_ms_implib_p ARG 5158fe24f8a2Smrg# This predicate returns with zero status (TRUE) if 5159fe24f8a2Smrg# ARG is an MS-style import library. Returns 5160fe24f8a2Smrg# with nonzero status (FALSE) otherwise. 5161fe24f8a2Smrgfunc_cygming_ms_implib_p () 5162fe24f8a2Smrg{ 5163fe24f8a2Smrg $debug_cmd 5164fe24f8a2Smrg 5165fe24f8a2Smrg func_to_tool_file "$1" func_convert_file_msys_to_w32 5166fe24f8a2Smrg func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` 5167fe24f8a2Smrg test -n "$func_cygming_ms_implib_tmp" 5168fe24f8a2Smrg} 5169fe24f8a2Smrg 517034977a2fSmrg# func_win32_libid arg 517134977a2fSmrg# return the library type of file 'arg' 517234977a2fSmrg# 517334977a2fSmrg# Need a lot of goo to handle *both* DLLs and import libs 517434977a2fSmrg# Has to be a shell function in order to 'eat' the argument 517534977a2fSmrg# that is supplied when $file_magic_command is called. 5176b425557eSmrg# Despite the name, also deal with 64 bit binaries. 517734977a2fSmrgfunc_win32_libid () 517834977a2fSmrg{ 5179fe24f8a2Smrg $debug_cmd 5180fe24f8a2Smrg 5181fe24f8a2Smrg win32_libid_type=unknown 518234977a2fSmrg win32_fileres=`file -L $1 2>/dev/null` 518334977a2fSmrg case $win32_fileres in 518434977a2fSmrg *ar\ archive\ import\ library*) # definitely import 518534977a2fSmrg win32_libid_type="x86 archive import" 518634977a2fSmrg ;; 518734977a2fSmrg *ar\ archive*) # could be an import, or static 5188b425557eSmrg # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. 518934977a2fSmrg if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | 5190b425557eSmrg $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then 5191fe24f8a2Smrg case $nm_interface in 5192fe24f8a2Smrg "MS dumpbin") 5193fe24f8a2Smrg if func_cygming_ms_implib_p "$1" || 5194fe24f8a2Smrg func_cygming_gnu_implib_p "$1" 5195fe24f8a2Smrg then 5196fe24f8a2Smrg win32_nmres=import 5197fe24f8a2Smrg else 5198fe24f8a2Smrg win32_nmres= 5199fe24f8a2Smrg fi 5200fe24f8a2Smrg ;; 5201fe24f8a2Smrg *) 5202fe24f8a2Smrg func_to_tool_file "$1" func_convert_file_msys_to_w32 5203fe24f8a2Smrg win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | 5204fe24f8a2Smrg $SED -n -e ' 520534977a2fSmrg 1,100{ 520634977a2fSmrg / I /{ 5207fe24f8a2Smrg s|.*|import| 520834977a2fSmrg p 520934977a2fSmrg q 521034977a2fSmrg } 521134977a2fSmrg }'` 5212fe24f8a2Smrg ;; 5213fe24f8a2Smrg esac 521434977a2fSmrg case $win32_nmres in 521534977a2fSmrg import*) win32_libid_type="x86 archive import";; 521634977a2fSmrg *) win32_libid_type="x86 archive static";; 521734977a2fSmrg esac 521834977a2fSmrg fi 521934977a2fSmrg ;; 522034977a2fSmrg *DLL*) 522134977a2fSmrg win32_libid_type="x86 DLL" 522234977a2fSmrg ;; 522334977a2fSmrg *executable*) # but shell scripts are "executable" too... 522434977a2fSmrg case $win32_fileres in 522534977a2fSmrg *MS\ Windows\ PE\ Intel*) 522634977a2fSmrg win32_libid_type="x86 DLL" 522734977a2fSmrg ;; 522834977a2fSmrg esac 522934977a2fSmrg ;; 523034977a2fSmrg esac 523134977a2fSmrg $ECHO "$win32_libid_type" 523234977a2fSmrg} 5233ee3138f1Smrg 52343e72ca8cSmrg# func_cygming_dll_for_implib ARG 52353e72ca8cSmrg# 52363e72ca8cSmrg# Platform-specific function to extract the 52373e72ca8cSmrg# name of the DLL associated with the specified 52383e72ca8cSmrg# import library ARG. 52393e72ca8cSmrg# Invoked by eval'ing the libtool variable 52403e72ca8cSmrg# $sharedlib_from_linklib_cmd 52413e72ca8cSmrg# Result is available in the variable 52423e72ca8cSmrg# $sharedlib_from_linklib_result 52433e72ca8cSmrgfunc_cygming_dll_for_implib () 52443e72ca8cSmrg{ 5245fe24f8a2Smrg $debug_cmd 5246fe24f8a2Smrg 52473e72ca8cSmrg sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` 52483e72ca8cSmrg} 52493e72ca8cSmrg 52503e72ca8cSmrg# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs 52513e72ca8cSmrg# 52523e72ca8cSmrg# The is the core of a fallback implementation of a 52533e72ca8cSmrg# platform-specific function to extract the name of the 52543e72ca8cSmrg# DLL associated with the specified import library LIBNAME. 52553e72ca8cSmrg# 52563e72ca8cSmrg# SECTION_NAME is either .idata$6 or .idata$7, depending 52573e72ca8cSmrg# on the platform and compiler that created the implib. 52583e72ca8cSmrg# 52593e72ca8cSmrg# Echos the name of the DLL associated with the 52603e72ca8cSmrg# specified import library. 52613e72ca8cSmrgfunc_cygming_dll_for_implib_fallback_core () 52623e72ca8cSmrg{ 5263fe24f8a2Smrg $debug_cmd 5264fe24f8a2Smrg 52653e72ca8cSmrg match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` 52663e72ca8cSmrg $OBJDUMP -s --section "$1" "$2" 2>/dev/null | 52673e72ca8cSmrg $SED '/^Contents of section '"$match_literal"':/{ 52683e72ca8cSmrg # Place marker at beginning of archive member dllname section 52693e72ca8cSmrg s/.*/====MARK====/ 52703e72ca8cSmrg p 52713e72ca8cSmrg d 52723e72ca8cSmrg } 52733e72ca8cSmrg # These lines can sometimes be longer than 43 characters, but 52743e72ca8cSmrg # are always uninteresting 52753e72ca8cSmrg /:[ ]*file format pe[i]\{,1\}-/d 52763e72ca8cSmrg /^In archive [^:]*:/d 52773e72ca8cSmrg # Ensure marker is printed 52783e72ca8cSmrg /^====MARK====/p 52793e72ca8cSmrg # Remove all lines with less than 43 characters 52803e72ca8cSmrg /^.\{43\}/!d 52813e72ca8cSmrg # From remaining lines, remove first 43 characters 52823e72ca8cSmrg s/^.\{43\}//' | 52833e72ca8cSmrg $SED -n ' 52843e72ca8cSmrg # Join marker and all lines until next marker into a single line 52853e72ca8cSmrg /^====MARK====/ b para 52863e72ca8cSmrg H 52873e72ca8cSmrg $ b para 52883e72ca8cSmrg b 52893e72ca8cSmrg :para 52903e72ca8cSmrg x 52913e72ca8cSmrg s/\n//g 52923e72ca8cSmrg # Remove the marker 52933e72ca8cSmrg s/^====MARK====// 52943e72ca8cSmrg # Remove trailing dots and whitespace 52953e72ca8cSmrg s/[\. \t]*$// 52963e72ca8cSmrg # Print 52973e72ca8cSmrg /./p' | 52983e72ca8cSmrg # we now have a list, one entry per line, of the stringified 52993e72ca8cSmrg # contents of the appropriate section of all members of the 5300fe24f8a2Smrg # archive that possess that section. Heuristic: eliminate 5301fe24f8a2Smrg # all those that have a first or second character that is 53023e72ca8cSmrg # a '.' (that is, objdump's representation of an unprintable 53033e72ca8cSmrg # character.) This should work for all archives with less than 53043e72ca8cSmrg # 0x302f exports -- but will fail for DLLs whose name actually 53053e72ca8cSmrg # begins with a literal '.' or a single character followed by 53063e72ca8cSmrg # a '.'. 53073e72ca8cSmrg # 53083e72ca8cSmrg # Of those that remain, print the first one. 53093e72ca8cSmrg $SED -e '/^\./d;/^.\./d;q' 53103e72ca8cSmrg} 53113e72ca8cSmrg 53123e72ca8cSmrg# func_cygming_dll_for_implib_fallback ARG 53133e72ca8cSmrg# Platform-specific function to extract the 53143e72ca8cSmrg# name of the DLL associated with the specified 53153e72ca8cSmrg# import library ARG. 53163e72ca8cSmrg# 53173e72ca8cSmrg# This fallback implementation is for use when $DLLTOOL 53183e72ca8cSmrg# does not support the --identify-strict option. 53193e72ca8cSmrg# Invoked by eval'ing the libtool variable 53203e72ca8cSmrg# $sharedlib_from_linklib_cmd 53213e72ca8cSmrg# Result is available in the variable 53223e72ca8cSmrg# $sharedlib_from_linklib_result 53233e72ca8cSmrgfunc_cygming_dll_for_implib_fallback () 53243e72ca8cSmrg{ 5325fe24f8a2Smrg $debug_cmd 5326fe24f8a2Smrg 5327fe24f8a2Smrg if func_cygming_gnu_implib_p "$1"; then 53283e72ca8cSmrg # binutils import library 53293e72ca8cSmrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` 5330fe24f8a2Smrg elif func_cygming_ms_implib_p "$1"; then 53313e72ca8cSmrg # ms-generated import library 53323e72ca8cSmrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` 53333e72ca8cSmrg else 53343e72ca8cSmrg # unknown 5335fe24f8a2Smrg sharedlib_from_linklib_result= 53363e72ca8cSmrg fi 53373e72ca8cSmrg} 5338ee3138f1Smrg 5339ee3138f1Smrg 534034977a2fSmrg# func_extract_an_archive dir oldlib 534134977a2fSmrgfunc_extract_an_archive () 534234977a2fSmrg{ 5343fe24f8a2Smrg $debug_cmd 5344fe24f8a2Smrg 5345fe24f8a2Smrg f_ex_an_ar_dir=$1; shift 5346fe24f8a2Smrg f_ex_an_ar_oldlib=$1 5347fe24f8a2Smrg if test yes = "$lock_old_archive_extraction"; then 5348b425557eSmrg lockfile=$f_ex_an_ar_oldlib.lock 5349b425557eSmrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 5350b425557eSmrg func_echo "Waiting for $lockfile to be removed" 5351b425557eSmrg sleep 2 5352b425557eSmrg done 5353b425557eSmrg fi 5354b425557eSmrg func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ 5355b425557eSmrg 'stat=$?; rm -f "$lockfile"; exit $stat' 5356fe24f8a2Smrg if test yes = "$lock_old_archive_extraction"; then 5357b425557eSmrg $opt_dry_run || rm -f "$lockfile" 5358b425557eSmrg fi 535934977a2fSmrg if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then 536034977a2fSmrg : 536134977a2fSmrg else 536234977a2fSmrg func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 536334977a2fSmrg fi 536434977a2fSmrg} 5365ee3138f1Smrg 5366ee3138f1Smrg 536734977a2fSmrg# func_extract_archives gentop oldlib ... 536834977a2fSmrgfunc_extract_archives () 536934977a2fSmrg{ 5370fe24f8a2Smrg $debug_cmd 5371fe24f8a2Smrg 5372fe24f8a2Smrg my_gentop=$1; shift 537334977a2fSmrg my_oldlibs=${1+"$@"} 5374fe24f8a2Smrg my_oldobjs= 5375fe24f8a2Smrg my_xlib= 5376fe24f8a2Smrg my_xabs= 5377fe24f8a2Smrg my_xdir= 5378ee3138f1Smrg 537934977a2fSmrg for my_xlib in $my_oldlibs; do 538034977a2fSmrg # Extract the objects. 538134977a2fSmrg case $my_xlib in 5382fe24f8a2Smrg [\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;; 538334977a2fSmrg *) my_xabs=`pwd`"/$my_xlib" ;; 538434977a2fSmrg esac 538534977a2fSmrg func_basename "$my_xlib" 5386fe24f8a2Smrg my_xlib=$func_basename_result 538734977a2fSmrg my_xlib_u=$my_xlib 538834977a2fSmrg while :; do 538934977a2fSmrg case " $extracted_archives " in 539034977a2fSmrg *" $my_xlib_u "*) 539134977a2fSmrg func_arith $extracted_serial + 1 539234977a2fSmrg extracted_serial=$func_arith_result 539334977a2fSmrg my_xlib_u=lt$extracted_serial-$my_xlib ;; 539434977a2fSmrg *) break ;; 539534977a2fSmrg esac 539634977a2fSmrg done 539734977a2fSmrg extracted_archives="$extracted_archives $my_xlib_u" 5398fe24f8a2Smrg my_xdir=$my_gentop/$my_xlib_u 5399ee3138f1Smrg 540034977a2fSmrg func_mkdir_p "$my_xdir" 5401ee3138f1Smrg 540234977a2fSmrg case $host in 540334977a2fSmrg *-darwin*) 540434977a2fSmrg func_verbose "Extracting $my_xabs" 540534977a2fSmrg # Do not bother doing anything if just a dry run 540634977a2fSmrg $opt_dry_run || { 540734977a2fSmrg darwin_orig_dir=`pwd` 540834977a2fSmrg cd $my_xdir || exit $? 540934977a2fSmrg darwin_archive=$my_xabs 541034977a2fSmrg darwin_curdir=`pwd` 5411fe24f8a2Smrg func_basename "$darwin_archive" 5412fe24f8a2Smrg darwin_base_archive=$func_basename_result 541334977a2fSmrg darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` 541434977a2fSmrg if test -n "$darwin_arches"; then 541534977a2fSmrg darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` 541634977a2fSmrg darwin_arch= 541734977a2fSmrg func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" 5418fe24f8a2Smrg for darwin_arch in $darwin_arches; do 5419fe24f8a2Smrg func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch" 5420fe24f8a2Smrg $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive" 5421fe24f8a2Smrg cd "unfat-$$/$darwin_base_archive-$darwin_arch" 5422fe24f8a2Smrg func_extract_an_archive "`pwd`" "$darwin_base_archive" 542334977a2fSmrg cd "$darwin_curdir" 5424fe24f8a2Smrg $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" 542534977a2fSmrg done # $darwin_arches 542634977a2fSmrg ## Okay now we've a bunch of thin objects, gotta fatten them up :) 5427fe24f8a2Smrg darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$sed_basename" | sort -u` 542834977a2fSmrg darwin_file= 542934977a2fSmrg darwin_files= 543034977a2fSmrg for darwin_file in $darwin_filelist; do 5431b425557eSmrg darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` 543234977a2fSmrg $LIPO -create -output "$darwin_file" $darwin_files 543334977a2fSmrg done # $darwin_filelist 543434977a2fSmrg $RM -rf unfat-$$ 543534977a2fSmrg cd "$darwin_orig_dir" 5436ee3138f1Smrg else 543734977a2fSmrg cd $darwin_orig_dir 543834977a2fSmrg func_extract_an_archive "$my_xdir" "$my_xabs" 543934977a2fSmrg fi # $darwin_arches 544034977a2fSmrg } # !$opt_dry_run 544134977a2fSmrg ;; 544234977a2fSmrg *) 544334977a2fSmrg func_extract_an_archive "$my_xdir" "$my_xabs" 544434977a2fSmrg ;; 544534977a2fSmrg esac 5446b425557eSmrg my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` 544734977a2fSmrg done 5448ee3138f1Smrg 5449fe24f8a2Smrg func_extract_archives_result=$my_oldobjs 545034977a2fSmrg} 5451ee3138f1Smrg 5452ee3138f1Smrg 5453b425557eSmrg# func_emit_wrapper [arg=no] 5454b425557eSmrg# 5455b425557eSmrg# Emit a libtool wrapper script on stdout. 5456b425557eSmrg# Don't directly open a file because we may want to 5457b425557eSmrg# incorporate the script contents within a cygwin/mingw 5458b425557eSmrg# wrapper executable. Must ONLY be called from within 5459b425557eSmrg# func_mode_link because it depends on a number of variables 5460b425557eSmrg# set therein. 546134977a2fSmrg# 5462b425557eSmrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR 5463b425557eSmrg# variable will take. If 'yes', then the emitted script 5464fe24f8a2Smrg# will assume that the directory where it is stored is 5465b425557eSmrg# the $objdir directory. This is a cygwin/mingw-specific 5466b425557eSmrg# behavior. 5467b425557eSmrgfunc_emit_wrapper () 546834977a2fSmrg{ 5469b425557eSmrg func_emit_wrapper_arg1=${1-no} 5470ee3138f1Smrg 547134977a2fSmrg $ECHO "\ 547234977a2fSmrg#! $SHELL 5473ee3138f1Smrg 547434977a2fSmrg# $output - temporary wrapper script for $objdir/$outputname 5475fe24f8a2Smrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 547634977a2fSmrg# 547734977a2fSmrg# The $output program cannot be directly executed until all the libtool 547834977a2fSmrg# libraries that it depends on are installed. 547934977a2fSmrg# 548034977a2fSmrg# This wrapper script should never be moved out of the build directory. 548134977a2fSmrg# If it is, it will not operate correctly. 5482ee3138f1Smrg 548334977a2fSmrg# Sed substitution that helps us do robust quoting. It backslashifies 548434977a2fSmrg# metacharacters that are still active within double-quoted strings. 548534977a2fSmrgsed_quote_subst='$sed_quote_subst' 5486ee3138f1Smrg 548734977a2fSmrg# Be Bourne compatible 548834977a2fSmrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then 548934977a2fSmrg emulate sh 549034977a2fSmrg NULLCMD=: 549134977a2fSmrg # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which 549234977a2fSmrg # is contrary to our usage. Disable this feature. 549334977a2fSmrg alias -g '\${1+\"\$@\"}'='\"\$@\"' 549434977a2fSmrg setopt NO_GLOB_SUBST 549534977a2fSmrgelse 549634977a2fSmrg case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac 549734977a2fSmrgfi 549834977a2fSmrgBIN_SH=xpg4; export BIN_SH # for Tru64 549934977a2fSmrgDUALCASE=1; export DUALCASE # for MKS sh 5500ee3138f1Smrg 550134977a2fSmrg# The HP-UX ksh and POSIX shell print the target directory to stdout 550234977a2fSmrg# if CDPATH is set. 550334977a2fSmrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 5504ee3138f1Smrg 550534977a2fSmrgrelink_command=\"$relink_command\" 5506ee3138f1Smrg 550734977a2fSmrg# This environment variable determines our operation mode. 550834977a2fSmrgif test \"\$libtool_install_magic\" = \"$magic\"; then 550934977a2fSmrg # install mode needs the following variables: 551034977a2fSmrg generated_by_libtool_version='$macro_version' 551134977a2fSmrg notinst_deplibs='$notinst_deplibs' 551234977a2fSmrgelse 551334977a2fSmrg # When we are sourced in execute mode, \$file and \$ECHO are already set. 551434977a2fSmrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 5515b425557eSmrg file=\"\$0\"" 5516b425557eSmrg 55178d623946Smrg func_quote_arg pretty "$ECHO" 55188d623946Smrg qECHO=$func_quote_arg_result 5519b425557eSmrg $ECHO "\ 5520b425557eSmrg 5521b425557eSmrg# A function that is used when there is no print builtin or printf. 5522b425557eSmrgfunc_fallback_echo () 5523b425557eSmrg{ 5524b425557eSmrg eval 'cat <<_LTECHO_EOF 5525b425557eSmrg\$1 5526b425557eSmrg_LTECHO_EOF' 5527b425557eSmrg} 55288d623946Smrg ECHO=$qECHO 5529b425557eSmrg fi 5530b425557eSmrg 5531b425557eSmrg# Very basic option parsing. These options are (a) specific to 5532b425557eSmrg# the libtool wrapper, (b) are identical between the wrapper 5533fe24f8a2Smrg# /script/ and the wrapper /executable/ that is used only on 5534b425557eSmrg# windows platforms, and (c) all begin with the string "--lt-" 5535fe24f8a2Smrg# (application programs are unlikely to have options that match 5536b425557eSmrg# this pattern). 5537b425557eSmrg# 5538b425557eSmrg# There are only two supported options: --lt-debug and 5539b425557eSmrg# --lt-dump-script. There is, deliberately, no --lt-help. 5540b425557eSmrg# 5541b425557eSmrg# The first argument to this parsing function should be the 5542b425557eSmrg# script's $0 value, followed by "$@". 5543b425557eSmrglt_option_debug= 5544b425557eSmrgfunc_parse_lt_options () 5545b425557eSmrg{ 5546b425557eSmrg lt_script_arg0=\$0 5547b425557eSmrg shift 5548b425557eSmrg for lt_opt 5549b425557eSmrg do 5550b425557eSmrg case \"\$lt_opt\" in 5551b425557eSmrg --lt-debug) lt_option_debug=1 ;; 5552b425557eSmrg --lt-dump-script) 5553b425557eSmrg lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` 5554b425557eSmrg test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. 5555b425557eSmrg lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` 5556b425557eSmrg cat \"\$lt_dump_D/\$lt_dump_F\" 5557b425557eSmrg exit 0 5558b425557eSmrg ;; 5559b425557eSmrg --lt-*) 5560b425557eSmrg \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 5561b425557eSmrg exit 1 5562b425557eSmrg ;; 5563b425557eSmrg esac 5564b425557eSmrg done 5565b425557eSmrg 5566b425557eSmrg # Print the debug banner immediately: 5567b425557eSmrg if test -n \"\$lt_option_debug\"; then 5568fe24f8a2Smrg echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2 5569b425557eSmrg fi 5570b425557eSmrg} 5571b425557eSmrg 5572b425557eSmrg# Used when --lt-debug. Prints its arguments to stdout 5573b425557eSmrg# (redirection is the responsibility of the caller) 5574b425557eSmrgfunc_lt_dump_args () 5575b425557eSmrg{ 5576b425557eSmrg lt_dump_args_N=1; 5577b425557eSmrg for lt_arg 5578b425557eSmrg do 5579fe24f8a2Smrg \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\" 5580b425557eSmrg lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` 5581b425557eSmrg done 5582b425557eSmrg} 5583b425557eSmrg 5584b425557eSmrg# Core function for launching the target application 5585b425557eSmrgfunc_exec_program_core () 5586b425557eSmrg{ 558734977a2fSmrg" 5588b425557eSmrg case $host in 5589b425557eSmrg # Backslashes separate directories on plain windows 5590b425557eSmrg *-*-mingw | *-*-os2* | *-cegcc*) 5591b425557eSmrg $ECHO "\ 5592b425557eSmrg if test -n \"\$lt_option_debug\"; then 5593fe24f8a2Smrg \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2 5594b425557eSmrg func_lt_dump_args \${1+\"\$@\"} 1>&2 5595b425557eSmrg fi 5596b425557eSmrg exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} 5597b425557eSmrg" 5598b425557eSmrg ;; 5599b425557eSmrg 5600b425557eSmrg *) 5601b425557eSmrg $ECHO "\ 5602b425557eSmrg if test -n \"\$lt_option_debug\"; then 5603fe24f8a2Smrg \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2 5604b425557eSmrg func_lt_dump_args \${1+\"\$@\"} 1>&2 5605b425557eSmrg fi 5606b425557eSmrg exec \"\$progdir/\$program\" \${1+\"\$@\"} 5607b425557eSmrg" 5608b425557eSmrg ;; 5609b425557eSmrg esac 5610b425557eSmrg $ECHO "\ 5611b425557eSmrg \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 5612b425557eSmrg exit 1 5613b425557eSmrg} 5614b425557eSmrg 5615b425557eSmrg# A function to encapsulate launching the target application 5616b425557eSmrg# Strips options in the --lt-* namespace from \$@ and 5617b425557eSmrg# launches target application with the remaining arguments. 5618b425557eSmrgfunc_exec_program () 5619b425557eSmrg{ 56203e72ca8cSmrg case \" \$* \" in 56213e72ca8cSmrg *\\ --lt-*) 56223e72ca8cSmrg for lt_wr_arg 56233e72ca8cSmrg do 56243e72ca8cSmrg case \$lt_wr_arg in 56253e72ca8cSmrg --lt-*) ;; 56263e72ca8cSmrg *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; 56273e72ca8cSmrg esac 56283e72ca8cSmrg shift 56293e72ca8cSmrg done ;; 56303e72ca8cSmrg esac 5631b425557eSmrg func_exec_program_core \${1+\"\$@\"} 5632b425557eSmrg} 5633b425557eSmrg 5634b425557eSmrg # Parse options 5635b425557eSmrg func_parse_lt_options \"\$0\" \${1+\"\$@\"} 5636ee3138f1Smrg 563734977a2fSmrg # Find the directory that this script lives in. 5638b425557eSmrg thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` 563934977a2fSmrg test \"x\$thisdir\" = \"x\$file\" && thisdir=. 5640ee3138f1Smrg 564134977a2fSmrg # Follow symbolic links until we get to the real thisdir. 5642b425557eSmrg file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` 564334977a2fSmrg while test -n \"\$file\"; do 5644b425557eSmrg destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` 5645ee3138f1Smrg 564634977a2fSmrg # If there was a directory component, then change thisdir. 564734977a2fSmrg if test \"x\$destdir\" != \"x\$file\"; then 564834977a2fSmrg case \"\$destdir\" in 564934977a2fSmrg [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; 565034977a2fSmrg *) thisdir=\"\$thisdir/\$destdir\" ;; 5651ee3138f1Smrg esac 565234977a2fSmrg fi 5653ee3138f1Smrg 5654b425557eSmrg file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` 5655b425557eSmrg file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` 565634977a2fSmrg done 5657ee3138f1Smrg 565834977a2fSmrg # Usually 'no', except on cygwin/mingw when embedded into 565934977a2fSmrg # the cwrapper. 5660b425557eSmrg WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 566134977a2fSmrg if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then 566234977a2fSmrg # special case for '.' 566334977a2fSmrg if test \"\$thisdir\" = \".\"; then 566434977a2fSmrg thisdir=\`pwd\` 566534977a2fSmrg fi 566634977a2fSmrg # remove .libs from thisdir 566734977a2fSmrg case \"\$thisdir\" in 5668b425557eSmrg *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; 566934977a2fSmrg $objdir ) thisdir=. ;; 567034977a2fSmrg esac 567134977a2fSmrg fi 567234977a2fSmrg 567334977a2fSmrg # Try to get the absolute directory name. 567434977a2fSmrg absdir=\`cd \"\$thisdir\" && pwd\` 567534977a2fSmrg test -n \"\$absdir\" && thisdir=\"\$absdir\" 567634977a2fSmrg" 567734977a2fSmrg 5678fe24f8a2Smrg if test yes = "$fast_install"; then 567934977a2fSmrg $ECHO "\ 568034977a2fSmrg program=lt-'$outputname'$exeext 568134977a2fSmrg progdir=\"\$thisdir/$objdir\" 568234977a2fSmrg 568334977a2fSmrg if test ! -f \"\$progdir/\$program\" || 5684fe24f8a2Smrg { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\ 568534977a2fSmrg test \"X\$file\" != \"X\$progdir/\$program\"; }; then 568634977a2fSmrg 568734977a2fSmrg file=\"\$\$-\$program\" 568834977a2fSmrg 568934977a2fSmrg if test ! -d \"\$progdir\"; then 569034977a2fSmrg $MKDIR \"\$progdir\" 569134977a2fSmrg else 569234977a2fSmrg $RM \"\$progdir/\$file\" 569334977a2fSmrg fi" 569434977a2fSmrg 569534977a2fSmrg $ECHO "\ 569634977a2fSmrg 569734977a2fSmrg # relink executable if necessary 569834977a2fSmrg if test -n \"\$relink_command\"; then 569934977a2fSmrg if relink_command_output=\`eval \$relink_command 2>&1\`; then : 570034977a2fSmrg else 5701fe24f8a2Smrg \$ECHO \"\$relink_command_output\" >&2 570234977a2fSmrg $RM \"\$progdir/\$file\" 570334977a2fSmrg exit 1 5704ee3138f1Smrg fi 570534977a2fSmrg fi 5706ee3138f1Smrg 570734977a2fSmrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || 570834977a2fSmrg { $RM \"\$progdir/\$program\"; 570934977a2fSmrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } 571034977a2fSmrg $RM \"\$progdir/\$file\" 571134977a2fSmrg fi" 571234977a2fSmrg else 571334977a2fSmrg $ECHO "\ 571434977a2fSmrg program='$outputname' 571534977a2fSmrg progdir=\"\$thisdir/$objdir\" 571634977a2fSmrg" 5717ee3138f1Smrg fi 5718ee3138f1Smrg 571934977a2fSmrg $ECHO "\ 5720ee3138f1Smrg 572134977a2fSmrg if test -f \"\$progdir/\$program\"; then" 5722ee3138f1Smrg 57233e72ca8cSmrg # fixup the dll searchpath if we need to. 57243e72ca8cSmrg # 57253e72ca8cSmrg # Fix the DLL searchpath if we need to. Do this before prepending 57263e72ca8cSmrg # to shlibpath, because on Windows, both are PATH and uninstalled 57273e72ca8cSmrg # libraries must come first. 57283e72ca8cSmrg if test -n "$dllsearchpath"; then 57293e72ca8cSmrg $ECHO "\ 57303e72ca8cSmrg # Add the dll search path components to the executable PATH 57313e72ca8cSmrg PATH=$dllsearchpath:\$PATH 57323e72ca8cSmrg" 57333e72ca8cSmrg fi 57343e72ca8cSmrg 573534977a2fSmrg # Export our shlibpath_var if we have one. 5736fe24f8a2Smrg if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 573734977a2fSmrg $ECHO "\ 573834977a2fSmrg # Add our own library path to $shlibpath_var 573934977a2fSmrg $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" 5740ee3138f1Smrg 574134977a2fSmrg # Some systems cannot cope with colon-terminated $shlibpath_var 574234977a2fSmrg # The second colon is a workaround for a bug in BeOS R4 sed 5743b425557eSmrg $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` 574434977a2fSmrg 574534977a2fSmrg export $shlibpath_var 574634977a2fSmrg" 5747ee3138f1Smrg fi 5748ee3138f1Smrg 574934977a2fSmrg $ECHO "\ 575034977a2fSmrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 575134977a2fSmrg # Run the actual program with our arguments. 5752b425557eSmrg func_exec_program \${1+\"\$@\"} 575334977a2fSmrg fi 575434977a2fSmrg else 575534977a2fSmrg # The program doesn't exist. 5756fe24f8a2Smrg \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2 575734977a2fSmrg \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 5758b425557eSmrg \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 575934977a2fSmrg exit 1 576034977a2fSmrg fi 576134977a2fSmrgfi\ 576234977a2fSmrg" 576334977a2fSmrg} 5764ee3138f1Smrg 5765ee3138f1Smrg 576634977a2fSmrg# func_emit_cwrapperexe_src 576734977a2fSmrg# emit the source code for a wrapper executable on stdout 576834977a2fSmrg# Must ONLY be called from within func_mode_link because 576934977a2fSmrg# it depends on a number of variable set therein. 577034977a2fSmrgfunc_emit_cwrapperexe_src () 577134977a2fSmrg{ 577234977a2fSmrg cat <<EOF 5773ee3138f1Smrg 577434977a2fSmrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname 5775fe24f8a2Smrg Generated by $PROGRAM (GNU $PACKAGE) $VERSION 5776ee3138f1Smrg 577734977a2fSmrg The $output program cannot be directly executed until all the libtool 577834977a2fSmrg libraries that it depends on are installed. 5779ee3138f1Smrg 578034977a2fSmrg This wrapper executable should never be moved out of the build directory. 578134977a2fSmrg If it is, it will not operate correctly. 578234977a2fSmrg*/ 578334977a2fSmrgEOF 578434977a2fSmrg cat <<"EOF" 5785b425557eSmrg#ifdef _MSC_VER 5786b425557eSmrg# define _CRT_SECURE_NO_DEPRECATE 1 5787b425557eSmrg#endif 578834977a2fSmrg#include <stdio.h> 578934977a2fSmrg#include <stdlib.h> 579034977a2fSmrg#ifdef _MSC_VER 579134977a2fSmrg# include <direct.h> 579234977a2fSmrg# include <process.h> 579334977a2fSmrg# include <io.h> 579434977a2fSmrg#else 579534977a2fSmrg# include <unistd.h> 579634977a2fSmrg# include <stdint.h> 579734977a2fSmrg# ifdef __CYGWIN__ 579834977a2fSmrg# include <io.h> 579934977a2fSmrg# endif 580034977a2fSmrg#endif 580134977a2fSmrg#include <malloc.h> 580234977a2fSmrg#include <stdarg.h> 580334977a2fSmrg#include <assert.h> 580434977a2fSmrg#include <string.h> 580534977a2fSmrg#include <ctype.h> 580634977a2fSmrg#include <errno.h> 580734977a2fSmrg#include <fcntl.h> 580834977a2fSmrg#include <sys/stat.h> 5809ee3138f1Smrg 5810fe24f8a2Smrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 5811fe24f8a2Smrg 5812b425557eSmrg/* declarations of non-ANSI functions */ 5813fe24f8a2Smrg#if defined __MINGW32__ 5814b425557eSmrg# ifdef __STRICT_ANSI__ 5815b425557eSmrgint _putenv (const char *); 5816b425557eSmrg# endif 5817fe24f8a2Smrg#elif defined __CYGWIN__ 5818b425557eSmrg# ifdef __STRICT_ANSI__ 5819b425557eSmrgchar *realpath (const char *, char *); 5820b425557eSmrgint putenv (char *); 5821b425557eSmrgint setenv (const char *, const char *, int); 5822b425557eSmrg# endif 5823fe24f8a2Smrg/* #elif defined other_platform || defined ... */ 5824b425557eSmrg#endif 5825b425557eSmrg 5826b425557eSmrg/* portability defines, excluding path handling macros */ 5827fe24f8a2Smrg#if defined _MSC_VER 5828b425557eSmrg# define setmode _setmode 5829b425557eSmrg# define stat _stat 5830b425557eSmrg# define chmod _chmod 5831b425557eSmrg# define getcwd _getcwd 5832b425557eSmrg# define putenv _putenv 5833b425557eSmrg# define S_IXUSR _S_IEXEC 5834fe24f8a2Smrg#elif defined __MINGW32__ 5835b425557eSmrg# define setmode _setmode 5836b425557eSmrg# define stat _stat 5837b425557eSmrg# define chmod _chmod 5838b425557eSmrg# define getcwd _getcwd 5839b425557eSmrg# define putenv _putenv 5840fe24f8a2Smrg#elif defined __CYGWIN__ 5841b425557eSmrg# define HAVE_SETENV 5842b425557eSmrg# define FOPEN_WB "wb" 5843fe24f8a2Smrg/* #elif defined other platforms ... */ 5844b425557eSmrg#endif 5845b425557eSmrg 5846fe24f8a2Smrg#if defined PATH_MAX 584734977a2fSmrg# define LT_PATHMAX PATH_MAX 5848fe24f8a2Smrg#elif defined MAXPATHLEN 584934977a2fSmrg# define LT_PATHMAX MAXPATHLEN 585034977a2fSmrg#else 585134977a2fSmrg# define LT_PATHMAX 1024 585234977a2fSmrg#endif 5853ee3138f1Smrg 585434977a2fSmrg#ifndef S_IXOTH 585534977a2fSmrg# define S_IXOTH 0 585634977a2fSmrg#endif 585734977a2fSmrg#ifndef S_IXGRP 585834977a2fSmrg# define S_IXGRP 0 585934977a2fSmrg#endif 5860ee3138f1Smrg 5861b425557eSmrg/* path handling portability macros */ 586234977a2fSmrg#ifndef DIR_SEPARATOR 586334977a2fSmrg# define DIR_SEPARATOR '/' 586434977a2fSmrg# define PATH_SEPARATOR ':' 586534977a2fSmrg#endif 5866ee3138f1Smrg 5867fe24f8a2Smrg#if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \ 5868fe24f8a2Smrg defined __OS2__ 586934977a2fSmrg# define HAVE_DOS_BASED_FILE_SYSTEM 587034977a2fSmrg# define FOPEN_WB "wb" 587134977a2fSmrg# ifndef DIR_SEPARATOR_2 587234977a2fSmrg# define DIR_SEPARATOR_2 '\\' 587334977a2fSmrg# endif 587434977a2fSmrg# ifndef PATH_SEPARATOR_2 587534977a2fSmrg# define PATH_SEPARATOR_2 ';' 587634977a2fSmrg# endif 587734977a2fSmrg#endif 5878ee3138f1Smrg 587934977a2fSmrg#ifndef DIR_SEPARATOR_2 588034977a2fSmrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) 588134977a2fSmrg#else /* DIR_SEPARATOR_2 */ 588234977a2fSmrg# define IS_DIR_SEPARATOR(ch) \ 588334977a2fSmrg (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) 588434977a2fSmrg#endif /* DIR_SEPARATOR_2 */ 5885ee3138f1Smrg 588634977a2fSmrg#ifndef PATH_SEPARATOR_2 588734977a2fSmrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) 588834977a2fSmrg#else /* PATH_SEPARATOR_2 */ 588934977a2fSmrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) 589034977a2fSmrg#endif /* PATH_SEPARATOR_2 */ 5891ee3138f1Smrg 589234977a2fSmrg#ifndef FOPEN_WB 589334977a2fSmrg# define FOPEN_WB "w" 589434977a2fSmrg#endif 589534977a2fSmrg#ifndef _O_BINARY 589634977a2fSmrg# define _O_BINARY 0 589734977a2fSmrg#endif 5898ee3138f1Smrg 589934977a2fSmrg#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) 590034977a2fSmrg#define XFREE(stale) do { \ 5901fe24f8a2Smrg if (stale) { free (stale); stale = 0; } \ 590234977a2fSmrg} while (0) 5903ee3138f1Smrg 5904fe24f8a2Smrg#if defined LT_DEBUGWRAPPER 5905b425557eSmrgstatic int lt_debug = 1; 590634977a2fSmrg#else 5907b425557eSmrgstatic int lt_debug = 0; 590834977a2fSmrg#endif 5909ee3138f1Smrg 5910b425557eSmrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ 5911ee3138f1Smrg 591234977a2fSmrgvoid *xmalloc (size_t num); 591334977a2fSmrgchar *xstrdup (const char *string); 591434977a2fSmrgconst char *base_name (const char *name); 591534977a2fSmrgchar *find_executable (const char *wrapper); 591634977a2fSmrgchar *chase_symlinks (const char *pathspec); 591734977a2fSmrgint make_executable (const char *path); 591834977a2fSmrgint check_executable (const char *path); 591934977a2fSmrgchar *strendzap (char *str, const char *pat); 5920b425557eSmrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...); 5921b425557eSmrgvoid lt_fatal (const char *file, int line, const char *message, ...); 5922b425557eSmrgstatic const char *nonnull (const char *s); 5923b425557eSmrgstatic const char *nonempty (const char *s); 592434977a2fSmrgvoid lt_setenv (const char *name, const char *value); 592534977a2fSmrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end); 592634977a2fSmrgvoid lt_update_exe_path (const char *name, const char *value); 592734977a2fSmrgvoid lt_update_lib_path (const char *name, const char *value); 5928b425557eSmrgchar **prepare_spawn (char **argv); 5929b425557eSmrgvoid lt_dump_script (FILE *f); 593034977a2fSmrgEOF 593134977a2fSmrg 593234977a2fSmrg cat <<EOF 5933fe24f8a2Smrg#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5) 5934fe24f8a2Smrg# define externally_visible volatile 5935fe24f8a2Smrg#else 5936fe24f8a2Smrg# define externally_visible __attribute__((externally_visible)) volatile 5937fe24f8a2Smrg#endif 5938fe24f8a2Smrgexternally_visible const char * MAGIC_EXE = "$magic_exe"; 593934977a2fSmrgconst char * LIB_PATH_VARNAME = "$shlibpath_var"; 594034977a2fSmrgEOF 5941ee3138f1Smrg 5942fe24f8a2Smrg if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 59433e72ca8cSmrg func_to_host_path "$temp_rpath" 594434977a2fSmrg cat <<EOF 59453e72ca8cSmrgconst char * LIB_PATH_VALUE = "$func_to_host_path_result"; 594634977a2fSmrgEOF 594734977a2fSmrg else 594834977a2fSmrg cat <<"EOF" 594934977a2fSmrgconst char * LIB_PATH_VALUE = ""; 595034977a2fSmrgEOF 5951ee3138f1Smrg fi 5952ee3138f1Smrg 595334977a2fSmrg if test -n "$dllsearchpath"; then 59543e72ca8cSmrg func_to_host_path "$dllsearchpath:" 595534977a2fSmrg cat <<EOF 595634977a2fSmrgconst char * EXE_PATH_VARNAME = "PATH"; 59573e72ca8cSmrgconst char * EXE_PATH_VALUE = "$func_to_host_path_result"; 5958ee3138f1SmrgEOF 5959ee3138f1Smrg else 596034977a2fSmrg cat <<"EOF" 596134977a2fSmrgconst char * EXE_PATH_VARNAME = ""; 596234977a2fSmrgconst char * EXE_PATH_VALUE = ""; 596334977a2fSmrgEOF 5964ee3138f1Smrg fi 596534977a2fSmrg 5966fe24f8a2Smrg if test yes = "$fast_install"; then 596734977a2fSmrg cat <<EOF 596834977a2fSmrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */ 596934977a2fSmrgEOF 5970ee3138f1Smrg else 597134977a2fSmrg cat <<EOF 597234977a2fSmrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */ 597334977a2fSmrgEOF 5974ee3138f1Smrg fi 5975ee3138f1Smrg 5976ee3138f1Smrg 597734977a2fSmrg cat <<"EOF" 5978ee3138f1Smrg 597934977a2fSmrg#define LTWRAPPER_OPTION_PREFIX "--lt-" 5980ee3138f1Smrg 598134977a2fSmrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX; 598234977a2fSmrgstatic const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script"; 5983b425557eSmrgstatic const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug"; 5984ee3138f1Smrg 598534977a2fSmrgint 598634977a2fSmrgmain (int argc, char *argv[]) 598734977a2fSmrg{ 598834977a2fSmrg char **newargz; 598934977a2fSmrg int newargc; 599034977a2fSmrg char *tmp_pathspec; 599134977a2fSmrg char *actual_cwrapper_path; 599234977a2fSmrg char *actual_cwrapper_name; 599334977a2fSmrg char *target_name; 599434977a2fSmrg char *lt_argv_zero; 5995fe24f8a2Smrg int rval = 127; 5996ee3138f1Smrg 599734977a2fSmrg int i; 5998ee3138f1Smrg 599934977a2fSmrg program_name = (char *) xstrdup (base_name (argv[0])); 6000fe24f8a2Smrg newargz = XMALLOC (char *, (size_t) argc + 1); 6001ee3138f1Smrg 6002b425557eSmrg /* very simple arg parsing; don't want to rely on getopt 6003b425557eSmrg * also, copy all non cwrapper options to newargz, except 6004b425557eSmrg * argz[0], which is handled differently 6005b425557eSmrg */ 6006b425557eSmrg newargc=0; 600734977a2fSmrg for (i = 1; i < argc; i++) 600834977a2fSmrg { 6009fe24f8a2Smrg if (STREQ (argv[i], dumpscript_opt)) 601034977a2fSmrg { 601134977a2fSmrgEOF 6012fe24f8a2Smrg case $host in 601334977a2fSmrg *mingw* | *cygwin* ) 601434977a2fSmrg # make stdout use "unix" line endings 601534977a2fSmrg echo " setmode(1,_O_BINARY);" 601634977a2fSmrg ;; 601734977a2fSmrg esac 6018ee3138f1Smrg 601934977a2fSmrg cat <<"EOF" 6020b425557eSmrg lt_dump_script (stdout); 602134977a2fSmrg return 0; 602234977a2fSmrg } 6023fe24f8a2Smrg if (STREQ (argv[i], debug_opt)) 6024b425557eSmrg { 6025b425557eSmrg lt_debug = 1; 6026b425557eSmrg continue; 6027b425557eSmrg } 6028fe24f8a2Smrg if (STREQ (argv[i], ltwrapper_option_prefix)) 6029b425557eSmrg { 6030b425557eSmrg /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX 6031b425557eSmrg namespace, but it is not one of the ones we know about and 6032b425557eSmrg have already dealt with, above (inluding dump-script), then 6033b425557eSmrg report an error. Otherwise, targets might begin to believe 6034b425557eSmrg they are allowed to use options in the LTWRAPPER_OPTION_PREFIX 6035b425557eSmrg namespace. The first time any user complains about this, we'll 6036b425557eSmrg need to make LTWRAPPER_OPTION_PREFIX a configure-time option 6037b425557eSmrg or a configure.ac-settable value. 6038b425557eSmrg */ 6039b425557eSmrg lt_fatal (__FILE__, __LINE__, 6040b425557eSmrg "unrecognized %s option: '%s'", 6041b425557eSmrg ltwrapper_option_prefix, argv[i]); 6042b425557eSmrg } 6043b425557eSmrg /* otherwise ... */ 6044b425557eSmrg newargz[++newargc] = xstrdup (argv[i]); 604534977a2fSmrg } 6046b425557eSmrg newargz[++newargc] = NULL; 6047b425557eSmrg 6048b425557eSmrgEOF 6049b425557eSmrg cat <<EOF 6050b425557eSmrg /* The GNU banner must be the first non-error debug message */ 6051fe24f8a2Smrg lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE) $VERSION\n"); 6052b425557eSmrgEOF 6053b425557eSmrg cat <<"EOF" 6054b425557eSmrg lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]); 6055b425557eSmrg lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name); 6056ee3138f1Smrg 605734977a2fSmrg tmp_pathspec = find_executable (argv[0]); 605834977a2fSmrg if (tmp_pathspec == NULL) 6059b425557eSmrg lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]); 6060b425557eSmrg lt_debugprintf (__FILE__, __LINE__, 6061b425557eSmrg "(main) found exe (before symlink chase) at: %s\n", 6062b425557eSmrg tmp_pathspec); 606334977a2fSmrg 606434977a2fSmrg actual_cwrapper_path = chase_symlinks (tmp_pathspec); 6065b425557eSmrg lt_debugprintf (__FILE__, __LINE__, 6066b425557eSmrg "(main) found exe (after symlink chase) at: %s\n", 6067b425557eSmrg actual_cwrapper_path); 606834977a2fSmrg XFREE (tmp_pathspec); 606934977a2fSmrg 6070b425557eSmrg actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path)); 607134977a2fSmrg strendzap (actual_cwrapper_path, actual_cwrapper_name); 607234977a2fSmrg 607334977a2fSmrg /* wrapper name transforms */ 607434977a2fSmrg strendzap (actual_cwrapper_name, ".exe"); 607534977a2fSmrg tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1); 607634977a2fSmrg XFREE (actual_cwrapper_name); 607734977a2fSmrg actual_cwrapper_name = tmp_pathspec; 607834977a2fSmrg tmp_pathspec = 0; 607934977a2fSmrg 608034977a2fSmrg /* target_name transforms -- use actual target program name; might have lt- prefix */ 608134977a2fSmrg target_name = xstrdup (base_name (TARGET_PROGRAM_NAME)); 608234977a2fSmrg strendzap (target_name, ".exe"); 608334977a2fSmrg tmp_pathspec = lt_extend_str (target_name, ".exe", 1); 608434977a2fSmrg XFREE (target_name); 608534977a2fSmrg target_name = tmp_pathspec; 608634977a2fSmrg tmp_pathspec = 0; 608734977a2fSmrg 6088b425557eSmrg lt_debugprintf (__FILE__, __LINE__, 6089b425557eSmrg "(main) libtool target name: %s\n", 6090b425557eSmrg target_name); 609134977a2fSmrgEOF 6092ee3138f1Smrg 609334977a2fSmrg cat <<EOF 609434977a2fSmrg newargz[0] = 609534977a2fSmrg XMALLOC (char, (strlen (actual_cwrapper_path) + 609634977a2fSmrg strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1)); 609734977a2fSmrg strcpy (newargz[0], actual_cwrapper_path); 609834977a2fSmrg strcat (newargz[0], "$objdir"); 609934977a2fSmrg strcat (newargz[0], "/"); 610034977a2fSmrgEOF 6101ee3138f1Smrg 610234977a2fSmrg cat <<"EOF" 610334977a2fSmrg /* stop here, and copy so we don't have to do this twice */ 610434977a2fSmrg tmp_pathspec = xstrdup (newargz[0]); 6105ee3138f1Smrg 610634977a2fSmrg /* do NOT want the lt- prefix here, so use actual_cwrapper_name */ 610734977a2fSmrg strcat (newargz[0], actual_cwrapper_name); 6108ee3138f1Smrg 610934977a2fSmrg /* DO want the lt- prefix here if it exists, so use target_name */ 611034977a2fSmrg lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1); 611134977a2fSmrg XFREE (tmp_pathspec); 611234977a2fSmrg tmp_pathspec = NULL; 611334977a2fSmrgEOF 6114ee3138f1Smrg 611534977a2fSmrg case $host_os in 611634977a2fSmrg mingw*) 611734977a2fSmrg cat <<"EOF" 611834977a2fSmrg { 611934977a2fSmrg char* p; 612034977a2fSmrg while ((p = strchr (newargz[0], '\\')) != NULL) 612134977a2fSmrg { 612234977a2fSmrg *p = '/'; 612334977a2fSmrg } 612434977a2fSmrg while ((p = strchr (lt_argv_zero, '\\')) != NULL) 612534977a2fSmrg { 612634977a2fSmrg *p = '/'; 612734977a2fSmrg } 612834977a2fSmrg } 612934977a2fSmrgEOF 613034977a2fSmrg ;; 613134977a2fSmrg esac 6132ee3138f1Smrg 613334977a2fSmrg cat <<"EOF" 613434977a2fSmrg XFREE (target_name); 613534977a2fSmrg XFREE (actual_cwrapper_path); 613634977a2fSmrg XFREE (actual_cwrapper_name); 6137ee3138f1Smrg 613834977a2fSmrg lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */ 613934977a2fSmrg lt_setenv ("DUALCASE", "1"); /* for MSK sh */ 61403e72ca8cSmrg /* Update the DLL searchpath. EXE_PATH_VALUE ($dllsearchpath) must 61413e72ca8cSmrg be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath) 61423e72ca8cSmrg because on Windows, both *_VARNAMEs are PATH but uninstalled 61433e72ca8cSmrg libraries must come first. */ 614434977a2fSmrg lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE); 61453e72ca8cSmrg lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE); 6146ee3138f1Smrg 6147b425557eSmrg lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n", 6148b425557eSmrg nonnull (lt_argv_zero)); 614934977a2fSmrg for (i = 0; i < newargc; i++) 615034977a2fSmrg { 6151b425557eSmrg lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n", 6152b425557eSmrg i, nonnull (newargz[i])); 615334977a2fSmrg } 6154ee3138f1Smrg 615534977a2fSmrgEOF 6156ee3138f1Smrg 615734977a2fSmrg case $host_os in 615834977a2fSmrg mingw*) 615934977a2fSmrg cat <<"EOF" 616034977a2fSmrg /* execv doesn't actually work on mingw as expected on unix */ 6161b425557eSmrg newargz = prepare_spawn (newargz); 6162fe24f8a2Smrg rval = (int) _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz); 616334977a2fSmrg if (rval == -1) 616434977a2fSmrg { 616534977a2fSmrg /* failed to start process */ 6166b425557eSmrg lt_debugprintf (__FILE__, __LINE__, 6167b425557eSmrg "(main) failed to launch target \"%s\": %s\n", 6168b425557eSmrg lt_argv_zero, nonnull (strerror (errno))); 616934977a2fSmrg return 127; 617034977a2fSmrg } 617134977a2fSmrg return rval; 617234977a2fSmrgEOF 617334977a2fSmrg ;; 617434977a2fSmrg *) 617534977a2fSmrg cat <<"EOF" 617634977a2fSmrg execv (lt_argv_zero, newargz); 617734977a2fSmrg return rval; /* =127, but avoids unused variable warning */ 617834977a2fSmrgEOF 617934977a2fSmrg ;; 618034977a2fSmrg esac 6181ee3138f1Smrg 618234977a2fSmrg cat <<"EOF" 618334977a2fSmrg} 6184ee3138f1Smrg 618534977a2fSmrgvoid * 618634977a2fSmrgxmalloc (size_t num) 618734977a2fSmrg{ 618834977a2fSmrg void *p = (void *) malloc (num); 618934977a2fSmrg if (!p) 6190b425557eSmrg lt_fatal (__FILE__, __LINE__, "memory exhausted"); 6191ee3138f1Smrg 619234977a2fSmrg return p; 619334977a2fSmrg} 6194ee3138f1Smrg 619534977a2fSmrgchar * 619634977a2fSmrgxstrdup (const char *string) 619734977a2fSmrg{ 619834977a2fSmrg return string ? strcpy ((char *) xmalloc (strlen (string) + 1), 619934977a2fSmrg string) : NULL; 620034977a2fSmrg} 6201ee3138f1Smrg 620234977a2fSmrgconst char * 620334977a2fSmrgbase_name (const char *name) 620434977a2fSmrg{ 620534977a2fSmrg const char *base; 6206ee3138f1Smrg 6207fe24f8a2Smrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 620834977a2fSmrg /* Skip over the disk name in MSDOS pathnames. */ 620934977a2fSmrg if (isalpha ((unsigned char) name[0]) && name[1] == ':') 621034977a2fSmrg name += 2; 621134977a2fSmrg#endif 6212ee3138f1Smrg 621334977a2fSmrg for (base = name; *name; name++) 621434977a2fSmrg if (IS_DIR_SEPARATOR (*name)) 621534977a2fSmrg base = name + 1; 621634977a2fSmrg return base; 621734977a2fSmrg} 6218ee3138f1Smrg 621934977a2fSmrgint 622034977a2fSmrgcheck_executable (const char *path) 622134977a2fSmrg{ 622234977a2fSmrg struct stat st; 6223ee3138f1Smrg 6224b425557eSmrg lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n", 6225b425557eSmrg nonempty (path)); 622634977a2fSmrg if ((!path) || (!*path)) 622734977a2fSmrg return 0; 6228ee3138f1Smrg 622934977a2fSmrg if ((stat (path, &st) >= 0) 623034977a2fSmrg && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) 623134977a2fSmrg return 1; 623234977a2fSmrg else 623334977a2fSmrg return 0; 623434977a2fSmrg} 6235ee3138f1Smrg 623634977a2fSmrgint 623734977a2fSmrgmake_executable (const char *path) 623834977a2fSmrg{ 623934977a2fSmrg int rval = 0; 624034977a2fSmrg struct stat st; 6241ee3138f1Smrg 6242b425557eSmrg lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", 6243b425557eSmrg nonempty (path)); 624434977a2fSmrg if ((!path) || (!*path)) 624534977a2fSmrg return 0; 6246ee3138f1Smrg 624734977a2fSmrg if (stat (path, &st) >= 0) 624834977a2fSmrg { 624934977a2fSmrg rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); 625034977a2fSmrg } 625134977a2fSmrg return rval; 625234977a2fSmrg} 6253ee3138f1Smrg 625434977a2fSmrg/* Searches for the full path of the wrapper. Returns 625534977a2fSmrg newly allocated full path name if found, NULL otherwise 625634977a2fSmrg Does not chase symlinks, even on platforms that support them. 625734977a2fSmrg*/ 625834977a2fSmrgchar * 625934977a2fSmrgfind_executable (const char *wrapper) 626034977a2fSmrg{ 626134977a2fSmrg int has_slash = 0; 626234977a2fSmrg const char *p; 626334977a2fSmrg const char *p_next; 626434977a2fSmrg /* static buffer for getcwd */ 626534977a2fSmrg char tmp[LT_PATHMAX + 1]; 6266fe24f8a2Smrg size_t tmp_len; 626734977a2fSmrg char *concat_name; 6268ee3138f1Smrg 6269b425557eSmrg lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", 6270b425557eSmrg nonempty (wrapper)); 6271ee3138f1Smrg 627234977a2fSmrg if ((wrapper == NULL) || (*wrapper == '\0')) 627334977a2fSmrg return NULL; 6274ee3138f1Smrg 627534977a2fSmrg /* Absolute path? */ 6276fe24f8a2Smrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 627734977a2fSmrg if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') 627834977a2fSmrg { 627934977a2fSmrg concat_name = xstrdup (wrapper); 628034977a2fSmrg if (check_executable (concat_name)) 628134977a2fSmrg return concat_name; 628234977a2fSmrg XFREE (concat_name); 628334977a2fSmrg } 628434977a2fSmrg else 628534977a2fSmrg { 628634977a2fSmrg#endif 628734977a2fSmrg if (IS_DIR_SEPARATOR (wrapper[0])) 628834977a2fSmrg { 628934977a2fSmrg concat_name = xstrdup (wrapper); 629034977a2fSmrg if (check_executable (concat_name)) 629134977a2fSmrg return concat_name; 629234977a2fSmrg XFREE (concat_name); 629334977a2fSmrg } 6294fe24f8a2Smrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 629534977a2fSmrg } 629634977a2fSmrg#endif 6297ee3138f1Smrg 629834977a2fSmrg for (p = wrapper; *p; p++) 629934977a2fSmrg if (*p == '/') 630034977a2fSmrg { 630134977a2fSmrg has_slash = 1; 630234977a2fSmrg break; 630334977a2fSmrg } 630434977a2fSmrg if (!has_slash) 630534977a2fSmrg { 630634977a2fSmrg /* no slashes; search PATH */ 630734977a2fSmrg const char *path = getenv ("PATH"); 630834977a2fSmrg if (path != NULL) 630934977a2fSmrg { 631034977a2fSmrg for (p = path; *p; p = p_next) 631134977a2fSmrg { 631234977a2fSmrg const char *q; 631334977a2fSmrg size_t p_len; 631434977a2fSmrg for (q = p; *q; q++) 631534977a2fSmrg if (IS_PATH_SEPARATOR (*q)) 631634977a2fSmrg break; 6317fe24f8a2Smrg p_len = (size_t) (q - p); 631834977a2fSmrg p_next = (*q == '\0' ? q : q + 1); 631934977a2fSmrg if (p_len == 0) 632034977a2fSmrg { 632134977a2fSmrg /* empty path: current directory */ 632234977a2fSmrg if (getcwd (tmp, LT_PATHMAX) == NULL) 6323b425557eSmrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 6324b425557eSmrg nonnull (strerror (errno))); 632534977a2fSmrg tmp_len = strlen (tmp); 632634977a2fSmrg concat_name = 632734977a2fSmrg XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 632834977a2fSmrg memcpy (concat_name, tmp, tmp_len); 632934977a2fSmrg concat_name[tmp_len] = '/'; 633034977a2fSmrg strcpy (concat_name + tmp_len + 1, wrapper); 633134977a2fSmrg } 633234977a2fSmrg else 633334977a2fSmrg { 633434977a2fSmrg concat_name = 633534977a2fSmrg XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); 633634977a2fSmrg memcpy (concat_name, p, p_len); 633734977a2fSmrg concat_name[p_len] = '/'; 633834977a2fSmrg strcpy (concat_name + p_len + 1, wrapper); 633934977a2fSmrg } 634034977a2fSmrg if (check_executable (concat_name)) 634134977a2fSmrg return concat_name; 634234977a2fSmrg XFREE (concat_name); 634334977a2fSmrg } 634434977a2fSmrg } 634534977a2fSmrg /* not found in PATH; assume curdir */ 634634977a2fSmrg } 634734977a2fSmrg /* Relative path | not found in path: prepend cwd */ 634834977a2fSmrg if (getcwd (tmp, LT_PATHMAX) == NULL) 6349b425557eSmrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 6350b425557eSmrg nonnull (strerror (errno))); 635134977a2fSmrg tmp_len = strlen (tmp); 635234977a2fSmrg concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 635334977a2fSmrg memcpy (concat_name, tmp, tmp_len); 635434977a2fSmrg concat_name[tmp_len] = '/'; 635534977a2fSmrg strcpy (concat_name + tmp_len + 1, wrapper); 6356ee3138f1Smrg 635734977a2fSmrg if (check_executable (concat_name)) 635834977a2fSmrg return concat_name; 635934977a2fSmrg XFREE (concat_name); 636034977a2fSmrg return NULL; 636134977a2fSmrg} 6362ee3138f1Smrg 636334977a2fSmrgchar * 636434977a2fSmrgchase_symlinks (const char *pathspec) 636534977a2fSmrg{ 636634977a2fSmrg#ifndef S_ISLNK 636734977a2fSmrg return xstrdup (pathspec); 636834977a2fSmrg#else 636934977a2fSmrg char buf[LT_PATHMAX]; 637034977a2fSmrg struct stat s; 637134977a2fSmrg char *tmp_pathspec = xstrdup (pathspec); 637234977a2fSmrg char *p; 637334977a2fSmrg int has_symlinks = 0; 637434977a2fSmrg while (strlen (tmp_pathspec) && !has_symlinks) 637534977a2fSmrg { 6376b425557eSmrg lt_debugprintf (__FILE__, __LINE__, 6377b425557eSmrg "checking path component for symlinks: %s\n", 6378b425557eSmrg tmp_pathspec); 637934977a2fSmrg if (lstat (tmp_pathspec, &s) == 0) 638034977a2fSmrg { 638134977a2fSmrg if (S_ISLNK (s.st_mode) != 0) 638234977a2fSmrg { 638334977a2fSmrg has_symlinks = 1; 638434977a2fSmrg break; 638534977a2fSmrg } 6386ee3138f1Smrg 638734977a2fSmrg /* search backwards for last DIR_SEPARATOR */ 638834977a2fSmrg p = tmp_pathspec + strlen (tmp_pathspec) - 1; 638934977a2fSmrg while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 639034977a2fSmrg p--; 639134977a2fSmrg if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 639234977a2fSmrg { 639334977a2fSmrg /* no more DIR_SEPARATORS left */ 639434977a2fSmrg break; 639534977a2fSmrg } 639634977a2fSmrg *p = '\0'; 639734977a2fSmrg } 639834977a2fSmrg else 639934977a2fSmrg { 6400b425557eSmrg lt_fatal (__FILE__, __LINE__, 6401b425557eSmrg "error accessing file \"%s\": %s", 6402b425557eSmrg tmp_pathspec, nonnull (strerror (errno))); 640334977a2fSmrg } 640434977a2fSmrg } 640534977a2fSmrg XFREE (tmp_pathspec); 6406ee3138f1Smrg 640734977a2fSmrg if (!has_symlinks) 640834977a2fSmrg { 640934977a2fSmrg return xstrdup (pathspec); 641034977a2fSmrg } 6411ee3138f1Smrg 641234977a2fSmrg tmp_pathspec = realpath (pathspec, buf); 641334977a2fSmrg if (tmp_pathspec == 0) 641434977a2fSmrg { 6415b425557eSmrg lt_fatal (__FILE__, __LINE__, 6416b425557eSmrg "could not follow symlinks for %s", pathspec); 641734977a2fSmrg } 641834977a2fSmrg return xstrdup (tmp_pathspec); 641934977a2fSmrg#endif 642034977a2fSmrg} 6421ee3138f1Smrg 642234977a2fSmrgchar * 642334977a2fSmrgstrendzap (char *str, const char *pat) 642434977a2fSmrg{ 642534977a2fSmrg size_t len, patlen; 6426ee3138f1Smrg 642734977a2fSmrg assert (str != NULL); 642834977a2fSmrg assert (pat != NULL); 6429ee3138f1Smrg 643034977a2fSmrg len = strlen (str); 643134977a2fSmrg patlen = strlen (pat); 6432ee3138f1Smrg 643334977a2fSmrg if (patlen <= len) 643434977a2fSmrg { 643534977a2fSmrg str += len - patlen; 6436fe24f8a2Smrg if (STREQ (str, pat)) 643734977a2fSmrg *str = '\0'; 643834977a2fSmrg } 643934977a2fSmrg return str; 644034977a2fSmrg} 6441ee3138f1Smrg 6442b425557eSmrgvoid 6443b425557eSmrglt_debugprintf (const char *file, int line, const char *fmt, ...) 6444b425557eSmrg{ 6445b425557eSmrg va_list args; 6446b425557eSmrg if (lt_debug) 6447b425557eSmrg { 6448b425557eSmrg (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); 6449b425557eSmrg va_start (args, fmt); 6450b425557eSmrg (void) vfprintf (stderr, fmt, args); 6451b425557eSmrg va_end (args); 6452b425557eSmrg } 6453b425557eSmrg} 6454b425557eSmrg 645534977a2fSmrgstatic void 6456b425557eSmrglt_error_core (int exit_status, const char *file, 6457b425557eSmrg int line, const char *mode, 645834977a2fSmrg const char *message, va_list ap) 645934977a2fSmrg{ 6460b425557eSmrg fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); 646134977a2fSmrg vfprintf (stderr, message, ap); 646234977a2fSmrg fprintf (stderr, ".\n"); 6463ee3138f1Smrg 646434977a2fSmrg if (exit_status >= 0) 646534977a2fSmrg exit (exit_status); 646634977a2fSmrg} 6467ee3138f1Smrg 646834977a2fSmrgvoid 6469b425557eSmrglt_fatal (const char *file, int line, const char *message, ...) 647034977a2fSmrg{ 647134977a2fSmrg va_list ap; 647234977a2fSmrg va_start (ap, message); 6473b425557eSmrg lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); 647434977a2fSmrg va_end (ap); 647534977a2fSmrg} 6476ee3138f1Smrg 6477b425557eSmrgstatic const char * 6478b425557eSmrgnonnull (const char *s) 6479b425557eSmrg{ 6480b425557eSmrg return s ? s : "(null)"; 6481b425557eSmrg} 6482b425557eSmrg 6483b425557eSmrgstatic const char * 6484b425557eSmrgnonempty (const char *s) 6485b425557eSmrg{ 6486b425557eSmrg return (s && !*s) ? "(empty)" : nonnull (s); 6487b425557eSmrg} 6488b425557eSmrg 648934977a2fSmrgvoid 649034977a2fSmrglt_setenv (const char *name, const char *value) 649134977a2fSmrg{ 6492b425557eSmrg lt_debugprintf (__FILE__, __LINE__, 6493b425557eSmrg "(lt_setenv) setting '%s' to '%s'\n", 6494b425557eSmrg nonnull (name), nonnull (value)); 649534977a2fSmrg { 649634977a2fSmrg#ifdef HAVE_SETENV 649734977a2fSmrg /* always make a copy, for consistency with !HAVE_SETENV */ 649834977a2fSmrg char *str = xstrdup (value); 649934977a2fSmrg setenv (name, str, 1); 650034977a2fSmrg#else 6501fe24f8a2Smrg size_t len = strlen (name) + 1 + strlen (value) + 1; 650234977a2fSmrg char *str = XMALLOC (char, len); 650334977a2fSmrg sprintf (str, "%s=%s", name, value); 650434977a2fSmrg if (putenv (str) != EXIT_SUCCESS) 650534977a2fSmrg { 650634977a2fSmrg XFREE (str); 650734977a2fSmrg } 650834977a2fSmrg#endif 650934977a2fSmrg } 651034977a2fSmrg} 6511ee3138f1Smrg 651234977a2fSmrgchar * 651334977a2fSmrglt_extend_str (const char *orig_value, const char *add, int to_end) 651434977a2fSmrg{ 651534977a2fSmrg char *new_value; 651634977a2fSmrg if (orig_value && *orig_value) 651734977a2fSmrg { 6518fe24f8a2Smrg size_t orig_value_len = strlen (orig_value); 6519fe24f8a2Smrg size_t add_len = strlen (add); 652034977a2fSmrg new_value = XMALLOC (char, add_len + orig_value_len + 1); 652134977a2fSmrg if (to_end) 652234977a2fSmrg { 652334977a2fSmrg strcpy (new_value, orig_value); 652434977a2fSmrg strcpy (new_value + orig_value_len, add); 652534977a2fSmrg } 652634977a2fSmrg else 652734977a2fSmrg { 652834977a2fSmrg strcpy (new_value, add); 652934977a2fSmrg strcpy (new_value + add_len, orig_value); 653034977a2fSmrg } 653134977a2fSmrg } 653234977a2fSmrg else 653334977a2fSmrg { 653434977a2fSmrg new_value = xstrdup (add); 653534977a2fSmrg } 653634977a2fSmrg return new_value; 653734977a2fSmrg} 6538ee3138f1Smrg 653934977a2fSmrgvoid 654034977a2fSmrglt_update_exe_path (const char *name, const char *value) 654134977a2fSmrg{ 6542b425557eSmrg lt_debugprintf (__FILE__, __LINE__, 6543b425557eSmrg "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", 6544b425557eSmrg nonnull (name), nonnull (value)); 6545ee3138f1Smrg 654634977a2fSmrg if (name && *name && value && *value) 654734977a2fSmrg { 654834977a2fSmrg char *new_value = lt_extend_str (getenv (name), value, 0); 654934977a2fSmrg /* some systems can't cope with a ':'-terminated path #' */ 6550fe24f8a2Smrg size_t len = strlen (new_value); 6551fe24f8a2Smrg while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1])) 655234977a2fSmrg { 6553fe24f8a2Smrg new_value[--len] = '\0'; 655434977a2fSmrg } 655534977a2fSmrg lt_setenv (name, new_value); 655634977a2fSmrg XFREE (new_value); 655734977a2fSmrg } 655834977a2fSmrg} 6559ee3138f1Smrg 656034977a2fSmrgvoid 656134977a2fSmrglt_update_lib_path (const char *name, const char *value) 656234977a2fSmrg{ 6563b425557eSmrg lt_debugprintf (__FILE__, __LINE__, 6564b425557eSmrg "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", 6565b425557eSmrg nonnull (name), nonnull (value)); 6566ee3138f1Smrg 656734977a2fSmrg if (name && *name && value && *value) 656834977a2fSmrg { 656934977a2fSmrg char *new_value = lt_extend_str (getenv (name), value, 0); 657034977a2fSmrg lt_setenv (name, new_value); 657134977a2fSmrg XFREE (new_value); 657234977a2fSmrg } 657334977a2fSmrg} 6574ee3138f1Smrg 6575b425557eSmrgEOF 6576b425557eSmrg case $host_os in 6577b425557eSmrg mingw*) 6578b425557eSmrg cat <<"EOF" 6579b425557eSmrg 6580b425557eSmrg/* Prepares an argument vector before calling spawn(). 6581b425557eSmrg Note that spawn() does not by itself call the command interpreter 6582b425557eSmrg (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : 6583b425557eSmrg ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); 6584b425557eSmrg GetVersionEx(&v); 6585b425557eSmrg v.dwPlatformId == VER_PLATFORM_WIN32_NT; 6586b425557eSmrg }) ? "cmd.exe" : "command.com"). 6587b425557eSmrg Instead it simply concatenates the arguments, separated by ' ', and calls 6588b425557eSmrg CreateProcess(). We must quote the arguments since Win32 CreateProcess() 6589b425557eSmrg interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a 6590b425557eSmrg special way: 6591b425557eSmrg - Space and tab are interpreted as delimiters. They are not treated as 6592b425557eSmrg delimiters if they are surrounded by double quotes: "...". 6593b425557eSmrg - Unescaped double quotes are removed from the input. Their only effect is 6594b425557eSmrg that within double quotes, space and tab are treated like normal 6595b425557eSmrg characters. 6596b425557eSmrg - Backslashes not followed by double quotes are not special. 6597b425557eSmrg - But 2*n+1 backslashes followed by a double quote become 6598b425557eSmrg n backslashes followed by a double quote (n >= 0): 6599b425557eSmrg \" -> " 6600b425557eSmrg \\\" -> \" 6601b425557eSmrg \\\\\" -> \\" 6602b425557eSmrg */ 6603b425557eSmrg#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" 6604b425557eSmrg#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" 6605b425557eSmrgchar ** 6606b425557eSmrgprepare_spawn (char **argv) 6607b425557eSmrg{ 6608b425557eSmrg size_t argc; 6609b425557eSmrg char **new_argv; 6610b425557eSmrg size_t i; 6611b425557eSmrg 6612b425557eSmrg /* Count number of arguments. */ 6613b425557eSmrg for (argc = 0; argv[argc] != NULL; argc++) 6614b425557eSmrg ; 6615b425557eSmrg 6616b425557eSmrg /* Allocate new argument vector. */ 6617b425557eSmrg new_argv = XMALLOC (char *, argc + 1); 6618b425557eSmrg 6619b425557eSmrg /* Put quoted arguments into the new argument vector. */ 6620b425557eSmrg for (i = 0; i < argc; i++) 6621b425557eSmrg { 6622b425557eSmrg const char *string = argv[i]; 6623b425557eSmrg 6624b425557eSmrg if (string[0] == '\0') 6625b425557eSmrg new_argv[i] = xstrdup ("\"\""); 6626b425557eSmrg else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) 6627b425557eSmrg { 6628b425557eSmrg int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); 6629b425557eSmrg size_t length; 6630b425557eSmrg unsigned int backslashes; 6631b425557eSmrg const char *s; 6632b425557eSmrg char *quoted_string; 6633b425557eSmrg char *p; 6634b425557eSmrg 6635b425557eSmrg length = 0; 6636b425557eSmrg backslashes = 0; 6637b425557eSmrg if (quote_around) 6638b425557eSmrg length++; 6639b425557eSmrg for (s = string; *s != '\0'; s++) 6640b425557eSmrg { 6641b425557eSmrg char c = *s; 6642b425557eSmrg if (c == '"') 6643b425557eSmrg length += backslashes + 1; 6644b425557eSmrg length++; 6645b425557eSmrg if (c == '\\') 6646b425557eSmrg backslashes++; 6647b425557eSmrg else 6648b425557eSmrg backslashes = 0; 6649b425557eSmrg } 6650b425557eSmrg if (quote_around) 6651b425557eSmrg length += backslashes + 1; 6652b425557eSmrg 6653b425557eSmrg quoted_string = XMALLOC (char, length + 1); 6654b425557eSmrg 6655b425557eSmrg p = quoted_string; 6656b425557eSmrg backslashes = 0; 6657b425557eSmrg if (quote_around) 6658b425557eSmrg *p++ = '"'; 6659b425557eSmrg for (s = string; *s != '\0'; s++) 6660b425557eSmrg { 6661b425557eSmrg char c = *s; 6662b425557eSmrg if (c == '"') 6663b425557eSmrg { 6664b425557eSmrg unsigned int j; 6665b425557eSmrg for (j = backslashes + 1; j > 0; j--) 6666b425557eSmrg *p++ = '\\'; 6667b425557eSmrg } 6668b425557eSmrg *p++ = c; 6669b425557eSmrg if (c == '\\') 6670b425557eSmrg backslashes++; 6671b425557eSmrg else 6672b425557eSmrg backslashes = 0; 6673b425557eSmrg } 6674b425557eSmrg if (quote_around) 6675b425557eSmrg { 6676b425557eSmrg unsigned int j; 6677b425557eSmrg for (j = backslashes; j > 0; j--) 6678b425557eSmrg *p++ = '\\'; 6679b425557eSmrg *p++ = '"'; 6680b425557eSmrg } 6681b425557eSmrg *p = '\0'; 6682b425557eSmrg 6683b425557eSmrg new_argv[i] = quoted_string; 6684b425557eSmrg } 6685b425557eSmrg else 6686b425557eSmrg new_argv[i] = (char *) string; 6687b425557eSmrg } 6688b425557eSmrg new_argv[argc] = NULL; 6689b425557eSmrg 6690b425557eSmrg return new_argv; 6691b425557eSmrg} 6692b425557eSmrgEOF 6693b425557eSmrg ;; 6694b425557eSmrg esac 6695b425557eSmrg 6696b425557eSmrg cat <<"EOF" 6697b425557eSmrgvoid lt_dump_script (FILE* f) 6698b425557eSmrg{ 6699b425557eSmrgEOF 6700b425557eSmrg func_emit_wrapper yes | 67013e72ca8cSmrg $SED -n -e ' 67023e72ca8cSmrgs/^\(.\{79\}\)\(..*\)/\1\ 67033e72ca8cSmrg\2/ 67043e72ca8cSmrgh 67053e72ca8cSmrgs/\([\\"]\)/\\\1/g 67063e72ca8cSmrgs/$/\\n/ 67073e72ca8cSmrgs/\([^\n]*\).*/ fputs ("\1", f);/p 67083e72ca8cSmrgg 67093e72ca8cSmrgD' 6710b425557eSmrg cat <<"EOF" 6711b425557eSmrg} 671234977a2fSmrgEOF 671334977a2fSmrg} 671434977a2fSmrg# end: func_emit_cwrapperexe_src 6715ee3138f1Smrg 6716b425557eSmrg# func_win32_import_lib_p ARG 6717b425557eSmrg# True if ARG is an import lib, as indicated by $file_magic_cmd 6718b425557eSmrgfunc_win32_import_lib_p () 6719b425557eSmrg{ 6720fe24f8a2Smrg $debug_cmd 6721fe24f8a2Smrg 6722b425557eSmrg case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in 6723b425557eSmrg *import*) : ;; 6724b425557eSmrg *) false ;; 6725b425557eSmrg esac 6726b425557eSmrg} 6727b425557eSmrg 6728fe24f8a2Smrg# func_suncc_cstd_abi 6729fe24f8a2Smrg# !!ONLY CALL THIS FOR SUN CC AFTER $compile_command IS FULLY EXPANDED!! 6730fe24f8a2Smrg# Several compiler flags select an ABI that is incompatible with the 6731fe24f8a2Smrg# Cstd library. Avoid specifying it if any are in CXXFLAGS. 6732fe24f8a2Smrgfunc_suncc_cstd_abi () 6733fe24f8a2Smrg{ 6734fe24f8a2Smrg $debug_cmd 6735fe24f8a2Smrg 6736fe24f8a2Smrg case " $compile_command " in 6737fe24f8a2Smrg *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*) 6738fe24f8a2Smrg suncc_use_cstd_abi=no 6739fe24f8a2Smrg ;; 6740fe24f8a2Smrg *) 6741fe24f8a2Smrg suncc_use_cstd_abi=yes 6742fe24f8a2Smrg ;; 6743fe24f8a2Smrg esac 6744fe24f8a2Smrg} 6745fe24f8a2Smrg 674634977a2fSmrg# func_mode_link arg... 674734977a2fSmrgfunc_mode_link () 674834977a2fSmrg{ 6749fe24f8a2Smrg $debug_cmd 6750fe24f8a2Smrg 675134977a2fSmrg case $host in 675234977a2fSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 675334977a2fSmrg # It is impossible to link a dll without this setting, and 675434977a2fSmrg # we shouldn't force the makefile maintainer to figure out 6755fe24f8a2Smrg # what system we are compiling for in order to pass an extra 675634977a2fSmrg # flag for every libtool invocation. 675734977a2fSmrg # allow_undefined=no 6758ee3138f1Smrg 675934977a2fSmrg # FIXME: Unfortunately, there are problems with the above when trying 6760fe24f8a2Smrg # to make a dll that has undefined symbols, in which case not 676134977a2fSmrg # even a static library is built. For now, we need to specify 676234977a2fSmrg # -no-undefined on the libtool link line when we can be certain 676334977a2fSmrg # that all symbols are satisfied, otherwise we get a static library. 676434977a2fSmrg allow_undefined=yes 676534977a2fSmrg ;; 676634977a2fSmrg *) 676734977a2fSmrg allow_undefined=yes 676834977a2fSmrg ;; 676934977a2fSmrg esac 677034977a2fSmrg libtool_args=$nonopt 677134977a2fSmrg base_compile="$nonopt $@" 677234977a2fSmrg compile_command=$nonopt 677334977a2fSmrg finalize_command=$nonopt 6774ee3138f1Smrg 677534977a2fSmrg compile_rpath= 677634977a2fSmrg finalize_rpath= 677734977a2fSmrg compile_shlibpath= 677834977a2fSmrg finalize_shlibpath= 677934977a2fSmrg convenience= 678034977a2fSmrg old_convenience= 678134977a2fSmrg deplibs= 678234977a2fSmrg old_deplibs= 678334977a2fSmrg compiler_flags= 678434977a2fSmrg linker_flags= 678534977a2fSmrg dllsearchpath= 678634977a2fSmrg lib_search_path=`pwd` 678734977a2fSmrg inst_prefix_dir= 678834977a2fSmrg new_inherited_linker_flags= 6789ee3138f1Smrg 679034977a2fSmrg avoid_version=no 6791b425557eSmrg bindir= 679234977a2fSmrg dlfiles= 679334977a2fSmrg dlprefiles= 679434977a2fSmrg dlself=no 679534977a2fSmrg export_dynamic=no 679634977a2fSmrg export_symbols= 679734977a2fSmrg export_symbols_regex= 679834977a2fSmrg generated= 679934977a2fSmrg libobjs= 680034977a2fSmrg ltlibs= 680134977a2fSmrg module=no 680234977a2fSmrg no_install=no 680334977a2fSmrg objs= 6804fe24f8a2Smrg os2dllname= 680534977a2fSmrg non_pic_objects= 680634977a2fSmrg precious_files_regex= 680734977a2fSmrg prefer_static_libs=no 6808fe24f8a2Smrg preload=false 680934977a2fSmrg prev= 681034977a2fSmrg prevarg= 681134977a2fSmrg release= 681234977a2fSmrg rpath= 681334977a2fSmrg xrpath= 681434977a2fSmrg perm_rpath= 681534977a2fSmrg temp_rpath= 681634977a2fSmrg thread_safe=no 681734977a2fSmrg vinfo= 681834977a2fSmrg vinfo_number=no 681934977a2fSmrg weak_libs= 6820fe24f8a2Smrg single_module=$wl-single_module 682134977a2fSmrg func_infer_tag $base_compile 6822ee3138f1Smrg 682334977a2fSmrg # We need to know -static, to get the right output filenames. 682434977a2fSmrg for arg 682534977a2fSmrg do 682634977a2fSmrg case $arg in 682734977a2fSmrg -shared) 6828fe24f8a2Smrg test yes != "$build_libtool_libs" \ 6829fe24f8a2Smrg && func_fatal_configuration "cannot build a shared library" 683034977a2fSmrg build_old_libs=no 683134977a2fSmrg break 683234977a2fSmrg ;; 683334977a2fSmrg -all-static | -static | -static-libtool-libs) 683434977a2fSmrg case $arg in 683534977a2fSmrg -all-static) 6836fe24f8a2Smrg if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then 683734977a2fSmrg func_warning "complete static linking is impossible in this configuration" 683834977a2fSmrg fi 683934977a2fSmrg if test -n "$link_static_flag"; then 684034977a2fSmrg dlopen_self=$dlopen_self_static 684134977a2fSmrg fi 684234977a2fSmrg prefer_static_libs=yes 684334977a2fSmrg ;; 684434977a2fSmrg -static) 684534977a2fSmrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 684634977a2fSmrg dlopen_self=$dlopen_self_static 684734977a2fSmrg fi 684834977a2fSmrg prefer_static_libs=built 684934977a2fSmrg ;; 685034977a2fSmrg -static-libtool-libs) 685134977a2fSmrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 685234977a2fSmrg dlopen_self=$dlopen_self_static 685334977a2fSmrg fi 685434977a2fSmrg prefer_static_libs=yes 685534977a2fSmrg ;; 685634977a2fSmrg esac 685734977a2fSmrg build_libtool_libs=no 685834977a2fSmrg build_old_libs=yes 685934977a2fSmrg break 686034977a2fSmrg ;; 686134977a2fSmrg esac 686234977a2fSmrg done 6863ee3138f1Smrg 686434977a2fSmrg # See if our shared archives depend on static archives. 686534977a2fSmrg test -n "$old_archive_from_new_cmds" && build_old_libs=yes 6866ee3138f1Smrg 686734977a2fSmrg # Go through the arguments, transforming them on the way. 686834977a2fSmrg while test "$#" -gt 0; do 6869fe24f8a2Smrg arg=$1 687034977a2fSmrg shift 68718d623946Smrg func_quote_arg pretty,unquoted "$arg" 68728d623946Smrg qarg=$func_quote_arg_unquoted_result 68738d623946Smrg func_append libtool_args " $func_quote_arg_result" 6874ee3138f1Smrg 687534977a2fSmrg # If the previous option needs an argument, assign it. 687634977a2fSmrg if test -n "$prev"; then 687734977a2fSmrg case $prev in 687834977a2fSmrg output) 687934977a2fSmrg func_append compile_command " @OUTPUT@" 688034977a2fSmrg func_append finalize_command " @OUTPUT@" 688134977a2fSmrg ;; 688234977a2fSmrg esac 6883ee3138f1Smrg 688434977a2fSmrg case $prev in 6885b425557eSmrg bindir) 6886fe24f8a2Smrg bindir=$arg 6887b425557eSmrg prev= 6888b425557eSmrg continue 6889b425557eSmrg ;; 689034977a2fSmrg dlfiles|dlprefiles) 6891fe24f8a2Smrg $preload || { 689234977a2fSmrg # Add the symbol object into the linking commands. 689334977a2fSmrg func_append compile_command " @SYMFILE@" 689434977a2fSmrg func_append finalize_command " @SYMFILE@" 6895fe24f8a2Smrg preload=: 6896fe24f8a2Smrg } 689734977a2fSmrg case $arg in 689834977a2fSmrg *.la | *.lo) ;; # We handle these cases below. 689934977a2fSmrg force) 6900fe24f8a2Smrg if test no = "$dlself"; then 690134977a2fSmrg dlself=needless 690234977a2fSmrg export_dynamic=yes 690334977a2fSmrg fi 690434977a2fSmrg prev= 690534977a2fSmrg continue 690634977a2fSmrg ;; 690734977a2fSmrg self) 6908fe24f8a2Smrg if test dlprefiles = "$prev"; then 690934977a2fSmrg dlself=yes 6910fe24f8a2Smrg elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then 691134977a2fSmrg dlself=yes 691234977a2fSmrg else 691334977a2fSmrg dlself=needless 691434977a2fSmrg export_dynamic=yes 691534977a2fSmrg fi 691634977a2fSmrg prev= 691734977a2fSmrg continue 691834977a2fSmrg ;; 691934977a2fSmrg *) 6920fe24f8a2Smrg if test dlfiles = "$prev"; then 69213e72ca8cSmrg func_append dlfiles " $arg" 692234977a2fSmrg else 69233e72ca8cSmrg func_append dlprefiles " $arg" 692434977a2fSmrg fi 692534977a2fSmrg prev= 692634977a2fSmrg continue 692734977a2fSmrg ;; 692834977a2fSmrg esac 692934977a2fSmrg ;; 693034977a2fSmrg expsyms) 6931fe24f8a2Smrg export_symbols=$arg 693234977a2fSmrg test -f "$arg" \ 6933fe24f8a2Smrg || func_fatal_error "symbol file '$arg' does not exist" 693434977a2fSmrg prev= 693534977a2fSmrg continue 693634977a2fSmrg ;; 693734977a2fSmrg expsyms_regex) 6938fe24f8a2Smrg export_symbols_regex=$arg 693934977a2fSmrg prev= 694034977a2fSmrg continue 694134977a2fSmrg ;; 694234977a2fSmrg framework) 6943ee3138f1Smrg case $host in 694434977a2fSmrg *-*-darwin*) 694534977a2fSmrg case "$deplibs " in 694634977a2fSmrg *" $qarg.ltframework "*) ;; 69473e72ca8cSmrg *) func_append deplibs " $qarg.ltframework" # this is fixed later 694834977a2fSmrg ;; 694934977a2fSmrg esac 695034977a2fSmrg ;; 6951ee3138f1Smrg esac 695234977a2fSmrg prev= 695334977a2fSmrg continue 6954ee3138f1Smrg ;; 695534977a2fSmrg inst_prefix) 6956fe24f8a2Smrg inst_prefix_dir=$arg 6957fe24f8a2Smrg prev= 6958fe24f8a2Smrg continue 6959fe24f8a2Smrg ;; 6960fe24f8a2Smrg mllvm) 6961fe24f8a2Smrg # Clang does not use LLVM to link, so we can simply discard any 6962fe24f8a2Smrg # '-mllvm $arg' options when doing the link step. 696334977a2fSmrg prev= 696434977a2fSmrg continue 6965ee3138f1Smrg ;; 696634977a2fSmrg objectlist) 696734977a2fSmrg if test -f "$arg"; then 696834977a2fSmrg save_arg=$arg 696934977a2fSmrg moreargs= 697034977a2fSmrg for fil in `cat "$save_arg"` 697134977a2fSmrg do 69723e72ca8cSmrg# func_append moreargs " $fil" 697334977a2fSmrg arg=$fil 697434977a2fSmrg # A libtool-controlled object. 6975ee3138f1Smrg 697634977a2fSmrg # Check to see that this really is a libtool object. 697734977a2fSmrg if func_lalib_unsafe_p "$arg"; then 697834977a2fSmrg pic_object= 697934977a2fSmrg non_pic_object= 6980ee3138f1Smrg 698134977a2fSmrg # Read the .lo file 698234977a2fSmrg func_source "$arg" 6983ee3138f1Smrg 698434977a2fSmrg if test -z "$pic_object" || 698534977a2fSmrg test -z "$non_pic_object" || 6986fe24f8a2Smrg test none = "$pic_object" && 6987fe24f8a2Smrg test none = "$non_pic_object"; then 6988fe24f8a2Smrg func_fatal_error "cannot find name of object for '$arg'" 698934977a2fSmrg fi 6990ee3138f1Smrg 699134977a2fSmrg # Extract subdirectory from the argument. 699234977a2fSmrg func_dirname "$arg" "/" "" 6993fe24f8a2Smrg xdir=$func_dirname_result 6994ee3138f1Smrg 6995fe24f8a2Smrg if test none != "$pic_object"; then 699634977a2fSmrg # Prepend the subdirectory the object is found in. 6997fe24f8a2Smrg pic_object=$xdir$pic_object 6998ee3138f1Smrg 6999fe24f8a2Smrg if test dlfiles = "$prev"; then 7000fe24f8a2Smrg if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 70013e72ca8cSmrg func_append dlfiles " $pic_object" 700234977a2fSmrg prev= 700334977a2fSmrg continue 700434977a2fSmrg else 700534977a2fSmrg # If libtool objects are unsupported, then we need to preload. 700634977a2fSmrg prev=dlprefiles 700734977a2fSmrg fi 700834977a2fSmrg fi 7009ee3138f1Smrg 701034977a2fSmrg # CHECK ME: I think I busted this. -Ossama 7011fe24f8a2Smrg if test dlprefiles = "$prev"; then 701234977a2fSmrg # Preload the old-style object. 70133e72ca8cSmrg func_append dlprefiles " $pic_object" 701434977a2fSmrg prev= 701534977a2fSmrg fi 7016ee3138f1Smrg 701734977a2fSmrg # A PIC object. 701834977a2fSmrg func_append libobjs " $pic_object" 7019fe24f8a2Smrg arg=$pic_object 702034977a2fSmrg fi 7021ee3138f1Smrg 702234977a2fSmrg # Non-PIC object. 7023fe24f8a2Smrg if test none != "$non_pic_object"; then 702434977a2fSmrg # Prepend the subdirectory the object is found in. 7025fe24f8a2Smrg non_pic_object=$xdir$non_pic_object 702634977a2fSmrg 702734977a2fSmrg # A standard non-PIC object 702834977a2fSmrg func_append non_pic_objects " $non_pic_object" 7029fe24f8a2Smrg if test -z "$pic_object" || test none = "$pic_object"; then 7030fe24f8a2Smrg arg=$non_pic_object 703134977a2fSmrg fi 703234977a2fSmrg else 703334977a2fSmrg # If the PIC object exists, use it instead. 703434977a2fSmrg # $xdir was prepended to $pic_object above. 7035fe24f8a2Smrg non_pic_object=$pic_object 703634977a2fSmrg func_append non_pic_objects " $non_pic_object" 703734977a2fSmrg fi 703834977a2fSmrg else 703934977a2fSmrg # Only an error if not doing a dry-run. 704034977a2fSmrg if $opt_dry_run; then 704134977a2fSmrg # Extract subdirectory from the argument. 704234977a2fSmrg func_dirname "$arg" "/" "" 7043fe24f8a2Smrg xdir=$func_dirname_result 704434977a2fSmrg 704534977a2fSmrg func_lo2o "$arg" 704634977a2fSmrg pic_object=$xdir$objdir/$func_lo2o_result 704734977a2fSmrg non_pic_object=$xdir$func_lo2o_result 704834977a2fSmrg func_append libobjs " $pic_object" 704934977a2fSmrg func_append non_pic_objects " $non_pic_object" 705034977a2fSmrg else 7051fe24f8a2Smrg func_fatal_error "'$arg' is not a valid libtool object" 705234977a2fSmrg fi 705334977a2fSmrg fi 705434977a2fSmrg done 7055ee3138f1Smrg else 7056fe24f8a2Smrg func_fatal_error "link input file '$arg' does not exist" 7057ee3138f1Smrg fi 705834977a2fSmrg arg=$save_arg 705934977a2fSmrg prev= 706034977a2fSmrg continue 706134977a2fSmrg ;; 7062fe24f8a2Smrg os2dllname) 7063fe24f8a2Smrg os2dllname=$arg 7064fe24f8a2Smrg prev= 7065fe24f8a2Smrg continue 7066fe24f8a2Smrg ;; 706734977a2fSmrg precious_regex) 7068fe24f8a2Smrg precious_files_regex=$arg 706934977a2fSmrg prev= 707034977a2fSmrg continue 707134977a2fSmrg ;; 707234977a2fSmrg release) 7073fe24f8a2Smrg release=-$arg 707434977a2fSmrg prev= 707534977a2fSmrg continue 707634977a2fSmrg ;; 707734977a2fSmrg rpath | xrpath) 707834977a2fSmrg # We need an absolute path. 707934977a2fSmrg case $arg in 708034977a2fSmrg [\\/]* | [A-Za-z]:[\\/]*) ;; 708134977a2fSmrg *) 708234977a2fSmrg func_fatal_error "only absolute run-paths are allowed" 708334977a2fSmrg ;; 708434977a2fSmrg esac 7085fe24f8a2Smrg if test rpath = "$prev"; then 708634977a2fSmrg case "$rpath " in 708734977a2fSmrg *" $arg "*) ;; 70883e72ca8cSmrg *) func_append rpath " $arg" ;; 708934977a2fSmrg esac 7090ee3138f1Smrg else 709134977a2fSmrg case "$xrpath " in 709234977a2fSmrg *" $arg "*) ;; 70933e72ca8cSmrg *) func_append xrpath " $arg" ;; 709434977a2fSmrg esac 7095ee3138f1Smrg fi 709634977a2fSmrg prev= 709734977a2fSmrg continue 709834977a2fSmrg ;; 709934977a2fSmrg shrext) 7100fe24f8a2Smrg shrext_cmds=$arg 710134977a2fSmrg prev= 710234977a2fSmrg continue 710334977a2fSmrg ;; 710434977a2fSmrg weak) 71053e72ca8cSmrg func_append weak_libs " $arg" 710634977a2fSmrg prev= 710734977a2fSmrg continue 710834977a2fSmrg ;; 71098d623946Smrg xassembler) 71108d623946Smrg func_append compiler_flags " -Xassembler $qarg" 71118d623946Smrg prev= 71128d623946Smrg func_append compile_command " -Xassembler $qarg" 71138d623946Smrg func_append finalize_command " -Xassembler $qarg" 71148d623946Smrg continue 71158d623946Smrg ;; 711634977a2fSmrg xcclinker) 71173e72ca8cSmrg func_append linker_flags " $qarg" 71183e72ca8cSmrg func_append compiler_flags " $qarg" 711934977a2fSmrg prev= 712034977a2fSmrg func_append compile_command " $qarg" 712134977a2fSmrg func_append finalize_command " $qarg" 712234977a2fSmrg continue 712334977a2fSmrg ;; 712434977a2fSmrg xcompiler) 71253e72ca8cSmrg func_append compiler_flags " $qarg" 712634977a2fSmrg prev= 712734977a2fSmrg func_append compile_command " $qarg" 712834977a2fSmrg func_append finalize_command " $qarg" 712934977a2fSmrg continue 713034977a2fSmrg ;; 713134977a2fSmrg xlinker) 71323e72ca8cSmrg func_append linker_flags " $qarg" 71333e72ca8cSmrg func_append compiler_flags " $wl$qarg" 713434977a2fSmrg prev= 713534977a2fSmrg func_append compile_command " $wl$qarg" 713634977a2fSmrg func_append finalize_command " $wl$qarg" 713734977a2fSmrg continue 713834977a2fSmrg ;; 713934977a2fSmrg *) 714034977a2fSmrg eval "$prev=\"\$arg\"" 714134977a2fSmrg prev= 714234977a2fSmrg continue 714334977a2fSmrg ;; 7144ee3138f1Smrg esac 714534977a2fSmrg fi # test -n "$prev" 7146ee3138f1Smrg 7147fe24f8a2Smrg prevarg=$arg 7148ee3138f1Smrg 714934977a2fSmrg case $arg in 715034977a2fSmrg -all-static) 715134977a2fSmrg if test -n "$link_static_flag"; then 715234977a2fSmrg # See comment for -static flag below, for more details. 715334977a2fSmrg func_append compile_command " $link_static_flag" 715434977a2fSmrg func_append finalize_command " $link_static_flag" 715534977a2fSmrg fi 715634977a2fSmrg continue 715734977a2fSmrg ;; 7158ee3138f1Smrg 715934977a2fSmrg -allow-undefined) 716034977a2fSmrg # FIXME: remove this flag sometime in the future. 7161fe24f8a2Smrg func_fatal_error "'-allow-undefined' must not be used because it is the default" 716234977a2fSmrg ;; 7163ee3138f1Smrg 716434977a2fSmrg -avoid-version) 716534977a2fSmrg avoid_version=yes 716634977a2fSmrg continue 716734977a2fSmrg ;; 7168ee3138f1Smrg 7169b425557eSmrg -bindir) 7170b425557eSmrg prev=bindir 7171b425557eSmrg continue 7172b425557eSmrg ;; 7173b425557eSmrg 717434977a2fSmrg -dlopen) 717534977a2fSmrg prev=dlfiles 717634977a2fSmrg continue 717734977a2fSmrg ;; 7178ee3138f1Smrg 717934977a2fSmrg -dlpreopen) 718034977a2fSmrg prev=dlprefiles 718134977a2fSmrg continue 718234977a2fSmrg ;; 7183ee3138f1Smrg 718434977a2fSmrg -export-dynamic) 718534977a2fSmrg export_dynamic=yes 718634977a2fSmrg continue 718734977a2fSmrg ;; 7188ee3138f1Smrg 718934977a2fSmrg -export-symbols | -export-symbols-regex) 719034977a2fSmrg if test -n "$export_symbols" || test -n "$export_symbols_regex"; then 719134977a2fSmrg func_fatal_error "more than one -exported-symbols argument is not allowed" 719234977a2fSmrg fi 7193fe24f8a2Smrg if test X-export-symbols = "X$arg"; then 719434977a2fSmrg prev=expsyms 719534977a2fSmrg else 719634977a2fSmrg prev=expsyms_regex 719734977a2fSmrg fi 719834977a2fSmrg continue 719934977a2fSmrg ;; 7200ee3138f1Smrg 720134977a2fSmrg -framework) 720234977a2fSmrg prev=framework 720334977a2fSmrg continue 720434977a2fSmrg ;; 7205ee3138f1Smrg 720634977a2fSmrg -inst-prefix-dir) 720734977a2fSmrg prev=inst_prefix 720834977a2fSmrg continue 720934977a2fSmrg ;; 7210ee3138f1Smrg 721134977a2fSmrg # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* 721234977a2fSmrg # so, if we see these flags be careful not to treat them like -L 721334977a2fSmrg -L[A-Z][A-Z]*:*) 721434977a2fSmrg case $with_gcc/$host in 721534977a2fSmrg no/*-*-irix* | /*-*-irix*) 721634977a2fSmrg func_append compile_command " $arg" 721734977a2fSmrg func_append finalize_command " $arg" 721834977a2fSmrg ;; 721934977a2fSmrg esac 722034977a2fSmrg continue 722134977a2fSmrg ;; 7222ee3138f1Smrg 722334977a2fSmrg -L*) 72243e72ca8cSmrg func_stripname "-L" '' "$arg" 72253e72ca8cSmrg if test -z "$func_stripname_result"; then 722634977a2fSmrg if test "$#" -gt 0; then 7227fe24f8a2Smrg func_fatal_error "require no space between '-L' and '$1'" 722834977a2fSmrg else 7229fe24f8a2Smrg func_fatal_error "need path for '-L' option" 723034977a2fSmrg fi 723134977a2fSmrg fi 72323e72ca8cSmrg func_resolve_sysroot "$func_stripname_result" 72333e72ca8cSmrg dir=$func_resolve_sysroot_result 723434977a2fSmrg # We need an absolute path. 723534977a2fSmrg case $dir in 723634977a2fSmrg [\\/]* | [A-Za-z]:[\\/]*) ;; 723734977a2fSmrg *) 723834977a2fSmrg absdir=`cd "$dir" && pwd` 723934977a2fSmrg test -z "$absdir" && \ 7240fe24f8a2Smrg func_fatal_error "cannot determine absolute directory name of '$dir'" 7241fe24f8a2Smrg dir=$absdir 724234977a2fSmrg ;; 724334977a2fSmrg esac 724434977a2fSmrg case "$deplibs " in 72453e72ca8cSmrg *" -L$dir "* | *" $arg "*) 72463e72ca8cSmrg # Will only happen for absolute or sysroot arguments 72473e72ca8cSmrg ;; 724834977a2fSmrg *) 72493e72ca8cSmrg # Preserve sysroot, but never include relative directories 72503e72ca8cSmrg case $dir in 72513e72ca8cSmrg [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; 72523e72ca8cSmrg *) func_append deplibs " -L$dir" ;; 72533e72ca8cSmrg esac 72543e72ca8cSmrg func_append lib_search_path " $dir" 725534977a2fSmrg ;; 725634977a2fSmrg esac 725734977a2fSmrg case $host in 725834977a2fSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 7259b425557eSmrg testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` 726034977a2fSmrg case :$dllsearchpath: in 726134977a2fSmrg *":$dir:"*) ;; 726234977a2fSmrg ::) dllsearchpath=$dir;; 72633e72ca8cSmrg *) func_append dllsearchpath ":$dir";; 726434977a2fSmrg esac 726534977a2fSmrg case :$dllsearchpath: in 726634977a2fSmrg *":$testbindir:"*) ;; 726734977a2fSmrg ::) dllsearchpath=$testbindir;; 72683e72ca8cSmrg *) func_append dllsearchpath ":$testbindir";; 726934977a2fSmrg esac 727034977a2fSmrg ;; 727134977a2fSmrg esac 727234977a2fSmrg continue 727334977a2fSmrg ;; 7274ee3138f1Smrg 727534977a2fSmrg -l*) 7276fe24f8a2Smrg if test X-lc = "X$arg" || test X-lm = "X$arg"; then 727734977a2fSmrg case $host in 7278b425557eSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) 727934977a2fSmrg # These systems don't actually have a C or math library (as such) 728034977a2fSmrg continue 728134977a2fSmrg ;; 728234977a2fSmrg *-*-os2*) 728334977a2fSmrg # These systems don't actually have a C library (as such) 7284fe24f8a2Smrg test X-lc = "X$arg" && continue 728534977a2fSmrg ;; 72868d623946Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig* | *-*-midnightbsd*) 728734977a2fSmrg # Do not include libc due to us having libc/libc_r. 7288fe24f8a2Smrg test X-lc = "X$arg" && continue 728934977a2fSmrg ;; 729034977a2fSmrg *-*-rhapsody* | *-*-darwin1.[012]) 729134977a2fSmrg # Rhapsody C and math libraries are in the System framework 72923e72ca8cSmrg func_append deplibs " System.ltframework" 729334977a2fSmrg continue 729434977a2fSmrg ;; 729534977a2fSmrg *-*-sco3.2v5* | *-*-sco5v6*) 729634977a2fSmrg # Causes problems with __ctype 7297fe24f8a2Smrg test X-lc = "X$arg" && continue 729834977a2fSmrg ;; 729934977a2fSmrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 730034977a2fSmrg # Compiler inserts libc in the correct place for threads to work 7301fe24f8a2Smrg test X-lc = "X$arg" && continue 730234977a2fSmrg ;; 730334977a2fSmrg esac 7304fe24f8a2Smrg elif test X-lc_r = "X$arg"; then 730534977a2fSmrg case $host in 73068d623946Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig* | *-*-midnightbsd*) 730734977a2fSmrg # Do not include libc_r directly, use -pthread flag. 730834977a2fSmrg continue 730934977a2fSmrg ;; 731034977a2fSmrg esac 731134977a2fSmrg fi 73123e72ca8cSmrg func_append deplibs " $arg" 731334977a2fSmrg continue 731434977a2fSmrg ;; 7315ee3138f1Smrg 7316fe24f8a2Smrg -mllvm) 7317fe24f8a2Smrg prev=mllvm 7318fe24f8a2Smrg continue 7319fe24f8a2Smrg ;; 7320fe24f8a2Smrg 732134977a2fSmrg -module) 732234977a2fSmrg module=yes 732334977a2fSmrg continue 732434977a2fSmrg ;; 7325ee3138f1Smrg 732634977a2fSmrg # Tru64 UNIX uses -model [arg] to determine the layout of C++ 732734977a2fSmrg # classes, name mangling, and exception handling. 732834977a2fSmrg # Darwin uses the -arch flag to determine output architecture. 73293e72ca8cSmrg -model|-arch|-isysroot|--sysroot) 73303e72ca8cSmrg func_append compiler_flags " $arg" 733134977a2fSmrg func_append compile_command " $arg" 733234977a2fSmrg func_append finalize_command " $arg" 733334977a2fSmrg prev=xcompiler 733434977a2fSmrg continue 733534977a2fSmrg ;; 73368d623946Smrg # Solaris ld rejects as of 11.4. Refer to Oracle bug 22985199. 73378d623946Smrg -pthread) 73388d623946Smrg case $host in 73398d623946Smrg *solaris2*) ;; 73408d623946Smrg *) 73418d623946Smrg case "$new_inherited_linker_flags " in 73428d623946Smrg *" $arg "*) ;; 73438d623946Smrg * ) func_append new_inherited_linker_flags " $arg" ;; 73448d623946Smrg esac 73458d623946Smrg ;; 73468d623946Smrg esac 73478d623946Smrg continue 73488d623946Smrg ;; 73498d623946Smrg -mt|-mthreads|-kthread|-Kthread|-pthreads|--thread-safe \ 73503e72ca8cSmrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 73513e72ca8cSmrg func_append compiler_flags " $arg" 735234977a2fSmrg func_append compile_command " $arg" 735334977a2fSmrg func_append finalize_command " $arg" 735434977a2fSmrg case "$new_inherited_linker_flags " in 735534977a2fSmrg *" $arg "*) ;; 73563e72ca8cSmrg * ) func_append new_inherited_linker_flags " $arg" ;; 735734977a2fSmrg esac 735834977a2fSmrg continue 735934977a2fSmrg ;; 7360ee3138f1Smrg 736134977a2fSmrg -multi_module) 7362fe24f8a2Smrg single_module=$wl-multi_module 736334977a2fSmrg continue 736434977a2fSmrg ;; 7365ee3138f1Smrg 736634977a2fSmrg -no-fast-install) 736734977a2fSmrg fast_install=no 736834977a2fSmrg continue 736934977a2fSmrg ;; 7370ee3138f1Smrg 737134977a2fSmrg -no-install) 737234977a2fSmrg case $host in 737334977a2fSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) 737434977a2fSmrg # The PATH hackery in wrapper scripts is required on Windows 737534977a2fSmrg # and Darwin in order for the loader to find any dlls it needs. 7376fe24f8a2Smrg func_warning "'-no-install' is ignored for $host" 7377fe24f8a2Smrg func_warning "assuming '-no-fast-install' instead" 737834977a2fSmrg fast_install=no 737934977a2fSmrg ;; 738034977a2fSmrg *) no_install=yes ;; 738134977a2fSmrg esac 738234977a2fSmrg continue 738334977a2fSmrg ;; 7384ee3138f1Smrg 738534977a2fSmrg -no-undefined) 738634977a2fSmrg allow_undefined=no 738734977a2fSmrg continue 738834977a2fSmrg ;; 7389ee3138f1Smrg 739034977a2fSmrg -objectlist) 739134977a2fSmrg prev=objectlist 739234977a2fSmrg continue 739334977a2fSmrg ;; 7394ee3138f1Smrg 7395fe24f8a2Smrg -os2dllname) 7396fe24f8a2Smrg prev=os2dllname 7397fe24f8a2Smrg continue 7398fe24f8a2Smrg ;; 7399fe24f8a2Smrg 740034977a2fSmrg -o) prev=output ;; 7401ee3138f1Smrg 740234977a2fSmrg -precious-files-regex) 740334977a2fSmrg prev=precious_regex 740434977a2fSmrg continue 740534977a2fSmrg ;; 7406ee3138f1Smrg 740734977a2fSmrg -release) 740834977a2fSmrg prev=release 740934977a2fSmrg continue 741034977a2fSmrg ;; 7411ee3138f1Smrg 741234977a2fSmrg -rpath) 741334977a2fSmrg prev=rpath 741434977a2fSmrg continue 741534977a2fSmrg ;; 7416ee3138f1Smrg 741734977a2fSmrg -R) 741834977a2fSmrg prev=xrpath 741934977a2fSmrg continue 742034977a2fSmrg ;; 7421ee3138f1Smrg 742234977a2fSmrg -R*) 742334977a2fSmrg func_stripname '-R' '' "$arg" 742434977a2fSmrg dir=$func_stripname_result 742534977a2fSmrg # We need an absolute path. 742634977a2fSmrg case $dir in 742734977a2fSmrg [\\/]* | [A-Za-z]:[\\/]*) ;; 74283e72ca8cSmrg =*) 74293e72ca8cSmrg func_stripname '=' '' "$dir" 74303e72ca8cSmrg dir=$lt_sysroot$func_stripname_result 74313e72ca8cSmrg ;; 743234977a2fSmrg *) 743334977a2fSmrg func_fatal_error "only absolute run-paths are allowed" 743434977a2fSmrg ;; 743534977a2fSmrg esac 743634977a2fSmrg case "$xrpath " in 743734977a2fSmrg *" $dir "*) ;; 74383e72ca8cSmrg *) func_append xrpath " $dir" ;; 743934977a2fSmrg esac 744034977a2fSmrg continue 744134977a2fSmrg ;; 7442ee3138f1Smrg 744334977a2fSmrg -shared) 744434977a2fSmrg # The effects of -shared are defined in a previous loop. 744534977a2fSmrg continue 744634977a2fSmrg ;; 7447ee3138f1Smrg 744834977a2fSmrg -shrext) 744934977a2fSmrg prev=shrext 745034977a2fSmrg continue 745134977a2fSmrg ;; 7452ee3138f1Smrg 745334977a2fSmrg -static | -static-libtool-libs) 745434977a2fSmrg # The effects of -static are defined in a previous loop. 745534977a2fSmrg # We used to do the same as -all-static on platforms that 745634977a2fSmrg # didn't have a PIC flag, but the assumption that the effects 745734977a2fSmrg # would be equivalent was wrong. It would break on at least 745834977a2fSmrg # Digital Unix and AIX. 745934977a2fSmrg continue 746034977a2fSmrg ;; 7461ee3138f1Smrg 746234977a2fSmrg -thread-safe) 746334977a2fSmrg thread_safe=yes 746434977a2fSmrg continue 746534977a2fSmrg ;; 7466ee3138f1Smrg 746734977a2fSmrg -version-info) 746834977a2fSmrg prev=vinfo 746934977a2fSmrg continue 747034977a2fSmrg ;; 7471ee3138f1Smrg 747234977a2fSmrg -version-number) 747334977a2fSmrg prev=vinfo 747434977a2fSmrg vinfo_number=yes 747534977a2fSmrg continue 747634977a2fSmrg ;; 7477ee3138f1Smrg 747834977a2fSmrg -weak) 747934977a2fSmrg prev=weak 748034977a2fSmrg continue 748134977a2fSmrg ;; 7482ee3138f1Smrg 748334977a2fSmrg -Wc,*) 748434977a2fSmrg func_stripname '-Wc,' '' "$arg" 748534977a2fSmrg args=$func_stripname_result 748634977a2fSmrg arg= 7487fe24f8a2Smrg save_ifs=$IFS; IFS=, 748834977a2fSmrg for flag in $args; do 7489fe24f8a2Smrg IFS=$save_ifs 74908d623946Smrg func_quote_arg pretty "$flag" 74918d623946Smrg func_append arg " $func_quote_arg_result" 74928d623946Smrg func_append compiler_flags " $func_quote_arg_result" 749334977a2fSmrg done 7494fe24f8a2Smrg IFS=$save_ifs 749534977a2fSmrg func_stripname ' ' '' "$arg" 749634977a2fSmrg arg=$func_stripname_result 749734977a2fSmrg ;; 7498ee3138f1Smrg 749934977a2fSmrg -Wl,*) 750034977a2fSmrg func_stripname '-Wl,' '' "$arg" 750134977a2fSmrg args=$func_stripname_result 750234977a2fSmrg arg= 7503fe24f8a2Smrg save_ifs=$IFS; IFS=, 750434977a2fSmrg for flag in $args; do 7505fe24f8a2Smrg IFS=$save_ifs 75068d623946Smrg func_quote_arg pretty "$flag" 75078d623946Smrg func_append arg " $wl$func_quote_arg_result" 75088d623946Smrg func_append compiler_flags " $wl$func_quote_arg_result" 75098d623946Smrg func_append linker_flags " $func_quote_arg_result" 751034977a2fSmrg done 7511fe24f8a2Smrg IFS=$save_ifs 751234977a2fSmrg func_stripname ' ' '' "$arg" 751334977a2fSmrg arg=$func_stripname_result 751434977a2fSmrg ;; 7515ee3138f1Smrg 75168d623946Smrg -Xassembler) 75178d623946Smrg prev=xassembler 75188d623946Smrg continue 75198d623946Smrg ;; 75208d623946Smrg 752134977a2fSmrg -Xcompiler) 752234977a2fSmrg prev=xcompiler 752334977a2fSmrg continue 752434977a2fSmrg ;; 7525ee3138f1Smrg 752634977a2fSmrg -Xlinker) 752734977a2fSmrg prev=xlinker 752834977a2fSmrg continue 752934977a2fSmrg ;; 7530ee3138f1Smrg 753134977a2fSmrg -XCClinker) 753234977a2fSmrg prev=xcclinker 753334977a2fSmrg continue 753434977a2fSmrg ;; 7535ee3138f1Smrg 753634977a2fSmrg # -msg_* for osf cc 753734977a2fSmrg -msg_*) 75388d623946Smrg func_quote_arg pretty "$arg" 75398d623946Smrg arg=$func_quote_arg_result 754034977a2fSmrg ;; 7541ee3138f1Smrg 7542b425557eSmrg # Flags to be passed through unchanged, with rationale: 7543b425557eSmrg # -64, -mips[0-9] enable 64-bit mode for the SGI compiler 7544b425557eSmrg # -r[0-9][0-9]* specify processor for the SGI compiler 7545b425557eSmrg # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler 7546b425557eSmrg # +DA*, +DD* enable 64-bit mode for the HP compiler 7547b425557eSmrg # -q* compiler args for the IBM compiler 7548b425557eSmrg # -m*, -t[45]*, -txscale* architecture-specific flags for GCC 7549b425557eSmrg # -F/path path to uninstalled frameworks, gcc on darwin 7550b425557eSmrg # -p, -pg, --coverage, -fprofile-* profiling flags for GCC 7551fe24f8a2Smrg # -fstack-protector* stack protector flags for GCC 7552b425557eSmrg # @file GCC response files 7553b425557eSmrg # -tp=* Portland pgcc target processor selection 75543e72ca8cSmrg # --sysroot=* for sysroot support 7555fe24f8a2Smrg # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization 75568d623946Smrg # -specs=* GCC specs files 7557fe24f8a2Smrg # -stdlib=* select c++ std lib with clang 75588d623946Smrg # -fsanitize=* Clang/GCC memory and address sanitizer 75598d623946Smrg # -fuse-ld=* Linker select flags for GCC 75608d623946Smrg # -Wa,* Pass flags directly to the assembler 756134977a2fSmrg -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ 75623e72ca8cSmrg -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ 75638d623946Smrg -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*| \ 75648d623946Smrg -specs=*|-fsanitize=*|-fuse-ld=*|-Wa,*) 75658d623946Smrg func_quote_arg pretty "$arg" 75668d623946Smrg arg=$func_quote_arg_result 756734977a2fSmrg func_append compile_command " $arg" 756834977a2fSmrg func_append finalize_command " $arg" 75693e72ca8cSmrg func_append compiler_flags " $arg" 757034977a2fSmrg continue 757134977a2fSmrg ;; 7572ee3138f1Smrg 7573fe24f8a2Smrg -Z*) 7574fe24f8a2Smrg if test os2 = "`expr $host : '.*\(os2\)'`"; then 7575fe24f8a2Smrg # OS/2 uses -Zxxx to specify OS/2-specific options 7576fe24f8a2Smrg compiler_flags="$compiler_flags $arg" 7577fe24f8a2Smrg func_append compile_command " $arg" 7578fe24f8a2Smrg func_append finalize_command " $arg" 7579fe24f8a2Smrg case $arg in 7580fe24f8a2Smrg -Zlinker | -Zstack) 7581fe24f8a2Smrg prev=xcompiler 7582fe24f8a2Smrg ;; 7583fe24f8a2Smrg esac 7584fe24f8a2Smrg continue 7585fe24f8a2Smrg else 7586fe24f8a2Smrg # Otherwise treat like 'Some other compiler flag' below 75878d623946Smrg func_quote_arg pretty "$arg" 75888d623946Smrg arg=$func_quote_arg_result 7589fe24f8a2Smrg fi 7590fe24f8a2Smrg ;; 7591fe24f8a2Smrg 759234977a2fSmrg # Some other compiler flag. 759334977a2fSmrg -* | +*) 75948d623946Smrg func_quote_arg pretty "$arg" 75958d623946Smrg arg=$func_quote_arg_result 759634977a2fSmrg ;; 7597ee3138f1Smrg 759834977a2fSmrg *.$objext) 759934977a2fSmrg # A standard object. 76003e72ca8cSmrg func_append objs " $arg" 760134977a2fSmrg ;; 7602ee3138f1Smrg 760334977a2fSmrg *.lo) 760434977a2fSmrg # A libtool-controlled object. 7605ee3138f1Smrg 760634977a2fSmrg # Check to see that this really is a libtool object. 760734977a2fSmrg if func_lalib_unsafe_p "$arg"; then 760834977a2fSmrg pic_object= 760934977a2fSmrg non_pic_object= 7610ee3138f1Smrg 761134977a2fSmrg # Read the .lo file 761234977a2fSmrg func_source "$arg" 7613ee3138f1Smrg 761434977a2fSmrg if test -z "$pic_object" || 761534977a2fSmrg test -z "$non_pic_object" || 7616fe24f8a2Smrg test none = "$pic_object" && 7617fe24f8a2Smrg test none = "$non_pic_object"; then 7618fe24f8a2Smrg func_fatal_error "cannot find name of object for '$arg'" 761934977a2fSmrg fi 7620ee3138f1Smrg 762134977a2fSmrg # Extract subdirectory from the argument. 762234977a2fSmrg func_dirname "$arg" "/" "" 7623fe24f8a2Smrg xdir=$func_dirname_result 7624ee3138f1Smrg 7625fe24f8a2Smrg test none = "$pic_object" || { 762634977a2fSmrg # Prepend the subdirectory the object is found in. 7627fe24f8a2Smrg pic_object=$xdir$pic_object 7628ee3138f1Smrg 7629fe24f8a2Smrg if test dlfiles = "$prev"; then 7630fe24f8a2Smrg if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 76313e72ca8cSmrg func_append dlfiles " $pic_object" 763234977a2fSmrg prev= 763334977a2fSmrg continue 763434977a2fSmrg else 763534977a2fSmrg # If libtool objects are unsupported, then we need to preload. 763634977a2fSmrg prev=dlprefiles 763734977a2fSmrg fi 763834977a2fSmrg fi 7639ee3138f1Smrg 764034977a2fSmrg # CHECK ME: I think I busted this. -Ossama 7641fe24f8a2Smrg if test dlprefiles = "$prev"; then 764234977a2fSmrg # Preload the old-style object. 76433e72ca8cSmrg func_append dlprefiles " $pic_object" 764434977a2fSmrg prev= 764534977a2fSmrg fi 7646ee3138f1Smrg 764734977a2fSmrg # A PIC object. 764834977a2fSmrg func_append libobjs " $pic_object" 7649fe24f8a2Smrg arg=$pic_object 7650fe24f8a2Smrg } 7651ee3138f1Smrg 765234977a2fSmrg # Non-PIC object. 7653fe24f8a2Smrg if test none != "$non_pic_object"; then 765434977a2fSmrg # Prepend the subdirectory the object is found in. 7655fe24f8a2Smrg non_pic_object=$xdir$non_pic_object 7656ee3138f1Smrg 765734977a2fSmrg # A standard non-PIC object 765834977a2fSmrg func_append non_pic_objects " $non_pic_object" 7659fe24f8a2Smrg if test -z "$pic_object" || test none = "$pic_object"; then 7660fe24f8a2Smrg arg=$non_pic_object 766134977a2fSmrg fi 766234977a2fSmrg else 766334977a2fSmrg # If the PIC object exists, use it instead. 766434977a2fSmrg # $xdir was prepended to $pic_object above. 7665fe24f8a2Smrg non_pic_object=$pic_object 766634977a2fSmrg func_append non_pic_objects " $non_pic_object" 766734977a2fSmrg fi 766834977a2fSmrg else 766934977a2fSmrg # Only an error if not doing a dry-run. 767034977a2fSmrg if $opt_dry_run; then 767134977a2fSmrg # Extract subdirectory from the argument. 767234977a2fSmrg func_dirname "$arg" "/" "" 7673fe24f8a2Smrg xdir=$func_dirname_result 767434977a2fSmrg 767534977a2fSmrg func_lo2o "$arg" 767634977a2fSmrg pic_object=$xdir$objdir/$func_lo2o_result 767734977a2fSmrg non_pic_object=$xdir$func_lo2o_result 767834977a2fSmrg func_append libobjs " $pic_object" 767934977a2fSmrg func_append non_pic_objects " $non_pic_object" 768034977a2fSmrg else 7681fe24f8a2Smrg func_fatal_error "'$arg' is not a valid libtool object" 768234977a2fSmrg fi 768334977a2fSmrg fi 768434977a2fSmrg ;; 768534977a2fSmrg 768634977a2fSmrg *.$libext) 768734977a2fSmrg # An archive. 76883e72ca8cSmrg func_append deplibs " $arg" 76893e72ca8cSmrg func_append old_deplibs " $arg" 769034977a2fSmrg continue 769134977a2fSmrg ;; 769234977a2fSmrg 769334977a2fSmrg *.la) 769434977a2fSmrg # A libtool-controlled library. 769534977a2fSmrg 76963e72ca8cSmrg func_resolve_sysroot "$arg" 7697fe24f8a2Smrg if test dlfiles = "$prev"; then 769834977a2fSmrg # This library was specified with -dlopen. 76993e72ca8cSmrg func_append dlfiles " $func_resolve_sysroot_result" 770034977a2fSmrg prev= 7701fe24f8a2Smrg elif test dlprefiles = "$prev"; then 770234977a2fSmrg # The library was specified with -dlpreopen. 77033e72ca8cSmrg func_append dlprefiles " $func_resolve_sysroot_result" 770434977a2fSmrg prev= 770534977a2fSmrg else 77063e72ca8cSmrg func_append deplibs " $func_resolve_sysroot_result" 770734977a2fSmrg fi 770834977a2fSmrg continue 770934977a2fSmrg ;; 771034977a2fSmrg 771134977a2fSmrg # Some other compiler argument. 771234977a2fSmrg *) 771334977a2fSmrg # Unknown arguments in both finalize_command and compile_command need 771434977a2fSmrg # to be aesthetically quoted because they are evaled later. 77158d623946Smrg func_quote_arg pretty "$arg" 77168d623946Smrg arg=$func_quote_arg_result 771734977a2fSmrg ;; 771834977a2fSmrg esac # arg 771934977a2fSmrg 772034977a2fSmrg # Now actually substitute the argument into the commands. 772134977a2fSmrg if test -n "$arg"; then 772234977a2fSmrg func_append compile_command " $arg" 772334977a2fSmrg func_append finalize_command " $arg" 772434977a2fSmrg fi 772534977a2fSmrg done # argument parsing loop 772634977a2fSmrg 772734977a2fSmrg test -n "$prev" && \ 7728fe24f8a2Smrg func_fatal_help "the '$prevarg' option requires an argument" 772934977a2fSmrg 7730fe24f8a2Smrg if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then 773134977a2fSmrg eval arg=\"$export_dynamic_flag_spec\" 773234977a2fSmrg func_append compile_command " $arg" 773334977a2fSmrg func_append finalize_command " $arg" 773434977a2fSmrg fi 773534977a2fSmrg 773634977a2fSmrg oldlibs= 773734977a2fSmrg # calculate the name of the file, without its directory 773834977a2fSmrg func_basename "$output" 7739fe24f8a2Smrg outputname=$func_basename_result 7740fe24f8a2Smrg libobjs_save=$libobjs 774134977a2fSmrg 774234977a2fSmrg if test -n "$shlibpath_var"; then 774334977a2fSmrg # get the directories listed in $shlibpath_var 7744fe24f8a2Smrg eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\` 774534977a2fSmrg else 774634977a2fSmrg shlib_search_path= 774734977a2fSmrg fi 774834977a2fSmrg eval sys_lib_search_path=\"$sys_lib_search_path_spec\" 774934977a2fSmrg eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" 775034977a2fSmrg 7751fe24f8a2Smrg # Definition is injected by LT_CONFIG during libtool generation. 7752fe24f8a2Smrg func_munge_path_list sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH" 7753fe24f8a2Smrg 775434977a2fSmrg func_dirname "$output" "/" "" 7755fe24f8a2Smrg output_objdir=$func_dirname_result$objdir 77563e72ca8cSmrg func_to_tool_file "$output_objdir/" 77573e72ca8cSmrg tool_output_objdir=$func_to_tool_file_result 775834977a2fSmrg # Create the object directory. 775934977a2fSmrg func_mkdir_p "$output_objdir" 776034977a2fSmrg 776134977a2fSmrg # Determine the type of output 776234977a2fSmrg case $output in 776334977a2fSmrg "") 776434977a2fSmrg func_fatal_help "you must specify an output file" 776534977a2fSmrg ;; 776634977a2fSmrg *.$libext) linkmode=oldlib ;; 776734977a2fSmrg *.lo | *.$objext) linkmode=obj ;; 776834977a2fSmrg *.la) linkmode=lib ;; 776934977a2fSmrg *) linkmode=prog ;; # Anything else should be a program. 777034977a2fSmrg esac 777134977a2fSmrg 777234977a2fSmrg specialdeplibs= 777334977a2fSmrg 777434977a2fSmrg libs= 777534977a2fSmrg # Find all interdependent deplibs by searching for libraries 777634977a2fSmrg # that are linked more than once (e.g. -la -lb -la) 777734977a2fSmrg for deplib in $deplibs; do 7778fe24f8a2Smrg if $opt_preserve_dup_deps; then 777934977a2fSmrg case "$libs " in 77803e72ca8cSmrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 778134977a2fSmrg esac 778234977a2fSmrg fi 77833e72ca8cSmrg func_append libs " $deplib" 778434977a2fSmrg done 778534977a2fSmrg 7786fe24f8a2Smrg if test lib = "$linkmode"; then 778734977a2fSmrg libs="$predeps $libs $compiler_lib_search_path $postdeps" 778834977a2fSmrg 778934977a2fSmrg # Compute libraries that are listed more than once in $predeps 779034977a2fSmrg # $postdeps and mark them as special (i.e., whose duplicates are 779134977a2fSmrg # not to be eliminated). 779234977a2fSmrg pre_post_deps= 779334977a2fSmrg if $opt_duplicate_compiler_generated_deps; then 779434977a2fSmrg for pre_post_dep in $predeps $postdeps; do 779534977a2fSmrg case "$pre_post_deps " in 77963e72ca8cSmrg *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; 779734977a2fSmrg esac 77983e72ca8cSmrg func_append pre_post_deps " $pre_post_dep" 779934977a2fSmrg done 780034977a2fSmrg fi 780134977a2fSmrg pre_post_deps= 780234977a2fSmrg fi 780334977a2fSmrg 780434977a2fSmrg deplibs= 780534977a2fSmrg newdependency_libs= 780634977a2fSmrg newlib_search_path= 780734977a2fSmrg need_relink=no # whether we're linking any uninstalled libtool libraries 780834977a2fSmrg notinst_deplibs= # not-installed libtool libraries 780934977a2fSmrg notinst_path= # paths that contain not-installed libtool libraries 781034977a2fSmrg 781134977a2fSmrg case $linkmode in 781234977a2fSmrg lib) 781334977a2fSmrg passes="conv dlpreopen link" 781434977a2fSmrg for file in $dlfiles $dlprefiles; do 781534977a2fSmrg case $file in 781634977a2fSmrg *.la) ;; 781734977a2fSmrg *) 7818fe24f8a2Smrg func_fatal_help "libraries can '-dlopen' only libtool libraries: $file" 781934977a2fSmrg ;; 782034977a2fSmrg esac 782134977a2fSmrg done 782234977a2fSmrg ;; 782334977a2fSmrg prog) 782434977a2fSmrg compile_deplibs= 782534977a2fSmrg finalize_deplibs= 7826fe24f8a2Smrg alldeplibs=false 782734977a2fSmrg newdlfiles= 782834977a2fSmrg newdlprefiles= 782934977a2fSmrg passes="conv scan dlopen dlpreopen link" 783034977a2fSmrg ;; 783134977a2fSmrg *) passes="conv" 783234977a2fSmrg ;; 783334977a2fSmrg esac 783434977a2fSmrg 783534977a2fSmrg for pass in $passes; do 783634977a2fSmrg # The preopen pass in lib mode reverses $deplibs; put it back here 783734977a2fSmrg # so that -L comes before libs that need it for instance... 7838fe24f8a2Smrg if test lib,link = "$linkmode,$pass"; then 783934977a2fSmrg ## FIXME: Find the place where the list is rebuilt in the wrong 784034977a2fSmrg ## order, and fix it there properly 784134977a2fSmrg tmp_deplibs= 784234977a2fSmrg for deplib in $deplibs; do 784334977a2fSmrg tmp_deplibs="$deplib $tmp_deplibs" 784434977a2fSmrg done 7845fe24f8a2Smrg deplibs=$tmp_deplibs 784634977a2fSmrg fi 784734977a2fSmrg 7848fe24f8a2Smrg if test lib,link = "$linkmode,$pass" || 7849fe24f8a2Smrg test prog,scan = "$linkmode,$pass"; then 7850fe24f8a2Smrg libs=$deplibs 785134977a2fSmrg deplibs= 785234977a2fSmrg fi 7853fe24f8a2Smrg if test prog = "$linkmode"; then 785434977a2fSmrg case $pass in 7855fe24f8a2Smrg dlopen) libs=$dlfiles ;; 7856fe24f8a2Smrg dlpreopen) libs=$dlprefiles ;; 785734977a2fSmrg link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; 785834977a2fSmrg esac 785934977a2fSmrg fi 7860fe24f8a2Smrg if test lib,dlpreopen = "$linkmode,$pass"; then 786134977a2fSmrg # Collect and forward deplibs of preopened libtool libs 786234977a2fSmrg for lib in $dlprefiles; do 786334977a2fSmrg # Ignore non-libtool-libs 786434977a2fSmrg dependency_libs= 78653e72ca8cSmrg func_resolve_sysroot "$lib" 786634977a2fSmrg case $lib in 78673e72ca8cSmrg *.la) func_source "$func_resolve_sysroot_result" ;; 786834977a2fSmrg esac 786934977a2fSmrg 787034977a2fSmrg # Collect preopened libtool deplibs, except any this library 787134977a2fSmrg # has declared as weak libs 787234977a2fSmrg for deplib in $dependency_libs; do 7873b425557eSmrg func_basename "$deplib" 7874b425557eSmrg deplib_base=$func_basename_result 787534977a2fSmrg case " $weak_libs " in 787634977a2fSmrg *" $deplib_base "*) ;; 78773e72ca8cSmrg *) func_append deplibs " $deplib" ;; 787834977a2fSmrg esac 787934977a2fSmrg done 788034977a2fSmrg done 7881fe24f8a2Smrg libs=$dlprefiles 788234977a2fSmrg fi 7883fe24f8a2Smrg if test dlopen = "$pass"; then 788434977a2fSmrg # Collect dlpreopened libraries 7885fe24f8a2Smrg save_deplibs=$deplibs 788634977a2fSmrg deplibs= 788734977a2fSmrg fi 788834977a2fSmrg 788934977a2fSmrg for deplib in $libs; do 789034977a2fSmrg lib= 7891fe24f8a2Smrg found=false 789234977a2fSmrg case $deplib in 78933e72ca8cSmrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 78943e72ca8cSmrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 7895fe24f8a2Smrg if test prog,link = "$linkmode,$pass"; then 789634977a2fSmrg compile_deplibs="$deplib $compile_deplibs" 789734977a2fSmrg finalize_deplibs="$deplib $finalize_deplibs" 789834977a2fSmrg else 78993e72ca8cSmrg func_append compiler_flags " $deplib" 7900fe24f8a2Smrg if test lib = "$linkmode"; then 790134977a2fSmrg case "$new_inherited_linker_flags " in 790234977a2fSmrg *" $deplib "*) ;; 79033e72ca8cSmrg * ) func_append new_inherited_linker_flags " $deplib" ;; 790434977a2fSmrg esac 790534977a2fSmrg fi 790634977a2fSmrg fi 790734977a2fSmrg continue 790834977a2fSmrg ;; 790934977a2fSmrg -l*) 7910fe24f8a2Smrg if test lib != "$linkmode" && test prog != "$linkmode"; then 7911fe24f8a2Smrg func_warning "'-l' is ignored for archives/objects" 791234977a2fSmrg continue 791334977a2fSmrg fi 791434977a2fSmrg func_stripname '-l' '' "$deplib" 791534977a2fSmrg name=$func_stripname_result 7916fe24f8a2Smrg if test lib = "$linkmode"; then 791734977a2fSmrg searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" 791834977a2fSmrg else 791934977a2fSmrg searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" 792034977a2fSmrg fi 792134977a2fSmrg for searchdir in $searchdirs; do 792234977a2fSmrg for search_ext in .la $std_shrext .so .a; do 792334977a2fSmrg # Search the libtool library 7924fe24f8a2Smrg lib=$searchdir/lib$name$search_ext 792534977a2fSmrg if test -f "$lib"; then 7926fe24f8a2Smrg if test .la = "$search_ext"; then 7927fe24f8a2Smrg found=: 792834977a2fSmrg else 7929fe24f8a2Smrg found=false 793034977a2fSmrg fi 793134977a2fSmrg break 2 793234977a2fSmrg fi 793334977a2fSmrg done 793434977a2fSmrg done 7935fe24f8a2Smrg if $found; then 7936fe24f8a2Smrg # deplib is a libtool library 793734977a2fSmrg # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, 793834977a2fSmrg # We need to do some special things here, and not later. 7939fe24f8a2Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 794034977a2fSmrg case " $predeps $postdeps " in 794134977a2fSmrg *" $deplib "*) 794234977a2fSmrg if func_lalib_p "$lib"; then 794334977a2fSmrg library_names= 794434977a2fSmrg old_library= 794534977a2fSmrg func_source "$lib" 794634977a2fSmrg for l in $old_library $library_names; do 7947fe24f8a2Smrg ll=$l 794834977a2fSmrg done 7949fe24f8a2Smrg if test "X$ll" = "X$old_library"; then # only static version available 7950fe24f8a2Smrg found=false 795134977a2fSmrg func_dirname "$lib" "" "." 7952fe24f8a2Smrg ladir=$func_dirname_result 795334977a2fSmrg lib=$ladir/$old_library 7954fe24f8a2Smrg if test prog,link = "$linkmode,$pass"; then 795534977a2fSmrg compile_deplibs="$deplib $compile_deplibs" 795634977a2fSmrg finalize_deplibs="$deplib $finalize_deplibs" 795734977a2fSmrg else 795834977a2fSmrg deplibs="$deplib $deplibs" 7959fe24f8a2Smrg test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 796034977a2fSmrg fi 796134977a2fSmrg continue 796234977a2fSmrg fi 796334977a2fSmrg fi 796434977a2fSmrg ;; 796534977a2fSmrg *) ;; 796634977a2fSmrg esac 796734977a2fSmrg fi 7968fe24f8a2Smrg else 7969fe24f8a2Smrg # deplib doesn't seem to be a libtool library 7970fe24f8a2Smrg if test prog,link = "$linkmode,$pass"; then 7971fe24f8a2Smrg compile_deplibs="$deplib $compile_deplibs" 7972fe24f8a2Smrg finalize_deplibs="$deplib $finalize_deplibs" 7973fe24f8a2Smrg else 7974fe24f8a2Smrg deplibs="$deplib $deplibs" 7975fe24f8a2Smrg test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 7976fe24f8a2Smrg fi 7977fe24f8a2Smrg continue 797834977a2fSmrg fi 797934977a2fSmrg ;; # -l 798034977a2fSmrg *.ltframework) 7981fe24f8a2Smrg if test prog,link = "$linkmode,$pass"; then 798234977a2fSmrg compile_deplibs="$deplib $compile_deplibs" 798334977a2fSmrg finalize_deplibs="$deplib $finalize_deplibs" 798434977a2fSmrg else 798534977a2fSmrg deplibs="$deplib $deplibs" 7986fe24f8a2Smrg if test lib = "$linkmode"; then 798734977a2fSmrg case "$new_inherited_linker_flags " in 798834977a2fSmrg *" $deplib "*) ;; 79893e72ca8cSmrg * ) func_append new_inherited_linker_flags " $deplib" ;; 799034977a2fSmrg esac 799134977a2fSmrg fi 799234977a2fSmrg fi 799334977a2fSmrg continue 799434977a2fSmrg ;; 799534977a2fSmrg -L*) 799634977a2fSmrg case $linkmode in 799734977a2fSmrg lib) 799834977a2fSmrg deplibs="$deplib $deplibs" 7999fe24f8a2Smrg test conv = "$pass" && continue 800034977a2fSmrg newdependency_libs="$deplib $newdependency_libs" 800134977a2fSmrg func_stripname '-L' '' "$deplib" 80023e72ca8cSmrg func_resolve_sysroot "$func_stripname_result" 80033e72ca8cSmrg func_append newlib_search_path " $func_resolve_sysroot_result" 800434977a2fSmrg ;; 800534977a2fSmrg prog) 8006fe24f8a2Smrg if test conv = "$pass"; then 800734977a2fSmrg deplibs="$deplib $deplibs" 800834977a2fSmrg continue 800934977a2fSmrg fi 8010fe24f8a2Smrg if test scan = "$pass"; then 801134977a2fSmrg deplibs="$deplib $deplibs" 801234977a2fSmrg else 801334977a2fSmrg compile_deplibs="$deplib $compile_deplibs" 801434977a2fSmrg finalize_deplibs="$deplib $finalize_deplibs" 801534977a2fSmrg fi 801634977a2fSmrg func_stripname '-L' '' "$deplib" 80173e72ca8cSmrg func_resolve_sysroot "$func_stripname_result" 80183e72ca8cSmrg func_append newlib_search_path " $func_resolve_sysroot_result" 801934977a2fSmrg ;; 802034977a2fSmrg *) 8021fe24f8a2Smrg func_warning "'-L' is ignored for archives/objects" 802234977a2fSmrg ;; 802334977a2fSmrg esac # linkmode 802434977a2fSmrg continue 802534977a2fSmrg ;; # -L 802634977a2fSmrg -R*) 8027fe24f8a2Smrg if test link = "$pass"; then 802834977a2fSmrg func_stripname '-R' '' "$deplib" 80293e72ca8cSmrg func_resolve_sysroot "$func_stripname_result" 80303e72ca8cSmrg dir=$func_resolve_sysroot_result 803134977a2fSmrg # Make sure the xrpath contains only unique directories. 803234977a2fSmrg case "$xrpath " in 803334977a2fSmrg *" $dir "*) ;; 80343e72ca8cSmrg *) func_append xrpath " $dir" ;; 803534977a2fSmrg esac 803634977a2fSmrg fi 803734977a2fSmrg deplibs="$deplib $deplibs" 803834977a2fSmrg continue 803934977a2fSmrg ;; 80403e72ca8cSmrg *.la) 80413e72ca8cSmrg func_resolve_sysroot "$deplib" 80423e72ca8cSmrg lib=$func_resolve_sysroot_result 80433e72ca8cSmrg ;; 804434977a2fSmrg *.$libext) 8045fe24f8a2Smrg if test conv = "$pass"; then 804634977a2fSmrg deplibs="$deplib $deplibs" 804734977a2fSmrg continue 804834977a2fSmrg fi 804934977a2fSmrg case $linkmode in 805034977a2fSmrg lib) 805134977a2fSmrg # Linking convenience modules into shared libraries is allowed, 805234977a2fSmrg # but linking other static libraries is non-portable. 805334977a2fSmrg case " $dlpreconveniencelibs " in 805434977a2fSmrg *" $deplib "*) ;; 805534977a2fSmrg *) 8056fe24f8a2Smrg valid_a_lib=false 805734977a2fSmrg case $deplibs_check_method in 805834977a2fSmrg match_pattern*) 805934977a2fSmrg set dummy $deplibs_check_method; shift 806034977a2fSmrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 8061b425557eSmrg if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ 806234977a2fSmrg | $EGREP "$match_pattern_regex" > /dev/null; then 8063fe24f8a2Smrg valid_a_lib=: 806434977a2fSmrg fi 806534977a2fSmrg ;; 806634977a2fSmrg pass_all) 8067fe24f8a2Smrg valid_a_lib=: 806834977a2fSmrg ;; 806934977a2fSmrg esac 8070fe24f8a2Smrg if $valid_a_lib; then 8071fe24f8a2Smrg echo 8072fe24f8a2Smrg $ECHO "*** Warning: Linking the shared library $output against the" 8073fe24f8a2Smrg $ECHO "*** static library $deplib is not portable!" 8074fe24f8a2Smrg deplibs="$deplib $deplibs" 8075fe24f8a2Smrg else 8076b425557eSmrg echo 807734977a2fSmrg $ECHO "*** Warning: Trying to link with static lib archive $deplib." 8078b425557eSmrg echo "*** I have the capability to make that library automatically link in when" 8079b425557eSmrg echo "*** you link to this library. But I can only do this if you have a" 8080b425557eSmrg echo "*** shared version of the library, which you do not appear to have" 8081b425557eSmrg echo "*** because the file extensions .$libext of this argument makes me believe" 8082b425557eSmrg echo "*** that it is just a static archive that I should not use here." 808334977a2fSmrg fi 808434977a2fSmrg ;; 808534977a2fSmrg esac 808634977a2fSmrg continue 808734977a2fSmrg ;; 808834977a2fSmrg prog) 8089fe24f8a2Smrg if test link != "$pass"; then 809034977a2fSmrg deplibs="$deplib $deplibs" 809134977a2fSmrg else 809234977a2fSmrg compile_deplibs="$deplib $compile_deplibs" 809334977a2fSmrg finalize_deplibs="$deplib $finalize_deplibs" 809434977a2fSmrg fi 809534977a2fSmrg continue 809634977a2fSmrg ;; 809734977a2fSmrg esac # linkmode 809834977a2fSmrg ;; # *.$libext 809934977a2fSmrg *.lo | *.$objext) 8100fe24f8a2Smrg if test conv = "$pass"; then 810134977a2fSmrg deplibs="$deplib $deplibs" 8102fe24f8a2Smrg elif test prog = "$linkmode"; then 8103fe24f8a2Smrg if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then 810434977a2fSmrg # If there is no dlopen support or we're linking statically, 810534977a2fSmrg # we need to preload. 81063e72ca8cSmrg func_append newdlprefiles " $deplib" 810734977a2fSmrg compile_deplibs="$deplib $compile_deplibs" 810834977a2fSmrg finalize_deplibs="$deplib $finalize_deplibs" 810934977a2fSmrg else 81103e72ca8cSmrg func_append newdlfiles " $deplib" 811134977a2fSmrg fi 811234977a2fSmrg fi 811334977a2fSmrg continue 811434977a2fSmrg ;; 811534977a2fSmrg %DEPLIBS%) 8116fe24f8a2Smrg alldeplibs=: 811734977a2fSmrg continue 811834977a2fSmrg ;; 811934977a2fSmrg esac # case $deplib 812034977a2fSmrg 8121fe24f8a2Smrg $found || test -f "$lib" \ 8122fe24f8a2Smrg || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'" 812334977a2fSmrg 812434977a2fSmrg # Check to see that this really is a libtool archive. 812534977a2fSmrg func_lalib_unsafe_p "$lib" \ 8126fe24f8a2Smrg || func_fatal_error "'$lib' is not a valid libtool archive" 812734977a2fSmrg 812834977a2fSmrg func_dirname "$lib" "" "." 8129fe24f8a2Smrg ladir=$func_dirname_result 813034977a2fSmrg 813134977a2fSmrg dlname= 813234977a2fSmrg dlopen= 813334977a2fSmrg dlpreopen= 813434977a2fSmrg libdir= 813534977a2fSmrg library_names= 813634977a2fSmrg old_library= 813734977a2fSmrg inherited_linker_flags= 813834977a2fSmrg # If the library was installed with an old release of libtool, 813934977a2fSmrg # it will not redefine variables installed, or shouldnotlink 814034977a2fSmrg installed=yes 814134977a2fSmrg shouldnotlink=no 814234977a2fSmrg avoidtemprpath= 814334977a2fSmrg 814434977a2fSmrg 814534977a2fSmrg # Read the .la file 814634977a2fSmrg func_source "$lib" 814734977a2fSmrg 814834977a2fSmrg # Convert "-framework foo" to "foo.ltframework" 814934977a2fSmrg if test -n "$inherited_linker_flags"; then 8150b425557eSmrg tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` 815134977a2fSmrg for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do 815234977a2fSmrg case " $new_inherited_linker_flags " in 815334977a2fSmrg *" $tmp_inherited_linker_flag "*) ;; 81543e72ca8cSmrg *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; 815534977a2fSmrg esac 815634977a2fSmrg done 815734977a2fSmrg fi 8158b425557eSmrg dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 8159fe24f8a2Smrg if test lib,link = "$linkmode,$pass" || 8160fe24f8a2Smrg test prog,scan = "$linkmode,$pass" || 8161fe24f8a2Smrg { test prog != "$linkmode" && test lib != "$linkmode"; }; then 81623e72ca8cSmrg test -n "$dlopen" && func_append dlfiles " $dlopen" 81633e72ca8cSmrg test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" 816434977a2fSmrg fi 816534977a2fSmrg 8166fe24f8a2Smrg if test conv = "$pass"; then 816734977a2fSmrg # Only check for convenience libraries 816834977a2fSmrg deplibs="$lib $deplibs" 816934977a2fSmrg if test -z "$libdir"; then 817034977a2fSmrg if test -z "$old_library"; then 8171fe24f8a2Smrg func_fatal_error "cannot find name of link library for '$lib'" 817234977a2fSmrg fi 817334977a2fSmrg # It is a libtool convenience library, so add in its objects. 81743e72ca8cSmrg func_append convenience " $ladir/$objdir/$old_library" 81753e72ca8cSmrg func_append old_convenience " $ladir/$objdir/$old_library" 8176fe24f8a2Smrg elif test prog != "$linkmode" && test lib != "$linkmode"; then 8177fe24f8a2Smrg func_fatal_error "'$lib' is not a convenience library" 817834977a2fSmrg fi 817934977a2fSmrg tmp_libs= 818034977a2fSmrg for deplib in $dependency_libs; do 818134977a2fSmrg deplibs="$deplib $deplibs" 8182fe24f8a2Smrg if $opt_preserve_dup_deps; then 818334977a2fSmrg case "$tmp_libs " in 81843e72ca8cSmrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 818534977a2fSmrg esac 818634977a2fSmrg fi 81873e72ca8cSmrg func_append tmp_libs " $deplib" 818834977a2fSmrg done 818934977a2fSmrg continue 819034977a2fSmrg fi # $pass = conv 819134977a2fSmrg 819234977a2fSmrg 819334977a2fSmrg # Get the name of the library we link against. 819434977a2fSmrg linklib= 81953e72ca8cSmrg if test -n "$old_library" && 8196fe24f8a2Smrg { test yes = "$prefer_static_libs" || 8197fe24f8a2Smrg test built,no = "$prefer_static_libs,$installed"; }; then 81983e72ca8cSmrg linklib=$old_library 81993e72ca8cSmrg else 82003e72ca8cSmrg for l in $old_library $library_names; do 8201fe24f8a2Smrg linklib=$l 82023e72ca8cSmrg done 82033e72ca8cSmrg fi 820434977a2fSmrg if test -z "$linklib"; then 8205fe24f8a2Smrg func_fatal_error "cannot find name of link library for '$lib'" 820634977a2fSmrg fi 820734977a2fSmrg 820834977a2fSmrg # This library was specified with -dlopen. 8209fe24f8a2Smrg if test dlopen = "$pass"; then 8210fe24f8a2Smrg test -z "$libdir" \ 8211fe24f8a2Smrg && func_fatal_error "cannot -dlopen a convenience library: '$lib'" 821234977a2fSmrg if test -z "$dlname" || 8213fe24f8a2Smrg test yes != "$dlopen_support" || 8214fe24f8a2Smrg test no = "$build_libtool_libs" 8215fe24f8a2Smrg then 821634977a2fSmrg # If there is no dlname, no dlopen support or we're linking 821734977a2fSmrg # statically, we need to preload. We also need to preload any 821834977a2fSmrg # dependent libraries so libltdl's deplib preloader doesn't 821934977a2fSmrg # bomb out in the load deplibs phase. 82203e72ca8cSmrg func_append dlprefiles " $lib $dependency_libs" 822134977a2fSmrg else 82223e72ca8cSmrg func_append newdlfiles " $lib" 822334977a2fSmrg fi 822434977a2fSmrg continue 822534977a2fSmrg fi # $pass = dlopen 822634977a2fSmrg 822734977a2fSmrg # We need an absolute path. 822834977a2fSmrg case $ladir in 8229fe24f8a2Smrg [\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;; 823034977a2fSmrg *) 823134977a2fSmrg abs_ladir=`cd "$ladir" && pwd` 823234977a2fSmrg if test -z "$abs_ladir"; then 8233fe24f8a2Smrg func_warning "cannot determine absolute directory name of '$ladir'" 823434977a2fSmrg func_warning "passing it literally to the linker, although it might fail" 8235fe24f8a2Smrg abs_ladir=$ladir 823634977a2fSmrg fi 823734977a2fSmrg ;; 823834977a2fSmrg esac 823934977a2fSmrg func_basename "$lib" 8240fe24f8a2Smrg laname=$func_basename_result 824134977a2fSmrg 824234977a2fSmrg # Find the relevant object directory and library name. 8243fe24f8a2Smrg if test yes = "$installed"; then 82443e72ca8cSmrg if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then 8245fe24f8a2Smrg func_warning "library '$lib' was moved." 8246fe24f8a2Smrg dir=$ladir 8247fe24f8a2Smrg absdir=$abs_ladir 8248fe24f8a2Smrg libdir=$abs_ladir 824934977a2fSmrg else 8250fe24f8a2Smrg dir=$lt_sysroot$libdir 8251fe24f8a2Smrg absdir=$lt_sysroot$libdir 825234977a2fSmrg fi 8253fe24f8a2Smrg test yes = "$hardcode_automatic" && avoidtemprpath=yes 825434977a2fSmrg else 825534977a2fSmrg if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then 8256fe24f8a2Smrg dir=$ladir 8257fe24f8a2Smrg absdir=$abs_ladir 825834977a2fSmrg # Remove this search path later 82593e72ca8cSmrg func_append notinst_path " $abs_ladir" 826034977a2fSmrg else 8261fe24f8a2Smrg dir=$ladir/$objdir 8262fe24f8a2Smrg absdir=$abs_ladir/$objdir 826334977a2fSmrg # Remove this search path later 82643e72ca8cSmrg func_append notinst_path " $abs_ladir" 826534977a2fSmrg fi 826634977a2fSmrg fi # $installed = yes 826734977a2fSmrg func_stripname 'lib' '.la' "$laname" 826834977a2fSmrg name=$func_stripname_result 826934977a2fSmrg 827034977a2fSmrg # This library was specified with -dlpreopen. 8271fe24f8a2Smrg if test dlpreopen = "$pass"; then 8272fe24f8a2Smrg if test -z "$libdir" && test prog = "$linkmode"; then 8273fe24f8a2Smrg func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'" 827434977a2fSmrg fi 8275fe24f8a2Smrg case $host in 82763e72ca8cSmrg # special handling for platforms with PE-DLLs. 82773e72ca8cSmrg *cygwin* | *mingw* | *cegcc* ) 82783e72ca8cSmrg # Linker will automatically link against shared library if both 82793e72ca8cSmrg # static and shared are present. Therefore, ensure we extract 82803e72ca8cSmrg # symbols from the import library if a shared library is present 82813e72ca8cSmrg # (otherwise, the dlopen module name will be incorrect). We do 82823e72ca8cSmrg # this by putting the import library name into $newdlprefiles. 82833e72ca8cSmrg # We recover the dlopen module name by 'saving' the la file 82843e72ca8cSmrg # name in a special purpose variable, and (later) extracting the 82853e72ca8cSmrg # dlname from the la file. 82863e72ca8cSmrg if test -n "$dlname"; then 82873e72ca8cSmrg func_tr_sh "$dir/$linklib" 82883e72ca8cSmrg eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" 82893e72ca8cSmrg func_append newdlprefiles " $dir/$linklib" 82903e72ca8cSmrg else 82913e72ca8cSmrg func_append newdlprefiles " $dir/$old_library" 82923e72ca8cSmrg # Keep a list of preopened convenience libraries to check 82933e72ca8cSmrg # that they are being used correctly in the link pass. 82943e72ca8cSmrg test -z "$libdir" && \ 82953e72ca8cSmrg func_append dlpreconveniencelibs " $dir/$old_library" 82963e72ca8cSmrg fi 82973e72ca8cSmrg ;; 82983e72ca8cSmrg * ) 82993e72ca8cSmrg # Prefer using a static library (so that no silly _DYNAMIC symbols 83003e72ca8cSmrg # are required to link). 83013e72ca8cSmrg if test -n "$old_library"; then 83023e72ca8cSmrg func_append newdlprefiles " $dir/$old_library" 83033e72ca8cSmrg # Keep a list of preopened convenience libraries to check 83043e72ca8cSmrg # that they are being used correctly in the link pass. 83053e72ca8cSmrg test -z "$libdir" && \ 83063e72ca8cSmrg func_append dlpreconveniencelibs " $dir/$old_library" 83073e72ca8cSmrg # Otherwise, use the dlname, so that lt_dlopen finds it. 83083e72ca8cSmrg elif test -n "$dlname"; then 83093e72ca8cSmrg func_append newdlprefiles " $dir/$dlname" 83103e72ca8cSmrg else 83113e72ca8cSmrg func_append newdlprefiles " $dir/$linklib" 83123e72ca8cSmrg fi 83133e72ca8cSmrg ;; 83143e72ca8cSmrg esac 831534977a2fSmrg fi # $pass = dlpreopen 831634977a2fSmrg 831734977a2fSmrg if test -z "$libdir"; then 831834977a2fSmrg # Link the convenience library 8319fe24f8a2Smrg if test lib = "$linkmode"; then 832034977a2fSmrg deplibs="$dir/$old_library $deplibs" 8321fe24f8a2Smrg elif test prog,link = "$linkmode,$pass"; then 832234977a2fSmrg compile_deplibs="$dir/$old_library $compile_deplibs" 832334977a2fSmrg finalize_deplibs="$dir/$old_library $finalize_deplibs" 832434977a2fSmrg else 832534977a2fSmrg deplibs="$lib $deplibs" # used for prog,scan pass 832634977a2fSmrg fi 832734977a2fSmrg continue 832834977a2fSmrg fi 832934977a2fSmrg 833034977a2fSmrg 8331fe24f8a2Smrg if test prog = "$linkmode" && test link != "$pass"; then 83323e72ca8cSmrg func_append newlib_search_path " $ladir" 833334977a2fSmrg deplibs="$lib $deplibs" 833434977a2fSmrg 8335fe24f8a2Smrg linkalldeplibs=false 8336fe24f8a2Smrg if test no != "$link_all_deplibs" || test -z "$library_names" || 8337fe24f8a2Smrg test no = "$build_libtool_libs"; then 8338fe24f8a2Smrg linkalldeplibs=: 833934977a2fSmrg fi 834034977a2fSmrg 834134977a2fSmrg tmp_libs= 834234977a2fSmrg for deplib in $dependency_libs; do 834334977a2fSmrg case $deplib in 834434977a2fSmrg -L*) func_stripname '-L' '' "$deplib" 83453e72ca8cSmrg func_resolve_sysroot "$func_stripname_result" 83463e72ca8cSmrg func_append newlib_search_path " $func_resolve_sysroot_result" 834734977a2fSmrg ;; 834834977a2fSmrg esac 834934977a2fSmrg # Need to link against all dependency_libs? 8350fe24f8a2Smrg if $linkalldeplibs; then 835134977a2fSmrg deplibs="$deplib $deplibs" 835234977a2fSmrg else 835334977a2fSmrg # Need to hardcode shared library paths 835434977a2fSmrg # or/and link against static libraries 835534977a2fSmrg newdependency_libs="$deplib $newdependency_libs" 835634977a2fSmrg fi 8357fe24f8a2Smrg if $opt_preserve_dup_deps; then 835834977a2fSmrg case "$tmp_libs " in 83593e72ca8cSmrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 836034977a2fSmrg esac 836134977a2fSmrg fi 83623e72ca8cSmrg func_append tmp_libs " $deplib" 836334977a2fSmrg done # for deplib 836434977a2fSmrg continue 836534977a2fSmrg fi # $linkmode = prog... 836634977a2fSmrg 8367fe24f8a2Smrg if test prog,link = "$linkmode,$pass"; then 836834977a2fSmrg if test -n "$library_names" && 8369fe24f8a2Smrg { { test no = "$prefer_static_libs" || 8370fe24f8a2Smrg test built,yes = "$prefer_static_libs,$installed"; } || 837134977a2fSmrg test -z "$old_library"; }; then 837234977a2fSmrg # We need to hardcode the library path 8373fe24f8a2Smrg if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then 837434977a2fSmrg # Make sure the rpath contains only unique directories. 8375fe24f8a2Smrg case $temp_rpath: in 837634977a2fSmrg *"$absdir:"*) ;; 83773e72ca8cSmrg *) func_append temp_rpath "$absdir:" ;; 837834977a2fSmrg esac 837934977a2fSmrg fi 838034977a2fSmrg 838134977a2fSmrg # Hardcode the library path. 838234977a2fSmrg # Skip directories that are in the system default run-time 838334977a2fSmrg # search path. 838434977a2fSmrg case " $sys_lib_dlsearch_path " in 838534977a2fSmrg *" $absdir "*) ;; 838634977a2fSmrg *) 838734977a2fSmrg case "$compile_rpath " in 838834977a2fSmrg *" $absdir "*) ;; 83893e72ca8cSmrg *) func_append compile_rpath " $absdir" ;; 839034977a2fSmrg esac 839134977a2fSmrg ;; 839234977a2fSmrg esac 839334977a2fSmrg case " $sys_lib_dlsearch_path " in 839434977a2fSmrg *" $libdir "*) ;; 839534977a2fSmrg *) 839634977a2fSmrg case "$finalize_rpath " in 839734977a2fSmrg *" $libdir "*) ;; 83983e72ca8cSmrg *) func_append finalize_rpath " $libdir" ;; 839934977a2fSmrg esac 840034977a2fSmrg ;; 840134977a2fSmrg esac 840234977a2fSmrg fi # $linkmode,$pass = prog,link... 840334977a2fSmrg 8404fe24f8a2Smrg if $alldeplibs && 8405fe24f8a2Smrg { test pass_all = "$deplibs_check_method" || 8406fe24f8a2Smrg { test yes = "$build_libtool_libs" && 840734977a2fSmrg test -n "$library_names"; }; }; then 840834977a2fSmrg # We only need to search for static libraries 840934977a2fSmrg continue 841034977a2fSmrg fi 841134977a2fSmrg fi 841234977a2fSmrg 841334977a2fSmrg link_static=no # Whether the deplib will be linked statically 841434977a2fSmrg use_static_libs=$prefer_static_libs 8415fe24f8a2Smrg if test built = "$use_static_libs" && test yes = "$installed"; then 841634977a2fSmrg use_static_libs=no 841734977a2fSmrg fi 841834977a2fSmrg if test -n "$library_names" && 8419fe24f8a2Smrg { test no = "$use_static_libs" || test -z "$old_library"; }; then 842034977a2fSmrg case $host in 8421fe24f8a2Smrg *cygwin* | *mingw* | *cegcc* | *os2*) 842234977a2fSmrg # No point in relinking DLLs because paths are not encoded 84233e72ca8cSmrg func_append notinst_deplibs " $lib" 842434977a2fSmrg need_relink=no 842534977a2fSmrg ;; 842634977a2fSmrg *) 8427fe24f8a2Smrg if test no = "$installed"; then 84283e72ca8cSmrg func_append notinst_deplibs " $lib" 842934977a2fSmrg need_relink=yes 843034977a2fSmrg fi 843134977a2fSmrg ;; 843234977a2fSmrg esac 843334977a2fSmrg # This is a shared library 843434977a2fSmrg 843534977a2fSmrg # Warn about portability, can't link against -module's on some 843634977a2fSmrg # systems (darwin). Don't bleat about dlopened modules though! 8437fe24f8a2Smrg dlopenmodule= 843834977a2fSmrg for dlpremoduletest in $dlprefiles; do 843934977a2fSmrg if test "X$dlpremoduletest" = "X$lib"; then 8440fe24f8a2Smrg dlopenmodule=$dlpremoduletest 844134977a2fSmrg break 844234977a2fSmrg fi 844334977a2fSmrg done 8444fe24f8a2Smrg if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then 8445b425557eSmrg echo 8446fe24f8a2Smrg if test prog = "$linkmode"; then 844734977a2fSmrg $ECHO "*** Warning: Linking the executable $output against the loadable module" 844834977a2fSmrg else 844934977a2fSmrg $ECHO "*** Warning: Linking the shared library $output against the loadable module" 845034977a2fSmrg fi 845134977a2fSmrg $ECHO "*** $linklib is not portable!" 845234977a2fSmrg fi 8453fe24f8a2Smrg if test lib = "$linkmode" && 8454fe24f8a2Smrg test yes = "$hardcode_into_libs"; then 845534977a2fSmrg # Hardcode the library path. 845634977a2fSmrg # Skip directories that are in the system default run-time 845734977a2fSmrg # search path. 845834977a2fSmrg case " $sys_lib_dlsearch_path " in 845934977a2fSmrg *" $absdir "*) ;; 846034977a2fSmrg *) 846134977a2fSmrg case "$compile_rpath " in 846234977a2fSmrg *" $absdir "*) ;; 84633e72ca8cSmrg *) func_append compile_rpath " $absdir" ;; 846434977a2fSmrg esac 846534977a2fSmrg ;; 846634977a2fSmrg esac 846734977a2fSmrg case " $sys_lib_dlsearch_path " in 846834977a2fSmrg *" $libdir "*) ;; 846934977a2fSmrg *) 847034977a2fSmrg case "$finalize_rpath " in 847134977a2fSmrg *" $libdir "*) ;; 84723e72ca8cSmrg *) func_append finalize_rpath " $libdir" ;; 847334977a2fSmrg esac 847434977a2fSmrg ;; 847534977a2fSmrg esac 847634977a2fSmrg fi 847734977a2fSmrg 847834977a2fSmrg if test -n "$old_archive_from_expsyms_cmds"; then 847934977a2fSmrg # figure out the soname 848034977a2fSmrg set dummy $library_names 848134977a2fSmrg shift 8482fe24f8a2Smrg realname=$1 848334977a2fSmrg shift 848434977a2fSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 848534977a2fSmrg # use dlname if we got it. it's perfectly good, no? 848634977a2fSmrg if test -n "$dlname"; then 8487fe24f8a2Smrg soname=$dlname 848834977a2fSmrg elif test -n "$soname_spec"; then 848934977a2fSmrg # bleh windows 849034977a2fSmrg case $host in 8491fe24f8a2Smrg *cygwin* | mingw* | *cegcc* | *os2*) 849234977a2fSmrg func_arith $current - $age 849334977a2fSmrg major=$func_arith_result 8494fe24f8a2Smrg versuffix=-$major 849534977a2fSmrg ;; 849634977a2fSmrg esac 849734977a2fSmrg eval soname=\"$soname_spec\" 849834977a2fSmrg else 8499fe24f8a2Smrg soname=$realname 850034977a2fSmrg fi 850134977a2fSmrg 850234977a2fSmrg # Make a new name for the extract_expsyms_cmds to use 8503fe24f8a2Smrg soroot=$soname 850434977a2fSmrg func_basename "$soroot" 8505fe24f8a2Smrg soname=$func_basename_result 850634977a2fSmrg func_stripname 'lib' '.dll' "$soname" 850734977a2fSmrg newlib=libimp-$func_stripname_result.a 850834977a2fSmrg 850934977a2fSmrg # If the library has no export list, then create one now 851034977a2fSmrg if test -f "$output_objdir/$soname-def"; then : 851134977a2fSmrg else 8512fe24f8a2Smrg func_verbose "extracting exported symbol list from '$soname'" 851334977a2fSmrg func_execute_cmds "$extract_expsyms_cmds" 'exit $?' 851434977a2fSmrg fi 851534977a2fSmrg 851634977a2fSmrg # Create $newlib 851734977a2fSmrg if test -f "$output_objdir/$newlib"; then :; else 8518fe24f8a2Smrg func_verbose "generating import library for '$soname'" 851934977a2fSmrg func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' 852034977a2fSmrg fi 852134977a2fSmrg # make sure the library variables are pointing to the new library 852234977a2fSmrg dir=$output_objdir 852334977a2fSmrg linklib=$newlib 852434977a2fSmrg fi # test -n "$old_archive_from_expsyms_cmds" 852534977a2fSmrg 8526fe24f8a2Smrg if test prog = "$linkmode" || test relink != "$opt_mode"; then 852734977a2fSmrg add_shlibpath= 852834977a2fSmrg add_dir= 852934977a2fSmrg add= 853034977a2fSmrg lib_linked=yes 853134977a2fSmrg case $hardcode_action in 853234977a2fSmrg immediate | unsupported) 8533fe24f8a2Smrg if test no = "$hardcode_direct"; then 8534fe24f8a2Smrg add=$dir/$linklib 853534977a2fSmrg case $host in 8536fe24f8a2Smrg *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;; 8537fe24f8a2Smrg *-*-sysv4*uw2*) add_dir=-L$dir ;; 853834977a2fSmrg *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ 8539fe24f8a2Smrg *-*-unixware7*) add_dir=-L$dir ;; 854034977a2fSmrg *-*-darwin* ) 8541fe24f8a2Smrg # if the lib is a (non-dlopened) module then we cannot 854234977a2fSmrg # link against it, someone is ignoring the earlier warnings 854334977a2fSmrg if /usr/bin/file -L $add 2> /dev/null | 8544fe24f8a2Smrg $GREP ": [^:]* bundle" >/dev/null; then 854534977a2fSmrg if test "X$dlopenmodule" != "X$lib"; then 854634977a2fSmrg $ECHO "*** Warning: lib $linklib is a module, not a shared library" 8547fe24f8a2Smrg if test -z "$old_library"; then 8548b425557eSmrg echo 8549b425557eSmrg echo "*** And there doesn't seem to be a static archive available" 8550b425557eSmrg echo "*** The link will probably fail, sorry" 855134977a2fSmrg else 8552fe24f8a2Smrg add=$dir/$old_library 855334977a2fSmrg fi 855434977a2fSmrg elif test -n "$old_library"; then 8555fe24f8a2Smrg add=$dir/$old_library 855634977a2fSmrg fi 855734977a2fSmrg fi 855834977a2fSmrg esac 8559fe24f8a2Smrg elif test no = "$hardcode_minus_L"; then 856034977a2fSmrg case $host in 8561fe24f8a2Smrg *-*-sunos*) add_shlibpath=$dir ;; 856234977a2fSmrg esac 8563fe24f8a2Smrg add_dir=-L$dir 8564fe24f8a2Smrg add=-l$name 8565fe24f8a2Smrg elif test no = "$hardcode_shlibpath_var"; then 8566fe24f8a2Smrg add_shlibpath=$dir 8567fe24f8a2Smrg add=-l$name 856834977a2fSmrg else 856934977a2fSmrg lib_linked=no 857034977a2fSmrg fi 857134977a2fSmrg ;; 857234977a2fSmrg relink) 8573fe24f8a2Smrg if test yes = "$hardcode_direct" && 8574fe24f8a2Smrg test no = "$hardcode_direct_absolute"; then 8575fe24f8a2Smrg add=$dir/$linklib 8576fe24f8a2Smrg elif test yes = "$hardcode_minus_L"; then 8577fe24f8a2Smrg add_dir=-L$absdir 857834977a2fSmrg # Try looking first in the location we're being installed to. 857934977a2fSmrg if test -n "$inst_prefix_dir"; then 858034977a2fSmrg case $libdir in 858134977a2fSmrg [\\/]*) 85823e72ca8cSmrg func_append add_dir " -L$inst_prefix_dir$libdir" 858334977a2fSmrg ;; 858434977a2fSmrg esac 858534977a2fSmrg fi 8586fe24f8a2Smrg add=-l$name 8587fe24f8a2Smrg elif test yes = "$hardcode_shlibpath_var"; then 8588fe24f8a2Smrg add_shlibpath=$dir 8589fe24f8a2Smrg add=-l$name 859034977a2fSmrg else 859134977a2fSmrg lib_linked=no 859234977a2fSmrg fi 859334977a2fSmrg ;; 859434977a2fSmrg *) lib_linked=no ;; 859534977a2fSmrg esac 859634977a2fSmrg 8597fe24f8a2Smrg if test yes != "$lib_linked"; then 859834977a2fSmrg func_fatal_configuration "unsupported hardcode properties" 859934977a2fSmrg fi 860034977a2fSmrg 860134977a2fSmrg if test -n "$add_shlibpath"; then 860234977a2fSmrg case :$compile_shlibpath: in 860334977a2fSmrg *":$add_shlibpath:"*) ;; 86043e72ca8cSmrg *) func_append compile_shlibpath "$add_shlibpath:" ;; 860534977a2fSmrg esac 860634977a2fSmrg fi 8607fe24f8a2Smrg if test prog = "$linkmode"; then 860834977a2fSmrg test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" 860934977a2fSmrg test -n "$add" && compile_deplibs="$add $compile_deplibs" 861034977a2fSmrg else 861134977a2fSmrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 861234977a2fSmrg test -n "$add" && deplibs="$add $deplibs" 8613fe24f8a2Smrg if test yes != "$hardcode_direct" && 8614fe24f8a2Smrg test yes != "$hardcode_minus_L" && 8615fe24f8a2Smrg test yes = "$hardcode_shlibpath_var"; then 861634977a2fSmrg case :$finalize_shlibpath: in 861734977a2fSmrg *":$libdir:"*) ;; 86183e72ca8cSmrg *) func_append finalize_shlibpath "$libdir:" ;; 861934977a2fSmrg esac 862034977a2fSmrg fi 862134977a2fSmrg fi 862234977a2fSmrg fi 862334977a2fSmrg 8624fe24f8a2Smrg if test prog = "$linkmode" || test relink = "$opt_mode"; then 862534977a2fSmrg add_shlibpath= 862634977a2fSmrg add_dir= 862734977a2fSmrg add= 862834977a2fSmrg # Finalize command for both is simple: just hardcode it. 8629fe24f8a2Smrg if test yes = "$hardcode_direct" && 8630fe24f8a2Smrg test no = "$hardcode_direct_absolute"; then 8631fe24f8a2Smrg add=$libdir/$linklib 8632fe24f8a2Smrg elif test yes = "$hardcode_minus_L"; then 8633fe24f8a2Smrg add_dir=-L$libdir 8634fe24f8a2Smrg add=-l$name 8635fe24f8a2Smrg elif test yes = "$hardcode_shlibpath_var"; then 863634977a2fSmrg case :$finalize_shlibpath: in 863734977a2fSmrg *":$libdir:"*) ;; 86383e72ca8cSmrg *) func_append finalize_shlibpath "$libdir:" ;; 863934977a2fSmrg esac 8640fe24f8a2Smrg add=-l$name 8641fe24f8a2Smrg elif test yes = "$hardcode_automatic"; then 864234977a2fSmrg if test -n "$inst_prefix_dir" && 8643fe24f8a2Smrg test -f "$inst_prefix_dir$libdir/$linklib"; then 8644fe24f8a2Smrg add=$inst_prefix_dir$libdir/$linklib 864534977a2fSmrg else 8646fe24f8a2Smrg add=$libdir/$linklib 864734977a2fSmrg fi 864834977a2fSmrg else 864934977a2fSmrg # We cannot seem to hardcode it, guess we'll fake it. 8650fe24f8a2Smrg add_dir=-L$libdir 865134977a2fSmrg # Try looking first in the location we're being installed to. 865234977a2fSmrg if test -n "$inst_prefix_dir"; then 865334977a2fSmrg case $libdir in 865434977a2fSmrg [\\/]*) 86553e72ca8cSmrg func_append add_dir " -L$inst_prefix_dir$libdir" 865634977a2fSmrg ;; 865734977a2fSmrg esac 865834977a2fSmrg fi 8659fe24f8a2Smrg add=-l$name 866034977a2fSmrg fi 866134977a2fSmrg 8662fe24f8a2Smrg if test prog = "$linkmode"; then 866334977a2fSmrg test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" 866434977a2fSmrg test -n "$add" && finalize_deplibs="$add $finalize_deplibs" 866534977a2fSmrg else 866634977a2fSmrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 866734977a2fSmrg test -n "$add" && deplibs="$add $deplibs" 866834977a2fSmrg fi 866934977a2fSmrg fi 8670fe24f8a2Smrg elif test prog = "$linkmode"; then 867134977a2fSmrg # Here we assume that one of hardcode_direct or hardcode_minus_L 867234977a2fSmrg # is not unsupported. This is valid on all known static and 867334977a2fSmrg # shared platforms. 8674fe24f8a2Smrg if test unsupported != "$hardcode_direct"; then 8675fe24f8a2Smrg test -n "$old_library" && linklib=$old_library 867634977a2fSmrg compile_deplibs="$dir/$linklib $compile_deplibs" 867734977a2fSmrg finalize_deplibs="$dir/$linklib $finalize_deplibs" 867834977a2fSmrg else 867934977a2fSmrg compile_deplibs="-l$name -L$dir $compile_deplibs" 868034977a2fSmrg finalize_deplibs="-l$name -L$dir $finalize_deplibs" 868134977a2fSmrg fi 8682fe24f8a2Smrg elif test yes = "$build_libtool_libs"; then 868334977a2fSmrg # Not a shared library 8684fe24f8a2Smrg if test pass_all != "$deplibs_check_method"; then 868534977a2fSmrg # We're trying link a shared library against a static one 868634977a2fSmrg # but the system doesn't support it. 868734977a2fSmrg 868834977a2fSmrg # Just print a warning and add the library to dependency_libs so 868934977a2fSmrg # that the program can be linked against the static library. 8690b425557eSmrg echo 8691fe24f8a2Smrg $ECHO "*** Warning: This system cannot link to static lib archive $lib." 8692b425557eSmrg echo "*** I have the capability to make that library automatically link in when" 8693b425557eSmrg echo "*** you link to this library. But I can only do this if you have a" 8694b425557eSmrg echo "*** shared version of the library, which you do not appear to have." 8695fe24f8a2Smrg if test yes = "$module"; then 8696b425557eSmrg echo "*** But as you try to build a module library, libtool will still create " 8697b425557eSmrg echo "*** a static module, that should work as long as the dlopening application" 8698b425557eSmrg echo "*** is linked with the -dlopen flag to resolve symbols at runtime." 869934977a2fSmrg if test -z "$global_symbol_pipe"; then 8700b425557eSmrg echo 8701b425557eSmrg echo "*** However, this would only work if libtool was able to extract symbol" 8702fe24f8a2Smrg echo "*** lists from a program, using 'nm' or equivalent, but libtool could" 8703b425557eSmrg echo "*** not find such a program. So, this module is probably useless." 8704fe24f8a2Smrg echo "*** 'nm' from GNU binutils and a full rebuild may help." 870534977a2fSmrg fi 8706fe24f8a2Smrg if test no = "$build_old_libs"; then 870734977a2fSmrg build_libtool_libs=module 870834977a2fSmrg build_old_libs=yes 870934977a2fSmrg else 871034977a2fSmrg build_libtool_libs=no 871134977a2fSmrg fi 871234977a2fSmrg fi 871334977a2fSmrg else 871434977a2fSmrg deplibs="$dir/$old_library $deplibs" 871534977a2fSmrg link_static=yes 871634977a2fSmrg fi 871734977a2fSmrg fi # link shared/static library? 871834977a2fSmrg 8719fe24f8a2Smrg if test lib = "$linkmode"; then 872034977a2fSmrg if test -n "$dependency_libs" && 8721fe24f8a2Smrg { test yes != "$hardcode_into_libs" || 8722fe24f8a2Smrg test yes = "$build_old_libs" || 8723fe24f8a2Smrg test yes = "$link_static"; }; then 872434977a2fSmrg # Extract -R from dependency_libs 872534977a2fSmrg temp_deplibs= 872634977a2fSmrg for libdir in $dependency_libs; do 872734977a2fSmrg case $libdir in 872834977a2fSmrg -R*) func_stripname '-R' '' "$libdir" 872934977a2fSmrg temp_xrpath=$func_stripname_result 873034977a2fSmrg case " $xrpath " in 873134977a2fSmrg *" $temp_xrpath "*) ;; 87323e72ca8cSmrg *) func_append xrpath " $temp_xrpath";; 873334977a2fSmrg esac;; 87343e72ca8cSmrg *) func_append temp_deplibs " $libdir";; 873534977a2fSmrg esac 873634977a2fSmrg done 8737fe24f8a2Smrg dependency_libs=$temp_deplibs 873834977a2fSmrg fi 873934977a2fSmrg 87403e72ca8cSmrg func_append newlib_search_path " $absdir" 874134977a2fSmrg # Link against this library 8742fe24f8a2Smrg test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs" 874334977a2fSmrg # ... and its dependency_libs 874434977a2fSmrg tmp_libs= 874534977a2fSmrg for deplib in $dependency_libs; do 874634977a2fSmrg newdependency_libs="$deplib $newdependency_libs" 87473e72ca8cSmrg case $deplib in 87483e72ca8cSmrg -L*) func_stripname '-L' '' "$deplib" 87493e72ca8cSmrg func_resolve_sysroot "$func_stripname_result";; 87503e72ca8cSmrg *) func_resolve_sysroot "$deplib" ;; 87513e72ca8cSmrg esac 8752fe24f8a2Smrg if $opt_preserve_dup_deps; then 875334977a2fSmrg case "$tmp_libs " in 87543e72ca8cSmrg *" $func_resolve_sysroot_result "*) 87553e72ca8cSmrg func_append specialdeplibs " $func_resolve_sysroot_result" ;; 875634977a2fSmrg esac 875734977a2fSmrg fi 87583e72ca8cSmrg func_append tmp_libs " $func_resolve_sysroot_result" 875934977a2fSmrg done 876034977a2fSmrg 8761fe24f8a2Smrg if test no != "$link_all_deplibs"; then 876234977a2fSmrg # Add the search paths of all dependency libraries 876334977a2fSmrg for deplib in $dependency_libs; do 8764b425557eSmrg path= 876534977a2fSmrg case $deplib in 8766fe24f8a2Smrg -L*) path=$deplib ;; 876734977a2fSmrg *.la) 87683e72ca8cSmrg func_resolve_sysroot "$deplib" 87693e72ca8cSmrg deplib=$func_resolve_sysroot_result 877034977a2fSmrg func_dirname "$deplib" "" "." 87713e72ca8cSmrg dir=$func_dirname_result 877234977a2fSmrg # We need an absolute path. 877334977a2fSmrg case $dir in 8774fe24f8a2Smrg [\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;; 877534977a2fSmrg *) 877634977a2fSmrg absdir=`cd "$dir" && pwd` 877734977a2fSmrg if test -z "$absdir"; then 8778fe24f8a2Smrg func_warning "cannot determine absolute directory name of '$dir'" 8779fe24f8a2Smrg absdir=$dir 878034977a2fSmrg fi 878134977a2fSmrg ;; 878234977a2fSmrg esac 878334977a2fSmrg if $GREP "^installed=no" $deplib > /dev/null; then 878434977a2fSmrg case $host in 878534977a2fSmrg *-*-darwin*) 878634977a2fSmrg depdepl= 8787fe24f8a2Smrg eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` 8788fe24f8a2Smrg if test -n "$deplibrary_names"; then 8789fe24f8a2Smrg for tmp in $deplibrary_names; do 879034977a2fSmrg depdepl=$tmp 879134977a2fSmrg done 8792fe24f8a2Smrg if test -f "$absdir/$objdir/$depdepl"; then 8793fe24f8a2Smrg depdepl=$absdir/$objdir/$depdepl 8794fe24f8a2Smrg darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 879534977a2fSmrg if test -z "$darwin_install_name"; then 8796fe24f8a2Smrg darwin_install_name=`$OTOOL64 -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 879734977a2fSmrg fi 8798fe24f8a2Smrg func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl" 8799fe24f8a2Smrg func_append linker_flags " -dylib_file $darwin_install_name:$depdepl" 880034977a2fSmrg path= 880134977a2fSmrg fi 880234977a2fSmrg fi 880334977a2fSmrg ;; 880434977a2fSmrg *) 8805fe24f8a2Smrg path=-L$absdir/$objdir 880634977a2fSmrg ;; 880734977a2fSmrg esac 880834977a2fSmrg else 8809fe24f8a2Smrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` 881034977a2fSmrg test -z "$libdir" && \ 8811fe24f8a2Smrg func_fatal_error "'$deplib' is not a valid libtool archive" 881234977a2fSmrg test "$absdir" != "$libdir" && \ 8813fe24f8a2Smrg func_warning "'$deplib' seems to be moved" 881434977a2fSmrg 8815fe24f8a2Smrg path=-L$absdir 881634977a2fSmrg fi 881734977a2fSmrg ;; 881834977a2fSmrg esac 881934977a2fSmrg case " $deplibs " in 882034977a2fSmrg *" $path "*) ;; 882134977a2fSmrg *) deplibs="$path $deplibs" ;; 882234977a2fSmrg esac 882334977a2fSmrg done 882434977a2fSmrg fi # link_all_deplibs != no 882534977a2fSmrg fi # linkmode = lib 882634977a2fSmrg done # for deplib in $libs 8827fe24f8a2Smrg if test link = "$pass"; then 8828fe24f8a2Smrg if test prog = "$linkmode"; then 882934977a2fSmrg compile_deplibs="$new_inherited_linker_flags $compile_deplibs" 883034977a2fSmrg finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" 883134977a2fSmrg else 8832b425557eSmrg compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 883334977a2fSmrg fi 883434977a2fSmrg fi 8835fe24f8a2Smrg dependency_libs=$newdependency_libs 8836fe24f8a2Smrg if test dlpreopen = "$pass"; then 883734977a2fSmrg # Link the dlpreopened libraries before other libraries 883834977a2fSmrg for deplib in $save_deplibs; do 883934977a2fSmrg deplibs="$deplib $deplibs" 884034977a2fSmrg done 884134977a2fSmrg fi 8842fe24f8a2Smrg if test dlopen != "$pass"; then 8843fe24f8a2Smrg test conv = "$pass" || { 884434977a2fSmrg # Make sure lib_search_path contains only unique directories. 884534977a2fSmrg lib_search_path= 884634977a2fSmrg for dir in $newlib_search_path; do 884734977a2fSmrg case "$lib_search_path " in 884834977a2fSmrg *" $dir "*) ;; 88493e72ca8cSmrg *) func_append lib_search_path " $dir" ;; 885034977a2fSmrg esac 885134977a2fSmrg done 885234977a2fSmrg newlib_search_path= 8853fe24f8a2Smrg } 885434977a2fSmrg 8855fe24f8a2Smrg if test prog,link = "$linkmode,$pass"; then 885634977a2fSmrg vars="compile_deplibs finalize_deplibs" 8857fe24f8a2Smrg else 8858fe24f8a2Smrg vars=deplibs 885934977a2fSmrg fi 886034977a2fSmrg for var in $vars dependency_libs; do 886134977a2fSmrg # Add libraries to $var in reverse order 886234977a2fSmrg eval tmp_libs=\"\$$var\" 886334977a2fSmrg new_libs= 886434977a2fSmrg for deplib in $tmp_libs; do 886534977a2fSmrg # FIXME: Pedantically, this is the right thing to do, so 886634977a2fSmrg # that some nasty dependency loop isn't accidentally 886734977a2fSmrg # broken: 886834977a2fSmrg #new_libs="$deplib $new_libs" 886934977a2fSmrg # Pragmatically, this seems to cause very few problems in 887034977a2fSmrg # practice: 887134977a2fSmrg case $deplib in 887234977a2fSmrg -L*) new_libs="$deplib $new_libs" ;; 887334977a2fSmrg -R*) ;; 887434977a2fSmrg *) 887534977a2fSmrg # And here is the reason: when a library appears more 887634977a2fSmrg # than once as an explicit dependence of a library, or 887734977a2fSmrg # is implicitly linked in more than once by the 887834977a2fSmrg # compiler, it is considered special, and multiple 887934977a2fSmrg # occurrences thereof are not removed. Compare this 888034977a2fSmrg # with having the same library being listed as a 888134977a2fSmrg # dependency of multiple other libraries: in this case, 888234977a2fSmrg # we know (pedantically, we assume) the library does not 888334977a2fSmrg # need to be listed more than once, so we keep only the 888434977a2fSmrg # last copy. This is not always right, but it is rare 888534977a2fSmrg # enough that we require users that really mean to play 888634977a2fSmrg # such unportable linking tricks to link the library 888734977a2fSmrg # using -Wl,-lname, so that libtool does not consider it 888834977a2fSmrg # for duplicate removal. 888934977a2fSmrg case " $specialdeplibs " in 889034977a2fSmrg *" $deplib "*) new_libs="$deplib $new_libs" ;; 889134977a2fSmrg *) 889234977a2fSmrg case " $new_libs " in 889334977a2fSmrg *" $deplib "*) ;; 889434977a2fSmrg *) new_libs="$deplib $new_libs" ;; 889534977a2fSmrg esac 889634977a2fSmrg ;; 889734977a2fSmrg esac 889834977a2fSmrg ;; 889934977a2fSmrg esac 890034977a2fSmrg done 890134977a2fSmrg tmp_libs= 890234977a2fSmrg for deplib in $new_libs; do 890334977a2fSmrg case $deplib in 890434977a2fSmrg -L*) 890534977a2fSmrg case " $tmp_libs " in 890634977a2fSmrg *" $deplib "*) ;; 89073e72ca8cSmrg *) func_append tmp_libs " $deplib" ;; 890834977a2fSmrg esac 890934977a2fSmrg ;; 89103e72ca8cSmrg *) func_append tmp_libs " $deplib" ;; 891134977a2fSmrg esac 891234977a2fSmrg done 891334977a2fSmrg eval $var=\"$tmp_libs\" 891434977a2fSmrg done # for var 891534977a2fSmrg fi 8916fe24f8a2Smrg 8917fe24f8a2Smrg # Add Sun CC postdeps if required: 8918fe24f8a2Smrg test CXX = "$tagname" && { 8919fe24f8a2Smrg case $host_os in 8920fe24f8a2Smrg linux*) 89218d623946Smrg case `$CC -V 2>&1 | $SED 5q` in 8922fe24f8a2Smrg *Sun\ C*) # Sun C++ 5.9 8923fe24f8a2Smrg func_suncc_cstd_abi 8924fe24f8a2Smrg 8925fe24f8a2Smrg if test no != "$suncc_use_cstd_abi"; then 8926fe24f8a2Smrg func_append postdeps ' -library=Cstd -library=Crun' 8927fe24f8a2Smrg fi 8928fe24f8a2Smrg ;; 8929fe24f8a2Smrg esac 8930fe24f8a2Smrg ;; 8931fe24f8a2Smrg 8932fe24f8a2Smrg solaris*) 8933fe24f8a2Smrg func_cc_basename "$CC" 8934fe24f8a2Smrg case $func_cc_basename_result in 8935fe24f8a2Smrg CC* | sunCC*) 8936fe24f8a2Smrg func_suncc_cstd_abi 8937fe24f8a2Smrg 8938fe24f8a2Smrg if test no != "$suncc_use_cstd_abi"; then 8939fe24f8a2Smrg func_append postdeps ' -library=Cstd -library=Crun' 8940fe24f8a2Smrg fi 8941fe24f8a2Smrg ;; 8942fe24f8a2Smrg esac 8943fe24f8a2Smrg ;; 8944fe24f8a2Smrg esac 8945fe24f8a2Smrg } 8946fe24f8a2Smrg 894734977a2fSmrg # Last step: remove runtime libs from dependency_libs 894834977a2fSmrg # (they stay in deplibs) 894934977a2fSmrg tmp_libs= 8950fe24f8a2Smrg for i in $dependency_libs; do 895134977a2fSmrg case " $predeps $postdeps $compiler_lib_search_path " in 895234977a2fSmrg *" $i "*) 8953fe24f8a2Smrg i= 895434977a2fSmrg ;; 895534977a2fSmrg esac 8956fe24f8a2Smrg if test -n "$i"; then 89573e72ca8cSmrg func_append tmp_libs " $i" 895834977a2fSmrg fi 895934977a2fSmrg done 896034977a2fSmrg dependency_libs=$tmp_libs 896134977a2fSmrg done # for pass 8962fe24f8a2Smrg if test prog = "$linkmode"; then 8963fe24f8a2Smrg dlfiles=$newdlfiles 896434977a2fSmrg fi 8965fe24f8a2Smrg if test prog = "$linkmode" || test lib = "$linkmode"; then 8966fe24f8a2Smrg dlprefiles=$newdlprefiles 896734977a2fSmrg fi 896834977a2fSmrg 896934977a2fSmrg case $linkmode in 897034977a2fSmrg oldlib) 8971fe24f8a2Smrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 8972fe24f8a2Smrg func_warning "'-dlopen' is ignored for archives" 897334977a2fSmrg fi 897434977a2fSmrg 897534977a2fSmrg case " $deplibs" in 897634977a2fSmrg *\ -l* | *\ -L*) 8977fe24f8a2Smrg func_warning "'-l' and '-L' are ignored for archives" ;; 897834977a2fSmrg esac 897934977a2fSmrg 898034977a2fSmrg test -n "$rpath" && \ 8981fe24f8a2Smrg func_warning "'-rpath' is ignored for archives" 898234977a2fSmrg 898334977a2fSmrg test -n "$xrpath" && \ 8984fe24f8a2Smrg func_warning "'-R' is ignored for archives" 898534977a2fSmrg 898634977a2fSmrg test -n "$vinfo" && \ 8987fe24f8a2Smrg func_warning "'-version-info/-version-number' is ignored for archives" 898834977a2fSmrg 898934977a2fSmrg test -n "$release" && \ 8990fe24f8a2Smrg func_warning "'-release' is ignored for archives" 899134977a2fSmrg 899234977a2fSmrg test -n "$export_symbols$export_symbols_regex" && \ 8993fe24f8a2Smrg func_warning "'-export-symbols' is ignored for archives" 899434977a2fSmrg 899534977a2fSmrg # Now set the variables for building old libraries. 899634977a2fSmrg build_libtool_libs=no 8997fe24f8a2Smrg oldlibs=$output 89983e72ca8cSmrg func_append objs "$old_deplibs" 899934977a2fSmrg ;; 900034977a2fSmrg 900134977a2fSmrg lib) 9002fe24f8a2Smrg # Make sure we only generate libraries of the form 'libNAME.la'. 900334977a2fSmrg case $outputname in 900434977a2fSmrg lib*) 900534977a2fSmrg func_stripname 'lib' '.la' "$outputname" 900634977a2fSmrg name=$func_stripname_result 900734977a2fSmrg eval shared_ext=\"$shrext_cmds\" 900834977a2fSmrg eval libname=\"$libname_spec\" 900934977a2fSmrg ;; 901034977a2fSmrg *) 9011fe24f8a2Smrg test no = "$module" \ 9012fe24f8a2Smrg && func_fatal_help "libtool library '$output' must begin with 'lib'" 901334977a2fSmrg 9014fe24f8a2Smrg if test no != "$need_lib_prefix"; then 901534977a2fSmrg # Add the "lib" prefix for modules if required 901634977a2fSmrg func_stripname '' '.la' "$outputname" 901734977a2fSmrg name=$func_stripname_result 901834977a2fSmrg eval shared_ext=\"$shrext_cmds\" 901934977a2fSmrg eval libname=\"$libname_spec\" 902034977a2fSmrg else 902134977a2fSmrg func_stripname '' '.la' "$outputname" 902234977a2fSmrg libname=$func_stripname_result 902334977a2fSmrg fi 902434977a2fSmrg ;; 902534977a2fSmrg esac 902634977a2fSmrg 902734977a2fSmrg if test -n "$objs"; then 9028fe24f8a2Smrg if test pass_all != "$deplibs_check_method"; then 9029fe24f8a2Smrg func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs" 903034977a2fSmrg else 9031b425557eSmrg echo 903234977a2fSmrg $ECHO "*** Warning: Linking the shared library $output against the non-libtool" 903334977a2fSmrg $ECHO "*** objects $objs is not portable!" 90343e72ca8cSmrg func_append libobjs " $objs" 903534977a2fSmrg fi 903634977a2fSmrg fi 903734977a2fSmrg 9038fe24f8a2Smrg test no = "$dlself" \ 9039fe24f8a2Smrg || func_warning "'-dlopen self' is ignored for libtool libraries" 904034977a2fSmrg 904134977a2fSmrg set dummy $rpath 904234977a2fSmrg shift 9043fe24f8a2Smrg test 1 -lt "$#" \ 9044fe24f8a2Smrg && func_warning "ignoring multiple '-rpath's for a libtool library" 904534977a2fSmrg 9046fe24f8a2Smrg install_libdir=$1 904734977a2fSmrg 904834977a2fSmrg oldlibs= 904934977a2fSmrg if test -z "$rpath"; then 9050fe24f8a2Smrg if test yes = "$build_libtool_libs"; then 905134977a2fSmrg # Building a libtool convenience library. 9052fe24f8a2Smrg # Some compilers have problems with a '.al' extension so 905334977a2fSmrg # convenience libraries should have the same extension an 905434977a2fSmrg # archive normally would. 905534977a2fSmrg oldlibs="$output_objdir/$libname.$libext $oldlibs" 905634977a2fSmrg build_libtool_libs=convenience 905734977a2fSmrg build_old_libs=yes 905834977a2fSmrg fi 905934977a2fSmrg 906034977a2fSmrg test -n "$vinfo" && \ 9061fe24f8a2Smrg func_warning "'-version-info/-version-number' is ignored for convenience libraries" 906234977a2fSmrg 906334977a2fSmrg test -n "$release" && \ 9064fe24f8a2Smrg func_warning "'-release' is ignored for convenience libraries" 906534977a2fSmrg else 906634977a2fSmrg 906734977a2fSmrg # Parse the version information argument. 9068fe24f8a2Smrg save_ifs=$IFS; IFS=: 906934977a2fSmrg set dummy $vinfo 0 0 0 907034977a2fSmrg shift 9071fe24f8a2Smrg IFS=$save_ifs 907234977a2fSmrg 907334977a2fSmrg test -n "$7" && \ 9074fe24f8a2Smrg func_fatal_help "too many parameters to '-version-info'" 907534977a2fSmrg 907634977a2fSmrg # convert absolute version numbers to libtool ages 907734977a2fSmrg # this retains compatibility with .la files and attempts 907834977a2fSmrg # to make the code below a bit more comprehensible 907934977a2fSmrg 908034977a2fSmrg case $vinfo_number in 908134977a2fSmrg yes) 9082fe24f8a2Smrg number_major=$1 9083fe24f8a2Smrg number_minor=$2 9084fe24f8a2Smrg number_revision=$3 908534977a2fSmrg # 908634977a2fSmrg # There are really only two kinds -- those that 908734977a2fSmrg # use the current revision as the major version 908834977a2fSmrg # and those that subtract age and use age as 908934977a2fSmrg # a minor version. But, then there is irix 9090fe24f8a2Smrg # that has an extra 1 added just for fun 909134977a2fSmrg # 909234977a2fSmrg case $version_type in 90933e72ca8cSmrg # correct linux to gnu/linux during the next big refactor 90948d623946Smrg darwin|freebsd-elf|linux|midnightbsd-elf|osf|windows|none) 909534977a2fSmrg func_arith $number_major + $number_minor 909634977a2fSmrg current=$func_arith_result 9097fe24f8a2Smrg age=$number_minor 9098fe24f8a2Smrg revision=$number_revision 909934977a2fSmrg ;; 9100fe24f8a2Smrg freebsd-aout|qnx|sunos) 9101fe24f8a2Smrg current=$number_major 9102fe24f8a2Smrg revision=$number_minor 9103fe24f8a2Smrg age=0 910434977a2fSmrg ;; 910534977a2fSmrg irix|nonstopux) 910634977a2fSmrg func_arith $number_major + $number_minor 910734977a2fSmrg current=$func_arith_result 9108fe24f8a2Smrg age=$number_minor 9109fe24f8a2Smrg revision=$number_minor 911034977a2fSmrg lt_irix_increment=no 911134977a2fSmrg ;; 911234977a2fSmrg esac 911334977a2fSmrg ;; 911434977a2fSmrg no) 9115fe24f8a2Smrg current=$1 9116fe24f8a2Smrg revision=$2 9117fe24f8a2Smrg age=$3 911834977a2fSmrg ;; 911934977a2fSmrg esac 912034977a2fSmrg 912134977a2fSmrg # Check that each of the things are valid numbers. 912234977a2fSmrg case $current in 912334977a2fSmrg 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]) ;; 912434977a2fSmrg *) 9125fe24f8a2Smrg func_error "CURRENT '$current' must be a nonnegative integer" 9126fe24f8a2Smrg func_fatal_error "'$vinfo' is not valid version information" 912734977a2fSmrg ;; 912834977a2fSmrg esac 912934977a2fSmrg 913034977a2fSmrg case $revision in 913134977a2fSmrg 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]) ;; 913234977a2fSmrg *) 9133fe24f8a2Smrg func_error "REVISION '$revision' must be a nonnegative integer" 9134fe24f8a2Smrg func_fatal_error "'$vinfo' is not valid version information" 913534977a2fSmrg ;; 913634977a2fSmrg esac 913734977a2fSmrg 913834977a2fSmrg case $age in 913934977a2fSmrg 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]) ;; 914034977a2fSmrg *) 9141fe24f8a2Smrg func_error "AGE '$age' must be a nonnegative integer" 9142fe24f8a2Smrg func_fatal_error "'$vinfo' is not valid version information" 914334977a2fSmrg ;; 914434977a2fSmrg esac 914534977a2fSmrg 914634977a2fSmrg if test "$age" -gt "$current"; then 9147fe24f8a2Smrg func_error "AGE '$age' is greater than the current interface number '$current'" 9148fe24f8a2Smrg func_fatal_error "'$vinfo' is not valid version information" 914934977a2fSmrg fi 915034977a2fSmrg 915134977a2fSmrg # Calculate the version variables. 915234977a2fSmrg major= 915334977a2fSmrg versuffix= 915434977a2fSmrg verstring= 915534977a2fSmrg case $version_type in 915634977a2fSmrg none) ;; 915734977a2fSmrg 915834977a2fSmrg darwin) 915934977a2fSmrg # Like Linux, but with the current version available in 916034977a2fSmrg # verstring for coding it into the library header 916134977a2fSmrg func_arith $current - $age 916234977a2fSmrg major=.$func_arith_result 9163fe24f8a2Smrg versuffix=$major.$age.$revision 916434977a2fSmrg # Darwin ld doesn't like 0 for these options... 916534977a2fSmrg func_arith $current + 1 916634977a2fSmrg minor_current=$func_arith_result 9167fe24f8a2Smrg xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" 916834977a2fSmrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 9169fe24f8a2Smrg # On Darwin other compilers 9170fe24f8a2Smrg case $CC in 9171fe24f8a2Smrg nagfor*) 9172fe24f8a2Smrg verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" 9173fe24f8a2Smrg ;; 9174fe24f8a2Smrg *) 9175fe24f8a2Smrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 9176fe24f8a2Smrg ;; 9177fe24f8a2Smrg esac 917834977a2fSmrg ;; 917934977a2fSmrg 918034977a2fSmrg freebsd-aout) 9181fe24f8a2Smrg major=.$current 9182fe24f8a2Smrg versuffix=.$current.$revision 918334977a2fSmrg ;; 918434977a2fSmrg 91858d623946Smrg freebsd-elf | midnightbsd-elf) 9186fe24f8a2Smrg func_arith $current - $age 9187fe24f8a2Smrg major=.$func_arith_result 9188fe24f8a2Smrg versuffix=$major.$age.$revision 918934977a2fSmrg ;; 919034977a2fSmrg 919134977a2fSmrg irix | nonstopux) 9192fe24f8a2Smrg if test no = "$lt_irix_increment"; then 919334977a2fSmrg func_arith $current - $age 919434977a2fSmrg else 919534977a2fSmrg func_arith $current - $age + 1 919634977a2fSmrg fi 919734977a2fSmrg major=$func_arith_result 919834977a2fSmrg 919934977a2fSmrg case $version_type in 920034977a2fSmrg nonstopux) verstring_prefix=nonstopux ;; 920134977a2fSmrg *) verstring_prefix=sgi ;; 920234977a2fSmrg esac 9203fe24f8a2Smrg verstring=$verstring_prefix$major.$revision 920434977a2fSmrg 920534977a2fSmrg # Add in all the interfaces that we are compatible with. 920634977a2fSmrg loop=$revision 9207fe24f8a2Smrg while test 0 -ne "$loop"; do 920834977a2fSmrg func_arith $revision - $loop 920934977a2fSmrg iface=$func_arith_result 921034977a2fSmrg func_arith $loop - 1 921134977a2fSmrg loop=$func_arith_result 9212fe24f8a2Smrg verstring=$verstring_prefix$major.$iface:$verstring 921334977a2fSmrg done 921434977a2fSmrg 9215fe24f8a2Smrg # Before this point, $major must not contain '.'. 921634977a2fSmrg major=.$major 9217fe24f8a2Smrg versuffix=$major.$revision 921834977a2fSmrg ;; 921934977a2fSmrg 92203e72ca8cSmrg linux) # correct to gnu/linux during the next big refactor 922134977a2fSmrg func_arith $current - $age 922234977a2fSmrg major=.$func_arith_result 9223fe24f8a2Smrg versuffix=$major.$age.$revision 922434977a2fSmrg ;; 922534977a2fSmrg 922634977a2fSmrg osf) 922734977a2fSmrg func_arith $current - $age 922834977a2fSmrg major=.$func_arith_result 9229fe24f8a2Smrg versuffix=.$current.$age.$revision 9230fe24f8a2Smrg verstring=$current.$age.$revision 923134977a2fSmrg 923234977a2fSmrg # Add in all the interfaces that we are compatible with. 923334977a2fSmrg loop=$age 9234fe24f8a2Smrg while test 0 -ne "$loop"; do 923534977a2fSmrg func_arith $current - $loop 923634977a2fSmrg iface=$func_arith_result 923734977a2fSmrg func_arith $loop - 1 923834977a2fSmrg loop=$func_arith_result 9239fe24f8a2Smrg verstring=$verstring:$iface.0 924034977a2fSmrg done 924134977a2fSmrg 924234977a2fSmrg # Make executables depend on our current version. 9243fe24f8a2Smrg func_append verstring ":$current.0" 924434977a2fSmrg ;; 924534977a2fSmrg 924634977a2fSmrg qnx) 9247fe24f8a2Smrg major=.$current 9248fe24f8a2Smrg versuffix=.$current 9249fe24f8a2Smrg ;; 9250fe24f8a2Smrg 9251fe24f8a2Smrg sco) 9252fe24f8a2Smrg major=.$current 9253fe24f8a2Smrg versuffix=.$current 925434977a2fSmrg ;; 925534977a2fSmrg 925634977a2fSmrg sunos) 9257fe24f8a2Smrg major=.$current 9258fe24f8a2Smrg versuffix=.$current.$revision 925934977a2fSmrg ;; 926034977a2fSmrg 926134977a2fSmrg windows) 926234977a2fSmrg # Use '-' rather than '.', since we only want one 9263fe24f8a2Smrg # extension on DOS 8.3 file systems. 926434977a2fSmrg func_arith $current - $age 926534977a2fSmrg major=$func_arith_result 9266fe24f8a2Smrg versuffix=-$major 926734977a2fSmrg ;; 926834977a2fSmrg 926934977a2fSmrg *) 9270fe24f8a2Smrg func_fatal_configuration "unknown library version type '$version_type'" 927134977a2fSmrg ;; 927234977a2fSmrg esac 927334977a2fSmrg 927434977a2fSmrg # Clear the version info if we defaulted, and they specified a release. 927534977a2fSmrg if test -z "$vinfo" && test -n "$release"; then 927634977a2fSmrg major= 927734977a2fSmrg case $version_type in 927834977a2fSmrg darwin) 927934977a2fSmrg # we can't check for "0.0" in archive_cmds due to quoting 928034977a2fSmrg # problems, so we reset it completely 928134977a2fSmrg verstring= 928234977a2fSmrg ;; 928334977a2fSmrg *) 9284fe24f8a2Smrg verstring=0.0 928534977a2fSmrg ;; 928634977a2fSmrg esac 9287fe24f8a2Smrg if test no = "$need_version"; then 928834977a2fSmrg versuffix= 928934977a2fSmrg else 9290fe24f8a2Smrg versuffix=.0.0 929134977a2fSmrg fi 929234977a2fSmrg fi 929334977a2fSmrg 929434977a2fSmrg # Remove version info from name if versioning should be avoided 9295fe24f8a2Smrg if test yes,no = "$avoid_version,$need_version"; then 929634977a2fSmrg major= 929734977a2fSmrg versuffix= 9298fe24f8a2Smrg verstring= 929934977a2fSmrg fi 930034977a2fSmrg 930134977a2fSmrg # Check to see if the archive will have undefined symbols. 9302fe24f8a2Smrg if test yes = "$allow_undefined"; then 9303fe24f8a2Smrg if test unsupported = "$allow_undefined_flag"; then 9304fe24f8a2Smrg if test yes = "$build_old_libs"; then 9305fe24f8a2Smrg func_warning "undefined symbols not allowed in $host shared libraries; building static only" 9306fe24f8a2Smrg build_libtool_libs=no 9307fe24f8a2Smrg else 9308fe24f8a2Smrg func_fatal_error "can't build $host shared library unless -no-undefined is specified" 9309fe24f8a2Smrg fi 931034977a2fSmrg fi 931134977a2fSmrg else 931234977a2fSmrg # Don't allow undefined symbols. 9313fe24f8a2Smrg allow_undefined_flag=$no_undefined_flag 931434977a2fSmrg fi 931534977a2fSmrg 931634977a2fSmrg fi 931734977a2fSmrg 9318fe24f8a2Smrg func_generate_dlsyms "$libname" "$libname" : 93193e72ca8cSmrg func_append libobjs " $symfileobj" 9320fe24f8a2Smrg test " " = "$libobjs" && libobjs= 932134977a2fSmrg 9322fe24f8a2Smrg if test relink != "$opt_mode"; then 932334977a2fSmrg # Remove our outputs, but don't remove object files since they 932434977a2fSmrg # may have been created when compiling PIC objects. 932534977a2fSmrg removelist= 932634977a2fSmrg tempremovelist=`$ECHO "$output_objdir/*"` 932734977a2fSmrg for p in $tempremovelist; do 932834977a2fSmrg case $p in 932934977a2fSmrg *.$objext | *.gcno) 933034977a2fSmrg ;; 9331fe24f8a2Smrg $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/$libname$release.*) 9332fe24f8a2Smrg if test -n "$precious_files_regex"; then 933334977a2fSmrg if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 933434977a2fSmrg then 933534977a2fSmrg continue 933634977a2fSmrg fi 933734977a2fSmrg fi 93383e72ca8cSmrg func_append removelist " $p" 933934977a2fSmrg ;; 934034977a2fSmrg *) ;; 934134977a2fSmrg esac 934234977a2fSmrg done 934334977a2fSmrg test -n "$removelist" && \ 934434977a2fSmrg func_show_eval "${RM}r \$removelist" 934534977a2fSmrg fi 934634977a2fSmrg 934734977a2fSmrg # Now set the variables for building old libraries. 9348fe24f8a2Smrg if test yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; then 93493e72ca8cSmrg func_append oldlibs " $output_objdir/$libname.$libext" 935034977a2fSmrg 935134977a2fSmrg # Transform .lo files to .o files. 9352fe24f8a2Smrg oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; $lo2o" | $NL2SP` 935334977a2fSmrg fi 935434977a2fSmrg 935534977a2fSmrg # Eliminate all temporary directories. 935634977a2fSmrg #for path in $notinst_path; do 9357b425557eSmrg # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` 9358b425557eSmrg # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` 9359b425557eSmrg # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` 936034977a2fSmrg #done 936134977a2fSmrg 936234977a2fSmrg if test -n "$xrpath"; then 936334977a2fSmrg # If the user specified any rpath flags, then add them. 936434977a2fSmrg temp_xrpath= 936534977a2fSmrg for libdir in $xrpath; do 93663e72ca8cSmrg func_replace_sysroot "$libdir" 93673e72ca8cSmrg func_append temp_xrpath " -R$func_replace_sysroot_result" 936834977a2fSmrg case "$finalize_rpath " in 936934977a2fSmrg *" $libdir "*) ;; 93703e72ca8cSmrg *) func_append finalize_rpath " $libdir" ;; 937134977a2fSmrg esac 937234977a2fSmrg done 9373fe24f8a2Smrg if test yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; then 937434977a2fSmrg dependency_libs="$temp_xrpath $dependency_libs" 937534977a2fSmrg fi 937634977a2fSmrg fi 937734977a2fSmrg 937834977a2fSmrg # Make sure dlfiles contains only unique files that won't be dlpreopened 9379fe24f8a2Smrg old_dlfiles=$dlfiles 938034977a2fSmrg dlfiles= 938134977a2fSmrg for lib in $old_dlfiles; do 938234977a2fSmrg case " $dlprefiles $dlfiles " in 938334977a2fSmrg *" $lib "*) ;; 93843e72ca8cSmrg *) func_append dlfiles " $lib" ;; 938534977a2fSmrg esac 938634977a2fSmrg done 938734977a2fSmrg 938834977a2fSmrg # Make sure dlprefiles contains only unique files 9389fe24f8a2Smrg old_dlprefiles=$dlprefiles 939034977a2fSmrg dlprefiles= 939134977a2fSmrg for lib in $old_dlprefiles; do 939234977a2fSmrg case "$dlprefiles " in 939334977a2fSmrg *" $lib "*) ;; 93943e72ca8cSmrg *) func_append dlprefiles " $lib" ;; 939534977a2fSmrg esac 939634977a2fSmrg done 939734977a2fSmrg 9398fe24f8a2Smrg if test yes = "$build_libtool_libs"; then 939934977a2fSmrg if test -n "$rpath"; then 940034977a2fSmrg case $host in 9401b425557eSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) 940234977a2fSmrg # these systems don't actually have a c library (as such)! 940334977a2fSmrg ;; 940434977a2fSmrg *-*-rhapsody* | *-*-darwin1.[012]) 940534977a2fSmrg # Rhapsody C library is in the System framework 94063e72ca8cSmrg func_append deplibs " System.ltframework" 940734977a2fSmrg ;; 940834977a2fSmrg *-*-netbsd*) 940934977a2fSmrg # Don't link with libc until the a.out ld.so is fixed. 941034977a2fSmrg ;; 94118d623946Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-midnightbsd*) 941234977a2fSmrg # Do not include libc due to us having libc/libc_r. 941334977a2fSmrg ;; 941434977a2fSmrg *-*-sco3.2v5* | *-*-sco5v6*) 941534977a2fSmrg # Causes problems with __ctype 941634977a2fSmrg ;; 941734977a2fSmrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 941834977a2fSmrg # Compiler inserts libc in the correct place for threads to work 941934977a2fSmrg ;; 942034977a2fSmrg *) 942134977a2fSmrg # Add libc to deplibs on all other systems if necessary. 9422fe24f8a2Smrg if test yes = "$build_libtool_need_lc"; then 94233e72ca8cSmrg func_append deplibs " -lc" 942434977a2fSmrg fi 942534977a2fSmrg ;; 942634977a2fSmrg esac 942734977a2fSmrg fi 942834977a2fSmrg 942934977a2fSmrg # Transform deplibs into only deplibs that can be linked in shared. 943034977a2fSmrg name_save=$name 943134977a2fSmrg libname_save=$libname 943234977a2fSmrg release_save=$release 943334977a2fSmrg versuffix_save=$versuffix 943434977a2fSmrg major_save=$major 943534977a2fSmrg # I'm not sure if I'm treating the release correctly. I think 943634977a2fSmrg # release should show up in the -l (ie -lgmp5) so we don't want to 943734977a2fSmrg # add it in twice. Is that correct? 9438fe24f8a2Smrg release= 9439fe24f8a2Smrg versuffix= 9440fe24f8a2Smrg major= 944134977a2fSmrg newdeplibs= 944234977a2fSmrg droppeddeps=no 944334977a2fSmrg case $deplibs_check_method in 944434977a2fSmrg pass_all) 944534977a2fSmrg # Don't check for shared/static. Everything works. 944634977a2fSmrg # This might be a little naive. We might want to check 944734977a2fSmrg # whether the library exists or not. But this is on 944834977a2fSmrg # osf3 & osf4 and I'm not really sure... Just 944934977a2fSmrg # implementing what was already the behavior. 945034977a2fSmrg newdeplibs=$deplibs 945134977a2fSmrg ;; 945234977a2fSmrg test_compile) 945334977a2fSmrg # This code stresses the "libraries are programs" paradigm to its 945434977a2fSmrg # limits. Maybe even breaks it. We compile a program, linking it 945534977a2fSmrg # against the deplibs as a proxy for the library. Then we can check 945634977a2fSmrg # whether they linked in statically or dynamically with ldd. 945734977a2fSmrg $opt_dry_run || $RM conftest.c 945834977a2fSmrg cat > conftest.c <<EOF 945934977a2fSmrg int main() { return 0; } 946034977a2fSmrgEOF 946134977a2fSmrg $opt_dry_run || $RM conftest 946234977a2fSmrg if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then 946334977a2fSmrg ldd_output=`ldd conftest` 946434977a2fSmrg for i in $deplibs; do 946534977a2fSmrg case $i in 946634977a2fSmrg -l*) 946734977a2fSmrg func_stripname -l '' "$i" 946834977a2fSmrg name=$func_stripname_result 9469fe24f8a2Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 947034977a2fSmrg case " $predeps $postdeps " in 947134977a2fSmrg *" $i "*) 94723e72ca8cSmrg func_append newdeplibs " $i" 9473fe24f8a2Smrg i= 947434977a2fSmrg ;; 947534977a2fSmrg esac 947634977a2fSmrg fi 9477fe24f8a2Smrg if test -n "$i"; then 947834977a2fSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 947934977a2fSmrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 948034977a2fSmrg set dummy $deplib_matches; shift 948134977a2fSmrg deplib_match=$1 9482fe24f8a2Smrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then 94833e72ca8cSmrg func_append newdeplibs " $i" 948434977a2fSmrg else 948534977a2fSmrg droppeddeps=yes 9486b425557eSmrg echo 948734977a2fSmrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 9488b425557eSmrg echo "*** I have the capability to make that library automatically link in when" 9489b425557eSmrg echo "*** you link to this library. But I can only do this if you have a" 9490b425557eSmrg echo "*** shared version of the library, which I believe you do not have" 9491b425557eSmrg echo "*** because a test_compile did reveal that the linker did not use it for" 9492b425557eSmrg echo "*** its dynamic dependency list that programs get resolved with at runtime." 949334977a2fSmrg fi 949434977a2fSmrg fi 949534977a2fSmrg ;; 949634977a2fSmrg *) 94973e72ca8cSmrg func_append newdeplibs " $i" 949834977a2fSmrg ;; 949934977a2fSmrg esac 950034977a2fSmrg done 950134977a2fSmrg else 950234977a2fSmrg # Error occurred in the first compile. Let's try to salvage 950334977a2fSmrg # the situation: Compile a separate program for each library. 950434977a2fSmrg for i in $deplibs; do 950534977a2fSmrg case $i in 950634977a2fSmrg -l*) 950734977a2fSmrg func_stripname -l '' "$i" 950834977a2fSmrg name=$func_stripname_result 950934977a2fSmrg $opt_dry_run || $RM conftest 951034977a2fSmrg if $LTCC $LTCFLAGS -o conftest conftest.c $i; then 951134977a2fSmrg ldd_output=`ldd conftest` 9512fe24f8a2Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 951334977a2fSmrg case " $predeps $postdeps " in 951434977a2fSmrg *" $i "*) 95153e72ca8cSmrg func_append newdeplibs " $i" 9516fe24f8a2Smrg i= 951734977a2fSmrg ;; 951834977a2fSmrg esac 951934977a2fSmrg fi 9520fe24f8a2Smrg if test -n "$i"; then 952134977a2fSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 952234977a2fSmrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 952334977a2fSmrg set dummy $deplib_matches; shift 952434977a2fSmrg deplib_match=$1 9525fe24f8a2Smrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then 95263e72ca8cSmrg func_append newdeplibs " $i" 952734977a2fSmrg else 952834977a2fSmrg droppeddeps=yes 9529b425557eSmrg echo 953034977a2fSmrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 9531b425557eSmrg echo "*** I have the capability to make that library automatically link in when" 9532b425557eSmrg echo "*** you link to this library. But I can only do this if you have a" 9533b425557eSmrg echo "*** shared version of the library, which you do not appear to have" 9534b425557eSmrg echo "*** because a test_compile did reveal that the linker did not use this one" 9535b425557eSmrg echo "*** as a dynamic dependency that programs can get resolved with at runtime." 953634977a2fSmrg fi 953734977a2fSmrg fi 953834977a2fSmrg else 953934977a2fSmrg droppeddeps=yes 9540b425557eSmrg echo 954134977a2fSmrg $ECHO "*** Warning! Library $i is needed by this library but I was not able to" 9542b425557eSmrg echo "*** make it link in! You will probably need to install it or some" 9543b425557eSmrg echo "*** library that it depends on before this library will be fully" 9544b425557eSmrg echo "*** functional. Installing it before continuing would be even better." 954534977a2fSmrg fi 954634977a2fSmrg ;; 954734977a2fSmrg *) 95483e72ca8cSmrg func_append newdeplibs " $i" 954934977a2fSmrg ;; 955034977a2fSmrg esac 955134977a2fSmrg done 955234977a2fSmrg fi 955334977a2fSmrg ;; 955434977a2fSmrg file_magic*) 955534977a2fSmrg set dummy $deplibs_check_method; shift 955634977a2fSmrg file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 955734977a2fSmrg for a_deplib in $deplibs; do 955834977a2fSmrg case $a_deplib in 955934977a2fSmrg -l*) 956034977a2fSmrg func_stripname -l '' "$a_deplib" 956134977a2fSmrg name=$func_stripname_result 9562fe24f8a2Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 956334977a2fSmrg case " $predeps $postdeps " in 956434977a2fSmrg *" $a_deplib "*) 95653e72ca8cSmrg func_append newdeplibs " $a_deplib" 9566fe24f8a2Smrg a_deplib= 956734977a2fSmrg ;; 956834977a2fSmrg esac 956934977a2fSmrg fi 9570fe24f8a2Smrg if test -n "$a_deplib"; then 957134977a2fSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 95723e72ca8cSmrg if test -n "$file_magic_glob"; then 95733e72ca8cSmrg libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob` 95743e72ca8cSmrg else 95753e72ca8cSmrg libnameglob=$libname 95763e72ca8cSmrg fi 9577fe24f8a2Smrg test yes = "$want_nocaseglob" && nocaseglob=`shopt -p nocaseglob` 957834977a2fSmrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 9579fe24f8a2Smrg if test yes = "$want_nocaseglob"; then 95803e72ca8cSmrg shopt -s nocaseglob 95813e72ca8cSmrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 95823e72ca8cSmrg $nocaseglob 95833e72ca8cSmrg else 95843e72ca8cSmrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 95853e72ca8cSmrg fi 958634977a2fSmrg for potent_lib in $potential_libs; do 958734977a2fSmrg # Follow soft links. 958834977a2fSmrg if ls -lLd "$potent_lib" 2>/dev/null | 958934977a2fSmrg $GREP " -> " >/dev/null; then 959034977a2fSmrg continue 959134977a2fSmrg fi 959234977a2fSmrg # The statement above tries to avoid entering an 959334977a2fSmrg # endless loop below, in case of cyclic links. 959434977a2fSmrg # We might still enter an endless loop, since a link 959534977a2fSmrg # loop can be closed while we follow links, 959634977a2fSmrg # but so what? 9597fe24f8a2Smrg potlib=$potent_lib 959834977a2fSmrg while test -h "$potlib" 2>/dev/null; do 9599fe24f8a2Smrg potliblink=`ls -ld $potlib | $SED 's/.* -> //'` 960034977a2fSmrg case $potliblink in 9601fe24f8a2Smrg [\\/]* | [A-Za-z]:[\\/]*) potlib=$potliblink;; 9602fe24f8a2Smrg *) potlib=`$ECHO "$potlib" | $SED 's|[^/]*$||'`"$potliblink";; 960334977a2fSmrg esac 960434977a2fSmrg done 960534977a2fSmrg if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | 960634977a2fSmrg $SED -e 10q | 960734977a2fSmrg $EGREP "$file_magic_regex" > /dev/null; then 96083e72ca8cSmrg func_append newdeplibs " $a_deplib" 9609fe24f8a2Smrg a_deplib= 961034977a2fSmrg break 2 961134977a2fSmrg fi 961234977a2fSmrg done 961334977a2fSmrg done 961434977a2fSmrg fi 9615fe24f8a2Smrg if test -n "$a_deplib"; then 961634977a2fSmrg droppeddeps=yes 9617b425557eSmrg echo 961834977a2fSmrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 9619b425557eSmrg echo "*** I have the capability to make that library automatically link in when" 9620b425557eSmrg echo "*** you link to this library. But I can only do this if you have a" 9621b425557eSmrg echo "*** shared version of the library, which you do not appear to have" 9622b425557eSmrg echo "*** because I did check the linker path looking for a file starting" 9623fe24f8a2Smrg if test -z "$potlib"; then 962434977a2fSmrg $ECHO "*** with $libname but no candidates were found. (...for file magic test)" 962534977a2fSmrg else 962634977a2fSmrg $ECHO "*** with $libname and none of the candidates passed a file format test" 962734977a2fSmrg $ECHO "*** using a file magic. Last file checked: $potlib" 962834977a2fSmrg fi 962934977a2fSmrg fi 963034977a2fSmrg ;; 963134977a2fSmrg *) 963234977a2fSmrg # Add a -L argument. 96333e72ca8cSmrg func_append newdeplibs " $a_deplib" 963434977a2fSmrg ;; 963534977a2fSmrg esac 963634977a2fSmrg done # Gone through all deplibs. 963734977a2fSmrg ;; 963834977a2fSmrg match_pattern*) 963934977a2fSmrg set dummy $deplibs_check_method; shift 964034977a2fSmrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 964134977a2fSmrg for a_deplib in $deplibs; do 964234977a2fSmrg case $a_deplib in 964334977a2fSmrg -l*) 964434977a2fSmrg func_stripname -l '' "$a_deplib" 964534977a2fSmrg name=$func_stripname_result 9646fe24f8a2Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 964734977a2fSmrg case " $predeps $postdeps " in 964834977a2fSmrg *" $a_deplib "*) 96493e72ca8cSmrg func_append newdeplibs " $a_deplib" 9650fe24f8a2Smrg a_deplib= 965134977a2fSmrg ;; 965234977a2fSmrg esac 965334977a2fSmrg fi 9654fe24f8a2Smrg if test -n "$a_deplib"; then 965534977a2fSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 965634977a2fSmrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 965734977a2fSmrg potential_libs=`ls $i/$libname[.-]* 2>/dev/null` 965834977a2fSmrg for potent_lib in $potential_libs; do 9659fe24f8a2Smrg potlib=$potent_lib # see symlink-check above in file_magic test 9660b425557eSmrg if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ 966134977a2fSmrg $EGREP "$match_pattern_regex" > /dev/null; then 96623e72ca8cSmrg func_append newdeplibs " $a_deplib" 9663fe24f8a2Smrg a_deplib= 966434977a2fSmrg break 2 966534977a2fSmrg fi 966634977a2fSmrg done 966734977a2fSmrg done 966834977a2fSmrg fi 9669fe24f8a2Smrg if test -n "$a_deplib"; then 967034977a2fSmrg droppeddeps=yes 9671b425557eSmrg echo 967234977a2fSmrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 9673b425557eSmrg echo "*** I have the capability to make that library automatically link in when" 9674b425557eSmrg echo "*** you link to this library. But I can only do this if you have a" 9675b425557eSmrg echo "*** shared version of the library, which you do not appear to have" 9676b425557eSmrg echo "*** because I did check the linker path looking for a file starting" 9677fe24f8a2Smrg if test -z "$potlib"; then 967834977a2fSmrg $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" 967934977a2fSmrg else 968034977a2fSmrg $ECHO "*** with $libname and none of the candidates passed a file format test" 968134977a2fSmrg $ECHO "*** using a regex pattern. Last file checked: $potlib" 968234977a2fSmrg fi 968334977a2fSmrg fi 968434977a2fSmrg ;; 968534977a2fSmrg *) 968634977a2fSmrg # Add a -L argument. 96873e72ca8cSmrg func_append newdeplibs " $a_deplib" 968834977a2fSmrg ;; 968934977a2fSmrg esac 969034977a2fSmrg done # Gone through all deplibs. 969134977a2fSmrg ;; 969234977a2fSmrg none | unknown | *) 9693fe24f8a2Smrg newdeplibs= 9694b425557eSmrg tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` 9695fe24f8a2Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9696fe24f8a2Smrg for i in $predeps $postdeps; do 969734977a2fSmrg # can't use Xsed below, because $i might contain '/' 9698fe24f8a2Smrg tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s|$i||"` 969934977a2fSmrg done 970034977a2fSmrg fi 9701b425557eSmrg case $tmp_deplibs in 9702b425557eSmrg *[!\ \ ]*) 9703b425557eSmrg echo 9704fe24f8a2Smrg if test none = "$deplibs_check_method"; then 9705b425557eSmrg echo "*** Warning: inter-library dependencies are not supported in this platform." 970634977a2fSmrg else 9707b425557eSmrg echo "*** Warning: inter-library dependencies are not known to be supported." 970834977a2fSmrg fi 9709b425557eSmrg echo "*** All declared inter-library dependencies are being dropped." 971034977a2fSmrg droppeddeps=yes 9711b425557eSmrg ;; 9712b425557eSmrg esac 971334977a2fSmrg ;; 971434977a2fSmrg esac 971534977a2fSmrg versuffix=$versuffix_save 971634977a2fSmrg major=$major_save 971734977a2fSmrg release=$release_save 971834977a2fSmrg libname=$libname_save 971934977a2fSmrg name=$name_save 972034977a2fSmrg 972134977a2fSmrg case $host in 972234977a2fSmrg *-*-rhapsody* | *-*-darwin1.[012]) 972334977a2fSmrg # On Rhapsody replace the C library with the System framework 9724b425557eSmrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` 972534977a2fSmrg ;; 972634977a2fSmrg esac 972734977a2fSmrg 9728fe24f8a2Smrg if test yes = "$droppeddeps"; then 9729fe24f8a2Smrg if test yes = "$module"; then 9730b425557eSmrg echo 9731b425557eSmrg echo "*** Warning: libtool could not satisfy all declared inter-library" 973234977a2fSmrg $ECHO "*** dependencies of module $libname. Therefore, libtool will create" 9733b425557eSmrg echo "*** a static module, that should work as long as the dlopening" 9734b425557eSmrg echo "*** application is linked with the -dlopen flag." 973534977a2fSmrg if test -z "$global_symbol_pipe"; then 9736b425557eSmrg echo 9737b425557eSmrg echo "*** However, this would only work if libtool was able to extract symbol" 9738fe24f8a2Smrg echo "*** lists from a program, using 'nm' or equivalent, but libtool could" 9739b425557eSmrg echo "*** not find such a program. So, this module is probably useless." 9740fe24f8a2Smrg echo "*** 'nm' from GNU binutils and a full rebuild may help." 974134977a2fSmrg fi 9742fe24f8a2Smrg if test no = "$build_old_libs"; then 9743fe24f8a2Smrg oldlibs=$output_objdir/$libname.$libext 974434977a2fSmrg build_libtool_libs=module 974534977a2fSmrg build_old_libs=yes 974634977a2fSmrg else 974734977a2fSmrg build_libtool_libs=no 974834977a2fSmrg fi 974934977a2fSmrg else 9750b425557eSmrg echo "*** The inter-library dependencies that have been dropped here will be" 9751b425557eSmrg echo "*** automatically added whenever a program is linked with this library" 9752b425557eSmrg echo "*** or is declared to -dlopen it." 975334977a2fSmrg 9754fe24f8a2Smrg if test no = "$allow_undefined"; then 9755b425557eSmrg echo 9756b425557eSmrg echo "*** Since this library must not contain undefined symbols," 9757b425557eSmrg echo "*** because either the platform does not support them or" 9758b425557eSmrg echo "*** it was explicitly requested with -no-undefined," 9759b425557eSmrg echo "*** libtool will only create a static version of it." 9760fe24f8a2Smrg if test no = "$build_old_libs"; then 9761fe24f8a2Smrg oldlibs=$output_objdir/$libname.$libext 976234977a2fSmrg build_libtool_libs=module 976334977a2fSmrg build_old_libs=yes 976434977a2fSmrg else 976534977a2fSmrg build_libtool_libs=no 976634977a2fSmrg fi 976734977a2fSmrg fi 976834977a2fSmrg fi 976934977a2fSmrg fi 977034977a2fSmrg # Done checking deplibs! 977134977a2fSmrg deplibs=$newdeplibs 977234977a2fSmrg fi 977334977a2fSmrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 977434977a2fSmrg case $host in 977534977a2fSmrg *-*-darwin*) 9776b425557eSmrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 9777b425557eSmrg new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 9778b425557eSmrg deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 977934977a2fSmrg ;; 978034977a2fSmrg esac 978134977a2fSmrg 978234977a2fSmrg # move library search paths that coincide with paths to not yet 978334977a2fSmrg # installed libraries to the beginning of the library search list 978434977a2fSmrg new_libs= 978534977a2fSmrg for path in $notinst_path; do 978634977a2fSmrg case " $new_libs " in 978734977a2fSmrg *" -L$path/$objdir "*) ;; 978834977a2fSmrg *) 978934977a2fSmrg case " $deplibs " in 979034977a2fSmrg *" -L$path/$objdir "*) 97913e72ca8cSmrg func_append new_libs " -L$path/$objdir" ;; 979234977a2fSmrg esac 979334977a2fSmrg ;; 979434977a2fSmrg esac 979534977a2fSmrg done 979634977a2fSmrg for deplib in $deplibs; do 979734977a2fSmrg case $deplib in 979834977a2fSmrg -L*) 979934977a2fSmrg case " $new_libs " in 980034977a2fSmrg *" $deplib "*) ;; 98013e72ca8cSmrg *) func_append new_libs " $deplib" ;; 980234977a2fSmrg esac 980334977a2fSmrg ;; 98043e72ca8cSmrg *) func_append new_libs " $deplib" ;; 980534977a2fSmrg esac 980634977a2fSmrg done 9807fe24f8a2Smrg deplibs=$new_libs 980834977a2fSmrg 980934977a2fSmrg # All the library-specific variables (install_libdir is set above). 981034977a2fSmrg library_names= 981134977a2fSmrg old_library= 981234977a2fSmrg dlname= 981334977a2fSmrg 981434977a2fSmrg # Test again, we may have decided not to build it any more 9815fe24f8a2Smrg if test yes = "$build_libtool_libs"; then 9816fe24f8a2Smrg # Remove $wl instances when linking with ld. 98173e72ca8cSmrg # FIXME: should test the right _cmds variable. 98183e72ca8cSmrg case $archive_cmds in 98193e72ca8cSmrg *\$LD\ *) wl= ;; 98203e72ca8cSmrg esac 9821fe24f8a2Smrg if test yes = "$hardcode_into_libs"; then 982234977a2fSmrg # Hardcode the library paths 982334977a2fSmrg hardcode_libdirs= 982434977a2fSmrg dep_rpath= 9825fe24f8a2Smrg rpath=$finalize_rpath 9826fe24f8a2Smrg test relink = "$opt_mode" || rpath=$compile_rpath$rpath 982734977a2fSmrg for libdir in $rpath; do 982834977a2fSmrg if test -n "$hardcode_libdir_flag_spec"; then 982934977a2fSmrg if test -n "$hardcode_libdir_separator"; then 98303e72ca8cSmrg func_replace_sysroot "$libdir" 98313e72ca8cSmrg libdir=$func_replace_sysroot_result 983234977a2fSmrg if test -z "$hardcode_libdirs"; then 9833fe24f8a2Smrg hardcode_libdirs=$libdir 983434977a2fSmrg else 983534977a2fSmrg # Just accumulate the unique libdirs. 983634977a2fSmrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 983734977a2fSmrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 983834977a2fSmrg ;; 983934977a2fSmrg *) 98403e72ca8cSmrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 984134977a2fSmrg ;; 984234977a2fSmrg esac 984334977a2fSmrg fi 984434977a2fSmrg else 984534977a2fSmrg eval flag=\"$hardcode_libdir_flag_spec\" 98463e72ca8cSmrg func_append dep_rpath " $flag" 984734977a2fSmrg fi 984834977a2fSmrg elif test -n "$runpath_var"; then 984934977a2fSmrg case "$perm_rpath " in 985034977a2fSmrg *" $libdir "*) ;; 98513e72ca8cSmrg *) func_append perm_rpath " $libdir" ;; 985234977a2fSmrg esac 985334977a2fSmrg fi 985434977a2fSmrg done 985534977a2fSmrg # Substitute the hardcoded libdirs into the rpath. 985634977a2fSmrg if test -n "$hardcode_libdir_separator" && 985734977a2fSmrg test -n "$hardcode_libdirs"; then 9858fe24f8a2Smrg libdir=$hardcode_libdirs 98593e72ca8cSmrg eval "dep_rpath=\"$hardcode_libdir_flag_spec\"" 986034977a2fSmrg fi 986134977a2fSmrg if test -n "$runpath_var" && test -n "$perm_rpath"; then 986234977a2fSmrg # We should set the runpath_var. 986334977a2fSmrg rpath= 986434977a2fSmrg for dir in $perm_rpath; do 98653e72ca8cSmrg func_append rpath "$dir:" 986634977a2fSmrg done 986734977a2fSmrg eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" 986834977a2fSmrg fi 986934977a2fSmrg test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" 987034977a2fSmrg fi 9871ee3138f1Smrg 9872fe24f8a2Smrg shlibpath=$finalize_shlibpath 9873fe24f8a2Smrg test relink = "$opt_mode" || shlibpath=$compile_shlibpath$shlibpath 987434977a2fSmrg if test -n "$shlibpath"; then 987534977a2fSmrg eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" 987634977a2fSmrg fi 9877ee3138f1Smrg 987834977a2fSmrg # Get the real and link names of the library. 987934977a2fSmrg eval shared_ext=\"$shrext_cmds\" 988034977a2fSmrg eval library_names=\"$library_names_spec\" 988134977a2fSmrg set dummy $library_names 988234977a2fSmrg shift 9883fe24f8a2Smrg realname=$1 988434977a2fSmrg shift 9885ee3138f1Smrg 988634977a2fSmrg if test -n "$soname_spec"; then 988734977a2fSmrg eval soname=\"$soname_spec\" 988834977a2fSmrg else 9889fe24f8a2Smrg soname=$realname 989034977a2fSmrg fi 989134977a2fSmrg if test -z "$dlname"; then 989234977a2fSmrg dlname=$soname 989334977a2fSmrg fi 9894ee3138f1Smrg 9895fe24f8a2Smrg lib=$output_objdir/$realname 989634977a2fSmrg linknames= 989734977a2fSmrg for link 989834977a2fSmrg do 98993e72ca8cSmrg func_append linknames " $link" 990034977a2fSmrg done 9901ee3138f1Smrg 990234977a2fSmrg # Use standard objects if they are pic 9903b425557eSmrg test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` 990434977a2fSmrg test "X$libobjs" = "X " && libobjs= 9905ee3138f1Smrg 990634977a2fSmrg delfiles= 990734977a2fSmrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 990834977a2fSmrg $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" 9909fe24f8a2Smrg export_symbols=$output_objdir/$libname.uexp 99103e72ca8cSmrg func_append delfiles " $export_symbols" 991134977a2fSmrg fi 9912ee3138f1Smrg 991334977a2fSmrg orig_export_symbols= 991434977a2fSmrg case $host_os in 991534977a2fSmrg cygwin* | mingw* | cegcc*) 991634977a2fSmrg if test -n "$export_symbols" && test -z "$export_symbols_regex"; then 991734977a2fSmrg # exporting using user supplied symfile 9918fe24f8a2Smrg func_dll_def_p "$export_symbols" || { 991934977a2fSmrg # and it's NOT already a .def file. Must figure out 992034977a2fSmrg # which of the given symbols are data symbols and tag 992134977a2fSmrg # them as such. So, trigger use of export_symbols_cmds. 992234977a2fSmrg # export_symbols gets reassigned inside the "prepare 992334977a2fSmrg # the list of exported symbols" if statement, so the 992434977a2fSmrg # include_expsyms logic still works. 9925fe24f8a2Smrg orig_export_symbols=$export_symbols 992634977a2fSmrg export_symbols= 992734977a2fSmrg always_export_symbols=yes 9928fe24f8a2Smrg } 992934977a2fSmrg fi 993034977a2fSmrg ;; 993134977a2fSmrg esac 9932ee3138f1Smrg 993334977a2fSmrg # Prepare the list of exported symbols 993434977a2fSmrg if test -z "$export_symbols"; then 9935fe24f8a2Smrg if test yes = "$always_export_symbols" || test -n "$export_symbols_regex"; then 9936fe24f8a2Smrg func_verbose "generating symbol list for '$libname.la'" 9937fe24f8a2Smrg export_symbols=$output_objdir/$libname.exp 993834977a2fSmrg $opt_dry_run || $RM $export_symbols 993934977a2fSmrg cmds=$export_symbols_cmds 9940fe24f8a2Smrg save_ifs=$IFS; IFS='~' 99413e72ca8cSmrg for cmd1 in $cmds; do 9942fe24f8a2Smrg IFS=$save_ifs 99433e72ca8cSmrg # Take the normal branch if the nm_file_list_spec branch 99443e72ca8cSmrg # doesn't work or if tool conversion is not needed. 99453e72ca8cSmrg case $nm_file_list_spec~$to_tool_file_cmd in 99463e72ca8cSmrg *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) 99473e72ca8cSmrg try_normal_branch=yes 99483e72ca8cSmrg eval cmd=\"$cmd1\" 99493e72ca8cSmrg func_len " $cmd" 99503e72ca8cSmrg len=$func_len_result 99513e72ca8cSmrg ;; 99523e72ca8cSmrg *) 99533e72ca8cSmrg try_normal_branch=no 99543e72ca8cSmrg ;; 99553e72ca8cSmrg esac 9956fe24f8a2Smrg if test yes = "$try_normal_branch" \ 99573e72ca8cSmrg && { test "$len" -lt "$max_cmd_len" \ 99583e72ca8cSmrg || test "$max_cmd_len" -le -1; } 99593e72ca8cSmrg then 99603e72ca8cSmrg func_show_eval "$cmd" 'exit $?' 99613e72ca8cSmrg skipped_export=false 99623e72ca8cSmrg elif test -n "$nm_file_list_spec"; then 99633e72ca8cSmrg func_basename "$output" 99643e72ca8cSmrg output_la=$func_basename_result 99653e72ca8cSmrg save_libobjs=$libobjs 99663e72ca8cSmrg save_output=$output 9967fe24f8a2Smrg output=$output_objdir/$output_la.nm 99683e72ca8cSmrg func_to_tool_file "$output" 99693e72ca8cSmrg libobjs=$nm_file_list_spec$func_to_tool_file_result 99703e72ca8cSmrg func_append delfiles " $output" 99713e72ca8cSmrg func_verbose "creating $NM input file list: $output" 99723e72ca8cSmrg for obj in $save_libobjs; do 99733e72ca8cSmrg func_to_tool_file "$obj" 99743e72ca8cSmrg $ECHO "$func_to_tool_file_result" 99753e72ca8cSmrg done > "$output" 99763e72ca8cSmrg eval cmd=\"$cmd1\" 997734977a2fSmrg func_show_eval "$cmd" 'exit $?' 99783e72ca8cSmrg output=$save_output 99793e72ca8cSmrg libobjs=$save_libobjs 998034977a2fSmrg skipped_export=false 998134977a2fSmrg else 998234977a2fSmrg # The command line is too long to execute in one step. 998334977a2fSmrg func_verbose "using reloadable object file for export list..." 998434977a2fSmrg skipped_export=: 998534977a2fSmrg # Break out early, otherwise skipped_export may be 998634977a2fSmrg # set to false by a later but shorter cmd. 998734977a2fSmrg break 998834977a2fSmrg fi 998934977a2fSmrg done 9990fe24f8a2Smrg IFS=$save_ifs 9991fe24f8a2Smrg if test -n "$export_symbols_regex" && test : != "$skipped_export"; then 999234977a2fSmrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 999334977a2fSmrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 999434977a2fSmrg fi 999534977a2fSmrg fi 9996ee3138f1Smrg fi 9997ee3138f1Smrg 999834977a2fSmrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 9999fe24f8a2Smrg tmp_export_symbols=$export_symbols 10000fe24f8a2Smrg test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols 10001b425557eSmrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 1000234977a2fSmrg fi 10003ee3138f1Smrg 10004fe24f8a2Smrg if test : != "$skipped_export" && test -n "$orig_export_symbols"; then 1000534977a2fSmrg # The given exports_symbols file has to be filtered, so filter it. 10006fe24f8a2Smrg func_verbose "filter symbol list for '$libname.la' to tag DATA exports" 1000734977a2fSmrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 10008fe24f8a2Smrg # 's' commands, which not all seds can handle. GNU sed should be fine 1000934977a2fSmrg # though. Also, the filter scales superlinearly with the number of 1001034977a2fSmrg # global variables. join(1) would be nice here, but unfortunately 1001134977a2fSmrg # isn't a blessed tool. 1001234977a2fSmrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 100133e72ca8cSmrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 1001434977a2fSmrg export_symbols=$output_objdir/$libname.def 1001534977a2fSmrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 1001634977a2fSmrg fi 10017ee3138f1Smrg 1001834977a2fSmrg tmp_deplibs= 1001934977a2fSmrg for test_deplib in $deplibs; do 1002034977a2fSmrg case " $convenience " in 1002134977a2fSmrg *" $test_deplib "*) ;; 1002234977a2fSmrg *) 100233e72ca8cSmrg func_append tmp_deplibs " $test_deplib" 1002434977a2fSmrg ;; 1002534977a2fSmrg esac 1002634977a2fSmrg done 10027fe24f8a2Smrg deplibs=$tmp_deplibs 10028ee3138f1Smrg 1002934977a2fSmrg if test -n "$convenience"; then 1003034977a2fSmrg if test -n "$whole_archive_flag_spec" && 10031fe24f8a2Smrg test yes = "$compiler_needs_object" && 1003234977a2fSmrg test -z "$libobjs"; then 1003334977a2fSmrg # extract the archives, so we have objects to list. 1003434977a2fSmrg # TODO: could optimize this to just extract one archive. 1003534977a2fSmrg whole_archive_flag_spec= 1003634977a2fSmrg fi 1003734977a2fSmrg if test -n "$whole_archive_flag_spec"; then 1003834977a2fSmrg save_libobjs=$libobjs 1003934977a2fSmrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 1004034977a2fSmrg test "X$libobjs" = "X " && libobjs= 1004134977a2fSmrg else 10042fe24f8a2Smrg gentop=$output_objdir/${outputname}x 100433e72ca8cSmrg func_append generated " $gentop" 10044ee3138f1Smrg 1004534977a2fSmrg func_extract_archives $gentop $convenience 100463e72ca8cSmrg func_append libobjs " $func_extract_archives_result" 1004734977a2fSmrg test "X$libobjs" = "X " && libobjs= 1004834977a2fSmrg fi 10049ee3138f1Smrg fi 10050ee3138f1Smrg 10051fe24f8a2Smrg if test yes = "$thread_safe" && test -n "$thread_safe_flag_spec"; then 1005234977a2fSmrg eval flag=\"$thread_safe_flag_spec\" 100533e72ca8cSmrg func_append linker_flags " $flag" 10054ee3138f1Smrg fi 10055ee3138f1Smrg 1005634977a2fSmrg # Make a backup of the uninstalled library when relinking 10057fe24f8a2Smrg if test relink = "$opt_mode"; then 1005834977a2fSmrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? 1005934977a2fSmrg fi 10060ee3138f1Smrg 1006134977a2fSmrg # Do each of the archive commands. 10062fe24f8a2Smrg if test yes = "$module" && test -n "$module_cmds"; then 1006334977a2fSmrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 1006434977a2fSmrg eval test_cmds=\"$module_expsym_cmds\" 1006534977a2fSmrg cmds=$module_expsym_cmds 1006634977a2fSmrg else 1006734977a2fSmrg eval test_cmds=\"$module_cmds\" 1006834977a2fSmrg cmds=$module_cmds 1006934977a2fSmrg fi 10070ee3138f1Smrg else 1007134977a2fSmrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 1007234977a2fSmrg eval test_cmds=\"$archive_expsym_cmds\" 1007334977a2fSmrg cmds=$archive_expsym_cmds 1007434977a2fSmrg else 1007534977a2fSmrg eval test_cmds=\"$archive_cmds\" 1007634977a2fSmrg cmds=$archive_cmds 1007734977a2fSmrg fi 10078ee3138f1Smrg fi 10079ee3138f1Smrg 10080fe24f8a2Smrg if test : != "$skipped_export" && 1008134977a2fSmrg func_len " $test_cmds" && 1008234977a2fSmrg len=$func_len_result && 1008334977a2fSmrg test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 1008434977a2fSmrg : 1008534977a2fSmrg else 1008634977a2fSmrg # The command line is too long to link in one step, link piecewise 1008734977a2fSmrg # or, if using GNU ld and skipped_export is not :, use a linker 1008834977a2fSmrg # script. 10089ee3138f1Smrg 1009034977a2fSmrg # Save the value of $output and $libobjs because we want to 1009134977a2fSmrg # use them later. If we have whole_archive_flag_spec, we 1009234977a2fSmrg # want to use save_libobjs as it was before 1009334977a2fSmrg # whole_archive_flag_spec was expanded, because we can't 1009434977a2fSmrg # assume the linker understands whole_archive_flag_spec. 1009534977a2fSmrg # This may have to be revisited, in case too many 1009634977a2fSmrg # convenience libraries get linked in and end up exceeding 1009734977a2fSmrg # the spec. 1009834977a2fSmrg if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then 1009934977a2fSmrg save_libobjs=$libobjs 1010034977a2fSmrg fi 1010134977a2fSmrg save_output=$output 10102b425557eSmrg func_basename "$output" 10103b425557eSmrg output_la=$func_basename_result 10104ee3138f1Smrg 1010534977a2fSmrg # Clear the reloadable object creation command queue and 1010634977a2fSmrg # initialize k to one. 1010734977a2fSmrg test_cmds= 1010834977a2fSmrg concat_cmds= 1010934977a2fSmrg objlist= 1011034977a2fSmrg last_robj= 1011134977a2fSmrg k=1 1011234977a2fSmrg 10113fe24f8a2Smrg if test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then 10114fe24f8a2Smrg output=$output_objdir/$output_la.lnkscript 1011534977a2fSmrg func_verbose "creating GNU ld script: $output" 10116b425557eSmrg echo 'INPUT (' > $output 1011734977a2fSmrg for obj in $save_libobjs 10118ee3138f1Smrg do 101193e72ca8cSmrg func_to_tool_file "$obj" 101203e72ca8cSmrg $ECHO "$func_to_tool_file_result" >> $output 1012134977a2fSmrg done 10122b425557eSmrg echo ')' >> $output 101233e72ca8cSmrg func_append delfiles " $output" 101243e72ca8cSmrg func_to_tool_file "$output" 101253e72ca8cSmrg output=$func_to_tool_file_result 10126fe24f8a2Smrg elif test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then 10127fe24f8a2Smrg output=$output_objdir/$output_la.lnk 1012834977a2fSmrg func_verbose "creating linker input file list: $output" 1012934977a2fSmrg : > $output 1013034977a2fSmrg set x $save_libobjs 1013134977a2fSmrg shift 1013234977a2fSmrg firstobj= 10133fe24f8a2Smrg if test yes = "$compiler_needs_object"; then 1013434977a2fSmrg firstobj="$1 " 1013534977a2fSmrg shift 1013634977a2fSmrg fi 1013734977a2fSmrg for obj 1013834977a2fSmrg do 101393e72ca8cSmrg func_to_tool_file "$obj" 101403e72ca8cSmrg $ECHO "$func_to_tool_file_result" >> $output 1014134977a2fSmrg done 101423e72ca8cSmrg func_append delfiles " $output" 101433e72ca8cSmrg func_to_tool_file "$output" 101443e72ca8cSmrg output=$firstobj\"$file_list_spec$func_to_tool_file_result\" 1014534977a2fSmrg else 1014634977a2fSmrg if test -n "$save_libobjs"; then 1014734977a2fSmrg func_verbose "creating reloadable object files..." 10148fe24f8a2Smrg output=$output_objdir/$output_la-$k.$objext 1014934977a2fSmrg eval test_cmds=\"$reload_cmds\" 1015034977a2fSmrg func_len " $test_cmds" 1015134977a2fSmrg len0=$func_len_result 1015234977a2fSmrg len=$len0 1015334977a2fSmrg 1015434977a2fSmrg # Loop over the list of objects to be linked. 1015534977a2fSmrg for obj in $save_libobjs 1015634977a2fSmrg do 1015734977a2fSmrg func_len " $obj" 1015834977a2fSmrg func_arith $len + $func_len_result 1015934977a2fSmrg len=$func_arith_result 10160fe24f8a2Smrg if test -z "$objlist" || 1016134977a2fSmrg test "$len" -lt "$max_cmd_len"; then 1016234977a2fSmrg func_append objlist " $obj" 1016334977a2fSmrg else 1016434977a2fSmrg # The command $test_cmds is almost too long, add a 1016534977a2fSmrg # command to the queue. 10166fe24f8a2Smrg if test 1 -eq "$k"; then 1016734977a2fSmrg # The first file doesn't have a previous command to add. 10168b425557eSmrg reload_objs=$objlist 10169b425557eSmrg eval concat_cmds=\"$reload_cmds\" 1017034977a2fSmrg else 1017134977a2fSmrg # All subsequent reloadable object files will link in 1017234977a2fSmrg # the last one created. 10173b425557eSmrg reload_objs="$objlist $last_robj" 10174b425557eSmrg eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" 1017534977a2fSmrg fi 10176fe24f8a2Smrg last_robj=$output_objdir/$output_la-$k.$objext 1017734977a2fSmrg func_arith $k + 1 1017834977a2fSmrg k=$func_arith_result 10179fe24f8a2Smrg output=$output_objdir/$output_la-$k.$objext 10180b425557eSmrg objlist=" $obj" 1018134977a2fSmrg func_len " $last_robj" 1018234977a2fSmrg func_arith $len0 + $func_len_result 1018334977a2fSmrg len=$func_arith_result 1018434977a2fSmrg fi 1018534977a2fSmrg done 1018634977a2fSmrg # Handle the remaining objects by creating one last 1018734977a2fSmrg # reloadable object file. All subsequent reloadable object 1018834977a2fSmrg # files will link in the last one created. 1018934977a2fSmrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 10190b425557eSmrg reload_objs="$objlist $last_robj" 10191fe24f8a2Smrg eval concat_cmds=\"\$concat_cmds$reload_cmds\" 1019234977a2fSmrg if test -n "$last_robj"; then 10193fe24f8a2Smrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 1019434977a2fSmrg fi 101953e72ca8cSmrg func_append delfiles " $output" 10196ee3138f1Smrg 1019734977a2fSmrg else 1019834977a2fSmrg output= 1019934977a2fSmrg fi 10200ee3138f1Smrg 10201fe24f8a2Smrg ${skipped_export-false} && { 10202fe24f8a2Smrg func_verbose "generating symbol list for '$libname.la'" 10203fe24f8a2Smrg export_symbols=$output_objdir/$libname.exp 1020434977a2fSmrg $opt_dry_run || $RM $export_symbols 1020534977a2fSmrg libobjs=$output 1020634977a2fSmrg # Append the command to create the export file. 1020734977a2fSmrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 1020834977a2fSmrg eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" 1020934977a2fSmrg if test -n "$last_robj"; then 1021034977a2fSmrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 1021134977a2fSmrg fi 10212fe24f8a2Smrg } 10213ee3138f1Smrg 1021434977a2fSmrg test -n "$save_libobjs" && 1021534977a2fSmrg func_verbose "creating a temporary reloadable object file: $output" 10216ee3138f1Smrg 1021734977a2fSmrg # Loop through the commands generated above and execute them. 10218fe24f8a2Smrg save_ifs=$IFS; IFS='~' 1021934977a2fSmrg for cmd in $concat_cmds; do 10220fe24f8a2Smrg IFS=$save_ifs 10221fe24f8a2Smrg $opt_quiet || { 102228d623946Smrg func_quote_arg expand,pretty "$cmd" 102238d623946Smrg eval "func_echo $func_quote_arg_result" 1022434977a2fSmrg } 1022534977a2fSmrg $opt_dry_run || eval "$cmd" || { 1022634977a2fSmrg lt_exit=$? 1022734977a2fSmrg 1022834977a2fSmrg # Restore the uninstalled library and exit 10229fe24f8a2Smrg if test relink = "$opt_mode"; then 1023034977a2fSmrg ( cd "$output_objdir" && \ 1023134977a2fSmrg $RM "${realname}T" && \ 1023234977a2fSmrg $MV "${realname}U" "$realname" ) 1023334977a2fSmrg fi 10234ee3138f1Smrg 1023534977a2fSmrg exit $lt_exit 1023634977a2fSmrg } 1023734977a2fSmrg done 10238fe24f8a2Smrg IFS=$save_ifs 10239ee3138f1Smrg 1024034977a2fSmrg if test -n "$export_symbols_regex" && ${skipped_export-false}; then 1024134977a2fSmrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 1024234977a2fSmrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 10243ee3138f1Smrg fi 10244ee3138f1Smrg fi 10245ee3138f1Smrg 10246fe24f8a2Smrg ${skipped_export-false} && { 1024734977a2fSmrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 10248fe24f8a2Smrg tmp_export_symbols=$export_symbols 10249fe24f8a2Smrg test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols 10250b425557eSmrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 1025134977a2fSmrg fi 10252ee3138f1Smrg 1025334977a2fSmrg if test -n "$orig_export_symbols"; then 1025434977a2fSmrg # The given exports_symbols file has to be filtered, so filter it. 10255fe24f8a2Smrg func_verbose "filter symbol list for '$libname.la' to tag DATA exports" 1025634977a2fSmrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 10257fe24f8a2Smrg # 's' commands, which not all seds can handle. GNU sed should be fine 1025834977a2fSmrg # though. Also, the filter scales superlinearly with the number of 1025934977a2fSmrg # global variables. join(1) would be nice here, but unfortunately 1026034977a2fSmrg # isn't a blessed tool. 1026134977a2fSmrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 102623e72ca8cSmrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 1026334977a2fSmrg export_symbols=$output_objdir/$libname.def 1026434977a2fSmrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 1026534977a2fSmrg fi 10266fe24f8a2Smrg } 10267ee3138f1Smrg 1026834977a2fSmrg libobjs=$output 1026934977a2fSmrg # Restore the value of output. 1027034977a2fSmrg output=$save_output 10271ee3138f1Smrg 1027234977a2fSmrg if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then 1027334977a2fSmrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 1027434977a2fSmrg test "X$libobjs" = "X " && libobjs= 1027534977a2fSmrg fi 1027634977a2fSmrg # Expand the library linking commands again to reset the 1027734977a2fSmrg # value of $libobjs for piecewise linking. 10278ee3138f1Smrg 1027934977a2fSmrg # Do each of the archive commands. 10280fe24f8a2Smrg if test yes = "$module" && test -n "$module_cmds"; then 1028134977a2fSmrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 1028234977a2fSmrg cmds=$module_expsym_cmds 1028334977a2fSmrg else 1028434977a2fSmrg cmds=$module_cmds 10285ee3138f1Smrg fi 10286ee3138f1Smrg else 1028734977a2fSmrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 1028834977a2fSmrg cmds=$archive_expsym_cmds 1028934977a2fSmrg else 1029034977a2fSmrg cmds=$archive_cmds 1029134977a2fSmrg fi 10292ee3138f1Smrg fi 1029334977a2fSmrg fi 10294ee3138f1Smrg 1029534977a2fSmrg if test -n "$delfiles"; then 1029634977a2fSmrg # Append the command to remove temporary files to $cmds. 1029734977a2fSmrg eval cmds=\"\$cmds~\$RM $delfiles\" 1029834977a2fSmrg fi 10299ee3138f1Smrg 1030034977a2fSmrg # Add any objects from preloaded convenience libraries 1030134977a2fSmrg if test -n "$dlprefiles"; then 10302fe24f8a2Smrg gentop=$output_objdir/${outputname}x 103033e72ca8cSmrg func_append generated " $gentop" 10304ee3138f1Smrg 1030534977a2fSmrg func_extract_archives $gentop $dlprefiles 103063e72ca8cSmrg func_append libobjs " $func_extract_archives_result" 1030734977a2fSmrg test "X$libobjs" = "X " && libobjs= 1030834977a2fSmrg fi 10309ee3138f1Smrg 10310fe24f8a2Smrg save_ifs=$IFS; IFS='~' 1031134977a2fSmrg for cmd in $cmds; do 10312fe24f8a2Smrg IFS=$sp$nl 1031334977a2fSmrg eval cmd=\"$cmd\" 10314fe24f8a2Smrg IFS=$save_ifs 10315fe24f8a2Smrg $opt_quiet || { 103168d623946Smrg func_quote_arg expand,pretty "$cmd" 103178d623946Smrg eval "func_echo $func_quote_arg_result" 1031834977a2fSmrg } 1031934977a2fSmrg $opt_dry_run || eval "$cmd" || { 1032034977a2fSmrg lt_exit=$? 10321ee3138f1Smrg 1032234977a2fSmrg # Restore the uninstalled library and exit 10323fe24f8a2Smrg if test relink = "$opt_mode"; then 1032434977a2fSmrg ( cd "$output_objdir" && \ 1032534977a2fSmrg $RM "${realname}T" && \ 1032634977a2fSmrg $MV "${realname}U" "$realname" ) 1032734977a2fSmrg fi 10328ee3138f1Smrg 1032934977a2fSmrg exit $lt_exit 1033034977a2fSmrg } 1033134977a2fSmrg done 10332fe24f8a2Smrg IFS=$save_ifs 10333ee3138f1Smrg 1033434977a2fSmrg # Restore the uninstalled library and exit 10335fe24f8a2Smrg if test relink = "$opt_mode"; then 1033634977a2fSmrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? 10337ee3138f1Smrg 1033834977a2fSmrg if test -n "$convenience"; then 1033934977a2fSmrg if test -z "$whole_archive_flag_spec"; then 1034034977a2fSmrg func_show_eval '${RM}r "$gentop"' 1034134977a2fSmrg fi 1034234977a2fSmrg fi 10343ee3138f1Smrg 1034434977a2fSmrg exit $EXIT_SUCCESS 1034534977a2fSmrg fi 1034634977a2fSmrg 1034734977a2fSmrg # Create links to the real library. 1034834977a2fSmrg for linkname in $linknames; do 1034934977a2fSmrg if test "$realname" != "$linkname"; then 1035034977a2fSmrg func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' 10351ee3138f1Smrg fi 10352ee3138f1Smrg done 10353ee3138f1Smrg 1035434977a2fSmrg # If -module or -export-dynamic was specified, set the dlname. 10355fe24f8a2Smrg if test yes = "$module" || test yes = "$export_dynamic"; then 1035634977a2fSmrg # On all known operating systems, these are identical. 10357fe24f8a2Smrg dlname=$soname 1035834977a2fSmrg fi 1035934977a2fSmrg fi 10360ee3138f1Smrg ;; 10361ee3138f1Smrg 1036234977a2fSmrg obj) 10363fe24f8a2Smrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 10364fe24f8a2Smrg func_warning "'-dlopen' is ignored for objects" 1036534977a2fSmrg fi 10366ee3138f1Smrg 1036734977a2fSmrg case " $deplibs" in 1036834977a2fSmrg *\ -l* | *\ -L*) 10369fe24f8a2Smrg func_warning "'-l' and '-L' are ignored for objects" ;; 10370ee3138f1Smrg esac 10371ee3138f1Smrg 1037234977a2fSmrg test -n "$rpath" && \ 10373fe24f8a2Smrg func_warning "'-rpath' is ignored for objects" 1037434977a2fSmrg 1037534977a2fSmrg test -n "$xrpath" && \ 10376fe24f8a2Smrg func_warning "'-R' is ignored for objects" 10377ee3138f1Smrg 1037834977a2fSmrg test -n "$vinfo" && \ 10379fe24f8a2Smrg func_warning "'-version-info' is ignored for objects" 10380ee3138f1Smrg 1038134977a2fSmrg test -n "$release" && \ 10382fe24f8a2Smrg func_warning "'-release' is ignored for objects" 1038334977a2fSmrg 1038434977a2fSmrg case $output in 1038534977a2fSmrg *.lo) 1038634977a2fSmrg test -n "$objs$old_deplibs" && \ 10387fe24f8a2Smrg func_fatal_error "cannot build library object '$output' from non-libtool objects" 1038834977a2fSmrg 1038934977a2fSmrg libobj=$output 1039034977a2fSmrg func_lo2o "$libobj" 1039134977a2fSmrg obj=$func_lo2o_result 10392ee3138f1Smrg ;; 10393ee3138f1Smrg *) 1039434977a2fSmrg libobj= 10395fe24f8a2Smrg obj=$output 10396ee3138f1Smrg ;; 10397ee3138f1Smrg esac 10398ee3138f1Smrg 1039934977a2fSmrg # Delete the old objects. 1040034977a2fSmrg $opt_dry_run || $RM $obj $libobj 10401ee3138f1Smrg 1040234977a2fSmrg # Objects from convenience libraries. This assumes 1040334977a2fSmrg # single-version convenience libraries. Whenever we create 1040434977a2fSmrg # different ones for PIC/non-PIC, this we'll have to duplicate 1040534977a2fSmrg # the extraction. 1040634977a2fSmrg reload_conv_objs= 1040734977a2fSmrg gentop= 10408fe24f8a2Smrg # if reload_cmds runs $LD directly, get rid of -Wl from 10409fe24f8a2Smrg # whole_archive_flag_spec and hope we can get by with turning comma 10410fe24f8a2Smrg # into space. 10411fe24f8a2Smrg case $reload_cmds in 10412fe24f8a2Smrg *\$LD[\ \$]*) wl= ;; 10413fe24f8a2Smrg esac 1041434977a2fSmrg if test -n "$convenience"; then 1041534977a2fSmrg if test -n "$whole_archive_flag_spec"; then 1041634977a2fSmrg eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" 10417fe24f8a2Smrg test -n "$wl" || tmp_whole_archive_flags=`$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` 10418fe24f8a2Smrg reload_conv_objs=$reload_objs\ $tmp_whole_archive_flags 1041934977a2fSmrg else 10420fe24f8a2Smrg gentop=$output_objdir/${obj}x 104213e72ca8cSmrg func_append generated " $gentop" 10422ee3138f1Smrg 1042334977a2fSmrg func_extract_archives $gentop $convenience 1042434977a2fSmrg reload_conv_objs="$reload_objs $func_extract_archives_result" 1042534977a2fSmrg fi 10426ee3138f1Smrg fi 10427ee3138f1Smrg 104283e72ca8cSmrg # If we're not building shared, we need to use non_pic_objs 10429fe24f8a2Smrg test yes = "$build_libtool_libs" || libobjs=$non_pic_objects 104303e72ca8cSmrg 1043134977a2fSmrg # Create the old-style object. 10432fe24f8a2Smrg reload_objs=$objs$old_deplibs' '`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; /\.lib$/d; $lo2o" | $NL2SP`' '$reload_conv_objs 10433ee3138f1Smrg 10434fe24f8a2Smrg output=$obj 1043534977a2fSmrg func_execute_cmds "$reload_cmds" 'exit $?' 10436ee3138f1Smrg 1043734977a2fSmrg # Exit if we aren't doing a library object file. 1043834977a2fSmrg if test -z "$libobj"; then 1043934977a2fSmrg if test -n "$gentop"; then 1044034977a2fSmrg func_show_eval '${RM}r "$gentop"' 1044134977a2fSmrg fi 1044234977a2fSmrg 1044334977a2fSmrg exit $EXIT_SUCCESS 10444ee3138f1Smrg fi 1044534977a2fSmrg 10446fe24f8a2Smrg test yes = "$build_libtool_libs" || { 1044734977a2fSmrg if test -n "$gentop"; then 1044834977a2fSmrg func_show_eval '${RM}r "$gentop"' 1044934977a2fSmrg fi 1045034977a2fSmrg 1045134977a2fSmrg # Create an invalid libtool object if no PIC, so that we don't 1045234977a2fSmrg # accidentally link it into a program. 1045334977a2fSmrg # $show "echo timestamp > $libobj" 1045434977a2fSmrg # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? 1045534977a2fSmrg exit $EXIT_SUCCESS 10456fe24f8a2Smrg } 1045734977a2fSmrg 10458fe24f8a2Smrg if test -n "$pic_flag" || test default != "$pic_mode"; then 1045934977a2fSmrg # Only do commands if we really have different PIC objects. 1046034977a2fSmrg reload_objs="$libobjs $reload_conv_objs" 10461fe24f8a2Smrg output=$libobj 1046234977a2fSmrg func_execute_cmds "$reload_cmds" 'exit $?' 1046334977a2fSmrg fi 1046434977a2fSmrg 1046534977a2fSmrg if test -n "$gentop"; then 1046634977a2fSmrg func_show_eval '${RM}r "$gentop"' 1046734977a2fSmrg fi 1046834977a2fSmrg 1046934977a2fSmrg exit $EXIT_SUCCESS 10470ee3138f1Smrg ;; 10471ee3138f1Smrg 1047234977a2fSmrg prog) 1047334977a2fSmrg case $host in 1047434977a2fSmrg *cygwin*) func_stripname '' '.exe' "$output" 1047534977a2fSmrg output=$func_stripname_result.exe;; 1047634977a2fSmrg esac 1047734977a2fSmrg test -n "$vinfo" && \ 10478fe24f8a2Smrg func_warning "'-version-info' is ignored for programs" 10479ee3138f1Smrg 1048034977a2fSmrg test -n "$release" && \ 10481fe24f8a2Smrg func_warning "'-release' is ignored for programs" 10482ee3138f1Smrg 10483fe24f8a2Smrg $preload \ 10484fe24f8a2Smrg && test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \ 10485fe24f8a2Smrg && func_warning "'LT_INIT([dlopen])' not used. Assuming no dlopen support." 1048634977a2fSmrg 1048734977a2fSmrg case $host in 1048834977a2fSmrg *-*-rhapsody* | *-*-darwin1.[012]) 1048934977a2fSmrg # On Rhapsody replace the C library is the System framework 10490b425557eSmrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` 10491b425557eSmrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` 10492ee3138f1Smrg ;; 1049334977a2fSmrg esac 10494ee3138f1Smrg 1049534977a2fSmrg case $host in 1049634977a2fSmrg *-*-darwin*) 1049734977a2fSmrg # Don't allow lazy linking, it breaks C++ global constructors 1049834977a2fSmrg # But is supposedly fixed on 10.4 or later (yay!). 10499fe24f8a2Smrg if test CXX = "$tagname"; then 1050034977a2fSmrg case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 1050134977a2fSmrg 10.[0123]) 10502fe24f8a2Smrg func_append compile_command " $wl-bind_at_load" 10503fe24f8a2Smrg func_append finalize_command " $wl-bind_at_load" 1050434977a2fSmrg ;; 1050534977a2fSmrg esac 10506ee3138f1Smrg fi 1050734977a2fSmrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 10508b425557eSmrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 10509b425557eSmrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 1051034977a2fSmrg ;; 1051134977a2fSmrg esac 10512ee3138f1Smrg 10513ee3138f1Smrg 1051434977a2fSmrg # move library search paths that coincide with paths to not yet 1051534977a2fSmrg # installed libraries to the beginning of the library search list 1051634977a2fSmrg new_libs= 1051734977a2fSmrg for path in $notinst_path; do 1051834977a2fSmrg case " $new_libs " in 1051934977a2fSmrg *" -L$path/$objdir "*) ;; 1052034977a2fSmrg *) 1052134977a2fSmrg case " $compile_deplibs " in 1052234977a2fSmrg *" -L$path/$objdir "*) 105233e72ca8cSmrg func_append new_libs " -L$path/$objdir" ;; 10524ee3138f1Smrg esac 1052534977a2fSmrg ;; 1052634977a2fSmrg esac 1052734977a2fSmrg done 1052834977a2fSmrg for deplib in $compile_deplibs; do 1052934977a2fSmrg case $deplib in 1053034977a2fSmrg -L*) 1053134977a2fSmrg case " $new_libs " in 1053234977a2fSmrg *" $deplib "*) ;; 105333e72ca8cSmrg *) func_append new_libs " $deplib" ;; 10534ee3138f1Smrg esac 1053534977a2fSmrg ;; 105363e72ca8cSmrg *) func_append new_libs " $deplib" ;; 1053734977a2fSmrg esac 1053834977a2fSmrg done 10539fe24f8a2Smrg compile_deplibs=$new_libs 10540ee3138f1Smrg 10541ee3138f1Smrg 105423e72ca8cSmrg func_append compile_command " $compile_deplibs" 105433e72ca8cSmrg func_append finalize_command " $finalize_deplibs" 10544ee3138f1Smrg 1054534977a2fSmrg if test -n "$rpath$xrpath"; then 1054634977a2fSmrg # If the user specified any rpath flags, then add them. 1054734977a2fSmrg for libdir in $rpath $xrpath; do 1054834977a2fSmrg # This is the magic to use -rpath. 1054934977a2fSmrg case "$finalize_rpath " in 1055034977a2fSmrg *" $libdir "*) ;; 105513e72ca8cSmrg *) func_append finalize_rpath " $libdir" ;; 1055234977a2fSmrg esac 1055334977a2fSmrg done 1055434977a2fSmrg fi 10555ee3138f1Smrg 1055634977a2fSmrg # Now hardcode the library paths 1055734977a2fSmrg rpath= 1055834977a2fSmrg hardcode_libdirs= 1055934977a2fSmrg for libdir in $compile_rpath $finalize_rpath; do 1056034977a2fSmrg if test -n "$hardcode_libdir_flag_spec"; then 1056134977a2fSmrg if test -n "$hardcode_libdir_separator"; then 1056234977a2fSmrg if test -z "$hardcode_libdirs"; then 10563fe24f8a2Smrg hardcode_libdirs=$libdir 1056434977a2fSmrg else 1056534977a2fSmrg # Just accumulate the unique libdirs. 1056634977a2fSmrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 1056734977a2fSmrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 1056834977a2fSmrg ;; 1056934977a2fSmrg *) 105703e72ca8cSmrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 1057134977a2fSmrg ;; 1057234977a2fSmrg esac 1057334977a2fSmrg fi 10574ee3138f1Smrg else 1057534977a2fSmrg eval flag=\"$hardcode_libdir_flag_spec\" 105763e72ca8cSmrg func_append rpath " $flag" 10577ee3138f1Smrg fi 1057834977a2fSmrg elif test -n "$runpath_var"; then 1057934977a2fSmrg case "$perm_rpath " in 1058034977a2fSmrg *" $libdir "*) ;; 105813e72ca8cSmrg *) func_append perm_rpath " $libdir" ;; 1058234977a2fSmrg esac 1058334977a2fSmrg fi 1058434977a2fSmrg case $host in 1058534977a2fSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 10586fe24f8a2Smrg testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'` 1058734977a2fSmrg case :$dllsearchpath: in 1058834977a2fSmrg *":$libdir:"*) ;; 1058934977a2fSmrg ::) dllsearchpath=$libdir;; 105903e72ca8cSmrg *) func_append dllsearchpath ":$libdir";; 1059134977a2fSmrg esac 1059234977a2fSmrg case :$dllsearchpath: in 1059334977a2fSmrg *":$testbindir:"*) ;; 1059434977a2fSmrg ::) dllsearchpath=$testbindir;; 105953e72ca8cSmrg *) func_append dllsearchpath ":$testbindir";; 1059634977a2fSmrg esac 1059734977a2fSmrg ;; 1059834977a2fSmrg esac 1059934977a2fSmrg done 1060034977a2fSmrg # Substitute the hardcoded libdirs into the rpath. 1060134977a2fSmrg if test -n "$hardcode_libdir_separator" && 1060234977a2fSmrg test -n "$hardcode_libdirs"; then 10603fe24f8a2Smrg libdir=$hardcode_libdirs 1060434977a2fSmrg eval rpath=\" $hardcode_libdir_flag_spec\" 1060534977a2fSmrg fi 10606fe24f8a2Smrg compile_rpath=$rpath 10607ee3138f1Smrg 1060834977a2fSmrg rpath= 1060934977a2fSmrg hardcode_libdirs= 1061034977a2fSmrg for libdir in $finalize_rpath; do 1061134977a2fSmrg if test -n "$hardcode_libdir_flag_spec"; then 1061234977a2fSmrg if test -n "$hardcode_libdir_separator"; then 1061334977a2fSmrg if test -z "$hardcode_libdirs"; then 10614fe24f8a2Smrg hardcode_libdirs=$libdir 1061534977a2fSmrg else 1061634977a2fSmrg # Just accumulate the unique libdirs. 1061734977a2fSmrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 1061834977a2fSmrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 1061934977a2fSmrg ;; 1062034977a2fSmrg *) 106213e72ca8cSmrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 1062234977a2fSmrg ;; 1062334977a2fSmrg esac 1062434977a2fSmrg fi 10625ee3138f1Smrg else 1062634977a2fSmrg eval flag=\"$hardcode_libdir_flag_spec\" 106273e72ca8cSmrg func_append rpath " $flag" 10628ee3138f1Smrg fi 1062934977a2fSmrg elif test -n "$runpath_var"; then 1063034977a2fSmrg case "$finalize_perm_rpath " in 1063134977a2fSmrg *" $libdir "*) ;; 106323e72ca8cSmrg *) func_append finalize_perm_rpath " $libdir" ;; 1063334977a2fSmrg esac 10634ee3138f1Smrg fi 1063534977a2fSmrg done 1063634977a2fSmrg # Substitute the hardcoded libdirs into the rpath. 1063734977a2fSmrg if test -n "$hardcode_libdir_separator" && 1063834977a2fSmrg test -n "$hardcode_libdirs"; then 10639fe24f8a2Smrg libdir=$hardcode_libdirs 1064034977a2fSmrg eval rpath=\" $hardcode_libdir_flag_spec\" 1064134977a2fSmrg fi 10642fe24f8a2Smrg finalize_rpath=$rpath 10643ee3138f1Smrg 10644fe24f8a2Smrg if test -n "$libobjs" && test yes = "$build_old_libs"; then 1064534977a2fSmrg # Transform all the library objects into standard objects. 10646b425557eSmrg compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 10647b425557eSmrg finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 1064834977a2fSmrg fi 10649ee3138f1Smrg 10650fe24f8a2Smrg func_generate_dlsyms "$outputname" "@PROGRAM@" false 10651ee3138f1Smrg 1065234977a2fSmrg # template prelinking step 1065334977a2fSmrg if test -n "$prelink_cmds"; then 1065434977a2fSmrg func_execute_cmds "$prelink_cmds" 'exit $?' 1065534977a2fSmrg fi 10656ee3138f1Smrg 10657fe24f8a2Smrg wrappers_required=: 1065834977a2fSmrg case $host in 10659b425557eSmrg *cegcc* | *mingw32ce*) 10660b425557eSmrg # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. 10661fe24f8a2Smrg wrappers_required=false 10662b425557eSmrg ;; 1066334977a2fSmrg *cygwin* | *mingw* ) 10664fe24f8a2Smrg test yes = "$build_libtool_libs" || wrappers_required=false 1066534977a2fSmrg ;; 1066634977a2fSmrg *) 10667fe24f8a2Smrg if test no = "$need_relink" || test yes != "$build_libtool_libs"; then 10668fe24f8a2Smrg wrappers_required=false 1066934977a2fSmrg fi 1067034977a2fSmrg ;; 1067134977a2fSmrg esac 10672fe24f8a2Smrg $wrappers_required || { 1067334977a2fSmrg # Replace the output file specification. 10674b425557eSmrg compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 10675fe24f8a2Smrg link_command=$compile_command$compile_rpath 10676ee3138f1Smrg 1067734977a2fSmrg # We have no uninstalled library dependencies, so finalize right now. 1067834977a2fSmrg exit_status=0 1067934977a2fSmrg func_show_eval "$link_command" 'exit_status=$?' 10680ee3138f1Smrg 106813e72ca8cSmrg if test -n "$postlink_cmds"; then 106823e72ca8cSmrg func_to_tool_file "$output" 106833e72ca8cSmrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 106843e72ca8cSmrg func_execute_cmds "$postlink_cmds" 'exit $?' 106853e72ca8cSmrg fi 106863e72ca8cSmrg 1068734977a2fSmrg # Delete the generated files. 10688fe24f8a2Smrg if test -f "$output_objdir/${outputname}S.$objext"; then 10689fe24f8a2Smrg func_show_eval '$RM "$output_objdir/${outputname}S.$objext"' 10690ee3138f1Smrg fi 10691ee3138f1Smrg 1069234977a2fSmrg exit $exit_status 10693fe24f8a2Smrg } 10694ee3138f1Smrg 1069534977a2fSmrg if test -n "$compile_shlibpath$finalize_shlibpath"; then 1069634977a2fSmrg compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" 1069734977a2fSmrg fi 1069834977a2fSmrg if test -n "$finalize_shlibpath"; then 1069934977a2fSmrg finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" 1070034977a2fSmrg fi 10701ee3138f1Smrg 1070234977a2fSmrg compile_var= 1070334977a2fSmrg finalize_var= 1070434977a2fSmrg if test -n "$runpath_var"; then 1070534977a2fSmrg if test -n "$perm_rpath"; then 1070634977a2fSmrg # We should set the runpath_var. 1070734977a2fSmrg rpath= 1070834977a2fSmrg for dir in $perm_rpath; do 107093e72ca8cSmrg func_append rpath "$dir:" 1071034977a2fSmrg done 1071134977a2fSmrg compile_var="$runpath_var=\"$rpath\$$runpath_var\" " 10712ee3138f1Smrg fi 1071334977a2fSmrg if test -n "$finalize_perm_rpath"; then 1071434977a2fSmrg # We should set the runpath_var. 1071534977a2fSmrg rpath= 1071634977a2fSmrg for dir in $finalize_perm_rpath; do 107173e72ca8cSmrg func_append rpath "$dir:" 1071834977a2fSmrg done 1071934977a2fSmrg finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " 10720ee3138f1Smrg fi 1072134977a2fSmrg fi 10722ee3138f1Smrg 10723fe24f8a2Smrg if test yes = "$no_install"; then 1072434977a2fSmrg # We don't need to create a wrapper script. 10725fe24f8a2Smrg link_command=$compile_var$compile_command$compile_rpath 1072634977a2fSmrg # Replace the output file specification. 10727b425557eSmrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 1072834977a2fSmrg # Delete the old output file. 1072934977a2fSmrg $opt_dry_run || $RM $output 1073034977a2fSmrg # Link the executable and exit 1073134977a2fSmrg func_show_eval "$link_command" 'exit $?' 107323e72ca8cSmrg 107333e72ca8cSmrg if test -n "$postlink_cmds"; then 107343e72ca8cSmrg func_to_tool_file "$output" 107353e72ca8cSmrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 107363e72ca8cSmrg func_execute_cmds "$postlink_cmds" 'exit $?' 107373e72ca8cSmrg fi 107383e72ca8cSmrg 10739ee3138f1Smrg exit $EXIT_SUCCESS 1074034977a2fSmrg fi 10741ee3138f1Smrg 10742fe24f8a2Smrg case $hardcode_action,$fast_install in 10743fe24f8a2Smrg relink,*) 10744fe24f8a2Smrg # Fast installation is not supported 10745fe24f8a2Smrg link_command=$compile_var$compile_command$compile_rpath 10746fe24f8a2Smrg relink_command=$finalize_var$finalize_command$finalize_rpath 1074734977a2fSmrg 10748fe24f8a2Smrg func_warning "this platform does not like uninstalled shared libraries" 10749fe24f8a2Smrg func_warning "'$output' will be relinked during installation" 10750fe24f8a2Smrg ;; 10751fe24f8a2Smrg *,yes) 10752fe24f8a2Smrg link_command=$finalize_var$compile_command$finalize_rpath 10753fe24f8a2Smrg relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` 10754fe24f8a2Smrg ;; 10755fe24f8a2Smrg *,no) 10756fe24f8a2Smrg link_command=$compile_var$compile_command$compile_rpath 10757fe24f8a2Smrg relink_command=$finalize_var$finalize_command$finalize_rpath 10758fe24f8a2Smrg ;; 10759fe24f8a2Smrg *,needless) 10760fe24f8a2Smrg link_command=$finalize_var$compile_command$finalize_rpath 10761fe24f8a2Smrg relink_command= 10762fe24f8a2Smrg ;; 10763fe24f8a2Smrg esac 10764ee3138f1Smrg 1076534977a2fSmrg # Replace the output file specification. 10766b425557eSmrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` 10767ee3138f1Smrg 1076834977a2fSmrg # Delete the old output files. 1076934977a2fSmrg $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname 10770ee3138f1Smrg 1077134977a2fSmrg func_show_eval "$link_command" 'exit $?' 10772ee3138f1Smrg 107733e72ca8cSmrg if test -n "$postlink_cmds"; then 107743e72ca8cSmrg func_to_tool_file "$output_objdir/$outputname" 107753e72ca8cSmrg 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'` 107763e72ca8cSmrg func_execute_cmds "$postlink_cmds" 'exit $?' 107773e72ca8cSmrg fi 107783e72ca8cSmrg 1077934977a2fSmrg # Now create the wrapper script. 1078034977a2fSmrg func_verbose "creating $output" 10781ee3138f1Smrg 1078234977a2fSmrg # Quote the relink command for shipping. 1078334977a2fSmrg if test -n "$relink_command"; then 1078434977a2fSmrg # Preserve any variables that may affect compiler behavior 1078534977a2fSmrg for var in $variables_saved_for_relink; do 1078634977a2fSmrg if eval test -z \"\${$var+set}\"; then 1078734977a2fSmrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 1078834977a2fSmrg elif eval var_value=\$$var; test -z "$var_value"; then 1078934977a2fSmrg relink_command="$var=; export $var; $relink_command" 10790ee3138f1Smrg else 107918d623946Smrg func_quote_arg pretty "$var_value" 107928d623946Smrg relink_command="$var=$func_quote_arg_result; export $var; $relink_command" 10793ee3138f1Smrg fi 1079434977a2fSmrg done 107958d623946Smrg func_quote eval cd "`pwd`" 107968d623946Smrg func_quote_arg pretty,unquoted "($func_quote_result; $relink_command)" 107978d623946Smrg relink_command=$func_quote_arg_unquoted_result 1079834977a2fSmrg fi 1079934977a2fSmrg 1080034977a2fSmrg # Only actually do things if not in dry run mode. 1080134977a2fSmrg $opt_dry_run || { 1080234977a2fSmrg # win32 will think the script is a binary if it has 1080334977a2fSmrg # a .exe suffix, so we strip it off here. 1080434977a2fSmrg case $output in 1080534977a2fSmrg *.exe) func_stripname '' '.exe' "$output" 1080634977a2fSmrg output=$func_stripname_result ;; 1080734977a2fSmrg esac 1080834977a2fSmrg # test for cygwin because mv fails w/o .exe extensions 1080934977a2fSmrg case $host in 1081034977a2fSmrg *cygwin*) 1081134977a2fSmrg exeext=.exe 1081234977a2fSmrg func_stripname '' '.exe' "$outputname" 1081334977a2fSmrg outputname=$func_stripname_result ;; 1081434977a2fSmrg *) exeext= ;; 10815ee3138f1Smrg esac 1081634977a2fSmrg case $host in 1081734977a2fSmrg *cygwin* | *mingw* ) 1081834977a2fSmrg func_dirname_and_basename "$output" "" "." 1081934977a2fSmrg output_name=$func_basename_result 1082034977a2fSmrg output_path=$func_dirname_result 10821fe24f8a2Smrg cwrappersource=$output_path/$objdir/lt-$output_name.c 10822fe24f8a2Smrg cwrapper=$output_path/$output_name.exe 1082334977a2fSmrg $RM $cwrappersource $cwrapper 1082434977a2fSmrg trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 1082534977a2fSmrg 1082634977a2fSmrg func_emit_cwrapperexe_src > $cwrappersource 1082734977a2fSmrg 1082834977a2fSmrg # The wrapper executable is built using the $host compiler, 1082934977a2fSmrg # because it contains $host paths and files. If cross- 1083034977a2fSmrg # compiling, it, like the target executable, must be 1083134977a2fSmrg # executed on the $host or under an emulation environment. 1083234977a2fSmrg $opt_dry_run || { 1083334977a2fSmrg $LTCC $LTCFLAGS -o $cwrapper $cwrappersource 1083434977a2fSmrg $STRIP $cwrapper 1083534977a2fSmrg } 10836ee3138f1Smrg 1083734977a2fSmrg # Now, create the wrapper script for func_source use: 1083834977a2fSmrg func_ltwrapper_scriptname $cwrapper 1083934977a2fSmrg $RM $func_ltwrapper_scriptname_result 1084034977a2fSmrg trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 1084134977a2fSmrg $opt_dry_run || { 1084234977a2fSmrg # note: this script will not be executed, so do not chmod. 10843fe24f8a2Smrg if test "x$build" = "x$host"; then 1084434977a2fSmrg $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result 1084534977a2fSmrg else 1084634977a2fSmrg func_emit_wrapper no > $func_ltwrapper_scriptname_result 1084734977a2fSmrg fi 1084834977a2fSmrg } 1084934977a2fSmrg ;; 1085034977a2fSmrg * ) 1085134977a2fSmrg $RM $output 1085234977a2fSmrg trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 10853ee3138f1Smrg 1085434977a2fSmrg func_emit_wrapper no > $output 1085534977a2fSmrg chmod +x $output 1085634977a2fSmrg ;; 1085734977a2fSmrg esac 1085834977a2fSmrg } 1085934977a2fSmrg exit $EXIT_SUCCESS 1086034977a2fSmrg ;; 1086134977a2fSmrg esac 10862ee3138f1Smrg 1086334977a2fSmrg # See if we need to build an old-fashioned archive. 1086434977a2fSmrg for oldlib in $oldlibs; do 10865ee3138f1Smrg 10866fe24f8a2Smrg case $build_libtool_libs in 10867fe24f8a2Smrg convenience) 10868fe24f8a2Smrg oldobjs="$libobjs_save $symfileobj" 10869fe24f8a2Smrg addlibs=$convenience 1087034977a2fSmrg build_libtool_libs=no 10871fe24f8a2Smrg ;; 10872fe24f8a2Smrg module) 10873fe24f8a2Smrg oldobjs=$libobjs_save 10874fe24f8a2Smrg addlibs=$old_convenience 10875fe24f8a2Smrg build_libtool_libs=no 10876fe24f8a2Smrg ;; 10877fe24f8a2Smrg *) 1087834977a2fSmrg oldobjs="$old_deplibs $non_pic_objects" 10879fe24f8a2Smrg $preload && test -f "$symfileobj" \ 10880fe24f8a2Smrg && func_append oldobjs " $symfileobj" 10881fe24f8a2Smrg addlibs=$old_convenience 10882fe24f8a2Smrg ;; 10883fe24f8a2Smrg esac 10884ee3138f1Smrg 1088534977a2fSmrg if test -n "$addlibs"; then 10886fe24f8a2Smrg gentop=$output_objdir/${outputname}x 108873e72ca8cSmrg func_append generated " $gentop" 10888ee3138f1Smrg 1088934977a2fSmrg func_extract_archives $gentop $addlibs 108903e72ca8cSmrg func_append oldobjs " $func_extract_archives_result" 1089134977a2fSmrg fi 10892ee3138f1Smrg 1089334977a2fSmrg # Do each command in the archive commands. 10894fe24f8a2Smrg if test -n "$old_archive_from_new_cmds" && test yes = "$build_libtool_libs"; then 1089534977a2fSmrg cmds=$old_archive_from_new_cmds 1089634977a2fSmrg else 10897ee3138f1Smrg 1089834977a2fSmrg # Add any objects from preloaded convenience libraries 1089934977a2fSmrg if test -n "$dlprefiles"; then 10900fe24f8a2Smrg gentop=$output_objdir/${outputname}x 109013e72ca8cSmrg func_append generated " $gentop" 10902ee3138f1Smrg 1090334977a2fSmrg func_extract_archives $gentop $dlprefiles 109043e72ca8cSmrg func_append oldobjs " $func_extract_archives_result" 1090534977a2fSmrg fi 10906ee3138f1Smrg 1090734977a2fSmrg # POSIX demands no paths to be encoded in archives. We have 1090834977a2fSmrg # to avoid creating archives with duplicate basenames if we 1090934977a2fSmrg # might have to extract them afterwards, e.g., when creating a 1091034977a2fSmrg # static archive out of a convenience library, or when linking 1091134977a2fSmrg # the entirety of a libtool archive into another (currently 1091234977a2fSmrg # not supported by libtool). 1091334977a2fSmrg if (for obj in $oldobjs 1091434977a2fSmrg do 1091534977a2fSmrg func_basename "$obj" 1091634977a2fSmrg $ECHO "$func_basename_result" 1091734977a2fSmrg done | sort | sort -uc >/dev/null 2>&1); then 1091834977a2fSmrg : 1091934977a2fSmrg else 10920b425557eSmrg echo "copying selected object files to avoid basename conflicts..." 10921fe24f8a2Smrg gentop=$output_objdir/${outputname}x 109223e72ca8cSmrg func_append generated " $gentop" 1092334977a2fSmrg func_mkdir_p "$gentop" 1092434977a2fSmrg save_oldobjs=$oldobjs 1092534977a2fSmrg oldobjs= 1092634977a2fSmrg counter=1 1092734977a2fSmrg for obj in $save_oldobjs 1092834977a2fSmrg do 1092934977a2fSmrg func_basename "$obj" 10930fe24f8a2Smrg objbase=$func_basename_result 1093134977a2fSmrg case " $oldobjs " in 1093234977a2fSmrg " ") oldobjs=$obj ;; 1093334977a2fSmrg *[\ /]"$objbase "*) 1093434977a2fSmrg while :; do 1093534977a2fSmrg # Make sure we don't pick an alternate name that also 1093634977a2fSmrg # overlaps. 1093734977a2fSmrg newobj=lt$counter-$objbase 1093834977a2fSmrg func_arith $counter + 1 1093934977a2fSmrg counter=$func_arith_result 1094034977a2fSmrg case " $oldobjs " in 1094134977a2fSmrg *[\ /]"$newobj "*) ;; 1094234977a2fSmrg *) if test ! -f "$gentop/$newobj"; then break; fi ;; 1094334977a2fSmrg esac 1094434977a2fSmrg done 1094534977a2fSmrg func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" 109463e72ca8cSmrg func_append oldobjs " $gentop/$newobj" 1094734977a2fSmrg ;; 109483e72ca8cSmrg *) func_append oldobjs " $obj" ;; 1094934977a2fSmrg esac 10950ee3138f1Smrg done 10951ee3138f1Smrg fi 109523e72ca8cSmrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 109533e72ca8cSmrg tool_oldlib=$func_to_tool_file_result 1095434977a2fSmrg eval cmds=\"$old_archive_cmds\" 10955ee3138f1Smrg 1095634977a2fSmrg func_len " $cmds" 1095734977a2fSmrg len=$func_len_result 1095834977a2fSmrg if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 1095934977a2fSmrg cmds=$old_archive_cmds 109603e72ca8cSmrg elif test -n "$archiver_list_spec"; then 109613e72ca8cSmrg func_verbose "using command file archive linking..." 109623e72ca8cSmrg for obj in $oldobjs 109633e72ca8cSmrg do 109643e72ca8cSmrg func_to_tool_file "$obj" 109653e72ca8cSmrg $ECHO "$func_to_tool_file_result" 109663e72ca8cSmrg done > $output_objdir/$libname.libcmd 109673e72ca8cSmrg func_to_tool_file "$output_objdir/$libname.libcmd" 109683e72ca8cSmrg oldobjs=" $archiver_list_spec$func_to_tool_file_result" 109693e72ca8cSmrg cmds=$old_archive_cmds 1097034977a2fSmrg else 1097134977a2fSmrg # the command line is too long to link in one step, link in parts 1097234977a2fSmrg func_verbose "using piecewise archive linking..." 1097334977a2fSmrg save_RANLIB=$RANLIB 1097434977a2fSmrg RANLIB=: 1097534977a2fSmrg objlist= 1097634977a2fSmrg concat_cmds= 1097734977a2fSmrg save_oldobjs=$oldobjs 1097834977a2fSmrg oldobjs= 1097934977a2fSmrg # Is there a better way of finding the last object in the list? 1098034977a2fSmrg for obj in $save_oldobjs 1098134977a2fSmrg do 1098234977a2fSmrg last_oldobj=$obj 1098334977a2fSmrg done 1098434977a2fSmrg eval test_cmds=\"$old_archive_cmds\" 1098534977a2fSmrg func_len " $test_cmds" 1098634977a2fSmrg len0=$func_len_result 1098734977a2fSmrg len=$len0 1098834977a2fSmrg for obj in $save_oldobjs 1098934977a2fSmrg do 1099034977a2fSmrg func_len " $obj" 1099134977a2fSmrg func_arith $len + $func_len_result 1099234977a2fSmrg len=$func_arith_result 1099334977a2fSmrg func_append objlist " $obj" 1099434977a2fSmrg if test "$len" -lt "$max_cmd_len"; then 1099534977a2fSmrg : 1099634977a2fSmrg else 1099734977a2fSmrg # the above command should be used before it gets too long 1099834977a2fSmrg oldobjs=$objlist 10999fe24f8a2Smrg if test "$obj" = "$last_oldobj"; then 1100034977a2fSmrg RANLIB=$save_RANLIB 1100134977a2fSmrg fi 1100234977a2fSmrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 11003fe24f8a2Smrg eval concat_cmds=\"\$concat_cmds$old_archive_cmds\" 1100434977a2fSmrg objlist= 1100534977a2fSmrg len=$len0 1100634977a2fSmrg fi 1100734977a2fSmrg done 1100834977a2fSmrg RANLIB=$save_RANLIB 1100934977a2fSmrg oldobjs=$objlist 11010fe24f8a2Smrg if test -z "$oldobjs"; then 1101134977a2fSmrg eval cmds=\"\$concat_cmds\" 1101234977a2fSmrg else 1101334977a2fSmrg eval cmds=\"\$concat_cmds~\$old_archive_cmds\" 1101434977a2fSmrg fi 1101534977a2fSmrg fi 1101634977a2fSmrg fi 1101734977a2fSmrg func_execute_cmds "$cmds" 'exit $?' 11018ee3138f1Smrg done 11019ee3138f1Smrg 1102034977a2fSmrg test -n "$generated" && \ 1102134977a2fSmrg func_show_eval "${RM}r$generated" 11022ee3138f1Smrg 1102334977a2fSmrg # Now create the libtool archive. 1102434977a2fSmrg case $output in 1102534977a2fSmrg *.la) 1102634977a2fSmrg old_library= 11027fe24f8a2Smrg test yes = "$build_old_libs" && old_library=$libname.$libext 1102834977a2fSmrg func_verbose "creating $output" 11029ee3138f1Smrg 1103034977a2fSmrg # Preserve any variables that may affect compiler behavior 1103134977a2fSmrg for var in $variables_saved_for_relink; do 1103234977a2fSmrg if eval test -z \"\${$var+set}\"; then 1103334977a2fSmrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 1103434977a2fSmrg elif eval var_value=\$$var; test -z "$var_value"; then 1103534977a2fSmrg relink_command="$var=; export $var; $relink_command" 11036ee3138f1Smrg else 110378d623946Smrg func_quote_arg pretty,unquoted "$var_value" 110388d623946Smrg relink_command="$var=$func_quote_arg_unquoted_result; export $var; $relink_command" 11039ee3138f1Smrg fi 1104034977a2fSmrg done 1104134977a2fSmrg # Quote the link command for shipping. 110428d623946Smrg func_quote eval cd "`pwd`" 110438d623946Smrg relink_command="($func_quote_result; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" 110448d623946Smrg func_quote_arg pretty,unquoted "$relink_command" 110458d623946Smrg relink_command=$func_quote_arg_unquoted_result 11046fe24f8a2Smrg if test yes = "$hardcode_automatic"; then 1104734977a2fSmrg relink_command= 1104834977a2fSmrg fi 11049ee3138f1Smrg 1105034977a2fSmrg # Only create the output if not a dry run. 1105134977a2fSmrg $opt_dry_run || { 1105234977a2fSmrg for installed in no yes; do 11053fe24f8a2Smrg if test yes = "$installed"; then 1105434977a2fSmrg if test -z "$install_libdir"; then 1105534977a2fSmrg break 1105634977a2fSmrg fi 11057fe24f8a2Smrg output=$output_objdir/${outputname}i 1105834977a2fSmrg # Replace all uninstalled libtool libraries with the installed ones 1105934977a2fSmrg newdependency_libs= 1106034977a2fSmrg for deplib in $dependency_libs; do 1106134977a2fSmrg case $deplib in 1106234977a2fSmrg *.la) 1106334977a2fSmrg func_basename "$deplib" 11064fe24f8a2Smrg name=$func_basename_result 110653e72ca8cSmrg func_resolve_sysroot "$deplib" 11066fe24f8a2Smrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` 1106734977a2fSmrg test -z "$libdir" && \ 11068fe24f8a2Smrg func_fatal_error "'$deplib' is not a valid libtool archive" 110693e72ca8cSmrg func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" 110703e72ca8cSmrg ;; 110713e72ca8cSmrg -L*) 110723e72ca8cSmrg func_stripname -L '' "$deplib" 110733e72ca8cSmrg func_replace_sysroot "$func_stripname_result" 110743e72ca8cSmrg func_append newdependency_libs " -L$func_replace_sysroot_result" 110753e72ca8cSmrg ;; 110763e72ca8cSmrg -R*) 110773e72ca8cSmrg func_stripname -R '' "$deplib" 110783e72ca8cSmrg func_replace_sysroot "$func_stripname_result" 110793e72ca8cSmrg func_append newdependency_libs " -R$func_replace_sysroot_result" 1108034977a2fSmrg ;; 110813e72ca8cSmrg *) func_append newdependency_libs " $deplib" ;; 1108234977a2fSmrg esac 1108334977a2fSmrg done 11084fe24f8a2Smrg dependency_libs=$newdependency_libs 1108534977a2fSmrg newdlfiles= 1108634977a2fSmrg 1108734977a2fSmrg for lib in $dlfiles; do 1108834977a2fSmrg case $lib in 1108934977a2fSmrg *.la) 1109034977a2fSmrg func_basename "$lib" 11091fe24f8a2Smrg name=$func_basename_result 11092fe24f8a2Smrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 1109334977a2fSmrg test -z "$libdir" && \ 11094fe24f8a2Smrg func_fatal_error "'$lib' is not a valid libtool archive" 110953e72ca8cSmrg func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" 1109634977a2fSmrg ;; 110973e72ca8cSmrg *) func_append newdlfiles " $lib" ;; 1109834977a2fSmrg esac 1109934977a2fSmrg done 11100fe24f8a2Smrg dlfiles=$newdlfiles 1110134977a2fSmrg newdlprefiles= 1110234977a2fSmrg for lib in $dlprefiles; do 1110334977a2fSmrg case $lib in 1110434977a2fSmrg *.la) 1110534977a2fSmrg # Only pass preopened files to the pseudo-archive (for 1110634977a2fSmrg # eventual linking with the app. that links it) if we 1110734977a2fSmrg # didn't already link the preopened objects directly into 1110834977a2fSmrg # the library: 1110934977a2fSmrg func_basename "$lib" 11110fe24f8a2Smrg name=$func_basename_result 11111fe24f8a2Smrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 1111234977a2fSmrg test -z "$libdir" && \ 11113fe24f8a2Smrg func_fatal_error "'$lib' is not a valid libtool archive" 111143e72ca8cSmrg func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" 1111534977a2fSmrg ;; 1111634977a2fSmrg esac 1111734977a2fSmrg done 11118fe24f8a2Smrg dlprefiles=$newdlprefiles 1111934977a2fSmrg else 1112034977a2fSmrg newdlfiles= 1112134977a2fSmrg for lib in $dlfiles; do 1112234977a2fSmrg case $lib in 11123fe24f8a2Smrg [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; 1112434977a2fSmrg *) abs=`pwd`"/$lib" ;; 1112534977a2fSmrg esac 111263e72ca8cSmrg func_append newdlfiles " $abs" 1112734977a2fSmrg done 11128fe24f8a2Smrg dlfiles=$newdlfiles 1112934977a2fSmrg newdlprefiles= 1113034977a2fSmrg for lib in $dlprefiles; do 1113134977a2fSmrg case $lib in 11132fe24f8a2Smrg [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; 1113334977a2fSmrg *) abs=`pwd`"/$lib" ;; 1113434977a2fSmrg esac 111353e72ca8cSmrg func_append newdlprefiles " $abs" 1113634977a2fSmrg done 11137fe24f8a2Smrg dlprefiles=$newdlprefiles 1113834977a2fSmrg fi 1113934977a2fSmrg $RM $output 1114034977a2fSmrg # place dlname in correct position for cygwin 11141b425557eSmrg # In fact, it would be nice if we could use this code for all target 11142b425557eSmrg # systems that can't hard-code library paths into their executables 11143b425557eSmrg # and that have no shared library path variable independent of PATH, 11144b425557eSmrg # but it turns out we can't easily determine that from inspecting 11145b425557eSmrg # libtool variables, so we have to hard-code the OSs to which it 11146b425557eSmrg # applies here; at the moment, that means platforms that use the PE 11147b425557eSmrg # object format with DLL files. See the long comment at the top of 11148b425557eSmrg # tests/bindir.at for full details. 1114934977a2fSmrg tdlname=$dlname 1115034977a2fSmrg case $host,$output,$installed,$module,$dlname in 11151b425557eSmrg *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) 11152b425557eSmrg # If a -bindir argument was supplied, place the dll there. 11153fe24f8a2Smrg if test -n "$bindir"; then 11154b425557eSmrg func_relative_path "$install_libdir" "$bindir" 11155fe24f8a2Smrg tdlname=$func_relative_path_result/$dlname 11156b425557eSmrg else 11157b425557eSmrg # Otherwise fall back on heuristic. 11158b425557eSmrg tdlname=../bin/$dlname 11159b425557eSmrg fi 11160b425557eSmrg ;; 1116134977a2fSmrg esac 1116234977a2fSmrg $ECHO > $output "\ 1116334977a2fSmrg# $outputname - a libtool library file 11164fe24f8a2Smrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 1116534977a2fSmrg# 1116634977a2fSmrg# Please DO NOT delete this file! 1116734977a2fSmrg# It is necessary for linking the library. 11168ee3138f1Smrg 1116934977a2fSmrg# The name that we can dlopen(3). 1117034977a2fSmrgdlname='$tdlname' 11171ee3138f1Smrg 1117234977a2fSmrg# Names of this library. 1117334977a2fSmrglibrary_names='$library_names' 11174ee3138f1Smrg 1117534977a2fSmrg# The name of the static archive. 1117634977a2fSmrgold_library='$old_library' 11177ee3138f1Smrg 11178fe24f8a2Smrg# Linker flags that cannot go in dependency_libs. 1117934977a2fSmrginherited_linker_flags='$new_inherited_linker_flags' 11180ee3138f1Smrg 1118134977a2fSmrg# Libraries that this one depends upon. 1118234977a2fSmrgdependency_libs='$dependency_libs' 11183ee3138f1Smrg 1118434977a2fSmrg# Names of additional weak libraries provided by this library 1118534977a2fSmrgweak_library_names='$weak_libs' 11186ee3138f1Smrg 1118734977a2fSmrg# Version information for $libname. 1118834977a2fSmrgcurrent=$current 1118934977a2fSmrgage=$age 1119034977a2fSmrgrevision=$revision 11191ee3138f1Smrg 1119234977a2fSmrg# Is this an already installed library? 1119334977a2fSmrginstalled=$installed 11194ee3138f1Smrg 1119534977a2fSmrg# Should we warn about portability when linking against -modules? 1119634977a2fSmrgshouldnotlink=$module 11197ee3138f1Smrg 1119834977a2fSmrg# Files to dlopen/dlpreopen 1119934977a2fSmrgdlopen='$dlfiles' 1120034977a2fSmrgdlpreopen='$dlprefiles' 11201ee3138f1Smrg 1120234977a2fSmrg# Directory that this library needs to be installed in: 1120334977a2fSmrglibdir='$install_libdir'" 11204fe24f8a2Smrg if test no,yes = "$installed,$need_relink"; then 1120534977a2fSmrg $ECHO >> $output "\ 1120634977a2fSmrgrelink_command=\"$relink_command\"" 1120734977a2fSmrg fi 1120834977a2fSmrg done 1120934977a2fSmrg } 11210ee3138f1Smrg 1121134977a2fSmrg # Do a symbolic link so that the libtool archive can be found in 1121234977a2fSmrg # LD_LIBRARY_PATH before the program is installed. 1121334977a2fSmrg func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' 1121434977a2fSmrg ;; 1121534977a2fSmrg esac 1121634977a2fSmrg exit $EXIT_SUCCESS 1121734977a2fSmrg} 11218ee3138f1Smrg 11219fe24f8a2Smrgif test link = "$opt_mode" || test relink = "$opt_mode"; then 11220fe24f8a2Smrg func_mode_link ${1+"$@"} 11221fe24f8a2Smrgfi 11222ee3138f1Smrg 11223ee3138f1Smrg 1122434977a2fSmrg# func_mode_uninstall arg... 1122534977a2fSmrgfunc_mode_uninstall () 1122634977a2fSmrg{ 11227fe24f8a2Smrg $debug_cmd 11228fe24f8a2Smrg 11229fe24f8a2Smrg RM=$nonopt 11230ee3138f1Smrg files= 11231fe24f8a2Smrg rmforce=false 11232ee3138f1Smrg exit_status=0 11233ee3138f1Smrg 11234ee3138f1Smrg # This variable tells wrapper scripts just to set variables rather 11235ee3138f1Smrg # than running their programs. 11236fe24f8a2Smrg libtool_install_magic=$magic 11237ee3138f1Smrg 11238ee3138f1Smrg for arg 11239ee3138f1Smrg do 11240ee3138f1Smrg case $arg in 11241fe24f8a2Smrg -f) func_append RM " $arg"; rmforce=: ;; 112423e72ca8cSmrg -*) func_append RM " $arg" ;; 112433e72ca8cSmrg *) func_append files " $arg" ;; 11244ee3138f1Smrg esac 11245ee3138f1Smrg done 11246ee3138f1Smrg 1124734977a2fSmrg test -z "$RM" && \ 1124834977a2fSmrg func_fatal_help "you must specify an RM program" 11249ee3138f1Smrg 11250ee3138f1Smrg rmdirs= 11251ee3138f1Smrg 11252ee3138f1Smrg for file in $files; do 1125334977a2fSmrg func_dirname "$file" "" "." 11254fe24f8a2Smrg dir=$func_dirname_result 11255fe24f8a2Smrg if test . = "$dir"; then 11256fe24f8a2Smrg odir=$objdir 11257ee3138f1Smrg else 11258fe24f8a2Smrg odir=$dir/$objdir 11259ee3138f1Smrg fi 1126034977a2fSmrg func_basename "$file" 11261fe24f8a2Smrg name=$func_basename_result 11262fe24f8a2Smrg test uninstall = "$opt_mode" && odir=$dir 11263ee3138f1Smrg 112643e72ca8cSmrg # Remember odir for removal later, being careful to avoid duplicates 11265fe24f8a2Smrg if test clean = "$opt_mode"; then 11266ee3138f1Smrg case " $rmdirs " in 112673e72ca8cSmrg *" $odir "*) ;; 112683e72ca8cSmrg *) func_append rmdirs " $odir" ;; 11269ee3138f1Smrg esac 11270ee3138f1Smrg fi 11271ee3138f1Smrg 11272ee3138f1Smrg # Don't error if the file doesn't exist and rm -f was used. 1127334977a2fSmrg if { test -L "$file"; } >/dev/null 2>&1 || 1127434977a2fSmrg { test -h "$file"; } >/dev/null 2>&1 || 1127534977a2fSmrg test -f "$file"; then 11276ee3138f1Smrg : 11277ee3138f1Smrg elif test -d "$file"; then 11278ee3138f1Smrg exit_status=1 11279ee3138f1Smrg continue 11280fe24f8a2Smrg elif $rmforce; then 11281ee3138f1Smrg continue 11282ee3138f1Smrg fi 11283ee3138f1Smrg 11284fe24f8a2Smrg rmfiles=$file 11285ee3138f1Smrg 11286ee3138f1Smrg case $name in 11287ee3138f1Smrg *.la) 11288ee3138f1Smrg # Possibly a libtool archive, so verify it. 1128934977a2fSmrg if func_lalib_p "$file"; then 1129034977a2fSmrg func_source $dir/$name 11291ee3138f1Smrg 11292ee3138f1Smrg # Delete the libtool libraries and symlinks. 11293ee3138f1Smrg for n in $library_names; do 112943e72ca8cSmrg func_append rmfiles " $odir/$n" 11295ee3138f1Smrg done 112963e72ca8cSmrg test -n "$old_library" && func_append rmfiles " $odir/$old_library" 11297ee3138f1Smrg 11298fe24f8a2Smrg case $opt_mode in 11299ee3138f1Smrg clean) 113003e72ca8cSmrg case " $library_names " in 11301ee3138f1Smrg *" $dlname "*) ;; 113023e72ca8cSmrg *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; 11303ee3138f1Smrg esac 113043e72ca8cSmrg test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" 11305ee3138f1Smrg ;; 11306ee3138f1Smrg uninstall) 11307ee3138f1Smrg if test -n "$library_names"; then 11308ee3138f1Smrg # Do each command in the postuninstall commands. 11309fe24f8a2Smrg func_execute_cmds "$postuninstall_cmds" '$rmforce || exit_status=1' 11310ee3138f1Smrg fi 11311ee3138f1Smrg 11312ee3138f1Smrg if test -n "$old_library"; then 11313ee3138f1Smrg # Do each command in the old_postuninstall commands. 11314fe24f8a2Smrg func_execute_cmds "$old_postuninstall_cmds" '$rmforce || exit_status=1' 11315ee3138f1Smrg fi 11316ee3138f1Smrg # FIXME: should reinstall the best remaining shared library. 11317ee3138f1Smrg ;; 11318ee3138f1Smrg esac 11319ee3138f1Smrg fi 11320ee3138f1Smrg ;; 11321ee3138f1Smrg 11322ee3138f1Smrg *.lo) 11323ee3138f1Smrg # Possibly a libtool object, so verify it. 1132434977a2fSmrg if func_lalib_p "$file"; then 11325ee3138f1Smrg 11326ee3138f1Smrg # Read the .lo file 1132734977a2fSmrg func_source $dir/$name 11328ee3138f1Smrg 11329ee3138f1Smrg # Add PIC object to the list of files to remove. 11330fe24f8a2Smrg if test -n "$pic_object" && test none != "$pic_object"; then 113313e72ca8cSmrg func_append rmfiles " $dir/$pic_object" 11332ee3138f1Smrg fi 11333ee3138f1Smrg 11334ee3138f1Smrg # Add non-PIC object to the list of files to remove. 11335fe24f8a2Smrg if test -n "$non_pic_object" && test none != "$non_pic_object"; then 113363e72ca8cSmrg func_append rmfiles " $dir/$non_pic_object" 11337ee3138f1Smrg fi 11338ee3138f1Smrg fi 11339ee3138f1Smrg ;; 11340ee3138f1Smrg 11341ee3138f1Smrg *) 11342fe24f8a2Smrg if test clean = "$opt_mode"; then 11343ee3138f1Smrg noexename=$name 11344ee3138f1Smrg case $file in 11345ee3138f1Smrg *.exe) 1134634977a2fSmrg func_stripname '' '.exe' "$file" 1134734977a2fSmrg file=$func_stripname_result 1134834977a2fSmrg func_stripname '' '.exe' "$name" 1134934977a2fSmrg noexename=$func_stripname_result 11350ee3138f1Smrg # $file with .exe has already been added to rmfiles, 11351ee3138f1Smrg # add $file without .exe 113523e72ca8cSmrg func_append rmfiles " $file" 11353ee3138f1Smrg ;; 11354ee3138f1Smrg esac 11355ee3138f1Smrg # Do a test to see if this is a libtool program. 1135634977a2fSmrg if func_ltwrapper_p "$file"; then 1135734977a2fSmrg if func_ltwrapper_executable_p "$file"; then 1135834977a2fSmrg func_ltwrapper_scriptname "$file" 1135934977a2fSmrg relink_command= 1136034977a2fSmrg func_source $func_ltwrapper_scriptname_result 113613e72ca8cSmrg func_append rmfiles " $func_ltwrapper_scriptname_result" 1136234977a2fSmrg else 1136334977a2fSmrg relink_command= 1136434977a2fSmrg func_source $dir/$noexename 1136534977a2fSmrg fi 11366ee3138f1Smrg 11367ee3138f1Smrg # note $name still contains .exe if it was in $file originally 11368ee3138f1Smrg # as does the version of $file that was added into $rmfiles 11369fe24f8a2Smrg func_append rmfiles " $odir/$name $odir/${name}S.$objext" 11370fe24f8a2Smrg if test yes = "$fast_install" && test -n "$relink_command"; then 113713e72ca8cSmrg func_append rmfiles " $odir/lt-$name" 11372ee3138f1Smrg fi 11373fe24f8a2Smrg if test "X$noexename" != "X$name"; then 11374fe24f8a2Smrg func_append rmfiles " $odir/lt-$noexename.c" 11375ee3138f1Smrg fi 11376ee3138f1Smrg fi 11377ee3138f1Smrg fi 11378ee3138f1Smrg ;; 11379ee3138f1Smrg esac 1138034977a2fSmrg func_show_eval "$RM $rmfiles" 'exit_status=1' 11381ee3138f1Smrg done 11382ee3138f1Smrg 11383fe24f8a2Smrg # Try to remove the $objdir's in the directories where we deleted files 11384ee3138f1Smrg for dir in $rmdirs; do 11385ee3138f1Smrg if test -d "$dir"; then 1138634977a2fSmrg func_show_eval "rmdir $dir >/dev/null 2>&1" 11387ee3138f1Smrg fi 11388ee3138f1Smrg done 11389ee3138f1Smrg 11390ee3138f1Smrg exit $exit_status 1139134977a2fSmrg} 11392ee3138f1Smrg 11393fe24f8a2Smrgif test uninstall = "$opt_mode" || test clean = "$opt_mode"; then 11394fe24f8a2Smrg func_mode_uninstall ${1+"$@"} 11395fe24f8a2Smrgfi 11396ee3138f1Smrg 113973e72ca8cSmrgtest -z "$opt_mode" && { 11398fe24f8a2Smrg help=$generic_help 1139934977a2fSmrg func_fatal_help "you must specify a MODE" 1140034977a2fSmrg} 1140134977a2fSmrg 1140234977a2fSmrgtest -z "$exec_cmd" && \ 11403fe24f8a2Smrg func_fatal_help "invalid operation mode '$opt_mode'" 11404ee3138f1Smrg 11405ee3138f1Smrgif test -n "$exec_cmd"; then 1140634977a2fSmrg eval exec "$exec_cmd" 11407ee3138f1Smrg exit $EXIT_FAILURE 11408ee3138f1Smrgfi 11409ee3138f1Smrg 1141034977a2fSmrgexit $exit_status 11411ee3138f1Smrg 11412ee3138f1Smrg 11413ee3138f1Smrg# The TAGs below are defined such that we never get into a situation 11414fe24f8a2Smrg# where we disable both kinds of libraries. Given conflicting 11415ee3138f1Smrg# choices, we go for a static library, that is the most portable, 11416ee3138f1Smrg# since we can't tell whether shared libraries were disabled because 11417ee3138f1Smrg# the user asked for that or because the platform doesn't support 11418ee3138f1Smrg# them. This is particularly important on AIX, because we don't 11419ee3138f1Smrg# support having both static and shared libraries enabled at the same 11420ee3138f1Smrg# time on that platform, so we default to a shared-only configuration. 11421ee3138f1Smrg# If a disable-shared tag is given, we'll fallback to a static-only 11422ee3138f1Smrg# configuration. But we'll never go from static-only to shared-only. 11423ee3138f1Smrg 11424ee3138f1Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared 1142534977a2fSmrgbuild_libtool_libs=no 1142634977a2fSmrgbuild_old_libs=yes 11427ee3138f1Smrg# ### END LIBTOOL TAG CONFIG: disable-shared 11428ee3138f1Smrg 11429ee3138f1Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static 1143034977a2fSmrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` 11431ee3138f1Smrg# ### END LIBTOOL TAG CONFIG: disable-static 11432ee3138f1Smrg 11433ee3138f1Smrg# Local Variables: 11434ee3138f1Smrg# mode:shell-script 11435ee3138f1Smrg# sh-indentation:2 11436ee3138f1Smrg# End: 11437