10ea508b1Smrg#! /usr/bin/env sh 29d0ccd10Smrg## DO NOT EDIT - This file generated from ./build-aux/ltmain.in 30ea508b1Smrg## by inline-source v2019-02-19.15 4e169010aSmrg 50ea508b1Smrg# libtool (GNU libtool) 2.4.7 69d0ccd10Smrg# Provide generalized library-building support services. 7e169010aSmrg# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 8e169010aSmrg 90ea508b1Smrg# Copyright (C) 1996-2019, 2021-2022 Free Software Foundation, Inc. 10e169010aSmrg# This is free software; see the source for copying conditions. There is NO 11e169010aSmrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12e169010aSmrg 13e169010aSmrg# GNU Libtool is free software; you can redistribute it and/or modify 147914d74bSmrg# it under the terms of the GNU General Public License as published by 157914d74bSmrg# the Free Software Foundation; either version 2 of the License, or 167914d74bSmrg# (at your option) any later version. 177914d74bSmrg# 18e169010aSmrg# As a special exception to the GNU General Public License, 19e169010aSmrg# if you distribute this file as part of a program or library that 20e169010aSmrg# is built using GNU Libtool, you may include this file under the 21e169010aSmrg# same distribution terms that you use for the rest of that program. 22e169010aSmrg# 23e169010aSmrg# GNU Libtool is distributed in the hope that it will be useful, but 247914d74bSmrg# WITHOUT ANY WARRANTY; without even the implied warranty of 257914d74bSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 267914d74bSmrg# General Public License for more details. 277914d74bSmrg# 287914d74bSmrg# You should have received a copy of the GNU General Public License 299d0ccd10Smrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 30e169010aSmrg 31e169010aSmrg 32e8ead290SmrgPROGRAM=libtool 33e169010aSmrgPACKAGE=libtool 346b7436aeSmrgVERSION="2.4.7 Debian-2.4.7-7~deb12u1" 350ea508b1Smrgpackage_revision=2.4.7 36e169010aSmrg 379d0ccd10Smrg 389d0ccd10Smrg## ------ ## 399d0ccd10Smrg## Usage. ## 409d0ccd10Smrg## ------ ## 419d0ccd10Smrg 429d0ccd10Smrg# Run './libtool --help' for help with using this script from the 439d0ccd10Smrg# command line. 449d0ccd10Smrg 459d0ccd10Smrg 469d0ccd10Smrg## ------------------------------- ## 479d0ccd10Smrg## User overridable command paths. ## 489d0ccd10Smrg## ------------------------------- ## 499d0ccd10Smrg 509d0ccd10Smrg# After configure completes, it has a better idea of some of the 519d0ccd10Smrg# shell tools we need than the defaults used by the functions shared 529d0ccd10Smrg# with bootstrap, so set those here where they can still be over- 539d0ccd10Smrg# ridden by the user, but otherwise take precedence. 549d0ccd10Smrg 559d0ccd10Smrg: ${AUTOCONF="autoconf"} 569d0ccd10Smrg: ${AUTOMAKE="automake"} 579d0ccd10Smrg 589d0ccd10Smrg 599d0ccd10Smrg## -------------------------- ## 609d0ccd10Smrg## Source external libraries. ## 619d0ccd10Smrg## -------------------------- ## 629d0ccd10Smrg 639d0ccd10Smrg# Much of our low-level functionality needs to be sourced from external 649d0ccd10Smrg# libraries, which are installed to $pkgauxdir. 659d0ccd10Smrg 669d0ccd10Smrg# Set a version string for this script. 670ea508b1Smrgscriptversion=2019-02-19.15; # UTC 689d0ccd10Smrg 699d0ccd10Smrg# General shell script boiler plate, and helper functions. 709d0ccd10Smrg# Written by Gary V. Vaughan, 2004 719d0ccd10Smrg 720ea508b1Smrg# This is free software. There is NO warranty; not even for 730ea508b1Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 740ea508b1Smrg# 750ea508b1Smrg# Copyright (C) 2004-2019, 2021 Bootstrap Authors 760ea508b1Smrg# 770ea508b1Smrg# This file is dual licensed under the terms of the MIT license 780ea508b1Smrg# <https://opensource.org/license/MIT>, and GPL version 2 or later 790ea508b1Smrg# <http://www.gnu.org/licenses/gpl-2.0.html>. You must apply one of 800ea508b1Smrg# these licenses when using or redistributing this software or any of 810ea508b1Smrg# the files within it. See the URLs above, or the file `LICENSE` 820ea508b1Smrg# included in the Bootstrap distribution for the full license texts. 839d0ccd10Smrg 840ea508b1Smrg# Please report bugs or propose patches to: 850ea508b1Smrg# <https://github.com/gnulib-modules/bootstrap/issues> 869d0ccd10Smrg 879d0ccd10Smrg 889d0ccd10Smrg## ------ ## 899d0ccd10Smrg## Usage. ## 909d0ccd10Smrg## ------ ## 919d0ccd10Smrg 929d0ccd10Smrg# Evaluate this file near the top of your script to gain access to 939d0ccd10Smrg# the functions and variables defined here: 949d0ccd10Smrg# 959d0ccd10Smrg# . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh 969d0ccd10Smrg# 979d0ccd10Smrg# If you need to override any of the default environment variable 989d0ccd10Smrg# settings, do that before evaluating this file. 999d0ccd10Smrg 1009d0ccd10Smrg 1019d0ccd10Smrg## -------------------- ## 1029d0ccd10Smrg## Shell normalisation. ## 1039d0ccd10Smrg## -------------------- ## 1049d0ccd10Smrg 1059d0ccd10Smrg# Some shells need a little help to be as Bourne compatible as possible. 1069d0ccd10Smrg# Before doing anything else, make sure all that help has been provided! 1079d0ccd10Smrg 1089d0ccd10SmrgDUALCASE=1; export DUALCASE # for MKS sh 1099d0ccd10Smrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : 110e169010aSmrg emulate sh 111e169010aSmrg NULLCMD=: 1129d0ccd10Smrg # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which 113e169010aSmrg # is contrary to our usage. Disable this feature. 114e169010aSmrg alias -g '${1+"$@"}'='"$@"' 115e169010aSmrg setopt NO_GLOB_SUBST 116e169010aSmrgelse 1179d0ccd10Smrg case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac 118e169010aSmrgfi 119e8ead290Smrg 1209d0ccd10Smrg# NLS nuisances: We save the old values in case they are required later. 1219d0ccd10Smrg_G_user_locale= 1229d0ccd10Smrg_G_safe_locale= 1239d0ccd10Smrgfor _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 124e169010aSmrgdo 1259d0ccd10Smrg eval "if test set = \"\${$_G_var+set}\"; then 1269d0ccd10Smrg save_$_G_var=\$$_G_var 1279d0ccd10Smrg $_G_var=C 1289d0ccd10Smrg export $_G_var 1299d0ccd10Smrg _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\" 1309d0ccd10Smrg _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\" 131e169010aSmrg fi" 132e169010aSmrgdone 1330ea508b1Smrg# These NLS vars are set unconditionally (bootstrap issue #24). Unset those 1340ea508b1Smrg# in case the environment reset is needed later and the $save_* variant is not 1350ea508b1Smrg# defined (see the code above). 1360ea508b1SmrgLC_ALL=C 1370ea508b1SmrgLANGUAGE=C 1380ea508b1Smrgexport LANGUAGE LC_ALL 139e169010aSmrg 1409d0ccd10Smrg# Make sure IFS has a sensible default 1419d0ccd10Smrgsp=' ' 1429d0ccd10Smrgnl=' 1439d0ccd10Smrg' 1449d0ccd10SmrgIFS="$sp $nl" 1459d0ccd10Smrg 1469d0ccd10Smrg# There are apparently some retarded systems that use ';' as a PATH separator! 1479d0ccd10Smrgif test "${PATH_SEPARATOR+set}" != set; then 1489d0ccd10Smrg PATH_SEPARATOR=: 1499d0ccd10Smrg (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { 1509d0ccd10Smrg (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || 1519d0ccd10Smrg PATH_SEPARATOR=';' 1529d0ccd10Smrg } 1539d0ccd10Smrgfi 154e169010aSmrg 155e169010aSmrg 1560ea508b1Smrg# func_unset VAR 1570ea508b1Smrg# -------------- 1580ea508b1Smrg# Portably unset VAR. 1590ea508b1Smrg# In some shells, an 'unset VAR' statement leaves a non-zero return 1600ea508b1Smrg# status if VAR is already unset, which might be problematic if the 1610ea508b1Smrg# statement is used at the end of a function (thus poisoning its return 1620ea508b1Smrg# value) or when 'set -e' is active (causing even a spurious abort of 1630ea508b1Smrg# the script in this case). 1640ea508b1Smrgfunc_unset () 1650ea508b1Smrg{ 1660ea508b1Smrg { eval $1=; (eval unset $1) >/dev/null 2>&1 && eval unset $1 || : ; } 1670ea508b1Smrg} 1680ea508b1Smrg 1690ea508b1Smrg 1700ea508b1Smrg# Make sure CDPATH doesn't cause `cd` commands to output the target dir. 1710ea508b1Smrgfunc_unset CDPATH 1720ea508b1Smrg 1730ea508b1Smrg# Make sure ${,E,F}GREP behave sanely. 1740ea508b1Smrgfunc_unset GREP_OPTIONS 1750ea508b1Smrg 176e169010aSmrg 1779d0ccd10Smrg## ------------------------- ## 1789d0ccd10Smrg## Locate command utilities. ## 1799d0ccd10Smrg## ------------------------- ## 1809d0ccd10Smrg 1819d0ccd10Smrg 1829d0ccd10Smrg# func_executable_p FILE 1839d0ccd10Smrg# ---------------------- 1849d0ccd10Smrg# Check that FILE is an executable regular file. 1859d0ccd10Smrgfunc_executable_p () 1869d0ccd10Smrg{ 1879d0ccd10Smrg test -f "$1" && test -x "$1" 1889d0ccd10Smrg} 1899d0ccd10Smrg 1909d0ccd10Smrg 1919d0ccd10Smrg# func_path_progs PROGS_LIST CHECK_FUNC [PATH] 1929d0ccd10Smrg# -------------------------------------------- 1939d0ccd10Smrg# Search for either a program that responds to --version with output 1949d0ccd10Smrg# containing "GNU", or else returned by CHECK_FUNC otherwise, by 1959d0ccd10Smrg# trying all the directories in PATH with each of the elements of 1969d0ccd10Smrg# PROGS_LIST. 1979d0ccd10Smrg# 1989d0ccd10Smrg# CHECK_FUNC should accept the path to a candidate program, and 1999d0ccd10Smrg# set $func_check_prog_result if it truncates its output less than 2009d0ccd10Smrg# $_G_path_prog_max characters. 2019d0ccd10Smrgfunc_path_progs () 2029d0ccd10Smrg{ 2039d0ccd10Smrg _G_progs_list=$1 2049d0ccd10Smrg _G_check_func=$2 2059d0ccd10Smrg _G_PATH=${3-"$PATH"} 2069d0ccd10Smrg 2079d0ccd10Smrg _G_path_prog_max=0 2089d0ccd10Smrg _G_path_prog_found=false 2099d0ccd10Smrg _G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:} 2109d0ccd10Smrg for _G_dir in $_G_PATH; do 2119d0ccd10Smrg IFS=$_G_save_IFS 2129d0ccd10Smrg test -z "$_G_dir" && _G_dir=. 2139d0ccd10Smrg for _G_prog_name in $_G_progs_list; do 2149d0ccd10Smrg for _exeext in '' .EXE; do 2159d0ccd10Smrg _G_path_prog=$_G_dir/$_G_prog_name$_exeext 2169d0ccd10Smrg func_executable_p "$_G_path_prog" || continue 2179d0ccd10Smrg case `"$_G_path_prog" --version 2>&1` in 2189d0ccd10Smrg *GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;; 2199d0ccd10Smrg *) $_G_check_func $_G_path_prog 2209d0ccd10Smrg func_path_progs_result=$func_check_prog_result 2219d0ccd10Smrg ;; 2229d0ccd10Smrg esac 2239d0ccd10Smrg $_G_path_prog_found && break 3 2249d0ccd10Smrg done 2259d0ccd10Smrg done 2269d0ccd10Smrg done 2279d0ccd10Smrg IFS=$_G_save_IFS 2289d0ccd10Smrg test -z "$func_path_progs_result" && { 2299d0ccd10Smrg echo "no acceptable sed could be found in \$PATH" >&2 2309d0ccd10Smrg exit 1 2319d0ccd10Smrg } 2329d0ccd10Smrg} 2339d0ccd10Smrg 2349d0ccd10Smrg 2359d0ccd10Smrg# We want to be able to use the functions in this file before configure 2369d0ccd10Smrg# has figured out where the best binaries are kept, which means we have 2379d0ccd10Smrg# to search for them ourselves - except when the results are already set 2389d0ccd10Smrg# where we skip the searches. 2399d0ccd10Smrg 2409d0ccd10Smrg# Unless the user overrides by setting SED, search the path for either GNU 2419d0ccd10Smrg# sed, or the sed that truncates its output the least. 2429d0ccd10Smrgtest -z "$SED" && { 2439d0ccd10Smrg _G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ 2449d0ccd10Smrg for _G_i in 1 2 3 4 5 6 7; do 2459d0ccd10Smrg _G_sed_script=$_G_sed_script$nl$_G_sed_script 2469d0ccd10Smrg done 2479d0ccd10Smrg echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed 2489d0ccd10Smrg _G_sed_script= 2499d0ccd10Smrg 2509d0ccd10Smrg func_check_prog_sed () 2519d0ccd10Smrg { 2529d0ccd10Smrg _G_path_prog=$1 2539d0ccd10Smrg 2549d0ccd10Smrg _G_count=0 2559d0ccd10Smrg printf 0123456789 >conftest.in 2569d0ccd10Smrg while : 2579d0ccd10Smrg do 2589d0ccd10Smrg cat conftest.in conftest.in >conftest.tmp 2599d0ccd10Smrg mv conftest.tmp conftest.in 2609d0ccd10Smrg cp conftest.in conftest.nl 2619d0ccd10Smrg echo '' >> conftest.nl 2629d0ccd10Smrg "$_G_path_prog" -f conftest.sed <conftest.nl >conftest.out 2>/dev/null || break 2639d0ccd10Smrg diff conftest.out conftest.nl >/dev/null 2>&1 || break 2649d0ccd10Smrg _G_count=`expr $_G_count + 1` 2659d0ccd10Smrg if test "$_G_count" -gt "$_G_path_prog_max"; then 2669d0ccd10Smrg # Best one so far, save it but keep looking for a better one 2679d0ccd10Smrg func_check_prog_result=$_G_path_prog 2689d0ccd10Smrg _G_path_prog_max=$_G_count 2699d0ccd10Smrg fi 2709d0ccd10Smrg # 10*(2^10) chars as input seems more than enough 2719d0ccd10Smrg test 10 -lt "$_G_count" && break 2729d0ccd10Smrg done 2739d0ccd10Smrg rm -f conftest.in conftest.tmp conftest.nl conftest.out 2749d0ccd10Smrg } 2759d0ccd10Smrg 2760ea508b1Smrg func_path_progs "sed gsed" func_check_prog_sed "$PATH:/usr/xpg4/bin" 2779d0ccd10Smrg rm -f conftest.sed 2789d0ccd10Smrg SED=$func_path_progs_result 2799d0ccd10Smrg} 2809d0ccd10Smrg 2819d0ccd10Smrg 2829d0ccd10Smrg# Unless the user overrides by setting GREP, search the path for either GNU 2839d0ccd10Smrg# grep, or the grep that truncates its output the least. 2849d0ccd10Smrgtest -z "$GREP" && { 2859d0ccd10Smrg func_check_prog_grep () 2869d0ccd10Smrg { 2879d0ccd10Smrg _G_path_prog=$1 2889d0ccd10Smrg 2899d0ccd10Smrg _G_count=0 2909d0ccd10Smrg _G_path_prog_max=0 2919d0ccd10Smrg printf 0123456789 >conftest.in 2929d0ccd10Smrg while : 2939d0ccd10Smrg do 2949d0ccd10Smrg cat conftest.in conftest.in >conftest.tmp 2959d0ccd10Smrg mv conftest.tmp conftest.in 2969d0ccd10Smrg cp conftest.in conftest.nl 2979d0ccd10Smrg echo 'GREP' >> conftest.nl 2989d0ccd10Smrg "$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' <conftest.nl >conftest.out 2>/dev/null || break 2999d0ccd10Smrg diff conftest.out conftest.nl >/dev/null 2>&1 || break 3009d0ccd10Smrg _G_count=`expr $_G_count + 1` 3019d0ccd10Smrg if test "$_G_count" -gt "$_G_path_prog_max"; then 3029d0ccd10Smrg # Best one so far, save it but keep looking for a better one 3039d0ccd10Smrg func_check_prog_result=$_G_path_prog 3049d0ccd10Smrg _G_path_prog_max=$_G_count 3059d0ccd10Smrg fi 3069d0ccd10Smrg # 10*(2^10) chars as input seems more than enough 3079d0ccd10Smrg test 10 -lt "$_G_count" && break 3089d0ccd10Smrg done 3099d0ccd10Smrg rm -f conftest.in conftest.tmp conftest.nl conftest.out 3109d0ccd10Smrg } 3119d0ccd10Smrg 3120ea508b1Smrg func_path_progs "grep ggrep" func_check_prog_grep "$PATH:/usr/xpg4/bin" 3139d0ccd10Smrg GREP=$func_path_progs_result 3149d0ccd10Smrg} 3159d0ccd10Smrg 3169d0ccd10Smrg 3179d0ccd10Smrg## ------------------------------- ## 3189d0ccd10Smrg## User overridable command paths. ## 3199d0ccd10Smrg## ------------------------------- ## 3209d0ccd10Smrg 3219d0ccd10Smrg# All uppercase variable names are used for environment variables. These 3229d0ccd10Smrg# variables can be overridden by the user before calling a script that 3239d0ccd10Smrg# uses them if a suitable command of that name is not already available 3249d0ccd10Smrg# in the command search PATH. 325e169010aSmrg 326e169010aSmrg: ${CP="cp -f"} 3279d0ccd10Smrg: ${ECHO="printf %s\n"} 3289d0ccd10Smrg: ${EGREP="$GREP -E"} 3299d0ccd10Smrg: ${FGREP="$GREP -F"} 3309d0ccd10Smrg: ${LN_S="ln -s"} 331e169010aSmrg: ${MAKE="make"} 332e169010aSmrg: ${MKDIR="mkdir"} 333e169010aSmrg: ${MV="mv -f"} 334e169010aSmrg: ${RM="rm -f"} 335e169010aSmrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"} 336e169010aSmrg 337e169010aSmrg 3389d0ccd10Smrg## -------------------- ## 3399d0ccd10Smrg## Useful sed snippets. ## 3409d0ccd10Smrg## -------------------- ## 341c63293b5Smrg 3429d0ccd10Smrgsed_dirname='s|/[^/]*$||' 3439d0ccd10Smrgsed_basename='s|^.*/||' 344c63293b5Smrg 3459d0ccd10Smrg# Sed substitution that helps us do robust quoting. It backslashifies 3469d0ccd10Smrg# metacharacters that are still active within double-quoted strings. 3479d0ccd10Smrgsed_quote_subst='s|\([`"$\\]\)|\\\1|g' 348c63293b5Smrg 3499d0ccd10Smrg# Same as above, but do not quote variable references. 3509d0ccd10Smrgsed_double_quote_subst='s/\(["`\\]\)/\\\1/g' 351c63293b5Smrg 3529d0ccd10Smrg# Sed substitution that turns a string into a regex matching for the 3539d0ccd10Smrg# string literally. 3549d0ccd10Smrgsed_make_literal_regex='s|[].[^$\\*\/]|\\&|g' 355c63293b5Smrg 3569d0ccd10Smrg# Sed substitution that converts a w32 file name or path 3579d0ccd10Smrg# that contains forward slashes, into one that contains 3589d0ccd10Smrg# (escaped) backslashes. A very naive implementation. 3599d0ccd10Smrgsed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' 3609d0ccd10Smrg 3619d0ccd10Smrg# Re-'\' parameter expansions in output of sed_double_quote_subst that 3629d0ccd10Smrg# were '\'-ed in input to the same. If an odd number of '\' preceded a 3639d0ccd10Smrg# '$' in input to sed_double_quote_subst, that '$' was protected from 3649d0ccd10Smrg# expansion. Since each input '\' is now two '\'s, look for any number 3659d0ccd10Smrg# of runs of four '\'s followed by two '\'s and then a '$'. '\' that '$'. 3669d0ccd10Smrg_G_bs='\\' 3679d0ccd10Smrg_G_bs2='\\\\' 3689d0ccd10Smrg_G_bs4='\\\\\\\\' 3699d0ccd10Smrg_G_dollar='\$' 3709d0ccd10Smrgsed_double_backslash="\ 3719d0ccd10Smrg s/$_G_bs4/&\\ 3729d0ccd10Smrg/g 3739d0ccd10Smrg s/^$_G_bs2$_G_dollar/$_G_bs&/ 3749d0ccd10Smrg s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g 3759d0ccd10Smrg s/\n//g" 376c63293b5Smrg 3770ea508b1Smrg# require_check_ifs_backslash 3780ea508b1Smrg# --------------------------- 3790ea508b1Smrg# Check if we can use backslash as IFS='\' separator, and set 3800ea508b1Smrg# $check_ifs_backshlash_broken to ':' or 'false'. 3810ea508b1Smrgrequire_check_ifs_backslash=func_require_check_ifs_backslash 3820ea508b1Smrgfunc_require_check_ifs_backslash () 3830ea508b1Smrg{ 3840ea508b1Smrg _G_save_IFS=$IFS 3850ea508b1Smrg IFS='\' 3860ea508b1Smrg _G_check_ifs_backshlash='a\\b' 3870ea508b1Smrg for _G_i in $_G_check_ifs_backshlash 3880ea508b1Smrg do 3890ea508b1Smrg case $_G_i in 3900ea508b1Smrg a) 3910ea508b1Smrg check_ifs_backshlash_broken=false 3920ea508b1Smrg ;; 3930ea508b1Smrg '') 3940ea508b1Smrg break 3950ea508b1Smrg ;; 3960ea508b1Smrg *) 3970ea508b1Smrg check_ifs_backshlash_broken=: 3980ea508b1Smrg break 3990ea508b1Smrg ;; 4000ea508b1Smrg esac 4010ea508b1Smrg done 4020ea508b1Smrg IFS=$_G_save_IFS 4030ea508b1Smrg require_check_ifs_backslash=: 4040ea508b1Smrg} 4050ea508b1Smrg 406e169010aSmrg 4079d0ccd10Smrg## ----------------- ## 4089d0ccd10Smrg## Global variables. ## 4099d0ccd10Smrg## ----------------- ## 4107914d74bSmrg 4119d0ccd10Smrg# Except for the global variables explicitly listed below, the following 4129d0ccd10Smrg# functions in the '^func_' namespace, and the '^require_' namespace 4139d0ccd10Smrg# variables initialised in the 'Resource management' section, sourcing 4149d0ccd10Smrg# this file will not pollute your global namespace with anything 4159d0ccd10Smrg# else. There's no portable way to scope variables in Bourne shell 4169d0ccd10Smrg# though, so actually running these functions will sometimes place 4179d0ccd10Smrg# results into a variable named after the function, and often use 4189d0ccd10Smrg# temporary variables in the '^_G_' namespace. If you are careful to 4199d0ccd10Smrg# avoid using those namespaces casually in your sourcing script, things 4209d0ccd10Smrg# should continue to work as you expect. And, of course, you can freely 4219d0ccd10Smrg# overwrite any of the functions or variables defined here before 4229d0ccd10Smrg# calling anything to customize them. 423e8ead290Smrg 4249d0ccd10SmrgEXIT_SUCCESS=0 4259d0ccd10SmrgEXIT_FAILURE=1 4269d0ccd10SmrgEXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. 4279d0ccd10SmrgEXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. 428e8ead290Smrg 4299d0ccd10Smrg# Allow overriding, eg assuming that you follow the convention of 4309d0ccd10Smrg# putting '$debug_cmd' at the start of all your functions, you can get 4319d0ccd10Smrg# bash to show function call trace with: 4329d0ccd10Smrg# 4336b7436aeSmrg# debug_cmd='echo "${FUNCNAME[0]} $*" >&2' bash your-script-name 4349d0ccd10Smrgdebug_cmd=${debug_cmd-":"} 4359d0ccd10Smrgexit_cmd=: 436e8ead290Smrg 4379d0ccd10Smrg# By convention, finish your script with: 4389d0ccd10Smrg# 4399d0ccd10Smrg# exit $exit_status 4409d0ccd10Smrg# 4419d0ccd10Smrg# so that you can set exit_status to non-zero if you want to indicate 4429d0ccd10Smrg# something went wrong during execution without actually bailing out at 4439d0ccd10Smrg# the point of failure. 4449d0ccd10Smrgexit_status=$EXIT_SUCCESS 445e8ead290Smrg 4469d0ccd10Smrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh 4479d0ccd10Smrg# is ksh but when the shell is invoked as "sh" and the current value of 4489d0ccd10Smrg# the _XPG environment variable is not equal to 1 (one), the special 4499d0ccd10Smrg# positional parameter $0, within a function call, is the name of the 4509d0ccd10Smrg# function. 4519d0ccd10Smrgprogpath=$0 4527914d74bSmrg 4539d0ccd10Smrg# The name of this program. 4549d0ccd10Smrgprogname=`$ECHO "$progpath" |$SED "$sed_basename"` 4557914d74bSmrg 4569d0ccd10Smrg# Make sure we have an absolute progpath for reexecution: 457e169010aSmrgcase $progpath in 458e169010aSmrg [\\/]*|[A-Za-z]:\\*) ;; 459e169010aSmrg *[\\/]*) 4609d0ccd10Smrg progdir=`$ECHO "$progpath" |$SED "$sed_dirname"` 461e169010aSmrg progdir=`cd "$progdir" && pwd` 4629d0ccd10Smrg progpath=$progdir/$progname 463e169010aSmrg ;; 464e169010aSmrg *) 4659d0ccd10Smrg _G_IFS=$IFS 466e6d5e4e0Smrg IFS=${PATH_SEPARATOR-:} 467e169010aSmrg for progdir in $PATH; do 4689d0ccd10Smrg IFS=$_G_IFS 469e169010aSmrg test -x "$progdir/$progname" && break 470e169010aSmrg done 4719d0ccd10Smrg IFS=$_G_IFS 472e169010aSmrg test -n "$progdir" || progdir=`pwd` 4739d0ccd10Smrg progpath=$progdir/$progname 474e169010aSmrg ;; 475e169010aSmrgesac 4767914d74bSmrg 477e169010aSmrg 4789d0ccd10Smrg## ----------------- ## 4799d0ccd10Smrg## Standard options. ## 4809d0ccd10Smrg## ----------------- ## 481c63293b5Smrg 4829d0ccd10Smrg# The following options affect the operation of the functions defined 4839d0ccd10Smrg# below, and should be set appropriately depending on run-time para- 4849d0ccd10Smrg# meters passed on the command line. 485e169010aSmrg 486e169010aSmrgopt_dry_run=false 487e169010aSmrgopt_quiet=false 488e169010aSmrgopt_verbose=false 489e169010aSmrg 4909d0ccd10Smrg# Categories 'all' and 'none' are always available. Append any others 4919d0ccd10Smrg# you will pass as the first argument to func_warning from your own 4929d0ccd10Smrg# code. 4939d0ccd10Smrgwarning_categories= 4947914d74bSmrg 4959d0ccd10Smrg# By default, display warnings according to 'opt_warning_types'. Set 4969d0ccd10Smrg# 'warning_func' to ':' to elide all warnings, or func_fatal_error to 4979d0ccd10Smrg# treat the next displayed warning as a fatal error. 4989d0ccd10Smrgwarning_func=func_warn_and_continue 4997914d74bSmrg 5009d0ccd10Smrg# Set to 'all' to display all warnings, 'none' to suppress all 5019d0ccd10Smrg# warnings, or a space delimited list of some subset of 5029d0ccd10Smrg# 'warning_categories' to display only the listed warnings. 5039d0ccd10Smrgopt_warning_types=all 5047914d74bSmrg 505e8ead290Smrg 5069d0ccd10Smrg## -------------------- ## 5079d0ccd10Smrg## Resource management. ## 5089d0ccd10Smrg## -------------------- ## 5097914d74bSmrg 5109d0ccd10Smrg# This section contains definitions for functions that each ensure a 5119d0ccd10Smrg# particular resource (a file, or a non-empty configuration variable for 5129d0ccd10Smrg# example) is available, and if appropriate to extract default values 5139d0ccd10Smrg# from pertinent package files. Call them using their associated 5149d0ccd10Smrg# 'require_*' variable to ensure that they are executed, at most, once. 5159d0ccd10Smrg# 5169d0ccd10Smrg# It's entirely deliberate that calling these functions can set 5179d0ccd10Smrg# variables that don't obey the namespace limitations obeyed by the rest 5189d0ccd10Smrg# of this file, in order that that they be as useful as possible to 5199d0ccd10Smrg# callers. 5207914d74bSmrg 5217914d74bSmrg 5229d0ccd10Smrg# require_term_colors 5239d0ccd10Smrg# ------------------- 5249d0ccd10Smrg# Allow display of bold text on terminals that support it. 5259d0ccd10Smrgrequire_term_colors=func_require_term_colors 5269d0ccd10Smrgfunc_require_term_colors () 527e169010aSmrg{ 5289d0ccd10Smrg $debug_cmd 5299d0ccd10Smrg 5309d0ccd10Smrg test -t 1 && { 5319d0ccd10Smrg # COLORTERM and USE_ANSI_COLORS environment variables take 5329d0ccd10Smrg # precedence, because most terminfo databases neglect to describe 5339d0ccd10Smrg # whether color sequences are supported. 5349d0ccd10Smrg test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"} 5359d0ccd10Smrg 5369d0ccd10Smrg if test 1 = "$USE_ANSI_COLORS"; then 5379d0ccd10Smrg # Standard ANSI escape sequences 5389d0ccd10Smrg tc_reset='[0m' 5399d0ccd10Smrg tc_bold='[1m'; tc_standout='[7m' 5409d0ccd10Smrg tc_red='[31m'; tc_green='[32m' 5419d0ccd10Smrg tc_blue='[34m'; tc_cyan='[36m' 5429d0ccd10Smrg else 5439d0ccd10Smrg # Otherwise trust the terminfo database after all. 5449d0ccd10Smrg test -n "`tput sgr0 2>/dev/null`" && { 5459d0ccd10Smrg tc_reset=`tput sgr0` 5469d0ccd10Smrg test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold` 5479d0ccd10Smrg tc_standout=$tc_bold 5489d0ccd10Smrg test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso` 5499d0ccd10Smrg test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1` 5509d0ccd10Smrg test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2` 5519d0ccd10Smrg test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4` 5529d0ccd10Smrg test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5` 5539d0ccd10Smrg } 5549d0ccd10Smrg fi 5559d0ccd10Smrg } 5567914d74bSmrg 5579d0ccd10Smrg require_term_colors=: 558e169010aSmrg} 5597914d74bSmrg 5607914d74bSmrg 5619d0ccd10Smrg## ----------------- ## 5629d0ccd10Smrg## Function library. ## 5639d0ccd10Smrg## ----------------- ## 5649d0ccd10Smrg 5659d0ccd10Smrg# This section contains a variety of useful functions to call in your 5669d0ccd10Smrg# scripts. Take note of the portable wrappers for features provided by 5679d0ccd10Smrg# some modern shells, which will fall back to slower equivalents on 5689d0ccd10Smrg# less featureful shells. 5699d0ccd10Smrg 5709d0ccd10Smrg 5719d0ccd10Smrg# func_append VAR VALUE 5729d0ccd10Smrg# --------------------- 5739d0ccd10Smrg# Append VALUE onto the existing contents of VAR. 5749d0ccd10Smrg 5759d0ccd10Smrg # _G_HAVE_PLUSEQ_OP 5769d0ccd10Smrg # Can be empty, in which case the shell is probed, "yes" if += is 5779d0ccd10Smrg # useable or anything else if it does not work. 5786b7436aeSmrg if test -z "$_G_HAVE_PLUSEQ_OP" && \ 5796b7436aeSmrg __PLUSEQ_TEST="a" && \ 5806b7436aeSmrg __PLUSEQ_TEST+=" b" 2>/dev/null && \ 5816b7436aeSmrg test "a b" = "$__PLUSEQ_TEST"; then 5826b7436aeSmrg _G_HAVE_PLUSEQ_OP=yes 5836b7436aeSmrg fi 5849d0ccd10Smrg 5859d0ccd10Smrgif test yes = "$_G_HAVE_PLUSEQ_OP" 5869d0ccd10Smrgthen 5879d0ccd10Smrg # This is an XSI compatible shell, allowing a faster implementation... 5889d0ccd10Smrg eval 'func_append () 5899d0ccd10Smrg { 5909d0ccd10Smrg $debug_cmd 5919d0ccd10Smrg 5929d0ccd10Smrg eval "$1+=\$2" 5939d0ccd10Smrg }' 5949d0ccd10Smrgelse 5959d0ccd10Smrg # ...otherwise fall back to using expr, which is often a shell builtin. 5969d0ccd10Smrg func_append () 5979d0ccd10Smrg { 5989d0ccd10Smrg $debug_cmd 5999d0ccd10Smrg 6009d0ccd10Smrg eval "$1=\$$1\$2" 6019d0ccd10Smrg } 6029d0ccd10Smrgfi 6039d0ccd10Smrg 6049d0ccd10Smrg 6059d0ccd10Smrg# func_append_quoted VAR VALUE 6069d0ccd10Smrg# ---------------------------- 6079d0ccd10Smrg# Quote VALUE and append to the end of shell variable VAR, separated 6089d0ccd10Smrg# by a space. 6099d0ccd10Smrgif test yes = "$_G_HAVE_PLUSEQ_OP"; then 6109d0ccd10Smrg eval 'func_append_quoted () 6119d0ccd10Smrg { 6129d0ccd10Smrg $debug_cmd 6139d0ccd10Smrg 6140ea508b1Smrg func_quote_arg pretty "$2" 6150ea508b1Smrg eval "$1+=\\ \$func_quote_arg_result" 6169d0ccd10Smrg }' 6179d0ccd10Smrgelse 6189d0ccd10Smrg func_append_quoted () 6199d0ccd10Smrg { 6209d0ccd10Smrg $debug_cmd 6219d0ccd10Smrg 6220ea508b1Smrg func_quote_arg pretty "$2" 6230ea508b1Smrg eval "$1=\$$1\\ \$func_quote_arg_result" 6249d0ccd10Smrg } 6259d0ccd10Smrgfi 6269d0ccd10Smrg 6279d0ccd10Smrg 6289d0ccd10Smrg# func_append_uniq VAR VALUE 6299d0ccd10Smrg# -------------------------- 6309d0ccd10Smrg# Append unique VALUE onto the existing contents of VAR, assuming 6319d0ccd10Smrg# entries are delimited by the first character of VALUE. For example: 6329d0ccd10Smrg# 6339d0ccd10Smrg# func_append_uniq options " --another-option option-argument" 6349d0ccd10Smrg# 6359d0ccd10Smrg# will only append to $options if " --another-option option-argument " 6369d0ccd10Smrg# is not already present somewhere in $options already (note spaces at 6379d0ccd10Smrg# each end implied by leading space in second argument). 6389d0ccd10Smrgfunc_append_uniq () 6399d0ccd10Smrg{ 6409d0ccd10Smrg $debug_cmd 6419d0ccd10Smrg 6429d0ccd10Smrg eval _G_current_value='`$ECHO $'$1'`' 6439d0ccd10Smrg _G_delim=`expr "$2" : '\(.\)'` 6449d0ccd10Smrg 6459d0ccd10Smrg case $_G_delim$_G_current_value$_G_delim in 6469d0ccd10Smrg *"$2$_G_delim"*) ;; 6479d0ccd10Smrg *) func_append "$@" ;; 6489d0ccd10Smrg esac 6499d0ccd10Smrg} 6509d0ccd10Smrg 6519d0ccd10Smrg 6529d0ccd10Smrg# func_arith TERM... 6539d0ccd10Smrg# ------------------ 6549d0ccd10Smrg# Set func_arith_result to the result of evaluating TERMs. 6559d0ccd10Smrg test -z "$_G_HAVE_ARITH_OP" \ 6569d0ccd10Smrg && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \ 6579d0ccd10Smrg && _G_HAVE_ARITH_OP=yes 6589d0ccd10Smrg 6599d0ccd10Smrgif test yes = "$_G_HAVE_ARITH_OP"; then 6609d0ccd10Smrg eval 'func_arith () 6619d0ccd10Smrg { 6629d0ccd10Smrg $debug_cmd 6639d0ccd10Smrg 6649d0ccd10Smrg func_arith_result=$(( $* )) 6659d0ccd10Smrg }' 6669d0ccd10Smrgelse 6679d0ccd10Smrg func_arith () 6689d0ccd10Smrg { 6699d0ccd10Smrg $debug_cmd 6709d0ccd10Smrg 6719d0ccd10Smrg func_arith_result=`expr "$@"` 6729d0ccd10Smrg } 6739d0ccd10Smrgfi 6749d0ccd10Smrg 6759d0ccd10Smrg 6769d0ccd10Smrg# func_basename FILE 6779d0ccd10Smrg# ------------------ 6789d0ccd10Smrg# Set func_basename_result to FILE with everything up to and including 6799d0ccd10Smrg# the last / stripped. 6809d0ccd10Smrgif test yes = "$_G_HAVE_XSI_OPS"; then 6819d0ccd10Smrg # If this shell supports suffix pattern removal, then use it to avoid 6829d0ccd10Smrg # forking. Hide the definitions single quotes in case the shell chokes 6839d0ccd10Smrg # on unsupported syntax... 6849d0ccd10Smrg _b='func_basename_result=${1##*/}' 6859d0ccd10Smrg _d='case $1 in 6869d0ccd10Smrg */*) func_dirname_result=${1%/*}$2 ;; 6879d0ccd10Smrg * ) func_dirname_result=$3 ;; 6889d0ccd10Smrg esac' 6899d0ccd10Smrg 6909d0ccd10Smrgelse 6919d0ccd10Smrg # ...otherwise fall back to using sed. 6929d0ccd10Smrg _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`' 6939d0ccd10Smrg _d='func_dirname_result=`$ECHO "$1" |$SED "$sed_dirname"` 6949d0ccd10Smrg if test "X$func_dirname_result" = "X$1"; then 6959d0ccd10Smrg func_dirname_result=$3 6969d0ccd10Smrg else 6979d0ccd10Smrg func_append func_dirname_result "$2" 6989d0ccd10Smrg fi' 6999d0ccd10Smrgfi 7009d0ccd10Smrg 7019d0ccd10Smrgeval 'func_basename () 7029d0ccd10Smrg{ 7039d0ccd10Smrg $debug_cmd 7049d0ccd10Smrg 7059d0ccd10Smrg '"$_b"' 7069d0ccd10Smrg}' 7079d0ccd10Smrg 7089d0ccd10Smrg 7099d0ccd10Smrg# func_dirname FILE APPEND NONDIR_REPLACEMENT 7109d0ccd10Smrg# ------------------------------------------- 7119d0ccd10Smrg# Compute the dirname of FILE. If nonempty, add APPEND to the result, 7129d0ccd10Smrg# otherwise set result to NONDIR_REPLACEMENT. 7139d0ccd10Smrgeval 'func_dirname () 7149d0ccd10Smrg{ 7159d0ccd10Smrg $debug_cmd 7169d0ccd10Smrg 7179d0ccd10Smrg '"$_d"' 7189d0ccd10Smrg}' 7199d0ccd10Smrg 7209d0ccd10Smrg 7219d0ccd10Smrg# func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT 7229d0ccd10Smrg# -------------------------------------------------------- 7239d0ccd10Smrg# Perform func_basename and func_dirname in a single function 7249d0ccd10Smrg# call: 7259d0ccd10Smrg# dirname: Compute the dirname of FILE. If nonempty, 7269d0ccd10Smrg# add APPEND to the result, otherwise set result 7279d0ccd10Smrg# to NONDIR_REPLACEMENT. 7289d0ccd10Smrg# value returned in "$func_dirname_result" 7299d0ccd10Smrg# basename: Compute filename of FILE. 7309d0ccd10Smrg# value retuned in "$func_basename_result" 7319d0ccd10Smrg# For efficiency, we do not delegate to the functions above but instead 7329d0ccd10Smrg# duplicate the functionality here. 7339d0ccd10Smrgeval 'func_dirname_and_basename () 7349d0ccd10Smrg{ 7359d0ccd10Smrg $debug_cmd 7369d0ccd10Smrg 7379d0ccd10Smrg '"$_b"' 7389d0ccd10Smrg '"$_d"' 7399d0ccd10Smrg}' 7409d0ccd10Smrg 7419d0ccd10Smrg 7429d0ccd10Smrg# func_echo ARG... 7439d0ccd10Smrg# ---------------- 7449d0ccd10Smrg# Echo program name prefixed message. 7459d0ccd10Smrgfunc_echo () 7469d0ccd10Smrg{ 7479d0ccd10Smrg $debug_cmd 7489d0ccd10Smrg 7499d0ccd10Smrg _G_message=$* 7509d0ccd10Smrg 7519d0ccd10Smrg func_echo_IFS=$IFS 7529d0ccd10Smrg IFS=$nl 7539d0ccd10Smrg for _G_line in $_G_message; do 7549d0ccd10Smrg IFS=$func_echo_IFS 7559d0ccd10Smrg $ECHO "$progname: $_G_line" 7569d0ccd10Smrg done 7579d0ccd10Smrg IFS=$func_echo_IFS 7589d0ccd10Smrg} 7599d0ccd10Smrg 7609d0ccd10Smrg 7619d0ccd10Smrg# func_echo_all ARG... 7629d0ccd10Smrg# -------------------- 7639d0ccd10Smrg# Invoke $ECHO with all args, space-separated. 7649d0ccd10Smrgfunc_echo_all () 7659d0ccd10Smrg{ 7669d0ccd10Smrg $ECHO "$*" 7679d0ccd10Smrg} 7689d0ccd10Smrg 7699d0ccd10Smrg 7709d0ccd10Smrg# func_echo_infix_1 INFIX ARG... 7719d0ccd10Smrg# ------------------------------ 7729d0ccd10Smrg# Echo program name, followed by INFIX on the first line, with any 7739d0ccd10Smrg# additional lines not showing INFIX. 7749d0ccd10Smrgfunc_echo_infix_1 () 7759d0ccd10Smrg{ 7769d0ccd10Smrg $debug_cmd 7779d0ccd10Smrg 7789d0ccd10Smrg $require_term_colors 7799d0ccd10Smrg 7809d0ccd10Smrg _G_infix=$1; shift 7819d0ccd10Smrg _G_indent=$_G_infix 7829d0ccd10Smrg _G_prefix="$progname: $_G_infix: " 7839d0ccd10Smrg _G_message=$* 7849d0ccd10Smrg 7859d0ccd10Smrg # Strip color escape sequences before counting printable length 7869d0ccd10Smrg for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan" 7879d0ccd10Smrg do 7889d0ccd10Smrg test -n "$_G_tc" && { 7899d0ccd10Smrg _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"` 7909d0ccd10Smrg _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"` 7919d0ccd10Smrg } 7929d0ccd10Smrg done 7939d0ccd10Smrg _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`" " ## exclude from sc_prohibit_nested_quotes 7949d0ccd10Smrg 7959d0ccd10Smrg func_echo_infix_1_IFS=$IFS 7969d0ccd10Smrg IFS=$nl 7979d0ccd10Smrg for _G_line in $_G_message; do 7989d0ccd10Smrg IFS=$func_echo_infix_1_IFS 7999d0ccd10Smrg $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2 8009d0ccd10Smrg _G_prefix=$_G_indent 8019d0ccd10Smrg done 8029d0ccd10Smrg IFS=$func_echo_infix_1_IFS 8039d0ccd10Smrg} 8049d0ccd10Smrg 8059d0ccd10Smrg 8069d0ccd10Smrg# func_error ARG... 8079d0ccd10Smrg# ----------------- 8089d0ccd10Smrg# Echo program name prefixed message to standard error. 8099d0ccd10Smrgfunc_error () 8109d0ccd10Smrg{ 8119d0ccd10Smrg $debug_cmd 8129d0ccd10Smrg 8139d0ccd10Smrg $require_term_colors 8149d0ccd10Smrg 8159d0ccd10Smrg func_echo_infix_1 " $tc_standout${tc_red}error$tc_reset" "$*" >&2 8169d0ccd10Smrg} 8179d0ccd10Smrg 8189d0ccd10Smrg 8199d0ccd10Smrg# func_fatal_error ARG... 8209d0ccd10Smrg# ----------------------- 8219d0ccd10Smrg# Echo program name prefixed message to standard error, and exit. 8229d0ccd10Smrgfunc_fatal_error () 8239d0ccd10Smrg{ 8249d0ccd10Smrg $debug_cmd 8259d0ccd10Smrg 8269d0ccd10Smrg func_error "$*" 8279d0ccd10Smrg exit $EXIT_FAILURE 8289d0ccd10Smrg} 8299d0ccd10Smrg 8309d0ccd10Smrg 8319d0ccd10Smrg# func_grep EXPRESSION FILENAME 8329d0ccd10Smrg# ----------------------------- 833e169010aSmrg# Check whether EXPRESSION matches any line of FILENAME, without output. 834e169010aSmrgfunc_grep () 835e169010aSmrg{ 8369d0ccd10Smrg $debug_cmd 8379d0ccd10Smrg 838e169010aSmrg $GREP "$1" "$2" >/dev/null 2>&1 839e169010aSmrg} 840e169010aSmrg 841e169010aSmrg 8429d0ccd10Smrg# func_len STRING 8439d0ccd10Smrg# --------------- 8449d0ccd10Smrg# Set func_len_result to the length of STRING. STRING may not 8459d0ccd10Smrg# start with a hyphen. 8469d0ccd10Smrg test -z "$_G_HAVE_XSI_OPS" \ 8479d0ccd10Smrg && (eval 'x=a/b/c; 8489d0ccd10Smrg test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ 8499d0ccd10Smrg && _G_HAVE_XSI_OPS=yes 8509d0ccd10Smrg 8519d0ccd10Smrgif test yes = "$_G_HAVE_XSI_OPS"; then 8529d0ccd10Smrg eval 'func_len () 8539d0ccd10Smrg { 8549d0ccd10Smrg $debug_cmd 8559d0ccd10Smrg 8569d0ccd10Smrg func_len_result=${#1} 8579d0ccd10Smrg }' 8589d0ccd10Smrgelse 8599d0ccd10Smrg func_len () 8609d0ccd10Smrg { 8619d0ccd10Smrg $debug_cmd 8629d0ccd10Smrg 8639d0ccd10Smrg func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len` 8649d0ccd10Smrg } 8659d0ccd10Smrgfi 8669d0ccd10Smrg 8679d0ccd10Smrg 8689d0ccd10Smrg# func_mkdir_p DIRECTORY-PATH 8699d0ccd10Smrg# --------------------------- 870e169010aSmrg# Make sure the entire path to DIRECTORY-PATH is available. 871e169010aSmrgfunc_mkdir_p () 872e169010aSmrg{ 8739d0ccd10Smrg $debug_cmd 8749d0ccd10Smrg 8759d0ccd10Smrg _G_directory_path=$1 8769d0ccd10Smrg _G_dir_list= 877e169010aSmrg 8789d0ccd10Smrg if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then 879e169010aSmrg 8809d0ccd10Smrg # Protect directory names starting with '-' 8819d0ccd10Smrg case $_G_directory_path in 8829d0ccd10Smrg -*) _G_directory_path=./$_G_directory_path ;; 883e169010aSmrg esac 884e169010aSmrg 885e169010aSmrg # While some portion of DIR does not yet exist... 8869d0ccd10Smrg while test ! -d "$_G_directory_path"; do 887e169010aSmrg # ...make a list in topmost first order. Use a colon delimited 888e169010aSmrg # list incase some portion of path contains whitespace. 8899d0ccd10Smrg _G_dir_list=$_G_directory_path:$_G_dir_list 890e169010aSmrg 891e169010aSmrg # If the last portion added has no slash in it, the list is done 8929d0ccd10Smrg case $_G_directory_path in */*) ;; *) break ;; esac 893e169010aSmrg 894e169010aSmrg # ...otherwise throw away the child directory and loop 8959d0ccd10Smrg _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"` 896e169010aSmrg done 8979d0ccd10Smrg _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'` 898e169010aSmrg 8999d0ccd10Smrg func_mkdir_p_IFS=$IFS; IFS=: 9009d0ccd10Smrg for _G_dir in $_G_dir_list; do 9019d0ccd10Smrg IFS=$func_mkdir_p_IFS 9029d0ccd10Smrg # mkdir can fail with a 'File exist' error if two processes 903e169010aSmrg # try to create one of the directories concurrently. Don't 904e169010aSmrg # stop in that case! 9059d0ccd10Smrg $MKDIR "$_G_dir" 2>/dev/null || : 906e169010aSmrg done 9079d0ccd10Smrg IFS=$func_mkdir_p_IFS 908e169010aSmrg 909e169010aSmrg # Bail out if we (or some other process) failed to create a directory. 9109d0ccd10Smrg test -d "$_G_directory_path" || \ 9119d0ccd10Smrg func_fatal_error "Failed to create '$1'" 912e169010aSmrg fi 913e169010aSmrg} 9147914d74bSmrg 9157914d74bSmrg 9169d0ccd10Smrg# func_mktempdir [BASENAME] 9179d0ccd10Smrg# ------------------------- 9187914d74bSmrg# Make a temporary directory that won't clash with other running 9197914d74bSmrg# libtool processes, and avoids race conditions if possible. If 9209d0ccd10Smrg# given, BASENAME is the basename for that directory. 9217914d74bSmrgfunc_mktempdir () 9227914d74bSmrg{ 9239d0ccd10Smrg $debug_cmd 9249d0ccd10Smrg 9259d0ccd10Smrg _G_template=${TMPDIR-/tmp}/${1-$progname} 9267914d74bSmrg 9279d0ccd10Smrg if test : = "$opt_dry_run"; then 9287914d74bSmrg # Return a directory name, but don't create it in dry-run mode 9299d0ccd10Smrg _G_tmpdir=$_G_template-$$ 9307914d74bSmrg else 9317914d74bSmrg 9327914d74bSmrg # If mktemp works, use that first and foremost 9339d0ccd10Smrg _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null` 9347914d74bSmrg 9359d0ccd10Smrg if test ! -d "$_G_tmpdir"; then 936e169010aSmrg # Failing that, at least try and use $RANDOM to avoid a race 9379d0ccd10Smrg _G_tmpdir=$_G_template-${RANDOM-0}$$ 9387914d74bSmrg 9399d0ccd10Smrg func_mktempdir_umask=`umask` 940e169010aSmrg umask 0077 9419d0ccd10Smrg $MKDIR "$_G_tmpdir" 9429d0ccd10Smrg umask $func_mktempdir_umask 9437914d74bSmrg fi 9447914d74bSmrg 9457914d74bSmrg # If we're not in dry-run mode, bomb out on failure 9469d0ccd10Smrg test -d "$_G_tmpdir" || \ 9479d0ccd10Smrg func_fatal_error "cannot create temporary directory '$_G_tmpdir'" 9487914d74bSmrg fi 9497914d74bSmrg 9509d0ccd10Smrg $ECHO "$_G_tmpdir" 9517914d74bSmrg} 9527914d74bSmrg 9537914d74bSmrg 9549d0ccd10Smrg# func_normal_abspath PATH 9559d0ccd10Smrg# ------------------------ 9569d0ccd10Smrg# Remove doubled-up and trailing slashes, "." path components, 9579d0ccd10Smrg# and cancel out any ".." path components in PATH after making 9589d0ccd10Smrg# it an absolute path. 9599d0ccd10Smrgfunc_normal_abspath () 9607914d74bSmrg{ 9619d0ccd10Smrg $debug_cmd 962e169010aSmrg 9639d0ccd10Smrg # These SED scripts presuppose an absolute path with a trailing slash. 9649d0ccd10Smrg _G_pathcar='s|^/\([^/]*\).*$|\1|' 9659d0ccd10Smrg _G_pathcdr='s|^/[^/]*||' 9669d0ccd10Smrg _G_removedotparts=':dotsl 9679d0ccd10Smrg s|/\./|/|g 9689d0ccd10Smrg t dotsl 9699d0ccd10Smrg s|/\.$|/|' 9709d0ccd10Smrg _G_collapseslashes='s|/\{1,\}|/|g' 9719d0ccd10Smrg _G_finalslash='s|/*$|/|' 9729d0ccd10Smrg 9739d0ccd10Smrg # Start from root dir and reassemble the path. 9749d0ccd10Smrg func_normal_abspath_result= 9759d0ccd10Smrg func_normal_abspath_tpath=$1 9769d0ccd10Smrg func_normal_abspath_altnamespace= 9779d0ccd10Smrg case $func_normal_abspath_tpath in 9789d0ccd10Smrg "") 9799d0ccd10Smrg # Empty path, that just means $cwd. 9809d0ccd10Smrg func_stripname '' '/' "`pwd`" 9819d0ccd10Smrg func_normal_abspath_result=$func_stripname_result 9829d0ccd10Smrg return 9839d0ccd10Smrg ;; 9849d0ccd10Smrg # The next three entries are used to spot a run of precisely 9859d0ccd10Smrg # two leading slashes without using negated character classes; 9869d0ccd10Smrg # we take advantage of case's first-match behaviour. 9879d0ccd10Smrg ///*) 9889d0ccd10Smrg # Unusual form of absolute path, do nothing. 9899d0ccd10Smrg ;; 9909d0ccd10Smrg //*) 9919d0ccd10Smrg # Not necessarily an ordinary path; POSIX reserves leading '//' 9929d0ccd10Smrg # and for example Cygwin uses it to access remote file shares 9939d0ccd10Smrg # over CIFS/SMB, so we conserve a leading double slash if found. 9949d0ccd10Smrg func_normal_abspath_altnamespace=/ 9959d0ccd10Smrg ;; 9969d0ccd10Smrg /*) 9979d0ccd10Smrg # Absolute path, do nothing. 998e169010aSmrg ;; 999e169010aSmrg *) 10009d0ccd10Smrg # Relative path, prepend $cwd. 10019d0ccd10Smrg func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath 10029d0ccd10Smrg ;; 10037914d74bSmrg esac 10049d0ccd10Smrg 10059d0ccd10Smrg # Cancel out all the simple stuff to save iterations. We also want 10069d0ccd10Smrg # the path to end with a slash for ease of parsing, so make sure 10079d0ccd10Smrg # there is one (and only one) here. 10089d0ccd10Smrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 10099d0ccd10Smrg -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"` 10109d0ccd10Smrg while :; do 10119d0ccd10Smrg # Processed it all yet? 10129d0ccd10Smrg if test / = "$func_normal_abspath_tpath"; then 10139d0ccd10Smrg # If we ascended to the root using ".." the result may be empty now. 10149d0ccd10Smrg if test -z "$func_normal_abspath_result"; then 10159d0ccd10Smrg func_normal_abspath_result=/ 10169d0ccd10Smrg fi 10179d0ccd10Smrg break 10189d0ccd10Smrg fi 10199d0ccd10Smrg func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ 10209d0ccd10Smrg -e "$_G_pathcar"` 10219d0ccd10Smrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 10229d0ccd10Smrg -e "$_G_pathcdr"` 10239d0ccd10Smrg # Figure out what to do with it 10249d0ccd10Smrg case $func_normal_abspath_tcomponent in 10259d0ccd10Smrg "") 10269d0ccd10Smrg # Trailing empty path component, ignore it. 10279d0ccd10Smrg ;; 10289d0ccd10Smrg ..) 10299d0ccd10Smrg # Parent dir; strip last assembled component from result. 10309d0ccd10Smrg func_dirname "$func_normal_abspath_result" 10319d0ccd10Smrg func_normal_abspath_result=$func_dirname_result 10329d0ccd10Smrg ;; 10339d0ccd10Smrg *) 10349d0ccd10Smrg # Actual path component, append it. 10359d0ccd10Smrg func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent" 10369d0ccd10Smrg ;; 10379d0ccd10Smrg esac 10389d0ccd10Smrg done 10399d0ccd10Smrg # Restore leading double-slash if one was found on entry. 10409d0ccd10Smrg func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result 10419d0ccd10Smrg} 10429d0ccd10Smrg 10439d0ccd10Smrg 10449d0ccd10Smrg# func_notquiet ARG... 10459d0ccd10Smrg# -------------------- 10469d0ccd10Smrg# Echo program name prefixed message only when not in quiet mode. 10479d0ccd10Smrgfunc_notquiet () 10489d0ccd10Smrg{ 10499d0ccd10Smrg $debug_cmd 10509d0ccd10Smrg 10519d0ccd10Smrg $opt_quiet || func_echo ${1+"$@"} 10529d0ccd10Smrg 10539d0ccd10Smrg # A bug in bash halts the script if the last line of a function 10549d0ccd10Smrg # fails when set -e is in force, so we need another command to 10559d0ccd10Smrg # work around that: 10569d0ccd10Smrg : 10579d0ccd10Smrg} 10589d0ccd10Smrg 10599d0ccd10Smrg 10609d0ccd10Smrg# func_relative_path SRCDIR DSTDIR 10619d0ccd10Smrg# -------------------------------- 10629d0ccd10Smrg# Set func_relative_path_result to the relative path from SRCDIR to DSTDIR. 10639d0ccd10Smrgfunc_relative_path () 10649d0ccd10Smrg{ 10659d0ccd10Smrg $debug_cmd 10669d0ccd10Smrg 10679d0ccd10Smrg func_relative_path_result= 10689d0ccd10Smrg func_normal_abspath "$1" 10699d0ccd10Smrg func_relative_path_tlibdir=$func_normal_abspath_result 10709d0ccd10Smrg func_normal_abspath "$2" 10719d0ccd10Smrg func_relative_path_tbindir=$func_normal_abspath_result 10729d0ccd10Smrg 10739d0ccd10Smrg # Ascend the tree starting from libdir 10749d0ccd10Smrg while :; do 10759d0ccd10Smrg # check if we have found a prefix of bindir 10769d0ccd10Smrg case $func_relative_path_tbindir in 10779d0ccd10Smrg $func_relative_path_tlibdir) 10789d0ccd10Smrg # found an exact match 10799d0ccd10Smrg func_relative_path_tcancelled= 10809d0ccd10Smrg break 10819d0ccd10Smrg ;; 10829d0ccd10Smrg $func_relative_path_tlibdir*) 10839d0ccd10Smrg # found a matching prefix 10849d0ccd10Smrg func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" 10859d0ccd10Smrg func_relative_path_tcancelled=$func_stripname_result 10869d0ccd10Smrg if test -z "$func_relative_path_result"; then 10879d0ccd10Smrg func_relative_path_result=. 10889d0ccd10Smrg fi 10899d0ccd10Smrg break 10909d0ccd10Smrg ;; 10919d0ccd10Smrg *) 10929d0ccd10Smrg func_dirname $func_relative_path_tlibdir 10939d0ccd10Smrg func_relative_path_tlibdir=$func_dirname_result 10949d0ccd10Smrg if test -z "$func_relative_path_tlibdir"; then 10959d0ccd10Smrg # Have to descend all the way to the root! 10969d0ccd10Smrg func_relative_path_result=../$func_relative_path_result 10979d0ccd10Smrg func_relative_path_tcancelled=$func_relative_path_tbindir 10989d0ccd10Smrg break 10999d0ccd10Smrg fi 11009d0ccd10Smrg func_relative_path_result=../$func_relative_path_result 11019d0ccd10Smrg ;; 11029d0ccd10Smrg esac 11039d0ccd10Smrg done 11049d0ccd10Smrg 11059d0ccd10Smrg # Now calculate path; take care to avoid doubling-up slashes. 11069d0ccd10Smrg func_stripname '' '/' "$func_relative_path_result" 11079d0ccd10Smrg func_relative_path_result=$func_stripname_result 11089d0ccd10Smrg func_stripname '/' '/' "$func_relative_path_tcancelled" 11099d0ccd10Smrg if test -n "$func_stripname_result"; then 11109d0ccd10Smrg func_append func_relative_path_result "/$func_stripname_result" 11119d0ccd10Smrg fi 11129d0ccd10Smrg 11139d0ccd10Smrg # Normalisation. If bindir is libdir, return '.' else relative path. 11149d0ccd10Smrg if test -n "$func_relative_path_result"; then 11159d0ccd10Smrg func_stripname './' '' "$func_relative_path_result" 11169d0ccd10Smrg func_relative_path_result=$func_stripname_result 11179d0ccd10Smrg fi 11189d0ccd10Smrg 11199d0ccd10Smrg test -n "$func_relative_path_result" || func_relative_path_result=. 11209d0ccd10Smrg 11219d0ccd10Smrg : 11227914d74bSmrg} 11237914d74bSmrg 11247914d74bSmrg 11250ea508b1Smrg# func_quote_portable EVAL ARG 11260ea508b1Smrg# ---------------------------- 11270ea508b1Smrg# Internal function to portably implement func_quote_arg. Note that we still 11280ea508b1Smrg# keep attention to performance here so we as much as possible try to avoid 11290ea508b1Smrg# calling sed binary (so far O(N) complexity as long as func_append is O(1)). 11300ea508b1Smrgfunc_quote_portable () 11319d0ccd10Smrg{ 11329d0ccd10Smrg $debug_cmd 11339d0ccd10Smrg 11340ea508b1Smrg $require_check_ifs_backslash 11350ea508b1Smrg 11360ea508b1Smrg func_quote_portable_result=$2 11370ea508b1Smrg 11380ea508b1Smrg # one-time-loop (easy break) 11390ea508b1Smrg while true 11400ea508b1Smrg do 11410ea508b1Smrg if $1; then 11420ea508b1Smrg func_quote_portable_result=`$ECHO "$2" | $SED \ 11430ea508b1Smrg -e "$sed_double_quote_subst" -e "$sed_double_backslash"` 11440ea508b1Smrg break 11459d0ccd10Smrg fi 11469d0ccd10Smrg 11470ea508b1Smrg # Quote for eval. 11480ea508b1Smrg case $func_quote_portable_result in 11490ea508b1Smrg *[\\\`\"\$]*) 11500ea508b1Smrg # Fallback to sed for $func_check_bs_ifs_broken=:, or when the string 11510ea508b1Smrg # contains the shell wildcard characters. 11520ea508b1Smrg case $check_ifs_backshlash_broken$func_quote_portable_result in 11530ea508b1Smrg :*|*[\[\*\?]*) 11540ea508b1Smrg func_quote_portable_result=`$ECHO "$func_quote_portable_result" \ 11550ea508b1Smrg | $SED "$sed_quote_subst"` 11560ea508b1Smrg break 11570ea508b1Smrg ;; 11580ea508b1Smrg esac 11590ea508b1Smrg 11600ea508b1Smrg func_quote_portable_old_IFS=$IFS 11610ea508b1Smrg for _G_char in '\' '`' '"' '$' 11620ea508b1Smrg do 11630ea508b1Smrg # STATE($1) PREV($2) SEPARATOR($3) 11640ea508b1Smrg set start "" "" 11650ea508b1Smrg func_quote_portable_result=dummy"$_G_char$func_quote_portable_result$_G_char"dummy 11660ea508b1Smrg IFS=$_G_char 11670ea508b1Smrg for _G_part in $func_quote_portable_result 11680ea508b1Smrg do 11690ea508b1Smrg case $1 in 11700ea508b1Smrg quote) 11710ea508b1Smrg func_append func_quote_portable_result "$3$2" 11720ea508b1Smrg set quote "$_G_part" "\\$_G_char" 11730ea508b1Smrg ;; 11740ea508b1Smrg start) 11750ea508b1Smrg set first "" "" 11760ea508b1Smrg func_quote_portable_result= 11770ea508b1Smrg ;; 11780ea508b1Smrg first) 11790ea508b1Smrg set quote "$_G_part" "" 11800ea508b1Smrg ;; 11810ea508b1Smrg esac 11820ea508b1Smrg done 11830ea508b1Smrg done 11840ea508b1Smrg IFS=$func_quote_portable_old_IFS 11859d0ccd10Smrg ;; 11860ea508b1Smrg *) ;; 11879d0ccd10Smrg esac 11880ea508b1Smrg break 11899d0ccd10Smrg done 11900ea508b1Smrg 11910ea508b1Smrg func_quote_portable_unquoted_result=$func_quote_portable_result 11920ea508b1Smrg case $func_quote_portable_result in 11930ea508b1Smrg # double-quote args containing shell metacharacters to delay 11940ea508b1Smrg # word splitting, command substitution and variable expansion 11950ea508b1Smrg # for a subsequent eval. 11960ea508b1Smrg # many bourne shells cannot handle close brackets correctly 11970ea508b1Smrg # in scan sets, so we specify it separately. 11980ea508b1Smrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 11990ea508b1Smrg func_quote_portable_result=\"$func_quote_portable_result\" 12000ea508b1Smrg ;; 12010ea508b1Smrg esac 12029d0ccd10Smrg} 12039d0ccd10Smrg 12049d0ccd10Smrg 12050ea508b1Smrg# func_quotefast_eval ARG 12060ea508b1Smrg# ----------------------- 12070ea508b1Smrg# Quote one ARG (internal). This is equivalent to 'func_quote_arg eval ARG', 12080ea508b1Smrg# but optimized for speed. Result is stored in $func_quotefast_eval. 12090ea508b1Smrgif test xyes = `(x=; printf -v x %q yes; echo x"$x") 2>/dev/null`; then 12100ea508b1Smrg printf -v _GL_test_printf_tilde %q '~' 12110ea508b1Smrg if test '\~' = "$_GL_test_printf_tilde"; then 12120ea508b1Smrg func_quotefast_eval () 12130ea508b1Smrg { 12140ea508b1Smrg printf -v func_quotefast_eval_result %q "$1" 12150ea508b1Smrg } 12160ea508b1Smrg else 12170ea508b1Smrg # Broken older Bash implementations. Make those faster too if possible. 12180ea508b1Smrg func_quotefast_eval () 12190ea508b1Smrg { 12200ea508b1Smrg case $1 in 12210ea508b1Smrg '~'*) 12220ea508b1Smrg func_quote_portable false "$1" 12230ea508b1Smrg func_quotefast_eval_result=$func_quote_portable_result 12240ea508b1Smrg ;; 12250ea508b1Smrg *) 12260ea508b1Smrg printf -v func_quotefast_eval_result %q "$1" 12270ea508b1Smrg ;; 12280ea508b1Smrg esac 12290ea508b1Smrg } 12300ea508b1Smrg fi 12310ea508b1Smrgelse 12320ea508b1Smrg func_quotefast_eval () 12330ea508b1Smrg { 12340ea508b1Smrg func_quote_portable false "$1" 12350ea508b1Smrg func_quotefast_eval_result=$func_quote_portable_result 12360ea508b1Smrg } 12370ea508b1Smrgfi 12389d0ccd10Smrg 12390ea508b1Smrg 12400ea508b1Smrg# func_quote_arg MODEs ARG 12410ea508b1Smrg# ------------------------ 12420ea508b1Smrg# Quote one ARG to be evaled later. MODEs argument may contain zero or more 12430ea508b1Smrg# specifiers listed below separated by ',' character. This function returns two 12440ea508b1Smrg# values: 12450ea508b1Smrg# i) func_quote_arg_result 12460ea508b1Smrg# double-quoted (when needed), suitable for a subsequent eval 12470ea508b1Smrg# ii) func_quote_arg_unquoted_result 12480ea508b1Smrg# has all characters that are still active within double 12490ea508b1Smrg# quotes backslashified. Available only if 'unquoted' is specified. 12500ea508b1Smrg# 12510ea508b1Smrg# Available modes: 12520ea508b1Smrg# ---------------- 12530ea508b1Smrg# 'eval' (default) 12540ea508b1Smrg# - escape shell special characters 12550ea508b1Smrg# 'expand' 12560ea508b1Smrg# - the same as 'eval'; but do not quote variable references 12570ea508b1Smrg# 'pretty' 12580ea508b1Smrg# - request aesthetic output, i.e. '"a b"' instead of 'a\ b'. This might 12590ea508b1Smrg# be used later in func_quote to get output like: 'echo "a b"' instead 12600ea508b1Smrg# of 'echo a\ b'. This is slower than default on some shells. 12610ea508b1Smrg# 'unquoted' 12620ea508b1Smrg# - produce also $func_quote_arg_unquoted_result which does not contain 12630ea508b1Smrg# wrapping double-quotes. 12640ea508b1Smrg# 12650ea508b1Smrg# Examples for 'func_quote_arg pretty,unquoted string': 12660ea508b1Smrg# 12670ea508b1Smrg# string | *_result | *_unquoted_result 12680ea508b1Smrg# ------------+-----------------------+------------------- 12690ea508b1Smrg# " | \" | \" 12700ea508b1Smrg# a b | "a b" | a b 12710ea508b1Smrg# "a b" | "\"a b\"" | \"a b\" 12720ea508b1Smrg# * | "*" | * 12730ea508b1Smrg# z="${x-$y}" | "z=\"\${x-\$y}\"" | z=\"\${x-\$y}\" 12740ea508b1Smrg# 12750ea508b1Smrg# Examples for 'func_quote_arg pretty,unquoted,expand string': 12760ea508b1Smrg# 12770ea508b1Smrg# string | *_result | *_unquoted_result 12780ea508b1Smrg# --------------+---------------------+-------------------- 12790ea508b1Smrg# z="${x-$y}" | "z=\"${x-$y}\"" | z=\"${x-$y}\" 12800ea508b1Smrgfunc_quote_arg () 12810ea508b1Smrg{ 12820ea508b1Smrg _G_quote_expand=false 12830ea508b1Smrg case ,$1, in 12840ea508b1Smrg *,expand,*) 12850ea508b1Smrg _G_quote_expand=: 12860ea508b1Smrg ;; 1287e169010aSmrg esac 1288e169010aSmrg 12890ea508b1Smrg case ,$1, in 12900ea508b1Smrg *,pretty,*|*,expand,*|*,unquoted,*) 12910ea508b1Smrg func_quote_portable $_G_quote_expand "$2" 12920ea508b1Smrg func_quote_arg_result=$func_quote_portable_result 12930ea508b1Smrg func_quote_arg_unquoted_result=$func_quote_portable_unquoted_result 12940ea508b1Smrg ;; 12950ea508b1Smrg *) 12960ea508b1Smrg # Faster quote-for-eval for some shells. 12970ea508b1Smrg func_quotefast_eval "$2" 12980ea508b1Smrg func_quote_arg_result=$func_quotefast_eval_result 1299e169010aSmrg ;; 1300e169010aSmrg esac 13010ea508b1Smrg} 13020ea508b1Smrg 1303e169010aSmrg 13040ea508b1Smrg# func_quote MODEs ARGs... 13050ea508b1Smrg# ------------------------ 13060ea508b1Smrg# Quote all ARGs to be evaled later and join them into single command. See 13070ea508b1Smrg# func_quote_arg's description for more info. 13080ea508b1Smrgfunc_quote () 13090ea508b1Smrg{ 13100ea508b1Smrg $debug_cmd 13110ea508b1Smrg _G_func_quote_mode=$1 ; shift 13120ea508b1Smrg func_quote_result= 13130ea508b1Smrg while test 0 -lt $#; do 13140ea508b1Smrg func_quote_arg "$_G_func_quote_mode" "$1" 13150ea508b1Smrg if test -n "$func_quote_result"; then 13160ea508b1Smrg func_append func_quote_result " $func_quote_arg_result" 13170ea508b1Smrg else 13180ea508b1Smrg func_append func_quote_result "$func_quote_arg_result" 13190ea508b1Smrg fi 13200ea508b1Smrg shift 13210ea508b1Smrg done 13229d0ccd10Smrg} 13239d0ccd10Smrg 13249d0ccd10Smrg 13259d0ccd10Smrg# func_stripname PREFIX SUFFIX NAME 13269d0ccd10Smrg# --------------------------------- 13279d0ccd10Smrg# strip PREFIX and SUFFIX from NAME, and store in func_stripname_result. 13289d0ccd10Smrg# PREFIX and SUFFIX must not contain globbing or regex special 13299d0ccd10Smrg# characters, hashes, percent signs, but SUFFIX may contain a leading 13309d0ccd10Smrg# dot (in which case that matches only a dot). 13319d0ccd10Smrgif test yes = "$_G_HAVE_XSI_OPS"; then 13329d0ccd10Smrg eval 'func_stripname () 13339d0ccd10Smrg { 13349d0ccd10Smrg $debug_cmd 13359d0ccd10Smrg 13369d0ccd10Smrg # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are 13379d0ccd10Smrg # positional parameters, so assign one to ordinary variable first. 13389d0ccd10Smrg func_stripname_result=$3 13399d0ccd10Smrg func_stripname_result=${func_stripname_result#"$1"} 13409d0ccd10Smrg func_stripname_result=${func_stripname_result%"$2"} 13419d0ccd10Smrg }' 13429d0ccd10Smrgelse 13439d0ccd10Smrg func_stripname () 13449d0ccd10Smrg { 13459d0ccd10Smrg $debug_cmd 13469d0ccd10Smrg 13479d0ccd10Smrg case $2 in 13489d0ccd10Smrg .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;; 13499d0ccd10Smrg *) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;; 13509d0ccd10Smrg esac 13519d0ccd10Smrg } 13529d0ccd10Smrgfi 13539d0ccd10Smrg 13549d0ccd10Smrg 13559d0ccd10Smrg# func_show_eval CMD [FAIL_EXP] 13569d0ccd10Smrg# ----------------------------- 13579d0ccd10Smrg# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is 13589d0ccd10Smrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 13599d0ccd10Smrg# is given, then evaluate it. 13609d0ccd10Smrgfunc_show_eval () 13619d0ccd10Smrg{ 13629d0ccd10Smrg $debug_cmd 13639d0ccd10Smrg 13649d0ccd10Smrg _G_cmd=$1 13659d0ccd10Smrg _G_fail_exp=${2-':'} 13669d0ccd10Smrg 13670ea508b1Smrg func_quote_arg pretty,expand "$_G_cmd" 13680ea508b1Smrg eval "func_notquiet $func_quote_arg_result" 13699d0ccd10Smrg 13709d0ccd10Smrg $opt_dry_run || { 13719d0ccd10Smrg eval "$_G_cmd" 13729d0ccd10Smrg _G_status=$? 13739d0ccd10Smrg if test 0 -ne "$_G_status"; then 13749d0ccd10Smrg eval "(exit $_G_status); $_G_fail_exp" 13759d0ccd10Smrg fi 13769d0ccd10Smrg } 13779d0ccd10Smrg} 13789d0ccd10Smrg 13799d0ccd10Smrg 13809d0ccd10Smrg# func_show_eval_locale CMD [FAIL_EXP] 13819d0ccd10Smrg# ------------------------------------ 13829d0ccd10Smrg# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is 13839d0ccd10Smrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 13849d0ccd10Smrg# is given, then evaluate it. Use the saved locale for evaluation. 13859d0ccd10Smrgfunc_show_eval_locale () 13869d0ccd10Smrg{ 13879d0ccd10Smrg $debug_cmd 13889d0ccd10Smrg 13899d0ccd10Smrg _G_cmd=$1 13909d0ccd10Smrg _G_fail_exp=${2-':'} 13919d0ccd10Smrg 13929d0ccd10Smrg $opt_quiet || { 13930ea508b1Smrg func_quote_arg expand,pretty "$_G_cmd" 13940ea508b1Smrg eval "func_echo $func_quote_arg_result" 13959d0ccd10Smrg } 13969d0ccd10Smrg 13979d0ccd10Smrg $opt_dry_run || { 13989d0ccd10Smrg eval "$_G_user_locale 13999d0ccd10Smrg $_G_cmd" 14009d0ccd10Smrg _G_status=$? 14019d0ccd10Smrg eval "$_G_safe_locale" 14029d0ccd10Smrg if test 0 -ne "$_G_status"; then 14039d0ccd10Smrg eval "(exit $_G_status); $_G_fail_exp" 14049d0ccd10Smrg fi 14059d0ccd10Smrg } 14069d0ccd10Smrg} 14079d0ccd10Smrg 14089d0ccd10Smrg 14099d0ccd10Smrg# func_tr_sh 14109d0ccd10Smrg# ---------- 14119d0ccd10Smrg# Turn $1 into a string suitable for a shell variable name. 14129d0ccd10Smrg# Result is stored in $func_tr_sh_result. All characters 14139d0ccd10Smrg# not in the set a-zA-Z0-9_ are replaced with '_'. Further, 14149d0ccd10Smrg# if $1 begins with a digit, a '_' is prepended as well. 14159d0ccd10Smrgfunc_tr_sh () 14169d0ccd10Smrg{ 14179d0ccd10Smrg $debug_cmd 14189d0ccd10Smrg 14199d0ccd10Smrg case $1 in 14209d0ccd10Smrg [0-9]* | *[!a-zA-Z0-9_]*) 14219d0ccd10Smrg func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'` 14229d0ccd10Smrg ;; 14239d0ccd10Smrg * ) 14249d0ccd10Smrg func_tr_sh_result=$1 14259d0ccd10Smrg ;; 14269d0ccd10Smrg esac 14279d0ccd10Smrg} 14289d0ccd10Smrg 14299d0ccd10Smrg 14309d0ccd10Smrg# func_verbose ARG... 14319d0ccd10Smrg# ------------------- 14329d0ccd10Smrg# Echo program name prefixed message in verbose mode only. 14339d0ccd10Smrgfunc_verbose () 14349d0ccd10Smrg{ 14359d0ccd10Smrg $debug_cmd 14369d0ccd10Smrg 14379d0ccd10Smrg $opt_verbose && func_echo "$*" 14389d0ccd10Smrg 14399d0ccd10Smrg : 14409d0ccd10Smrg} 14419d0ccd10Smrg 14429d0ccd10Smrg 14439d0ccd10Smrg# func_warn_and_continue ARG... 14449d0ccd10Smrg# ----------------------------- 14459d0ccd10Smrg# Echo program name prefixed warning message to standard error. 14469d0ccd10Smrgfunc_warn_and_continue () 14479d0ccd10Smrg{ 14489d0ccd10Smrg $debug_cmd 14499d0ccd10Smrg 14509d0ccd10Smrg $require_term_colors 14519d0ccd10Smrg 14529d0ccd10Smrg func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2 14539d0ccd10Smrg} 14549d0ccd10Smrg 14559d0ccd10Smrg 14569d0ccd10Smrg# func_warning CATEGORY ARG... 14579d0ccd10Smrg# ---------------------------- 14589d0ccd10Smrg# Echo program name prefixed warning message to standard error. Warning 14599d0ccd10Smrg# messages can be filtered according to CATEGORY, where this function 14609d0ccd10Smrg# elides messages where CATEGORY is not listed in the global variable 14619d0ccd10Smrg# 'opt_warning_types'. 14629d0ccd10Smrgfunc_warning () 14639d0ccd10Smrg{ 14649d0ccd10Smrg $debug_cmd 14659d0ccd10Smrg 14669d0ccd10Smrg # CATEGORY must be in the warning_categories list! 14679d0ccd10Smrg case " $warning_categories " in 14689d0ccd10Smrg *" $1 "*) ;; 14699d0ccd10Smrg *) func_internal_error "invalid warning category '$1'" ;; 14709d0ccd10Smrg esac 14719d0ccd10Smrg 14729d0ccd10Smrg _G_category=$1 14739d0ccd10Smrg shift 14749d0ccd10Smrg 14759d0ccd10Smrg case " $opt_warning_types " in 14769d0ccd10Smrg *" $_G_category "*) $warning_func ${1+"$@"} ;; 14779d0ccd10Smrg esac 14787914d74bSmrg} 14797914d74bSmrg 14807914d74bSmrg 14819d0ccd10Smrg# func_sort_ver VER1 VER2 14829d0ccd10Smrg# ----------------------- 14839d0ccd10Smrg# 'sort -V' is not generally available. 14849d0ccd10Smrg# Note this deviates from the version comparison in automake 14859d0ccd10Smrg# in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a 14869d0ccd10Smrg# but this should suffice as we won't be specifying old 14879d0ccd10Smrg# version formats or redundant trailing .0 in bootstrap.conf. 14889d0ccd10Smrg# If we did want full compatibility then we should probably 14899d0ccd10Smrg# use m4_version_compare from autoconf. 14909d0ccd10Smrgfunc_sort_ver () 14919d0ccd10Smrg{ 14929d0ccd10Smrg $debug_cmd 14939d0ccd10Smrg 14949d0ccd10Smrg printf '%s\n%s\n' "$1" "$2" \ 14959d0ccd10Smrg | 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 14969d0ccd10Smrg} 14979d0ccd10Smrg 14989d0ccd10Smrg# func_lt_ver PREV CURR 14999d0ccd10Smrg# --------------------- 15009d0ccd10Smrg# Return true if PREV and CURR are in the correct order according to 15019d0ccd10Smrg# func_sort_ver, otherwise false. Use it like this: 15029d0ccd10Smrg# 15039d0ccd10Smrg# func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..." 15049d0ccd10Smrgfunc_lt_ver () 15059d0ccd10Smrg{ 15069d0ccd10Smrg $debug_cmd 15079d0ccd10Smrg 15089d0ccd10Smrg test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q` 15099d0ccd10Smrg} 15109d0ccd10Smrg 15119d0ccd10Smrg 15129d0ccd10Smrg# Local variables: 15139d0ccd10Smrg# mode: shell-script 15149d0ccd10Smrg# sh-indentation: 2 15159d0ccd10Smrg# eval: (add-hook 'before-save-hook 'time-stamp) 15169d0ccd10Smrg# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" 15179d0ccd10Smrg# time-stamp-time-zone: "UTC" 15189d0ccd10Smrg# End: 15199d0ccd10Smrg#! /bin/sh 15209d0ccd10Smrg 15219d0ccd10Smrg# A portable, pluggable option parser for Bourne shell. 15229d0ccd10Smrg# Written by Gary V. Vaughan, 2010 15239d0ccd10Smrg 15240ea508b1Smrg# This is free software. There is NO warranty; not even for 15250ea508b1Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 15260ea508b1Smrg# 15270ea508b1Smrg# Copyright (C) 2010-2019, 2021 Bootstrap Authors 15280ea508b1Smrg# 15290ea508b1Smrg# This file is dual licensed under the terms of the MIT license 15300ea508b1Smrg# <https://opensource.org/license/MIT>, and GPL version 2 or later 15310ea508b1Smrg# <http://www.gnu.org/licenses/gpl-2.0.html>. You must apply one of 15320ea508b1Smrg# these licenses when using or redistributing this software or any of 15330ea508b1Smrg# the files within it. See the URLs above, or the file `LICENSE` 15340ea508b1Smrg# included in the Bootstrap distribution for the full license texts. 15359d0ccd10Smrg 15360ea508b1Smrg# Please report bugs or propose patches to: 15370ea508b1Smrg# <https://github.com/gnulib-modules/bootstrap/issues> 15389d0ccd10Smrg 15390ea508b1Smrg# Set a version string for this script. 15400ea508b1Smrgscriptversion=2019-02-19.15; # UTC 15419d0ccd10Smrg 15429d0ccd10Smrg 15439d0ccd10Smrg## ------ ## 15449d0ccd10Smrg## Usage. ## 15459d0ccd10Smrg## ------ ## 15469d0ccd10Smrg 15479d0ccd10Smrg# This file is a library for parsing options in your shell scripts along 15489d0ccd10Smrg# with assorted other useful supporting features that you can make use 15499d0ccd10Smrg# of too. 15509d0ccd10Smrg# 15519d0ccd10Smrg# For the simplest scripts you might need only: 15529d0ccd10Smrg# 15539d0ccd10Smrg# #!/bin/sh 15549d0ccd10Smrg# . relative/path/to/funclib.sh 15559d0ccd10Smrg# . relative/path/to/options-parser 15569d0ccd10Smrg# scriptversion=1.0 15579d0ccd10Smrg# func_options ${1+"$@"} 15589d0ccd10Smrg# eval set dummy "$func_options_result"; shift 15599d0ccd10Smrg# ...rest of your script... 15609d0ccd10Smrg# 15619d0ccd10Smrg# In order for the '--version' option to work, you will need to have a 15629d0ccd10Smrg# suitably formatted comment like the one at the top of this file 15630ea508b1Smrg# starting with '# Written by ' and ending with '# Copyright'. 15649d0ccd10Smrg# 15659d0ccd10Smrg# For '-h' and '--help' to work, you will also need a one line 15669d0ccd10Smrg# description of your script's purpose in a comment directly above the 15679d0ccd10Smrg# '# Written by ' line, like the one at the top of this file. 15689d0ccd10Smrg# 15699d0ccd10Smrg# The default options also support '--debug', which will turn on shell 15709d0ccd10Smrg# execution tracing (see the comment above debug_cmd below for another 15719d0ccd10Smrg# use), and '--verbose' and the func_verbose function to allow your script 15729d0ccd10Smrg# to display verbose messages only when your user has specified 15739d0ccd10Smrg# '--verbose'. 15749d0ccd10Smrg# 15750ea508b1Smrg# After sourcing this file, you can plug in processing for additional 15769d0ccd10Smrg# options by amending the variables from the 'Configuration' section 15779d0ccd10Smrg# below, and following the instructions in the 'Option parsing' 15789d0ccd10Smrg# section further down. 15799d0ccd10Smrg 15809d0ccd10Smrg## -------------- ## 15819d0ccd10Smrg## Configuration. ## 15829d0ccd10Smrg## -------------- ## 15839d0ccd10Smrg 15849d0ccd10Smrg# You should override these variables in your script after sourcing this 15859d0ccd10Smrg# file so that they reflect the customisations you have added to the 15869d0ccd10Smrg# option parser. 15879d0ccd10Smrg 15889d0ccd10Smrg# The usage line for option parsing errors and the start of '-h' and 15899d0ccd10Smrg# '--help' output messages. You can embed shell variables for delayed 15909d0ccd10Smrg# expansion at the time the message is displayed, but you will need to 15919d0ccd10Smrg# quote other shell meta-characters carefully to prevent them being 15929d0ccd10Smrg# expanded when the contents are evaled. 15939d0ccd10Smrgusage='$progpath [OPTION]...' 15949d0ccd10Smrg 15959d0ccd10Smrg# Short help message in response to '-h' and '--help'. Add to this or 15969d0ccd10Smrg# override it after sourcing this library to reflect the full set of 15979d0ccd10Smrg# options your script accepts. 15989d0ccd10Smrgusage_message="\ 15999d0ccd10Smrg --debug enable verbose shell tracing 16009d0ccd10Smrg -W, --warnings=CATEGORY 16019d0ccd10Smrg report the warnings falling in CATEGORY [all] 16029d0ccd10Smrg -v, --verbose verbosely report processing 16039d0ccd10Smrg --version print version information and exit 16049d0ccd10Smrg -h, --help print short or long help message and exit 16059d0ccd10Smrg" 16069d0ccd10Smrg 16079d0ccd10Smrg# Additional text appended to 'usage_message' in response to '--help'. 16089d0ccd10Smrglong_help_message=" 16099d0ccd10SmrgWarning categories include: 16109d0ccd10Smrg 'all' show all warnings 16119d0ccd10Smrg 'none' turn off all the warnings 16129d0ccd10Smrg 'error' warnings are treated as fatal errors" 16139d0ccd10Smrg 16149d0ccd10Smrg# Help message printed before fatal option parsing errors. 16159d0ccd10Smrgfatal_help="Try '\$progname --help' for more information." 16169d0ccd10Smrg 16179d0ccd10Smrg 16189d0ccd10Smrg 16199d0ccd10Smrg## ------------------------- ## 16209d0ccd10Smrg## Hook function management. ## 16219d0ccd10Smrg## ------------------------- ## 16229d0ccd10Smrg 16239d0ccd10Smrg# This section contains functions for adding, removing, and running hooks 16240ea508b1Smrg# in the main code. A hook is just a list of function names that can be 16250ea508b1Smrg# run in order later on. 16269d0ccd10Smrg 16279d0ccd10Smrg# func_hookable FUNC_NAME 16289d0ccd10Smrg# ----------------------- 16299d0ccd10Smrg# Declare that FUNC_NAME will run hooks added with 16309d0ccd10Smrg# 'func_add_hook FUNC_NAME ...'. 16319d0ccd10Smrgfunc_hookable () 16329d0ccd10Smrg{ 16339d0ccd10Smrg $debug_cmd 16349d0ccd10Smrg 16359d0ccd10Smrg func_append hookable_fns " $1" 16369d0ccd10Smrg} 16379d0ccd10Smrg 16389d0ccd10Smrg 16399d0ccd10Smrg# func_add_hook FUNC_NAME HOOK_FUNC 16409d0ccd10Smrg# --------------------------------- 16419d0ccd10Smrg# Request that FUNC_NAME call HOOK_FUNC before it returns. FUNC_NAME must 16429d0ccd10Smrg# first have been declared "hookable" by a call to 'func_hookable'. 16439d0ccd10Smrgfunc_add_hook () 16449d0ccd10Smrg{ 16459d0ccd10Smrg $debug_cmd 16469d0ccd10Smrg 16479d0ccd10Smrg case " $hookable_fns " in 16489d0ccd10Smrg *" $1 "*) ;; 16499d0ccd10Smrg *) func_fatal_error "'$1' does not accept hook functions." ;; 16509d0ccd10Smrg esac 16519d0ccd10Smrg 16529d0ccd10Smrg eval func_append ${1}_hooks '" $2"' 16539d0ccd10Smrg} 16549d0ccd10Smrg 16559d0ccd10Smrg 16569d0ccd10Smrg# func_remove_hook FUNC_NAME HOOK_FUNC 16579d0ccd10Smrg# ------------------------------------ 16580ea508b1Smrg# Remove HOOK_FUNC from the list of hook functions to be called by 16590ea508b1Smrg# FUNC_NAME. 16609d0ccd10Smrgfunc_remove_hook () 16619d0ccd10Smrg{ 16629d0ccd10Smrg $debug_cmd 16639d0ccd10Smrg 16649d0ccd10Smrg eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`' 16659d0ccd10Smrg} 16669d0ccd10Smrg 16679d0ccd10Smrg 16680ea508b1Smrg# func_propagate_result FUNC_NAME_A FUNC_NAME_B 16690ea508b1Smrg# --------------------------------------------- 16700ea508b1Smrg# If the *_result variable of FUNC_NAME_A _is set_, assign its value to 16710ea508b1Smrg# *_result variable of FUNC_NAME_B. 16720ea508b1Smrgfunc_propagate_result () 16730ea508b1Smrg{ 16740ea508b1Smrg $debug_cmd 16750ea508b1Smrg 16760ea508b1Smrg func_propagate_result_result=: 16770ea508b1Smrg if eval "test \"\${${1}_result+set}\" = set" 16780ea508b1Smrg then 16790ea508b1Smrg eval "${2}_result=\$${1}_result" 16800ea508b1Smrg else 16810ea508b1Smrg func_propagate_result_result=false 16820ea508b1Smrg fi 16830ea508b1Smrg} 16840ea508b1Smrg 16850ea508b1Smrg 16869d0ccd10Smrg# func_run_hooks FUNC_NAME [ARG]... 16879d0ccd10Smrg# --------------------------------- 16889d0ccd10Smrg# Run all hook functions registered to FUNC_NAME. 16890ea508b1Smrg# It's assumed that the list of hook functions contains nothing more 16909d0ccd10Smrg# than a whitespace-delimited list of legal shell function names, and 16919d0ccd10Smrg# no effort is wasted trying to catch shell meta-characters or preserve 16929d0ccd10Smrg# whitespace. 16939d0ccd10Smrgfunc_run_hooks () 16949d0ccd10Smrg{ 16959d0ccd10Smrg $debug_cmd 16969d0ccd10Smrg 16976b7436aeSmrg _G_rc_run_hooks=false 16986b7436aeSmrg 16999d0ccd10Smrg case " $hookable_fns " in 17009d0ccd10Smrg *" $1 "*) ;; 17010ea508b1Smrg *) func_fatal_error "'$1' does not support hook functions." ;; 17029d0ccd10Smrg esac 17039d0ccd10Smrg 17049d0ccd10Smrg eval _G_hook_fns=\$$1_hooks; shift 17059d0ccd10Smrg 17069d0ccd10Smrg for _G_hook in $_G_hook_fns; do 17070ea508b1Smrg func_unset "${_G_hook}_result" 17080ea508b1Smrg eval $_G_hook '${1+"$@"}' 17090ea508b1Smrg func_propagate_result $_G_hook func_run_hooks 17100ea508b1Smrg if $func_propagate_result_result; then 17110ea508b1Smrg eval set dummy "$func_run_hooks_result"; shift 17120ea508b1Smrg fi 17139d0ccd10Smrg done 17149d0ccd10Smrg} 17159d0ccd10Smrg 17169d0ccd10Smrg 17179d0ccd10Smrg 17189d0ccd10Smrg## --------------- ## 17199d0ccd10Smrg## Option parsing. ## 17209d0ccd10Smrg## --------------- ## 17219d0ccd10Smrg 17229d0ccd10Smrg# In order to add your own option parsing hooks, you must accept the 17230ea508b1Smrg# full positional parameter list from your hook function. You may remove 17240ea508b1Smrg# or edit any options that you action, and then pass back the remaining 17250ea508b1Smrg# unprocessed options in '<hooked_function_name>_result', escaped 17260ea508b1Smrg# suitably for 'eval'. 17270ea508b1Smrg# 17280ea508b1Smrg# The '<hooked_function_name>_result' variable is automatically unset 17290ea508b1Smrg# before your hook gets called; for best performance, only set the 17300ea508b1Smrg# *_result variable when necessary (i.e. don't call the 'func_quote' 17310ea508b1Smrg# function unnecessarily because it can be an expensive operation on some 17320ea508b1Smrg# machines). 17330ea508b1Smrg# 17340ea508b1Smrg# Like this: 17359d0ccd10Smrg# 17369d0ccd10Smrg# my_options_prep () 17379d0ccd10Smrg# { 17389d0ccd10Smrg# $debug_cmd 17399d0ccd10Smrg# 17409d0ccd10Smrg# # Extend the existing usage message. 17419d0ccd10Smrg# usage_message=$usage_message' 17429d0ccd10Smrg# -s, --silent don'\''t print informational messages 17439d0ccd10Smrg# ' 17440ea508b1Smrg# # No change in '$@' (ignored completely by this hook). Leave 17450ea508b1Smrg# # my_options_prep_result variable intact. 17469d0ccd10Smrg# } 17479d0ccd10Smrg# func_add_hook func_options_prep my_options_prep 17489d0ccd10Smrg# 17499d0ccd10Smrg# 17509d0ccd10Smrg# my_silent_option () 17519d0ccd10Smrg# { 17529d0ccd10Smrg# $debug_cmd 17539d0ccd10Smrg# 17540ea508b1Smrg# args_changed=false 17550ea508b1Smrg# 17560ea508b1Smrg# # Note that, for efficiency, we parse as many options as we can 17579d0ccd10Smrg# # recognise in a loop before passing the remainder back to the 17589d0ccd10Smrg# # caller on the first unrecognised argument we encounter. 17599d0ccd10Smrg# while test $# -gt 0; do 17609d0ccd10Smrg# opt=$1; shift 17619d0ccd10Smrg# case $opt in 17620ea508b1Smrg# --silent|-s) opt_silent=: 17630ea508b1Smrg# args_changed=: 17640ea508b1Smrg# ;; 17659d0ccd10Smrg# # Separate non-argument short options: 17669d0ccd10Smrg# -s*) func_split_short_opt "$_G_opt" 17679d0ccd10Smrg# set dummy "$func_split_short_opt_name" \ 17689d0ccd10Smrg# "-$func_split_short_opt_arg" ${1+"$@"} 17699d0ccd10Smrg# shift 17700ea508b1Smrg# args_changed=: 17719d0ccd10Smrg# ;; 17720ea508b1Smrg# *) # Make sure the first unrecognised option "$_G_opt" 17730ea508b1Smrg# # is added back to "$@" in case we need it later, 17740ea508b1Smrg# # if $args_changed was set to 'true'. 17750ea508b1Smrg# set dummy "$_G_opt" ${1+"$@"}; shift; break ;; 17769d0ccd10Smrg# esac 17779d0ccd10Smrg# done 17789d0ccd10Smrg# 17790ea508b1Smrg# # Only call 'func_quote' here if we processed at least one argument. 17800ea508b1Smrg# if $args_changed; then 17810ea508b1Smrg# func_quote eval ${1+"$@"} 17820ea508b1Smrg# my_silent_option_result=$func_quote_result 17830ea508b1Smrg# fi 17849d0ccd10Smrg# } 17859d0ccd10Smrg# func_add_hook func_parse_options my_silent_option 17869d0ccd10Smrg# 17879d0ccd10Smrg# 17889d0ccd10Smrg# my_option_validation () 17899d0ccd10Smrg# { 17909d0ccd10Smrg# $debug_cmd 17919d0ccd10Smrg# 17929d0ccd10Smrg# $opt_silent && $opt_verbose && func_fatal_help "\ 17939d0ccd10Smrg# '--silent' and '--verbose' options are mutually exclusive." 17949d0ccd10Smrg# } 17959d0ccd10Smrg# func_add_hook func_validate_options my_option_validation 17969d0ccd10Smrg# 17970ea508b1Smrg# You'll also need to manually amend $usage_message to reflect the extra 17989d0ccd10Smrg# options you parse. It's preferable to append if you can, so that 17999d0ccd10Smrg# multiple option parsing hooks can be added safely. 18009d0ccd10Smrg 18019d0ccd10Smrg 18020ea508b1Smrg# func_options_finish [ARG]... 18030ea508b1Smrg# ---------------------------- 18040ea508b1Smrg# Finishing the option parse loop (call 'func_options' hooks ATM). 18050ea508b1Smrgfunc_options_finish () 18060ea508b1Smrg{ 18070ea508b1Smrg $debug_cmd 18080ea508b1Smrg 18090ea508b1Smrg func_run_hooks func_options ${1+"$@"} 18100ea508b1Smrg func_propagate_result func_run_hooks func_options_finish 18110ea508b1Smrg} 18120ea508b1Smrg 18130ea508b1Smrg 18149d0ccd10Smrg# func_options [ARG]... 18159d0ccd10Smrg# --------------------- 18169d0ccd10Smrg# All the functions called inside func_options are hookable. See the 18179d0ccd10Smrg# individual implementations for details. 18189d0ccd10Smrgfunc_hookable func_options 18199d0ccd10Smrgfunc_options () 18207914d74bSmrg{ 18219d0ccd10Smrg $debug_cmd 18227914d74bSmrg 18230ea508b1Smrg _G_options_quoted=false 1824e169010aSmrg 18250ea508b1Smrg for my_func in options_prep parse_options validate_options options_finish 18260ea508b1Smrg do 18270ea508b1Smrg func_unset func_${my_func}_result 18280ea508b1Smrg func_unset func_run_hooks_result 18290ea508b1Smrg eval func_$my_func '${1+"$@"}' 18300ea508b1Smrg func_propagate_result func_$my_func func_options 18310ea508b1Smrg if $func_propagate_result_result; then 18320ea508b1Smrg eval set dummy "$func_options_result"; shift 18330ea508b1Smrg _G_options_quoted=: 18340ea508b1Smrg fi 18350ea508b1Smrg done 18369d0ccd10Smrg 18370ea508b1Smrg $_G_options_quoted || { 18380ea508b1Smrg # As we (func_options) are top-level options-parser function and 18390ea508b1Smrg # nobody quoted "$@" for us yet, we need to do it explicitly for 18400ea508b1Smrg # caller. 18410ea508b1Smrg func_quote eval ${1+"$@"} 18420ea508b1Smrg func_options_result=$func_quote_result 18430ea508b1Smrg } 18447914d74bSmrg} 18457914d74bSmrg 1846e169010aSmrg 18479d0ccd10Smrg# func_options_prep [ARG]... 18489d0ccd10Smrg# -------------------------- 18499d0ccd10Smrg# All initialisations required before starting the option parse loop. 18509d0ccd10Smrg# Note that when calling hook functions, we pass through the list of 18519d0ccd10Smrg# positional parameters. If a hook function modifies that list, and 18520ea508b1Smrg# needs to propagate that back to rest of this script, then the complete 18530ea508b1Smrg# modified list must be put in 'func_run_hooks_result' before returning. 18549d0ccd10Smrgfunc_hookable func_options_prep 18559d0ccd10Smrgfunc_options_prep () 18567914d74bSmrg{ 18579d0ccd10Smrg $debug_cmd 18587914d74bSmrg 18599d0ccd10Smrg # Option defaults: 18609d0ccd10Smrg opt_verbose=false 18619d0ccd10Smrg opt_warning_types= 1862e169010aSmrg 18639d0ccd10Smrg func_run_hooks func_options_prep ${1+"$@"} 18640ea508b1Smrg func_propagate_result func_run_hooks func_options_prep 18657914d74bSmrg} 18667914d74bSmrg 18679d0ccd10Smrg 18689d0ccd10Smrg# func_parse_options [ARG]... 18699d0ccd10Smrg# --------------------------- 18709d0ccd10Smrg# The main option parsing loop. 18719d0ccd10Smrgfunc_hookable func_parse_options 18729d0ccd10Smrgfunc_parse_options () 1873c63293b5Smrg{ 18749d0ccd10Smrg $debug_cmd 18759d0ccd10Smrg 18760ea508b1Smrg _G_parse_options_requote=false 18779d0ccd10Smrg # this just eases exit handling 18789d0ccd10Smrg while test $# -gt 0; do 18799d0ccd10Smrg # Defer to hook functions for initial option parsing, so they 18809d0ccd10Smrg # get priority in the event of reusing an option name. 18819d0ccd10Smrg func_run_hooks func_parse_options ${1+"$@"} 18820ea508b1Smrg func_propagate_result func_run_hooks func_parse_options 18830ea508b1Smrg if $func_propagate_result_result; then 18840ea508b1Smrg eval set dummy "$func_parse_options_result"; shift 18850ea508b1Smrg # Even though we may have changed "$@", we passed the "$@" array 18860ea508b1Smrg # down into the hook and it quoted it for us (because we are in 18870ea508b1Smrg # this if-branch). No need to quote it again. 18880ea508b1Smrg _G_parse_options_requote=false 18890ea508b1Smrg fi 18909d0ccd10Smrg 18919d0ccd10Smrg # Break out of the loop if we already parsed every option. 18929d0ccd10Smrg test $# -gt 0 || break 18939d0ccd10Smrg 18940ea508b1Smrg # We expect that one of the options parsed in this function matches 18950ea508b1Smrg # and thus we remove _G_opt from "$@" and need to re-quote. 18960ea508b1Smrg _G_match_parse_options=: 18979d0ccd10Smrg _G_opt=$1 18989d0ccd10Smrg shift 18999d0ccd10Smrg case $_G_opt in 19009d0ccd10Smrg --debug|-x) debug_cmd='set -x' 19010ea508b1Smrg func_echo "enabling shell trace mode" >&2 19029d0ccd10Smrg $debug_cmd 19039d0ccd10Smrg ;; 19049d0ccd10Smrg 19059d0ccd10Smrg --no-warnings|--no-warning|--no-warn) 19069d0ccd10Smrg set dummy --warnings none ${1+"$@"} 19079d0ccd10Smrg shift 19089d0ccd10Smrg ;; 19099d0ccd10Smrg 19109d0ccd10Smrg --warnings|--warning|-W) 19110ea508b1Smrg if test $# = 0 && func_missing_arg $_G_opt; then 19120ea508b1Smrg _G_parse_options_requote=: 19130ea508b1Smrg break 19140ea508b1Smrg fi 19159d0ccd10Smrg case " $warning_categories $1" in 19169d0ccd10Smrg *" $1 "*) 19179d0ccd10Smrg # trailing space prevents matching last $1 above 19189d0ccd10Smrg func_append_uniq opt_warning_types " $1" 19199d0ccd10Smrg ;; 19209d0ccd10Smrg *all) 19219d0ccd10Smrg opt_warning_types=$warning_categories 19229d0ccd10Smrg ;; 19239d0ccd10Smrg *none) 19249d0ccd10Smrg opt_warning_types=none 19259d0ccd10Smrg warning_func=: 19269d0ccd10Smrg ;; 19279d0ccd10Smrg *error) 19289d0ccd10Smrg opt_warning_types=$warning_categories 19299d0ccd10Smrg warning_func=func_fatal_error 19309d0ccd10Smrg ;; 19319d0ccd10Smrg *) 19329d0ccd10Smrg func_fatal_error \ 19339d0ccd10Smrg "unsupported warning category: '$1'" 19349d0ccd10Smrg ;; 19359d0ccd10Smrg esac 19369d0ccd10Smrg shift 19379d0ccd10Smrg ;; 19389d0ccd10Smrg 19399d0ccd10Smrg --verbose|-v) opt_verbose=: ;; 19409d0ccd10Smrg --version) func_version ;; 19419d0ccd10Smrg -\?|-h) func_usage ;; 19429d0ccd10Smrg --help) func_help ;; 19439d0ccd10Smrg 19449d0ccd10Smrg # Separate optargs to long options (plugins may need this): 19459d0ccd10Smrg --*=*) func_split_equals "$_G_opt" 19469d0ccd10Smrg set dummy "$func_split_equals_lhs" \ 19479d0ccd10Smrg "$func_split_equals_rhs" ${1+"$@"} 19489d0ccd10Smrg shift 19499d0ccd10Smrg ;; 19509d0ccd10Smrg 19519d0ccd10Smrg # Separate optargs to short options: 19529d0ccd10Smrg -W*) 19539d0ccd10Smrg func_split_short_opt "$_G_opt" 19549d0ccd10Smrg set dummy "$func_split_short_opt_name" \ 19559d0ccd10Smrg "$func_split_short_opt_arg" ${1+"$@"} 19569d0ccd10Smrg shift 19579d0ccd10Smrg ;; 19589d0ccd10Smrg 19599d0ccd10Smrg # Separate non-argument short options: 19609d0ccd10Smrg -\?*|-h*|-v*|-x*) 19619d0ccd10Smrg func_split_short_opt "$_G_opt" 19629d0ccd10Smrg set dummy "$func_split_short_opt_name" \ 19639d0ccd10Smrg "-$func_split_short_opt_arg" ${1+"$@"} 19649d0ccd10Smrg shift 19659d0ccd10Smrg ;; 19669d0ccd10Smrg 19670ea508b1Smrg --) _G_parse_options_requote=: ; break ;; 19689d0ccd10Smrg -*) func_fatal_help "unrecognised option: '$_G_opt'" ;; 19690ea508b1Smrg *) set dummy "$_G_opt" ${1+"$@"}; shift 19700ea508b1Smrg _G_match_parse_options=false 19710ea508b1Smrg break 19720ea508b1Smrg ;; 19739d0ccd10Smrg esac 19740ea508b1Smrg 19750ea508b1Smrg if $_G_match_parse_options; then 19760ea508b1Smrg _G_parse_options_requote=: 19770ea508b1Smrg fi 19789d0ccd10Smrg done 19799d0ccd10Smrg 19800ea508b1Smrg if $_G_parse_options_requote; then 19810ea508b1Smrg # save modified positional parameters for caller 19820ea508b1Smrg func_quote eval ${1+"$@"} 19830ea508b1Smrg func_parse_options_result=$func_quote_result 19840ea508b1Smrg fi 1985c63293b5Smrg} 1986c63293b5Smrg 19877914d74bSmrg 19889d0ccd10Smrg# func_validate_options [ARG]... 19899d0ccd10Smrg# ------------------------------ 19909d0ccd10Smrg# Perform any sanity checks on option settings and/or unconsumed 19919d0ccd10Smrg# arguments. 19929d0ccd10Smrgfunc_hookable func_validate_options 19939d0ccd10Smrgfunc_validate_options () 1994e169010aSmrg{ 19959d0ccd10Smrg $debug_cmd 1996c63293b5Smrg 19979d0ccd10Smrg # Display all warnings if -W was not given. 19989d0ccd10Smrg test -n "$opt_warning_types" || opt_warning_types=" $warning_categories" 19999d0ccd10Smrg 20009d0ccd10Smrg func_run_hooks func_validate_options ${1+"$@"} 20010ea508b1Smrg func_propagate_result func_run_hooks func_validate_options 20029d0ccd10Smrg 20039d0ccd10Smrg # Bail if the options were screwed! 20049d0ccd10Smrg $exit_cmd $EXIT_FAILURE 2005e169010aSmrg} 2006e169010aSmrg 20079d0ccd10Smrg 20089d0ccd10Smrg 20099d0ccd10Smrg## ----------------- ## 20109d0ccd10Smrg## Helper functions. ## 20119d0ccd10Smrg## ----------------- ## 20129d0ccd10Smrg 20139d0ccd10Smrg# This section contains the helper functions used by the rest of the 20149d0ccd10Smrg# hookable option parser framework in ascii-betical order. 20159d0ccd10Smrg 20169d0ccd10Smrg 20179d0ccd10Smrg# func_fatal_help ARG... 20189d0ccd10Smrg# ---------------------- 20199d0ccd10Smrg# Echo program name prefixed message to standard error, followed by 20209d0ccd10Smrg# a help hint, and exit. 20219d0ccd10Smrgfunc_fatal_help () 2022e169010aSmrg{ 20239d0ccd10Smrg $debug_cmd 2024c63293b5Smrg 20259d0ccd10Smrg eval \$ECHO \""Usage: $usage"\" 20269d0ccd10Smrg eval \$ECHO \""$fatal_help"\" 20279d0ccd10Smrg func_error ${1+"$@"} 20289d0ccd10Smrg exit $EXIT_FAILURE 2029e169010aSmrg} 2030e169010aSmrg 20319d0ccd10Smrg 20329d0ccd10Smrg# func_help 20339d0ccd10Smrg# --------- 20349d0ccd10Smrg# Echo long help message to standard output and exit. 2035e169010aSmrgfunc_help () 2036e169010aSmrg{ 20379d0ccd10Smrg $debug_cmd 20389d0ccd10Smrg 20399d0ccd10Smrg func_usage_message 20409d0ccd10Smrg $ECHO "$long_help_message" 20419d0ccd10Smrg exit 0 2042e169010aSmrg} 2043e169010aSmrg 20449d0ccd10Smrg 20459d0ccd10Smrg# func_missing_arg ARGNAME 20469d0ccd10Smrg# ------------------------ 2047e169010aSmrg# Echo program name prefixed message to standard error and set global 2048e169010aSmrg# exit_cmd. 2049e169010aSmrgfunc_missing_arg () 2050e169010aSmrg{ 20519d0ccd10Smrg $debug_cmd 2052c63293b5Smrg 20539d0ccd10Smrg func_error "Missing argument for '$1'." 2054e169010aSmrg exit_cmd=exit 2055e169010aSmrg} 2056e169010aSmrg 2057e169010aSmrg 20589d0ccd10Smrg# func_split_equals STRING 20599d0ccd10Smrg# ------------------------ 20600ea508b1Smrg# Set func_split_equals_lhs and func_split_equals_rhs shell variables 20610ea508b1Smrg# after splitting STRING at the '=' sign. 20629d0ccd10Smrgtest -z "$_G_HAVE_XSI_OPS" \ 20639d0ccd10Smrg && (eval 'x=a/b/c; 20649d0ccd10Smrg test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ 20659d0ccd10Smrg && _G_HAVE_XSI_OPS=yes 20669d0ccd10Smrg 20679d0ccd10Smrgif test yes = "$_G_HAVE_XSI_OPS" 20689d0ccd10Smrgthen 20699d0ccd10Smrg # This is an XSI compatible shell, allowing a faster implementation... 20709d0ccd10Smrg eval 'func_split_equals () 20719d0ccd10Smrg { 20729d0ccd10Smrg $debug_cmd 20739d0ccd10Smrg 20749d0ccd10Smrg func_split_equals_lhs=${1%%=*} 20759d0ccd10Smrg func_split_equals_rhs=${1#*=} 20760ea508b1Smrg if test "x$func_split_equals_lhs" = "x$1"; then 20770ea508b1Smrg func_split_equals_rhs= 20780ea508b1Smrg fi 20799d0ccd10Smrg }' 20809d0ccd10Smrgelse 20819d0ccd10Smrg # ...otherwise fall back to using expr, which is often a shell builtin. 20829d0ccd10Smrg func_split_equals () 20839d0ccd10Smrg { 20849d0ccd10Smrg $debug_cmd 20859d0ccd10Smrg 20869d0ccd10Smrg func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'` 20879d0ccd10Smrg func_split_equals_rhs= 20880ea508b1Smrg test "x$func_split_equals_lhs=" = "x$1" \ 20899d0ccd10Smrg || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'` 20909d0ccd10Smrg } 20919d0ccd10Smrgfi #func_split_equals 20929d0ccd10Smrg 20939d0ccd10Smrg 20949d0ccd10Smrg# func_split_short_opt SHORTOPT 20959d0ccd10Smrg# ----------------------------- 2096c63293b5Smrg# Set func_split_short_opt_name and func_split_short_opt_arg shell 2097c63293b5Smrg# variables after splitting SHORTOPT after the 2nd character. 20989d0ccd10Smrgif test yes = "$_G_HAVE_XSI_OPS" 20999d0ccd10Smrgthen 21009d0ccd10Smrg # This is an XSI compatible shell, allowing a faster implementation... 21019d0ccd10Smrg eval 'func_split_short_opt () 21029d0ccd10Smrg { 21039d0ccd10Smrg $debug_cmd 21049d0ccd10Smrg 21059d0ccd10Smrg func_split_short_opt_arg=${1#??} 21069d0ccd10Smrg func_split_short_opt_name=${1%"$func_split_short_opt_arg"} 21079d0ccd10Smrg }' 21089d0ccd10Smrgelse 21099d0ccd10Smrg # ...otherwise fall back to using expr, which is often a shell builtin. 21109d0ccd10Smrg func_split_short_opt () 21119d0ccd10Smrg { 21129d0ccd10Smrg $debug_cmd 21139d0ccd10Smrg 21140ea508b1Smrg func_split_short_opt_name=`expr "x$1" : 'x\(-.\)'` 21159d0ccd10Smrg func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'` 21169d0ccd10Smrg } 21179d0ccd10Smrgfi #func_split_short_opt 21189d0ccd10Smrg 21199d0ccd10Smrg 21209d0ccd10Smrg# func_usage 21219d0ccd10Smrg# ---------- 21229d0ccd10Smrg# Echo short help message to standard output and exit. 21239d0ccd10Smrgfunc_usage () 2124c63293b5Smrg{ 21259d0ccd10Smrg $debug_cmd 2126c63293b5Smrg 21279d0ccd10Smrg func_usage_message 21289d0ccd10Smrg $ECHO "Run '$progname --help |${PAGER-more}' for full usage" 21299d0ccd10Smrg exit 0 21309d0ccd10Smrg} 2131c63293b5Smrg 2132c63293b5Smrg 21339d0ccd10Smrg# func_usage_message 21349d0ccd10Smrg# ------------------ 21359d0ccd10Smrg# Echo short help message to standard output. 21369d0ccd10Smrgfunc_usage_message () 2137c63293b5Smrg{ 21389d0ccd10Smrg $debug_cmd 2139c63293b5Smrg 21409d0ccd10Smrg eval \$ECHO \""Usage: $usage"\" 21419d0ccd10Smrg echo 21429d0ccd10Smrg $SED -n 's|^# || 21439d0ccd10Smrg /^Written by/{ 21449d0ccd10Smrg x;p;x 21459d0ccd10Smrg } 21469d0ccd10Smrg h 21479d0ccd10Smrg /^Written by/q' < "$progpath" 21489d0ccd10Smrg echo 21499d0ccd10Smrg eval \$ECHO \""$usage_message"\" 21509d0ccd10Smrg} 2151c63293b5Smrg 2152e169010aSmrg 21539d0ccd10Smrg# func_version 21549d0ccd10Smrg# ------------ 21559d0ccd10Smrg# Echo version message to standard output and exit. 21560ea508b1Smrg# The version message is extracted from the calling file's header 21570ea508b1Smrg# comments, with leading '# ' stripped: 21580ea508b1Smrg# 1. First display the progname and version 21590ea508b1Smrg# 2. Followed by the header comment line matching /^# Written by / 21600ea508b1Smrg# 3. Then a blank line followed by the first following line matching 21610ea508b1Smrg# /^# Copyright / 21620ea508b1Smrg# 4. Immediately followed by any lines between the previous matches, 21630ea508b1Smrg# except lines preceding the intervening completely blank line. 21640ea508b1Smrg# For example, see the header comments of this file. 21659d0ccd10Smrgfunc_version () 21669d0ccd10Smrg{ 21679d0ccd10Smrg $debug_cmd 2168e169010aSmrg 21699d0ccd10Smrg printf '%s\n' "$progname $scriptversion" 21709d0ccd10Smrg $SED -n ' 21710ea508b1Smrg /^# Written by /!b 21720ea508b1Smrg s|^# ||; p; n 21730ea508b1Smrg 21740ea508b1Smrg :fwd2blnk 21750ea508b1Smrg /./ { 21760ea508b1Smrg n 21770ea508b1Smrg b fwd2blnk 21789d0ccd10Smrg } 21790ea508b1Smrg p; n 21800ea508b1Smrg 21810ea508b1Smrg :holdwrnt 21820ea508b1Smrg s|^# || 21830ea508b1Smrg s|^# *$|| 21840ea508b1Smrg /^Copyright /!{ 21850ea508b1Smrg /./H 21860ea508b1Smrg n 21870ea508b1Smrg b holdwrnt 21889d0ccd10Smrg } 21890ea508b1Smrg 21900ea508b1Smrg s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2| 21910ea508b1Smrg G 21920ea508b1Smrg s|\(\n\)\n*|\1|g 21930ea508b1Smrg p; q' < "$progpath" 2194e169010aSmrg 21959d0ccd10Smrg exit $? 21969d0ccd10Smrg} 2197e169010aSmrg 21987914d74bSmrg 21999d0ccd10Smrg# Local variables: 22009d0ccd10Smrg# mode: shell-script 22019d0ccd10Smrg# sh-indentation: 2 22029d0ccd10Smrg# eval: (add-hook 'before-save-hook 'time-stamp) 22030ea508b1Smrg# time-stamp-pattern: "30/scriptversion=%:y-%02m-%02d.%02H; # UTC" 22049d0ccd10Smrg# time-stamp-time-zone: "UTC" 22059d0ccd10Smrg# End: 22067914d74bSmrg 22079d0ccd10Smrg# Set a version string. 22080ea508b1Smrgscriptversion='(GNU libtool) 2.4.7' 22097914d74bSmrg 22107914d74bSmrg 22119d0ccd10Smrg# func_echo ARG... 22129d0ccd10Smrg# ---------------- 22139d0ccd10Smrg# Libtool also displays the current mode in messages, so override 22149d0ccd10Smrg# funclib.sh func_echo with this custom definition. 22159d0ccd10Smrgfunc_echo () 2216c63293b5Smrg{ 22179d0ccd10Smrg $debug_cmd 2218c63293b5Smrg 22199d0ccd10Smrg _G_message=$* 22209d0ccd10Smrg 22219d0ccd10Smrg func_echo_IFS=$IFS 22229d0ccd10Smrg IFS=$nl 22239d0ccd10Smrg for _G_line in $_G_message; do 22249d0ccd10Smrg IFS=$func_echo_IFS 22259d0ccd10Smrg $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line" 22269d0ccd10Smrg done 22279d0ccd10Smrg IFS=$func_echo_IFS 22289d0ccd10Smrg} 2229c63293b5Smrg 2230c63293b5Smrg 22319d0ccd10Smrg# func_warning ARG... 22329d0ccd10Smrg# ------------------- 22339d0ccd10Smrg# Libtool warnings are not categorized, so override funclib.sh 22349d0ccd10Smrg# func_warning with this simpler definition. 22359d0ccd10Smrgfunc_warning () 2236c63293b5Smrg{ 22379d0ccd10Smrg $debug_cmd 22389d0ccd10Smrg 22399d0ccd10Smrg $warning_func ${1+"$@"} 22409d0ccd10Smrg} 22419d0ccd10Smrg 2242c63293b5Smrg 22439d0ccd10Smrg## ---------------- ## 22449d0ccd10Smrg## Options parsing. ## 22459d0ccd10Smrg## ---------------- ## 22469d0ccd10Smrg 22479d0ccd10Smrg# Hook in the functions to make sure our own options are parsed during 22489d0ccd10Smrg# the option parsing loop. 22499d0ccd10Smrg 22509d0ccd10Smrgusage='$progpath [OPTION]... [MODE-ARG]...' 22519d0ccd10Smrg 22529d0ccd10Smrg# Short help message in response to '-h'. 22539d0ccd10Smrgusage_message="Options: 22549d0ccd10Smrg --config show all configuration variables 22559d0ccd10Smrg --debug enable verbose shell tracing 22569d0ccd10Smrg -n, --dry-run display commands without modifying any files 22579d0ccd10Smrg --features display basic configuration information and exit 22589d0ccd10Smrg --mode=MODE use operation mode MODE 22599d0ccd10Smrg --no-warnings equivalent to '-Wnone' 22609d0ccd10Smrg --preserve-dup-deps don't remove duplicate dependency libraries 22619d0ccd10Smrg --quiet, --silent don't print informational messages 22629d0ccd10Smrg --tag=TAG use configuration variables from tag TAG 22639d0ccd10Smrg -v, --verbose print more informational messages than default 22649d0ccd10Smrg --version print version information 22659d0ccd10Smrg -W, --warnings=CATEGORY report the warnings falling in CATEGORY [all] 22669d0ccd10Smrg -h, --help, --help-all print short, long, or detailed help message 22679d0ccd10Smrg" 2268c63293b5Smrg 22699d0ccd10Smrg# Additional text appended to 'usage_message' in response to '--help'. 22709d0ccd10Smrgfunc_help () 2271c63293b5Smrg{ 22729d0ccd10Smrg $debug_cmd 22739d0ccd10Smrg 22749d0ccd10Smrg func_usage_message 22759d0ccd10Smrg $ECHO "$long_help_message 22769d0ccd10Smrg 22779d0ccd10SmrgMODE must be one of the following: 22789d0ccd10Smrg 22799d0ccd10Smrg clean remove files from the build directory 22809d0ccd10Smrg compile compile a source file into a libtool object 22819d0ccd10Smrg execute automatically set library path, then run a program 22829d0ccd10Smrg finish complete the installation of libtool libraries 22839d0ccd10Smrg install install libraries or executables 22849d0ccd10Smrg link create a library or an executable 22859d0ccd10Smrg uninstall remove libraries from an installed directory 22869d0ccd10Smrg 22879d0ccd10SmrgMODE-ARGS vary depending on the MODE. When passed as first option, 22889d0ccd10Smrg'--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that. 22899d0ccd10SmrgTry '$progname --help --mode=MODE' for a more detailed description of MODE. 22909d0ccd10Smrg 22919d0ccd10SmrgWhen reporting a bug, please describe a test case to reproduce it and 22929d0ccd10Smrginclude the following information: 22939d0ccd10Smrg 22949d0ccd10Smrg host-triplet: $host 22959d0ccd10Smrg shell: $SHELL 22969d0ccd10Smrg compiler: $LTCC 22979d0ccd10Smrg compiler flags: $LTCFLAGS 22989d0ccd10Smrg linker: $LD (gnu? $with_gnu_ld) 22996b7436aeSmrg version: $progname $scriptversion Debian-2.4.7-7~deb12u1 23009d0ccd10Smrg automake: `($AUTOMAKE --version) 2>/dev/null |$SED 1q` 23019d0ccd10Smrg autoconf: `($AUTOCONF --version) 2>/dev/null |$SED 1q` 23029d0ccd10Smrg 23039d0ccd10SmrgReport bugs to <bug-libtool@gnu.org>. 23046b7436aeSmrgGNU libtool home page: <http://www.gnu.org/s/libtool/>. 23059d0ccd10SmrgGeneral help using GNU software: <http://www.gnu.org/gethelp/>." 23069d0ccd10Smrg exit 0 23079d0ccd10Smrg} 2308c63293b5Smrg 2309c63293b5Smrg 23109d0ccd10Smrg# func_lo2o OBJECT-NAME 23119d0ccd10Smrg# --------------------- 23129d0ccd10Smrg# Transform OBJECT-NAME from a '.lo' suffix to the platform specific 23139d0ccd10Smrg# object suffix. 2314c63293b5Smrg 23159d0ccd10Smrglo2o=s/\\.lo\$/.$objext/ 23169d0ccd10Smrgo2lo=s/\\.$objext\$/.lo/ 2317c63293b5Smrg 23189d0ccd10Smrgif test yes = "$_G_HAVE_XSI_OPS"; then 23199d0ccd10Smrg eval 'func_lo2o () 23209d0ccd10Smrg { 23219d0ccd10Smrg case $1 in 23229d0ccd10Smrg *.lo) func_lo2o_result=${1%.lo}.$objext ;; 23239d0ccd10Smrg * ) func_lo2o_result=$1 ;; 23249d0ccd10Smrg esac 23259d0ccd10Smrg }' 23269d0ccd10Smrg 23279d0ccd10Smrg # func_xform LIBOBJ-OR-SOURCE 23289d0ccd10Smrg # --------------------------- 23299d0ccd10Smrg # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise) 23309d0ccd10Smrg # suffix to a '.lo' libtool-object suffix. 23319d0ccd10Smrg eval 'func_xform () 23329d0ccd10Smrg { 23339d0ccd10Smrg func_xform_result=${1%.*}.lo 23349d0ccd10Smrg }' 23359d0ccd10Smrgelse 23369d0ccd10Smrg # ...otherwise fall back to using sed. 23379d0ccd10Smrg func_lo2o () 23389d0ccd10Smrg { 23399d0ccd10Smrg func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"` 23409d0ccd10Smrg } 23419d0ccd10Smrg 23429d0ccd10Smrg func_xform () 23439d0ccd10Smrg { 23449d0ccd10Smrg func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'` 23459d0ccd10Smrg } 23469d0ccd10Smrgfi 2347c63293b5Smrg 2348c63293b5Smrg 23499d0ccd10Smrg# func_fatal_configuration ARG... 23509d0ccd10Smrg# ------------------------------- 2351e169010aSmrg# Echo program name prefixed message to standard error, followed by 2352e169010aSmrg# a configuration failure hint, and exit. 2353e169010aSmrgfunc_fatal_configuration () 2354e169010aSmrg{ 23550ea508b1Smrg func_fatal_error ${1+"$@"} \ 23569d0ccd10Smrg "See the $PACKAGE documentation for more information." \ 23579d0ccd10Smrg "Fatal configuration error." 2358e169010aSmrg} 2359e169010aSmrg 2360e169010aSmrg 2361e169010aSmrg# func_config 23629d0ccd10Smrg# ----------- 2363e169010aSmrg# Display the configuration for all the tags in this script. 2364e169010aSmrgfunc_config () 2365e169010aSmrg{ 2366e169010aSmrg re_begincf='^# ### BEGIN LIBTOOL' 2367e169010aSmrg re_endcf='^# ### END LIBTOOL' 2368e169010aSmrg 2369e169010aSmrg # Default configuration. 2370e169010aSmrg $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" 23717914d74bSmrg 23727914d74bSmrg # Now print the configurations for the tags. 23737914d74bSmrg for tagname in $taglist; do 2374e169010aSmrg $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" 23757914d74bSmrg done 23767914d74bSmrg 2377e169010aSmrg exit $? 2378e169010aSmrg} 23797914d74bSmrg 23809d0ccd10Smrg 2381e169010aSmrg# func_features 23829d0ccd10Smrg# ------------- 2383e169010aSmrg# Display the features supported by this script. 2384e169010aSmrgfunc_features () 2385e169010aSmrg{ 2386e8ead290Smrg echo "host: $host" 23879d0ccd10Smrg if test yes = "$build_libtool_libs"; then 2388e8ead290Smrg echo "enable shared libraries" 23897914d74bSmrg else 2390e8ead290Smrg echo "disable shared libraries" 23917914d74bSmrg fi 23929d0ccd10Smrg if test yes = "$build_old_libs"; then 2393e8ead290Smrg echo "enable static libraries" 23947914d74bSmrg else 2395e8ead290Smrg echo "disable static libraries" 23967914d74bSmrg fi 2397e169010aSmrg 23987914d74bSmrg exit $? 2399e169010aSmrg} 2400e169010aSmrg 24019d0ccd10Smrg 24029d0ccd10Smrg# func_enable_tag TAGNAME 24039d0ccd10Smrg# ----------------------- 2404e169010aSmrg# Verify that TAGNAME is valid, and either flag an error and exit, or 2405e169010aSmrg# enable the TAGNAME tag. We also add TAGNAME to the global $taglist 2406e169010aSmrg# variable here. 2407e169010aSmrgfunc_enable_tag () 2408e169010aSmrg{ 24099d0ccd10Smrg # Global variable: 24109d0ccd10Smrg tagname=$1 24117914d74bSmrg 24129d0ccd10Smrg re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" 24139d0ccd10Smrg re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" 24149d0ccd10Smrg sed_extractcf=/$re_begincf/,/$re_endcf/p 24157914d74bSmrg 24169d0ccd10Smrg # Validate tagname. 24179d0ccd10Smrg case $tagname in 24189d0ccd10Smrg *[!-_A-Za-z0-9,/]*) 24199d0ccd10Smrg func_fatal_error "invalid tag name: $tagname" 24209d0ccd10Smrg ;; 24219d0ccd10Smrg esac 24227914d74bSmrg 24239d0ccd10Smrg # Don't test for the "default" C tag, as we know it's 24249d0ccd10Smrg # there but not specially marked. 24259d0ccd10Smrg case $tagname in 24269d0ccd10Smrg CC) ;; 2427e169010aSmrg *) 24289d0ccd10Smrg if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then 24299d0ccd10Smrg taglist="$taglist $tagname" 24309d0ccd10Smrg 24319d0ccd10Smrg # Evaluate the configuration. Be careful to quote the path 24329d0ccd10Smrg # and the sed script, to avoid splitting on whitespace, but 24339d0ccd10Smrg # also don't use non-portable quotes within backquotes within 24349d0ccd10Smrg # quotes we have to do it in 2 steps: 24359d0ccd10Smrg extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` 24369d0ccd10Smrg eval "$extractedcf" 24379d0ccd10Smrg else 24389d0ccd10Smrg func_error "ignoring unknown tag $tagname" 24399d0ccd10Smrg fi 24409d0ccd10Smrg ;; 24419d0ccd10Smrg esac 2442e169010aSmrg} 24437914d74bSmrg 24449d0ccd10Smrg 2445c63293b5Smrg# func_check_version_match 24469d0ccd10Smrg# ------------------------ 2447c63293b5Smrg# Ensure that we are using m4 macros, and libtool script from the same 2448c63293b5Smrg# release of libtool. 2449c63293b5Smrgfunc_check_version_match () 2450e169010aSmrg{ 24519d0ccd10Smrg if test "$package_revision" != "$macro_revision"; then 24529d0ccd10Smrg if test "$VERSION" != "$macro_version"; then 24539d0ccd10Smrg if test -z "$macro_version"; then 24549d0ccd10Smrg cat >&2 <<_LT_EOF 2455c63293b5Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 2456c63293b5Smrg$progname: definition of this LT_INIT comes from an older release. 2457c63293b5Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 2458c63293b5Smrg$progname: and run autoconf again. 2459c63293b5Smrg_LT_EOF 24609d0ccd10Smrg else 24619d0ccd10Smrg cat >&2 <<_LT_EOF 2462c63293b5Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 2463c63293b5Smrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version. 2464c63293b5Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 2465c63293b5Smrg$progname: and run autoconf again. 2466c63293b5Smrg_LT_EOF 24679d0ccd10Smrg fi 24689d0ccd10Smrg else 24699d0ccd10Smrg cat >&2 <<_LT_EOF 2470c63293b5Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, 2471c63293b5Smrg$progname: but the definition of this LT_INIT comes from revision $macro_revision. 2472c63293b5Smrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision 2473c63293b5Smrg$progname: of $PACKAGE $VERSION and run autoconf again. 2474c63293b5Smrg_LT_EOF 24759d0ccd10Smrg fi 24767914d74bSmrg 24779d0ccd10Smrg exit $EXIT_MISMATCH 24789d0ccd10Smrg fi 2479c63293b5Smrg} 2480c63293b5Smrg 2481c63293b5Smrg 24829d0ccd10Smrg# libtool_options_prep [ARG]... 24839d0ccd10Smrg# ----------------------------- 24849d0ccd10Smrg# Preparation for options parsed by libtool. 24859d0ccd10Smrglibtool_options_prep () 24869d0ccd10Smrg{ 24879d0ccd10Smrg $debug_mode 24887914d74bSmrg 24899d0ccd10Smrg # Option defaults: 24909d0ccd10Smrg opt_config=false 24919d0ccd10Smrg opt_dlopen= 24929d0ccd10Smrg opt_dry_run=false 24939d0ccd10Smrg opt_help=false 24949d0ccd10Smrg opt_mode= 24959d0ccd10Smrg opt_preserve_dup_deps=false 24969d0ccd10Smrg opt_quiet=false 2497c63293b5Smrg 24989d0ccd10Smrg nonopt= 24999d0ccd10Smrg preserve_args= 2500c63293b5Smrg 25010ea508b1Smrg _G_rc_lt_options_prep=: 25020ea508b1Smrg 25036b7436aeSmrg _G_rc_lt_options_prep=: 25046b7436aeSmrg 25059d0ccd10Smrg # Shorthand for --mode=foo, only valid as the first argument 25069d0ccd10Smrg case $1 in 25079d0ccd10Smrg clean|clea|cle|cl) 25089d0ccd10Smrg shift; set dummy --mode clean ${1+"$@"}; shift 25099d0ccd10Smrg ;; 25109d0ccd10Smrg compile|compil|compi|comp|com|co|c) 25119d0ccd10Smrg shift; set dummy --mode compile ${1+"$@"}; shift 25129d0ccd10Smrg ;; 25139d0ccd10Smrg execute|execut|execu|exec|exe|ex|e) 25149d0ccd10Smrg shift; set dummy --mode execute ${1+"$@"}; shift 25159d0ccd10Smrg ;; 25169d0ccd10Smrg finish|finis|fini|fin|fi|f) 25179d0ccd10Smrg shift; set dummy --mode finish ${1+"$@"}; shift 25189d0ccd10Smrg ;; 25199d0ccd10Smrg install|instal|insta|inst|ins|in|i) 25209d0ccd10Smrg shift; set dummy --mode install ${1+"$@"}; shift 25219d0ccd10Smrg ;; 25229d0ccd10Smrg link|lin|li|l) 25239d0ccd10Smrg shift; set dummy --mode link ${1+"$@"}; shift 25249d0ccd10Smrg ;; 25259d0ccd10Smrg uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) 25269d0ccd10Smrg shift; set dummy --mode uninstall ${1+"$@"}; shift 25279d0ccd10Smrg ;; 25280ea508b1Smrg *) 25290ea508b1Smrg _G_rc_lt_options_prep=false 25300ea508b1Smrg ;; 25319d0ccd10Smrg esac 25329d0ccd10Smrg 25330ea508b1Smrg if $_G_rc_lt_options_prep; then 25340ea508b1Smrg # Pass back the list of options. 25350ea508b1Smrg func_quote eval ${1+"$@"} 25360ea508b1Smrg libtool_options_prep_result=$func_quote_result 25370ea508b1Smrg fi 25389d0ccd10Smrg} 25399d0ccd10Smrgfunc_add_hook func_options_prep libtool_options_prep 2540c63293b5Smrg 2541c63293b5Smrg 25429d0ccd10Smrg# libtool_parse_options [ARG]... 25439d0ccd10Smrg# --------------------------------- 25449d0ccd10Smrg# Provide handling for libtool specific options. 25459d0ccd10Smrglibtool_parse_options () 2546c63293b5Smrg{ 25479d0ccd10Smrg $debug_cmd 2548e169010aSmrg 25490ea508b1Smrg _G_rc_lt_parse_options=false 25500ea508b1Smrg 25519d0ccd10Smrg # Perform our own loop to consume as many options as possible in 25529d0ccd10Smrg # each iteration. 25539d0ccd10Smrg while test $# -gt 0; do 25540ea508b1Smrg _G_match_lt_parse_options=: 25559d0ccd10Smrg _G_opt=$1 25569d0ccd10Smrg shift 25579d0ccd10Smrg case $_G_opt in 25589d0ccd10Smrg --dry-run|--dryrun|-n) 25599d0ccd10Smrg opt_dry_run=: 25609d0ccd10Smrg ;; 25619d0ccd10Smrg 25629d0ccd10Smrg --config) func_config ;; 25639d0ccd10Smrg 25649d0ccd10Smrg --dlopen|-dlopen) 25659d0ccd10Smrg opt_dlopen="${opt_dlopen+$opt_dlopen 25669d0ccd10Smrg}$1" 25679d0ccd10Smrg shift 25689d0ccd10Smrg ;; 25699d0ccd10Smrg 25709d0ccd10Smrg --preserve-dup-deps) 25719d0ccd10Smrg opt_preserve_dup_deps=: ;; 25729d0ccd10Smrg 25739d0ccd10Smrg --features) func_features ;; 25749d0ccd10Smrg 25759d0ccd10Smrg --finish) set dummy --mode finish ${1+"$@"}; shift ;; 25769d0ccd10Smrg 25779d0ccd10Smrg --help) opt_help=: ;; 25789d0ccd10Smrg 25799d0ccd10Smrg --help-all) opt_help=': help-all' ;; 25809d0ccd10Smrg 25819d0ccd10Smrg --mode) test $# = 0 && func_missing_arg $_G_opt && break 25829d0ccd10Smrg opt_mode=$1 25839d0ccd10Smrg case $1 in 25849d0ccd10Smrg # Valid mode arguments: 25859d0ccd10Smrg clean|compile|execute|finish|install|link|relink|uninstall) ;; 25869d0ccd10Smrg 25879d0ccd10Smrg # Catch anything else as an error 25889d0ccd10Smrg *) func_error "invalid argument for $_G_opt" 25899d0ccd10Smrg exit_cmd=exit 25909d0ccd10Smrg break 25919d0ccd10Smrg ;; 25929d0ccd10Smrg esac 25939d0ccd10Smrg shift 25949d0ccd10Smrg ;; 25959d0ccd10Smrg 25969d0ccd10Smrg --no-silent|--no-quiet) 25979d0ccd10Smrg opt_quiet=false 25989d0ccd10Smrg func_append preserve_args " $_G_opt" 25999d0ccd10Smrg ;; 26009d0ccd10Smrg 26019d0ccd10Smrg --no-warnings|--no-warning|--no-warn) 26029d0ccd10Smrg opt_warning=false 26039d0ccd10Smrg func_append preserve_args " $_G_opt" 26049d0ccd10Smrg ;; 26059d0ccd10Smrg 26069d0ccd10Smrg --no-verbose) 26079d0ccd10Smrg opt_verbose=false 26089d0ccd10Smrg func_append preserve_args " $_G_opt" 26099d0ccd10Smrg ;; 26109d0ccd10Smrg 26119d0ccd10Smrg --silent|--quiet) 26129d0ccd10Smrg opt_quiet=: 26139d0ccd10Smrg opt_verbose=false 26149d0ccd10Smrg func_append preserve_args " $_G_opt" 26159d0ccd10Smrg ;; 26169d0ccd10Smrg 26179d0ccd10Smrg --tag) test $# = 0 && func_missing_arg $_G_opt && break 26189d0ccd10Smrg opt_tag=$1 26199d0ccd10Smrg func_append preserve_args " $_G_opt $1" 26209d0ccd10Smrg func_enable_tag "$1" 26219d0ccd10Smrg shift 26229d0ccd10Smrg ;; 26239d0ccd10Smrg 26249d0ccd10Smrg --verbose|-v) opt_quiet=false 26259d0ccd10Smrg opt_verbose=: 26269d0ccd10Smrg func_append preserve_args " $_G_opt" 26279d0ccd10Smrg ;; 26289d0ccd10Smrg 26290ea508b1Smrg # An option not handled by this hook function: 26300ea508b1Smrg *) set dummy "$_G_opt" ${1+"$@"} ; shift 26310ea508b1Smrg _G_match_lt_parse_options=false 26320ea508b1Smrg break 26330ea508b1Smrg ;; 26349d0ccd10Smrg esac 26350ea508b1Smrg $_G_match_lt_parse_options && _G_rc_lt_parse_options=: 26369d0ccd10Smrg done 2637c63293b5Smrg 26380ea508b1Smrg if $_G_rc_lt_parse_options; then 26390ea508b1Smrg # save modified positional parameters for caller 26400ea508b1Smrg func_quote eval ${1+"$@"} 26410ea508b1Smrg libtool_parse_options_result=$func_quote_result 26420ea508b1Smrg fi 26439d0ccd10Smrg} 26449d0ccd10Smrgfunc_add_hook func_parse_options libtool_parse_options 2645e169010aSmrg 26467914d74bSmrg 2647e169010aSmrg 26489d0ccd10Smrg# libtool_validate_options [ARG]... 26499d0ccd10Smrg# --------------------------------- 26509d0ccd10Smrg# Perform any sanity checks on option settings and/or unconsumed 26519d0ccd10Smrg# arguments. 26529d0ccd10Smrglibtool_validate_options () 26539d0ccd10Smrg{ 26549d0ccd10Smrg # save first non-option argument 26559d0ccd10Smrg if test 0 -lt $#; then 26569d0ccd10Smrg nonopt=$1 26579d0ccd10Smrg shift 2658e169010aSmrg fi 2659e169010aSmrg 26609d0ccd10Smrg # preserve --debug 26619d0ccd10Smrg test : = "$debug_cmd" || func_append preserve_args " --debug" 2662e169010aSmrg 26639d0ccd10Smrg case $host in 26649d0ccd10Smrg # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452 26659d0ccd10Smrg # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788 26669d0ccd10Smrg *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*) 26679d0ccd10Smrg # don't eliminate duplications in $postdeps and $predeps 26689d0ccd10Smrg opt_duplicate_compiler_generated_deps=: 26699d0ccd10Smrg ;; 26709d0ccd10Smrg *) 26719d0ccd10Smrg opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps 26729d0ccd10Smrg ;; 26739d0ccd10Smrg esac 2674e169010aSmrg 26759d0ccd10Smrg $opt_help || { 26769d0ccd10Smrg # Sanity checks first: 26779d0ccd10Smrg func_check_version_match 2678e169010aSmrg 26799d0ccd10Smrg test yes != "$build_libtool_libs" \ 26809d0ccd10Smrg && test yes != "$build_old_libs" \ 26819d0ccd10Smrg && func_fatal_configuration "not configured to build any kind of library" 2682e169010aSmrg 26839d0ccd10Smrg # Darwin sucks 26849d0ccd10Smrg eval std_shrext=\"$shrext_cmds\" 26859d0ccd10Smrg 26869d0ccd10Smrg # Only execute mode is allowed to have -dlopen flags. 26879d0ccd10Smrg if test -n "$opt_dlopen" && test execute != "$opt_mode"; then 26889d0ccd10Smrg func_error "unrecognized option '-dlopen'" 26899d0ccd10Smrg $ECHO "$help" 1>&2 26909d0ccd10Smrg exit $EXIT_FAILURE 26919d0ccd10Smrg fi 26929d0ccd10Smrg 26939d0ccd10Smrg # Change the help message to a mode-specific one. 26949d0ccd10Smrg generic_help=$help 26959d0ccd10Smrg help="Try '$progname --help --mode=$opt_mode' for more information." 26969d0ccd10Smrg } 26979d0ccd10Smrg 26989d0ccd10Smrg # Pass back the unparsed argument list 26990ea508b1Smrg func_quote eval ${1+"$@"} 27000ea508b1Smrg libtool_validate_options_result=$func_quote_result 2701c63293b5Smrg} 27029d0ccd10Smrgfunc_add_hook func_validate_options libtool_validate_options 27039d0ccd10Smrg 2704e169010aSmrg 27059d0ccd10Smrg# Process options as early as possible so that --help and --version 27069d0ccd10Smrg# can return quickly. 27079d0ccd10Smrgfunc_options ${1+"$@"} 27089d0ccd10Smrgeval set dummy "$func_options_result"; shift 2709e169010aSmrg 27107914d74bSmrg 27117914d74bSmrg 2712c63293b5Smrg## ----------- ## 2713c63293b5Smrg## Main. ## 2714c63293b5Smrg## ----------- ## 27157914d74bSmrg 27169d0ccd10Smrgmagic='%%%MAGIC variable%%%' 27179d0ccd10Smrgmagic_exe='%%%MAGIC EXE variable%%%' 27189d0ccd10Smrg 27199d0ccd10Smrg# Global variables. 27209d0ccd10Smrgextracted_archives= 27219d0ccd10Smrgextracted_serial=0 27229d0ccd10Smrg 27239d0ccd10Smrg# If this variable is set in any of the actions, the command in it 27249d0ccd10Smrg# will be execed at the end. This prevents here-documents from being 27259d0ccd10Smrg# left over by shells. 27269d0ccd10Smrgexec_cmd= 27279d0ccd10Smrg 27289d0ccd10Smrg 27299d0ccd10Smrg# A function that is used when there is no print builtin or printf. 27309d0ccd10Smrgfunc_fallback_echo () 27319d0ccd10Smrg{ 27329d0ccd10Smrg eval 'cat <<_LTECHO_EOF 27339d0ccd10Smrg$1 27349d0ccd10Smrg_LTECHO_EOF' 27359d0ccd10Smrg} 27369d0ccd10Smrg 27379d0ccd10Smrg# func_generated_by_libtool 27389d0ccd10Smrg# True iff stdin has been generated by Libtool. This function is only 27399d0ccd10Smrg# a basic sanity check; it will hardly flush out determined imposters. 27409d0ccd10Smrgfunc_generated_by_libtool_p () 27419d0ccd10Smrg{ 27429d0ccd10Smrg $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 27439d0ccd10Smrg} 27449d0ccd10Smrg 2745e169010aSmrg# func_lalib_p file 27469d0ccd10Smrg# True iff FILE is a libtool '.la' library or '.lo' object file. 2747e169010aSmrg# This function is only a basic sanity check; it will hardly flush out 2748e169010aSmrg# determined imposters. 2749e169010aSmrgfunc_lalib_p () 2750e169010aSmrg{ 2751e169010aSmrg test -f "$1" && 27529d0ccd10Smrg $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p 2753e169010aSmrg} 27547914d74bSmrg 2755e169010aSmrg# func_lalib_unsafe_p file 27569d0ccd10Smrg# True iff FILE is a libtool '.la' library or '.lo' object file. 2757e169010aSmrg# This function implements the same check as func_lalib_p without 2758e169010aSmrg# resorting to external programs. To this end, it redirects stdin and 2759e169010aSmrg# closes it afterwards, without saving the original file descriptor. 2760e169010aSmrg# As a safety measure, use it only where a negative result would be 27619d0ccd10Smrg# fatal anyway. Works if 'file' does not exist. 2762e169010aSmrgfunc_lalib_unsafe_p () 2763e169010aSmrg{ 2764e169010aSmrg lalib_p=no 2765e169010aSmrg if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then 2766e169010aSmrg for lalib_p_l in 1 2 3 4 2767e169010aSmrg do 2768e169010aSmrg read lalib_p_line 27699d0ccd10Smrg case $lalib_p_line in 2770e169010aSmrg \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; 2771e169010aSmrg esac 2772e169010aSmrg done 2773e169010aSmrg exec 0<&5 5<&- 2774e169010aSmrg fi 27759d0ccd10Smrg test yes = "$lalib_p" 2776e169010aSmrg} 27777914d74bSmrg 2778e169010aSmrg# func_ltwrapper_script_p file 2779e169010aSmrg# True iff FILE is a libtool wrapper script 2780e169010aSmrg# This function is only a basic sanity check; it will hardly flush out 2781e169010aSmrg# determined imposters. 2782e169010aSmrgfunc_ltwrapper_script_p () 2783e169010aSmrg{ 27849d0ccd10Smrg test -f "$1" && 27859d0ccd10Smrg $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p 2786e169010aSmrg} 27877914d74bSmrg 2788e169010aSmrg# func_ltwrapper_executable_p file 2789e169010aSmrg# True iff FILE is a libtool wrapper executable 2790e169010aSmrg# This function is only a basic sanity check; it will hardly flush out 2791e169010aSmrg# determined imposters. 2792e169010aSmrgfunc_ltwrapper_executable_p () 2793e169010aSmrg{ 2794e169010aSmrg func_ltwrapper_exec_suffix= 2795e169010aSmrg case $1 in 2796e169010aSmrg *.exe) ;; 2797e169010aSmrg *) func_ltwrapper_exec_suffix=.exe ;; 2798e169010aSmrg esac 2799e169010aSmrg $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 2800e169010aSmrg} 28017914d74bSmrg 2802e169010aSmrg# func_ltwrapper_scriptname file 2803e169010aSmrg# Assumes file is an ltwrapper_executable 2804e169010aSmrg# uses $file to determine the appropriate filename for a 2805e169010aSmrg# temporary ltwrapper_script. 2806e169010aSmrgfunc_ltwrapper_scriptname () 2807e169010aSmrg{ 2808c63293b5Smrg func_dirname_and_basename "$1" "" "." 2809c63293b5Smrg func_stripname '' '.exe' "$func_basename_result" 28109d0ccd10Smrg func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper 2811e169010aSmrg} 28127914d74bSmrg 2813e169010aSmrg# func_ltwrapper_p file 2814e169010aSmrg# True iff FILE is a libtool wrapper script or wrapper executable 2815e169010aSmrg# This function is only a basic sanity check; it will hardly flush out 2816e169010aSmrg# determined imposters. 2817e169010aSmrgfunc_ltwrapper_p () 2818e169010aSmrg{ 2819e169010aSmrg func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" 2820e169010aSmrg} 28217914d74bSmrg 28227914d74bSmrg 2823e169010aSmrg# func_execute_cmds commands fail_cmd 2824e169010aSmrg# Execute tilde-delimited COMMANDS. 2825e169010aSmrg# If FAIL_CMD is given, eval that upon failure. 2826e169010aSmrg# FAIL_CMD may read-access the current command in variable CMD! 2827e169010aSmrgfunc_execute_cmds () 2828e169010aSmrg{ 28299d0ccd10Smrg $debug_cmd 28309d0ccd10Smrg 2831e169010aSmrg save_ifs=$IFS; IFS='~' 2832e169010aSmrg for cmd in $1; do 28339d0ccd10Smrg IFS=$sp$nl 2834e169010aSmrg eval cmd=\"$cmd\" 28359d0ccd10Smrg IFS=$save_ifs 2836e169010aSmrg func_show_eval "$cmd" "${2-:}" 2837e169010aSmrg done 2838e169010aSmrg IFS=$save_ifs 2839e169010aSmrg} 2840e169010aSmrg 2841e169010aSmrg 2842e169010aSmrg# func_source file 2843e169010aSmrg# Source FILE, adding directory component if necessary. 2844e169010aSmrg# Note that it is not necessary on cygwin/mingw to append a dot to 2845e169010aSmrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe 2846e169010aSmrg# behavior happens only for exec(3), not for open(2)! Also, sourcing 28479d0ccd10Smrg# 'FILE.' does not work on cygwin managed mounts. 2848e169010aSmrgfunc_source () 2849e169010aSmrg{ 28509d0ccd10Smrg $debug_cmd 28519d0ccd10Smrg 2852e169010aSmrg case $1 in 2853e169010aSmrg */* | *\\*) . "$1" ;; 2854e169010aSmrg *) . "./$1" ;; 2855e169010aSmrg esac 2856e169010aSmrg} 2857e169010aSmrg 2858e169010aSmrg 2859c63293b5Smrg# func_resolve_sysroot PATH 2860c63293b5Smrg# Replace a leading = in PATH with a sysroot. Store the result into 2861c63293b5Smrg# func_resolve_sysroot_result 2862c63293b5Smrgfunc_resolve_sysroot () 2863c63293b5Smrg{ 2864c63293b5Smrg func_resolve_sysroot_result=$1 2865c63293b5Smrg case $func_resolve_sysroot_result in 2866c63293b5Smrg =*) 2867c63293b5Smrg func_stripname '=' '' "$func_resolve_sysroot_result" 2868c63293b5Smrg func_resolve_sysroot_result=$lt_sysroot$func_stripname_result 2869c63293b5Smrg ;; 2870c63293b5Smrg esac 2871c63293b5Smrg} 2872c63293b5Smrg 2873c63293b5Smrg# func_replace_sysroot PATH 2874c63293b5Smrg# If PATH begins with the sysroot, replace it with = and 2875c63293b5Smrg# store the result into func_replace_sysroot_result. 2876c63293b5Smrgfunc_replace_sysroot () 2877c63293b5Smrg{ 28789d0ccd10Smrg case $lt_sysroot:$1 in 2879c63293b5Smrg ?*:"$lt_sysroot"*) 2880c63293b5Smrg func_stripname "$lt_sysroot" '' "$1" 28819d0ccd10Smrg func_replace_sysroot_result='='$func_stripname_result 2882c63293b5Smrg ;; 2883c63293b5Smrg *) 2884c63293b5Smrg # Including no sysroot. 2885c63293b5Smrg func_replace_sysroot_result=$1 2886c63293b5Smrg ;; 2887c63293b5Smrg esac 2888c63293b5Smrg} 2889c63293b5Smrg 2890e169010aSmrg# func_infer_tag arg 2891e169010aSmrg# Infer tagged configuration to use if any are available and 2892e169010aSmrg# if one wasn't chosen via the "--tag" command line option. 2893e169010aSmrg# Only attempt this if the compiler in the base compile 2894e169010aSmrg# command doesn't match the default compiler. 2895e169010aSmrg# arg is usually of the form 'gcc ...' 2896e169010aSmrgfunc_infer_tag () 2897e169010aSmrg{ 28989d0ccd10Smrg $debug_cmd 28999d0ccd10Smrg 2900e169010aSmrg if test -n "$available_tags" && test -z "$tagname"; then 2901e169010aSmrg CC_quoted= 2902e169010aSmrg for arg in $CC; do 2903c63293b5Smrg func_append_quoted CC_quoted "$arg" 2904e169010aSmrg done 2905e8ead290Smrg CC_expanded=`func_echo_all $CC` 2906e8ead290Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 2907e169010aSmrg case $@ in 2908e169010aSmrg # Blanks in the command may have been stripped by the calling shell, 2909e169010aSmrg # but not from the CC environment variable when configure was run. 2910e8ead290Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 2911e8ead290Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; 2912e169010aSmrg # Blanks at the start of $base_compile will cause this to fail 2913e169010aSmrg # if we don't check for them as well. 2914e169010aSmrg *) 2915e169010aSmrg for z in $available_tags; do 2916e169010aSmrg if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then 2917e169010aSmrg # Evaluate the configuration. 29189d0ccd10Smrg eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" 2919e169010aSmrg CC_quoted= 2920e169010aSmrg for arg in $CC; do 2921e169010aSmrg # Double-quote args containing other shell metacharacters. 2922c63293b5Smrg func_append_quoted CC_quoted "$arg" 2923e169010aSmrg done 2924e8ead290Smrg CC_expanded=`func_echo_all $CC` 2925e8ead290Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 2926e169010aSmrg case "$@ " in 2927e8ead290Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 2928e8ead290Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) 2929e169010aSmrg # The compiler in the base compile command matches 2930e169010aSmrg # the one in the tagged configuration. 2931e169010aSmrg # Assume this is the tagged configuration we want. 2932e169010aSmrg tagname=$z 2933e169010aSmrg break 2934e169010aSmrg ;; 29357914d74bSmrg esac 2936e169010aSmrg fi 2937e169010aSmrg done 2938e169010aSmrg # If $tagname still isn't set, then no tagged configuration 2939e169010aSmrg # was found and let the user know that the "--tag" command 2940e169010aSmrg # line option must be used. 2941e169010aSmrg if test -z "$tagname"; then 2942e169010aSmrg func_echo "unable to infer tagged configuration" 29439d0ccd10Smrg func_fatal_error "specify a tag with '--tag'" 2944e169010aSmrg# else 2945e169010aSmrg# func_verbose "using $tagname tagged configuration" 2946e169010aSmrg fi 2947e169010aSmrg ;; 2948e169010aSmrg esac 2949e169010aSmrg fi 2950e169010aSmrg} 2951e169010aSmrg 2952e169010aSmrg 2953e169010aSmrg 2954c63293b5Smrg# func_write_libtool_object output_name pic_name nonpic_name 2955c63293b5Smrg# Create a libtool object file (analogous to a ".la" file), 2956c63293b5Smrg# but don't create it if we're doing a dry run. 2957c63293b5Smrgfunc_write_libtool_object () 2958c63293b5Smrg{ 29599d0ccd10Smrg write_libobj=$1 29609d0ccd10Smrg if test yes = "$build_libtool_libs"; then 29619d0ccd10Smrg write_lobj=\'$2\' 2962c63293b5Smrg else 2963c63293b5Smrg write_lobj=none 2964c63293b5Smrg fi 2965c63293b5Smrg 29669d0ccd10Smrg if test yes = "$build_old_libs"; then 29679d0ccd10Smrg write_oldobj=\'$3\' 2968c63293b5Smrg else 2969c63293b5Smrg write_oldobj=none 2970c63293b5Smrg fi 2971c63293b5Smrg 2972c63293b5Smrg $opt_dry_run || { 2973c63293b5Smrg cat >${write_libobj}T <<EOF 2974c63293b5Smrg# $write_libobj - a libtool object file 29759d0ccd10Smrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 2976c63293b5Smrg# 2977c63293b5Smrg# Please DO NOT delete this file! 2978c63293b5Smrg# It is necessary for linking the library. 2979c63293b5Smrg 2980c63293b5Smrg# Name of the PIC object. 2981c63293b5Smrgpic_object=$write_lobj 2982c63293b5Smrg 2983c63293b5Smrg# Name of the non-PIC object 2984c63293b5Smrgnon_pic_object=$write_oldobj 2985c63293b5Smrg 2986c63293b5SmrgEOF 29879d0ccd10Smrg $MV "${write_libobj}T" "$write_libobj" 2988c63293b5Smrg } 2989c63293b5Smrg} 2990c63293b5Smrg 2991c63293b5Smrg 2992c63293b5Smrg################################################## 2993c63293b5Smrg# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS # 2994c63293b5Smrg################################################## 2995c63293b5Smrg 2996c63293b5Smrg# func_convert_core_file_wine_to_w32 ARG 2997c63293b5Smrg# Helper function used by file name conversion functions when $build is *nix, 2998c63293b5Smrg# and $host is mingw, cygwin, or some other w32 environment. Relies on a 2999c63293b5Smrg# correctly configured wine environment available, with the winepath program 3000c63293b5Smrg# in $build's $PATH. 3001c63293b5Smrg# 3002c63293b5Smrg# ARG is the $build file name to be converted to w32 format. 3003c63293b5Smrg# Result is available in $func_convert_core_file_wine_to_w32_result, and will 3004c63293b5Smrg# be empty on error (or when ARG is empty) 3005c63293b5Smrgfunc_convert_core_file_wine_to_w32 () 3006c63293b5Smrg{ 30079d0ccd10Smrg $debug_cmd 30089d0ccd10Smrg 30099d0ccd10Smrg func_convert_core_file_wine_to_w32_result=$1 3010c63293b5Smrg if test -n "$1"; then 3011c63293b5Smrg # Unfortunately, winepath does not exit with a non-zero error code, so we 3012c63293b5Smrg # are forced to check the contents of stdout. On the other hand, if the 3013c63293b5Smrg # command is not found, the shell will set an exit code of 127 and print 3014c63293b5Smrg # *an error message* to stdout. So we must check for both error code of 3015c63293b5Smrg # zero AND non-empty stdout, which explains the odd construction: 3016c63293b5Smrg func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null` 30179d0ccd10Smrg if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then 3018c63293b5Smrg func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | 30199d0ccd10Smrg $SED -e "$sed_naive_backslashify"` 3020c63293b5Smrg else 3021c63293b5Smrg func_convert_core_file_wine_to_w32_result= 3022c63293b5Smrg fi 3023c63293b5Smrg fi 3024c63293b5Smrg} 3025c63293b5Smrg# end: func_convert_core_file_wine_to_w32 3026c63293b5Smrg 3027c63293b5Smrg 3028c63293b5Smrg# func_convert_core_path_wine_to_w32 ARG 3029c63293b5Smrg# Helper function used by path conversion functions when $build is *nix, and 3030c63293b5Smrg# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly 3031c63293b5Smrg# configured wine environment available, with the winepath program in $build's 3032c63293b5Smrg# $PATH. Assumes ARG has no leading or trailing path separator characters. 3033c63293b5Smrg# 3034c63293b5Smrg# ARG is path to be converted from $build format to win32. 3035c63293b5Smrg# Result is available in $func_convert_core_path_wine_to_w32_result. 3036c63293b5Smrg# Unconvertible file (directory) names in ARG are skipped; if no directory names 3037c63293b5Smrg# are convertible, then the result may be empty. 3038c63293b5Smrgfunc_convert_core_path_wine_to_w32 () 3039c63293b5Smrg{ 30409d0ccd10Smrg $debug_cmd 30419d0ccd10Smrg 3042c63293b5Smrg # unfortunately, winepath doesn't convert paths, only file names 30439d0ccd10Smrg func_convert_core_path_wine_to_w32_result= 3044c63293b5Smrg if test -n "$1"; then 3045c63293b5Smrg oldIFS=$IFS 3046c63293b5Smrg IFS=: 3047c63293b5Smrg for func_convert_core_path_wine_to_w32_f in $1; do 3048c63293b5Smrg IFS=$oldIFS 3049c63293b5Smrg func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" 30509d0ccd10Smrg if test -n "$func_convert_core_file_wine_to_w32_result"; then 3051c63293b5Smrg if test -z "$func_convert_core_path_wine_to_w32_result"; then 30529d0ccd10Smrg func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result 3053c63293b5Smrg else 3054c63293b5Smrg func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" 3055c63293b5Smrg fi 3056c63293b5Smrg fi 3057c63293b5Smrg done 3058c63293b5Smrg IFS=$oldIFS 3059c63293b5Smrg fi 3060c63293b5Smrg} 3061c63293b5Smrg# end: func_convert_core_path_wine_to_w32 3062c63293b5Smrg 3063c63293b5Smrg 3064c63293b5Smrg# func_cygpath ARGS... 3065c63293b5Smrg# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when 3066c63293b5Smrg# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) 3067c63293b5Smrg# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or 3068c63293b5Smrg# (2), returns the Cygwin file name or path in func_cygpath_result (input 3069c63293b5Smrg# file name or path is assumed to be in w32 format, as previously converted 3070c63293b5Smrg# from $build's *nix or MSYS format). In case (3), returns the w32 file name 3071c63293b5Smrg# or path in func_cygpath_result (input file name or path is assumed to be in 3072c63293b5Smrg# Cygwin format). Returns an empty string on error. 3073c63293b5Smrg# 3074c63293b5Smrg# ARGS are passed to cygpath, with the last one being the file name or path to 3075c63293b5Smrg# be converted. 3076c63293b5Smrg# 3077c63293b5Smrg# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH 3078c63293b5Smrg# environment variable; do not put it in $PATH. 3079c63293b5Smrgfunc_cygpath () 3080c63293b5Smrg{ 30819d0ccd10Smrg $debug_cmd 30829d0ccd10Smrg 3083c63293b5Smrg if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then 3084c63293b5Smrg func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` 3085c63293b5Smrg if test "$?" -ne 0; then 3086c63293b5Smrg # on failure, ensure result is empty 3087c63293b5Smrg func_cygpath_result= 3088c63293b5Smrg fi 3089c63293b5Smrg else 3090c63293b5Smrg func_cygpath_result= 30919d0ccd10Smrg func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'" 3092c63293b5Smrg fi 3093c63293b5Smrg} 3094c63293b5Smrg#end: func_cygpath 3095c63293b5Smrg 3096c63293b5Smrg 3097c63293b5Smrg# func_convert_core_msys_to_w32 ARG 3098c63293b5Smrg# Convert file name or path ARG from MSYS format to w32 format. Return 3099c63293b5Smrg# result in func_convert_core_msys_to_w32_result. 3100c63293b5Smrgfunc_convert_core_msys_to_w32 () 3101c63293b5Smrg{ 31029d0ccd10Smrg $debug_cmd 31039d0ccd10Smrg 3104c63293b5Smrg # awkward: cmd appends spaces to result 3105c63293b5Smrg func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | 31069d0ccd10Smrg $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"` 3107c63293b5Smrg} 3108c63293b5Smrg#end: func_convert_core_msys_to_w32 3109c63293b5Smrg 3110c63293b5Smrg 3111c63293b5Smrg# func_convert_file_check ARG1 ARG2 3112c63293b5Smrg# Verify that ARG1 (a file name in $build format) was converted to $host 3113c63293b5Smrg# format in ARG2. Otherwise, emit an error message, but continue (resetting 3114c63293b5Smrg# func_to_host_file_result to ARG1). 3115c63293b5Smrgfunc_convert_file_check () 3116c63293b5Smrg{ 31179d0ccd10Smrg $debug_cmd 31189d0ccd10Smrg 31199d0ccd10Smrg if test -z "$2" && test -n "$1"; then 3120c63293b5Smrg func_error "Could not determine host file name corresponding to" 31219d0ccd10Smrg func_error " '$1'" 3122c63293b5Smrg func_error "Continuing, but uninstalled executables may not work." 3123c63293b5Smrg # Fallback: 31249d0ccd10Smrg func_to_host_file_result=$1 3125c63293b5Smrg fi 3126c63293b5Smrg} 3127c63293b5Smrg# end func_convert_file_check 3128c63293b5Smrg 3129c63293b5Smrg 3130c63293b5Smrg# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH 3131c63293b5Smrg# Verify that FROM_PATH (a path in $build format) was converted to $host 3132c63293b5Smrg# format in TO_PATH. Otherwise, emit an error message, but continue, resetting 3133c63293b5Smrg# func_to_host_file_result to a simplistic fallback value (see below). 3134c63293b5Smrgfunc_convert_path_check () 3135c63293b5Smrg{ 31369d0ccd10Smrg $debug_cmd 31379d0ccd10Smrg 3138c63293b5Smrg if test -z "$4" && test -n "$3"; then 3139c63293b5Smrg func_error "Could not determine the host path corresponding to" 31409d0ccd10Smrg func_error " '$3'" 3141c63293b5Smrg func_error "Continuing, but uninstalled executables may not work." 3142c63293b5Smrg # Fallback. This is a deliberately simplistic "conversion" and 3143c63293b5Smrg # should not be "improved". See libtool.info. 3144c63293b5Smrg if test "x$1" != "x$2"; then 3145c63293b5Smrg lt_replace_pathsep_chars="s|$1|$2|g" 3146c63293b5Smrg func_to_host_path_result=`echo "$3" | 3147c63293b5Smrg $SED -e "$lt_replace_pathsep_chars"` 3148c63293b5Smrg else 31499d0ccd10Smrg func_to_host_path_result=$3 3150c63293b5Smrg fi 3151c63293b5Smrg fi 3152c63293b5Smrg} 3153c63293b5Smrg# end func_convert_path_check 3154c63293b5Smrg 3155c63293b5Smrg 3156c63293b5Smrg# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG 3157c63293b5Smrg# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT 3158c63293b5Smrg# and appending REPL if ORIG matches BACKPAT. 3159c63293b5Smrgfunc_convert_path_front_back_pathsep () 3160c63293b5Smrg{ 31619d0ccd10Smrg $debug_cmd 31629d0ccd10Smrg 3163c63293b5Smrg case $4 in 31649d0ccd10Smrg $1 ) func_to_host_path_result=$3$func_to_host_path_result 3165c63293b5Smrg ;; 3166c63293b5Smrg esac 3167c63293b5Smrg case $4 in 3168c63293b5Smrg $2 ) func_append func_to_host_path_result "$3" 3169c63293b5Smrg ;; 3170c63293b5Smrg esac 3171c63293b5Smrg} 3172c63293b5Smrg# end func_convert_path_front_back_pathsep 3173c63293b5Smrg 3174c63293b5Smrg 3175c63293b5Smrg################################################## 3176c63293b5Smrg# $build to $host FILE NAME CONVERSION FUNCTIONS # 3177c63293b5Smrg################################################## 31789d0ccd10Smrg# invoked via '$to_host_file_cmd ARG' 3179c63293b5Smrg# 3180c63293b5Smrg# In each case, ARG is the path to be converted from $build to $host format. 3181c63293b5Smrg# Result will be available in $func_to_host_file_result. 3182c63293b5Smrg 3183c63293b5Smrg 3184c63293b5Smrg# func_to_host_file ARG 3185c63293b5Smrg# Converts the file name ARG from $build format to $host format. Return result 3186c63293b5Smrg# in func_to_host_file_result. 3187c63293b5Smrgfunc_to_host_file () 3188c63293b5Smrg{ 31899d0ccd10Smrg $debug_cmd 31909d0ccd10Smrg 3191c63293b5Smrg $to_host_file_cmd "$1" 3192c63293b5Smrg} 3193c63293b5Smrg# end func_to_host_file 3194c63293b5Smrg 3195c63293b5Smrg 3196c63293b5Smrg# func_to_tool_file ARG LAZY 3197c63293b5Smrg# converts the file name ARG from $build format to toolchain format. Return 3198c63293b5Smrg# result in func_to_tool_file_result. If the conversion in use is listed 3199c63293b5Smrg# in (the comma separated) LAZY, no conversion takes place. 3200c63293b5Smrgfunc_to_tool_file () 3201c63293b5Smrg{ 32029d0ccd10Smrg $debug_cmd 32039d0ccd10Smrg 3204c63293b5Smrg case ,$2, in 3205c63293b5Smrg *,"$to_tool_file_cmd",*) 3206c63293b5Smrg func_to_tool_file_result=$1 3207c63293b5Smrg ;; 3208c63293b5Smrg *) 3209c63293b5Smrg $to_tool_file_cmd "$1" 3210c63293b5Smrg func_to_tool_file_result=$func_to_host_file_result 3211c63293b5Smrg ;; 3212c63293b5Smrg esac 3213c63293b5Smrg} 3214c63293b5Smrg# end func_to_tool_file 3215c63293b5Smrg 3216c63293b5Smrg 3217c63293b5Smrg# func_convert_file_noop ARG 3218c63293b5Smrg# Copy ARG to func_to_host_file_result. 3219c63293b5Smrgfunc_convert_file_noop () 3220c63293b5Smrg{ 32219d0ccd10Smrg func_to_host_file_result=$1 3222c63293b5Smrg} 3223c63293b5Smrg# end func_convert_file_noop 3224c63293b5Smrg 3225c63293b5Smrg 3226c63293b5Smrg# func_convert_file_msys_to_w32 ARG 3227c63293b5Smrg# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic 3228c63293b5Smrg# conversion to w32 is not available inside the cwrapper. Returns result in 3229c63293b5Smrg# func_to_host_file_result. 3230c63293b5Smrgfunc_convert_file_msys_to_w32 () 3231c63293b5Smrg{ 32329d0ccd10Smrg $debug_cmd 32339d0ccd10Smrg 32349d0ccd10Smrg func_to_host_file_result=$1 3235c63293b5Smrg if test -n "$1"; then 3236c63293b5Smrg func_convert_core_msys_to_w32 "$1" 32379d0ccd10Smrg func_to_host_file_result=$func_convert_core_msys_to_w32_result 3238c63293b5Smrg fi 3239c63293b5Smrg func_convert_file_check "$1" "$func_to_host_file_result" 3240c63293b5Smrg} 3241c63293b5Smrg# end func_convert_file_msys_to_w32 3242c63293b5Smrg 3243c63293b5Smrg 3244c63293b5Smrg# func_convert_file_cygwin_to_w32 ARG 3245c63293b5Smrg# Convert file name ARG from Cygwin to w32 format. Returns result in 3246c63293b5Smrg# func_to_host_file_result. 3247c63293b5Smrgfunc_convert_file_cygwin_to_w32 () 3248c63293b5Smrg{ 32499d0ccd10Smrg $debug_cmd 32509d0ccd10Smrg 32519d0ccd10Smrg func_to_host_file_result=$1 3252c63293b5Smrg if test -n "$1"; then 3253c63293b5Smrg # because $build is cygwin, we call "the" cygpath in $PATH; no need to use 3254c63293b5Smrg # LT_CYGPATH in this case. 3255c63293b5Smrg func_to_host_file_result=`cygpath -m "$1"` 3256c63293b5Smrg fi 3257c63293b5Smrg func_convert_file_check "$1" "$func_to_host_file_result" 3258c63293b5Smrg} 3259c63293b5Smrg# end func_convert_file_cygwin_to_w32 3260c63293b5Smrg 3261c63293b5Smrg 3262c63293b5Smrg# func_convert_file_nix_to_w32 ARG 3263c63293b5Smrg# Convert file name ARG from *nix to w32 format. Requires a wine environment 3264c63293b5Smrg# and a working winepath. Returns result in func_to_host_file_result. 3265c63293b5Smrgfunc_convert_file_nix_to_w32 () 3266c63293b5Smrg{ 32679d0ccd10Smrg $debug_cmd 32689d0ccd10Smrg 32699d0ccd10Smrg func_to_host_file_result=$1 3270c63293b5Smrg if test -n "$1"; then 3271c63293b5Smrg func_convert_core_file_wine_to_w32 "$1" 32729d0ccd10Smrg func_to_host_file_result=$func_convert_core_file_wine_to_w32_result 3273c63293b5Smrg fi 3274c63293b5Smrg func_convert_file_check "$1" "$func_to_host_file_result" 3275c63293b5Smrg} 3276c63293b5Smrg# end func_convert_file_nix_to_w32 3277c63293b5Smrg 3278c63293b5Smrg 3279c63293b5Smrg# func_convert_file_msys_to_cygwin ARG 3280c63293b5Smrg# Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 3281c63293b5Smrg# Returns result in func_to_host_file_result. 3282c63293b5Smrgfunc_convert_file_msys_to_cygwin () 3283c63293b5Smrg{ 32849d0ccd10Smrg $debug_cmd 32859d0ccd10Smrg 32869d0ccd10Smrg func_to_host_file_result=$1 3287c63293b5Smrg if test -n "$1"; then 3288c63293b5Smrg func_convert_core_msys_to_w32 "$1" 3289c63293b5Smrg func_cygpath -u "$func_convert_core_msys_to_w32_result" 32909d0ccd10Smrg func_to_host_file_result=$func_cygpath_result 3291c63293b5Smrg fi 3292c63293b5Smrg func_convert_file_check "$1" "$func_to_host_file_result" 3293c63293b5Smrg} 3294c63293b5Smrg# end func_convert_file_msys_to_cygwin 3295c63293b5Smrg 3296c63293b5Smrg 3297c63293b5Smrg# func_convert_file_nix_to_cygwin ARG 3298c63293b5Smrg# Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed 3299c63293b5Smrg# in a wine environment, working winepath, and LT_CYGPATH set. Returns result 3300c63293b5Smrg# in func_to_host_file_result. 3301c63293b5Smrgfunc_convert_file_nix_to_cygwin () 3302c63293b5Smrg{ 33039d0ccd10Smrg $debug_cmd 33049d0ccd10Smrg 33059d0ccd10Smrg func_to_host_file_result=$1 3306c63293b5Smrg if test -n "$1"; then 3307c63293b5Smrg # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. 3308c63293b5Smrg func_convert_core_file_wine_to_w32 "$1" 3309c63293b5Smrg func_cygpath -u "$func_convert_core_file_wine_to_w32_result" 33109d0ccd10Smrg func_to_host_file_result=$func_cygpath_result 3311c63293b5Smrg fi 3312c63293b5Smrg func_convert_file_check "$1" "$func_to_host_file_result" 3313c63293b5Smrg} 3314c63293b5Smrg# end func_convert_file_nix_to_cygwin 3315c63293b5Smrg 3316c63293b5Smrg 3317c63293b5Smrg############################################# 3318c63293b5Smrg# $build to $host PATH CONVERSION FUNCTIONS # 3319c63293b5Smrg############################################# 33209d0ccd10Smrg# invoked via '$to_host_path_cmd ARG' 3321c63293b5Smrg# 3322c63293b5Smrg# In each case, ARG is the path to be converted from $build to $host format. 3323c63293b5Smrg# The result will be available in $func_to_host_path_result. 3324c63293b5Smrg# 3325c63293b5Smrg# Path separators are also converted from $build format to $host format. If 3326c63293b5Smrg# ARG begins or ends with a path separator character, it is preserved (but 3327c63293b5Smrg# converted to $host format) on output. 3328c63293b5Smrg# 3329c63293b5Smrg# All path conversion functions are named using the following convention: 3330c63293b5Smrg# file name conversion function : func_convert_file_X_to_Y () 3331c63293b5Smrg# path conversion function : func_convert_path_X_to_Y () 3332c63293b5Smrg# where, for any given $build/$host combination the 'X_to_Y' value is the 3333c63293b5Smrg# same. If conversion functions are added for new $build/$host combinations, 3334c63293b5Smrg# the two new functions must follow this pattern, or func_init_to_host_path_cmd 3335c63293b5Smrg# will break. 3336c63293b5Smrg 3337c63293b5Smrg 3338c63293b5Smrg# func_init_to_host_path_cmd 3339c63293b5Smrg# Ensures that function "pointer" variable $to_host_path_cmd is set to the 3340c63293b5Smrg# appropriate value, based on the value of $to_host_file_cmd. 3341c63293b5Smrgto_host_path_cmd= 3342c63293b5Smrgfunc_init_to_host_path_cmd () 3343c63293b5Smrg{ 33449d0ccd10Smrg $debug_cmd 33459d0ccd10Smrg 3346c63293b5Smrg if test -z "$to_host_path_cmd"; then 3347c63293b5Smrg func_stripname 'func_convert_file_' '' "$to_host_file_cmd" 33489d0ccd10Smrg to_host_path_cmd=func_convert_path_$func_stripname_result 3349c63293b5Smrg fi 3350c63293b5Smrg} 3351c63293b5Smrg 3352c63293b5Smrg 3353c63293b5Smrg# func_to_host_path ARG 3354c63293b5Smrg# Converts the path ARG from $build format to $host format. Return result 3355c63293b5Smrg# in func_to_host_path_result. 3356c63293b5Smrgfunc_to_host_path () 3357c63293b5Smrg{ 33589d0ccd10Smrg $debug_cmd 33599d0ccd10Smrg 3360c63293b5Smrg func_init_to_host_path_cmd 3361c63293b5Smrg $to_host_path_cmd "$1" 3362c63293b5Smrg} 3363c63293b5Smrg# end func_to_host_path 3364c63293b5Smrg 3365c63293b5Smrg 3366c63293b5Smrg# func_convert_path_noop ARG 3367c63293b5Smrg# Copy ARG to func_to_host_path_result. 3368c63293b5Smrgfunc_convert_path_noop () 3369c63293b5Smrg{ 33709d0ccd10Smrg func_to_host_path_result=$1 3371c63293b5Smrg} 3372c63293b5Smrg# end func_convert_path_noop 3373c63293b5Smrg 3374c63293b5Smrg 3375c63293b5Smrg# func_convert_path_msys_to_w32 ARG 3376c63293b5Smrg# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic 3377c63293b5Smrg# conversion to w32 is not available inside the cwrapper. Returns result in 3378c63293b5Smrg# func_to_host_path_result. 3379c63293b5Smrgfunc_convert_path_msys_to_w32 () 3380e169010aSmrg{ 33819d0ccd10Smrg $debug_cmd 33829d0ccd10Smrg 33839d0ccd10Smrg func_to_host_path_result=$1 3384c63293b5Smrg if test -n "$1"; then 3385c63293b5Smrg # Remove leading and trailing path separator characters from ARG. MSYS 3386c63293b5Smrg # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; 3387c63293b5Smrg # and winepath ignores them completely. 3388c63293b5Smrg func_stripname : : "$1" 3389c63293b5Smrg func_to_host_path_tmp1=$func_stripname_result 3390c63293b5Smrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 33919d0ccd10Smrg func_to_host_path_result=$func_convert_core_msys_to_w32_result 3392c63293b5Smrg func_convert_path_check : ";" \ 3393c63293b5Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3394c63293b5Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 3395c63293b5Smrg fi 3396c63293b5Smrg} 3397c63293b5Smrg# end func_convert_path_msys_to_w32 3398e169010aSmrg 3399e169010aSmrg 3400c63293b5Smrg# func_convert_path_cygwin_to_w32 ARG 3401c63293b5Smrg# Convert path ARG from Cygwin to w32 format. Returns result in 3402c63293b5Smrg# func_to_host_file_result. 3403c63293b5Smrgfunc_convert_path_cygwin_to_w32 () 3404c63293b5Smrg{ 34059d0ccd10Smrg $debug_cmd 34069d0ccd10Smrg 34079d0ccd10Smrg func_to_host_path_result=$1 3408c63293b5Smrg if test -n "$1"; then 3409c63293b5Smrg # See func_convert_path_msys_to_w32: 3410c63293b5Smrg func_stripname : : "$1" 3411c63293b5Smrg func_to_host_path_tmp1=$func_stripname_result 3412c63293b5Smrg func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` 3413c63293b5Smrg func_convert_path_check : ";" \ 3414c63293b5Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3415c63293b5Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 3416c63293b5Smrg fi 3417c63293b5Smrg} 3418c63293b5Smrg# end func_convert_path_cygwin_to_w32 3419e169010aSmrg 3420e169010aSmrg 3421c63293b5Smrg# func_convert_path_nix_to_w32 ARG 3422c63293b5Smrg# Convert path ARG from *nix to w32 format. Requires a wine environment and 3423c63293b5Smrg# a working winepath. Returns result in func_to_host_file_result. 3424c63293b5Smrgfunc_convert_path_nix_to_w32 () 3425c63293b5Smrg{ 34269d0ccd10Smrg $debug_cmd 34279d0ccd10Smrg 34289d0ccd10Smrg func_to_host_path_result=$1 3429c63293b5Smrg if test -n "$1"; then 3430c63293b5Smrg # See func_convert_path_msys_to_w32: 3431c63293b5Smrg func_stripname : : "$1" 3432c63293b5Smrg func_to_host_path_tmp1=$func_stripname_result 3433c63293b5Smrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 34349d0ccd10Smrg func_to_host_path_result=$func_convert_core_path_wine_to_w32_result 3435c63293b5Smrg func_convert_path_check : ";" \ 3436c63293b5Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3437c63293b5Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 3438c63293b5Smrg fi 3439c63293b5Smrg} 3440c63293b5Smrg# end func_convert_path_nix_to_w32 3441e169010aSmrg 3442c63293b5Smrg 3443c63293b5Smrg# func_convert_path_msys_to_cygwin ARG 3444c63293b5Smrg# Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 3445c63293b5Smrg# Returns result in func_to_host_file_result. 3446c63293b5Smrgfunc_convert_path_msys_to_cygwin () 3447c63293b5Smrg{ 34489d0ccd10Smrg $debug_cmd 34499d0ccd10Smrg 34509d0ccd10Smrg func_to_host_path_result=$1 3451c63293b5Smrg if test -n "$1"; then 3452c63293b5Smrg # See func_convert_path_msys_to_w32: 3453c63293b5Smrg func_stripname : : "$1" 3454c63293b5Smrg func_to_host_path_tmp1=$func_stripname_result 3455c63293b5Smrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 3456c63293b5Smrg func_cygpath -u -p "$func_convert_core_msys_to_w32_result" 34579d0ccd10Smrg func_to_host_path_result=$func_cygpath_result 3458c63293b5Smrg func_convert_path_check : : \ 3459c63293b5Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3460c63293b5Smrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 3461c63293b5Smrg fi 3462c63293b5Smrg} 3463c63293b5Smrg# end func_convert_path_msys_to_cygwin 3464c63293b5Smrg 3465c63293b5Smrg 3466c63293b5Smrg# func_convert_path_nix_to_cygwin ARG 3467c63293b5Smrg# Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a 3468c63293b5Smrg# a wine environment, working winepath, and LT_CYGPATH set. Returns result in 3469c63293b5Smrg# func_to_host_file_result. 3470c63293b5Smrgfunc_convert_path_nix_to_cygwin () 3471c63293b5Smrg{ 34729d0ccd10Smrg $debug_cmd 34739d0ccd10Smrg 34749d0ccd10Smrg func_to_host_path_result=$1 3475c63293b5Smrg if test -n "$1"; then 3476c63293b5Smrg # Remove leading and trailing path separator characters from 3477c63293b5Smrg # ARG. msys behavior is inconsistent here, cygpath turns them 3478c63293b5Smrg # into '.;' and ';.', and winepath ignores them completely. 3479c63293b5Smrg func_stripname : : "$1" 3480c63293b5Smrg func_to_host_path_tmp1=$func_stripname_result 3481c63293b5Smrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 3482c63293b5Smrg func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" 34839d0ccd10Smrg func_to_host_path_result=$func_cygpath_result 3484c63293b5Smrg func_convert_path_check : : \ 3485c63293b5Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3486c63293b5Smrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 3487c63293b5Smrg fi 3488e169010aSmrg} 3489c63293b5Smrg# end func_convert_path_nix_to_cygwin 3490c63293b5Smrg 3491e169010aSmrg 34929d0ccd10Smrg# func_dll_def_p FILE 34939d0ccd10Smrg# True iff FILE is a Windows DLL '.def' file. 34949d0ccd10Smrg# Keep in sync with _LT_DLL_DEF_P in libtool.m4 34959d0ccd10Smrgfunc_dll_def_p () 34969d0ccd10Smrg{ 34979d0ccd10Smrg $debug_cmd 34989d0ccd10Smrg 34999d0ccd10Smrg func_dll_def_p_tmp=`$SED -n \ 35009d0ccd10Smrg -e 's/^[ ]*//' \ 35019d0ccd10Smrg -e '/^\(;.*\)*$/d' \ 35029d0ccd10Smrg -e 's/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p' \ 35039d0ccd10Smrg -e q \ 35049d0ccd10Smrg "$1"` 35059d0ccd10Smrg test DEF = "$func_dll_def_p_tmp" 35069d0ccd10Smrg} 35079d0ccd10Smrg 35089d0ccd10Smrg 3509e169010aSmrg# func_mode_compile arg... 3510e169010aSmrgfunc_mode_compile () 3511e169010aSmrg{ 35129d0ccd10Smrg $debug_cmd 35139d0ccd10Smrg 3514e169010aSmrg # Get the compilation command and the source file. 3515e169010aSmrg base_compile= 35169d0ccd10Smrg srcfile=$nonopt # always keep a non-empty value in "srcfile" 3517e169010aSmrg suppress_opt=yes 3518e169010aSmrg suppress_output= 3519e169010aSmrg arg_mode=normal 3520e169010aSmrg libobj= 3521e169010aSmrg later= 3522e169010aSmrg pie_flag= 3523e169010aSmrg 3524e169010aSmrg for arg 3525e169010aSmrg do 3526e169010aSmrg case $arg_mode in 3527e169010aSmrg arg ) 3528e169010aSmrg # do not "continue". Instead, add this to base_compile 35299d0ccd10Smrg lastarg=$arg 3530e169010aSmrg arg_mode=normal 3531e169010aSmrg ;; 3532e169010aSmrg 3533e169010aSmrg target ) 35349d0ccd10Smrg libobj=$arg 3535e169010aSmrg arg_mode=normal 3536e169010aSmrg continue 3537e169010aSmrg ;; 3538e169010aSmrg 3539e169010aSmrg normal ) 3540e169010aSmrg # Accept any command-line options. 3541e169010aSmrg case $arg in 3542e169010aSmrg -o) 3543e169010aSmrg test -n "$libobj" && \ 35449d0ccd10Smrg func_fatal_error "you cannot specify '-o' more than once" 3545e169010aSmrg arg_mode=target 3546e169010aSmrg continue 3547e169010aSmrg ;; 3548e169010aSmrg 3549e169010aSmrg -pie | -fpie | -fPIE) 3550c63293b5Smrg func_append pie_flag " $arg" 3551e169010aSmrg continue 3552e169010aSmrg ;; 3553e169010aSmrg 3554e169010aSmrg -shared | -static | -prefer-pic | -prefer-non-pic) 3555c63293b5Smrg func_append later " $arg" 3556e169010aSmrg continue 3557e169010aSmrg ;; 3558e169010aSmrg 3559e169010aSmrg -no-suppress) 3560e169010aSmrg suppress_opt=no 3561e169010aSmrg continue 3562e169010aSmrg ;; 3563e169010aSmrg 3564e169010aSmrg -Xcompiler) 3565e169010aSmrg arg_mode=arg # the next one goes into the "base_compile" arg list 3566e169010aSmrg continue # The current "srcfile" will either be retained or 3567e169010aSmrg ;; # replaced later. I would guess that would be a bug. 3568e169010aSmrg 3569e169010aSmrg -Wc,*) 3570e169010aSmrg func_stripname '-Wc,' '' "$arg" 3571e169010aSmrg args=$func_stripname_result 3572e169010aSmrg lastarg= 35739d0ccd10Smrg save_ifs=$IFS; IFS=, 3574e169010aSmrg for arg in $args; do 35759d0ccd10Smrg IFS=$save_ifs 3576c63293b5Smrg func_append_quoted lastarg "$arg" 35777914d74bSmrg done 35789d0ccd10Smrg IFS=$save_ifs 3579e169010aSmrg func_stripname ' ' '' "$lastarg" 3580e169010aSmrg lastarg=$func_stripname_result 35817914d74bSmrg 35827914d74bSmrg # Add the arguments to base_compile. 3583c63293b5Smrg func_append base_compile " $lastarg" 35847914d74bSmrg continue 35857914d74bSmrg ;; 35867914d74bSmrg 3587e169010aSmrg *) 35887914d74bSmrg # Accept the current argument as the source file. 35897914d74bSmrg # The previous "srcfile" becomes the current argument. 35907914d74bSmrg # 35919d0ccd10Smrg lastarg=$srcfile 35929d0ccd10Smrg srcfile=$arg 35937914d74bSmrg ;; 35947914d74bSmrg esac # case $arg 35957914d74bSmrg ;; 35967914d74bSmrg esac # case $arg_mode 35977914d74bSmrg 35987914d74bSmrg # Aesthetically quote the previous argument. 3599c63293b5Smrg func_append_quoted base_compile "$lastarg" 36007914d74bSmrg done # for arg 36017914d74bSmrg 36027914d74bSmrg case $arg_mode in 36037914d74bSmrg arg) 3604e169010aSmrg func_fatal_error "you must specify an argument for -Xcompile" 36057914d74bSmrg ;; 36067914d74bSmrg target) 36079d0ccd10Smrg func_fatal_error "you must specify a target with '-o'" 36087914d74bSmrg ;; 36097914d74bSmrg *) 36107914d74bSmrg # Get the name of the library object. 3611e169010aSmrg test -z "$libobj" && { 3612e169010aSmrg func_basename "$srcfile" 36139d0ccd10Smrg libobj=$func_basename_result 3614e169010aSmrg } 36157914d74bSmrg ;; 36167914d74bSmrg esac 36177914d74bSmrg 36187914d74bSmrg # Recognize several different file suffixes. 36197914d74bSmrg # If the user specifies -o file.o, it is replaced with file.lo 36207914d74bSmrg case $libobj in 3621e169010aSmrg *.[cCFSifmso] | \ 3622e169010aSmrg *.ada | *.adb | *.ads | *.asm | \ 3623e169010aSmrg *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ 3624e6d5e4e0Smrg *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup) 3625e169010aSmrg func_xform "$libobj" 3626e169010aSmrg libobj=$func_xform_result 3627e169010aSmrg ;; 36287914d74bSmrg esac 36297914d74bSmrg 36307914d74bSmrg case $libobj in 3631e169010aSmrg *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; 36327914d74bSmrg *) 36339d0ccd10Smrg func_fatal_error "cannot determine name of library object from '$libobj'" 36347914d74bSmrg ;; 36357914d74bSmrg esac 36367914d74bSmrg 36377914d74bSmrg func_infer_tag $base_compile 36387914d74bSmrg 36397914d74bSmrg for arg in $later; do 36407914d74bSmrg case $arg in 3641e169010aSmrg -shared) 36429d0ccd10Smrg test yes = "$build_libtool_libs" \ 36439d0ccd10Smrg || func_fatal_configuration "cannot build a shared library" 3644e169010aSmrg build_old_libs=no 3645e169010aSmrg continue 3646e169010aSmrg ;; 3647e169010aSmrg 36487914d74bSmrg -static) 3649e169010aSmrg build_libtool_libs=no 36507914d74bSmrg build_old_libs=yes 36517914d74bSmrg continue 36527914d74bSmrg ;; 36537914d74bSmrg 36547914d74bSmrg -prefer-pic) 36557914d74bSmrg pic_mode=yes 36567914d74bSmrg continue 36577914d74bSmrg ;; 36587914d74bSmrg 36597914d74bSmrg -prefer-non-pic) 36607914d74bSmrg pic_mode=no 36617914d74bSmrg continue 36627914d74bSmrg ;; 36637914d74bSmrg esac 36647914d74bSmrg done 36657914d74bSmrg 36660ea508b1Smrg func_quote_arg pretty "$libobj" 36670ea508b1Smrg test "X$libobj" != "X$func_quote_arg_result" \ 3668e169010aSmrg && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ 36699d0ccd10Smrg && func_warning "libobj name '$libobj' may not contain shell special characters." 3670e169010aSmrg func_dirname_and_basename "$obj" "/" "" 36719d0ccd10Smrg objname=$func_basename_result 36729d0ccd10Smrg xdir=$func_dirname_result 36739d0ccd10Smrg lobj=$xdir$objdir/$objname 36747914d74bSmrg 3675e169010aSmrg test -z "$base_compile" && \ 3676e169010aSmrg func_fatal_help "you must specify a compilation command" 36777914d74bSmrg 36787914d74bSmrg # Delete any leftover library objects. 36799d0ccd10Smrg if test yes = "$build_old_libs"; then 36807914d74bSmrg removelist="$obj $lobj $libobj ${libobj}T" 36817914d74bSmrg else 36827914d74bSmrg removelist="$lobj $libobj ${libobj}T" 36837914d74bSmrg fi 36847914d74bSmrg 36857914d74bSmrg # On Cygwin there's no "real" PIC flag so we must build both object types 36867914d74bSmrg case $host_os in 3687e169010aSmrg cygwin* | mingw* | pw32* | os2* | cegcc*) 36887914d74bSmrg pic_mode=default 36897914d74bSmrg ;; 36907914d74bSmrg esac 36919d0ccd10Smrg if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then 36927914d74bSmrg # non-PIC code in shared libraries is not supported 36937914d74bSmrg pic_mode=default 36947914d74bSmrg fi 36957914d74bSmrg 36967914d74bSmrg # Calculate the filename of the output object if compiler does 36977914d74bSmrg # not support -o with -c 36989d0ccd10Smrg if test no = "$compiler_c_o"; then 36999d0ccd10Smrg output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext 37009d0ccd10Smrg lockfile=$output_obj.lock 37017914d74bSmrg else 37027914d74bSmrg output_obj= 37037914d74bSmrg need_locks=no 37047914d74bSmrg lockfile= 37057914d74bSmrg fi 37067914d74bSmrg 37077914d74bSmrg # Lock this critical section if it is needed 37087914d74bSmrg # We use this script file to make the link, it avoids creating a new file 37099d0ccd10Smrg if test yes = "$need_locks"; then 3710e169010aSmrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 3711e169010aSmrg func_echo "Waiting for $lockfile to be removed" 37127914d74bSmrg sleep 2 37137914d74bSmrg done 37149d0ccd10Smrg elif test warn = "$need_locks"; then 37157914d74bSmrg if test -f "$lockfile"; then 3716e169010aSmrg $ECHO "\ 37177914d74bSmrg*** ERROR, $lockfile exists and contains: 37187914d74bSmrg`cat $lockfile 2>/dev/null` 37197914d74bSmrg 37207914d74bSmrgThis indicates that another process is trying to use the same 37217914d74bSmrgtemporary object file, and libtool could not work around it because 37229d0ccd10Smrgyour compiler does not support '-c' and '-o' together. If you 37237914d74bSmrgrepeat this compilation, it may succeed, by chance, but you had better 37247914d74bSmrgavoid parallel builds (make -j) in this platform, or get a better 37257914d74bSmrgcompiler." 37267914d74bSmrg 3727e169010aSmrg $opt_dry_run || $RM $removelist 37287914d74bSmrg exit $EXIT_FAILURE 37297914d74bSmrg fi 3730c63293b5Smrg func_append removelist " $output_obj" 3731e169010aSmrg $ECHO "$srcfile" > "$lockfile" 37327914d74bSmrg fi 37337914d74bSmrg 3734e169010aSmrg $opt_dry_run || $RM $removelist 3735c63293b5Smrg func_append removelist " $lockfile" 3736e169010aSmrg trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 3737e169010aSmrg 3738c63293b5Smrg func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 3739c63293b5Smrg srcfile=$func_to_tool_file_result 37400ea508b1Smrg func_quote_arg pretty "$srcfile" 37410ea508b1Smrg qsrcfile=$func_quote_arg_result 37427914d74bSmrg 37437914d74bSmrg # Only build a PIC object if we are building libtool libraries. 37449d0ccd10Smrg if test yes = "$build_libtool_libs"; then 37457914d74bSmrg # Without this assignment, base_compile gets emptied. 37467914d74bSmrg fbsd_hideous_sh_bug=$base_compile 37477914d74bSmrg 37489d0ccd10Smrg if test no != "$pic_mode"; then 37497914d74bSmrg command="$base_compile $qsrcfile $pic_flag" 37507914d74bSmrg else 37517914d74bSmrg # Don't build PIC code 37527914d74bSmrg command="$base_compile $qsrcfile" 37537914d74bSmrg fi 37547914d74bSmrg 3755e169010aSmrg func_mkdir_p "$xdir$objdir" 37567914d74bSmrg 37577914d74bSmrg if test -z "$output_obj"; then 37587914d74bSmrg # Place PIC objects in $objdir 3759c63293b5Smrg func_append command " -o $lobj" 37607914d74bSmrg fi 37617914d74bSmrg 3762e169010aSmrg func_show_eval_locale "$command" \ 3763e169010aSmrg 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' 37647914d74bSmrg 37659d0ccd10Smrg if test warn = "$need_locks" && 37667914d74bSmrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 3767e169010aSmrg $ECHO "\ 37687914d74bSmrg*** ERROR, $lockfile contains: 37697914d74bSmrg`cat $lockfile 2>/dev/null` 37707914d74bSmrg 37717914d74bSmrgbut it should contain: 37727914d74bSmrg$srcfile 37737914d74bSmrg 37747914d74bSmrgThis indicates that another process is trying to use the same 37757914d74bSmrgtemporary object file, and libtool could not work around it because 37769d0ccd10Smrgyour compiler does not support '-c' and '-o' together. If you 37777914d74bSmrgrepeat this compilation, it may succeed, by chance, but you had better 37787914d74bSmrgavoid parallel builds (make -j) in this platform, or get a better 37797914d74bSmrgcompiler." 37807914d74bSmrg 3781e169010aSmrg $opt_dry_run || $RM $removelist 37827914d74bSmrg exit $EXIT_FAILURE 37837914d74bSmrg fi 37847914d74bSmrg 37857914d74bSmrg # Just move the object if needed, then go on to compile the next one 37867914d74bSmrg if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then 3787e169010aSmrg func_show_eval '$MV "$output_obj" "$lobj"' \ 3788e169010aSmrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 37897914d74bSmrg fi 37907914d74bSmrg 37917914d74bSmrg # Allow error messages only from the first compilation. 37929d0ccd10Smrg if test yes = "$suppress_opt"; then 3793e169010aSmrg suppress_output=' >/dev/null 2>&1' 37947914d74bSmrg fi 37957914d74bSmrg fi 37967914d74bSmrg 37977914d74bSmrg # Only build a position-dependent object if we build old libraries. 37989d0ccd10Smrg if test yes = "$build_old_libs"; then 37999d0ccd10Smrg if test yes != "$pic_mode"; then 38007914d74bSmrg # Don't build PIC code 3801e169010aSmrg command="$base_compile $qsrcfile$pie_flag" 38027914d74bSmrg else 38037914d74bSmrg command="$base_compile $qsrcfile $pic_flag" 38047914d74bSmrg fi 38059d0ccd10Smrg if test yes = "$compiler_c_o"; then 3806c63293b5Smrg func_append command " -o $obj" 38077914d74bSmrg fi 38087914d74bSmrg 38097914d74bSmrg # Suppress compiler output if we already did a PIC compilation. 3810c63293b5Smrg func_append command "$suppress_output" 3811e169010aSmrg func_show_eval_locale "$command" \ 3812e169010aSmrg '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 38137914d74bSmrg 38149d0ccd10Smrg if test warn = "$need_locks" && 38157914d74bSmrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 3816e169010aSmrg $ECHO "\ 38177914d74bSmrg*** ERROR, $lockfile contains: 38187914d74bSmrg`cat $lockfile 2>/dev/null` 38197914d74bSmrg 38207914d74bSmrgbut it should contain: 38217914d74bSmrg$srcfile 38227914d74bSmrg 38237914d74bSmrgThis indicates that another process is trying to use the same 38247914d74bSmrgtemporary object file, and libtool could not work around it because 38259d0ccd10Smrgyour compiler does not support '-c' and '-o' together. If you 38267914d74bSmrgrepeat this compilation, it may succeed, by chance, but you had better 38277914d74bSmrgavoid parallel builds (make -j) in this platform, or get a better 38287914d74bSmrgcompiler." 38297914d74bSmrg 3830e169010aSmrg $opt_dry_run || $RM $removelist 38317914d74bSmrg exit $EXIT_FAILURE 38327914d74bSmrg fi 38337914d74bSmrg 38347914d74bSmrg # Just move the object if needed 38357914d74bSmrg if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then 3836e169010aSmrg func_show_eval '$MV "$output_obj" "$obj"' \ 3837e169010aSmrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 38387914d74bSmrg fi 38397914d74bSmrg fi 38407914d74bSmrg 3841e169010aSmrg $opt_dry_run || { 3842e169010aSmrg func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" 38437914d74bSmrg 3844e169010aSmrg # Unlock the critical section if it was locked 38459d0ccd10Smrg if test no != "$need_locks"; then 3846e169010aSmrg removelist=$lockfile 3847e169010aSmrg $RM "$lockfile" 3848e169010aSmrg fi 3849e169010aSmrg } 38507914d74bSmrg 38517914d74bSmrg exit $EXIT_SUCCESS 3852e169010aSmrg} 38537914d74bSmrg 3854e169010aSmrg$opt_help || { 38559d0ccd10Smrg test compile = "$opt_mode" && func_mode_compile ${1+"$@"} 3856e169010aSmrg} 38577914d74bSmrg 3858e169010aSmrgfunc_mode_help () 3859e169010aSmrg{ 3860e169010aSmrg # We need to display help for each of the modes. 3861c63293b5Smrg case $opt_mode in 3862e169010aSmrg "") 3863e169010aSmrg # Generic help is extracted from the usage comments 3864e169010aSmrg # at the start of this file. 3865e169010aSmrg func_help 3866e169010aSmrg ;; 38677914d74bSmrg 3868e169010aSmrg clean) 3869e169010aSmrg $ECHO \ 3870e169010aSmrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... 38717914d74bSmrg 3872e169010aSmrgRemove files from the build directory. 38737914d74bSmrg 3874e169010aSmrgRM is the name of the program to use to delete files associated with each FILE 38759d0ccd10Smrg(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 3876e169010aSmrgto RM. 38777914d74bSmrg 3878e169010aSmrgIf FILE is a libtool library, object or program, all the files associated 3879e169010aSmrgwith it are deleted. Otherwise, only FILE itself is deleted using RM." 3880e169010aSmrg ;; 38817914d74bSmrg 3882e169010aSmrg compile) 3883e169010aSmrg $ECHO \ 3884e169010aSmrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE 38857914d74bSmrg 3886e169010aSmrgCompile a source file into a libtool library object. 38877914d74bSmrg 3888e169010aSmrgThis mode accepts the following additional options: 38897914d74bSmrg 3890e169010aSmrg -o OUTPUT-FILE set the output file name to OUTPUT-FILE 3891e169010aSmrg -no-suppress do not suppress compiler output for multiple passes 3892e8ead290Smrg -prefer-pic try to build PIC objects only 3893e8ead290Smrg -prefer-non-pic try to build non-PIC objects only 38949d0ccd10Smrg -shared do not build a '.o' file suitable for static linking 38959d0ccd10Smrg -static only build a '.o' file suitable for static linking 38960ea508b1Smrg -Wc,FLAG 38970ea508b1Smrg -Xcompiler FLAG pass FLAG directly to the compiler 38987914d74bSmrg 38999d0ccd10SmrgCOMPILE-COMMAND is a command to be used in creating a 'standard' object file 3900e169010aSmrgfrom the given SOURCEFILE. 39017914d74bSmrg 3902e169010aSmrgThe output file name is determined by removing the directory component from 39039d0ccd10SmrgSOURCEFILE, then substituting the C source code suffix '.c' with the 39049d0ccd10Smrglibrary object suffix, '.lo'." 3905e169010aSmrg ;; 39067914d74bSmrg 3907e169010aSmrg execute) 3908e169010aSmrg $ECHO \ 3909e169010aSmrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... 39107914d74bSmrg 3911e169010aSmrgAutomatically set library path, then run a program. 39127914d74bSmrg 3913e169010aSmrgThis mode accepts the following additional options: 39147914d74bSmrg 3915e169010aSmrg -dlopen FILE add the directory containing FILE to the library path 39167914d74bSmrg 39179d0ccd10SmrgThis mode sets the library path environment variable according to '-dlopen' 3918e169010aSmrgflags. 39197914d74bSmrg 3920e169010aSmrgIf any of the ARGS are libtool executable wrappers, then they are translated 3921e169010aSmrginto their corresponding uninstalled binary, and any of their required library 3922e169010aSmrgdirectories are added to the library path. 39237914d74bSmrg 3924e169010aSmrgThen, COMMAND is executed, with ARGS as arguments." 3925e169010aSmrg ;; 39267914d74bSmrg 3927e169010aSmrg finish) 3928e169010aSmrg $ECHO \ 3929e169010aSmrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]... 39307914d74bSmrg 3931e169010aSmrgComplete the installation of libtool libraries. 39327914d74bSmrg 3933e169010aSmrgEach LIBDIR is a directory that contains libtool libraries. 39347914d74bSmrg 3935e169010aSmrgThe commands that this mode executes may require superuser privileges. Use 39369d0ccd10Smrgthe '--dry-run' option if you just want to see what would be executed." 3937e169010aSmrg ;; 39387914d74bSmrg 3939e169010aSmrg install) 3940e169010aSmrg $ECHO \ 3941e169010aSmrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... 39427914d74bSmrg 3943e169010aSmrgInstall executables or libraries. 39447914d74bSmrg 3945e169010aSmrgINSTALL-COMMAND is the installation command. The first component should be 39469d0ccd10Smrgeither the 'install' or 'cp' program. 39477914d74bSmrg 3948e169010aSmrgThe following components of INSTALL-COMMAND are treated specially: 39497914d74bSmrg 3950e8ead290Smrg -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation 39517914d74bSmrg 3952e169010aSmrgThe rest of the components are interpreted as arguments to that command (only 3953e169010aSmrgBSD-compatible install options are recognized)." 3954e169010aSmrg ;; 39557914d74bSmrg 3956e169010aSmrg link) 3957e169010aSmrg $ECHO \ 3958e169010aSmrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND... 39597914d74bSmrg 3960e169010aSmrgLink object files or libraries together to form another library, or to 3961e169010aSmrgcreate an executable program. 39627914d74bSmrg 3963e169010aSmrgLINK-COMMAND is a command using the C compiler that you would use to create 3964e169010aSmrga program from several object files. 39657914d74bSmrg 3966e169010aSmrgThe following components of LINK-COMMAND are treated specially: 39677914d74bSmrg 3968e169010aSmrg -all-static do not do any dynamic linking at all 3969e169010aSmrg -avoid-version do not add a version suffix if possible 3970e8ead290Smrg -bindir BINDIR specify path to binaries directory (for systems where 3971e8ead290Smrg libraries must be found in the PATH setting at runtime) 39729d0ccd10Smrg -dlopen FILE '-dlpreopen' FILE if it cannot be dlopened at runtime 3973e169010aSmrg -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols 3974e169010aSmrg -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) 3975e169010aSmrg -export-symbols SYMFILE 3976e169010aSmrg try to export only the symbols listed in SYMFILE 3977e169010aSmrg -export-symbols-regex REGEX 3978e169010aSmrg try to export only the symbols matching REGEX 3979e169010aSmrg -LLIBDIR search LIBDIR for required installed libraries 3980e169010aSmrg -lNAME OUTPUT-FILE requires the installed library libNAME 3981e169010aSmrg -module build a library that can dlopened 3982e169010aSmrg -no-fast-install disable the fast-install mode 3983e169010aSmrg -no-install link a not-installable executable 3984e169010aSmrg -no-undefined declare that a library does not refer to external symbols 3985e169010aSmrg -o OUTPUT-FILE create OUTPUT-FILE from the specified objects 39869d0ccd10Smrg -objectlist FILE use a list of object files found in FILE to specify objects 39879d0ccd10Smrg -os2dllname NAME force a short DLL name on OS/2 (no effect on other OSes) 3988e169010aSmrg -precious-files-regex REGEX 3989e169010aSmrg don't remove output files matching REGEX 3990e169010aSmrg -release RELEASE specify package release information 3991e169010aSmrg -rpath LIBDIR the created library will eventually be installed in LIBDIR 3992e169010aSmrg -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries 3993e169010aSmrg -shared only do dynamic linking of libtool libraries 3994e169010aSmrg -shrext SUFFIX override the standard shared library file extension 3995e169010aSmrg -static do not do any dynamic linking of uninstalled libtool libraries 3996e169010aSmrg -static-libtool-libs 3997e169010aSmrg do not do any dynamic linking of libtool libraries 3998e169010aSmrg -version-info CURRENT[:REVISION[:AGE]] 3999e169010aSmrg specify library version info [each variable defaults to 0] 4000e169010aSmrg -weak LIBNAME declare that the target provides the LIBNAME interface 4001e8ead290Smrg -Wc,FLAG 4002e8ead290Smrg -Xcompiler FLAG pass linker-specific FLAG directly to the compiler 40030ea508b1Smrg -Wa,FLAG 40040ea508b1Smrg -Xassembler FLAG pass linker-specific FLAG directly to the assembler 4005e8ead290Smrg -Wl,FLAG 4006e8ead290Smrg -Xlinker FLAG pass linker-specific FLAG directly to the linker 4007e8ead290Smrg -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) 40087914d74bSmrg 40099d0ccd10SmrgAll other options (arguments beginning with '-') are ignored. 40107914d74bSmrg 40119d0ccd10SmrgEvery other argument is treated as a filename. Files ending in '.la' are 4012e169010aSmrgtreated as uninstalled libtool libraries, other files are standard or library 4013e169010aSmrgobject files. 40147914d74bSmrg 40159d0ccd10SmrgIf the OUTPUT-FILE ends in '.la', then a libtool library is created, 40169d0ccd10Smrgonly library objects ('.lo' files) may be specified, and '-rpath' is 4017e169010aSmrgrequired, except when creating a convenience library. 40187914d74bSmrg 40199d0ccd10SmrgIf OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created 40209d0ccd10Smrgusing 'ar' and 'ranlib', or on Windows using 'lib'. 40217914d74bSmrg 40229d0ccd10SmrgIf OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file 4023e169010aSmrgis created, otherwise an executable program is created." 40247914d74bSmrg ;; 40257914d74bSmrg 4026e169010aSmrg uninstall) 4027e169010aSmrg $ECHO \ 4028e169010aSmrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... 40297914d74bSmrg 4030e169010aSmrgRemove libraries from an installation directory. 40317914d74bSmrg 4032e169010aSmrgRM is the name of the program to use to delete files associated with each FILE 40339d0ccd10Smrg(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 4034e169010aSmrgto RM. 40357914d74bSmrg 4036e169010aSmrgIf FILE is a libtool library, all the files associated with it are deleted. 4037e169010aSmrgOtherwise, only FILE itself is deleted using RM." 4038e169010aSmrg ;; 40397914d74bSmrg 4040e169010aSmrg *) 40419d0ccd10Smrg func_fatal_help "invalid operation mode '$opt_mode'" 4042e169010aSmrg ;; 4043e169010aSmrg esac 40447914d74bSmrg 4045e8ead290Smrg echo 40469d0ccd10Smrg $ECHO "Try '$progname --help' for more information about other modes." 4047e169010aSmrg} 40487914d74bSmrg 4049e8ead290Smrg# Now that we've collected a possible --mode arg, show help if necessary 4050e8ead290Smrgif $opt_help; then 40519d0ccd10Smrg if test : = "$opt_help"; then 4052e8ead290Smrg func_mode_help 4053e8ead290Smrg else 4054e8ead290Smrg { 4055e8ead290Smrg func_help noexit 4056c63293b5Smrg for opt_mode in compile link execute install finish uninstall clean; do 4057e8ead290Smrg func_mode_help 4058e8ead290Smrg done 40599d0ccd10Smrg } | $SED -n '1p; 2,$s/^Usage:/ or: /p' 4060e8ead290Smrg { 4061e8ead290Smrg func_help noexit 4062c63293b5Smrg for opt_mode in compile link execute install finish uninstall clean; do 4063e8ead290Smrg echo 4064e8ead290Smrg func_mode_help 4065e8ead290Smrg done 4066e8ead290Smrg } | 40679d0ccd10Smrg $SED '1d 4068e8ead290Smrg /^When reporting/,/^Report/{ 4069e8ead290Smrg H 4070e8ead290Smrg d 4071e8ead290Smrg } 4072e8ead290Smrg $x 4073e8ead290Smrg /information about other modes/d 4074e8ead290Smrg /more detailed .*MODE/d 4075e8ead290Smrg s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' 4076e8ead290Smrg fi 4077e8ead290Smrg exit $? 4078e8ead290Smrgfi 40797914d74bSmrg 40807914d74bSmrg 4081e169010aSmrg# func_mode_execute arg... 4082e169010aSmrgfunc_mode_execute () 4083e169010aSmrg{ 40849d0ccd10Smrg $debug_cmd 40859d0ccd10Smrg 4086e169010aSmrg # The first argument is the command name. 40879d0ccd10Smrg cmd=$nonopt 4088e169010aSmrg test -z "$cmd" && \ 4089e169010aSmrg func_fatal_help "you must specify a COMMAND" 40907914d74bSmrg 4091e169010aSmrg # Handle -dlopen flags immediately. 4092c63293b5Smrg for file in $opt_dlopen; do 4093e169010aSmrg test -f "$file" \ 40949d0ccd10Smrg || func_fatal_help "'$file' is not a file" 40957914d74bSmrg 4096e169010aSmrg dir= 4097e169010aSmrg case $file in 4098e169010aSmrg *.la) 4099c63293b5Smrg func_resolve_sysroot "$file" 4100c63293b5Smrg file=$func_resolve_sysroot_result 4101c63293b5Smrg 4102e169010aSmrg # Check to see that this really is a libtool archive. 4103e169010aSmrg func_lalib_unsafe_p "$file" \ 41049d0ccd10Smrg || func_fatal_help "'$lib' is not a valid libtool archive" 41057914d74bSmrg 4106e169010aSmrg # Read the libtool library. 4107e169010aSmrg dlname= 4108e169010aSmrg library_names= 4109e169010aSmrg func_source "$file" 41107914d74bSmrg 4111e169010aSmrg # Skip this library if it cannot be dlopened. 4112e169010aSmrg if test -z "$dlname"; then 4113e169010aSmrg # Warn if it was a shared library. 4114e169010aSmrg test -n "$library_names" && \ 41159d0ccd10Smrg func_warning "'$file' was not linked with '-export-dynamic'" 4116e169010aSmrg continue 4117e169010aSmrg fi 41187914d74bSmrg 4119e169010aSmrg func_dirname "$file" "" "." 41209d0ccd10Smrg dir=$func_dirname_result 41217914d74bSmrg 4122e169010aSmrg if test -f "$dir/$objdir/$dlname"; then 4123c63293b5Smrg func_append dir "/$objdir" 4124e169010aSmrg else 4125e169010aSmrg if test ! -f "$dir/$dlname"; then 41269d0ccd10Smrg func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'" 4127e169010aSmrg fi 4128e169010aSmrg fi 41297914d74bSmrg ;; 41307914d74bSmrg 4131e169010aSmrg *.lo) 4132e169010aSmrg # Just add the directory containing the .lo file. 4133e169010aSmrg func_dirname "$file" "" "." 41349d0ccd10Smrg dir=$func_dirname_result 41357914d74bSmrg ;; 41367914d74bSmrg 4137e169010aSmrg *) 41389d0ccd10Smrg func_warning "'-dlopen' is ignored for non-libtool libraries and objects" 41397914d74bSmrg continue 41407914d74bSmrg ;; 4141e169010aSmrg esac 41427914d74bSmrg 4143e169010aSmrg # Get the absolute pathname. 4144e169010aSmrg absdir=`cd "$dir" && pwd` 41459d0ccd10Smrg test -n "$absdir" && dir=$absdir 41467914d74bSmrg 4147e169010aSmrg # Now add the directory to shlibpath_var. 4148e169010aSmrg if eval "test -z \"\$$shlibpath_var\""; then 4149e169010aSmrg eval "$shlibpath_var=\"\$dir\"" 4150e169010aSmrg else 4151e169010aSmrg eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" 4152e169010aSmrg fi 4153e169010aSmrg done 41547914d74bSmrg 4155e169010aSmrg # This variable tells wrapper scripts just to set shlibpath_var 4156e169010aSmrg # rather than running their programs. 41579d0ccd10Smrg libtool_execute_magic=$magic 41587914d74bSmrg 4159e169010aSmrg # Check if any of the arguments is a wrapper script. 4160e169010aSmrg args= 4161e169010aSmrg for file 4162e169010aSmrg do 4163e169010aSmrg case $file in 4164e8ead290Smrg -* | *.la | *.lo ) ;; 4165e169010aSmrg *) 4166e169010aSmrg # Do a test to see if this is really a libtool program. 4167e169010aSmrg if func_ltwrapper_script_p "$file"; then 4168e169010aSmrg func_source "$file" 4169e169010aSmrg # Transform arg to wrapped name. 41709d0ccd10Smrg file=$progdir/$program 4171e169010aSmrg elif func_ltwrapper_executable_p "$file"; then 4172e169010aSmrg func_ltwrapper_scriptname "$file" 4173e169010aSmrg func_source "$func_ltwrapper_scriptname_result" 4174e169010aSmrg # Transform arg to wrapped name. 41759d0ccd10Smrg file=$progdir/$program 4176e169010aSmrg fi 4177e169010aSmrg ;; 4178e169010aSmrg esac 4179e169010aSmrg # Quote arguments (to preserve shell metacharacters). 4180c63293b5Smrg func_append_quoted args "$file" 4181e169010aSmrg done 41827914d74bSmrg 41839d0ccd10Smrg if $opt_dry_run; then 41849d0ccd10Smrg # Display what would be done. 41859d0ccd10Smrg if test -n "$shlibpath_var"; then 41869d0ccd10Smrg eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" 41879d0ccd10Smrg echo "export $shlibpath_var" 41889d0ccd10Smrg fi 41899d0ccd10Smrg $ECHO "$cmd$args" 41909d0ccd10Smrg exit $EXIT_SUCCESS 41919d0ccd10Smrg else 4192e169010aSmrg if test -n "$shlibpath_var"; then 4193e169010aSmrg # Export the shlibpath_var. 4194e169010aSmrg eval "export $shlibpath_var" 4195e169010aSmrg fi 41967914d74bSmrg 4197e169010aSmrg # Restore saved environment variables 4198e169010aSmrg for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 4199e169010aSmrg do 4200e169010aSmrg eval "if test \"\${save_$lt_var+set}\" = set; then 4201e169010aSmrg $lt_var=\$save_$lt_var; export $lt_var 4202e169010aSmrg else 4203e169010aSmrg $lt_unset $lt_var 4204e169010aSmrg fi" 4205e169010aSmrg done 42067914d74bSmrg 4207e169010aSmrg # Now prepare to actually exec the command. 42089d0ccd10Smrg exec_cmd=\$cmd$args 4209e169010aSmrg fi 4210e169010aSmrg} 42117914d74bSmrg 42129d0ccd10Smrgtest execute = "$opt_mode" && func_mode_execute ${1+"$@"} 42137914d74bSmrg 42147914d74bSmrg 4215e169010aSmrg# func_mode_finish arg... 4216e169010aSmrgfunc_mode_finish () 4217e169010aSmrg{ 42189d0ccd10Smrg $debug_cmd 42199d0ccd10Smrg 4220c63293b5Smrg libs= 4221c63293b5Smrg libdirs= 4222e169010aSmrg admincmds= 42237914d74bSmrg 4224c63293b5Smrg for opt in "$nonopt" ${1+"$@"} 4225c63293b5Smrg do 4226c63293b5Smrg if test -d "$opt"; then 4227c63293b5Smrg func_append libdirs " $opt" 4228c63293b5Smrg 4229c63293b5Smrg elif test -f "$opt"; then 4230c63293b5Smrg if func_lalib_unsafe_p "$opt"; then 4231c63293b5Smrg func_append libs " $opt" 4232c63293b5Smrg else 42339d0ccd10Smrg func_warning "'$opt' is not a valid libtool archive" 4234c63293b5Smrg fi 4235c63293b5Smrg 4236c63293b5Smrg else 42379d0ccd10Smrg func_fatal_error "invalid argument '$opt'" 4238c63293b5Smrg fi 4239c63293b5Smrg done 4240c63293b5Smrg 4241c63293b5Smrg if test -n "$libs"; then 4242c63293b5Smrg if test -n "$lt_sysroot"; then 4243c63293b5Smrg sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` 4244c63293b5Smrg sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" 4245c63293b5Smrg else 4246c63293b5Smrg sysroot_cmd= 4247c63293b5Smrg fi 4248c63293b5Smrg 4249c63293b5Smrg # Remove sysroot references 4250c63293b5Smrg if $opt_dry_run; then 4251c63293b5Smrg for lib in $libs; do 42529d0ccd10Smrg echo "removing references to $lt_sysroot and '=' prefixes from $lib" 4253c63293b5Smrg done 4254c63293b5Smrg else 4255c63293b5Smrg tmpdir=`func_mktempdir` 4256c63293b5Smrg for lib in $libs; do 42579d0ccd10Smrg $SED -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ 4258c63293b5Smrg > $tmpdir/tmp-la 4259c63293b5Smrg mv -f $tmpdir/tmp-la $lib 4260c63293b5Smrg done 4261c63293b5Smrg ${RM}r "$tmpdir" 4262c63293b5Smrg fi 4263c63293b5Smrg fi 42647914d74bSmrg 4265c63293b5Smrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 4266e169010aSmrg for libdir in $libdirs; do 4267e169010aSmrg if test -n "$finish_cmds"; then 4268e169010aSmrg # Do each command in the finish commands. 4269e169010aSmrg func_execute_cmds "$finish_cmds" 'admincmds="$admincmds 4270e169010aSmrg'"$cmd"'"' 4271e169010aSmrg fi 4272e169010aSmrg if test -n "$finish_eval"; then 4273e169010aSmrg # Do the single finish_eval. 4274e169010aSmrg eval cmds=\"$finish_eval\" 4275c63293b5Smrg $opt_dry_run || eval "$cmds" || func_append admincmds " 4276e169010aSmrg $cmds" 4277e169010aSmrg fi 4278e169010aSmrg done 4279e169010aSmrg fi 42807914d74bSmrg 4281e169010aSmrg # Exit here if they wanted silent mode. 42829d0ccd10Smrg $opt_quiet && exit $EXIT_SUCCESS 42837914d74bSmrg 4284c63293b5Smrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 4285c63293b5Smrg echo "----------------------------------------------------------------------" 4286c63293b5Smrg echo "Libraries have been installed in:" 4287c63293b5Smrg for libdir in $libdirs; do 4288c63293b5Smrg $ECHO " $libdir" 4289c63293b5Smrg done 4290c63293b5Smrg echo 4291c63293b5Smrg echo "If you ever happen to want to link against installed libraries" 4292c63293b5Smrg echo "in a given directory, LIBDIR, you must either use libtool, and" 42939d0ccd10Smrg echo "specify the full pathname of the library, or use the '-LLIBDIR'" 4294c63293b5Smrg echo "flag during linking and do at least one of the following:" 4295c63293b5Smrg if test -n "$shlibpath_var"; then 42969d0ccd10Smrg echo " - add LIBDIR to the '$shlibpath_var' environment variable" 4297c63293b5Smrg echo " during execution" 4298c63293b5Smrg fi 4299c63293b5Smrg if test -n "$runpath_var"; then 43009d0ccd10Smrg echo " - add LIBDIR to the '$runpath_var' environment variable" 4301c63293b5Smrg echo " during linking" 4302c63293b5Smrg fi 4303c63293b5Smrg if test -n "$hardcode_libdir_flag_spec"; then 4304c63293b5Smrg libdir=LIBDIR 4305c63293b5Smrg eval flag=\"$hardcode_libdir_flag_spec\" 43067914d74bSmrg 43079d0ccd10Smrg $ECHO " - use the '$flag' linker flag" 4308c63293b5Smrg fi 4309c63293b5Smrg if test -n "$admincmds"; then 4310c63293b5Smrg $ECHO " - have your system administrator run these commands:$admincmds" 4311c63293b5Smrg fi 4312c63293b5Smrg if test -f /etc/ld.so.conf; then 43139d0ccd10Smrg echo " - have your system administrator add LIBDIR to '/etc/ld.so.conf'" 4314c63293b5Smrg fi 4315c63293b5Smrg echo 43167914d74bSmrg 4317c63293b5Smrg echo "See any operating system documentation about shared libraries for" 4318c63293b5Smrg case $host in 4319c63293b5Smrg solaris2.[6789]|solaris2.1[0-9]) 4320c63293b5Smrg echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" 4321c63293b5Smrg echo "pages." 4322c63293b5Smrg ;; 4323c63293b5Smrg *) 4324c63293b5Smrg echo "more information, such as the ld(1) and ld.so(8) manual pages." 4325c63293b5Smrg ;; 4326c63293b5Smrg esac 4327c63293b5Smrg echo "----------------------------------------------------------------------" 4328c63293b5Smrg fi 4329e169010aSmrg exit $EXIT_SUCCESS 4330e169010aSmrg} 43317914d74bSmrg 43329d0ccd10Smrgtest finish = "$opt_mode" && func_mode_finish ${1+"$@"} 43337914d74bSmrg 43347914d74bSmrg 4335e169010aSmrg# func_mode_install arg... 4336e169010aSmrgfunc_mode_install () 4337e169010aSmrg{ 43389d0ccd10Smrg $debug_cmd 43399d0ccd10Smrg 4340e169010aSmrg # There may be an optional sh(1) argument at the beginning of 4341e169010aSmrg # install_prog (especially on Windows NT). 43429d0ccd10Smrg if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" || 4343e169010aSmrg # Allow the use of GNU shtool's install command. 43449d0ccd10Smrg case $nonopt in *shtool*) :;; *) false;; esac 43459d0ccd10Smrg then 4346e169010aSmrg # Aesthetically quote it. 43470ea508b1Smrg func_quote_arg pretty "$nonopt" 43480ea508b1Smrg install_prog="$func_quote_arg_result " 4349e169010aSmrg arg=$1 4350e169010aSmrg shift 4351e169010aSmrg else 4352e169010aSmrg install_prog= 4353e169010aSmrg arg=$nonopt 4354e169010aSmrg fi 43557914d74bSmrg 4356e169010aSmrg # The real first argument should be the name of the installation program. 4357e169010aSmrg # Aesthetically quote it. 43580ea508b1Smrg func_quote_arg pretty "$arg" 43590ea508b1Smrg func_append install_prog "$func_quote_arg_result" 4360e8ead290Smrg install_shared_prog=$install_prog 4361e8ead290Smrg case " $install_prog " in 4362e8ead290Smrg *[\\\ /]cp\ *) install_cp=: ;; 4363e8ead290Smrg *) install_cp=false ;; 4364e8ead290Smrg esac 4365e169010aSmrg 4366e169010aSmrg # We need to accept at least all the BSD install flags. 4367e169010aSmrg dest= 4368e169010aSmrg files= 4369e169010aSmrg opts= 4370e169010aSmrg prev= 4371e169010aSmrg install_type= 43729d0ccd10Smrg isdir=false 4373e169010aSmrg stripme= 4374e8ead290Smrg no_mode=: 4375e169010aSmrg for arg 4376e169010aSmrg do 4377e8ead290Smrg arg2= 4378e169010aSmrg if test -n "$dest"; then 4379c63293b5Smrg func_append files " $dest" 4380e169010aSmrg dest=$arg 4381e169010aSmrg continue 43827914d74bSmrg fi 43837914d74bSmrg 4384e169010aSmrg case $arg in 43859d0ccd10Smrg -d) isdir=: ;; 4386e169010aSmrg -f) 4387e8ead290Smrg if $install_cp; then :; else 4388e8ead290Smrg prev=$arg 4389e8ead290Smrg fi 4390e169010aSmrg ;; 4391e169010aSmrg -g | -m | -o) 4392e169010aSmrg prev=$arg 4393e169010aSmrg ;; 4394e169010aSmrg -s) 4395e169010aSmrg stripme=" -s" 4396e169010aSmrg continue 4397e169010aSmrg ;; 4398e169010aSmrg -*) 4399e169010aSmrg ;; 4400e169010aSmrg *) 4401e169010aSmrg # If the previous option needed an argument, then skip it. 4402e169010aSmrg if test -n "$prev"; then 44039d0ccd10Smrg if test X-m = "X$prev" && test -n "$install_override_mode"; then 4404e8ead290Smrg arg2=$install_override_mode 4405e8ead290Smrg no_mode=false 4406e8ead290Smrg fi 4407e169010aSmrg prev= 4408e169010aSmrg else 4409e169010aSmrg dest=$arg 4410e169010aSmrg continue 4411e169010aSmrg fi 4412e169010aSmrg ;; 4413e169010aSmrg esac 44147914d74bSmrg 4415e169010aSmrg # Aesthetically quote the argument. 44160ea508b1Smrg func_quote_arg pretty "$arg" 44170ea508b1Smrg func_append install_prog " $func_quote_arg_result" 4418e8ead290Smrg if test -n "$arg2"; then 44190ea508b1Smrg func_quote_arg pretty "$arg2" 4420e8ead290Smrg fi 44210ea508b1Smrg func_append install_shared_prog " $func_quote_arg_result" 4422e169010aSmrg done 44237914d74bSmrg 4424e169010aSmrg test -z "$install_prog" && \ 4425e169010aSmrg func_fatal_help "you must specify an install program" 44267914d74bSmrg 4427e169010aSmrg test -n "$prev" && \ 44289d0ccd10Smrg func_fatal_help "the '$prev' option requires an argument" 44297914d74bSmrg 4430e8ead290Smrg if test -n "$install_override_mode" && $no_mode; then 4431e8ead290Smrg if $install_cp; then :; else 44320ea508b1Smrg func_quote_arg pretty "$install_override_mode" 44330ea508b1Smrg func_append install_shared_prog " -m $func_quote_arg_result" 4434e8ead290Smrg fi 4435e8ead290Smrg fi 4436e8ead290Smrg 4437e169010aSmrg if test -z "$files"; then 4438e169010aSmrg if test -z "$dest"; then 4439e169010aSmrg func_fatal_help "no file or destination specified" 4440e169010aSmrg else 4441e169010aSmrg func_fatal_help "you must specify a destination" 44427914d74bSmrg fi 44437914d74bSmrg fi 44447914d74bSmrg 4445e169010aSmrg # Strip any trailing slash from the destination. 4446e169010aSmrg func_stripname '' '/' "$dest" 4447e169010aSmrg dest=$func_stripname_result 44487914d74bSmrg 4449e169010aSmrg # Check to see that the destination is a directory. 44509d0ccd10Smrg test -d "$dest" && isdir=: 44519d0ccd10Smrg if $isdir; then 44529d0ccd10Smrg destdir=$dest 4453e169010aSmrg destname= 4454e169010aSmrg else 4455e169010aSmrg func_dirname_and_basename "$dest" "" "." 44569d0ccd10Smrg destdir=$func_dirname_result 44579d0ccd10Smrg destname=$func_basename_result 4458e169010aSmrg 4459e169010aSmrg # Not a directory, so check to see that there is only one file specified. 4460e169010aSmrg set dummy $files; shift 4461e169010aSmrg test "$#" -gt 1 && \ 44629d0ccd10Smrg func_fatal_help "'$dest' is not a directory" 4463e169010aSmrg fi 4464e169010aSmrg case $destdir in 4465e169010aSmrg [\\/]* | [A-Za-z]:[\\/]*) ;; 44667914d74bSmrg *) 4467e169010aSmrg for file in $files; do 4468e169010aSmrg case $file in 4469e169010aSmrg *.lo) ;; 4470e169010aSmrg *) 44719d0ccd10Smrg func_fatal_help "'$destdir' must be an absolute directory name" 4472e169010aSmrg ;; 4473e169010aSmrg esac 4474e169010aSmrg done 44757914d74bSmrg ;; 44767914d74bSmrg esac 44777914d74bSmrg 4478e169010aSmrg # This variable tells wrapper scripts just to set variables rather 4479e169010aSmrg # than running their programs. 44809d0ccd10Smrg libtool_install_magic=$magic 44817914d74bSmrg 4482e169010aSmrg staticlibs= 4483e169010aSmrg future_libdirs= 4484e169010aSmrg current_libdirs= 4485e169010aSmrg for file in $files; do 44867914d74bSmrg 4487e169010aSmrg # Do each installation. 4488e169010aSmrg case $file in 4489e169010aSmrg *.$libext) 4490e169010aSmrg # Do the static libraries later. 4491c63293b5Smrg func_append staticlibs " $file" 4492e169010aSmrg ;; 4493e169010aSmrg 4494e169010aSmrg *.la) 4495c63293b5Smrg func_resolve_sysroot "$file" 4496c63293b5Smrg file=$func_resolve_sysroot_result 4497c63293b5Smrg 4498e169010aSmrg # Check to see that this really is a libtool archive. 4499e169010aSmrg func_lalib_unsafe_p "$file" \ 45009d0ccd10Smrg || func_fatal_help "'$file' is not a valid libtool archive" 4501e169010aSmrg 4502e169010aSmrg library_names= 4503e169010aSmrg old_library= 4504e169010aSmrg relink_command= 4505e169010aSmrg func_source "$file" 4506e169010aSmrg 4507e169010aSmrg # Add the libdir to current_libdirs if it is the destination. 4508e169010aSmrg if test "X$destdir" = "X$libdir"; then 4509e169010aSmrg case "$current_libdirs " in 4510e169010aSmrg *" $libdir "*) ;; 4511c63293b5Smrg *) func_append current_libdirs " $libdir" ;; 45127914d74bSmrg esac 4513e169010aSmrg else 4514e169010aSmrg # Note the libdir as a future libdir. 4515e169010aSmrg case "$future_libdirs " in 4516e169010aSmrg *" $libdir "*) ;; 4517c63293b5Smrg *) func_append future_libdirs " $libdir" ;; 4518e169010aSmrg esac 4519e169010aSmrg fi 45207914d74bSmrg 4521e169010aSmrg func_dirname "$file" "/" "" 45229d0ccd10Smrg dir=$func_dirname_result 4523c63293b5Smrg func_append dir "$objdir" 4524e169010aSmrg 4525e169010aSmrg if test -n "$relink_command"; then 4526e169010aSmrg # Determine the prefix the user has applied to our future dir. 4527e8ead290Smrg inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` 4528e169010aSmrg 4529e169010aSmrg # Don't allow the user to place us outside of our expected 4530e169010aSmrg # location b/c this prevents finding dependent libraries that 4531e169010aSmrg # are installed to the same prefix. 4532e169010aSmrg # At present, this check doesn't affect windows .dll's that 4533e169010aSmrg # are installed into $libdir/../bin (currently, that works fine) 4534e169010aSmrg # but it's something to keep an eye on. 4535e169010aSmrg test "$inst_prefix_dir" = "$destdir" && \ 45369d0ccd10Smrg func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir" 4537e169010aSmrg 4538e169010aSmrg if test -n "$inst_prefix_dir"; then 4539e169010aSmrg # Stick the inst_prefix_dir data into the link command. 4540e8ead290Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` 4541e169010aSmrg else 4542e8ead290Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` 4543e169010aSmrg fi 4544e169010aSmrg 45459d0ccd10Smrg func_warning "relinking '$file'" 4546e169010aSmrg func_show_eval "$relink_command" \ 45479d0ccd10Smrg 'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"' 4548e169010aSmrg fi 4549e169010aSmrg 4550e169010aSmrg # See the names of the shared library. 4551e169010aSmrg set dummy $library_names; shift 4552e169010aSmrg if test -n "$1"; then 45539d0ccd10Smrg realname=$1 4554e169010aSmrg shift 4555e169010aSmrg 45569d0ccd10Smrg srcname=$realname 45579d0ccd10Smrg test -n "$relink_command" && srcname=${realname}T 4558e169010aSmrg 4559e169010aSmrg # Install the shared library and build the symlinks. 4560e8ead290Smrg func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ 4561e169010aSmrg 'exit $?' 45629d0ccd10Smrg tstripme=$stripme 4563e169010aSmrg case $host_os in 4564e169010aSmrg cygwin* | mingw* | pw32* | cegcc*) 4565e169010aSmrg case $realname in 4566e169010aSmrg *.dll.a) 45679d0ccd10Smrg tstripme= 45689d0ccd10Smrg ;; 45699d0ccd10Smrg esac 45709d0ccd10Smrg ;; 45719d0ccd10Smrg os2*) 45729d0ccd10Smrg case $realname in 45739d0ccd10Smrg *_dll.a) 45749d0ccd10Smrg tstripme= 4575e169010aSmrg ;; 4576e169010aSmrg esac 45777914d74bSmrg ;; 45787914d74bSmrg esac 4579e169010aSmrg if test -n "$tstripme" && test -n "$striplib"; then 4580e169010aSmrg func_show_eval "$striplib $destdir/$realname" 'exit $?' 45817914d74bSmrg fi 4582e169010aSmrg 4583e169010aSmrg if test "$#" -gt 0; then 4584e169010aSmrg # Delete the old symlinks, and create new ones. 45859d0ccd10Smrg # Try 'ln -sf' first, because the 'ln' binary might depend on 4586e169010aSmrg # the symlink we replace! Solaris /bin/ln does not understand -f, 4587e169010aSmrg # so we also need to try rm && ln -s. 4588e169010aSmrg for linkname 4589e169010aSmrg do 4590e169010aSmrg test "$linkname" != "$realname" \ 4591e169010aSmrg && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" 45927914d74bSmrg done 45937914d74bSmrg fi 45947914d74bSmrg 4595e169010aSmrg # Do each command in the postinstall commands. 45969d0ccd10Smrg lib=$destdir/$realname 4597e169010aSmrg func_execute_cmds "$postinstall_cmds" 'exit $?' 45987914d74bSmrg fi 45997914d74bSmrg 4600e169010aSmrg # Install the pseudo-library for information purposes. 4601e169010aSmrg func_basename "$file" 46029d0ccd10Smrg name=$func_basename_result 46039d0ccd10Smrg instname=$dir/${name}i 4604e169010aSmrg func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' 46057914d74bSmrg 4606e169010aSmrg # Maybe install the static library, too. 4607c63293b5Smrg test -n "$old_library" && func_append staticlibs " $dir/$old_library" 4608e169010aSmrg ;; 46097914d74bSmrg 4610e169010aSmrg *.lo) 4611e169010aSmrg # Install (i.e. copy) a libtool object. 46127914d74bSmrg 4613e169010aSmrg # Figure out destination file name, if it wasn't already specified. 4614e169010aSmrg if test -n "$destname"; then 46159d0ccd10Smrg destfile=$destdir/$destname 4616e169010aSmrg else 4617e169010aSmrg func_basename "$file" 46189d0ccd10Smrg destfile=$func_basename_result 46199d0ccd10Smrg destfile=$destdir/$destfile 4620e169010aSmrg fi 4621e169010aSmrg 4622e169010aSmrg # Deduce the name of the destination old-style object file. 4623e169010aSmrg case $destfile in 4624e169010aSmrg *.lo) 4625e169010aSmrg func_lo2o "$destfile" 4626e169010aSmrg staticdest=$func_lo2o_result 4627e169010aSmrg ;; 4628e169010aSmrg *.$objext) 46299d0ccd10Smrg staticdest=$destfile 4630e169010aSmrg destfile= 4631e169010aSmrg ;; 4632e169010aSmrg *) 46339d0ccd10Smrg func_fatal_help "cannot copy a libtool object to '$destfile'" 4634e169010aSmrg ;; 46357914d74bSmrg esac 46367914d74bSmrg 4637e169010aSmrg # Install the libtool object if requested. 4638e169010aSmrg test -n "$destfile" && \ 4639e169010aSmrg func_show_eval "$install_prog $file $destfile" 'exit $?' 4640e169010aSmrg 4641e169010aSmrg # Install the old object if enabled. 46429d0ccd10Smrg if test yes = "$build_old_libs"; then 4643e169010aSmrg # Deduce the name of the old-style object file. 4644e169010aSmrg func_lo2o "$file" 4645e169010aSmrg staticobj=$func_lo2o_result 4646e169010aSmrg func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' 46477914d74bSmrg fi 4648e169010aSmrg exit $EXIT_SUCCESS 4649e169010aSmrg ;; 46507914d74bSmrg 4651e169010aSmrg *) 4652e169010aSmrg # Figure out destination file name, if it wasn't already specified. 4653e169010aSmrg if test -n "$destname"; then 46549d0ccd10Smrg destfile=$destdir/$destname 4655e169010aSmrg else 4656e169010aSmrg func_basename "$file" 46579d0ccd10Smrg destfile=$func_basename_result 46589d0ccd10Smrg destfile=$destdir/$destfile 4659e169010aSmrg fi 4660e169010aSmrg 4661e169010aSmrg # If the file is missing, and there is a .exe on the end, strip it 4662e169010aSmrg # because it is most likely a libtool script we actually want to 4663e169010aSmrg # install 46649d0ccd10Smrg stripped_ext= 4665e169010aSmrg case $file in 4666e169010aSmrg *.exe) 4667e169010aSmrg if test ! -f "$file"; then 4668e169010aSmrg func_stripname '' '.exe' "$file" 4669e169010aSmrg file=$func_stripname_result 46709d0ccd10Smrg stripped_ext=.exe 46717914d74bSmrg fi 4672e169010aSmrg ;; 4673e169010aSmrg esac 46747914d74bSmrg 4675e169010aSmrg # Do a test to see if this is really a libtool program. 4676e169010aSmrg case $host in 4677e169010aSmrg *cygwin* | *mingw*) 4678e169010aSmrg if func_ltwrapper_executable_p "$file"; then 4679e169010aSmrg func_ltwrapper_scriptname "$file" 4680e169010aSmrg wrapper=$func_ltwrapper_scriptname_result 4681e169010aSmrg else 4682e169010aSmrg func_stripname '' '.exe' "$file" 4683e169010aSmrg wrapper=$func_stripname_result 4684e169010aSmrg fi 4685e169010aSmrg ;; 4686e169010aSmrg *) 4687e169010aSmrg wrapper=$file 4688e169010aSmrg ;; 4689e169010aSmrg esac 4690e169010aSmrg if func_ltwrapper_script_p "$wrapper"; then 4691e169010aSmrg notinst_deplibs= 4692e169010aSmrg relink_command= 46937914d74bSmrg 4694e169010aSmrg func_source "$wrapper" 46957914d74bSmrg 4696e169010aSmrg # Check the variables that should have been set. 4697e169010aSmrg test -z "$generated_by_libtool_version" && \ 46989d0ccd10Smrg func_fatal_error "invalid libtool wrapper script '$wrapper'" 4699e169010aSmrg 47009d0ccd10Smrg finalize=: 4701e169010aSmrg for lib in $notinst_deplibs; do 4702e169010aSmrg # Check to see that each library is installed. 4703e169010aSmrg libdir= 4704e169010aSmrg if test -f "$lib"; then 4705e169010aSmrg func_source "$lib" 4706e169010aSmrg fi 47079d0ccd10Smrg libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'` 4708e169010aSmrg if test -n "$libdir" && test ! -f "$libfile"; then 47099d0ccd10Smrg func_warning "'$lib' has not been installed in '$libdir'" 47109d0ccd10Smrg finalize=false 4711e169010aSmrg fi 4712e169010aSmrg done 4713e169010aSmrg 4714e169010aSmrg relink_command= 4715e169010aSmrg func_source "$wrapper" 4716e169010aSmrg 4717e169010aSmrg outputname= 47189d0ccd10Smrg if test no = "$fast_install" && test -n "$relink_command"; then 4719e169010aSmrg $opt_dry_run || { 47209d0ccd10Smrg if $finalize; then 4721e169010aSmrg tmpdir=`func_mktempdir` 4722e169010aSmrg func_basename "$file$stripped_ext" 47239d0ccd10Smrg file=$func_basename_result 47249d0ccd10Smrg outputname=$tmpdir/$file 4725e169010aSmrg # Replace the output file specification. 4726e8ead290Smrg relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` 4727e169010aSmrg 47289d0ccd10Smrg $opt_quiet || { 47290ea508b1Smrg func_quote_arg expand,pretty "$relink_command" 47300ea508b1Smrg eval "func_echo $func_quote_arg_result" 4731e169010aSmrg } 4732e169010aSmrg if eval "$relink_command"; then : 4733e169010aSmrg else 47349d0ccd10Smrg func_error "error: relink '$file' with the above command before installing it" 4735e169010aSmrg $opt_dry_run || ${RM}r "$tmpdir" 4736e169010aSmrg continue 4737e169010aSmrg fi 47389d0ccd10Smrg file=$outputname 4739e169010aSmrg else 47409d0ccd10Smrg func_warning "cannot relink '$file'" 4741e169010aSmrg fi 4742e169010aSmrg } 47437914d74bSmrg else 4744e169010aSmrg # Install the binary that we compiled earlier. 4745e8ead290Smrg file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` 47467914d74bSmrg fi 4747e169010aSmrg fi 47487914d74bSmrg 4749e169010aSmrg # remove .exe since cygwin /usr/bin/install will append another 4750e169010aSmrg # one anyway 4751e169010aSmrg case $install_prog,$host in 4752e169010aSmrg */usr/bin/install*,*cygwin*) 4753e169010aSmrg case $file:$destfile in 4754e169010aSmrg *.exe:*.exe) 4755e169010aSmrg # this is ok 4756e169010aSmrg ;; 4757e169010aSmrg *.exe:*) 4758e169010aSmrg destfile=$destfile.exe 4759e169010aSmrg ;; 4760e169010aSmrg *:*.exe) 4761e169010aSmrg func_stripname '' '.exe' "$destfile" 4762e169010aSmrg destfile=$func_stripname_result 4763e169010aSmrg ;; 4764e169010aSmrg esac 47657914d74bSmrg ;; 47667914d74bSmrg esac 4767e169010aSmrg func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' 4768e169010aSmrg $opt_dry_run || if test -n "$outputname"; then 4769e169010aSmrg ${RM}r "$tmpdir" 4770e169010aSmrg fi 4771e169010aSmrg ;; 4772e169010aSmrg esac 4773e169010aSmrg done 47747914d74bSmrg 4775e169010aSmrg for file in $staticlibs; do 4776e169010aSmrg func_basename "$file" 47779d0ccd10Smrg name=$func_basename_result 47787914d74bSmrg 4779e169010aSmrg # Set up the ranlib parameters. 47809d0ccd10Smrg oldlib=$destdir/$name 4781e6d5e4e0Smrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 4782e6d5e4e0Smrg tool_oldlib=$func_to_tool_file_result 47837914d74bSmrg 4784e169010aSmrg func_show_eval "$install_prog \$file \$oldlib" 'exit $?' 47857914d74bSmrg 4786e169010aSmrg if test -n "$stripme" && test -n "$old_striplib"; then 4787e6d5e4e0Smrg func_show_eval "$old_striplib $tool_oldlib" 'exit $?' 4788e169010aSmrg fi 47897914d74bSmrg 4790e169010aSmrg # Do each command in the postinstall commands. 4791e169010aSmrg func_execute_cmds "$old_postinstall_cmds" 'exit $?' 4792e169010aSmrg done 47937914d74bSmrg 4794e169010aSmrg test -n "$future_libdirs" && \ 47959d0ccd10Smrg func_warning "remember to run '$progname --finish$future_libdirs'" 47967914d74bSmrg 4797e169010aSmrg if test -n "$current_libdirs"; then 4798e169010aSmrg # Maybe just do a dry run. 4799e169010aSmrg $opt_dry_run && current_libdirs=" -n$current_libdirs" 48009d0ccd10Smrg exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs' 4801e169010aSmrg else 4802e169010aSmrg exit $EXIT_SUCCESS 4803e169010aSmrg fi 4804e169010aSmrg} 48057914d74bSmrg 48069d0ccd10Smrgtest install = "$opt_mode" && func_mode_install ${1+"$@"} 48077914d74bSmrg 48087914d74bSmrg 4809e169010aSmrg# func_generate_dlsyms outputname originator pic_p 4810e169010aSmrg# Extract symbols from dlprefiles and create ${outputname}S.o with 4811e169010aSmrg# a dlpreopen symbol table. 4812e169010aSmrgfunc_generate_dlsyms () 4813e169010aSmrg{ 48149d0ccd10Smrg $debug_cmd 48159d0ccd10Smrg 48169d0ccd10Smrg my_outputname=$1 48179d0ccd10Smrg my_originator=$2 48189d0ccd10Smrg my_pic_p=${3-false} 48199d0ccd10Smrg my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'` 4820e169010aSmrg my_dlsyms= 4821e169010aSmrg 48229d0ccd10Smrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 4823e169010aSmrg if test -n "$NM" && test -n "$global_symbol_pipe"; then 48249d0ccd10Smrg my_dlsyms=${my_outputname}S.c 4825e169010aSmrg else 4826e169010aSmrg func_error "not configured to extract global symbols from dlpreopened files" 4827e169010aSmrg fi 4828e169010aSmrg fi 48297914d74bSmrg 4830e169010aSmrg if test -n "$my_dlsyms"; then 4831e169010aSmrg case $my_dlsyms in 4832e169010aSmrg "") ;; 4833e169010aSmrg *.c) 4834e169010aSmrg # Discover the nlist of each of the dlfiles. 48359d0ccd10Smrg nlist=$output_objdir/$my_outputname.nm 4836e169010aSmrg 4837e169010aSmrg func_show_eval "$RM $nlist ${nlist}S ${nlist}T" 4838e169010aSmrg 4839e169010aSmrg # Parse the name list into a source file. 4840e169010aSmrg func_verbose "creating $output_objdir/$my_dlsyms" 4841e169010aSmrg 4842e169010aSmrg $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ 48439d0ccd10Smrg/* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */ 48449d0ccd10Smrg/* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */ 4845e169010aSmrg 4846e169010aSmrg#ifdef __cplusplus 4847e169010aSmrgextern \"C\" { 4848e169010aSmrg#endif 4849e169010aSmrg 48509d0ccd10Smrg#if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) 4851e8ead290Smrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\" 4852e8ead290Smrg#endif 4853e8ead290Smrg 4854c63293b5Smrg/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ 48559d0ccd10Smrg#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE 48569d0ccd10Smrg/* DATA imports from DLLs on WIN32 can't be const, because runtime 4857c63293b5Smrg relocations are performed -- see ld's documentation on pseudo-relocs. */ 4858c63293b5Smrg# define LT_DLSYM_CONST 48599d0ccd10Smrg#elif defined __osf__ 4860c63293b5Smrg/* This system does not cope well with relocations in const data. */ 4861c63293b5Smrg# define LT_DLSYM_CONST 4862c63293b5Smrg#else 4863c63293b5Smrg# define LT_DLSYM_CONST const 4864c63293b5Smrg#endif 4865c63293b5Smrg 48669d0ccd10Smrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 48679d0ccd10Smrg 4868e169010aSmrg/* External symbol declarations for the compiler. */\ 4869e169010aSmrg" 4870e169010aSmrg 48719d0ccd10Smrg if test yes = "$dlself"; then 48729d0ccd10Smrg func_verbose "generating symbol list for '$output'" 4873e169010aSmrg 4874e169010aSmrg $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" 4875e169010aSmrg 4876e169010aSmrg # Add our own program objects to the symbol list. 4877e8ead290Smrg progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` 4878e169010aSmrg for progfile in $progfiles; do 4879c63293b5Smrg func_to_tool_file "$progfile" func_convert_file_msys_to_w32 48809d0ccd10Smrg func_verbose "extracting global C symbols from '$func_to_tool_file_result'" 4881c63293b5Smrg $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" 4882e169010aSmrg done 4883e169010aSmrg 4884e169010aSmrg if test -n "$exclude_expsyms"; then 4885e169010aSmrg $opt_dry_run || { 4886e169010aSmrg eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' 4887e169010aSmrg eval '$MV "$nlist"T "$nlist"' 4888e169010aSmrg } 48897914d74bSmrg fi 48907914d74bSmrg 4891e169010aSmrg if test -n "$export_symbols_regex"; then 4892e169010aSmrg $opt_dry_run || { 4893e169010aSmrg eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' 4894e169010aSmrg eval '$MV "$nlist"T "$nlist"' 4895e169010aSmrg } 48967914d74bSmrg fi 4897e169010aSmrg 4898e169010aSmrg # Prepare the list of exported symbols 4899e169010aSmrg if test -z "$export_symbols"; then 49009d0ccd10Smrg export_symbols=$output_objdir/$outputname.exp 4901e169010aSmrg $opt_dry_run || { 4902e169010aSmrg $RM $export_symbols 49039d0ccd10Smrg eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' 4904e169010aSmrg case $host in 4905e169010aSmrg *cygwin* | *mingw* | *cegcc* ) 4906e169010aSmrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 4907e169010aSmrg eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' 4908e169010aSmrg ;; 49097914d74bSmrg esac 4910e169010aSmrg } 4911e169010aSmrg else 4912e169010aSmrg $opt_dry_run || { 49139d0ccd10Smrg eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' 4914e169010aSmrg eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' 4915e169010aSmrg eval '$MV "$nlist"T "$nlist"' 4916e169010aSmrg case $host in 4917e8ead290Smrg *cygwin* | *mingw* | *cegcc* ) 4918e169010aSmrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 4919e169010aSmrg eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' 4920e169010aSmrg ;; 49217914d74bSmrg esac 4922e169010aSmrg } 49237914d74bSmrg fi 4924e169010aSmrg fi 49257914d74bSmrg 4926e169010aSmrg for dlprefile in $dlprefiles; do 49279d0ccd10Smrg func_verbose "extracting global C symbols from '$dlprefile'" 4928e169010aSmrg func_basename "$dlprefile" 49299d0ccd10Smrg name=$func_basename_result 4930c63293b5Smrg case $host in 4931c63293b5Smrg *cygwin* | *mingw* | *cegcc* ) 4932c63293b5Smrg # if an import library, we need to obtain dlname 4933c63293b5Smrg if func_win32_import_lib_p "$dlprefile"; then 4934c63293b5Smrg func_tr_sh "$dlprefile" 4935c63293b5Smrg eval "curr_lafile=\$libfile_$func_tr_sh_result" 49369d0ccd10Smrg dlprefile_dlbasename= 4937c63293b5Smrg if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then 4938c63293b5Smrg # Use subshell, to avoid clobbering current variable values 4939c63293b5Smrg dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` 49409d0ccd10Smrg if test -n "$dlprefile_dlname"; then 4941c63293b5Smrg func_basename "$dlprefile_dlname" 49429d0ccd10Smrg dlprefile_dlbasename=$func_basename_result 4943c63293b5Smrg else 4944c63293b5Smrg # no lafile. user explicitly requested -dlpreopen <import library>. 4945c63293b5Smrg $sharedlib_from_linklib_cmd "$dlprefile" 4946c63293b5Smrg dlprefile_dlbasename=$sharedlib_from_linklib_result 4947c63293b5Smrg fi 4948c63293b5Smrg fi 4949c63293b5Smrg $opt_dry_run || { 49509d0ccd10Smrg if test -n "$dlprefile_dlbasename"; then 4951c63293b5Smrg eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' 4952c63293b5Smrg else 4953c63293b5Smrg func_warning "Could not compute DLL name from $name" 4954c63293b5Smrg eval '$ECHO ": $name " >> "$nlist"' 4955c63293b5Smrg fi 4956c63293b5Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 4957c63293b5Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | 4958c63293b5Smrg $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" 4959c63293b5Smrg } 4960c63293b5Smrg else # not an import lib 4961c63293b5Smrg $opt_dry_run || { 4962c63293b5Smrg eval '$ECHO ": $name " >> "$nlist"' 4963c63293b5Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 4964c63293b5Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 4965c63293b5Smrg } 4966c63293b5Smrg fi 4967c63293b5Smrg ;; 4968c63293b5Smrg *) 4969c63293b5Smrg $opt_dry_run || { 4970c63293b5Smrg eval '$ECHO ": $name " >> "$nlist"' 4971c63293b5Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 4972c63293b5Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 4973c63293b5Smrg } 4974c63293b5Smrg ;; 4975c63293b5Smrg esac 4976e169010aSmrg done 49777914d74bSmrg 4978e169010aSmrg $opt_dry_run || { 4979e169010aSmrg # Make sure we have at least an empty file. 4980e169010aSmrg test -f "$nlist" || : > "$nlist" 49817914d74bSmrg 4982e169010aSmrg if test -n "$exclude_expsyms"; then 4983e169010aSmrg $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T 4984e169010aSmrg $MV "$nlist"T "$nlist" 49857914d74bSmrg fi 49867914d74bSmrg 4987e169010aSmrg # Try sorting and uniquifying the output. 4988e169010aSmrg if $GREP -v "^: " < "$nlist" | 4989e169010aSmrg if sort -k 3 </dev/null >/dev/null 2>&1; then 4990e169010aSmrg sort -k 3 49917914d74bSmrg else 4992e169010aSmrg sort +2 4993e169010aSmrg fi | 4994e169010aSmrg uniq > "$nlist"S; then 4995e169010aSmrg : 49967914d74bSmrg else 4997e169010aSmrg $GREP -v "^: " < "$nlist" > "$nlist"S 49987914d74bSmrg fi 49997914d74bSmrg 5000e169010aSmrg if test -f "$nlist"S; then 5001e169010aSmrg eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' 50027914d74bSmrg else 5003e8ead290Smrg echo '/* NONE */' >> "$output_objdir/$my_dlsyms" 50047914d74bSmrg fi 50057914d74bSmrg 50069d0ccd10Smrg func_show_eval '$RM "${nlist}I"' 50079d0ccd10Smrg if test -n "$global_symbol_to_import"; then 50089d0ccd10Smrg eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I' 50099d0ccd10Smrg fi 50109d0ccd10Smrg 5011e8ead290Smrg echo >> "$output_objdir/$my_dlsyms" "\ 50127914d74bSmrg 5013e169010aSmrg/* The mapping between symbol names and symbols. */ 5014e169010aSmrgtypedef struct { 5015e169010aSmrg const char *name; 5016e169010aSmrg void *address; 5017e169010aSmrg} lt_dlsymlist; 5018c63293b5Smrgextern LT_DLSYM_CONST lt_dlsymlist 50199d0ccd10Smrglt_${my_prefix}_LTX_preloaded_symbols[];\ 50209d0ccd10Smrg" 50219d0ccd10Smrg 50229d0ccd10Smrg if test -s "$nlist"I; then 50239d0ccd10Smrg echo >> "$output_objdir/$my_dlsyms" "\ 50249d0ccd10Smrgstatic void lt_syminit(void) 50259d0ccd10Smrg{ 50269d0ccd10Smrg LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols; 50279d0ccd10Smrg for (; symbol->name; ++symbol) 50289d0ccd10Smrg {" 50299d0ccd10Smrg $SED 's/.*/ if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms" 50309d0ccd10Smrg echo >> "$output_objdir/$my_dlsyms" "\ 50319d0ccd10Smrg } 50329d0ccd10Smrg}" 50339d0ccd10Smrg fi 50349d0ccd10Smrg echo >> "$output_objdir/$my_dlsyms" "\ 5035c63293b5SmrgLT_DLSYM_CONST lt_dlsymlist 5036e169010aSmrglt_${my_prefix}_LTX_preloaded_symbols[] = 50379d0ccd10Smrg{ {\"$my_originator\", (void *) 0}," 50389d0ccd10Smrg 50399d0ccd10Smrg if test -s "$nlist"I; then 50409d0ccd10Smrg echo >> "$output_objdir/$my_dlsyms" "\ 50419d0ccd10Smrg {\"@INIT@\", (void *) <_syminit}," 50429d0ccd10Smrg fi 5043e169010aSmrg 5044e169010aSmrg case $need_lib_prefix in 5045e169010aSmrg no) 5046e169010aSmrg eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" 5047e169010aSmrg ;; 5048e169010aSmrg *) 5049e169010aSmrg eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" 5050e169010aSmrg ;; 5051e169010aSmrg esac 5052e8ead290Smrg echo >> "$output_objdir/$my_dlsyms" "\ 5053e169010aSmrg {0, (void *) 0} 5054e169010aSmrg}; 5055e169010aSmrg 5056e169010aSmrg/* This works around a problem in FreeBSD linker */ 5057e169010aSmrg#ifdef FREEBSD_WORKAROUND 5058e169010aSmrgstatic const void *lt_preloaded_setup() { 5059e169010aSmrg return lt_${my_prefix}_LTX_preloaded_symbols; 5060e169010aSmrg} 5061e169010aSmrg#endif 5062e169010aSmrg 5063e169010aSmrg#ifdef __cplusplus 5064e169010aSmrg} 5065e169010aSmrg#endif\ 5066e169010aSmrg" 5067e169010aSmrg } # !$opt_dry_run 5068e169010aSmrg 5069e169010aSmrg pic_flag_for_symtable= 5070e169010aSmrg case "$compile_command " in 5071e169010aSmrg *" -static "*) ;; 5072e169010aSmrg *) 5073e169010aSmrg case $host in 5074e169010aSmrg # compiling the symbol table file with pic_flag works around 5075e169010aSmrg # a FreeBSD bug that causes programs to crash when -lm is 5076e169010aSmrg # linked before any other PIC object. But we must not use 5077e169010aSmrg # pic_flag when linking with -static. The problem exists in 5078e169010aSmrg # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. 5079e6d5e4e0Smrg *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) 5080e169010aSmrg pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; 5081e169010aSmrg *-*-hpux*) 5082e169010aSmrg pic_flag_for_symtable=" $pic_flag" ;; 5083e169010aSmrg *) 50849d0ccd10Smrg $my_pic_p && pic_flag_for_symtable=" $pic_flag" 5085e169010aSmrg ;; 5086e169010aSmrg esac 5087e169010aSmrg ;; 5088e169010aSmrg esac 5089e169010aSmrg symtab_cflags= 5090e169010aSmrg for arg in $LTCFLAGS; do 5091e169010aSmrg case $arg in 5092e169010aSmrg -pie | -fpie | -fPIE) ;; 5093c63293b5Smrg *) func_append symtab_cflags " $arg" ;; 5094e169010aSmrg esac 5095e169010aSmrg done 50967914d74bSmrg 5097e169010aSmrg # Now compile the dynamic symbol file. 5098e169010aSmrg func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' 50997914d74bSmrg 5100e169010aSmrg # Clean up the generated files. 51019d0ccd10Smrg func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"' 5102e169010aSmrg 5103e169010aSmrg # Transform the symbol file into the correct name. 51049d0ccd10Smrg symfileobj=$output_objdir/${my_outputname}S.$objext 5105e169010aSmrg case $host in 5106e169010aSmrg *cygwin* | *mingw* | *cegcc* ) 5107e169010aSmrg if test -f "$output_objdir/$my_outputname.def"; then 5108e8ead290Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 5109e8ead290Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 5110e169010aSmrg else 5111e8ead290Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 5112e8ead290Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 5113e169010aSmrg fi 5114e169010aSmrg ;; 5115e169010aSmrg *) 5116e8ead290Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 5117e8ead290Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 51187914d74bSmrg ;; 51197914d74bSmrg esac 5120e169010aSmrg ;; 5121e169010aSmrg *) 51229d0ccd10Smrg func_fatal_error "unknown suffix for '$my_dlsyms'" 5123e169010aSmrg ;; 5124e169010aSmrg esac 5125e169010aSmrg else 5126e169010aSmrg # We keep going just in case the user didn't refer to 5127e169010aSmrg # lt_preloaded_symbols. The linker will fail if global_symbol_pipe 5128e169010aSmrg # really was required. 5129e169010aSmrg 5130e169010aSmrg # Nullify the symbol file. 5131e8ead290Smrg compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` 5132e8ead290Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` 51337914d74bSmrg fi 5134e169010aSmrg} 51357914d74bSmrg 51369d0ccd10Smrg# func_cygming_gnu_implib_p ARG 51379d0ccd10Smrg# This predicate returns with zero status (TRUE) if 51389d0ccd10Smrg# ARG is a GNU/binutils-style import library. Returns 51399d0ccd10Smrg# with nonzero status (FALSE) otherwise. 51409d0ccd10Smrgfunc_cygming_gnu_implib_p () 51419d0ccd10Smrg{ 51429d0ccd10Smrg $debug_cmd 51439d0ccd10Smrg 51449d0ccd10Smrg func_to_tool_file "$1" func_convert_file_msys_to_w32 51459d0ccd10Smrg 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)$'` 51469d0ccd10Smrg test -n "$func_cygming_gnu_implib_tmp" 51479d0ccd10Smrg} 51489d0ccd10Smrg 51499d0ccd10Smrg# func_cygming_ms_implib_p ARG 51509d0ccd10Smrg# This predicate returns with zero status (TRUE) if 51519d0ccd10Smrg# ARG is an MS-style import library. Returns 51529d0ccd10Smrg# with nonzero status (FALSE) otherwise. 51539d0ccd10Smrgfunc_cygming_ms_implib_p () 51549d0ccd10Smrg{ 51559d0ccd10Smrg $debug_cmd 51569d0ccd10Smrg 51579d0ccd10Smrg func_to_tool_file "$1" func_convert_file_msys_to_w32 51589d0ccd10Smrg func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` 51599d0ccd10Smrg test -n "$func_cygming_ms_implib_tmp" 51609d0ccd10Smrg} 51619d0ccd10Smrg 5162e169010aSmrg# func_win32_libid arg 5163e169010aSmrg# return the library type of file 'arg' 5164e169010aSmrg# 5165e169010aSmrg# Need a lot of goo to handle *both* DLLs and import libs 5166e169010aSmrg# Has to be a shell function in order to 'eat' the argument 5167e169010aSmrg# that is supplied when $file_magic_command is called. 5168e8ead290Smrg# Despite the name, also deal with 64 bit binaries. 5169e169010aSmrgfunc_win32_libid () 5170e169010aSmrg{ 51719d0ccd10Smrg $debug_cmd 51729d0ccd10Smrg 51739d0ccd10Smrg win32_libid_type=unknown 5174e169010aSmrg win32_fileres=`file -L $1 2>/dev/null` 5175e169010aSmrg case $win32_fileres in 5176e169010aSmrg *ar\ archive\ import\ library*) # definitely import 5177e169010aSmrg win32_libid_type="x86 archive import" 5178e169010aSmrg ;; 5179e169010aSmrg *ar\ archive*) # could be an import, or static 5180e8ead290Smrg # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. 5181e169010aSmrg if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | 5182e8ead290Smrg $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then 51839d0ccd10Smrg case $nm_interface in 51849d0ccd10Smrg "MS dumpbin") 51859d0ccd10Smrg if func_cygming_ms_implib_p "$1" || 51869d0ccd10Smrg func_cygming_gnu_implib_p "$1" 51879d0ccd10Smrg then 51889d0ccd10Smrg win32_nmres=import 51899d0ccd10Smrg else 51909d0ccd10Smrg win32_nmres= 51919d0ccd10Smrg fi 51929d0ccd10Smrg ;; 51939d0ccd10Smrg *) 51949d0ccd10Smrg func_to_tool_file "$1" func_convert_file_msys_to_w32 51959d0ccd10Smrg win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | 51969d0ccd10Smrg $SED -n -e ' 5197e169010aSmrg 1,100{ 5198e169010aSmrg / I /{ 51999d0ccd10Smrg s|.*|import| 5200e169010aSmrg p 5201e169010aSmrg q 5202e169010aSmrg } 5203e169010aSmrg }'` 52049d0ccd10Smrg ;; 52059d0ccd10Smrg esac 5206e169010aSmrg case $win32_nmres in 5207e169010aSmrg import*) win32_libid_type="x86 archive import";; 5208e169010aSmrg *) win32_libid_type="x86 archive static";; 5209e169010aSmrg esac 5210e169010aSmrg fi 5211e169010aSmrg ;; 5212e169010aSmrg *DLL*) 5213e169010aSmrg win32_libid_type="x86 DLL" 5214e169010aSmrg ;; 5215e169010aSmrg *executable*) # but shell scripts are "executable" too... 5216e169010aSmrg case $win32_fileres in 5217e169010aSmrg *MS\ Windows\ PE\ Intel*) 5218e169010aSmrg win32_libid_type="x86 DLL" 5219e169010aSmrg ;; 5220e169010aSmrg esac 5221e169010aSmrg ;; 5222e169010aSmrg esac 5223e169010aSmrg $ECHO "$win32_libid_type" 5224e169010aSmrg} 52257914d74bSmrg 5226c63293b5Smrg# func_cygming_dll_for_implib ARG 5227c63293b5Smrg# 5228c63293b5Smrg# Platform-specific function to extract the 5229c63293b5Smrg# name of the DLL associated with the specified 5230c63293b5Smrg# import library ARG. 5231c63293b5Smrg# Invoked by eval'ing the libtool variable 5232c63293b5Smrg# $sharedlib_from_linklib_cmd 5233c63293b5Smrg# Result is available in the variable 5234c63293b5Smrg# $sharedlib_from_linklib_result 5235c63293b5Smrgfunc_cygming_dll_for_implib () 5236c63293b5Smrg{ 52379d0ccd10Smrg $debug_cmd 52389d0ccd10Smrg 5239c63293b5Smrg sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` 5240c63293b5Smrg} 5241c63293b5Smrg 5242c63293b5Smrg# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs 5243c63293b5Smrg# 5244c63293b5Smrg# The is the core of a fallback implementation of a 5245c63293b5Smrg# platform-specific function to extract the name of the 5246c63293b5Smrg# DLL associated with the specified import library LIBNAME. 5247c63293b5Smrg# 5248c63293b5Smrg# SECTION_NAME is either .idata$6 or .idata$7, depending 5249c63293b5Smrg# on the platform and compiler that created the implib. 5250c63293b5Smrg# 5251c63293b5Smrg# Echos the name of the DLL associated with the 5252c63293b5Smrg# specified import library. 5253c63293b5Smrgfunc_cygming_dll_for_implib_fallback_core () 5254c63293b5Smrg{ 52559d0ccd10Smrg $debug_cmd 52569d0ccd10Smrg 5257c63293b5Smrg match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` 5258c63293b5Smrg $OBJDUMP -s --section "$1" "$2" 2>/dev/null | 5259c63293b5Smrg $SED '/^Contents of section '"$match_literal"':/{ 5260c63293b5Smrg # Place marker at beginning of archive member dllname section 5261c63293b5Smrg s/.*/====MARK====/ 5262c63293b5Smrg p 5263c63293b5Smrg d 5264c63293b5Smrg } 5265c63293b5Smrg # These lines can sometimes be longer than 43 characters, but 5266c63293b5Smrg # are always uninteresting 5267c63293b5Smrg /:[ ]*file format pe[i]\{,1\}-/d 5268c63293b5Smrg /^In archive [^:]*:/d 5269c63293b5Smrg # Ensure marker is printed 5270c63293b5Smrg /^====MARK====/p 5271c63293b5Smrg # Remove all lines with less than 43 characters 5272c63293b5Smrg /^.\{43\}/!d 5273c63293b5Smrg # From remaining lines, remove first 43 characters 5274c63293b5Smrg s/^.\{43\}//' | 5275c63293b5Smrg $SED -n ' 5276c63293b5Smrg # Join marker and all lines until next marker into a single line 5277c63293b5Smrg /^====MARK====/ b para 5278c63293b5Smrg H 5279c63293b5Smrg $ b para 5280c63293b5Smrg b 5281c63293b5Smrg :para 5282c63293b5Smrg x 5283c63293b5Smrg s/\n//g 5284c63293b5Smrg # Remove the marker 5285c63293b5Smrg s/^====MARK====// 5286c63293b5Smrg # Remove trailing dots and whitespace 5287c63293b5Smrg s/[\. \t]*$// 5288c63293b5Smrg # Print 5289c63293b5Smrg /./p' | 5290c63293b5Smrg # we now have a list, one entry per line, of the stringified 5291c63293b5Smrg # contents of the appropriate section of all members of the 52929d0ccd10Smrg # archive that possess that section. Heuristic: eliminate 52939d0ccd10Smrg # all those that have a first or second character that is 5294c63293b5Smrg # a '.' (that is, objdump's representation of an unprintable 5295c63293b5Smrg # character.) This should work for all archives with less than 5296c63293b5Smrg # 0x302f exports -- but will fail for DLLs whose name actually 5297c63293b5Smrg # begins with a literal '.' or a single character followed by 5298c63293b5Smrg # a '.'. 5299c63293b5Smrg # 5300c63293b5Smrg # Of those that remain, print the first one. 5301c63293b5Smrg $SED -e '/^\./d;/^.\./d;q' 5302c63293b5Smrg} 5303c63293b5Smrg 5304c63293b5Smrg# func_cygming_dll_for_implib_fallback ARG 5305c63293b5Smrg# Platform-specific function to extract the 5306c63293b5Smrg# name of the DLL associated with the specified 5307c63293b5Smrg# import library ARG. 5308c63293b5Smrg# 5309c63293b5Smrg# This fallback implementation is for use when $DLLTOOL 5310c63293b5Smrg# does not support the --identify-strict option. 5311c63293b5Smrg# Invoked by eval'ing the libtool variable 5312c63293b5Smrg# $sharedlib_from_linklib_cmd 5313c63293b5Smrg# Result is available in the variable 5314c63293b5Smrg# $sharedlib_from_linklib_result 5315c63293b5Smrgfunc_cygming_dll_for_implib_fallback () 5316c63293b5Smrg{ 53179d0ccd10Smrg $debug_cmd 53189d0ccd10Smrg 53199d0ccd10Smrg if func_cygming_gnu_implib_p "$1"; then 5320c63293b5Smrg # binutils import library 5321c63293b5Smrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` 53229d0ccd10Smrg elif func_cygming_ms_implib_p "$1"; then 5323c63293b5Smrg # ms-generated import library 5324c63293b5Smrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` 5325c63293b5Smrg else 5326c63293b5Smrg # unknown 53279d0ccd10Smrg sharedlib_from_linklib_result= 5328c63293b5Smrg fi 5329c63293b5Smrg} 53307914d74bSmrg 53317914d74bSmrg 5332e169010aSmrg# func_extract_an_archive dir oldlib 5333e169010aSmrgfunc_extract_an_archive () 5334e169010aSmrg{ 53359d0ccd10Smrg $debug_cmd 53369d0ccd10Smrg 53379d0ccd10Smrg f_ex_an_ar_dir=$1; shift 53389d0ccd10Smrg f_ex_an_ar_oldlib=$1 53399d0ccd10Smrg if test yes = "$lock_old_archive_extraction"; then 5340e8ead290Smrg lockfile=$f_ex_an_ar_oldlib.lock 5341e8ead290Smrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 5342e8ead290Smrg func_echo "Waiting for $lockfile to be removed" 5343e8ead290Smrg sleep 2 5344e8ead290Smrg done 5345e8ead290Smrg fi 5346e8ead290Smrg func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ 5347e8ead290Smrg 'stat=$?; rm -f "$lockfile"; exit $stat' 53489d0ccd10Smrg if test yes = "$lock_old_archive_extraction"; then 5349e8ead290Smrg $opt_dry_run || rm -f "$lockfile" 5350e8ead290Smrg fi 5351e169010aSmrg if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then 5352e169010aSmrg : 5353e169010aSmrg else 5354e169010aSmrg func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 5355e169010aSmrg fi 5356e169010aSmrg} 53577914d74bSmrg 53587914d74bSmrg 5359e169010aSmrg# func_extract_archives gentop oldlib ... 5360e169010aSmrgfunc_extract_archives () 5361e169010aSmrg{ 53629d0ccd10Smrg $debug_cmd 53639d0ccd10Smrg 53649d0ccd10Smrg my_gentop=$1; shift 5365e169010aSmrg my_oldlibs=${1+"$@"} 53669d0ccd10Smrg my_oldobjs= 53679d0ccd10Smrg my_xlib= 53689d0ccd10Smrg my_xabs= 53699d0ccd10Smrg my_xdir= 53707914d74bSmrg 5371e169010aSmrg for my_xlib in $my_oldlibs; do 5372e169010aSmrg # Extract the objects. 5373e169010aSmrg case $my_xlib in 53749d0ccd10Smrg [\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;; 5375e169010aSmrg *) my_xabs=`pwd`"/$my_xlib" ;; 5376e169010aSmrg esac 5377e169010aSmrg func_basename "$my_xlib" 53789d0ccd10Smrg my_xlib=$func_basename_result 5379e169010aSmrg my_xlib_u=$my_xlib 5380e169010aSmrg while :; do 5381e169010aSmrg case " $extracted_archives " in 5382e169010aSmrg *" $my_xlib_u "*) 5383e169010aSmrg func_arith $extracted_serial + 1 5384e169010aSmrg extracted_serial=$func_arith_result 5385e169010aSmrg my_xlib_u=lt$extracted_serial-$my_xlib ;; 5386e169010aSmrg *) break ;; 5387e169010aSmrg esac 5388e169010aSmrg done 5389e169010aSmrg extracted_archives="$extracted_archives $my_xlib_u" 53909d0ccd10Smrg my_xdir=$my_gentop/$my_xlib_u 53917914d74bSmrg 5392e169010aSmrg func_mkdir_p "$my_xdir" 53937914d74bSmrg 5394e169010aSmrg case $host in 5395e169010aSmrg *-darwin*) 5396e169010aSmrg func_verbose "Extracting $my_xabs" 5397e169010aSmrg # Do not bother doing anything if just a dry run 5398e169010aSmrg $opt_dry_run || { 5399e169010aSmrg darwin_orig_dir=`pwd` 5400e169010aSmrg cd $my_xdir || exit $? 5401e169010aSmrg darwin_archive=$my_xabs 5402e169010aSmrg darwin_curdir=`pwd` 54039d0ccd10Smrg func_basename "$darwin_archive" 54049d0ccd10Smrg darwin_base_archive=$func_basename_result 5405e169010aSmrg darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` 5406e169010aSmrg if test -n "$darwin_arches"; then 5407e169010aSmrg darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` 5408e169010aSmrg darwin_arch= 5409e169010aSmrg func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" 54109d0ccd10Smrg for darwin_arch in $darwin_arches; do 54119d0ccd10Smrg func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch" 54129d0ccd10Smrg $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive" 54139d0ccd10Smrg cd "unfat-$$/$darwin_base_archive-$darwin_arch" 54149d0ccd10Smrg func_extract_an_archive "`pwd`" "$darwin_base_archive" 5415e169010aSmrg cd "$darwin_curdir" 54169d0ccd10Smrg $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" 5417e169010aSmrg done # $darwin_arches 5418e169010aSmrg ## Okay now we've a bunch of thin objects, gotta fatten them up :) 54199d0ccd10Smrg darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$sed_basename" | sort -u` 5420e169010aSmrg darwin_file= 5421e169010aSmrg darwin_files= 5422e169010aSmrg for darwin_file in $darwin_filelist; do 5423e8ead290Smrg darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` 5424e169010aSmrg $LIPO -create -output "$darwin_file" $darwin_files 5425e169010aSmrg done # $darwin_filelist 5426e169010aSmrg $RM -rf unfat-$$ 5427e169010aSmrg cd "$darwin_orig_dir" 5428e169010aSmrg else 5429e169010aSmrg cd $darwin_orig_dir 5430e169010aSmrg func_extract_an_archive "$my_xdir" "$my_xabs" 5431e169010aSmrg fi # $darwin_arches 5432e169010aSmrg } # !$opt_dry_run 5433e169010aSmrg ;; 5434e169010aSmrg *) 5435e169010aSmrg func_extract_an_archive "$my_xdir" "$my_xabs" 5436e169010aSmrg ;; 54377914d74bSmrg esac 5438e8ead290Smrg my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` 5439e169010aSmrg done 54407914d74bSmrg 54419d0ccd10Smrg func_extract_archives_result=$my_oldobjs 5442e169010aSmrg} 54437914d74bSmrg 54447914d74bSmrg 5445e8ead290Smrg# func_emit_wrapper [arg=no] 5446e8ead290Smrg# 5447e8ead290Smrg# Emit a libtool wrapper script on stdout. 5448e8ead290Smrg# Don't directly open a file because we may want to 5449e8ead290Smrg# incorporate the script contents within a cygwin/mingw 5450e8ead290Smrg# wrapper executable. Must ONLY be called from within 5451e8ead290Smrg# func_mode_link because it depends on a number of variables 5452e8ead290Smrg# set therein. 5453e169010aSmrg# 5454e8ead290Smrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR 5455e8ead290Smrg# variable will take. If 'yes', then the emitted script 54569d0ccd10Smrg# will assume that the directory where it is stored is 5457e8ead290Smrg# the $objdir directory. This is a cygwin/mingw-specific 5458e8ead290Smrg# behavior. 5459e8ead290Smrgfunc_emit_wrapper () 5460e169010aSmrg{ 5461e8ead290Smrg func_emit_wrapper_arg1=${1-no} 54627914d74bSmrg 5463e169010aSmrg $ECHO "\ 5464e169010aSmrg#! $SHELL 54657914d74bSmrg 5466e169010aSmrg# $output - temporary wrapper script for $objdir/$outputname 54679d0ccd10Smrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 5468e169010aSmrg# 5469e169010aSmrg# The $output program cannot be directly executed until all the libtool 5470e169010aSmrg# libraries that it depends on are installed. 5471e169010aSmrg# 5472e169010aSmrg# This wrapper script should never be moved out of the build directory. 5473e169010aSmrg# If it is, it will not operate correctly. 54747914d74bSmrg 5475e169010aSmrg# Sed substitution that helps us do robust quoting. It backslashifies 5476e169010aSmrg# metacharacters that are still active within double-quoted strings. 5477e169010aSmrgsed_quote_subst='$sed_quote_subst' 54787914d74bSmrg 5479e169010aSmrg# Be Bourne compatible 5480e169010aSmrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then 5481e169010aSmrg emulate sh 5482e169010aSmrg NULLCMD=: 5483e169010aSmrg # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which 5484e169010aSmrg # is contrary to our usage. Disable this feature. 5485e169010aSmrg alias -g '\${1+\"\$@\"}'='\"\$@\"' 5486e169010aSmrg setopt NO_GLOB_SUBST 5487e169010aSmrgelse 5488e169010aSmrg case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac 5489e169010aSmrgfi 5490e169010aSmrgBIN_SH=xpg4; export BIN_SH # for Tru64 5491e169010aSmrgDUALCASE=1; export DUALCASE # for MKS sh 54927914d74bSmrg 5493e169010aSmrg# The HP-UX ksh and POSIX shell print the target directory to stdout 5494e169010aSmrg# if CDPATH is set. 5495e169010aSmrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 54967914d74bSmrg 5497e169010aSmrgrelink_command=\"$relink_command\" 54987914d74bSmrg 5499e169010aSmrg# This environment variable determines our operation mode. 5500e169010aSmrgif test \"\$libtool_install_magic\" = \"$magic\"; then 5501e169010aSmrg # install mode needs the following variables: 5502e169010aSmrg generated_by_libtool_version='$macro_version' 5503e169010aSmrg notinst_deplibs='$notinst_deplibs' 5504e169010aSmrgelse 5505e169010aSmrg # When we are sourced in execute mode, \$file and \$ECHO are already set. 5506e169010aSmrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 5507e8ead290Smrg file=\"\$0\"" 5508e8ead290Smrg 55090ea508b1Smrg func_quote_arg pretty "$ECHO" 55100ea508b1Smrg qECHO=$func_quote_arg_result 5511e8ead290Smrg $ECHO "\ 5512e8ead290Smrg 5513e8ead290Smrg# A function that is used when there is no print builtin or printf. 5514e8ead290Smrgfunc_fallback_echo () 5515e8ead290Smrg{ 5516e8ead290Smrg eval 'cat <<_LTECHO_EOF 5517e8ead290Smrg\$1 5518e8ead290Smrg_LTECHO_EOF' 5519e8ead290Smrg} 55200ea508b1Smrg ECHO=$qECHO 5521e8ead290Smrg fi 5522e8ead290Smrg 5523e8ead290Smrg# Very basic option parsing. These options are (a) specific to 5524e8ead290Smrg# the libtool wrapper, (b) are identical between the wrapper 55259d0ccd10Smrg# /script/ and the wrapper /executable/ that is used only on 5526e8ead290Smrg# windows platforms, and (c) all begin with the string "--lt-" 55279d0ccd10Smrg# (application programs are unlikely to have options that match 5528e8ead290Smrg# this pattern). 5529e8ead290Smrg# 5530e8ead290Smrg# There are only two supported options: --lt-debug and 5531e8ead290Smrg# --lt-dump-script. There is, deliberately, no --lt-help. 5532e8ead290Smrg# 5533e8ead290Smrg# The first argument to this parsing function should be the 5534e8ead290Smrg# script's $0 value, followed by "$@". 5535e8ead290Smrglt_option_debug= 5536e8ead290Smrgfunc_parse_lt_options () 5537e8ead290Smrg{ 5538e8ead290Smrg lt_script_arg0=\$0 5539e8ead290Smrg shift 5540e8ead290Smrg for lt_opt 5541e8ead290Smrg do 5542e8ead290Smrg case \"\$lt_opt\" in 5543e8ead290Smrg --lt-debug) lt_option_debug=1 ;; 5544e8ead290Smrg --lt-dump-script) 5545e8ead290Smrg lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` 5546e8ead290Smrg test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. 5547e8ead290Smrg lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` 5548e8ead290Smrg cat \"\$lt_dump_D/\$lt_dump_F\" 5549e8ead290Smrg exit 0 5550e8ead290Smrg ;; 5551e8ead290Smrg --lt-*) 5552e8ead290Smrg \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 5553e8ead290Smrg exit 1 5554e8ead290Smrg ;; 5555e8ead290Smrg esac 5556e8ead290Smrg done 5557e8ead290Smrg 5558e8ead290Smrg # Print the debug banner immediately: 5559e8ead290Smrg if test -n \"\$lt_option_debug\"; then 55609d0ccd10Smrg echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2 5561e8ead290Smrg fi 5562e8ead290Smrg} 5563e8ead290Smrg 5564e8ead290Smrg# Used when --lt-debug. Prints its arguments to stdout 5565e8ead290Smrg# (redirection is the responsibility of the caller) 5566e8ead290Smrgfunc_lt_dump_args () 5567e8ead290Smrg{ 5568e8ead290Smrg lt_dump_args_N=1; 5569e8ead290Smrg for lt_arg 5570e8ead290Smrg do 55719d0ccd10Smrg \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\" 5572e8ead290Smrg lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` 5573e8ead290Smrg done 5574e8ead290Smrg} 5575e8ead290Smrg 5576e8ead290Smrg# Core function for launching the target application 5577e8ead290Smrgfunc_exec_program_core () 5578e8ead290Smrg{ 5579e169010aSmrg" 5580e8ead290Smrg case $host in 5581e8ead290Smrg # Backslashes separate directories on plain windows 5582e8ead290Smrg *-*-mingw | *-*-os2* | *-cegcc*) 5583e8ead290Smrg $ECHO "\ 5584e8ead290Smrg if test -n \"\$lt_option_debug\"; then 55859d0ccd10Smrg \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2 5586e8ead290Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 5587e8ead290Smrg fi 5588e8ead290Smrg exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} 5589e8ead290Smrg" 5590e8ead290Smrg ;; 5591e8ead290Smrg 5592e8ead290Smrg *) 5593e8ead290Smrg $ECHO "\ 5594e8ead290Smrg if test -n \"\$lt_option_debug\"; then 55959d0ccd10Smrg \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2 5596e8ead290Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 5597e8ead290Smrg fi 5598e8ead290Smrg exec \"\$progdir/\$program\" \${1+\"\$@\"} 5599e8ead290Smrg" 5600e8ead290Smrg ;; 5601e8ead290Smrg esac 5602e8ead290Smrg $ECHO "\ 5603e8ead290Smrg \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 5604e8ead290Smrg exit 1 5605e8ead290Smrg} 5606e8ead290Smrg 5607e8ead290Smrg# A function to encapsulate launching the target application 5608e8ead290Smrg# Strips options in the --lt-* namespace from \$@ and 5609e8ead290Smrg# launches target application with the remaining arguments. 5610e8ead290Smrgfunc_exec_program () 5611e8ead290Smrg{ 5612e6d5e4e0Smrg case \" \$* \" in 5613e6d5e4e0Smrg *\\ --lt-*) 5614e6d5e4e0Smrg for lt_wr_arg 5615e6d5e4e0Smrg do 5616e6d5e4e0Smrg case \$lt_wr_arg in 5617e6d5e4e0Smrg --lt-*) ;; 5618e6d5e4e0Smrg *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; 5619e6d5e4e0Smrg esac 5620e6d5e4e0Smrg shift 5621e6d5e4e0Smrg done ;; 5622e6d5e4e0Smrg esac 5623e8ead290Smrg func_exec_program_core \${1+\"\$@\"} 5624e8ead290Smrg} 5625e8ead290Smrg 5626e8ead290Smrg # Parse options 5627e8ead290Smrg func_parse_lt_options \"\$0\" \${1+\"\$@\"} 56287914d74bSmrg 5629e169010aSmrg # Find the directory that this script lives in. 5630e8ead290Smrg thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` 5631e169010aSmrg test \"x\$thisdir\" = \"x\$file\" && thisdir=. 56327914d74bSmrg 5633e169010aSmrg # Follow symbolic links until we get to the real thisdir. 5634e8ead290Smrg file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` 5635e169010aSmrg while test -n \"\$file\"; do 5636e8ead290Smrg destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` 56377914d74bSmrg 5638e169010aSmrg # If there was a directory component, then change thisdir. 5639e169010aSmrg if test \"x\$destdir\" != \"x\$file\"; then 5640e169010aSmrg case \"\$destdir\" in 5641e169010aSmrg [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; 5642e169010aSmrg *) thisdir=\"\$thisdir/\$destdir\" ;; 5643e169010aSmrg esac 5644e169010aSmrg fi 56457914d74bSmrg 5646e8ead290Smrg file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` 5647e8ead290Smrg file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` 5648e169010aSmrg done 56497914d74bSmrg 5650e169010aSmrg # Usually 'no', except on cygwin/mingw when embedded into 5651e169010aSmrg # the cwrapper. 5652e8ead290Smrg WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 5653e169010aSmrg if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then 5654e169010aSmrg # special case for '.' 5655e169010aSmrg if test \"\$thisdir\" = \".\"; then 5656e169010aSmrg thisdir=\`pwd\` 5657e169010aSmrg fi 5658e169010aSmrg # remove .libs from thisdir 5659e169010aSmrg case \"\$thisdir\" in 5660e8ead290Smrg *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; 5661e169010aSmrg $objdir ) thisdir=. ;; 5662e169010aSmrg esac 5663e169010aSmrg fi 56647914d74bSmrg 5665e169010aSmrg # Try to get the absolute directory name. 5666e169010aSmrg absdir=\`cd \"\$thisdir\" && pwd\` 5667e169010aSmrg test -n \"\$absdir\" && thisdir=\"\$absdir\" 5668e169010aSmrg" 56697914d74bSmrg 56709d0ccd10Smrg if test yes = "$fast_install"; then 5671e169010aSmrg $ECHO "\ 5672e169010aSmrg program=lt-'$outputname'$exeext 5673e169010aSmrg progdir=\"\$thisdir/$objdir\" 56747914d74bSmrg 5675e169010aSmrg if test ! -f \"\$progdir/\$program\" || 56769d0ccd10Smrg { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\ 5677e169010aSmrg test \"X\$file\" != \"X\$progdir/\$program\"; }; then 56787914d74bSmrg 5679e169010aSmrg file=\"\$\$-\$program\" 56807914d74bSmrg 5681e169010aSmrg if test ! -d \"\$progdir\"; then 5682e169010aSmrg $MKDIR \"\$progdir\" 5683e169010aSmrg else 5684e169010aSmrg $RM \"\$progdir/\$file\" 5685e169010aSmrg fi" 56867914d74bSmrg 5687e169010aSmrg $ECHO "\ 56887914d74bSmrg 5689e169010aSmrg # relink executable if necessary 5690e169010aSmrg if test -n \"\$relink_command\"; then 5691e169010aSmrg if relink_command_output=\`eval \$relink_command 2>&1\`; then : 5692e169010aSmrg else 56939d0ccd10Smrg \$ECHO \"\$relink_command_output\" >&2 5694e169010aSmrg $RM \"\$progdir/\$file\" 5695e169010aSmrg exit 1 5696e169010aSmrg fi 5697e169010aSmrg fi 56987914d74bSmrg 5699e169010aSmrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || 5700e169010aSmrg { $RM \"\$progdir/\$program\"; 5701e169010aSmrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } 5702e169010aSmrg $RM \"\$progdir/\$file\" 5703e169010aSmrg fi" 5704e169010aSmrg else 5705e169010aSmrg $ECHO "\ 5706e169010aSmrg program='$outputname' 5707e169010aSmrg progdir=\"\$thisdir/$objdir\" 5708e169010aSmrg" 5709e169010aSmrg fi 57107914d74bSmrg 5711e169010aSmrg $ECHO "\ 57127914d74bSmrg 5713e169010aSmrg if test -f \"\$progdir/\$program\"; then" 57147914d74bSmrg 5715c63293b5Smrg # fixup the dll searchpath if we need to. 5716c63293b5Smrg # 5717c63293b5Smrg # Fix the DLL searchpath if we need to. Do this before prepending 5718c63293b5Smrg # to shlibpath, because on Windows, both are PATH and uninstalled 5719c63293b5Smrg # libraries must come first. 5720c63293b5Smrg if test -n "$dllsearchpath"; then 5721c63293b5Smrg $ECHO "\ 5722c63293b5Smrg # Add the dll search path components to the executable PATH 5723c63293b5Smrg PATH=$dllsearchpath:\$PATH 5724c63293b5Smrg" 5725c63293b5Smrg fi 5726c63293b5Smrg 5727e169010aSmrg # Export our shlibpath_var if we have one. 57289d0ccd10Smrg if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 5729e169010aSmrg $ECHO "\ 5730e169010aSmrg # Add our own library path to $shlibpath_var 5731e169010aSmrg $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" 57327914d74bSmrg 5733e169010aSmrg # Some systems cannot cope with colon-terminated $shlibpath_var 5734e169010aSmrg # The second colon is a workaround for a bug in BeOS R4 sed 5735e8ead290Smrg $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` 57367914d74bSmrg 5737e169010aSmrg export $shlibpath_var 5738e169010aSmrg" 57397914d74bSmrg fi 57407914d74bSmrg 5741e169010aSmrg $ECHO "\ 5742e169010aSmrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 5743e169010aSmrg # Run the actual program with our arguments. 5744e8ead290Smrg func_exec_program \${1+\"\$@\"} 5745e169010aSmrg fi 5746e169010aSmrg else 5747e169010aSmrg # The program doesn't exist. 57489d0ccd10Smrg \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2 5749e169010aSmrg \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 5750e8ead290Smrg \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 5751e169010aSmrg exit 1 5752e169010aSmrg fi 5753e169010aSmrgfi\ 5754e169010aSmrg" 5755e169010aSmrg} 57567914d74bSmrg 57577914d74bSmrg 5758e169010aSmrg# func_emit_cwrapperexe_src 5759e169010aSmrg# emit the source code for a wrapper executable on stdout 5760e169010aSmrg# Must ONLY be called from within func_mode_link because 5761e169010aSmrg# it depends on a number of variable set therein. 5762e169010aSmrgfunc_emit_cwrapperexe_src () 5763e169010aSmrg{ 5764e169010aSmrg cat <<EOF 57657914d74bSmrg 5766e169010aSmrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname 57679d0ccd10Smrg Generated by $PROGRAM (GNU $PACKAGE) $VERSION 57687914d74bSmrg 5769e169010aSmrg The $output program cannot be directly executed until all the libtool 5770e169010aSmrg libraries that it depends on are installed. 57717914d74bSmrg 5772e169010aSmrg This wrapper executable should never be moved out of the build directory. 5773e169010aSmrg If it is, it will not operate correctly. 5774e169010aSmrg*/ 5775e169010aSmrgEOF 5776e169010aSmrg cat <<"EOF" 5777e8ead290Smrg#ifdef _MSC_VER 5778e8ead290Smrg# define _CRT_SECURE_NO_DEPRECATE 1 5779e8ead290Smrg#endif 5780e169010aSmrg#include <stdio.h> 5781e169010aSmrg#include <stdlib.h> 5782e169010aSmrg#ifdef _MSC_VER 5783e169010aSmrg# include <direct.h> 5784e169010aSmrg# include <process.h> 5785e169010aSmrg# include <io.h> 5786e169010aSmrg#else 5787e169010aSmrg# include <unistd.h> 5788e169010aSmrg# include <stdint.h> 5789e169010aSmrg# ifdef __CYGWIN__ 5790e169010aSmrg# include <io.h> 5791e169010aSmrg# endif 5792e169010aSmrg#endif 5793e169010aSmrg#include <malloc.h> 5794e169010aSmrg#include <stdarg.h> 5795e169010aSmrg#include <assert.h> 5796e169010aSmrg#include <string.h> 5797e169010aSmrg#include <ctype.h> 5798e169010aSmrg#include <errno.h> 5799e169010aSmrg#include <fcntl.h> 5800e169010aSmrg#include <sys/stat.h> 5801e169010aSmrg 58029d0ccd10Smrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 58039d0ccd10Smrg 5804e8ead290Smrg/* declarations of non-ANSI functions */ 58059d0ccd10Smrg#if defined __MINGW32__ 5806e8ead290Smrg# ifdef __STRICT_ANSI__ 5807e8ead290Smrgint _putenv (const char *); 5808e8ead290Smrg# endif 58099d0ccd10Smrg#elif defined __CYGWIN__ 5810e8ead290Smrg# ifdef __STRICT_ANSI__ 5811e8ead290Smrgchar *realpath (const char *, char *); 5812e8ead290Smrgint putenv (char *); 5813e8ead290Smrgint setenv (const char *, const char *, int); 5814e8ead290Smrg# endif 58159d0ccd10Smrg/* #elif defined other_platform || defined ... */ 5816e8ead290Smrg#endif 5817e8ead290Smrg 5818e8ead290Smrg/* portability defines, excluding path handling macros */ 58199d0ccd10Smrg#if defined _MSC_VER 5820e8ead290Smrg# define setmode _setmode 5821e8ead290Smrg# define stat _stat 5822e8ead290Smrg# define chmod _chmod 5823e8ead290Smrg# define getcwd _getcwd 5824e8ead290Smrg# define putenv _putenv 5825e8ead290Smrg# define S_IXUSR _S_IEXEC 58269d0ccd10Smrg#elif defined __MINGW32__ 5827e8ead290Smrg# define setmode _setmode 5828e8ead290Smrg# define stat _stat 5829e8ead290Smrg# define chmod _chmod 5830e8ead290Smrg# define getcwd _getcwd 5831e8ead290Smrg# define putenv _putenv 58329d0ccd10Smrg#elif defined __CYGWIN__ 5833e8ead290Smrg# define HAVE_SETENV 5834e8ead290Smrg# define FOPEN_WB "wb" 58359d0ccd10Smrg/* #elif defined other platforms ... */ 5836e8ead290Smrg#endif 5837e8ead290Smrg 58389d0ccd10Smrg#if defined PATH_MAX 5839e169010aSmrg# define LT_PATHMAX PATH_MAX 58409d0ccd10Smrg#elif defined MAXPATHLEN 5841e169010aSmrg# define LT_PATHMAX MAXPATHLEN 5842e169010aSmrg#else 5843e169010aSmrg# define LT_PATHMAX 1024 5844e169010aSmrg#endif 5845e169010aSmrg 5846e169010aSmrg#ifndef S_IXOTH 5847e169010aSmrg# define S_IXOTH 0 5848e169010aSmrg#endif 5849e169010aSmrg#ifndef S_IXGRP 5850e169010aSmrg# define S_IXGRP 0 5851e169010aSmrg#endif 5852e169010aSmrg 5853e8ead290Smrg/* path handling portability macros */ 5854e169010aSmrg#ifndef DIR_SEPARATOR 5855e169010aSmrg# define DIR_SEPARATOR '/' 5856e169010aSmrg# define PATH_SEPARATOR ':' 5857e169010aSmrg#endif 5858e169010aSmrg 58599d0ccd10Smrg#if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \ 58609d0ccd10Smrg defined __OS2__ 5861e169010aSmrg# define HAVE_DOS_BASED_FILE_SYSTEM 5862e169010aSmrg# define FOPEN_WB "wb" 5863e169010aSmrg# ifndef DIR_SEPARATOR_2 5864e169010aSmrg# define DIR_SEPARATOR_2 '\\' 5865e169010aSmrg# endif 5866e169010aSmrg# ifndef PATH_SEPARATOR_2 5867e169010aSmrg# define PATH_SEPARATOR_2 ';' 5868e169010aSmrg# endif 5869e169010aSmrg#endif 5870e169010aSmrg 5871e169010aSmrg#ifndef DIR_SEPARATOR_2 5872e169010aSmrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) 5873e169010aSmrg#else /* DIR_SEPARATOR_2 */ 5874e169010aSmrg# define IS_DIR_SEPARATOR(ch) \ 5875e169010aSmrg (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) 5876e169010aSmrg#endif /* DIR_SEPARATOR_2 */ 5877e169010aSmrg 5878e169010aSmrg#ifndef PATH_SEPARATOR_2 5879e169010aSmrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) 5880e169010aSmrg#else /* PATH_SEPARATOR_2 */ 5881e169010aSmrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) 5882e169010aSmrg#endif /* PATH_SEPARATOR_2 */ 5883e169010aSmrg 5884e169010aSmrg#ifndef FOPEN_WB 5885e169010aSmrg# define FOPEN_WB "w" 5886e169010aSmrg#endif 5887e169010aSmrg#ifndef _O_BINARY 5888e169010aSmrg# define _O_BINARY 0 5889e169010aSmrg#endif 5890e169010aSmrg 5891e169010aSmrg#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) 5892e169010aSmrg#define XFREE(stale) do { \ 58939d0ccd10Smrg if (stale) { free (stale); stale = 0; } \ 5894e169010aSmrg} while (0) 5895e169010aSmrg 58969d0ccd10Smrg#if defined LT_DEBUGWRAPPER 5897e8ead290Smrgstatic int lt_debug = 1; 5898e169010aSmrg#else 5899e8ead290Smrgstatic int lt_debug = 0; 5900e169010aSmrg#endif 5901e169010aSmrg 5902e8ead290Smrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ 5903e169010aSmrg 5904e169010aSmrgvoid *xmalloc (size_t num); 5905e169010aSmrgchar *xstrdup (const char *string); 5906e169010aSmrgconst char *base_name (const char *name); 5907e169010aSmrgchar *find_executable (const char *wrapper); 5908e169010aSmrgchar *chase_symlinks (const char *pathspec); 5909e169010aSmrgint make_executable (const char *path); 5910e169010aSmrgint check_executable (const char *path); 5911e169010aSmrgchar *strendzap (char *str, const char *pat); 5912e8ead290Smrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...); 5913e8ead290Smrgvoid lt_fatal (const char *file, int line, const char *message, ...); 5914e8ead290Smrgstatic const char *nonnull (const char *s); 5915e8ead290Smrgstatic const char *nonempty (const char *s); 5916e169010aSmrgvoid lt_setenv (const char *name, const char *value); 5917e169010aSmrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end); 5918e169010aSmrgvoid lt_update_exe_path (const char *name, const char *value); 5919e169010aSmrgvoid lt_update_lib_path (const char *name, const char *value); 5920e8ead290Smrgchar **prepare_spawn (char **argv); 5921e8ead290Smrgvoid lt_dump_script (FILE *f); 5922e169010aSmrgEOF 5923e169010aSmrg 5924e169010aSmrg cat <<EOF 59259d0ccd10Smrg#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5) 59269d0ccd10Smrg# define externally_visible volatile 59279d0ccd10Smrg#else 59289d0ccd10Smrg# define externally_visible __attribute__((externally_visible)) volatile 59299d0ccd10Smrg#endif 59309d0ccd10Smrgexternally_visible const char * MAGIC_EXE = "$magic_exe"; 5931e169010aSmrgconst char * LIB_PATH_VARNAME = "$shlibpath_var"; 5932e169010aSmrgEOF 5933e169010aSmrg 59349d0ccd10Smrg if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 5935c63293b5Smrg func_to_host_path "$temp_rpath" 5936e169010aSmrg cat <<EOF 5937c63293b5Smrgconst char * LIB_PATH_VALUE = "$func_to_host_path_result"; 59387914d74bSmrgEOF 59397914d74bSmrg else 5940e169010aSmrg cat <<"EOF" 5941e169010aSmrgconst char * LIB_PATH_VALUE = ""; 5942e169010aSmrgEOF 59437914d74bSmrg fi 5944e169010aSmrg 5945e169010aSmrg if test -n "$dllsearchpath"; then 5946c63293b5Smrg func_to_host_path "$dllsearchpath:" 5947e169010aSmrg cat <<EOF 5948e169010aSmrgconst char * EXE_PATH_VARNAME = "PATH"; 5949c63293b5Smrgconst char * EXE_PATH_VALUE = "$func_to_host_path_result"; 5950e169010aSmrgEOF 59517914d74bSmrg else 5952e169010aSmrg cat <<"EOF" 5953e169010aSmrgconst char * EXE_PATH_VARNAME = ""; 5954e169010aSmrgconst char * EXE_PATH_VALUE = ""; 5955e169010aSmrgEOF 59567914d74bSmrg fi 5957e169010aSmrg 59589d0ccd10Smrg if test yes = "$fast_install"; then 5959e169010aSmrg cat <<EOF 5960e169010aSmrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */ 5961e169010aSmrgEOF 59627914d74bSmrg else 5963e169010aSmrg cat <<EOF 5964e169010aSmrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */ 5965e169010aSmrgEOF 59667914d74bSmrg fi 59677914d74bSmrg 59687914d74bSmrg 5969e169010aSmrg cat <<"EOF" 59707914d74bSmrg 5971e169010aSmrg#define LTWRAPPER_OPTION_PREFIX "--lt-" 59727914d74bSmrg 5973e169010aSmrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX; 5974e169010aSmrgstatic const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script"; 5975e8ead290Smrgstatic const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug"; 59767914d74bSmrg 5977e169010aSmrgint 5978e169010aSmrgmain (int argc, char *argv[]) 5979e169010aSmrg{ 5980e169010aSmrg char **newargz; 5981e169010aSmrg int newargc; 5982e169010aSmrg char *tmp_pathspec; 5983e169010aSmrg char *actual_cwrapper_path; 5984e169010aSmrg char *actual_cwrapper_name; 5985e169010aSmrg char *target_name; 5986e169010aSmrg char *lt_argv_zero; 59879d0ccd10Smrg int rval = 127; 59887914d74bSmrg 5989e169010aSmrg int i; 59907914d74bSmrg 5991e169010aSmrg program_name = (char *) xstrdup (base_name (argv[0])); 59929d0ccd10Smrg newargz = XMALLOC (char *, (size_t) argc + 1); 59937914d74bSmrg 5994e8ead290Smrg /* very simple arg parsing; don't want to rely on getopt 5995e8ead290Smrg * also, copy all non cwrapper options to newargz, except 5996e8ead290Smrg * argz[0], which is handled differently 5997e8ead290Smrg */ 5998e8ead290Smrg newargc=0; 5999e169010aSmrg for (i = 1; i < argc; i++) 6000e169010aSmrg { 60019d0ccd10Smrg if (STREQ (argv[i], dumpscript_opt)) 6002e169010aSmrg { 6003e169010aSmrgEOF 60049d0ccd10Smrg case $host in 6005e169010aSmrg *mingw* | *cygwin* ) 6006e169010aSmrg # make stdout use "unix" line endings 6007e169010aSmrg echo " setmode(1,_O_BINARY);" 6008e169010aSmrg ;; 6009e169010aSmrg esac 60107914d74bSmrg 6011e169010aSmrg cat <<"EOF" 6012e8ead290Smrg lt_dump_script (stdout); 6013e169010aSmrg return 0; 6014e169010aSmrg } 60159d0ccd10Smrg if (STREQ (argv[i], debug_opt)) 6016e8ead290Smrg { 6017e8ead290Smrg lt_debug = 1; 6018e8ead290Smrg continue; 6019e8ead290Smrg } 60209d0ccd10Smrg if (STREQ (argv[i], ltwrapper_option_prefix)) 6021e8ead290Smrg { 6022e8ead290Smrg /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX 6023e8ead290Smrg namespace, but it is not one of the ones we know about and 6024e8ead290Smrg have already dealt with, above (inluding dump-script), then 6025e8ead290Smrg report an error. Otherwise, targets might begin to believe 6026e8ead290Smrg they are allowed to use options in the LTWRAPPER_OPTION_PREFIX 6027e8ead290Smrg namespace. The first time any user complains about this, we'll 6028e8ead290Smrg need to make LTWRAPPER_OPTION_PREFIX a configure-time option 6029e8ead290Smrg or a configure.ac-settable value. 6030e8ead290Smrg */ 6031e8ead290Smrg lt_fatal (__FILE__, __LINE__, 6032e8ead290Smrg "unrecognized %s option: '%s'", 6033e8ead290Smrg ltwrapper_option_prefix, argv[i]); 6034e8ead290Smrg } 6035e8ead290Smrg /* otherwise ... */ 6036e8ead290Smrg newargz[++newargc] = xstrdup (argv[i]); 6037e169010aSmrg } 6038e8ead290Smrg newargz[++newargc] = NULL; 6039e8ead290Smrg 6040e8ead290SmrgEOF 6041e8ead290Smrg cat <<EOF 6042e8ead290Smrg /* The GNU banner must be the first non-error debug message */ 60439d0ccd10Smrg lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE) $VERSION\n"); 6044e8ead290SmrgEOF 6045e8ead290Smrg cat <<"EOF" 6046e8ead290Smrg lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]); 6047e8ead290Smrg lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name); 60487914d74bSmrg 6049e169010aSmrg tmp_pathspec = find_executable (argv[0]); 6050e169010aSmrg if (tmp_pathspec == NULL) 6051e8ead290Smrg lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]); 6052e8ead290Smrg lt_debugprintf (__FILE__, __LINE__, 6053e8ead290Smrg "(main) found exe (before symlink chase) at: %s\n", 6054e8ead290Smrg tmp_pathspec); 6055e169010aSmrg 6056e169010aSmrg actual_cwrapper_path = chase_symlinks (tmp_pathspec); 6057e8ead290Smrg lt_debugprintf (__FILE__, __LINE__, 6058e8ead290Smrg "(main) found exe (after symlink chase) at: %s\n", 6059e8ead290Smrg actual_cwrapper_path); 6060e169010aSmrg XFREE (tmp_pathspec); 6061e169010aSmrg 6062e8ead290Smrg actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path)); 6063e169010aSmrg strendzap (actual_cwrapper_path, actual_cwrapper_name); 6064e169010aSmrg 6065e169010aSmrg /* wrapper name transforms */ 6066e169010aSmrg strendzap (actual_cwrapper_name, ".exe"); 6067e169010aSmrg tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1); 6068e169010aSmrg XFREE (actual_cwrapper_name); 6069e169010aSmrg actual_cwrapper_name = tmp_pathspec; 6070e169010aSmrg tmp_pathspec = 0; 6071e169010aSmrg 6072e169010aSmrg /* target_name transforms -- use actual target program name; might have lt- prefix */ 6073e169010aSmrg target_name = xstrdup (base_name (TARGET_PROGRAM_NAME)); 6074e169010aSmrg strendzap (target_name, ".exe"); 6075e169010aSmrg tmp_pathspec = lt_extend_str (target_name, ".exe", 1); 6076e169010aSmrg XFREE (target_name); 6077e169010aSmrg target_name = tmp_pathspec; 6078e169010aSmrg tmp_pathspec = 0; 6079e169010aSmrg 6080e8ead290Smrg lt_debugprintf (__FILE__, __LINE__, 6081e8ead290Smrg "(main) libtool target name: %s\n", 6082e8ead290Smrg target_name); 6083e169010aSmrgEOF 60847914d74bSmrg 6085e169010aSmrg cat <<EOF 6086e169010aSmrg newargz[0] = 6087e169010aSmrg XMALLOC (char, (strlen (actual_cwrapper_path) + 6088e169010aSmrg strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1)); 6089e169010aSmrg strcpy (newargz[0], actual_cwrapper_path); 6090e169010aSmrg strcat (newargz[0], "$objdir"); 6091e169010aSmrg strcat (newargz[0], "/"); 6092e169010aSmrgEOF 60937914d74bSmrg 6094e169010aSmrg cat <<"EOF" 6095e169010aSmrg /* stop here, and copy so we don't have to do this twice */ 6096e169010aSmrg tmp_pathspec = xstrdup (newargz[0]); 60977914d74bSmrg 6098e169010aSmrg /* do NOT want the lt- prefix here, so use actual_cwrapper_name */ 6099e169010aSmrg strcat (newargz[0], actual_cwrapper_name); 61007914d74bSmrg 6101e169010aSmrg /* DO want the lt- prefix here if it exists, so use target_name */ 6102e169010aSmrg lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1); 6103e169010aSmrg XFREE (tmp_pathspec); 6104e169010aSmrg tmp_pathspec = NULL; 6105e169010aSmrgEOF 61067914d74bSmrg 6107e169010aSmrg case $host_os in 6108e169010aSmrg mingw*) 6109e169010aSmrg cat <<"EOF" 6110e169010aSmrg { 6111e169010aSmrg char* p; 6112e169010aSmrg while ((p = strchr (newargz[0], '\\')) != NULL) 6113e169010aSmrg { 6114e169010aSmrg *p = '/'; 6115e169010aSmrg } 6116e169010aSmrg while ((p = strchr (lt_argv_zero, '\\')) != NULL) 6117e169010aSmrg { 6118e169010aSmrg *p = '/'; 6119e169010aSmrg } 6120e169010aSmrg } 6121e169010aSmrgEOF 6122e169010aSmrg ;; 6123e169010aSmrg esac 61247914d74bSmrg 6125e169010aSmrg cat <<"EOF" 6126e169010aSmrg XFREE (target_name); 6127e169010aSmrg XFREE (actual_cwrapper_path); 6128e169010aSmrg XFREE (actual_cwrapper_name); 61297914d74bSmrg 6130e169010aSmrg lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */ 6131e169010aSmrg lt_setenv ("DUALCASE", "1"); /* for MSK sh */ 6132c63293b5Smrg /* Update the DLL searchpath. EXE_PATH_VALUE ($dllsearchpath) must 6133c63293b5Smrg be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath) 6134c63293b5Smrg because on Windows, both *_VARNAMEs are PATH but uninstalled 6135c63293b5Smrg libraries must come first. */ 6136e169010aSmrg lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE); 6137c63293b5Smrg lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE); 61387914d74bSmrg 6139e8ead290Smrg lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n", 6140e8ead290Smrg nonnull (lt_argv_zero)); 6141e169010aSmrg for (i = 0; i < newargc; i++) 6142e169010aSmrg { 6143e8ead290Smrg lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n", 6144e8ead290Smrg i, nonnull (newargz[i])); 6145e169010aSmrg } 61467914d74bSmrg 6147e169010aSmrgEOF 61487914d74bSmrg 6149e169010aSmrg case $host_os in 6150e169010aSmrg mingw*) 6151e169010aSmrg cat <<"EOF" 6152e169010aSmrg /* execv doesn't actually work on mingw as expected on unix */ 6153e8ead290Smrg newargz = prepare_spawn (newargz); 61549d0ccd10Smrg rval = (int) _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz); 6155e169010aSmrg if (rval == -1) 6156e169010aSmrg { 6157e169010aSmrg /* failed to start process */ 6158e8ead290Smrg lt_debugprintf (__FILE__, __LINE__, 6159e8ead290Smrg "(main) failed to launch target \"%s\": %s\n", 6160e8ead290Smrg lt_argv_zero, nonnull (strerror (errno))); 6161e169010aSmrg return 127; 6162e169010aSmrg } 6163e169010aSmrg return rval; 6164e169010aSmrgEOF 6165e169010aSmrg ;; 6166e169010aSmrg *) 6167e169010aSmrg cat <<"EOF" 6168e169010aSmrg execv (lt_argv_zero, newargz); 6169e169010aSmrg return rval; /* =127, but avoids unused variable warning */ 6170e169010aSmrgEOF 6171e169010aSmrg ;; 6172e169010aSmrg esac 61737914d74bSmrg 6174e169010aSmrg cat <<"EOF" 6175e169010aSmrg} 61767914d74bSmrg 6177e169010aSmrgvoid * 6178e169010aSmrgxmalloc (size_t num) 6179e169010aSmrg{ 6180e169010aSmrg void *p = (void *) malloc (num); 6181e169010aSmrg if (!p) 6182e8ead290Smrg lt_fatal (__FILE__, __LINE__, "memory exhausted"); 61837914d74bSmrg 6184e169010aSmrg return p; 6185e169010aSmrg} 61867914d74bSmrg 6187e169010aSmrgchar * 6188e169010aSmrgxstrdup (const char *string) 6189e169010aSmrg{ 6190e169010aSmrg return string ? strcpy ((char *) xmalloc (strlen (string) + 1), 6191e169010aSmrg string) : NULL; 6192e169010aSmrg} 61937914d74bSmrg 6194e169010aSmrgconst char * 6195e169010aSmrgbase_name (const char *name) 6196e169010aSmrg{ 6197e169010aSmrg const char *base; 61987914d74bSmrg 61999d0ccd10Smrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 6200e169010aSmrg /* Skip over the disk name in MSDOS pathnames. */ 6201e169010aSmrg if (isalpha ((unsigned char) name[0]) && name[1] == ':') 6202e169010aSmrg name += 2; 6203e169010aSmrg#endif 62047914d74bSmrg 6205e169010aSmrg for (base = name; *name; name++) 6206e169010aSmrg if (IS_DIR_SEPARATOR (*name)) 6207e169010aSmrg base = name + 1; 6208e169010aSmrg return base; 6209e169010aSmrg} 62107914d74bSmrg 6211e169010aSmrgint 6212e169010aSmrgcheck_executable (const char *path) 6213e169010aSmrg{ 6214e169010aSmrg struct stat st; 62157914d74bSmrg 6216e8ead290Smrg lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n", 6217e8ead290Smrg nonempty (path)); 6218e169010aSmrg if ((!path) || (!*path)) 6219e169010aSmrg return 0; 62207914d74bSmrg 6221e169010aSmrg if ((stat (path, &st) >= 0) 6222e169010aSmrg && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) 6223e169010aSmrg return 1; 6224e169010aSmrg else 6225e169010aSmrg return 0; 6226e169010aSmrg} 62277914d74bSmrg 6228e169010aSmrgint 6229e169010aSmrgmake_executable (const char *path) 6230e169010aSmrg{ 6231e169010aSmrg int rval = 0; 6232e169010aSmrg struct stat st; 62337914d74bSmrg 6234e8ead290Smrg lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", 6235e8ead290Smrg nonempty (path)); 6236e169010aSmrg if ((!path) || (!*path)) 6237e169010aSmrg return 0; 62387914d74bSmrg 6239e169010aSmrg if (stat (path, &st) >= 0) 6240e169010aSmrg { 6241e169010aSmrg rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); 6242e169010aSmrg } 6243e169010aSmrg return rval; 6244e169010aSmrg} 62457914d74bSmrg 6246e169010aSmrg/* Searches for the full path of the wrapper. Returns 6247e169010aSmrg newly allocated full path name if found, NULL otherwise 6248e169010aSmrg Does not chase symlinks, even on platforms that support them. 6249e169010aSmrg*/ 6250e169010aSmrgchar * 6251e169010aSmrgfind_executable (const char *wrapper) 6252e169010aSmrg{ 6253e169010aSmrg int has_slash = 0; 6254e169010aSmrg const char *p; 6255e169010aSmrg const char *p_next; 6256e169010aSmrg /* static buffer for getcwd */ 6257e169010aSmrg char tmp[LT_PATHMAX + 1]; 62589d0ccd10Smrg size_t tmp_len; 6259e169010aSmrg char *concat_name; 62607914d74bSmrg 6261e8ead290Smrg lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", 6262e8ead290Smrg nonempty (wrapper)); 62637914d74bSmrg 6264e169010aSmrg if ((wrapper == NULL) || (*wrapper == '\0')) 6265e169010aSmrg return NULL; 62667914d74bSmrg 6267e169010aSmrg /* Absolute path? */ 62689d0ccd10Smrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 6269e169010aSmrg if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') 6270e169010aSmrg { 6271e169010aSmrg concat_name = xstrdup (wrapper); 6272e169010aSmrg if (check_executable (concat_name)) 6273e169010aSmrg return concat_name; 6274e169010aSmrg XFREE (concat_name); 6275e169010aSmrg } 6276e169010aSmrg else 6277e169010aSmrg { 6278e169010aSmrg#endif 6279e169010aSmrg if (IS_DIR_SEPARATOR (wrapper[0])) 6280e169010aSmrg { 6281e169010aSmrg concat_name = xstrdup (wrapper); 6282e169010aSmrg if (check_executable (concat_name)) 6283e169010aSmrg return concat_name; 6284e169010aSmrg XFREE (concat_name); 6285e169010aSmrg } 62869d0ccd10Smrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 6287e169010aSmrg } 6288e169010aSmrg#endif 62897914d74bSmrg 6290e169010aSmrg for (p = wrapper; *p; p++) 6291e169010aSmrg if (*p == '/') 6292e169010aSmrg { 6293e169010aSmrg has_slash = 1; 6294e169010aSmrg break; 6295e169010aSmrg } 6296e169010aSmrg if (!has_slash) 6297e169010aSmrg { 6298e169010aSmrg /* no slashes; search PATH */ 6299e169010aSmrg const char *path = getenv ("PATH"); 6300e169010aSmrg if (path != NULL) 6301e169010aSmrg { 6302e169010aSmrg for (p = path; *p; p = p_next) 6303e169010aSmrg { 6304e169010aSmrg const char *q; 6305e169010aSmrg size_t p_len; 6306e169010aSmrg for (q = p; *q; q++) 6307e169010aSmrg if (IS_PATH_SEPARATOR (*q)) 6308e169010aSmrg break; 63099d0ccd10Smrg p_len = (size_t) (q - p); 6310e169010aSmrg p_next = (*q == '\0' ? q : q + 1); 6311e169010aSmrg if (p_len == 0) 6312e169010aSmrg { 6313e169010aSmrg /* empty path: current directory */ 6314e169010aSmrg if (getcwd (tmp, LT_PATHMAX) == NULL) 6315e8ead290Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 6316e8ead290Smrg nonnull (strerror (errno))); 6317e169010aSmrg tmp_len = strlen (tmp); 6318e169010aSmrg concat_name = 6319e169010aSmrg XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 6320e169010aSmrg memcpy (concat_name, tmp, tmp_len); 6321e169010aSmrg concat_name[tmp_len] = '/'; 6322e169010aSmrg strcpy (concat_name + tmp_len + 1, wrapper); 6323e169010aSmrg } 6324e169010aSmrg else 6325e169010aSmrg { 6326e169010aSmrg concat_name = 6327e169010aSmrg XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); 6328e169010aSmrg memcpy (concat_name, p, p_len); 6329e169010aSmrg concat_name[p_len] = '/'; 6330e169010aSmrg strcpy (concat_name + p_len + 1, wrapper); 6331e169010aSmrg } 6332e169010aSmrg if (check_executable (concat_name)) 6333e169010aSmrg return concat_name; 6334e169010aSmrg XFREE (concat_name); 6335e169010aSmrg } 6336e169010aSmrg } 6337e169010aSmrg /* not found in PATH; assume curdir */ 6338e169010aSmrg } 6339e169010aSmrg /* Relative path | not found in path: prepend cwd */ 6340e169010aSmrg if (getcwd (tmp, LT_PATHMAX) == NULL) 6341e8ead290Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 6342e8ead290Smrg nonnull (strerror (errno))); 6343e169010aSmrg tmp_len = strlen (tmp); 6344e169010aSmrg concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 6345e169010aSmrg memcpy (concat_name, tmp, tmp_len); 6346e169010aSmrg concat_name[tmp_len] = '/'; 6347e169010aSmrg strcpy (concat_name + tmp_len + 1, wrapper); 63487914d74bSmrg 6349e169010aSmrg if (check_executable (concat_name)) 6350e169010aSmrg return concat_name; 6351e169010aSmrg XFREE (concat_name); 6352e169010aSmrg return NULL; 6353e169010aSmrg} 63547914d74bSmrg 6355e169010aSmrgchar * 6356e169010aSmrgchase_symlinks (const char *pathspec) 6357e169010aSmrg{ 6358e169010aSmrg#ifndef S_ISLNK 6359e169010aSmrg return xstrdup (pathspec); 6360e169010aSmrg#else 6361e169010aSmrg char buf[LT_PATHMAX]; 6362e169010aSmrg struct stat s; 6363e169010aSmrg char *tmp_pathspec = xstrdup (pathspec); 6364e169010aSmrg char *p; 6365e169010aSmrg int has_symlinks = 0; 6366e169010aSmrg while (strlen (tmp_pathspec) && !has_symlinks) 6367e169010aSmrg { 6368e8ead290Smrg lt_debugprintf (__FILE__, __LINE__, 6369e8ead290Smrg "checking path component for symlinks: %s\n", 6370e8ead290Smrg tmp_pathspec); 6371e169010aSmrg if (lstat (tmp_pathspec, &s) == 0) 6372e169010aSmrg { 6373e169010aSmrg if (S_ISLNK (s.st_mode) != 0) 6374e169010aSmrg { 6375e169010aSmrg has_symlinks = 1; 6376e169010aSmrg break; 6377e169010aSmrg } 63787914d74bSmrg 6379e169010aSmrg /* search backwards for last DIR_SEPARATOR */ 6380e169010aSmrg p = tmp_pathspec + strlen (tmp_pathspec) - 1; 6381e169010aSmrg while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 6382e169010aSmrg p--; 6383e169010aSmrg if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 6384e169010aSmrg { 6385e169010aSmrg /* no more DIR_SEPARATORS left */ 6386e169010aSmrg break; 6387e169010aSmrg } 6388e169010aSmrg *p = '\0'; 6389e169010aSmrg } 6390e169010aSmrg else 6391e169010aSmrg { 6392e8ead290Smrg lt_fatal (__FILE__, __LINE__, 6393e8ead290Smrg "error accessing file \"%s\": %s", 6394e8ead290Smrg tmp_pathspec, nonnull (strerror (errno))); 6395e169010aSmrg } 6396e169010aSmrg } 6397e169010aSmrg XFREE (tmp_pathspec); 63987914d74bSmrg 6399e169010aSmrg if (!has_symlinks) 6400e169010aSmrg { 6401e169010aSmrg return xstrdup (pathspec); 6402e169010aSmrg } 64037914d74bSmrg 6404e169010aSmrg tmp_pathspec = realpath (pathspec, buf); 6405e169010aSmrg if (tmp_pathspec == 0) 6406e169010aSmrg { 6407e8ead290Smrg lt_fatal (__FILE__, __LINE__, 6408e8ead290Smrg "could not follow symlinks for %s", pathspec); 6409e169010aSmrg } 6410e169010aSmrg return xstrdup (tmp_pathspec); 6411e169010aSmrg#endif 6412e169010aSmrg} 64137914d74bSmrg 6414e169010aSmrgchar * 6415e169010aSmrgstrendzap (char *str, const char *pat) 6416e169010aSmrg{ 6417e169010aSmrg size_t len, patlen; 64187914d74bSmrg 6419e169010aSmrg assert (str != NULL); 6420e169010aSmrg assert (pat != NULL); 64217914d74bSmrg 6422e169010aSmrg len = strlen (str); 6423e169010aSmrg patlen = strlen (pat); 64247914d74bSmrg 6425e169010aSmrg if (patlen <= len) 6426e169010aSmrg { 6427e169010aSmrg str += len - patlen; 64289d0ccd10Smrg if (STREQ (str, pat)) 6429e169010aSmrg *str = '\0'; 6430e169010aSmrg } 6431e169010aSmrg return str; 6432e169010aSmrg} 64337914d74bSmrg 6434e8ead290Smrgvoid 6435e8ead290Smrglt_debugprintf (const char *file, int line, const char *fmt, ...) 6436e8ead290Smrg{ 6437e8ead290Smrg va_list args; 6438e8ead290Smrg if (lt_debug) 6439e8ead290Smrg { 6440e8ead290Smrg (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); 6441e8ead290Smrg va_start (args, fmt); 6442e8ead290Smrg (void) vfprintf (stderr, fmt, args); 6443e8ead290Smrg va_end (args); 6444e8ead290Smrg } 6445e8ead290Smrg} 6446e8ead290Smrg 6447e169010aSmrgstatic void 6448e8ead290Smrglt_error_core (int exit_status, const char *file, 6449e8ead290Smrg int line, const char *mode, 6450e169010aSmrg const char *message, va_list ap) 6451e169010aSmrg{ 6452e8ead290Smrg fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); 6453e169010aSmrg vfprintf (stderr, message, ap); 6454e169010aSmrg fprintf (stderr, ".\n"); 64557914d74bSmrg 6456e169010aSmrg if (exit_status >= 0) 6457e169010aSmrg exit (exit_status); 6458e169010aSmrg} 64597914d74bSmrg 6460e169010aSmrgvoid 6461e8ead290Smrglt_fatal (const char *file, int line, const char *message, ...) 6462e169010aSmrg{ 6463e169010aSmrg va_list ap; 6464e169010aSmrg va_start (ap, message); 6465e8ead290Smrg lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); 6466e169010aSmrg va_end (ap); 6467e169010aSmrg} 64687914d74bSmrg 6469e8ead290Smrgstatic const char * 6470e8ead290Smrgnonnull (const char *s) 6471e8ead290Smrg{ 6472e8ead290Smrg return s ? s : "(null)"; 6473e8ead290Smrg} 6474e8ead290Smrg 6475e8ead290Smrgstatic const char * 6476e8ead290Smrgnonempty (const char *s) 6477e8ead290Smrg{ 6478e8ead290Smrg return (s && !*s) ? "(empty)" : nonnull (s); 6479e8ead290Smrg} 6480e8ead290Smrg 6481e169010aSmrgvoid 6482e169010aSmrglt_setenv (const char *name, const char *value) 6483e169010aSmrg{ 6484e8ead290Smrg lt_debugprintf (__FILE__, __LINE__, 6485e8ead290Smrg "(lt_setenv) setting '%s' to '%s'\n", 6486e8ead290Smrg nonnull (name), nonnull (value)); 6487e169010aSmrg { 6488e169010aSmrg#ifdef HAVE_SETENV 6489e169010aSmrg /* always make a copy, for consistency with !HAVE_SETENV */ 6490e169010aSmrg char *str = xstrdup (value); 6491e169010aSmrg setenv (name, str, 1); 6492e169010aSmrg#else 64939d0ccd10Smrg size_t len = strlen (name) + 1 + strlen (value) + 1; 6494e169010aSmrg char *str = XMALLOC (char, len); 6495e169010aSmrg sprintf (str, "%s=%s", name, value); 6496e169010aSmrg if (putenv (str) != EXIT_SUCCESS) 6497e169010aSmrg { 6498e169010aSmrg XFREE (str); 6499e169010aSmrg } 6500e169010aSmrg#endif 6501e169010aSmrg } 6502e169010aSmrg} 65037914d74bSmrg 6504e169010aSmrgchar * 6505e169010aSmrglt_extend_str (const char *orig_value, const char *add, int to_end) 6506e169010aSmrg{ 6507e169010aSmrg char *new_value; 6508e169010aSmrg if (orig_value && *orig_value) 6509e169010aSmrg { 65109d0ccd10Smrg size_t orig_value_len = strlen (orig_value); 65119d0ccd10Smrg size_t add_len = strlen (add); 6512e169010aSmrg new_value = XMALLOC (char, add_len + orig_value_len + 1); 6513e169010aSmrg if (to_end) 6514e169010aSmrg { 6515e169010aSmrg strcpy (new_value, orig_value); 6516e169010aSmrg strcpy (new_value + orig_value_len, add); 6517e169010aSmrg } 6518e169010aSmrg else 6519e169010aSmrg { 6520e169010aSmrg strcpy (new_value, add); 6521e169010aSmrg strcpy (new_value + add_len, orig_value); 6522e169010aSmrg } 6523e169010aSmrg } 6524e169010aSmrg else 6525e169010aSmrg { 6526e169010aSmrg new_value = xstrdup (add); 6527e169010aSmrg } 6528e169010aSmrg return new_value; 6529e169010aSmrg} 65307914d74bSmrg 6531e169010aSmrgvoid 6532e169010aSmrglt_update_exe_path (const char *name, const char *value) 6533e169010aSmrg{ 6534e8ead290Smrg lt_debugprintf (__FILE__, __LINE__, 6535e8ead290Smrg "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", 6536e8ead290Smrg nonnull (name), nonnull (value)); 65377914d74bSmrg 6538e169010aSmrg if (name && *name && value && *value) 6539e169010aSmrg { 6540e169010aSmrg char *new_value = lt_extend_str (getenv (name), value, 0); 6541e169010aSmrg /* some systems can't cope with a ':'-terminated path #' */ 65429d0ccd10Smrg size_t len = strlen (new_value); 65439d0ccd10Smrg while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1])) 6544e169010aSmrg { 65459d0ccd10Smrg new_value[--len] = '\0'; 6546e169010aSmrg } 6547e169010aSmrg lt_setenv (name, new_value); 6548e169010aSmrg XFREE (new_value); 6549e169010aSmrg } 6550e169010aSmrg} 65517914d74bSmrg 6552e169010aSmrgvoid 6553e169010aSmrglt_update_lib_path (const char *name, const char *value) 6554e169010aSmrg{ 6555e8ead290Smrg lt_debugprintf (__FILE__, __LINE__, 6556e8ead290Smrg "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", 6557e8ead290Smrg nonnull (name), nonnull (value)); 65587914d74bSmrg 6559e169010aSmrg if (name && *name && value && *value) 6560e169010aSmrg { 6561e169010aSmrg char *new_value = lt_extend_str (getenv (name), value, 0); 6562e169010aSmrg lt_setenv (name, new_value); 6563e169010aSmrg XFREE (new_value); 6564e169010aSmrg } 6565e169010aSmrg} 65667914d74bSmrg 6567e8ead290SmrgEOF 6568e8ead290Smrg case $host_os in 6569e8ead290Smrg mingw*) 6570e8ead290Smrg cat <<"EOF" 6571e8ead290Smrg 6572e8ead290Smrg/* Prepares an argument vector before calling spawn(). 6573e8ead290Smrg Note that spawn() does not by itself call the command interpreter 6574e8ead290Smrg (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : 6575e8ead290Smrg ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); 6576e8ead290Smrg GetVersionEx(&v); 6577e8ead290Smrg v.dwPlatformId == VER_PLATFORM_WIN32_NT; 6578e8ead290Smrg }) ? "cmd.exe" : "command.com"). 6579e8ead290Smrg Instead it simply concatenates the arguments, separated by ' ', and calls 6580e8ead290Smrg CreateProcess(). We must quote the arguments since Win32 CreateProcess() 6581e8ead290Smrg interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a 6582e8ead290Smrg special way: 6583e8ead290Smrg - Space and tab are interpreted as delimiters. They are not treated as 6584e8ead290Smrg delimiters if they are surrounded by double quotes: "...". 6585e8ead290Smrg - Unescaped double quotes are removed from the input. Their only effect is 6586e8ead290Smrg that within double quotes, space and tab are treated like normal 6587e8ead290Smrg characters. 6588e8ead290Smrg - Backslashes not followed by double quotes are not special. 6589e8ead290Smrg - But 2*n+1 backslashes followed by a double quote become 6590e8ead290Smrg n backslashes followed by a double quote (n >= 0): 6591e8ead290Smrg \" -> " 6592e8ead290Smrg \\\" -> \" 6593e8ead290Smrg \\\\\" -> \\" 6594e8ead290Smrg */ 6595e8ead290Smrg#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" 6596e8ead290Smrg#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" 6597e8ead290Smrgchar ** 6598e8ead290Smrgprepare_spawn (char **argv) 6599e8ead290Smrg{ 6600e8ead290Smrg size_t argc; 6601e8ead290Smrg char **new_argv; 6602e8ead290Smrg size_t i; 6603e8ead290Smrg 6604e8ead290Smrg /* Count number of arguments. */ 6605e8ead290Smrg for (argc = 0; argv[argc] != NULL; argc++) 6606e8ead290Smrg ; 6607e8ead290Smrg 6608e8ead290Smrg /* Allocate new argument vector. */ 6609e8ead290Smrg new_argv = XMALLOC (char *, argc + 1); 6610e8ead290Smrg 6611e8ead290Smrg /* Put quoted arguments into the new argument vector. */ 6612e8ead290Smrg for (i = 0; i < argc; i++) 6613e8ead290Smrg { 6614e8ead290Smrg const char *string = argv[i]; 6615e8ead290Smrg 6616e8ead290Smrg if (string[0] == '\0') 6617e8ead290Smrg new_argv[i] = xstrdup ("\"\""); 6618e8ead290Smrg else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) 6619e8ead290Smrg { 6620e8ead290Smrg int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); 6621e8ead290Smrg size_t length; 6622e8ead290Smrg unsigned int backslashes; 6623e8ead290Smrg const char *s; 6624e8ead290Smrg char *quoted_string; 6625e8ead290Smrg char *p; 6626e8ead290Smrg 6627e8ead290Smrg length = 0; 6628e8ead290Smrg backslashes = 0; 6629e8ead290Smrg if (quote_around) 6630e8ead290Smrg length++; 6631e8ead290Smrg for (s = string; *s != '\0'; s++) 6632e8ead290Smrg { 6633e8ead290Smrg char c = *s; 6634e8ead290Smrg if (c == '"') 6635e8ead290Smrg length += backslashes + 1; 6636e8ead290Smrg length++; 6637e8ead290Smrg if (c == '\\') 6638e8ead290Smrg backslashes++; 6639e8ead290Smrg else 6640e8ead290Smrg backslashes = 0; 6641e8ead290Smrg } 6642e8ead290Smrg if (quote_around) 6643e8ead290Smrg length += backslashes + 1; 6644e8ead290Smrg 6645e8ead290Smrg quoted_string = XMALLOC (char, length + 1); 6646e8ead290Smrg 6647e8ead290Smrg p = quoted_string; 6648e8ead290Smrg backslashes = 0; 6649e8ead290Smrg if (quote_around) 6650e8ead290Smrg *p++ = '"'; 6651e8ead290Smrg for (s = string; *s != '\0'; s++) 6652e8ead290Smrg { 6653e8ead290Smrg char c = *s; 6654e8ead290Smrg if (c == '"') 6655e8ead290Smrg { 6656e8ead290Smrg unsigned int j; 6657e8ead290Smrg for (j = backslashes + 1; j > 0; j--) 6658e8ead290Smrg *p++ = '\\'; 6659e8ead290Smrg } 6660e8ead290Smrg *p++ = c; 6661e8ead290Smrg if (c == '\\') 6662e8ead290Smrg backslashes++; 6663e8ead290Smrg else 6664e8ead290Smrg backslashes = 0; 6665e8ead290Smrg } 6666e8ead290Smrg if (quote_around) 6667e8ead290Smrg { 6668e8ead290Smrg unsigned int j; 6669e8ead290Smrg for (j = backslashes; j > 0; j--) 6670e8ead290Smrg *p++ = '\\'; 6671e8ead290Smrg *p++ = '"'; 6672e8ead290Smrg } 6673e8ead290Smrg *p = '\0'; 6674e8ead290Smrg 6675e8ead290Smrg new_argv[i] = quoted_string; 6676e8ead290Smrg } 6677e8ead290Smrg else 6678e8ead290Smrg new_argv[i] = (char *) string; 6679e8ead290Smrg } 6680e8ead290Smrg new_argv[argc] = NULL; 6681e8ead290Smrg 6682e8ead290Smrg return new_argv; 6683e8ead290Smrg} 6684e8ead290SmrgEOF 6685e8ead290Smrg ;; 6686e8ead290Smrg esac 6687e8ead290Smrg 6688e8ead290Smrg cat <<"EOF" 6689e8ead290Smrgvoid lt_dump_script (FILE* f) 6690e8ead290Smrg{ 6691e8ead290SmrgEOF 6692e8ead290Smrg func_emit_wrapper yes | 6693e6d5e4e0Smrg $SED -n -e ' 6694e6d5e4e0Smrgs/^\(.\{79\}\)\(..*\)/\1\ 6695e6d5e4e0Smrg\2/ 6696e6d5e4e0Smrgh 6697e6d5e4e0Smrgs/\([\\"]\)/\\\1/g 6698e6d5e4e0Smrgs/$/\\n/ 6699e6d5e4e0Smrgs/\([^\n]*\).*/ fputs ("\1", f);/p 6700e6d5e4e0Smrgg 6701e6d5e4e0SmrgD' 6702e8ead290Smrg cat <<"EOF" 6703e8ead290Smrg} 6704e169010aSmrgEOF 6705e169010aSmrg} 6706e169010aSmrg# end: func_emit_cwrapperexe_src 67077914d74bSmrg 6708e8ead290Smrg# func_win32_import_lib_p ARG 6709e8ead290Smrg# True if ARG is an import lib, as indicated by $file_magic_cmd 6710e8ead290Smrgfunc_win32_import_lib_p () 6711e8ead290Smrg{ 67129d0ccd10Smrg $debug_cmd 67139d0ccd10Smrg 6714e8ead290Smrg case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in 6715e8ead290Smrg *import*) : ;; 6716e8ead290Smrg *) false ;; 6717e8ead290Smrg esac 6718e8ead290Smrg} 6719e8ead290Smrg 67209d0ccd10Smrg# func_suncc_cstd_abi 67219d0ccd10Smrg# !!ONLY CALL THIS FOR SUN CC AFTER $compile_command IS FULLY EXPANDED!! 67229d0ccd10Smrg# Several compiler flags select an ABI that is incompatible with the 67239d0ccd10Smrg# Cstd library. Avoid specifying it if any are in CXXFLAGS. 67249d0ccd10Smrgfunc_suncc_cstd_abi () 67259d0ccd10Smrg{ 67269d0ccd10Smrg $debug_cmd 67279d0ccd10Smrg 67289d0ccd10Smrg case " $compile_command " in 67299d0ccd10Smrg *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*) 67309d0ccd10Smrg suncc_use_cstd_abi=no 67319d0ccd10Smrg ;; 67329d0ccd10Smrg *) 67339d0ccd10Smrg suncc_use_cstd_abi=yes 67349d0ccd10Smrg ;; 67359d0ccd10Smrg esac 67369d0ccd10Smrg} 67379d0ccd10Smrg 6738e169010aSmrg# func_mode_link arg... 6739e169010aSmrgfunc_mode_link () 6740e169010aSmrg{ 67419d0ccd10Smrg $debug_cmd 67429d0ccd10Smrg 6743e169010aSmrg case $host in 6744e169010aSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 6745e169010aSmrg # It is impossible to link a dll without this setting, and 6746e169010aSmrg # we shouldn't force the makefile maintainer to figure out 67479d0ccd10Smrg # what system we are compiling for in order to pass an extra 6748e169010aSmrg # flag for every libtool invocation. 6749e169010aSmrg # allow_undefined=no 67507914d74bSmrg 6751e169010aSmrg # FIXME: Unfortunately, there are problems with the above when trying 67529d0ccd10Smrg # to make a dll that has undefined symbols, in which case not 6753e169010aSmrg # even a static library is built. For now, we need to specify 6754e169010aSmrg # -no-undefined on the libtool link line when we can be certain 6755e169010aSmrg # that all symbols are satisfied, otherwise we get a static library. 6756e169010aSmrg allow_undefined=yes 6757e169010aSmrg ;; 6758e169010aSmrg *) 6759e169010aSmrg allow_undefined=yes 6760e169010aSmrg ;; 6761e169010aSmrg esac 6762e169010aSmrg libtool_args=$nonopt 6763e169010aSmrg base_compile="$nonopt $@" 6764e169010aSmrg compile_command=$nonopt 6765e169010aSmrg finalize_command=$nonopt 67667914d74bSmrg 6767e169010aSmrg compile_rpath= 6768e169010aSmrg finalize_rpath= 6769e169010aSmrg compile_shlibpath= 6770e169010aSmrg finalize_shlibpath= 6771e169010aSmrg convenience= 6772e169010aSmrg old_convenience= 6773e169010aSmrg deplibs= 6774e169010aSmrg old_deplibs= 6775e169010aSmrg compiler_flags= 6776e169010aSmrg linker_flags= 6777e169010aSmrg dllsearchpath= 6778e169010aSmrg lib_search_path=`pwd` 6779e169010aSmrg inst_prefix_dir= 6780e169010aSmrg new_inherited_linker_flags= 67817914d74bSmrg 6782e169010aSmrg avoid_version=no 6783e8ead290Smrg bindir= 6784e169010aSmrg dlfiles= 6785e169010aSmrg dlprefiles= 6786e169010aSmrg dlself=no 6787e169010aSmrg export_dynamic=no 6788e169010aSmrg export_symbols= 6789e169010aSmrg export_symbols_regex= 6790e169010aSmrg generated= 6791e169010aSmrg libobjs= 6792e169010aSmrg ltlibs= 6793e169010aSmrg module=no 6794e169010aSmrg no_install=no 6795e169010aSmrg objs= 67969d0ccd10Smrg os2dllname= 6797e169010aSmrg non_pic_objects= 6798e169010aSmrg precious_files_regex= 6799e169010aSmrg prefer_static_libs=no 68009d0ccd10Smrg preload=false 6801e169010aSmrg prev= 6802e169010aSmrg prevarg= 6803e169010aSmrg release= 6804e169010aSmrg rpath= 6805e169010aSmrg xrpath= 6806e169010aSmrg perm_rpath= 6807e169010aSmrg temp_rpath= 6808e169010aSmrg thread_safe=no 6809e169010aSmrg vinfo= 6810e169010aSmrg vinfo_number=no 6811e169010aSmrg weak_libs= 68129d0ccd10Smrg single_module=$wl-single_module 6813e169010aSmrg func_infer_tag $base_compile 68147914d74bSmrg 6815e169010aSmrg # We need to know -static, to get the right output filenames. 6816e169010aSmrg for arg 6817e169010aSmrg do 6818e169010aSmrg case $arg in 6819e169010aSmrg -shared) 68209d0ccd10Smrg test yes != "$build_libtool_libs" \ 68219d0ccd10Smrg && func_fatal_configuration "cannot build a shared library" 6822e169010aSmrg build_old_libs=no 6823e169010aSmrg break 6824e169010aSmrg ;; 6825e169010aSmrg -all-static | -static | -static-libtool-libs) 6826e169010aSmrg case $arg in 6827e169010aSmrg -all-static) 68289d0ccd10Smrg if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then 6829e169010aSmrg func_warning "complete static linking is impossible in this configuration" 68307914d74bSmrg fi 6831e169010aSmrg if test -n "$link_static_flag"; then 6832e169010aSmrg dlopen_self=$dlopen_self_static 68337914d74bSmrg fi 6834e169010aSmrg prefer_static_libs=yes 68357914d74bSmrg ;; 6836e169010aSmrg -static) 6837e169010aSmrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 6838e169010aSmrg dlopen_self=$dlopen_self_static 6839e169010aSmrg fi 6840e169010aSmrg prefer_static_libs=built 6841e169010aSmrg ;; 6842e169010aSmrg -static-libtool-libs) 6843e169010aSmrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 6844e169010aSmrg dlopen_self=$dlopen_self_static 6845e169010aSmrg fi 6846e169010aSmrg prefer_static_libs=yes 68477914d74bSmrg ;; 68487914d74bSmrg esac 6849e169010aSmrg build_libtool_libs=no 6850e169010aSmrg build_old_libs=yes 6851e169010aSmrg break 6852e169010aSmrg ;; 6853e169010aSmrg esac 6854e169010aSmrg done 68557914d74bSmrg 6856e169010aSmrg # See if our shared archives depend on static archives. 6857e169010aSmrg test -n "$old_archive_from_new_cmds" && build_old_libs=yes 68587914d74bSmrg 6859e169010aSmrg # Go through the arguments, transforming them on the way. 6860e169010aSmrg while test "$#" -gt 0; do 68619d0ccd10Smrg arg=$1 6862e169010aSmrg shift 68630ea508b1Smrg func_quote_arg pretty,unquoted "$arg" 68640ea508b1Smrg qarg=$func_quote_arg_unquoted_result 68650ea508b1Smrg func_append libtool_args " $func_quote_arg_result" 68667914d74bSmrg 6867e169010aSmrg # If the previous option needs an argument, assign it. 6868e169010aSmrg if test -n "$prev"; then 6869e169010aSmrg case $prev in 6870e169010aSmrg output) 6871e169010aSmrg func_append compile_command " @OUTPUT@" 6872e169010aSmrg func_append finalize_command " @OUTPUT@" 6873e169010aSmrg ;; 6874e169010aSmrg esac 68757914d74bSmrg 6876e169010aSmrg case $prev in 6877e8ead290Smrg bindir) 68789d0ccd10Smrg bindir=$arg 6879e8ead290Smrg prev= 6880e8ead290Smrg continue 6881e8ead290Smrg ;; 6882e169010aSmrg dlfiles|dlprefiles) 68839d0ccd10Smrg $preload || { 6884e169010aSmrg # Add the symbol object into the linking commands. 6885e169010aSmrg func_append compile_command " @SYMFILE@" 6886e169010aSmrg func_append finalize_command " @SYMFILE@" 68879d0ccd10Smrg preload=: 68889d0ccd10Smrg } 6889e169010aSmrg case $arg in 6890e169010aSmrg *.la | *.lo) ;; # We handle these cases below. 6891e169010aSmrg force) 68929d0ccd10Smrg if test no = "$dlself"; then 6893e169010aSmrg dlself=needless 6894e169010aSmrg export_dynamic=yes 6895e169010aSmrg fi 6896e169010aSmrg prev= 6897e169010aSmrg continue 6898e169010aSmrg ;; 6899e169010aSmrg self) 69009d0ccd10Smrg if test dlprefiles = "$prev"; then 6901e169010aSmrg dlself=yes 69029d0ccd10Smrg elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then 6903e169010aSmrg dlself=yes 6904e169010aSmrg else 6905e169010aSmrg dlself=needless 6906e169010aSmrg export_dynamic=yes 6907e169010aSmrg fi 6908e169010aSmrg prev= 6909e169010aSmrg continue 69107914d74bSmrg ;; 69117914d74bSmrg *) 69129d0ccd10Smrg if test dlfiles = "$prev"; then 6913c63293b5Smrg func_append dlfiles " $arg" 6914e169010aSmrg else 6915c63293b5Smrg func_append dlprefiles " $arg" 6916e169010aSmrg fi 6917e169010aSmrg prev= 6918e169010aSmrg continue 69197914d74bSmrg ;; 69207914d74bSmrg esac 6921e169010aSmrg ;; 6922e169010aSmrg expsyms) 69239d0ccd10Smrg export_symbols=$arg 6924e169010aSmrg test -f "$arg" \ 69259d0ccd10Smrg || func_fatal_error "symbol file '$arg' does not exist" 6926e169010aSmrg prev= 6927e169010aSmrg continue 6928e169010aSmrg ;; 6929e169010aSmrg expsyms_regex) 69309d0ccd10Smrg export_symbols_regex=$arg 6931e169010aSmrg prev= 6932e169010aSmrg continue 6933e169010aSmrg ;; 6934e169010aSmrg framework) 6935e169010aSmrg case $host in 6936e169010aSmrg *-*-darwin*) 6937e169010aSmrg case "$deplibs " in 6938e169010aSmrg *" $qarg.ltframework "*) ;; 6939c63293b5Smrg *) func_append deplibs " $qarg.ltframework" # this is fixed later 6940e169010aSmrg ;; 6941e169010aSmrg esac 6942e169010aSmrg ;; 6943e169010aSmrg esac 6944e169010aSmrg prev= 6945e169010aSmrg continue 6946e169010aSmrg ;; 6947e169010aSmrg inst_prefix) 69489d0ccd10Smrg inst_prefix_dir=$arg 69499d0ccd10Smrg prev= 69509d0ccd10Smrg continue 69519d0ccd10Smrg ;; 69529d0ccd10Smrg mllvm) 69539d0ccd10Smrg # Clang does not use LLVM to link, so we can simply discard any 69549d0ccd10Smrg # '-mllvm $arg' options when doing the link step. 6955e169010aSmrg prev= 6956e169010aSmrg continue 6957e169010aSmrg ;; 6958e169010aSmrg objectlist) 6959e169010aSmrg if test -f "$arg"; then 6960e169010aSmrg save_arg=$arg 6961e169010aSmrg moreargs= 6962e169010aSmrg for fil in `cat "$save_arg"` 6963e169010aSmrg do 6964c63293b5Smrg# func_append moreargs " $fil" 6965e169010aSmrg arg=$fil 6966e169010aSmrg # A libtool-controlled object. 69677914d74bSmrg 6968e169010aSmrg # Check to see that this really is a libtool object. 6969e169010aSmrg if func_lalib_unsafe_p "$arg"; then 6970e169010aSmrg pic_object= 6971e169010aSmrg non_pic_object= 69727914d74bSmrg 6973e169010aSmrg # Read the .lo file 6974e169010aSmrg func_source "$arg" 69757914d74bSmrg 6976e169010aSmrg if test -z "$pic_object" || 6977e169010aSmrg test -z "$non_pic_object" || 69789d0ccd10Smrg test none = "$pic_object" && 69799d0ccd10Smrg test none = "$non_pic_object"; then 69809d0ccd10Smrg func_fatal_error "cannot find name of object for '$arg'" 6981e169010aSmrg fi 69827914d74bSmrg 6983e169010aSmrg # Extract subdirectory from the argument. 6984e169010aSmrg func_dirname "$arg" "/" "" 69859d0ccd10Smrg xdir=$func_dirname_result 69867914d74bSmrg 69879d0ccd10Smrg if test none != "$pic_object"; then 6988e169010aSmrg # Prepend the subdirectory the object is found in. 69899d0ccd10Smrg pic_object=$xdir$pic_object 69907914d74bSmrg 69919d0ccd10Smrg if test dlfiles = "$prev"; then 69929d0ccd10Smrg if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 6993c63293b5Smrg func_append dlfiles " $pic_object" 6994e169010aSmrg prev= 6995e169010aSmrg continue 6996e169010aSmrg else 6997e169010aSmrg # If libtool objects are unsupported, then we need to preload. 6998e169010aSmrg prev=dlprefiles 6999e169010aSmrg fi 7000e169010aSmrg fi 70017914d74bSmrg 7002e169010aSmrg # CHECK ME: I think I busted this. -Ossama 70039d0ccd10Smrg if test dlprefiles = "$prev"; then 7004e169010aSmrg # Preload the old-style object. 7005c63293b5Smrg func_append dlprefiles " $pic_object" 7006e169010aSmrg prev= 7007e169010aSmrg fi 70087914d74bSmrg 7009e169010aSmrg # A PIC object. 7010e169010aSmrg func_append libobjs " $pic_object" 70119d0ccd10Smrg arg=$pic_object 7012e169010aSmrg fi 70137914d74bSmrg 7014e169010aSmrg # Non-PIC object. 70159d0ccd10Smrg if test none != "$non_pic_object"; then 7016e169010aSmrg # Prepend the subdirectory the object is found in. 70179d0ccd10Smrg non_pic_object=$xdir$non_pic_object 70187914d74bSmrg 7019e169010aSmrg # A standard non-PIC object 7020e169010aSmrg func_append non_pic_objects " $non_pic_object" 70219d0ccd10Smrg if test -z "$pic_object" || test none = "$pic_object"; then 70229d0ccd10Smrg arg=$non_pic_object 7023e169010aSmrg fi 7024e169010aSmrg else 7025e169010aSmrg # If the PIC object exists, use it instead. 7026e169010aSmrg # $xdir was prepended to $pic_object above. 70279d0ccd10Smrg non_pic_object=$pic_object 7028e169010aSmrg func_append non_pic_objects " $non_pic_object" 7029e169010aSmrg fi 7030e169010aSmrg else 7031e169010aSmrg # Only an error if not doing a dry-run. 7032e169010aSmrg if $opt_dry_run; then 7033e169010aSmrg # Extract subdirectory from the argument. 7034e169010aSmrg func_dirname "$arg" "/" "" 70359d0ccd10Smrg xdir=$func_dirname_result 7036e169010aSmrg 7037e169010aSmrg func_lo2o "$arg" 7038e169010aSmrg pic_object=$xdir$objdir/$func_lo2o_result 7039e169010aSmrg non_pic_object=$xdir$func_lo2o_result 7040e169010aSmrg func_append libobjs " $pic_object" 7041e169010aSmrg func_append non_pic_objects " $non_pic_object" 7042e169010aSmrg else 70439d0ccd10Smrg func_fatal_error "'$arg' is not a valid libtool object" 7044e169010aSmrg fi 7045e169010aSmrg fi 7046e169010aSmrg done 7047e169010aSmrg else 70489d0ccd10Smrg func_fatal_error "link input file '$arg' does not exist" 7049e169010aSmrg fi 7050e169010aSmrg arg=$save_arg 7051e169010aSmrg prev= 7052e169010aSmrg continue 7053e169010aSmrg ;; 70549d0ccd10Smrg os2dllname) 70559d0ccd10Smrg os2dllname=$arg 70569d0ccd10Smrg prev= 70579d0ccd10Smrg continue 70589d0ccd10Smrg ;; 7059e169010aSmrg precious_regex) 70609d0ccd10Smrg precious_files_regex=$arg 7061e169010aSmrg prev= 7062e169010aSmrg continue 7063e169010aSmrg ;; 7064e169010aSmrg release) 70659d0ccd10Smrg release=-$arg 7066e169010aSmrg prev= 7067e169010aSmrg continue 7068e169010aSmrg ;; 7069e169010aSmrg rpath | xrpath) 7070e169010aSmrg # We need an absolute path. 7071e169010aSmrg case $arg in 7072e169010aSmrg [\\/]* | [A-Za-z]:[\\/]*) ;; 7073e169010aSmrg *) 7074e169010aSmrg func_fatal_error "only absolute run-paths are allowed" 7075e169010aSmrg ;; 7076e169010aSmrg esac 70779d0ccd10Smrg if test rpath = "$prev"; then 7078e169010aSmrg case "$rpath " in 7079e169010aSmrg *" $arg "*) ;; 7080c63293b5Smrg *) func_append rpath " $arg" ;; 7081e169010aSmrg esac 7082e169010aSmrg else 7083e169010aSmrg case "$xrpath " in 7084e169010aSmrg *" $arg "*) ;; 7085c63293b5Smrg *) func_append xrpath " $arg" ;; 7086e169010aSmrg esac 7087e169010aSmrg fi 7088e169010aSmrg prev= 7089e169010aSmrg continue 7090e169010aSmrg ;; 7091e169010aSmrg shrext) 70929d0ccd10Smrg shrext_cmds=$arg 7093e169010aSmrg prev= 7094e169010aSmrg continue 7095e169010aSmrg ;; 7096e169010aSmrg weak) 7097c63293b5Smrg func_append weak_libs " $arg" 7098e169010aSmrg prev= 7099e169010aSmrg continue 7100e169010aSmrg ;; 71010ea508b1Smrg xassembler) 71020ea508b1Smrg func_append compiler_flags " -Xassembler $qarg" 71030ea508b1Smrg prev= 71040ea508b1Smrg func_append compile_command " -Xassembler $qarg" 71050ea508b1Smrg func_append finalize_command " -Xassembler $qarg" 71060ea508b1Smrg continue 71070ea508b1Smrg ;; 7108e169010aSmrg xcclinker) 7109c63293b5Smrg func_append linker_flags " $qarg" 7110c63293b5Smrg func_append compiler_flags " $qarg" 7111e169010aSmrg prev= 7112e169010aSmrg func_append compile_command " $qarg" 7113e169010aSmrg func_append finalize_command " $qarg" 7114e169010aSmrg continue 7115e169010aSmrg ;; 7116e169010aSmrg xcompiler) 7117c63293b5Smrg func_append compiler_flags " $qarg" 7118e169010aSmrg prev= 7119e169010aSmrg func_append compile_command " $qarg" 7120e169010aSmrg func_append finalize_command " $qarg" 7121e169010aSmrg continue 7122e169010aSmrg ;; 7123e169010aSmrg xlinker) 7124c63293b5Smrg func_append linker_flags " $qarg" 7125c63293b5Smrg func_append compiler_flags " $wl$qarg" 7126e169010aSmrg prev= 7127e169010aSmrg func_append compile_command " $wl$qarg" 7128e169010aSmrg func_append finalize_command " $wl$qarg" 7129e169010aSmrg continue 7130e169010aSmrg ;; 7131e169010aSmrg *) 7132e169010aSmrg eval "$prev=\"\$arg\"" 7133e169010aSmrg prev= 7134e169010aSmrg continue 7135e169010aSmrg ;; 71367914d74bSmrg esac 7137e169010aSmrg fi # test -n "$prev" 71387914d74bSmrg 71399d0ccd10Smrg prevarg=$arg 71407914d74bSmrg 7141e169010aSmrg case $arg in 7142e169010aSmrg -all-static) 7143e169010aSmrg if test -n "$link_static_flag"; then 7144e169010aSmrg # See comment for -static flag below, for more details. 7145e169010aSmrg func_append compile_command " $link_static_flag" 7146e169010aSmrg func_append finalize_command " $link_static_flag" 7147e169010aSmrg fi 7148e169010aSmrg continue 7149e169010aSmrg ;; 71507914d74bSmrg 7151e169010aSmrg -allow-undefined) 7152e169010aSmrg # FIXME: remove this flag sometime in the future. 71539d0ccd10Smrg func_fatal_error "'-allow-undefined' must not be used because it is the default" 7154e169010aSmrg ;; 71557914d74bSmrg 7156e169010aSmrg -avoid-version) 7157e169010aSmrg avoid_version=yes 7158e169010aSmrg continue 7159e169010aSmrg ;; 71607914d74bSmrg 7161e8ead290Smrg -bindir) 7162e8ead290Smrg prev=bindir 7163e8ead290Smrg continue 7164e8ead290Smrg ;; 7165e8ead290Smrg 7166e169010aSmrg -dlopen) 7167e169010aSmrg prev=dlfiles 7168e169010aSmrg continue 7169e169010aSmrg ;; 71707914d74bSmrg 7171e169010aSmrg -dlpreopen) 7172e169010aSmrg prev=dlprefiles 7173e169010aSmrg continue 7174e169010aSmrg ;; 71757914d74bSmrg 7176e169010aSmrg -export-dynamic) 7177e169010aSmrg export_dynamic=yes 7178e169010aSmrg continue 7179e169010aSmrg ;; 71807914d74bSmrg 7181e169010aSmrg -export-symbols | -export-symbols-regex) 7182e169010aSmrg if test -n "$export_symbols" || test -n "$export_symbols_regex"; then 7183e169010aSmrg func_fatal_error "more than one -exported-symbols argument is not allowed" 7184e169010aSmrg fi 71859d0ccd10Smrg if test X-export-symbols = "X$arg"; then 7186e169010aSmrg prev=expsyms 7187e169010aSmrg else 7188e169010aSmrg prev=expsyms_regex 7189e169010aSmrg fi 7190e169010aSmrg continue 7191e169010aSmrg ;; 71927914d74bSmrg 7193e169010aSmrg -framework) 7194e169010aSmrg prev=framework 7195e169010aSmrg continue 7196e169010aSmrg ;; 71977914d74bSmrg 7198e169010aSmrg -inst-prefix-dir) 7199e169010aSmrg prev=inst_prefix 7200e169010aSmrg continue 7201e169010aSmrg ;; 72027914d74bSmrg 7203e169010aSmrg # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* 7204e169010aSmrg # so, if we see these flags be careful not to treat them like -L 7205e169010aSmrg -L[A-Z][A-Z]*:*) 7206e169010aSmrg case $with_gcc/$host in 7207e169010aSmrg no/*-*-irix* | /*-*-irix*) 7208e169010aSmrg func_append compile_command " $arg" 7209e169010aSmrg func_append finalize_command " $arg" 7210e169010aSmrg ;; 7211e169010aSmrg esac 7212e169010aSmrg continue 7213e169010aSmrg ;; 72147914d74bSmrg 7215e169010aSmrg -L*) 7216c63293b5Smrg func_stripname "-L" '' "$arg" 7217c63293b5Smrg if test -z "$func_stripname_result"; then 7218e169010aSmrg if test "$#" -gt 0; then 72199d0ccd10Smrg func_fatal_error "require no space between '-L' and '$1'" 7220e169010aSmrg else 72219d0ccd10Smrg func_fatal_error "need path for '-L' option" 7222e169010aSmrg fi 7223e169010aSmrg fi 7224c63293b5Smrg func_resolve_sysroot "$func_stripname_result" 7225c63293b5Smrg dir=$func_resolve_sysroot_result 7226e169010aSmrg # We need an absolute path. 7227e169010aSmrg case $dir in 7228e169010aSmrg [\\/]* | [A-Za-z]:[\\/]*) ;; 7229e169010aSmrg *) 7230e169010aSmrg absdir=`cd "$dir" && pwd` 7231e169010aSmrg test -z "$absdir" && \ 72329d0ccd10Smrg func_fatal_error "cannot determine absolute directory name of '$dir'" 72339d0ccd10Smrg dir=$absdir 7234e169010aSmrg ;; 7235e169010aSmrg esac 7236e169010aSmrg case "$deplibs " in 7237c63293b5Smrg *" -L$dir "* | *" $arg "*) 7238c63293b5Smrg # Will only happen for absolute or sysroot arguments 7239c63293b5Smrg ;; 7240e169010aSmrg *) 7241c63293b5Smrg # Preserve sysroot, but never include relative directories 7242c63293b5Smrg case $dir in 7243c63293b5Smrg [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; 7244c63293b5Smrg *) func_append deplibs " -L$dir" ;; 7245c63293b5Smrg esac 7246c63293b5Smrg func_append lib_search_path " $dir" 7247e169010aSmrg ;; 7248e169010aSmrg esac 7249e169010aSmrg case $host in 7250e169010aSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 7251e8ead290Smrg testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` 7252e169010aSmrg case :$dllsearchpath: in 7253e169010aSmrg *":$dir:"*) ;; 7254e169010aSmrg ::) dllsearchpath=$dir;; 7255c63293b5Smrg *) func_append dllsearchpath ":$dir";; 7256e169010aSmrg esac 7257e169010aSmrg case :$dllsearchpath: in 7258e169010aSmrg *":$testbindir:"*) ;; 7259e169010aSmrg ::) dllsearchpath=$testbindir;; 7260c63293b5Smrg *) func_append dllsearchpath ":$testbindir";; 7261e169010aSmrg esac 7262e169010aSmrg ;; 7263e169010aSmrg esac 7264e169010aSmrg continue 7265e169010aSmrg ;; 72667914d74bSmrg 7267e169010aSmrg -l*) 72689d0ccd10Smrg if test X-lc = "X$arg" || test X-lm = "X$arg"; then 7269e169010aSmrg case $host in 7270e8ead290Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) 7271e169010aSmrg # These systems don't actually have a C or math library (as such) 7272e169010aSmrg continue 7273e169010aSmrg ;; 7274e169010aSmrg *-*-os2*) 7275e169010aSmrg # These systems don't actually have a C library (as such) 72769d0ccd10Smrg test X-lc = "X$arg" && continue 7277e169010aSmrg ;; 72780ea508b1Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig* | *-*-midnightbsd*) 7279e169010aSmrg # Do not include libc due to us having libc/libc_r. 72809d0ccd10Smrg test X-lc = "X$arg" && continue 7281e169010aSmrg ;; 7282e169010aSmrg *-*-rhapsody* | *-*-darwin1.[012]) 7283e169010aSmrg # Rhapsody C and math libraries are in the System framework 7284c63293b5Smrg func_append deplibs " System.ltframework" 7285e169010aSmrg continue 7286e169010aSmrg ;; 7287e169010aSmrg *-*-sco3.2v5* | *-*-sco5v6*) 7288e169010aSmrg # Causes problems with __ctype 72899d0ccd10Smrg test X-lc = "X$arg" && continue 7290e169010aSmrg ;; 7291e169010aSmrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 7292e169010aSmrg # Compiler inserts libc in the correct place for threads to work 72939d0ccd10Smrg test X-lc = "X$arg" && continue 7294e169010aSmrg ;; 7295e169010aSmrg esac 72969d0ccd10Smrg elif test X-lc_r = "X$arg"; then 7297e169010aSmrg case $host in 72980ea508b1Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig* | *-*-midnightbsd*) 7299e169010aSmrg # Do not include libc_r directly, use -pthread flag. 7300e169010aSmrg continue 7301e169010aSmrg ;; 7302e169010aSmrg esac 7303e169010aSmrg fi 7304c63293b5Smrg func_append deplibs " $arg" 7305e169010aSmrg continue 7306e169010aSmrg ;; 73077914d74bSmrg 73089d0ccd10Smrg -mllvm) 73099d0ccd10Smrg prev=mllvm 73109d0ccd10Smrg continue 73119d0ccd10Smrg ;; 73129d0ccd10Smrg 7313e169010aSmrg -module) 7314e169010aSmrg module=yes 7315e169010aSmrg continue 7316e169010aSmrg ;; 73177914d74bSmrg 7318e169010aSmrg # Tru64 UNIX uses -model [arg] to determine the layout of C++ 7319e169010aSmrg # classes, name mangling, and exception handling. 7320e169010aSmrg # Darwin uses the -arch flag to determine output architecture. 7321c63293b5Smrg -model|-arch|-isysroot|--sysroot) 7322c63293b5Smrg func_append compiler_flags " $arg" 7323e169010aSmrg func_append compile_command " $arg" 7324e169010aSmrg func_append finalize_command " $arg" 7325e169010aSmrg prev=xcompiler 7326e169010aSmrg continue 7327e169010aSmrg ;; 73280ea508b1Smrg # Solaris ld rejects as of 11.4. Refer to Oracle bug 22985199. 73290ea508b1Smrg -pthread) 73300ea508b1Smrg case $host in 73310ea508b1Smrg *solaris2*) ;; 73320ea508b1Smrg *) 73330ea508b1Smrg case "$new_inherited_linker_flags " in 73340ea508b1Smrg *" $arg "*) ;; 73350ea508b1Smrg * ) func_append new_inherited_linker_flags " $arg" ;; 73360ea508b1Smrg esac 73370ea508b1Smrg ;; 73380ea508b1Smrg esac 73390ea508b1Smrg continue 73400ea508b1Smrg ;; 73410ea508b1Smrg -mt|-mthreads|-kthread|-Kthread|-pthreads|--thread-safe \ 7342e6d5e4e0Smrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 7343c63293b5Smrg func_append compiler_flags " $arg" 7344e169010aSmrg func_append compile_command " $arg" 7345e169010aSmrg func_append finalize_command " $arg" 7346e169010aSmrg case "$new_inherited_linker_flags " in 7347e169010aSmrg *" $arg "*) ;; 7348c63293b5Smrg * ) func_append new_inherited_linker_flags " $arg" ;; 7349e169010aSmrg esac 7350e169010aSmrg continue 7351e169010aSmrg ;; 73527914d74bSmrg 7353e169010aSmrg -multi_module) 73549d0ccd10Smrg single_module=$wl-multi_module 7355e169010aSmrg continue 7356e169010aSmrg ;; 73577914d74bSmrg 7358e169010aSmrg -no-fast-install) 7359e169010aSmrg fast_install=no 7360e169010aSmrg continue 7361e169010aSmrg ;; 73627914d74bSmrg 7363e169010aSmrg -no-install) 7364e169010aSmrg case $host in 7365e169010aSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) 7366e169010aSmrg # The PATH hackery in wrapper scripts is required on Windows 7367e169010aSmrg # and Darwin in order for the loader to find any dlls it needs. 73689d0ccd10Smrg func_warning "'-no-install' is ignored for $host" 73699d0ccd10Smrg func_warning "assuming '-no-fast-install' instead" 7370e169010aSmrg fast_install=no 7371e169010aSmrg ;; 7372e169010aSmrg *) no_install=yes ;; 7373e169010aSmrg esac 7374e169010aSmrg continue 7375e169010aSmrg ;; 73767914d74bSmrg 7377e169010aSmrg -no-undefined) 7378e169010aSmrg allow_undefined=no 7379e169010aSmrg continue 7380e169010aSmrg ;; 73817914d74bSmrg 7382e169010aSmrg -objectlist) 7383e169010aSmrg prev=objectlist 7384e169010aSmrg continue 7385e169010aSmrg ;; 73867914d74bSmrg 73879d0ccd10Smrg -os2dllname) 73889d0ccd10Smrg prev=os2dllname 73899d0ccd10Smrg continue 73909d0ccd10Smrg ;; 73919d0ccd10Smrg 7392e169010aSmrg -o) prev=output ;; 73937914d74bSmrg 7394e169010aSmrg -precious-files-regex) 7395e169010aSmrg prev=precious_regex 7396e169010aSmrg continue 7397e169010aSmrg ;; 73987914d74bSmrg 7399e169010aSmrg -release) 7400e169010aSmrg prev=release 7401e169010aSmrg continue 7402e169010aSmrg ;; 74037914d74bSmrg 7404e169010aSmrg -rpath) 7405e169010aSmrg prev=rpath 7406e169010aSmrg continue 7407e169010aSmrg ;; 74087914d74bSmrg 7409e169010aSmrg -R) 7410e169010aSmrg prev=xrpath 7411e169010aSmrg continue 7412e169010aSmrg ;; 74137914d74bSmrg 7414e169010aSmrg -R*) 7415e169010aSmrg func_stripname '-R' '' "$arg" 7416e169010aSmrg dir=$func_stripname_result 7417e169010aSmrg # We need an absolute path. 7418e169010aSmrg case $dir in 7419e169010aSmrg [\\/]* | [A-Za-z]:[\\/]*) ;; 7420c63293b5Smrg =*) 7421c63293b5Smrg func_stripname '=' '' "$dir" 7422c63293b5Smrg dir=$lt_sysroot$func_stripname_result 7423c63293b5Smrg ;; 7424e169010aSmrg *) 7425e169010aSmrg func_fatal_error "only absolute run-paths are allowed" 7426e169010aSmrg ;; 7427e169010aSmrg esac 7428e169010aSmrg case "$xrpath " in 7429e169010aSmrg *" $dir "*) ;; 7430c63293b5Smrg *) func_append xrpath " $dir" ;; 7431e169010aSmrg esac 7432e169010aSmrg continue 7433e169010aSmrg ;; 74347914d74bSmrg 7435e169010aSmrg -shared) 7436e169010aSmrg # The effects of -shared are defined in a previous loop. 7437e169010aSmrg continue 7438e169010aSmrg ;; 74397914d74bSmrg 7440e169010aSmrg -shrext) 7441e169010aSmrg prev=shrext 7442e169010aSmrg continue 7443e169010aSmrg ;; 74447914d74bSmrg 7445e169010aSmrg -static | -static-libtool-libs) 7446e169010aSmrg # The effects of -static are defined in a previous loop. 7447e169010aSmrg # We used to do the same as -all-static on platforms that 7448e169010aSmrg # didn't have a PIC flag, but the assumption that the effects 7449e169010aSmrg # would be equivalent was wrong. It would break on at least 7450e169010aSmrg # Digital Unix and AIX. 7451e169010aSmrg continue 7452e169010aSmrg ;; 74537914d74bSmrg 7454e169010aSmrg -thread-safe) 7455e169010aSmrg thread_safe=yes 7456e169010aSmrg continue 7457e169010aSmrg ;; 74587914d74bSmrg 7459e169010aSmrg -version-info) 7460e169010aSmrg prev=vinfo 7461e169010aSmrg continue 7462e169010aSmrg ;; 74637914d74bSmrg 7464e169010aSmrg -version-number) 7465e169010aSmrg prev=vinfo 7466e169010aSmrg vinfo_number=yes 7467e169010aSmrg continue 7468e169010aSmrg ;; 74697914d74bSmrg 7470e169010aSmrg -weak) 7471e169010aSmrg prev=weak 7472e169010aSmrg continue 7473e169010aSmrg ;; 74747914d74bSmrg 7475e169010aSmrg -Wc,*) 7476e169010aSmrg func_stripname '-Wc,' '' "$arg" 7477e169010aSmrg args=$func_stripname_result 7478e169010aSmrg arg= 74799d0ccd10Smrg save_ifs=$IFS; IFS=, 7480e169010aSmrg for flag in $args; do 74819d0ccd10Smrg IFS=$save_ifs 74820ea508b1Smrg func_quote_arg pretty "$flag" 74830ea508b1Smrg func_append arg " $func_quote_arg_result" 74840ea508b1Smrg func_append compiler_flags " $func_quote_arg_result" 7485e169010aSmrg done 74869d0ccd10Smrg IFS=$save_ifs 7487e169010aSmrg func_stripname ' ' '' "$arg" 7488e169010aSmrg arg=$func_stripname_result 7489e169010aSmrg ;; 74907914d74bSmrg 7491e169010aSmrg -Wl,*) 7492e169010aSmrg func_stripname '-Wl,' '' "$arg" 7493e169010aSmrg args=$func_stripname_result 7494e169010aSmrg arg= 74959d0ccd10Smrg save_ifs=$IFS; IFS=, 7496e169010aSmrg for flag in $args; do 74979d0ccd10Smrg IFS=$save_ifs 74980ea508b1Smrg func_quote_arg pretty "$flag" 74990ea508b1Smrg func_append arg " $wl$func_quote_arg_result" 75000ea508b1Smrg func_append compiler_flags " $wl$func_quote_arg_result" 75010ea508b1Smrg func_append linker_flags " $func_quote_arg_result" 7502e169010aSmrg done 75039d0ccd10Smrg IFS=$save_ifs 7504e169010aSmrg func_stripname ' ' '' "$arg" 7505e169010aSmrg arg=$func_stripname_result 7506e169010aSmrg ;; 75077914d74bSmrg 75080ea508b1Smrg -Xassembler) 75090ea508b1Smrg prev=xassembler 75100ea508b1Smrg continue 75110ea508b1Smrg ;; 75120ea508b1Smrg 7513e169010aSmrg -Xcompiler) 7514e169010aSmrg prev=xcompiler 7515e169010aSmrg continue 7516e169010aSmrg ;; 75177914d74bSmrg 7518e169010aSmrg -Xlinker) 7519e169010aSmrg prev=xlinker 7520e169010aSmrg continue 7521e169010aSmrg ;; 75227914d74bSmrg 7523e169010aSmrg -XCClinker) 7524e169010aSmrg prev=xcclinker 7525e169010aSmrg continue 7526e169010aSmrg ;; 75277914d74bSmrg 7528e169010aSmrg # -msg_* for osf cc 7529e169010aSmrg -msg_*) 75300ea508b1Smrg func_quote_arg pretty "$arg" 75310ea508b1Smrg arg=$func_quote_arg_result 7532e169010aSmrg ;; 75337914d74bSmrg 7534e8ead290Smrg # Flags to be passed through unchanged, with rationale: 7535e8ead290Smrg # -64, -mips[0-9] enable 64-bit mode for the SGI compiler 7536e8ead290Smrg # -r[0-9][0-9]* specify processor for the SGI compiler 7537e8ead290Smrg # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler 7538e8ead290Smrg # +DA*, +DD* enable 64-bit mode for the HP compiler 7539e8ead290Smrg # -q* compiler args for the IBM compiler 7540e8ead290Smrg # -m*, -t[45]*, -txscale* architecture-specific flags for GCC 7541e8ead290Smrg # -F/path path to uninstalled frameworks, gcc on darwin 7542e8ead290Smrg # -p, -pg, --coverage, -fprofile-* profiling flags for GCC 75439d0ccd10Smrg # -fstack-protector* stack protector flags for GCC 7544e8ead290Smrg # @file GCC response files 7545e8ead290Smrg # -tp=* Portland pgcc target processor selection 7546c63293b5Smrg # --sysroot=* for sysroot support 75479d0ccd10Smrg # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization 75480ea508b1Smrg # -specs=* GCC specs files 75499d0ccd10Smrg # -stdlib=* select c++ std lib with clang 75500ea508b1Smrg # -fsanitize=* Clang/GCC memory and address sanitizer 75510ea508b1Smrg # -fuse-ld=* Linker select flags for GCC 75526b7436aeSmrg # -static-* direct GCC to link specific libraries statically 75536b7436aeSmrg # -fcilkplus Cilk Plus language extension features for C/C++ 75540ea508b1Smrg # -Wa,* Pass flags directly to the assembler 7555e169010aSmrg -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ 7556c63293b5Smrg -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ 75570ea508b1Smrg -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*| \ 75586b7436aeSmrg -specs=*|-fsanitize=*|-fuse-ld=*|-static-*|-fcilkplus|-Wa,*) 75590ea508b1Smrg func_quote_arg pretty "$arg" 75600ea508b1Smrg arg=$func_quote_arg_result 7561e169010aSmrg func_append compile_command " $arg" 7562e169010aSmrg func_append finalize_command " $arg" 7563c63293b5Smrg func_append compiler_flags " $arg" 7564e169010aSmrg continue 7565e169010aSmrg ;; 75667914d74bSmrg 75679d0ccd10Smrg -Z*) 75689d0ccd10Smrg if test os2 = "`expr $host : '.*\(os2\)'`"; then 75699d0ccd10Smrg # OS/2 uses -Zxxx to specify OS/2-specific options 75709d0ccd10Smrg compiler_flags="$compiler_flags $arg" 75719d0ccd10Smrg func_append compile_command " $arg" 75729d0ccd10Smrg func_append finalize_command " $arg" 75739d0ccd10Smrg case $arg in 75749d0ccd10Smrg -Zlinker | -Zstack) 75759d0ccd10Smrg prev=xcompiler 75769d0ccd10Smrg ;; 75779d0ccd10Smrg esac 75789d0ccd10Smrg continue 75799d0ccd10Smrg else 75809d0ccd10Smrg # Otherwise treat like 'Some other compiler flag' below 75810ea508b1Smrg func_quote_arg pretty "$arg" 75820ea508b1Smrg arg=$func_quote_arg_result 75839d0ccd10Smrg fi 75849d0ccd10Smrg ;; 75859d0ccd10Smrg 7586e169010aSmrg # Some other compiler flag. 7587e169010aSmrg -* | +*) 75880ea508b1Smrg func_quote_arg pretty "$arg" 75890ea508b1Smrg arg=$func_quote_arg_result 7590e169010aSmrg ;; 75917914d74bSmrg 7592e169010aSmrg *.$objext) 7593e169010aSmrg # A standard object. 7594c63293b5Smrg func_append objs " $arg" 7595e169010aSmrg ;; 7596e169010aSmrg 7597e169010aSmrg *.lo) 7598e169010aSmrg # A libtool-controlled object. 7599e169010aSmrg 7600e169010aSmrg # Check to see that this really is a libtool object. 7601e169010aSmrg if func_lalib_unsafe_p "$arg"; then 7602e169010aSmrg pic_object= 7603e169010aSmrg non_pic_object= 7604e169010aSmrg 7605e169010aSmrg # Read the .lo file 7606e169010aSmrg func_source "$arg" 7607e169010aSmrg 7608e169010aSmrg if test -z "$pic_object" || 7609e169010aSmrg test -z "$non_pic_object" || 76109d0ccd10Smrg test none = "$pic_object" && 76119d0ccd10Smrg test none = "$non_pic_object"; then 76129d0ccd10Smrg func_fatal_error "cannot find name of object for '$arg'" 7613e169010aSmrg fi 7614e169010aSmrg 7615e169010aSmrg # Extract subdirectory from the argument. 7616e169010aSmrg func_dirname "$arg" "/" "" 76179d0ccd10Smrg xdir=$func_dirname_result 7618e169010aSmrg 76199d0ccd10Smrg test none = "$pic_object" || { 7620e169010aSmrg # Prepend the subdirectory the object is found in. 76219d0ccd10Smrg pic_object=$xdir$pic_object 7622e169010aSmrg 76239d0ccd10Smrg if test dlfiles = "$prev"; then 76249d0ccd10Smrg if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 7625c63293b5Smrg func_append dlfiles " $pic_object" 7626e169010aSmrg prev= 7627e169010aSmrg continue 7628e169010aSmrg else 7629e169010aSmrg # If libtool objects are unsupported, then we need to preload. 7630e169010aSmrg prev=dlprefiles 7631e169010aSmrg fi 7632e169010aSmrg fi 7633e169010aSmrg 7634e169010aSmrg # CHECK ME: I think I busted this. -Ossama 76359d0ccd10Smrg if test dlprefiles = "$prev"; then 7636e169010aSmrg # Preload the old-style object. 7637c63293b5Smrg func_append dlprefiles " $pic_object" 7638e169010aSmrg prev= 7639e169010aSmrg fi 7640e169010aSmrg 7641e169010aSmrg # A PIC object. 7642e169010aSmrg func_append libobjs " $pic_object" 76439d0ccd10Smrg arg=$pic_object 76449d0ccd10Smrg } 7645e169010aSmrg 7646e169010aSmrg # Non-PIC object. 76479d0ccd10Smrg if test none != "$non_pic_object"; then 7648e169010aSmrg # Prepend the subdirectory the object is found in. 76499d0ccd10Smrg non_pic_object=$xdir$non_pic_object 7650e169010aSmrg 7651e169010aSmrg # A standard non-PIC object 7652e169010aSmrg func_append non_pic_objects " $non_pic_object" 76539d0ccd10Smrg if test -z "$pic_object" || test none = "$pic_object"; then 76549d0ccd10Smrg arg=$non_pic_object 7655e169010aSmrg fi 7656e169010aSmrg else 7657e169010aSmrg # If the PIC object exists, use it instead. 7658e169010aSmrg # $xdir was prepended to $pic_object above. 76599d0ccd10Smrg non_pic_object=$pic_object 7660e169010aSmrg func_append non_pic_objects " $non_pic_object" 7661e169010aSmrg fi 7662e169010aSmrg else 7663e169010aSmrg # Only an error if not doing a dry-run. 7664e169010aSmrg if $opt_dry_run; then 7665e169010aSmrg # Extract subdirectory from the argument. 7666e169010aSmrg func_dirname "$arg" "/" "" 76679d0ccd10Smrg xdir=$func_dirname_result 7668e169010aSmrg 7669e169010aSmrg func_lo2o "$arg" 7670e169010aSmrg pic_object=$xdir$objdir/$func_lo2o_result 7671e169010aSmrg non_pic_object=$xdir$func_lo2o_result 7672e169010aSmrg func_append libobjs " $pic_object" 7673e169010aSmrg func_append non_pic_objects " $non_pic_object" 7674e169010aSmrg else 76759d0ccd10Smrg func_fatal_error "'$arg' is not a valid libtool object" 7676e169010aSmrg fi 7677e169010aSmrg fi 7678e169010aSmrg ;; 7679e169010aSmrg 7680e169010aSmrg *.$libext) 7681e169010aSmrg # An archive. 7682c63293b5Smrg func_append deplibs " $arg" 7683c63293b5Smrg func_append old_deplibs " $arg" 7684e169010aSmrg continue 7685e169010aSmrg ;; 7686e169010aSmrg 7687e169010aSmrg *.la) 7688e169010aSmrg # A libtool-controlled library. 7689e169010aSmrg 7690c63293b5Smrg func_resolve_sysroot "$arg" 76919d0ccd10Smrg if test dlfiles = "$prev"; then 7692e169010aSmrg # This library was specified with -dlopen. 7693c63293b5Smrg func_append dlfiles " $func_resolve_sysroot_result" 7694e169010aSmrg prev= 76959d0ccd10Smrg elif test dlprefiles = "$prev"; then 7696e169010aSmrg # The library was specified with -dlpreopen. 7697c63293b5Smrg func_append dlprefiles " $func_resolve_sysroot_result" 7698e169010aSmrg prev= 7699e169010aSmrg else 7700c63293b5Smrg func_append deplibs " $func_resolve_sysroot_result" 7701e169010aSmrg fi 7702e169010aSmrg continue 7703e169010aSmrg ;; 7704e169010aSmrg 7705e169010aSmrg # Some other compiler argument. 7706e169010aSmrg *) 7707e169010aSmrg # Unknown arguments in both finalize_command and compile_command need 7708e169010aSmrg # to be aesthetically quoted because they are evaled later. 77090ea508b1Smrg func_quote_arg pretty "$arg" 77100ea508b1Smrg arg=$func_quote_arg_result 7711e169010aSmrg ;; 7712e169010aSmrg esac # arg 7713e169010aSmrg 7714e169010aSmrg # Now actually substitute the argument into the commands. 7715e169010aSmrg if test -n "$arg"; then 7716e169010aSmrg func_append compile_command " $arg" 7717e169010aSmrg func_append finalize_command " $arg" 7718e169010aSmrg fi 7719e169010aSmrg done # argument parsing loop 7720e169010aSmrg 7721e169010aSmrg test -n "$prev" && \ 77229d0ccd10Smrg func_fatal_help "the '$prevarg' option requires an argument" 7723e169010aSmrg 77249d0ccd10Smrg if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then 7725e169010aSmrg eval arg=\"$export_dynamic_flag_spec\" 7726e169010aSmrg func_append compile_command " $arg" 7727e169010aSmrg func_append finalize_command " $arg" 7728e169010aSmrg fi 7729e169010aSmrg 7730e169010aSmrg oldlibs= 7731e169010aSmrg # calculate the name of the file, without its directory 7732e169010aSmrg func_basename "$output" 77339d0ccd10Smrg outputname=$func_basename_result 77349d0ccd10Smrg libobjs_save=$libobjs 7735e169010aSmrg 7736e169010aSmrg if test -n "$shlibpath_var"; then 7737e169010aSmrg # get the directories listed in $shlibpath_var 77389d0ccd10Smrg eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\` 77397914d74bSmrg else 7740e169010aSmrg shlib_search_path= 77417914d74bSmrg fi 7742e169010aSmrg eval sys_lib_search_path=\"$sys_lib_search_path_spec\" 7743e169010aSmrg eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" 77447914d74bSmrg 77459d0ccd10Smrg # Definition is injected by LT_CONFIG during libtool generation. 77469d0ccd10Smrg func_munge_path_list sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH" 77479d0ccd10Smrg 7748e169010aSmrg func_dirname "$output" "/" "" 77499d0ccd10Smrg output_objdir=$func_dirname_result$objdir 7750c63293b5Smrg func_to_tool_file "$output_objdir/" 7751c63293b5Smrg tool_output_objdir=$func_to_tool_file_result 7752e169010aSmrg # Create the object directory. 7753e169010aSmrg func_mkdir_p "$output_objdir" 77547914d74bSmrg 7755e169010aSmrg # Determine the type of output 7756e169010aSmrg case $output in 7757e169010aSmrg "") 7758e169010aSmrg func_fatal_help "you must specify an output file" 7759e169010aSmrg ;; 7760e169010aSmrg *.$libext) linkmode=oldlib ;; 7761e169010aSmrg *.lo | *.$objext) linkmode=obj ;; 7762e169010aSmrg *.la) linkmode=lib ;; 7763e169010aSmrg *) linkmode=prog ;; # Anything else should be a program. 7764e169010aSmrg esac 7765e169010aSmrg 7766e169010aSmrg specialdeplibs= 7767e169010aSmrg 7768e169010aSmrg libs= 7769e169010aSmrg # Find all interdependent deplibs by searching for libraries 7770e169010aSmrg # that are linked more than once (e.g. -la -lb -la) 7771e169010aSmrg for deplib in $deplibs; do 77729d0ccd10Smrg if $opt_preserve_dup_deps; then 7773e169010aSmrg case "$libs " in 7774c63293b5Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 7775e169010aSmrg esac 7776e169010aSmrg fi 7777c63293b5Smrg func_append libs " $deplib" 7778e169010aSmrg done 7779e169010aSmrg 77809d0ccd10Smrg if test lib = "$linkmode"; then 7781e169010aSmrg libs="$predeps $libs $compiler_lib_search_path $postdeps" 7782e169010aSmrg 7783e169010aSmrg # Compute libraries that are listed more than once in $predeps 7784e169010aSmrg # $postdeps and mark them as special (i.e., whose duplicates are 7785e169010aSmrg # not to be eliminated). 7786e169010aSmrg pre_post_deps= 7787e169010aSmrg if $opt_duplicate_compiler_generated_deps; then 7788e169010aSmrg for pre_post_dep in $predeps $postdeps; do 7789e169010aSmrg case "$pre_post_deps " in 7790c63293b5Smrg *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; 7791e169010aSmrg esac 7792c63293b5Smrg func_append pre_post_deps " $pre_post_dep" 7793e169010aSmrg done 7794e169010aSmrg fi 7795e169010aSmrg pre_post_deps= 7796e169010aSmrg fi 7797e169010aSmrg 7798e169010aSmrg deplibs= 7799e169010aSmrg newdependency_libs= 7800e169010aSmrg newlib_search_path= 7801e169010aSmrg need_relink=no # whether we're linking any uninstalled libtool libraries 7802e169010aSmrg notinst_deplibs= # not-installed libtool libraries 7803e169010aSmrg notinst_path= # paths that contain not-installed libtool libraries 7804e169010aSmrg 7805e169010aSmrg case $linkmode in 7806e169010aSmrg lib) 7807e169010aSmrg passes="conv dlpreopen link" 7808e169010aSmrg for file in $dlfiles $dlprefiles; do 7809e169010aSmrg case $file in 7810e169010aSmrg *.la) ;; 7811e169010aSmrg *) 78129d0ccd10Smrg func_fatal_help "libraries can '-dlopen' only libtool libraries: $file" 7813e169010aSmrg ;; 7814e169010aSmrg esac 7815e169010aSmrg done 7816e169010aSmrg ;; 7817e169010aSmrg prog) 7818e169010aSmrg compile_deplibs= 7819e169010aSmrg finalize_deplibs= 78209d0ccd10Smrg alldeplibs=false 7821e169010aSmrg newdlfiles= 7822e169010aSmrg newdlprefiles= 7823e169010aSmrg passes="conv scan dlopen dlpreopen link" 7824e169010aSmrg ;; 7825e169010aSmrg *) passes="conv" 7826e169010aSmrg ;; 7827e169010aSmrg esac 7828e169010aSmrg 7829e169010aSmrg for pass in $passes; do 7830e169010aSmrg # The preopen pass in lib mode reverses $deplibs; put it back here 7831e169010aSmrg # so that -L comes before libs that need it for instance... 78329d0ccd10Smrg if test lib,link = "$linkmode,$pass"; then 7833e169010aSmrg ## FIXME: Find the place where the list is rebuilt in the wrong 7834e169010aSmrg ## order, and fix it there properly 7835e169010aSmrg tmp_deplibs= 7836e169010aSmrg for deplib in $deplibs; do 7837e169010aSmrg tmp_deplibs="$deplib $tmp_deplibs" 7838e169010aSmrg done 78399d0ccd10Smrg deplibs=$tmp_deplibs 7840e169010aSmrg fi 7841e169010aSmrg 78429d0ccd10Smrg if test lib,link = "$linkmode,$pass" || 78439d0ccd10Smrg test prog,scan = "$linkmode,$pass"; then 78449d0ccd10Smrg libs=$deplibs 7845e169010aSmrg deplibs= 7846e169010aSmrg fi 78479d0ccd10Smrg if test prog = "$linkmode"; then 7848e169010aSmrg case $pass in 78499d0ccd10Smrg dlopen) libs=$dlfiles ;; 78509d0ccd10Smrg dlpreopen) libs=$dlprefiles ;; 78516b7436aeSmrg link) 78526b7436aeSmrg libs="$deplibs %DEPLIBS%" 78536b7436aeSmrg test "X$link_all_deplibs" != Xno && libs="$libs $dependency_libs" 78546b7436aeSmrg ;; 7855e169010aSmrg esac 7856e169010aSmrg fi 78579d0ccd10Smrg if test lib,dlpreopen = "$linkmode,$pass"; then 7858e169010aSmrg # Collect and forward deplibs of preopened libtool libs 7859e169010aSmrg for lib in $dlprefiles; do 7860e169010aSmrg # Ignore non-libtool-libs 7861e169010aSmrg dependency_libs= 7862c63293b5Smrg func_resolve_sysroot "$lib" 7863e169010aSmrg case $lib in 7864c63293b5Smrg *.la) func_source "$func_resolve_sysroot_result" ;; 7865e169010aSmrg esac 7866e169010aSmrg 7867e169010aSmrg # Collect preopened libtool deplibs, except any this library 7868e169010aSmrg # has declared as weak libs 7869e169010aSmrg for deplib in $dependency_libs; do 7870e8ead290Smrg func_basename "$deplib" 7871e8ead290Smrg deplib_base=$func_basename_result 7872e169010aSmrg case " $weak_libs " in 7873e169010aSmrg *" $deplib_base "*) ;; 7874c63293b5Smrg *) func_append deplibs " $deplib" ;; 7875e169010aSmrg esac 7876e169010aSmrg done 7877e169010aSmrg done 78789d0ccd10Smrg libs=$dlprefiles 7879e169010aSmrg fi 78809d0ccd10Smrg if test dlopen = "$pass"; then 7881e169010aSmrg # Collect dlpreopened libraries 78829d0ccd10Smrg save_deplibs=$deplibs 7883e169010aSmrg deplibs= 7884e169010aSmrg fi 7885e169010aSmrg 7886e169010aSmrg for deplib in $libs; do 7887e169010aSmrg lib= 78889d0ccd10Smrg found=false 7889e169010aSmrg case $deplib in 7890e6d5e4e0Smrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 7891e6d5e4e0Smrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 78929d0ccd10Smrg if test prog,link = "$linkmode,$pass"; then 7893e169010aSmrg compile_deplibs="$deplib $compile_deplibs" 7894e169010aSmrg finalize_deplibs="$deplib $finalize_deplibs" 7895e169010aSmrg else 7896c63293b5Smrg func_append compiler_flags " $deplib" 78979d0ccd10Smrg if test lib = "$linkmode"; then 7898e169010aSmrg case "$new_inherited_linker_flags " in 7899e169010aSmrg *" $deplib "*) ;; 7900c63293b5Smrg * ) func_append new_inherited_linker_flags " $deplib" ;; 7901e169010aSmrg esac 7902e169010aSmrg fi 7903e169010aSmrg fi 7904e169010aSmrg continue 7905e169010aSmrg ;; 7906e169010aSmrg -l*) 79079d0ccd10Smrg if test lib != "$linkmode" && test prog != "$linkmode"; then 79089d0ccd10Smrg func_warning "'-l' is ignored for archives/objects" 7909e169010aSmrg continue 7910e169010aSmrg fi 7911e169010aSmrg func_stripname '-l' '' "$deplib" 7912e169010aSmrg name=$func_stripname_result 79139d0ccd10Smrg if test lib = "$linkmode"; then 7914e169010aSmrg searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" 7915e169010aSmrg else 7916e169010aSmrg searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" 7917e169010aSmrg fi 7918e169010aSmrg for searchdir in $searchdirs; do 7919e169010aSmrg for search_ext in .la $std_shrext .so .a; do 7920e169010aSmrg # Search the libtool library 79219d0ccd10Smrg lib=$searchdir/lib$name$search_ext 7922e169010aSmrg if test -f "$lib"; then 79239d0ccd10Smrg if test .la = "$search_ext"; then 79249d0ccd10Smrg found=: 7925e169010aSmrg else 79269d0ccd10Smrg found=false 7927e169010aSmrg fi 7928e169010aSmrg break 2 7929e169010aSmrg fi 7930e169010aSmrg done 7931e169010aSmrg done 79329d0ccd10Smrg if $found; then 79339d0ccd10Smrg # deplib is a libtool library 7934e169010aSmrg # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, 7935e169010aSmrg # We need to do some special things here, and not later. 79369d0ccd10Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 7937e169010aSmrg case " $predeps $postdeps " in 7938e169010aSmrg *" $deplib "*) 7939e169010aSmrg if func_lalib_p "$lib"; then 7940e169010aSmrg library_names= 7941e169010aSmrg old_library= 7942e169010aSmrg func_source "$lib" 7943e169010aSmrg for l in $old_library $library_names; do 79449d0ccd10Smrg ll=$l 7945e169010aSmrg done 79469d0ccd10Smrg if test "X$ll" = "X$old_library"; then # only static version available 79479d0ccd10Smrg found=false 7948e169010aSmrg func_dirname "$lib" "" "." 79499d0ccd10Smrg ladir=$func_dirname_result 7950e169010aSmrg lib=$ladir/$old_library 79519d0ccd10Smrg if test prog,link = "$linkmode,$pass"; then 7952e169010aSmrg compile_deplibs="$deplib $compile_deplibs" 7953e169010aSmrg finalize_deplibs="$deplib $finalize_deplibs" 7954e169010aSmrg else 7955e169010aSmrg deplibs="$deplib $deplibs" 79569d0ccd10Smrg test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 7957e169010aSmrg fi 7958e169010aSmrg continue 7959e169010aSmrg fi 7960e169010aSmrg fi 7961e169010aSmrg ;; 7962e169010aSmrg *) ;; 7963e169010aSmrg esac 7964e169010aSmrg fi 79659d0ccd10Smrg else 79669d0ccd10Smrg # deplib doesn't seem to be a libtool library 79679d0ccd10Smrg if test prog,link = "$linkmode,$pass"; then 79689d0ccd10Smrg compile_deplibs="$deplib $compile_deplibs" 79699d0ccd10Smrg finalize_deplibs="$deplib $finalize_deplibs" 79709d0ccd10Smrg else 79719d0ccd10Smrg deplibs="$deplib $deplibs" 79729d0ccd10Smrg test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 79739d0ccd10Smrg fi 79749d0ccd10Smrg continue 7975e169010aSmrg fi 7976e169010aSmrg ;; # -l 7977e169010aSmrg *.ltframework) 79789d0ccd10Smrg if test prog,link = "$linkmode,$pass"; then 7979e169010aSmrg compile_deplibs="$deplib $compile_deplibs" 7980e169010aSmrg finalize_deplibs="$deplib $finalize_deplibs" 7981e169010aSmrg else 7982e169010aSmrg deplibs="$deplib $deplibs" 79839d0ccd10Smrg if test lib = "$linkmode"; then 7984e169010aSmrg case "$new_inherited_linker_flags " in 7985e169010aSmrg *" $deplib "*) ;; 7986c63293b5Smrg * ) func_append new_inherited_linker_flags " $deplib" ;; 7987e169010aSmrg esac 7988e169010aSmrg fi 7989e169010aSmrg fi 7990e169010aSmrg continue 7991e169010aSmrg ;; 7992e169010aSmrg -L*) 7993e169010aSmrg case $linkmode in 7994e169010aSmrg lib) 7995e169010aSmrg deplibs="$deplib $deplibs" 79969d0ccd10Smrg test conv = "$pass" && continue 7997e169010aSmrg newdependency_libs="$deplib $newdependency_libs" 7998e169010aSmrg func_stripname '-L' '' "$deplib" 7999c63293b5Smrg func_resolve_sysroot "$func_stripname_result" 8000c63293b5Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 8001e169010aSmrg ;; 8002e169010aSmrg prog) 80039d0ccd10Smrg if test conv = "$pass"; then 8004e169010aSmrg deplibs="$deplib $deplibs" 8005e169010aSmrg continue 8006e169010aSmrg fi 80079d0ccd10Smrg if test scan = "$pass"; then 8008e169010aSmrg deplibs="$deplib $deplibs" 8009e169010aSmrg else 8010e169010aSmrg compile_deplibs="$deplib $compile_deplibs" 8011e169010aSmrg finalize_deplibs="$deplib $finalize_deplibs" 8012e169010aSmrg fi 8013e169010aSmrg func_stripname '-L' '' "$deplib" 8014c63293b5Smrg func_resolve_sysroot "$func_stripname_result" 8015c63293b5Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 8016e169010aSmrg ;; 8017e169010aSmrg *) 80189d0ccd10Smrg func_warning "'-L' is ignored for archives/objects" 8019e169010aSmrg ;; 8020e169010aSmrg esac # linkmode 8021e169010aSmrg continue 8022e169010aSmrg ;; # -L 8023e169010aSmrg -R*) 80249d0ccd10Smrg if test link = "$pass"; then 8025e169010aSmrg func_stripname '-R' '' "$deplib" 8026c63293b5Smrg func_resolve_sysroot "$func_stripname_result" 8027c63293b5Smrg dir=$func_resolve_sysroot_result 8028e169010aSmrg # Make sure the xrpath contains only unique directories. 8029e169010aSmrg case "$xrpath " in 8030e169010aSmrg *" $dir "*) ;; 8031c63293b5Smrg *) func_append xrpath " $dir" ;; 8032e169010aSmrg esac 8033e169010aSmrg fi 8034e169010aSmrg deplibs="$deplib $deplibs" 8035e169010aSmrg continue 8036e169010aSmrg ;; 8037c63293b5Smrg *.la) 8038c63293b5Smrg func_resolve_sysroot "$deplib" 8039c63293b5Smrg lib=$func_resolve_sysroot_result 8040c63293b5Smrg ;; 8041e169010aSmrg *.$libext) 80429d0ccd10Smrg if test conv = "$pass"; then 8043e169010aSmrg deplibs="$deplib $deplibs" 8044e169010aSmrg continue 8045e169010aSmrg fi 8046e169010aSmrg case $linkmode in 8047e169010aSmrg lib) 8048e169010aSmrg # Linking convenience modules into shared libraries is allowed, 8049e169010aSmrg # but linking other static libraries is non-portable. 8050e169010aSmrg case " $dlpreconveniencelibs " in 8051e169010aSmrg *" $deplib "*) ;; 8052e169010aSmrg *) 80539d0ccd10Smrg valid_a_lib=false 8054e169010aSmrg case $deplibs_check_method in 8055e169010aSmrg match_pattern*) 8056e169010aSmrg set dummy $deplibs_check_method; shift 8057e169010aSmrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 8058e8ead290Smrg if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ 8059e169010aSmrg | $EGREP "$match_pattern_regex" > /dev/null; then 80609d0ccd10Smrg valid_a_lib=: 8061e169010aSmrg fi 8062e169010aSmrg ;; 8063e169010aSmrg pass_all) 80649d0ccd10Smrg valid_a_lib=: 8065e169010aSmrg ;; 8066e169010aSmrg esac 80679d0ccd10Smrg if $valid_a_lib; then 80689d0ccd10Smrg echo 80699d0ccd10Smrg $ECHO "*** Warning: Linking the shared library $output against the" 80709d0ccd10Smrg $ECHO "*** static library $deplib is not portable!" 80719d0ccd10Smrg deplibs="$deplib $deplibs" 80729d0ccd10Smrg else 8073e8ead290Smrg echo 8074e169010aSmrg $ECHO "*** Warning: Trying to link with static lib archive $deplib." 8075e8ead290Smrg echo "*** I have the capability to make that library automatically link in when" 8076e8ead290Smrg echo "*** you link to this library. But I can only do this if you have a" 8077e8ead290Smrg echo "*** shared version of the library, which you do not appear to have" 8078e8ead290Smrg echo "*** because the file extensions .$libext of this argument makes me believe" 8079e8ead290Smrg echo "*** that it is just a static archive that I should not use here." 8080e169010aSmrg fi 8081e169010aSmrg ;; 8082e169010aSmrg esac 8083e169010aSmrg continue 8084e169010aSmrg ;; 8085e169010aSmrg prog) 80869d0ccd10Smrg if test link != "$pass"; then 8087e169010aSmrg deplibs="$deplib $deplibs" 8088e169010aSmrg else 8089e169010aSmrg compile_deplibs="$deplib $compile_deplibs" 8090e169010aSmrg finalize_deplibs="$deplib $finalize_deplibs" 8091e169010aSmrg fi 8092e169010aSmrg continue 8093e169010aSmrg ;; 8094e169010aSmrg esac # linkmode 8095e169010aSmrg ;; # *.$libext 8096e169010aSmrg *.lo | *.$objext) 80979d0ccd10Smrg if test conv = "$pass"; then 8098e169010aSmrg deplibs="$deplib $deplibs" 80999d0ccd10Smrg elif test prog = "$linkmode"; then 81009d0ccd10Smrg if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then 8101e169010aSmrg # If there is no dlopen support or we're linking statically, 8102e169010aSmrg # we need to preload. 8103c63293b5Smrg func_append newdlprefiles " $deplib" 8104e169010aSmrg compile_deplibs="$deplib $compile_deplibs" 8105e169010aSmrg finalize_deplibs="$deplib $finalize_deplibs" 8106e169010aSmrg else 8107c63293b5Smrg func_append newdlfiles " $deplib" 8108e169010aSmrg fi 8109e169010aSmrg fi 8110e169010aSmrg continue 8111e169010aSmrg ;; 8112e169010aSmrg %DEPLIBS%) 81139d0ccd10Smrg alldeplibs=: 8114e169010aSmrg continue 8115e169010aSmrg ;; 8116e169010aSmrg esac # case $deplib 8117e169010aSmrg 81189d0ccd10Smrg $found || test -f "$lib" \ 81199d0ccd10Smrg || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'" 8120e169010aSmrg 8121e169010aSmrg # Check to see that this really is a libtool archive. 8122e169010aSmrg func_lalib_unsafe_p "$lib" \ 81239d0ccd10Smrg || func_fatal_error "'$lib' is not a valid libtool archive" 8124e169010aSmrg 8125e169010aSmrg func_dirname "$lib" "" "." 81269d0ccd10Smrg ladir=$func_dirname_result 8127e169010aSmrg 8128e169010aSmrg dlname= 8129e169010aSmrg dlopen= 8130e169010aSmrg dlpreopen= 8131e169010aSmrg libdir= 8132e169010aSmrg library_names= 8133e169010aSmrg old_library= 8134e169010aSmrg inherited_linker_flags= 8135e169010aSmrg # If the library was installed with an old release of libtool, 8136e169010aSmrg # it will not redefine variables installed, or shouldnotlink 8137e169010aSmrg installed=yes 8138e169010aSmrg shouldnotlink=no 8139e169010aSmrg avoidtemprpath= 8140e169010aSmrg 8141e169010aSmrg 8142e169010aSmrg # Read the .la file 8143e169010aSmrg func_source "$lib" 8144e169010aSmrg 8145e169010aSmrg # Convert "-framework foo" to "foo.ltframework" 8146e169010aSmrg if test -n "$inherited_linker_flags"; then 8147e8ead290Smrg tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` 8148e169010aSmrg for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do 8149e169010aSmrg case " $new_inherited_linker_flags " in 8150e169010aSmrg *" $tmp_inherited_linker_flag "*) ;; 8151c63293b5Smrg *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; 8152e169010aSmrg esac 8153e169010aSmrg done 8154e169010aSmrg fi 8155e8ead290Smrg dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 81569d0ccd10Smrg if test lib,link = "$linkmode,$pass" || 81579d0ccd10Smrg test prog,scan = "$linkmode,$pass" || 81589d0ccd10Smrg { test prog != "$linkmode" && test lib != "$linkmode"; }; then 8159c63293b5Smrg test -n "$dlopen" && func_append dlfiles " $dlopen" 8160c63293b5Smrg test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" 8161e169010aSmrg fi 8162e169010aSmrg 81639d0ccd10Smrg if test conv = "$pass"; then 8164e169010aSmrg # Only check for convenience libraries 8165e169010aSmrg deplibs="$lib $deplibs" 8166e169010aSmrg if test -z "$libdir"; then 8167e169010aSmrg if test -z "$old_library"; then 81689d0ccd10Smrg func_fatal_error "cannot find name of link library for '$lib'" 8169e169010aSmrg fi 8170e169010aSmrg # It is a libtool convenience library, so add in its objects. 8171c63293b5Smrg func_append convenience " $ladir/$objdir/$old_library" 8172c63293b5Smrg func_append old_convenience " $ladir/$objdir/$old_library" 81736b7436aeSmrg tmp_libs= 81746b7436aeSmrg for deplib in $dependency_libs; do 81756b7436aeSmrg deplibs="$deplib $deplibs" 81766b7436aeSmrg if $opt_preserve_dup_deps; then 81776b7436aeSmrg case "$tmp_libs " in 81786b7436aeSmrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 81796b7436aeSmrg esac 81806b7436aeSmrg fi 81816b7436aeSmrg func_append tmp_libs " $deplib" 81826b7436aeSmrg done 81839d0ccd10Smrg elif test prog != "$linkmode" && test lib != "$linkmode"; then 81849d0ccd10Smrg func_fatal_error "'$lib' is not a convenience library" 8185e169010aSmrg fi 8186e169010aSmrg continue 8187e169010aSmrg fi # $pass = conv 8188e169010aSmrg 8189e169010aSmrg 8190e169010aSmrg # Get the name of the library we link against. 8191e169010aSmrg linklib= 8192c63293b5Smrg if test -n "$old_library" && 81939d0ccd10Smrg { test yes = "$prefer_static_libs" || 81949d0ccd10Smrg test built,no = "$prefer_static_libs,$installed"; }; then 8195c63293b5Smrg linklib=$old_library 8196c63293b5Smrg else 8197c63293b5Smrg for l in $old_library $library_names; do 81989d0ccd10Smrg linklib=$l 8199c63293b5Smrg done 8200c63293b5Smrg fi 8201e169010aSmrg if test -z "$linklib"; then 82029d0ccd10Smrg func_fatal_error "cannot find name of link library for '$lib'" 8203e169010aSmrg fi 8204e169010aSmrg 8205e169010aSmrg # This library was specified with -dlopen. 82069d0ccd10Smrg if test dlopen = "$pass"; then 82079d0ccd10Smrg test -z "$libdir" \ 82089d0ccd10Smrg && func_fatal_error "cannot -dlopen a convenience library: '$lib'" 8209e169010aSmrg if test -z "$dlname" || 82109d0ccd10Smrg test yes != "$dlopen_support" || 82119d0ccd10Smrg test no = "$build_libtool_libs" 82129d0ccd10Smrg then 8213e169010aSmrg # If there is no dlname, no dlopen support or we're linking 8214e169010aSmrg # statically, we need to preload. We also need to preload any 8215e169010aSmrg # dependent libraries so libltdl's deplib preloader doesn't 8216e169010aSmrg # bomb out in the load deplibs phase. 8217c63293b5Smrg func_append dlprefiles " $lib $dependency_libs" 8218e169010aSmrg else 8219c63293b5Smrg func_append newdlfiles " $lib" 8220e169010aSmrg fi 8221e169010aSmrg continue 8222e169010aSmrg fi # $pass = dlopen 8223e169010aSmrg 8224e169010aSmrg # We need an absolute path. 8225e169010aSmrg case $ladir in 82269d0ccd10Smrg [\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;; 8227e169010aSmrg *) 8228e169010aSmrg abs_ladir=`cd "$ladir" && pwd` 8229e169010aSmrg if test -z "$abs_ladir"; then 82309d0ccd10Smrg func_warning "cannot determine absolute directory name of '$ladir'" 8231e169010aSmrg func_warning "passing it literally to the linker, although it might fail" 82329d0ccd10Smrg abs_ladir=$ladir 8233e169010aSmrg fi 8234e169010aSmrg ;; 8235e169010aSmrg esac 8236e169010aSmrg func_basename "$lib" 82379d0ccd10Smrg laname=$func_basename_result 8238e169010aSmrg 8239e169010aSmrg # Find the relevant object directory and library name. 82409d0ccd10Smrg if test yes = "$installed"; then 8241c63293b5Smrg if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then 82429d0ccd10Smrg func_warning "library '$lib' was moved." 82439d0ccd10Smrg dir=$ladir 82449d0ccd10Smrg absdir=$abs_ladir 82459d0ccd10Smrg libdir=$abs_ladir 8246e169010aSmrg else 82479d0ccd10Smrg dir=$lt_sysroot$libdir 82489d0ccd10Smrg absdir=$lt_sysroot$libdir 8249e169010aSmrg fi 82509d0ccd10Smrg test yes = "$hardcode_automatic" && avoidtemprpath=yes 8251e169010aSmrg else 8252e169010aSmrg if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then 82539d0ccd10Smrg dir=$ladir 82549d0ccd10Smrg absdir=$abs_ladir 8255e169010aSmrg # Remove this search path later 8256c63293b5Smrg func_append notinst_path " $abs_ladir" 8257e169010aSmrg else 82589d0ccd10Smrg dir=$ladir/$objdir 82599d0ccd10Smrg absdir=$abs_ladir/$objdir 8260e169010aSmrg # Remove this search path later 8261c63293b5Smrg func_append notinst_path " $abs_ladir" 8262e169010aSmrg fi 8263e169010aSmrg fi # $installed = yes 8264e169010aSmrg func_stripname 'lib' '.la' "$laname" 8265e169010aSmrg name=$func_stripname_result 8266e169010aSmrg 8267e169010aSmrg # This library was specified with -dlpreopen. 82689d0ccd10Smrg if test dlpreopen = "$pass"; then 82699d0ccd10Smrg if test -z "$libdir" && test prog = "$linkmode"; then 82709d0ccd10Smrg func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'" 8271e169010aSmrg fi 82729d0ccd10Smrg case $host in 8273c63293b5Smrg # special handling for platforms with PE-DLLs. 8274c63293b5Smrg *cygwin* | *mingw* | *cegcc* ) 8275c63293b5Smrg # Linker will automatically link against shared library if both 8276c63293b5Smrg # static and shared are present. Therefore, ensure we extract 8277c63293b5Smrg # symbols from the import library if a shared library is present 8278c63293b5Smrg # (otherwise, the dlopen module name will be incorrect). We do 8279c63293b5Smrg # this by putting the import library name into $newdlprefiles. 8280c63293b5Smrg # We recover the dlopen module name by 'saving' the la file 8281c63293b5Smrg # name in a special purpose variable, and (later) extracting the 8282c63293b5Smrg # dlname from the la file. 8283c63293b5Smrg if test -n "$dlname"; then 8284c63293b5Smrg func_tr_sh "$dir/$linklib" 8285c63293b5Smrg eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" 8286c63293b5Smrg func_append newdlprefiles " $dir/$linklib" 8287c63293b5Smrg else 8288c63293b5Smrg func_append newdlprefiles " $dir/$old_library" 8289c63293b5Smrg # Keep a list of preopened convenience libraries to check 8290c63293b5Smrg # that they are being used correctly in the link pass. 8291c63293b5Smrg test -z "$libdir" && \ 8292c63293b5Smrg func_append dlpreconveniencelibs " $dir/$old_library" 8293c63293b5Smrg fi 8294c63293b5Smrg ;; 8295c63293b5Smrg * ) 8296c63293b5Smrg # Prefer using a static library (so that no silly _DYNAMIC symbols 8297c63293b5Smrg # are required to link). 8298c63293b5Smrg if test -n "$old_library"; then 8299c63293b5Smrg func_append newdlprefiles " $dir/$old_library" 8300c63293b5Smrg # Keep a list of preopened convenience libraries to check 8301c63293b5Smrg # that they are being used correctly in the link pass. 8302c63293b5Smrg test -z "$libdir" && \ 8303c63293b5Smrg func_append dlpreconveniencelibs " $dir/$old_library" 8304c63293b5Smrg # Otherwise, use the dlname, so that lt_dlopen finds it. 8305c63293b5Smrg elif test -n "$dlname"; then 8306c63293b5Smrg func_append newdlprefiles " $dir/$dlname" 8307c63293b5Smrg else 8308c63293b5Smrg func_append newdlprefiles " $dir/$linklib" 8309c63293b5Smrg fi 8310c63293b5Smrg ;; 8311c63293b5Smrg esac 8312e169010aSmrg fi # $pass = dlpreopen 8313e169010aSmrg 8314e169010aSmrg if test -z "$libdir"; then 8315e169010aSmrg # Link the convenience library 83169d0ccd10Smrg if test lib = "$linkmode"; then 8317e169010aSmrg deplibs="$dir/$old_library $deplibs" 83189d0ccd10Smrg elif test prog,link = "$linkmode,$pass"; then 8319e169010aSmrg compile_deplibs="$dir/$old_library $compile_deplibs" 8320e169010aSmrg finalize_deplibs="$dir/$old_library $finalize_deplibs" 8321e169010aSmrg else 8322e169010aSmrg deplibs="$lib $deplibs" # used for prog,scan pass 8323e169010aSmrg fi 8324e169010aSmrg continue 8325e169010aSmrg fi 8326e169010aSmrg 8327e169010aSmrg 83289d0ccd10Smrg if test prog = "$linkmode" && test link != "$pass"; then 8329c63293b5Smrg func_append newlib_search_path " $ladir" 8330e169010aSmrg deplibs="$lib $deplibs" 8331e169010aSmrg 83329d0ccd10Smrg linkalldeplibs=false 83339d0ccd10Smrg if test no != "$link_all_deplibs" || test -z "$library_names" || 83349d0ccd10Smrg test no = "$build_libtool_libs"; then 83359d0ccd10Smrg linkalldeplibs=: 8336e169010aSmrg fi 8337e169010aSmrg 8338e169010aSmrg tmp_libs= 8339e169010aSmrg for deplib in $dependency_libs; do 8340e169010aSmrg case $deplib in 8341e169010aSmrg -L*) func_stripname '-L' '' "$deplib" 8342c63293b5Smrg func_resolve_sysroot "$func_stripname_result" 8343c63293b5Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 8344e169010aSmrg ;; 8345e169010aSmrg esac 8346e169010aSmrg # Need to link against all dependency_libs? 83479d0ccd10Smrg if $linkalldeplibs; then 8348e169010aSmrg deplibs="$deplib $deplibs" 8349e169010aSmrg else 8350e169010aSmrg # Need to hardcode shared library paths 8351e169010aSmrg # or/and link against static libraries 8352e169010aSmrg newdependency_libs="$deplib $newdependency_libs" 8353e169010aSmrg fi 83549d0ccd10Smrg if $opt_preserve_dup_deps; then 8355e169010aSmrg case "$tmp_libs " in 8356c63293b5Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 8357e169010aSmrg esac 8358e169010aSmrg fi 8359c63293b5Smrg func_append tmp_libs " $deplib" 8360e169010aSmrg done # for deplib 8361e169010aSmrg continue 8362e169010aSmrg fi # $linkmode = prog... 8363e169010aSmrg 83649d0ccd10Smrg if test prog,link = "$linkmode,$pass"; then 8365e169010aSmrg if test -n "$library_names" && 83669d0ccd10Smrg { { test no = "$prefer_static_libs" || 83679d0ccd10Smrg test built,yes = "$prefer_static_libs,$installed"; } || 8368e169010aSmrg test -z "$old_library"; }; then 8369e169010aSmrg # We need to hardcode the library path 83709d0ccd10Smrg if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then 8371e169010aSmrg # Make sure the rpath contains only unique directories. 83729d0ccd10Smrg case $temp_rpath: in 8373e169010aSmrg *"$absdir:"*) ;; 8374c63293b5Smrg *) func_append temp_rpath "$absdir:" ;; 8375e169010aSmrg esac 8376e169010aSmrg fi 8377e169010aSmrg 8378e169010aSmrg # Hardcode the library path. 8379e169010aSmrg # Skip directories that are in the system default run-time 8380e169010aSmrg # search path. 8381e169010aSmrg case " $sys_lib_dlsearch_path " in 8382e169010aSmrg *" $absdir "*) ;; 8383e169010aSmrg *) 8384e169010aSmrg case "$compile_rpath " in 8385e169010aSmrg *" $absdir "*) ;; 8386c63293b5Smrg *) func_append compile_rpath " $absdir" ;; 8387e169010aSmrg esac 8388e169010aSmrg ;; 8389e169010aSmrg esac 8390e169010aSmrg case " $sys_lib_dlsearch_path " in 8391e169010aSmrg *" $libdir "*) ;; 8392e169010aSmrg *) 8393e169010aSmrg case "$finalize_rpath " in 8394e169010aSmrg *" $libdir "*) ;; 8395c63293b5Smrg *) func_append finalize_rpath " $libdir" ;; 8396e169010aSmrg esac 8397e169010aSmrg ;; 8398e169010aSmrg esac 8399e169010aSmrg fi # $linkmode,$pass = prog,link... 8400e169010aSmrg 84019d0ccd10Smrg if $alldeplibs && 84029d0ccd10Smrg { test pass_all = "$deplibs_check_method" || 84039d0ccd10Smrg { test yes = "$build_libtool_libs" && 8404e169010aSmrg test -n "$library_names"; }; }; then 8405e169010aSmrg # We only need to search for static libraries 8406e169010aSmrg continue 8407e169010aSmrg fi 8408e169010aSmrg fi 8409e169010aSmrg 8410e169010aSmrg link_static=no # Whether the deplib will be linked statically 8411e169010aSmrg use_static_libs=$prefer_static_libs 84129d0ccd10Smrg if test built = "$use_static_libs" && test yes = "$installed"; then 8413e169010aSmrg use_static_libs=no 8414e169010aSmrg fi 8415e169010aSmrg if test -n "$library_names" && 84169d0ccd10Smrg { test no = "$use_static_libs" || test -z "$old_library"; }; then 8417e169010aSmrg case $host in 84189d0ccd10Smrg *cygwin* | *mingw* | *cegcc* | *os2*) 8419e169010aSmrg # No point in relinking DLLs because paths are not encoded 8420c63293b5Smrg func_append notinst_deplibs " $lib" 8421e169010aSmrg need_relink=no 8422e169010aSmrg ;; 8423e169010aSmrg *) 84249d0ccd10Smrg if test no = "$installed"; then 8425c63293b5Smrg func_append notinst_deplibs " $lib" 8426e169010aSmrg need_relink=yes 8427e169010aSmrg fi 8428e169010aSmrg ;; 8429e169010aSmrg esac 8430e169010aSmrg # This is a shared library 8431e169010aSmrg 8432e169010aSmrg # Warn about portability, can't link against -module's on some 8433e169010aSmrg # systems (darwin). Don't bleat about dlopened modules though! 84349d0ccd10Smrg dlopenmodule= 8435e169010aSmrg for dlpremoduletest in $dlprefiles; do 8436e169010aSmrg if test "X$dlpremoduletest" = "X$lib"; then 84379d0ccd10Smrg dlopenmodule=$dlpremoduletest 8438e169010aSmrg break 8439e169010aSmrg fi 8440e169010aSmrg done 84419d0ccd10Smrg if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then 8442e8ead290Smrg echo 84439d0ccd10Smrg if test prog = "$linkmode"; then 8444e169010aSmrg $ECHO "*** Warning: Linking the executable $output against the loadable module" 8445e169010aSmrg else 8446e169010aSmrg $ECHO "*** Warning: Linking the shared library $output against the loadable module" 8447e169010aSmrg fi 8448e169010aSmrg $ECHO "*** $linklib is not portable!" 8449e169010aSmrg fi 84509d0ccd10Smrg if test lib = "$linkmode" && 84519d0ccd10Smrg test yes = "$hardcode_into_libs"; then 8452e169010aSmrg # Hardcode the library path. 8453e169010aSmrg # Skip directories that are in the system default run-time 8454e169010aSmrg # search path. 8455e169010aSmrg case " $sys_lib_dlsearch_path " in 8456e169010aSmrg *" $absdir "*) ;; 8457e169010aSmrg *) 8458e169010aSmrg case "$compile_rpath " in 8459e169010aSmrg *" $absdir "*) ;; 8460c63293b5Smrg *) func_append compile_rpath " $absdir" ;; 8461e169010aSmrg esac 8462e169010aSmrg ;; 8463e169010aSmrg esac 8464e169010aSmrg case " $sys_lib_dlsearch_path " in 8465e169010aSmrg *" $libdir "*) ;; 8466e169010aSmrg *) 8467e169010aSmrg case "$finalize_rpath " in 8468e169010aSmrg *" $libdir "*) ;; 8469c63293b5Smrg *) func_append finalize_rpath " $libdir" ;; 8470e169010aSmrg esac 8471e169010aSmrg ;; 8472e169010aSmrg esac 8473e169010aSmrg fi 8474e169010aSmrg 8475e169010aSmrg if test -n "$old_archive_from_expsyms_cmds"; then 8476e169010aSmrg # figure out the soname 8477e169010aSmrg set dummy $library_names 8478e169010aSmrg shift 84799d0ccd10Smrg realname=$1 8480e169010aSmrg shift 8481e169010aSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 8482e169010aSmrg # use dlname if we got it. it's perfectly good, no? 8483e169010aSmrg if test -n "$dlname"; then 84849d0ccd10Smrg soname=$dlname 8485e169010aSmrg elif test -n "$soname_spec"; then 8486e169010aSmrg # bleh windows 8487e169010aSmrg case $host in 84889d0ccd10Smrg *cygwin* | mingw* | *cegcc* | *os2*) 8489e169010aSmrg func_arith $current - $age 8490e169010aSmrg major=$func_arith_result 84919d0ccd10Smrg versuffix=-$major 8492e169010aSmrg ;; 8493e169010aSmrg esac 8494e169010aSmrg eval soname=\"$soname_spec\" 8495e169010aSmrg else 84969d0ccd10Smrg soname=$realname 8497e169010aSmrg fi 8498e169010aSmrg 8499e169010aSmrg # Make a new name for the extract_expsyms_cmds to use 85009d0ccd10Smrg soroot=$soname 8501e169010aSmrg func_basename "$soroot" 85029d0ccd10Smrg soname=$func_basename_result 8503e169010aSmrg func_stripname 'lib' '.dll' "$soname" 8504e169010aSmrg newlib=libimp-$func_stripname_result.a 8505e169010aSmrg 8506e169010aSmrg # If the library has no export list, then create one now 8507e169010aSmrg if test -f "$output_objdir/$soname-def"; then : 8508e169010aSmrg else 85099d0ccd10Smrg func_verbose "extracting exported symbol list from '$soname'" 8510e169010aSmrg func_execute_cmds "$extract_expsyms_cmds" 'exit $?' 8511e169010aSmrg fi 8512e169010aSmrg 8513e169010aSmrg # Create $newlib 8514e169010aSmrg if test -f "$output_objdir/$newlib"; then :; else 85159d0ccd10Smrg func_verbose "generating import library for '$soname'" 8516e169010aSmrg func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' 8517e169010aSmrg fi 8518e169010aSmrg # make sure the library variables are pointing to the new library 8519e169010aSmrg dir=$output_objdir 8520e169010aSmrg linklib=$newlib 8521e169010aSmrg fi # test -n "$old_archive_from_expsyms_cmds" 8522e169010aSmrg 85239d0ccd10Smrg if test prog = "$linkmode" || test relink != "$opt_mode"; then 8524e169010aSmrg add_shlibpath= 8525e169010aSmrg add_dir= 8526e169010aSmrg add= 8527e169010aSmrg lib_linked=yes 8528e169010aSmrg case $hardcode_action in 8529e169010aSmrg immediate | unsupported) 85309d0ccd10Smrg if test no = "$hardcode_direct"; then 85319d0ccd10Smrg add=$dir/$linklib 8532e169010aSmrg case $host in 85339d0ccd10Smrg *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;; 85349d0ccd10Smrg *-*-sysv4*uw2*) add_dir=-L$dir ;; 8535e169010aSmrg *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ 85369d0ccd10Smrg *-*-unixware7*) add_dir=-L$dir ;; 8537e169010aSmrg *-*-darwin* ) 85389d0ccd10Smrg # if the lib is a (non-dlopened) module then we cannot 8539e169010aSmrg # link against it, someone is ignoring the earlier warnings 8540e169010aSmrg if /usr/bin/file -L $add 2> /dev/null | 85419d0ccd10Smrg $GREP ": [^:]* bundle" >/dev/null; then 8542e169010aSmrg if test "X$dlopenmodule" != "X$lib"; then 8543e169010aSmrg $ECHO "*** Warning: lib $linklib is a module, not a shared library" 85449d0ccd10Smrg if test -z "$old_library"; then 8545e8ead290Smrg echo 8546e8ead290Smrg echo "*** And there doesn't seem to be a static archive available" 8547e8ead290Smrg echo "*** The link will probably fail, sorry" 8548e169010aSmrg else 85499d0ccd10Smrg add=$dir/$old_library 8550e169010aSmrg fi 8551e169010aSmrg elif test -n "$old_library"; then 85529d0ccd10Smrg add=$dir/$old_library 8553e169010aSmrg fi 8554e169010aSmrg fi 8555e169010aSmrg esac 85569d0ccd10Smrg elif test no = "$hardcode_minus_L"; then 8557e169010aSmrg case $host in 85589d0ccd10Smrg *-*-sunos*) add_shlibpath=$dir ;; 8559e169010aSmrg esac 85609d0ccd10Smrg add_dir=-L$dir 85619d0ccd10Smrg add=-l$name 85629d0ccd10Smrg elif test no = "$hardcode_shlibpath_var"; then 85639d0ccd10Smrg add_shlibpath=$dir 85649d0ccd10Smrg add=-l$name 8565e169010aSmrg else 8566e169010aSmrg lib_linked=no 8567e169010aSmrg fi 8568e169010aSmrg ;; 8569e169010aSmrg relink) 85709d0ccd10Smrg if test yes = "$hardcode_direct" && 85719d0ccd10Smrg test no = "$hardcode_direct_absolute"; then 85729d0ccd10Smrg add=$dir/$linklib 85739d0ccd10Smrg elif test yes = "$hardcode_minus_L"; then 85749d0ccd10Smrg add_dir=-L$absdir 8575e169010aSmrg # Try looking first in the location we're being installed to. 8576e169010aSmrg if test -n "$inst_prefix_dir"; then 8577e169010aSmrg case $libdir in 8578e169010aSmrg [\\/]*) 8579c63293b5Smrg func_append add_dir " -L$inst_prefix_dir$libdir" 8580e169010aSmrg ;; 8581e169010aSmrg esac 8582e169010aSmrg fi 85839d0ccd10Smrg add=-l$name 85849d0ccd10Smrg elif test yes = "$hardcode_shlibpath_var"; then 85859d0ccd10Smrg add_shlibpath=$dir 85869d0ccd10Smrg add=-l$name 8587e169010aSmrg else 8588e169010aSmrg lib_linked=no 8589e169010aSmrg fi 8590e169010aSmrg ;; 8591e169010aSmrg *) lib_linked=no ;; 8592e169010aSmrg esac 8593e169010aSmrg 85949d0ccd10Smrg if test yes != "$lib_linked"; then 8595e169010aSmrg func_fatal_configuration "unsupported hardcode properties" 8596e169010aSmrg fi 8597e169010aSmrg 8598e169010aSmrg if test -n "$add_shlibpath"; then 8599e169010aSmrg case :$compile_shlibpath: in 8600e169010aSmrg *":$add_shlibpath:"*) ;; 8601c63293b5Smrg *) func_append compile_shlibpath "$add_shlibpath:" ;; 8602e169010aSmrg esac 8603e169010aSmrg fi 86049d0ccd10Smrg if test prog = "$linkmode"; then 8605e169010aSmrg test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" 8606e169010aSmrg test -n "$add" && compile_deplibs="$add $compile_deplibs" 8607e169010aSmrg else 8608e169010aSmrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 8609e169010aSmrg test -n "$add" && deplibs="$add $deplibs" 86109d0ccd10Smrg if test yes != "$hardcode_direct" && 86119d0ccd10Smrg test yes != "$hardcode_minus_L" && 86129d0ccd10Smrg test yes = "$hardcode_shlibpath_var"; then 8613e169010aSmrg case :$finalize_shlibpath: in 8614e169010aSmrg *":$libdir:"*) ;; 8615c63293b5Smrg *) func_append finalize_shlibpath "$libdir:" ;; 8616e169010aSmrg esac 8617e169010aSmrg fi 8618e169010aSmrg fi 8619e169010aSmrg fi 8620e169010aSmrg 86219d0ccd10Smrg if test prog = "$linkmode" || test relink = "$opt_mode"; then 8622e169010aSmrg add_shlibpath= 8623e169010aSmrg add_dir= 8624e169010aSmrg add= 8625e169010aSmrg # Finalize command for both is simple: just hardcode it. 86269d0ccd10Smrg if test yes = "$hardcode_direct" && 86279d0ccd10Smrg test no = "$hardcode_direct_absolute"; then 86289d0ccd10Smrg add=$libdir/$linklib 86299d0ccd10Smrg elif test yes = "$hardcode_minus_L"; then 86309d0ccd10Smrg add_dir=-L$libdir 86319d0ccd10Smrg add=-l$name 86329d0ccd10Smrg elif test yes = "$hardcode_shlibpath_var"; then 8633e169010aSmrg case :$finalize_shlibpath: in 8634e169010aSmrg *":$libdir:"*) ;; 8635c63293b5Smrg *) func_append finalize_shlibpath "$libdir:" ;; 8636e169010aSmrg esac 86379d0ccd10Smrg add=-l$name 86389d0ccd10Smrg elif test yes = "$hardcode_automatic"; then 8639e169010aSmrg if test -n "$inst_prefix_dir" && 86409d0ccd10Smrg test -f "$inst_prefix_dir$libdir/$linklib"; then 86419d0ccd10Smrg add=$inst_prefix_dir$libdir/$linklib 8642e169010aSmrg else 86439d0ccd10Smrg add=$libdir/$linklib 8644e169010aSmrg fi 8645e169010aSmrg else 8646e169010aSmrg # We cannot seem to hardcode it, guess we'll fake it. 86479d0ccd10Smrg add_dir=-L$libdir 8648e169010aSmrg # Try looking first in the location we're being installed to. 8649e169010aSmrg if test -n "$inst_prefix_dir"; then 8650e169010aSmrg case $libdir in 8651e169010aSmrg [\\/]*) 8652c63293b5Smrg func_append add_dir " -L$inst_prefix_dir$libdir" 8653e169010aSmrg ;; 8654e169010aSmrg esac 8655e169010aSmrg fi 86569d0ccd10Smrg add=-l$name 8657e169010aSmrg fi 8658e169010aSmrg 86599d0ccd10Smrg if test prog = "$linkmode"; then 8660e169010aSmrg test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" 8661e169010aSmrg test -n "$add" && finalize_deplibs="$add $finalize_deplibs" 8662e169010aSmrg else 8663e169010aSmrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 8664e169010aSmrg test -n "$add" && deplibs="$add $deplibs" 8665e169010aSmrg fi 8666e169010aSmrg fi 86679d0ccd10Smrg elif test prog = "$linkmode"; then 8668e169010aSmrg # Here we assume that one of hardcode_direct or hardcode_minus_L 8669e169010aSmrg # is not unsupported. This is valid on all known static and 8670e169010aSmrg # shared platforms. 86719d0ccd10Smrg if test unsupported != "$hardcode_direct"; then 86729d0ccd10Smrg test -n "$old_library" && linklib=$old_library 8673e169010aSmrg compile_deplibs="$dir/$linklib $compile_deplibs" 8674e169010aSmrg finalize_deplibs="$dir/$linklib $finalize_deplibs" 8675e169010aSmrg else 8676e169010aSmrg compile_deplibs="-l$name -L$dir $compile_deplibs" 8677e169010aSmrg finalize_deplibs="-l$name -L$dir $finalize_deplibs" 8678e169010aSmrg fi 86799d0ccd10Smrg elif test yes = "$build_libtool_libs"; then 8680e169010aSmrg # Not a shared library 86819d0ccd10Smrg if test pass_all != "$deplibs_check_method"; then 8682e169010aSmrg # We're trying link a shared library against a static one 8683e169010aSmrg # but the system doesn't support it. 8684e169010aSmrg 8685e169010aSmrg # Just print a warning and add the library to dependency_libs so 8686e169010aSmrg # that the program can be linked against the static library. 8687e8ead290Smrg echo 86889d0ccd10Smrg $ECHO "*** Warning: This system cannot link to static lib archive $lib." 8689e8ead290Smrg echo "*** I have the capability to make that library automatically link in when" 8690e8ead290Smrg echo "*** you link to this library. But I can only do this if you have a" 8691e8ead290Smrg echo "*** shared version of the library, which you do not appear to have." 86929d0ccd10Smrg if test yes = "$module"; then 8693e8ead290Smrg echo "*** But as you try to build a module library, libtool will still create " 8694e8ead290Smrg echo "*** a static module, that should work as long as the dlopening application" 8695e8ead290Smrg echo "*** is linked with the -dlopen flag to resolve symbols at runtime." 8696e169010aSmrg if test -z "$global_symbol_pipe"; then 8697e8ead290Smrg echo 8698e8ead290Smrg echo "*** However, this would only work if libtool was able to extract symbol" 86999d0ccd10Smrg echo "*** lists from a program, using 'nm' or equivalent, but libtool could" 8700e8ead290Smrg echo "*** not find such a program. So, this module is probably useless." 87019d0ccd10Smrg echo "*** 'nm' from GNU binutils and a full rebuild may help." 8702e169010aSmrg fi 87039d0ccd10Smrg if test no = "$build_old_libs"; then 8704e169010aSmrg build_libtool_libs=module 8705e169010aSmrg build_old_libs=yes 8706e169010aSmrg else 8707e169010aSmrg build_libtool_libs=no 8708e169010aSmrg fi 8709e169010aSmrg fi 8710e169010aSmrg else 8711e169010aSmrg deplibs="$dir/$old_library $deplibs" 8712e169010aSmrg link_static=yes 8713e169010aSmrg fi 8714e169010aSmrg fi # link shared/static library? 8715e169010aSmrg 87169d0ccd10Smrg if test lib = "$linkmode"; then 8717e169010aSmrg if test -n "$dependency_libs" && 87189d0ccd10Smrg { test yes != "$hardcode_into_libs" || 87199d0ccd10Smrg test yes = "$build_old_libs" || 87209d0ccd10Smrg test yes = "$link_static"; }; then 8721e169010aSmrg # Extract -R from dependency_libs 8722e169010aSmrg temp_deplibs= 8723e169010aSmrg for libdir in $dependency_libs; do 8724e169010aSmrg case $libdir in 8725e169010aSmrg -R*) func_stripname '-R' '' "$libdir" 8726e169010aSmrg temp_xrpath=$func_stripname_result 8727e169010aSmrg case " $xrpath " in 8728e169010aSmrg *" $temp_xrpath "*) ;; 8729c63293b5Smrg *) func_append xrpath " $temp_xrpath";; 8730e169010aSmrg esac;; 8731c63293b5Smrg *) func_append temp_deplibs " $libdir";; 8732e169010aSmrg esac 8733e169010aSmrg done 87349d0ccd10Smrg dependency_libs=$temp_deplibs 8735e169010aSmrg fi 8736e169010aSmrg 8737c63293b5Smrg func_append newlib_search_path " $absdir" 8738e169010aSmrg # Link against this library 87399d0ccd10Smrg test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs" 8740e169010aSmrg # ... and its dependency_libs 8741e169010aSmrg tmp_libs= 8742e169010aSmrg for deplib in $dependency_libs; do 8743e169010aSmrg newdependency_libs="$deplib $newdependency_libs" 8744c63293b5Smrg case $deplib in 8745c63293b5Smrg -L*) func_stripname '-L' '' "$deplib" 8746c63293b5Smrg func_resolve_sysroot "$func_stripname_result";; 8747c63293b5Smrg *) func_resolve_sysroot "$deplib" ;; 8748c63293b5Smrg esac 87499d0ccd10Smrg if $opt_preserve_dup_deps; then 8750e169010aSmrg case "$tmp_libs " in 8751c63293b5Smrg *" $func_resolve_sysroot_result "*) 8752c63293b5Smrg func_append specialdeplibs " $func_resolve_sysroot_result" ;; 8753e169010aSmrg esac 8754e169010aSmrg fi 8755c63293b5Smrg func_append tmp_libs " $func_resolve_sysroot_result" 8756e169010aSmrg done 8757e169010aSmrg 87589d0ccd10Smrg if test no != "$link_all_deplibs"; then 8759e169010aSmrg # Add the search paths of all dependency libraries 8760e169010aSmrg for deplib in $dependency_libs; do 8761e8ead290Smrg path= 8762e169010aSmrg case $deplib in 87639d0ccd10Smrg -L*) path=$deplib ;; 8764e169010aSmrg *.la) 8765c63293b5Smrg func_resolve_sysroot "$deplib" 8766c63293b5Smrg deplib=$func_resolve_sysroot_result 8767e169010aSmrg func_dirname "$deplib" "" "." 8768c63293b5Smrg dir=$func_dirname_result 8769e169010aSmrg # We need an absolute path. 8770e169010aSmrg case $dir in 87719d0ccd10Smrg [\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;; 8772e169010aSmrg *) 8773e169010aSmrg absdir=`cd "$dir" && pwd` 8774e169010aSmrg if test -z "$absdir"; then 87759d0ccd10Smrg func_warning "cannot determine absolute directory name of '$dir'" 87769d0ccd10Smrg absdir=$dir 8777e169010aSmrg fi 8778e169010aSmrg ;; 8779e169010aSmrg esac 8780e169010aSmrg if $GREP "^installed=no" $deplib > /dev/null; then 8781e169010aSmrg case $host in 8782e169010aSmrg *-*-darwin*) 8783e169010aSmrg depdepl= 87849d0ccd10Smrg eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` 87859d0ccd10Smrg if test -n "$deplibrary_names"; then 87869d0ccd10Smrg for tmp in $deplibrary_names; do 8787e169010aSmrg depdepl=$tmp 8788e169010aSmrg done 87899d0ccd10Smrg if test -f "$absdir/$objdir/$depdepl"; then 87909d0ccd10Smrg depdepl=$absdir/$objdir/$depdepl 87919d0ccd10Smrg darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 8792e169010aSmrg if test -z "$darwin_install_name"; then 87939d0ccd10Smrg darwin_install_name=`$OTOOL64 -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 8794e169010aSmrg fi 87959d0ccd10Smrg func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl" 87969d0ccd10Smrg func_append linker_flags " -dylib_file $darwin_install_name:$depdepl" 8797e169010aSmrg path= 8798e169010aSmrg fi 8799e169010aSmrg fi 8800e169010aSmrg ;; 8801e169010aSmrg *) 88029d0ccd10Smrg path=-L$absdir/$objdir 8803e169010aSmrg ;; 8804e169010aSmrg esac 8805e169010aSmrg else 88069d0ccd10Smrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` 8807e169010aSmrg test -z "$libdir" && \ 88089d0ccd10Smrg func_fatal_error "'$deplib' is not a valid libtool archive" 8809e169010aSmrg test "$absdir" != "$libdir" && \ 88109d0ccd10Smrg func_warning "'$deplib' seems to be moved" 8811e169010aSmrg 88129d0ccd10Smrg path=-L$absdir 8813e169010aSmrg fi 8814e169010aSmrg ;; 8815e169010aSmrg esac 8816e169010aSmrg case " $deplibs " in 8817e169010aSmrg *" $path "*) ;; 8818e169010aSmrg *) deplibs="$path $deplibs" ;; 8819e169010aSmrg esac 8820e169010aSmrg done 8821e169010aSmrg fi # link_all_deplibs != no 8822e169010aSmrg fi # linkmode = lib 8823e169010aSmrg done # for deplib in $libs 88249d0ccd10Smrg if test link = "$pass"; then 88259d0ccd10Smrg if test prog = "$linkmode"; then 8826e169010aSmrg compile_deplibs="$new_inherited_linker_flags $compile_deplibs" 8827e169010aSmrg finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" 8828e169010aSmrg else 8829e8ead290Smrg compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 8830e169010aSmrg fi 8831e169010aSmrg fi 88329d0ccd10Smrg dependency_libs=$newdependency_libs 88339d0ccd10Smrg if test dlpreopen = "$pass"; then 8834e169010aSmrg # Link the dlpreopened libraries before other libraries 8835e169010aSmrg for deplib in $save_deplibs; do 8836e169010aSmrg deplibs="$deplib $deplibs" 8837e169010aSmrg done 8838e169010aSmrg fi 88399d0ccd10Smrg if test dlopen != "$pass"; then 88409d0ccd10Smrg test conv = "$pass" || { 8841e169010aSmrg # Make sure lib_search_path contains only unique directories. 8842e169010aSmrg lib_search_path= 8843e169010aSmrg for dir in $newlib_search_path; do 8844e169010aSmrg case "$lib_search_path " in 8845e169010aSmrg *" $dir "*) ;; 8846c63293b5Smrg *) func_append lib_search_path " $dir" ;; 8847e169010aSmrg esac 8848e169010aSmrg done 8849e169010aSmrg newlib_search_path= 88509d0ccd10Smrg } 8851e169010aSmrg 88529d0ccd10Smrg if test prog,link = "$linkmode,$pass"; then 8853e169010aSmrg vars="compile_deplibs finalize_deplibs" 88549d0ccd10Smrg else 88559d0ccd10Smrg vars=deplibs 8856e169010aSmrg fi 8857e169010aSmrg for var in $vars dependency_libs; do 8858e169010aSmrg # Add libraries to $var in reverse order 8859e169010aSmrg eval tmp_libs=\"\$$var\" 8860e169010aSmrg new_libs= 8861e169010aSmrg for deplib in $tmp_libs; do 8862e169010aSmrg # FIXME: Pedantically, this is the right thing to do, so 8863e169010aSmrg # that some nasty dependency loop isn't accidentally 8864e169010aSmrg # broken: 8865e169010aSmrg #new_libs="$deplib $new_libs" 8866e169010aSmrg # Pragmatically, this seems to cause very few problems in 8867e169010aSmrg # practice: 8868e169010aSmrg case $deplib in 8869e169010aSmrg -L*) new_libs="$deplib $new_libs" ;; 8870e169010aSmrg -R*) ;; 8871e169010aSmrg *) 8872e169010aSmrg # And here is the reason: when a library appears more 8873e169010aSmrg # than once as an explicit dependence of a library, or 8874e169010aSmrg # is implicitly linked in more than once by the 8875e169010aSmrg # compiler, it is considered special, and multiple 8876e169010aSmrg # occurrences thereof are not removed. Compare this 8877e169010aSmrg # with having the same library being listed as a 8878e169010aSmrg # dependency of multiple other libraries: in this case, 8879e169010aSmrg # we know (pedantically, we assume) the library does not 8880e169010aSmrg # need to be listed more than once, so we keep only the 8881e169010aSmrg # last copy. This is not always right, but it is rare 8882e169010aSmrg # enough that we require users that really mean to play 8883e169010aSmrg # such unportable linking tricks to link the library 8884e169010aSmrg # using -Wl,-lname, so that libtool does not consider it 8885e169010aSmrg # for duplicate removal. 8886e169010aSmrg case " $specialdeplibs " in 8887e169010aSmrg *" $deplib "*) new_libs="$deplib $new_libs" ;; 8888e169010aSmrg *) 8889e169010aSmrg case " $new_libs " in 8890e169010aSmrg *" $deplib "*) ;; 8891e169010aSmrg *) new_libs="$deplib $new_libs" ;; 8892e169010aSmrg esac 8893e169010aSmrg ;; 8894e169010aSmrg esac 8895e169010aSmrg ;; 8896e169010aSmrg esac 8897e169010aSmrg done 8898e169010aSmrg tmp_libs= 8899e169010aSmrg for deplib in $new_libs; do 8900e169010aSmrg case $deplib in 8901e169010aSmrg -L*) 8902e169010aSmrg case " $tmp_libs " in 8903e169010aSmrg *" $deplib "*) ;; 8904c63293b5Smrg *) func_append tmp_libs " $deplib" ;; 8905e169010aSmrg esac 8906e169010aSmrg ;; 8907c63293b5Smrg *) func_append tmp_libs " $deplib" ;; 8908e169010aSmrg esac 8909e169010aSmrg done 8910e169010aSmrg eval $var=\"$tmp_libs\" 8911e169010aSmrg done # for var 8912e169010aSmrg fi 89139d0ccd10Smrg 89149d0ccd10Smrg # Add Sun CC postdeps if required: 89159d0ccd10Smrg test CXX = "$tagname" && { 89169d0ccd10Smrg case $host_os in 89179d0ccd10Smrg linux*) 89180ea508b1Smrg case `$CC -V 2>&1 | $SED 5q` in 89199d0ccd10Smrg *Sun\ C*) # Sun C++ 5.9 89209d0ccd10Smrg func_suncc_cstd_abi 89219d0ccd10Smrg 89229d0ccd10Smrg if test no != "$suncc_use_cstd_abi"; then 89239d0ccd10Smrg func_append postdeps ' -library=Cstd -library=Crun' 89249d0ccd10Smrg fi 89259d0ccd10Smrg ;; 89269d0ccd10Smrg esac 89279d0ccd10Smrg ;; 89289d0ccd10Smrg 89299d0ccd10Smrg solaris*) 89309d0ccd10Smrg func_cc_basename "$CC" 89319d0ccd10Smrg case $func_cc_basename_result in 89329d0ccd10Smrg CC* | sunCC*) 89339d0ccd10Smrg func_suncc_cstd_abi 89349d0ccd10Smrg 89359d0ccd10Smrg if test no != "$suncc_use_cstd_abi"; then 89369d0ccd10Smrg func_append postdeps ' -library=Cstd -library=Crun' 89379d0ccd10Smrg fi 89389d0ccd10Smrg ;; 89399d0ccd10Smrg esac 89409d0ccd10Smrg ;; 89419d0ccd10Smrg esac 89429d0ccd10Smrg } 89439d0ccd10Smrg 8944e169010aSmrg # Last step: remove runtime libs from dependency_libs 8945e169010aSmrg # (they stay in deplibs) 8946e169010aSmrg tmp_libs= 89479d0ccd10Smrg for i in $dependency_libs; do 8948e169010aSmrg case " $predeps $postdeps $compiler_lib_search_path " in 8949e169010aSmrg *" $i "*) 89509d0ccd10Smrg i= 8951e169010aSmrg ;; 8952e169010aSmrg esac 89539d0ccd10Smrg if test -n "$i"; then 8954c63293b5Smrg func_append tmp_libs " $i" 8955e169010aSmrg fi 8956e169010aSmrg done 8957e169010aSmrg dependency_libs=$tmp_libs 8958e169010aSmrg done # for pass 89599d0ccd10Smrg if test prog = "$linkmode"; then 89609d0ccd10Smrg dlfiles=$newdlfiles 8961e169010aSmrg fi 89629d0ccd10Smrg if test prog = "$linkmode" || test lib = "$linkmode"; then 89639d0ccd10Smrg dlprefiles=$newdlprefiles 8964e169010aSmrg fi 8965e169010aSmrg 8966e169010aSmrg case $linkmode in 8967e169010aSmrg oldlib) 89689d0ccd10Smrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 89699d0ccd10Smrg func_warning "'-dlopen' is ignored for archives" 8970e169010aSmrg fi 8971e169010aSmrg 8972e169010aSmrg case " $deplibs" in 8973e169010aSmrg *\ -l* | *\ -L*) 89749d0ccd10Smrg func_warning "'-l' and '-L' are ignored for archives" ;; 8975e169010aSmrg esac 8976e169010aSmrg 8977e169010aSmrg test -n "$rpath" && \ 89789d0ccd10Smrg func_warning "'-rpath' is ignored for archives" 8979e169010aSmrg 8980e169010aSmrg test -n "$xrpath" && \ 89819d0ccd10Smrg func_warning "'-R' is ignored for archives" 8982e169010aSmrg 8983e169010aSmrg test -n "$vinfo" && \ 89849d0ccd10Smrg func_warning "'-version-info/-version-number' is ignored for archives" 8985e169010aSmrg 8986e169010aSmrg test -n "$release" && \ 89879d0ccd10Smrg func_warning "'-release' is ignored for archives" 8988e169010aSmrg 8989e169010aSmrg test -n "$export_symbols$export_symbols_regex" && \ 89909d0ccd10Smrg func_warning "'-export-symbols' is ignored for archives" 8991e169010aSmrg 8992e169010aSmrg # Now set the variables for building old libraries. 8993e169010aSmrg build_libtool_libs=no 89949d0ccd10Smrg oldlibs=$output 8995c63293b5Smrg func_append objs "$old_deplibs" 8996e169010aSmrg ;; 8997e169010aSmrg 8998e169010aSmrg lib) 89999d0ccd10Smrg # Make sure we only generate libraries of the form 'libNAME.la'. 9000e169010aSmrg case $outputname in 9001e169010aSmrg lib*) 9002e169010aSmrg func_stripname 'lib' '.la' "$outputname" 9003e169010aSmrg name=$func_stripname_result 9004e169010aSmrg eval shared_ext=\"$shrext_cmds\" 9005e169010aSmrg eval libname=\"$libname_spec\" 9006e169010aSmrg ;; 9007e169010aSmrg *) 90089d0ccd10Smrg test no = "$module" \ 90099d0ccd10Smrg && func_fatal_help "libtool library '$output' must begin with 'lib'" 9010e169010aSmrg 90119d0ccd10Smrg if test no != "$need_lib_prefix"; then 9012e169010aSmrg # Add the "lib" prefix for modules if required 9013e169010aSmrg func_stripname '' '.la' "$outputname" 9014e169010aSmrg name=$func_stripname_result 9015e169010aSmrg eval shared_ext=\"$shrext_cmds\" 9016e169010aSmrg eval libname=\"$libname_spec\" 9017e169010aSmrg else 9018e169010aSmrg func_stripname '' '.la' "$outputname" 9019e169010aSmrg libname=$func_stripname_result 9020e169010aSmrg fi 9021e169010aSmrg ;; 9022e169010aSmrg esac 9023e169010aSmrg 9024e169010aSmrg if test -n "$objs"; then 90259d0ccd10Smrg if test pass_all != "$deplibs_check_method"; then 90269d0ccd10Smrg func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs" 9027e169010aSmrg else 9028e8ead290Smrg echo 9029e169010aSmrg $ECHO "*** Warning: Linking the shared library $output against the non-libtool" 9030e169010aSmrg $ECHO "*** objects $objs is not portable!" 9031c63293b5Smrg func_append libobjs " $objs" 9032e169010aSmrg fi 9033e169010aSmrg fi 9034e169010aSmrg 90359d0ccd10Smrg test no = "$dlself" \ 90369d0ccd10Smrg || func_warning "'-dlopen self' is ignored for libtool libraries" 9037e169010aSmrg 9038e169010aSmrg set dummy $rpath 9039e169010aSmrg shift 90409d0ccd10Smrg test 1 -lt "$#" \ 90419d0ccd10Smrg && func_warning "ignoring multiple '-rpath's for a libtool library" 9042e169010aSmrg 90439d0ccd10Smrg install_libdir=$1 9044e169010aSmrg 9045e169010aSmrg oldlibs= 9046e169010aSmrg if test -z "$rpath"; then 90479d0ccd10Smrg if test yes = "$build_libtool_libs"; then 9048e169010aSmrg # Building a libtool convenience library. 90499d0ccd10Smrg # Some compilers have problems with a '.al' extension so 9050e169010aSmrg # convenience libraries should have the same extension an 9051e169010aSmrg # archive normally would. 9052e169010aSmrg oldlibs="$output_objdir/$libname.$libext $oldlibs" 9053e169010aSmrg build_libtool_libs=convenience 9054e169010aSmrg build_old_libs=yes 9055e169010aSmrg fi 9056e169010aSmrg 9057e169010aSmrg test -n "$vinfo" && \ 90589d0ccd10Smrg func_warning "'-version-info/-version-number' is ignored for convenience libraries" 9059e169010aSmrg 9060e169010aSmrg test -n "$release" && \ 90619d0ccd10Smrg func_warning "'-release' is ignored for convenience libraries" 9062e169010aSmrg else 9063e169010aSmrg 9064e169010aSmrg # Parse the version information argument. 90659d0ccd10Smrg save_ifs=$IFS; IFS=: 9066e169010aSmrg set dummy $vinfo 0 0 0 9067e169010aSmrg shift 90689d0ccd10Smrg IFS=$save_ifs 9069e169010aSmrg 9070e169010aSmrg test -n "$7" && \ 90719d0ccd10Smrg func_fatal_help "too many parameters to '-version-info'" 9072e169010aSmrg 9073e169010aSmrg # convert absolute version numbers to libtool ages 9074e169010aSmrg # this retains compatibility with .la files and attempts 9075e169010aSmrg # to make the code below a bit more comprehensible 9076e169010aSmrg 9077e169010aSmrg case $vinfo_number in 9078e169010aSmrg yes) 90799d0ccd10Smrg number_major=$1 90809d0ccd10Smrg number_minor=$2 90819d0ccd10Smrg number_revision=$3 9082e169010aSmrg # 9083e169010aSmrg # There are really only two kinds -- those that 9084e169010aSmrg # use the current revision as the major version 9085e169010aSmrg # and those that subtract age and use age as 9086e169010aSmrg # a minor version. But, then there is irix 90879d0ccd10Smrg # that has an extra 1 added just for fun 9088e169010aSmrg # 9089e169010aSmrg case $version_type in 9090e6d5e4e0Smrg # correct linux to gnu/linux during the next big refactor 90910ea508b1Smrg darwin|freebsd-elf|linux|midnightbsd-elf|osf|windows|none) 9092e169010aSmrg func_arith $number_major + $number_minor 9093e169010aSmrg current=$func_arith_result 90949d0ccd10Smrg age=$number_minor 90959d0ccd10Smrg revision=$number_revision 9096e169010aSmrg ;; 90979d0ccd10Smrg freebsd-aout|qnx|sunos) 90989d0ccd10Smrg current=$number_major 90999d0ccd10Smrg revision=$number_minor 91009d0ccd10Smrg age=0 9101e169010aSmrg ;; 9102e169010aSmrg irix|nonstopux) 9103e169010aSmrg func_arith $number_major + $number_minor 9104e169010aSmrg current=$func_arith_result 91059d0ccd10Smrg age=$number_minor 91069d0ccd10Smrg revision=$number_minor 9107e169010aSmrg lt_irix_increment=no 9108e169010aSmrg ;; 91096b7436aeSmrg *) 91106b7436aeSmrg func_fatal_configuration "$modename: unknown library version type '$version_type'" 91116b7436aeSmrg ;; 9112e169010aSmrg esac 9113e169010aSmrg ;; 9114e169010aSmrg no) 91159d0ccd10Smrg current=$1 91169d0ccd10Smrg revision=$2 91179d0ccd10Smrg age=$3 9118e169010aSmrg ;; 9119e169010aSmrg esac 9120e169010aSmrg 9121e169010aSmrg # Check that each of the things are valid numbers. 9122e169010aSmrg case $current in 9123e169010aSmrg 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]) ;; 9124e169010aSmrg *) 91259d0ccd10Smrg func_error "CURRENT '$current' must be a nonnegative integer" 91269d0ccd10Smrg func_fatal_error "'$vinfo' is not valid version information" 9127e169010aSmrg ;; 9128e169010aSmrg esac 9129e169010aSmrg 9130e169010aSmrg case $revision in 9131e169010aSmrg 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]) ;; 9132e169010aSmrg *) 91339d0ccd10Smrg func_error "REVISION '$revision' must be a nonnegative integer" 91349d0ccd10Smrg func_fatal_error "'$vinfo' is not valid version information" 9135e169010aSmrg ;; 9136e169010aSmrg esac 9137e169010aSmrg 9138e169010aSmrg case $age in 9139e169010aSmrg 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]) ;; 9140e169010aSmrg *) 91419d0ccd10Smrg func_error "AGE '$age' must be a nonnegative integer" 91429d0ccd10Smrg func_fatal_error "'$vinfo' is not valid version information" 9143e169010aSmrg ;; 9144e169010aSmrg esac 9145e169010aSmrg 9146e169010aSmrg if test "$age" -gt "$current"; then 91479d0ccd10Smrg func_error "AGE '$age' is greater than the current interface number '$current'" 91489d0ccd10Smrg func_fatal_error "'$vinfo' is not valid version information" 9149e169010aSmrg fi 9150e169010aSmrg 9151e169010aSmrg # Calculate the version variables. 9152e169010aSmrg major= 9153e169010aSmrg versuffix= 9154e169010aSmrg verstring= 9155e169010aSmrg case $version_type in 9156e169010aSmrg none) ;; 9157e169010aSmrg 9158e169010aSmrg darwin) 9159e169010aSmrg # Like Linux, but with the current version available in 9160e169010aSmrg # verstring for coding it into the library header 9161e169010aSmrg func_arith $current - $age 9162e169010aSmrg major=.$func_arith_result 91639d0ccd10Smrg versuffix=$major.$age.$revision 9164e169010aSmrg # Darwin ld doesn't like 0 for these options... 9165e169010aSmrg func_arith $current + 1 9166e169010aSmrg minor_current=$func_arith_result 91679d0ccd10Smrg xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" 9168e169010aSmrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 91699d0ccd10Smrg # On Darwin other compilers 91709d0ccd10Smrg case $CC in 91719d0ccd10Smrg nagfor*) 91729d0ccd10Smrg verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" 91739d0ccd10Smrg ;; 91749d0ccd10Smrg *) 91759d0ccd10Smrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 91769d0ccd10Smrg ;; 91779d0ccd10Smrg esac 9178e169010aSmrg ;; 9179e169010aSmrg 9180e169010aSmrg freebsd-aout) 91819d0ccd10Smrg major=.$current 91829d0ccd10Smrg versuffix=.$current.$revision 9183e169010aSmrg ;; 9184e169010aSmrg 91850ea508b1Smrg freebsd-elf | midnightbsd-elf) 91869d0ccd10Smrg func_arith $current - $age 91879d0ccd10Smrg major=.$func_arith_result 91889d0ccd10Smrg versuffix=$major.$age.$revision 9189e169010aSmrg ;; 9190e169010aSmrg 9191e169010aSmrg irix | nonstopux) 91929d0ccd10Smrg if test no = "$lt_irix_increment"; then 9193e169010aSmrg func_arith $current - $age 9194e169010aSmrg else 9195e169010aSmrg func_arith $current - $age + 1 9196e169010aSmrg fi 9197e169010aSmrg major=$func_arith_result 9198e169010aSmrg 9199e169010aSmrg case $version_type in 9200e169010aSmrg nonstopux) verstring_prefix=nonstopux ;; 9201e169010aSmrg *) verstring_prefix=sgi ;; 9202e169010aSmrg esac 92039d0ccd10Smrg verstring=$verstring_prefix$major.$revision 9204e169010aSmrg 9205e169010aSmrg # Add in all the interfaces that we are compatible with. 9206e169010aSmrg loop=$revision 92079d0ccd10Smrg while test 0 -ne "$loop"; do 9208e169010aSmrg func_arith $revision - $loop 9209e169010aSmrg iface=$func_arith_result 9210e169010aSmrg func_arith $loop - 1 9211e169010aSmrg loop=$func_arith_result 92129d0ccd10Smrg verstring=$verstring_prefix$major.$iface:$verstring 9213e169010aSmrg done 9214e169010aSmrg 92159d0ccd10Smrg # Before this point, $major must not contain '.'. 9216e169010aSmrg major=.$major 92179d0ccd10Smrg versuffix=$major.$revision 9218e169010aSmrg ;; 9219e169010aSmrg 9220e6d5e4e0Smrg linux) # correct to gnu/linux during the next big refactor 9221e169010aSmrg func_arith $current - $age 9222e169010aSmrg major=.$func_arith_result 92239d0ccd10Smrg versuffix=$major.$age.$revision 9224e169010aSmrg ;; 9225e169010aSmrg 9226e169010aSmrg osf) 9227e169010aSmrg func_arith $current - $age 9228e169010aSmrg major=.$func_arith_result 92299d0ccd10Smrg versuffix=.$current.$age.$revision 92309d0ccd10Smrg verstring=$current.$age.$revision 9231e169010aSmrg 9232e169010aSmrg # Add in all the interfaces that we are compatible with. 9233e169010aSmrg loop=$age 92349d0ccd10Smrg while test 0 -ne "$loop"; do 9235e169010aSmrg func_arith $current - $loop 9236e169010aSmrg iface=$func_arith_result 9237e169010aSmrg func_arith $loop - 1 9238e169010aSmrg loop=$func_arith_result 92399d0ccd10Smrg verstring=$verstring:$iface.0 9240e169010aSmrg done 9241e169010aSmrg 9242e169010aSmrg # Make executables depend on our current version. 92439d0ccd10Smrg func_append verstring ":$current.0" 9244e169010aSmrg ;; 9245e169010aSmrg 9246e169010aSmrg qnx) 92479d0ccd10Smrg major=.$current 92489d0ccd10Smrg versuffix=.$current 92499d0ccd10Smrg ;; 92509d0ccd10Smrg 92519d0ccd10Smrg sco) 92529d0ccd10Smrg major=.$current 92539d0ccd10Smrg versuffix=.$current 9254e169010aSmrg ;; 9255e169010aSmrg 9256e169010aSmrg sunos) 92579d0ccd10Smrg major=.$current 92589d0ccd10Smrg versuffix=.$current.$revision 9259e169010aSmrg ;; 9260e169010aSmrg 9261e169010aSmrg windows) 9262e169010aSmrg # Use '-' rather than '.', since we only want one 92639d0ccd10Smrg # extension on DOS 8.3 file systems. 9264e169010aSmrg func_arith $current - $age 9265e169010aSmrg major=$func_arith_result 92669d0ccd10Smrg versuffix=-$major 9267e169010aSmrg ;; 9268e169010aSmrg 9269e169010aSmrg *) 92709d0ccd10Smrg func_fatal_configuration "unknown library version type '$version_type'" 9271e169010aSmrg ;; 9272e169010aSmrg esac 9273e169010aSmrg 9274e169010aSmrg # Clear the version info if we defaulted, and they specified a release. 9275e169010aSmrg if test -z "$vinfo" && test -n "$release"; then 9276e169010aSmrg major= 9277e169010aSmrg case $version_type in 9278e169010aSmrg darwin) 9279e169010aSmrg # we can't check for "0.0" in archive_cmds due to quoting 9280e169010aSmrg # problems, so we reset it completely 9281e169010aSmrg verstring= 9282e169010aSmrg ;; 9283e169010aSmrg *) 92849d0ccd10Smrg verstring=0.0 9285e169010aSmrg ;; 9286e169010aSmrg esac 92879d0ccd10Smrg if test no = "$need_version"; then 9288e169010aSmrg versuffix= 9289e169010aSmrg else 92909d0ccd10Smrg versuffix=.0.0 9291e169010aSmrg fi 9292e169010aSmrg fi 9293e169010aSmrg 9294e169010aSmrg # Remove version info from name if versioning should be avoided 92959d0ccd10Smrg if test yes,no = "$avoid_version,$need_version"; then 9296e169010aSmrg major= 9297e169010aSmrg versuffix= 92989d0ccd10Smrg verstring= 9299e169010aSmrg fi 9300e169010aSmrg 9301e169010aSmrg # Check to see if the archive will have undefined symbols. 93029d0ccd10Smrg if test yes = "$allow_undefined"; then 93039d0ccd10Smrg if test unsupported = "$allow_undefined_flag"; then 93049d0ccd10Smrg if test yes = "$build_old_libs"; then 93059d0ccd10Smrg func_warning "undefined symbols not allowed in $host shared libraries; building static only" 93069d0ccd10Smrg build_libtool_libs=no 93079d0ccd10Smrg else 93089d0ccd10Smrg func_fatal_error "can't build $host shared library unless -no-undefined is specified" 93099d0ccd10Smrg fi 9310e169010aSmrg fi 9311e169010aSmrg else 9312e169010aSmrg # Don't allow undefined symbols. 93139d0ccd10Smrg allow_undefined_flag=$no_undefined_flag 9314e169010aSmrg fi 9315e169010aSmrg 9316e169010aSmrg fi 9317e169010aSmrg 93189d0ccd10Smrg func_generate_dlsyms "$libname" "$libname" : 9319c63293b5Smrg func_append libobjs " $symfileobj" 93209d0ccd10Smrg test " " = "$libobjs" && libobjs= 9321e169010aSmrg 93229d0ccd10Smrg if test relink != "$opt_mode"; then 9323e169010aSmrg # Remove our outputs, but don't remove object files since they 9324e169010aSmrg # may have been created when compiling PIC objects. 9325e169010aSmrg removelist= 9326e169010aSmrg tempremovelist=`$ECHO "$output_objdir/*"` 9327e169010aSmrg for p in $tempremovelist; do 9328e169010aSmrg case $p in 9329e169010aSmrg *.$objext | *.gcno) 9330e169010aSmrg ;; 93319d0ccd10Smrg $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/$libname$release.*) 93329d0ccd10Smrg if test -n "$precious_files_regex"; then 9333e169010aSmrg if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 9334e169010aSmrg then 9335e169010aSmrg continue 9336e169010aSmrg fi 9337e169010aSmrg fi 9338c63293b5Smrg func_append removelist " $p" 9339e169010aSmrg ;; 9340e169010aSmrg *) ;; 9341e169010aSmrg esac 9342e169010aSmrg done 9343e169010aSmrg test -n "$removelist" && \ 9344e169010aSmrg func_show_eval "${RM}r \$removelist" 9345e169010aSmrg fi 9346e169010aSmrg 9347e169010aSmrg # Now set the variables for building old libraries. 93489d0ccd10Smrg if test yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; then 9349c63293b5Smrg func_append oldlibs " $output_objdir/$libname.$libext" 9350e169010aSmrg 9351e169010aSmrg # Transform .lo files to .o files. 93529d0ccd10Smrg oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; $lo2o" | $NL2SP` 9353e169010aSmrg fi 9354e169010aSmrg 9355e169010aSmrg # Eliminate all temporary directories. 9356e169010aSmrg #for path in $notinst_path; do 9357e8ead290Smrg # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` 9358e8ead290Smrg # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` 9359e8ead290Smrg # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` 9360e169010aSmrg #done 9361e169010aSmrg 9362e169010aSmrg if test -n "$xrpath"; then 9363e169010aSmrg # If the user specified any rpath flags, then add them. 9364e169010aSmrg temp_xrpath= 9365e169010aSmrg for libdir in $xrpath; do 9366c63293b5Smrg func_replace_sysroot "$libdir" 9367c63293b5Smrg func_append temp_xrpath " -R$func_replace_sysroot_result" 9368e169010aSmrg case "$finalize_rpath " in 9369e169010aSmrg *" $libdir "*) ;; 9370c63293b5Smrg *) func_append finalize_rpath " $libdir" ;; 9371e169010aSmrg esac 9372e169010aSmrg done 93739d0ccd10Smrg if test yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; then 9374e169010aSmrg dependency_libs="$temp_xrpath $dependency_libs" 9375e169010aSmrg fi 9376e169010aSmrg fi 9377e169010aSmrg 9378e169010aSmrg # Make sure dlfiles contains only unique files that won't be dlpreopened 93799d0ccd10Smrg old_dlfiles=$dlfiles 9380e169010aSmrg dlfiles= 9381e169010aSmrg for lib in $old_dlfiles; do 9382e169010aSmrg case " $dlprefiles $dlfiles " in 9383e169010aSmrg *" $lib "*) ;; 9384c63293b5Smrg *) func_append dlfiles " $lib" ;; 9385e169010aSmrg esac 9386e169010aSmrg done 9387e169010aSmrg 9388e169010aSmrg # Make sure dlprefiles contains only unique files 93899d0ccd10Smrg old_dlprefiles=$dlprefiles 9390e169010aSmrg dlprefiles= 9391e169010aSmrg for lib in $old_dlprefiles; do 9392e169010aSmrg case "$dlprefiles " in 9393e169010aSmrg *" $lib "*) ;; 9394c63293b5Smrg *) func_append dlprefiles " $lib" ;; 9395e169010aSmrg esac 9396e169010aSmrg done 9397e169010aSmrg 93989d0ccd10Smrg if test yes = "$build_libtool_libs"; then 9399e169010aSmrg if test -n "$rpath"; then 9400e169010aSmrg case $host in 9401e8ead290Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) 9402e169010aSmrg # these systems don't actually have a c library (as such)! 9403e169010aSmrg ;; 9404e169010aSmrg *-*-rhapsody* | *-*-darwin1.[012]) 9405e169010aSmrg # Rhapsody C library is in the System framework 9406c63293b5Smrg func_append deplibs " System.ltframework" 9407e169010aSmrg ;; 9408e169010aSmrg *-*-netbsd*) 9409e169010aSmrg # Don't link with libc until the a.out ld.so is fixed. 9410e169010aSmrg ;; 94110ea508b1Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-midnightbsd*) 9412e169010aSmrg # Do not include libc due to us having libc/libc_r. 9413e169010aSmrg ;; 9414e169010aSmrg *-*-sco3.2v5* | *-*-sco5v6*) 9415e169010aSmrg # Causes problems with __ctype 9416e169010aSmrg ;; 9417e169010aSmrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 9418e169010aSmrg # Compiler inserts libc in the correct place for threads to work 9419e169010aSmrg ;; 9420e169010aSmrg *) 9421e169010aSmrg # Add libc to deplibs on all other systems if necessary. 94229d0ccd10Smrg if test yes = "$build_libtool_need_lc"; then 9423c63293b5Smrg func_append deplibs " -lc" 9424e169010aSmrg fi 9425e169010aSmrg ;; 9426e169010aSmrg esac 9427e169010aSmrg fi 9428e169010aSmrg 9429e169010aSmrg # Transform deplibs into only deplibs that can be linked in shared. 9430e169010aSmrg name_save=$name 9431e169010aSmrg libname_save=$libname 9432e169010aSmrg release_save=$release 9433e169010aSmrg versuffix_save=$versuffix 9434e169010aSmrg major_save=$major 9435e169010aSmrg # I'm not sure if I'm treating the release correctly. I think 9436e169010aSmrg # release should show up in the -l (ie -lgmp5) so we don't want to 9437e169010aSmrg # add it in twice. Is that correct? 94389d0ccd10Smrg release= 94399d0ccd10Smrg versuffix= 94409d0ccd10Smrg major= 9441e169010aSmrg newdeplibs= 9442e169010aSmrg droppeddeps=no 9443e169010aSmrg case $deplibs_check_method in 9444e169010aSmrg pass_all) 9445e169010aSmrg # Don't check for shared/static. Everything works. 9446e169010aSmrg # This might be a little naive. We might want to check 9447e169010aSmrg # whether the library exists or not. But this is on 9448e169010aSmrg # osf3 & osf4 and I'm not really sure... Just 9449e169010aSmrg # implementing what was already the behavior. 9450e169010aSmrg newdeplibs=$deplibs 9451e169010aSmrg ;; 9452e169010aSmrg test_compile) 9453e169010aSmrg # This code stresses the "libraries are programs" paradigm to its 9454e169010aSmrg # limits. Maybe even breaks it. We compile a program, linking it 9455e169010aSmrg # against the deplibs as a proxy for the library. Then we can check 9456e169010aSmrg # whether they linked in statically or dynamically with ldd. 9457e169010aSmrg $opt_dry_run || $RM conftest.c 9458e169010aSmrg cat > conftest.c <<EOF 9459e169010aSmrg int main() { return 0; } 9460e169010aSmrgEOF 9461e169010aSmrg $opt_dry_run || $RM conftest 9462e169010aSmrg if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then 9463e169010aSmrg ldd_output=`ldd conftest` 9464e169010aSmrg for i in $deplibs; do 9465e169010aSmrg case $i in 9466e169010aSmrg -l*) 9467e169010aSmrg func_stripname -l '' "$i" 9468e169010aSmrg name=$func_stripname_result 94699d0ccd10Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9470e169010aSmrg case " $predeps $postdeps " in 9471e169010aSmrg *" $i "*) 9472c63293b5Smrg func_append newdeplibs " $i" 94739d0ccd10Smrg i= 9474e169010aSmrg ;; 9475e169010aSmrg esac 9476e169010aSmrg fi 94779d0ccd10Smrg if test -n "$i"; then 9478e169010aSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 9479e169010aSmrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 9480e169010aSmrg set dummy $deplib_matches; shift 9481e169010aSmrg deplib_match=$1 94829d0ccd10Smrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then 9483c63293b5Smrg func_append newdeplibs " $i" 9484e169010aSmrg else 9485e169010aSmrg droppeddeps=yes 9486e8ead290Smrg echo 9487e169010aSmrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 9488e8ead290Smrg echo "*** I have the capability to make that library automatically link in when" 9489e8ead290Smrg echo "*** you link to this library. But I can only do this if you have a" 9490e8ead290Smrg echo "*** shared version of the library, which I believe you do not have" 9491e8ead290Smrg echo "*** because a test_compile did reveal that the linker did not use it for" 9492e8ead290Smrg echo "*** its dynamic dependency list that programs get resolved with at runtime." 9493e169010aSmrg fi 9494e169010aSmrg fi 9495e169010aSmrg ;; 9496e169010aSmrg *) 9497c63293b5Smrg func_append newdeplibs " $i" 9498e169010aSmrg ;; 9499e169010aSmrg esac 9500e169010aSmrg done 9501e169010aSmrg else 9502e169010aSmrg # Error occurred in the first compile. Let's try to salvage 9503e169010aSmrg # the situation: Compile a separate program for each library. 9504e169010aSmrg for i in $deplibs; do 9505e169010aSmrg case $i in 9506e169010aSmrg -l*) 9507e169010aSmrg func_stripname -l '' "$i" 9508e169010aSmrg name=$func_stripname_result 9509e169010aSmrg $opt_dry_run || $RM conftest 9510e169010aSmrg if $LTCC $LTCFLAGS -o conftest conftest.c $i; then 9511e169010aSmrg ldd_output=`ldd conftest` 95129d0ccd10Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9513e169010aSmrg case " $predeps $postdeps " in 9514e169010aSmrg *" $i "*) 9515c63293b5Smrg func_append newdeplibs " $i" 95169d0ccd10Smrg i= 9517e169010aSmrg ;; 9518e169010aSmrg esac 9519e169010aSmrg fi 95209d0ccd10Smrg if test -n "$i"; then 9521e169010aSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 9522e169010aSmrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 9523e169010aSmrg set dummy $deplib_matches; shift 9524e169010aSmrg deplib_match=$1 95259d0ccd10Smrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then 9526c63293b5Smrg func_append newdeplibs " $i" 9527e169010aSmrg else 9528e169010aSmrg droppeddeps=yes 9529e8ead290Smrg echo 9530e169010aSmrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 9531e8ead290Smrg echo "*** I have the capability to make that library automatically link in when" 9532e8ead290Smrg echo "*** you link to this library. But I can only do this if you have a" 9533e8ead290Smrg echo "*** shared version of the library, which you do not appear to have" 9534e8ead290Smrg echo "*** because a test_compile did reveal that the linker did not use this one" 9535e8ead290Smrg echo "*** as a dynamic dependency that programs can get resolved with at runtime." 9536e169010aSmrg fi 9537e169010aSmrg fi 9538e169010aSmrg else 9539e169010aSmrg droppeddeps=yes 9540e8ead290Smrg echo 9541e169010aSmrg $ECHO "*** Warning! Library $i is needed by this library but I was not able to" 9542e8ead290Smrg echo "*** make it link in! You will probably need to install it or some" 9543e8ead290Smrg echo "*** library that it depends on before this library will be fully" 9544e8ead290Smrg echo "*** functional. Installing it before continuing would be even better." 9545e169010aSmrg fi 9546e169010aSmrg ;; 9547e169010aSmrg *) 9548c63293b5Smrg func_append newdeplibs " $i" 9549e169010aSmrg ;; 9550e169010aSmrg esac 9551e169010aSmrg done 9552e169010aSmrg fi 9553e169010aSmrg ;; 9554e169010aSmrg file_magic*) 9555e169010aSmrg set dummy $deplibs_check_method; shift 9556e169010aSmrg file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 9557e169010aSmrg for a_deplib in $deplibs; do 9558e169010aSmrg case $a_deplib in 9559e169010aSmrg -l*) 9560e169010aSmrg func_stripname -l '' "$a_deplib" 9561e169010aSmrg name=$func_stripname_result 95629d0ccd10Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9563e169010aSmrg case " $predeps $postdeps " in 9564e169010aSmrg *" $a_deplib "*) 9565c63293b5Smrg func_append newdeplibs " $a_deplib" 95669d0ccd10Smrg a_deplib= 9567e169010aSmrg ;; 9568e169010aSmrg esac 9569e169010aSmrg fi 95709d0ccd10Smrg if test -n "$a_deplib"; then 9571e169010aSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 9572c63293b5Smrg if test -n "$file_magic_glob"; then 9573c63293b5Smrg libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob` 9574c63293b5Smrg else 9575c63293b5Smrg libnameglob=$libname 9576c63293b5Smrg fi 95779d0ccd10Smrg test yes = "$want_nocaseglob" && nocaseglob=`shopt -p nocaseglob` 9578e169010aSmrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 95799d0ccd10Smrg if test yes = "$want_nocaseglob"; then 9580c63293b5Smrg shopt -s nocaseglob 9581c63293b5Smrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 9582c63293b5Smrg $nocaseglob 9583c63293b5Smrg else 9584c63293b5Smrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 9585c63293b5Smrg fi 9586e169010aSmrg for potent_lib in $potential_libs; do 9587e169010aSmrg # Follow soft links. 9588e169010aSmrg if ls -lLd "$potent_lib" 2>/dev/null | 9589e169010aSmrg $GREP " -> " >/dev/null; then 9590e169010aSmrg continue 9591e169010aSmrg fi 9592e169010aSmrg # The statement above tries to avoid entering an 9593e169010aSmrg # endless loop below, in case of cyclic links. 9594e169010aSmrg # We might still enter an endless loop, since a link 9595e169010aSmrg # loop can be closed while we follow links, 9596e169010aSmrg # but so what? 95979d0ccd10Smrg potlib=$potent_lib 9598e169010aSmrg while test -h "$potlib" 2>/dev/null; do 95999d0ccd10Smrg potliblink=`ls -ld $potlib | $SED 's/.* -> //'` 9600e169010aSmrg case $potliblink in 96019d0ccd10Smrg [\\/]* | [A-Za-z]:[\\/]*) potlib=$potliblink;; 96029d0ccd10Smrg *) potlib=`$ECHO "$potlib" | $SED 's|[^/]*$||'`"$potliblink";; 9603e169010aSmrg esac 9604e169010aSmrg done 9605e169010aSmrg if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | 9606e169010aSmrg $SED -e 10q | 9607e169010aSmrg $EGREP "$file_magic_regex" > /dev/null; then 9608c63293b5Smrg func_append newdeplibs " $a_deplib" 96099d0ccd10Smrg a_deplib= 9610e169010aSmrg break 2 9611e169010aSmrg fi 9612e169010aSmrg done 9613e169010aSmrg done 9614e169010aSmrg fi 96159d0ccd10Smrg if test -n "$a_deplib"; then 9616e169010aSmrg droppeddeps=yes 9617e8ead290Smrg echo 9618e169010aSmrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 9619e8ead290Smrg echo "*** I have the capability to make that library automatically link in when" 9620e8ead290Smrg echo "*** you link to this library. But I can only do this if you have a" 9621e8ead290Smrg echo "*** shared version of the library, which you do not appear to have" 9622e8ead290Smrg echo "*** because I did check the linker path looking for a file starting" 96239d0ccd10Smrg if test -z "$potlib"; then 9624e169010aSmrg $ECHO "*** with $libname but no candidates were found. (...for file magic test)" 9625e169010aSmrg else 9626e169010aSmrg $ECHO "*** with $libname and none of the candidates passed a file format test" 9627e169010aSmrg $ECHO "*** using a file magic. Last file checked: $potlib" 9628e169010aSmrg fi 9629e169010aSmrg fi 9630e169010aSmrg ;; 9631e169010aSmrg *) 9632e169010aSmrg # Add a -L argument. 9633c63293b5Smrg func_append newdeplibs " $a_deplib" 9634e169010aSmrg ;; 9635e169010aSmrg esac 9636e169010aSmrg done # Gone through all deplibs. 9637e169010aSmrg ;; 9638e169010aSmrg match_pattern*) 9639e169010aSmrg set dummy $deplibs_check_method; shift 9640e169010aSmrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 9641e169010aSmrg for a_deplib in $deplibs; do 9642e169010aSmrg case $a_deplib in 9643e169010aSmrg -l*) 9644e169010aSmrg func_stripname -l '' "$a_deplib" 9645e169010aSmrg name=$func_stripname_result 96469d0ccd10Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9647e169010aSmrg case " $predeps $postdeps " in 9648e169010aSmrg *" $a_deplib "*) 9649c63293b5Smrg func_append newdeplibs " $a_deplib" 96509d0ccd10Smrg a_deplib= 9651e169010aSmrg ;; 9652e169010aSmrg esac 9653e169010aSmrg fi 96549d0ccd10Smrg if test -n "$a_deplib"; then 9655e169010aSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 9656e169010aSmrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 9657e169010aSmrg potential_libs=`ls $i/$libname[.-]* 2>/dev/null` 9658e169010aSmrg for potent_lib in $potential_libs; do 96599d0ccd10Smrg potlib=$potent_lib # see symlink-check above in file_magic test 9660e8ead290Smrg if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ 9661e169010aSmrg $EGREP "$match_pattern_regex" > /dev/null; then 9662c63293b5Smrg func_append newdeplibs " $a_deplib" 96639d0ccd10Smrg a_deplib= 9664e169010aSmrg break 2 9665e169010aSmrg fi 9666e169010aSmrg done 9667e169010aSmrg done 9668e169010aSmrg fi 96699d0ccd10Smrg if test -n "$a_deplib"; then 9670e169010aSmrg droppeddeps=yes 9671e8ead290Smrg echo 9672e169010aSmrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 9673e8ead290Smrg echo "*** I have the capability to make that library automatically link in when" 9674e8ead290Smrg echo "*** you link to this library. But I can only do this if you have a" 9675e8ead290Smrg echo "*** shared version of the library, which you do not appear to have" 9676e8ead290Smrg echo "*** because I did check the linker path looking for a file starting" 96779d0ccd10Smrg if test -z "$potlib"; then 9678e169010aSmrg $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" 9679e169010aSmrg else 9680e169010aSmrg $ECHO "*** with $libname and none of the candidates passed a file format test" 9681e169010aSmrg $ECHO "*** using a regex pattern. Last file checked: $potlib" 9682e169010aSmrg fi 9683e169010aSmrg fi 9684e169010aSmrg ;; 9685e169010aSmrg *) 9686e169010aSmrg # Add a -L argument. 9687c63293b5Smrg func_append newdeplibs " $a_deplib" 9688e169010aSmrg ;; 9689e169010aSmrg esac 9690e169010aSmrg done # Gone through all deplibs. 9691e169010aSmrg ;; 9692e169010aSmrg none | unknown | *) 96939d0ccd10Smrg newdeplibs= 9694e8ead290Smrg tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` 96959d0ccd10Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 96969d0ccd10Smrg for i in $predeps $postdeps; do 9697e169010aSmrg # can't use Xsed below, because $i might contain '/' 96989d0ccd10Smrg tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s|$i||"` 9699e169010aSmrg done 9700e169010aSmrg fi 9701e8ead290Smrg case $tmp_deplibs in 9702e8ead290Smrg *[!\ \ ]*) 9703e8ead290Smrg echo 97049d0ccd10Smrg if test none = "$deplibs_check_method"; then 9705e8ead290Smrg echo "*** Warning: inter-library dependencies are not supported in this platform." 9706e169010aSmrg else 9707e8ead290Smrg echo "*** Warning: inter-library dependencies are not known to be supported." 9708e169010aSmrg fi 9709e8ead290Smrg echo "*** All declared inter-library dependencies are being dropped." 9710e169010aSmrg droppeddeps=yes 9711e8ead290Smrg ;; 9712e8ead290Smrg esac 9713e169010aSmrg ;; 9714e169010aSmrg esac 9715e169010aSmrg versuffix=$versuffix_save 9716e169010aSmrg major=$major_save 9717e169010aSmrg release=$release_save 9718e169010aSmrg libname=$libname_save 9719e169010aSmrg name=$name_save 9720e169010aSmrg 9721e169010aSmrg case $host in 9722e169010aSmrg *-*-rhapsody* | *-*-darwin1.[012]) 9723e169010aSmrg # On Rhapsody replace the C library with the System framework 9724e8ead290Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` 9725e169010aSmrg ;; 9726e169010aSmrg esac 9727e169010aSmrg 97289d0ccd10Smrg if test yes = "$droppeddeps"; then 97299d0ccd10Smrg if test yes = "$module"; then 9730e8ead290Smrg echo 9731e8ead290Smrg echo "*** Warning: libtool could not satisfy all declared inter-library" 9732e169010aSmrg $ECHO "*** dependencies of module $libname. Therefore, libtool will create" 9733e8ead290Smrg echo "*** a static module, that should work as long as the dlopening" 9734e8ead290Smrg echo "*** application is linked with the -dlopen flag." 9735e169010aSmrg if test -z "$global_symbol_pipe"; then 9736e8ead290Smrg echo 9737e8ead290Smrg echo "*** However, this would only work if libtool was able to extract symbol" 97389d0ccd10Smrg echo "*** lists from a program, using 'nm' or equivalent, but libtool could" 9739e8ead290Smrg echo "*** not find such a program. So, this module is probably useless." 97409d0ccd10Smrg echo "*** 'nm' from GNU binutils and a full rebuild may help." 9741e169010aSmrg fi 97429d0ccd10Smrg if test no = "$build_old_libs"; then 97439d0ccd10Smrg oldlibs=$output_objdir/$libname.$libext 9744e169010aSmrg build_libtool_libs=module 9745e169010aSmrg build_old_libs=yes 9746e169010aSmrg else 9747e169010aSmrg build_libtool_libs=no 9748e169010aSmrg fi 9749e169010aSmrg else 9750e8ead290Smrg echo "*** The inter-library dependencies that have been dropped here will be" 9751e8ead290Smrg echo "*** automatically added whenever a program is linked with this library" 9752e8ead290Smrg echo "*** or is declared to -dlopen it." 9753e169010aSmrg 97549d0ccd10Smrg if test no = "$allow_undefined"; then 9755e8ead290Smrg echo 9756e8ead290Smrg echo "*** Since this library must not contain undefined symbols," 9757e8ead290Smrg echo "*** because either the platform does not support them or" 9758e8ead290Smrg echo "*** it was explicitly requested with -no-undefined," 9759e8ead290Smrg echo "*** libtool will only create a static version of it." 97609d0ccd10Smrg if test no = "$build_old_libs"; then 97619d0ccd10Smrg oldlibs=$output_objdir/$libname.$libext 9762e169010aSmrg build_libtool_libs=module 9763e169010aSmrg build_old_libs=yes 9764e169010aSmrg else 9765e169010aSmrg build_libtool_libs=no 9766e169010aSmrg fi 9767e169010aSmrg fi 9768e169010aSmrg fi 9769e169010aSmrg fi 9770e169010aSmrg # Done checking deplibs! 9771e169010aSmrg deplibs=$newdeplibs 9772e169010aSmrg fi 9773e169010aSmrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 9774e169010aSmrg case $host in 9775e169010aSmrg *-*-darwin*) 9776e8ead290Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 9777e8ead290Smrg new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 9778e8ead290Smrg deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 9779e169010aSmrg ;; 9780e169010aSmrg esac 9781e169010aSmrg 9782e169010aSmrg # move library search paths that coincide with paths to not yet 9783e169010aSmrg # installed libraries to the beginning of the library search list 9784e169010aSmrg new_libs= 9785e169010aSmrg for path in $notinst_path; do 9786e169010aSmrg case " $new_libs " in 9787e169010aSmrg *" -L$path/$objdir "*) ;; 9788e169010aSmrg *) 9789e169010aSmrg case " $deplibs " in 9790e169010aSmrg *" -L$path/$objdir "*) 9791c63293b5Smrg func_append new_libs " -L$path/$objdir" ;; 9792e169010aSmrg esac 9793e169010aSmrg ;; 9794e169010aSmrg esac 9795e169010aSmrg done 9796e169010aSmrg for deplib in $deplibs; do 9797e169010aSmrg case $deplib in 9798e169010aSmrg -L*) 9799e169010aSmrg case " $new_libs " in 9800e169010aSmrg *" $deplib "*) ;; 9801c63293b5Smrg *) func_append new_libs " $deplib" ;; 9802e169010aSmrg esac 9803e169010aSmrg ;; 9804c63293b5Smrg *) func_append new_libs " $deplib" ;; 9805e169010aSmrg esac 9806e169010aSmrg done 98079d0ccd10Smrg deplibs=$new_libs 9808e169010aSmrg 9809e169010aSmrg # All the library-specific variables (install_libdir is set above). 9810e169010aSmrg library_names= 9811e169010aSmrg old_library= 9812e169010aSmrg dlname= 9813e169010aSmrg 9814e169010aSmrg # Test again, we may have decided not to build it any more 98159d0ccd10Smrg if test yes = "$build_libtool_libs"; then 98169d0ccd10Smrg # Remove $wl instances when linking with ld. 9817e6d5e4e0Smrg # FIXME: should test the right _cmds variable. 9818e6d5e4e0Smrg case $archive_cmds in 9819e6d5e4e0Smrg *\$LD\ *) wl= ;; 9820e6d5e4e0Smrg esac 98219d0ccd10Smrg if test yes = "$hardcode_into_libs"; then 9822e169010aSmrg # Hardcode the library paths 9823e169010aSmrg hardcode_libdirs= 9824e169010aSmrg dep_rpath= 98259d0ccd10Smrg rpath=$finalize_rpath 98269d0ccd10Smrg test relink = "$opt_mode" || rpath=$compile_rpath$rpath 9827e169010aSmrg for libdir in $rpath; do 9828e169010aSmrg if test -n "$hardcode_libdir_flag_spec"; then 9829e169010aSmrg if test -n "$hardcode_libdir_separator"; then 9830c63293b5Smrg func_replace_sysroot "$libdir" 9831c63293b5Smrg libdir=$func_replace_sysroot_result 9832e169010aSmrg if test -z "$hardcode_libdirs"; then 98339d0ccd10Smrg hardcode_libdirs=$libdir 9834e169010aSmrg else 9835e169010aSmrg # Just accumulate the unique libdirs. 9836e169010aSmrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 9837e169010aSmrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 9838e169010aSmrg ;; 9839e169010aSmrg *) 9840c63293b5Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 9841e169010aSmrg ;; 9842e169010aSmrg esac 9843e169010aSmrg fi 9844e169010aSmrg else 9845e169010aSmrg eval flag=\"$hardcode_libdir_flag_spec\" 9846c63293b5Smrg func_append dep_rpath " $flag" 9847e169010aSmrg fi 9848e169010aSmrg elif test -n "$runpath_var"; then 9849e169010aSmrg case "$perm_rpath " in 9850e169010aSmrg *" $libdir "*) ;; 9851e6d5e4e0Smrg *) func_append perm_rpath " $libdir" ;; 9852e169010aSmrg esac 9853e169010aSmrg fi 9854e169010aSmrg done 9855e169010aSmrg # Substitute the hardcoded libdirs into the rpath. 9856e169010aSmrg if test -n "$hardcode_libdir_separator" && 9857e169010aSmrg test -n "$hardcode_libdirs"; then 98589d0ccd10Smrg libdir=$hardcode_libdirs 9859e6d5e4e0Smrg eval "dep_rpath=\"$hardcode_libdir_flag_spec\"" 9860e169010aSmrg fi 9861e169010aSmrg if test -n "$runpath_var" && test -n "$perm_rpath"; then 9862e169010aSmrg # We should set the runpath_var. 9863e169010aSmrg rpath= 9864e169010aSmrg for dir in $perm_rpath; do 9865c63293b5Smrg func_append rpath "$dir:" 9866e169010aSmrg done 9867e169010aSmrg eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" 9868e169010aSmrg fi 9869e169010aSmrg test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" 9870e169010aSmrg fi 98717914d74bSmrg 98729d0ccd10Smrg shlibpath=$finalize_shlibpath 98739d0ccd10Smrg test relink = "$opt_mode" || shlibpath=$compile_shlibpath$shlibpath 9874e169010aSmrg if test -n "$shlibpath"; then 9875e169010aSmrg eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" 9876e169010aSmrg fi 98777914d74bSmrg 9878e169010aSmrg # Get the real and link names of the library. 9879e169010aSmrg eval shared_ext=\"$shrext_cmds\" 9880e169010aSmrg eval library_names=\"$library_names_spec\" 9881e169010aSmrg set dummy $library_names 9882e169010aSmrg shift 98839d0ccd10Smrg realname=$1 9884e169010aSmrg shift 98857914d74bSmrg 9886e169010aSmrg if test -n "$soname_spec"; then 9887e169010aSmrg eval soname=\"$soname_spec\" 9888e169010aSmrg else 98899d0ccd10Smrg soname=$realname 9890e169010aSmrg fi 9891e169010aSmrg if test -z "$dlname"; then 9892e169010aSmrg dlname=$soname 9893e169010aSmrg fi 98947914d74bSmrg 98959d0ccd10Smrg lib=$output_objdir/$realname 9896e169010aSmrg linknames= 9897e169010aSmrg for link 9898e169010aSmrg do 9899c63293b5Smrg func_append linknames " $link" 9900e169010aSmrg done 99017914d74bSmrg 9902e169010aSmrg # Use standard objects if they are pic 9903e8ead290Smrg test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` 9904e169010aSmrg test "X$libobjs" = "X " && libobjs= 99057914d74bSmrg 9906e169010aSmrg delfiles= 9907e169010aSmrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 9908e169010aSmrg $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" 99099d0ccd10Smrg export_symbols=$output_objdir/$libname.uexp 9910c63293b5Smrg func_append delfiles " $export_symbols" 9911e169010aSmrg fi 99127914d74bSmrg 9913e169010aSmrg orig_export_symbols= 9914e169010aSmrg case $host_os in 9915e169010aSmrg cygwin* | mingw* | cegcc*) 9916e169010aSmrg if test -n "$export_symbols" && test -z "$export_symbols_regex"; then 9917e169010aSmrg # exporting using user supplied symfile 99189d0ccd10Smrg func_dll_def_p "$export_symbols" || { 9919e169010aSmrg # and it's NOT already a .def file. Must figure out 9920e169010aSmrg # which of the given symbols are data symbols and tag 9921e169010aSmrg # them as such. So, trigger use of export_symbols_cmds. 9922e169010aSmrg # export_symbols gets reassigned inside the "prepare 9923e169010aSmrg # the list of exported symbols" if statement, so the 9924e169010aSmrg # include_expsyms logic still works. 99259d0ccd10Smrg orig_export_symbols=$export_symbols 9926e169010aSmrg export_symbols= 9927e169010aSmrg always_export_symbols=yes 99289d0ccd10Smrg } 9929e169010aSmrg fi 9930e169010aSmrg ;; 9931e169010aSmrg esac 99327914d74bSmrg 9933e169010aSmrg # Prepare the list of exported symbols 9934e169010aSmrg if test -z "$export_symbols"; then 99359d0ccd10Smrg if test yes = "$always_export_symbols" || test -n "$export_symbols_regex"; then 99369d0ccd10Smrg func_verbose "generating symbol list for '$libname.la'" 99379d0ccd10Smrg export_symbols=$output_objdir/$libname.exp 9938e169010aSmrg $opt_dry_run || $RM $export_symbols 9939e169010aSmrg cmds=$export_symbols_cmds 99409d0ccd10Smrg save_ifs=$IFS; IFS='~' 9941c63293b5Smrg for cmd1 in $cmds; do 99429d0ccd10Smrg IFS=$save_ifs 9943c63293b5Smrg # Take the normal branch if the nm_file_list_spec branch 9944c63293b5Smrg # doesn't work or if tool conversion is not needed. 9945c63293b5Smrg case $nm_file_list_spec~$to_tool_file_cmd in 9946c63293b5Smrg *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) 9947c63293b5Smrg try_normal_branch=yes 9948c63293b5Smrg eval cmd=\"$cmd1\" 9949c63293b5Smrg func_len " $cmd" 9950c63293b5Smrg len=$func_len_result 9951c63293b5Smrg ;; 9952c63293b5Smrg *) 9953c63293b5Smrg try_normal_branch=no 9954c63293b5Smrg ;; 9955c63293b5Smrg esac 99569d0ccd10Smrg if test yes = "$try_normal_branch" \ 9957c63293b5Smrg && { test "$len" -lt "$max_cmd_len" \ 9958c63293b5Smrg || test "$max_cmd_len" -le -1; } 9959c63293b5Smrg then 9960c63293b5Smrg func_show_eval "$cmd" 'exit $?' 9961c63293b5Smrg skipped_export=false 9962c63293b5Smrg elif test -n "$nm_file_list_spec"; then 9963c63293b5Smrg func_basename "$output" 9964c63293b5Smrg output_la=$func_basename_result 9965c63293b5Smrg save_libobjs=$libobjs 9966c63293b5Smrg save_output=$output 99679d0ccd10Smrg output=$output_objdir/$output_la.nm 9968c63293b5Smrg func_to_tool_file "$output" 9969c63293b5Smrg libobjs=$nm_file_list_spec$func_to_tool_file_result 9970c63293b5Smrg func_append delfiles " $output" 9971c63293b5Smrg func_verbose "creating $NM input file list: $output" 9972c63293b5Smrg for obj in $save_libobjs; do 9973c63293b5Smrg func_to_tool_file "$obj" 9974c63293b5Smrg $ECHO "$func_to_tool_file_result" 9975c63293b5Smrg done > "$output" 9976c63293b5Smrg eval cmd=\"$cmd1\" 9977e169010aSmrg func_show_eval "$cmd" 'exit $?' 9978c63293b5Smrg output=$save_output 9979c63293b5Smrg libobjs=$save_libobjs 9980e169010aSmrg skipped_export=false 9981e169010aSmrg else 9982e169010aSmrg # The command line is too long to execute in one step. 9983e169010aSmrg func_verbose "using reloadable object file for export list..." 9984e169010aSmrg skipped_export=: 9985e169010aSmrg # Break out early, otherwise skipped_export may be 9986e169010aSmrg # set to false by a later but shorter cmd. 9987e169010aSmrg break 9988e169010aSmrg fi 9989e169010aSmrg done 99909d0ccd10Smrg IFS=$save_ifs 99919d0ccd10Smrg if test -n "$export_symbols_regex" && test : != "$skipped_export"; then 9992e169010aSmrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 9993e169010aSmrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 9994e169010aSmrg fi 9995e169010aSmrg fi 9996e169010aSmrg fi 99977914d74bSmrg 9998e169010aSmrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 99999d0ccd10Smrg tmp_export_symbols=$export_symbols 100009d0ccd10Smrg test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols 10001e8ead290Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 10002e169010aSmrg fi 100037914d74bSmrg 100049d0ccd10Smrg if test : != "$skipped_export" && test -n "$orig_export_symbols"; then 10005e169010aSmrg # The given exports_symbols file has to be filtered, so filter it. 100069d0ccd10Smrg func_verbose "filter symbol list for '$libname.la' to tag DATA exports" 10007e169010aSmrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 100089d0ccd10Smrg # 's' commands, which not all seds can handle. GNU sed should be fine 10009e169010aSmrg # though. Also, the filter scales superlinearly with the number of 10010e169010aSmrg # global variables. join(1) would be nice here, but unfortunately 10011e169010aSmrg # isn't a blessed tool. 10012e169010aSmrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 10013c63293b5Smrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 10014e169010aSmrg export_symbols=$output_objdir/$libname.def 10015e169010aSmrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 100167914d74bSmrg fi 100177914d74bSmrg 10018e169010aSmrg tmp_deplibs= 10019e169010aSmrg for test_deplib in $deplibs; do 10020e169010aSmrg case " $convenience " in 10021e169010aSmrg *" $test_deplib "*) ;; 10022e169010aSmrg *) 10023c63293b5Smrg func_append tmp_deplibs " $test_deplib" 10024e169010aSmrg ;; 10025e169010aSmrg esac 10026e169010aSmrg done 100279d0ccd10Smrg deplibs=$tmp_deplibs 100287914d74bSmrg 10029e169010aSmrg if test -n "$convenience"; then 10030e169010aSmrg if test -n "$whole_archive_flag_spec" && 100319d0ccd10Smrg test yes = "$compiler_needs_object" && 10032e169010aSmrg test -z "$libobjs"; then 10033e169010aSmrg # extract the archives, so we have objects to list. 10034e169010aSmrg # TODO: could optimize this to just extract one archive. 10035e169010aSmrg whole_archive_flag_spec= 10036e169010aSmrg fi 10037e169010aSmrg if test -n "$whole_archive_flag_spec"; then 10038e169010aSmrg save_libobjs=$libobjs 10039e169010aSmrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 10040e169010aSmrg test "X$libobjs" = "X " && libobjs= 10041e169010aSmrg else 100429d0ccd10Smrg gentop=$output_objdir/${outputname}x 10043c63293b5Smrg func_append generated " $gentop" 100447914d74bSmrg 10045e169010aSmrg func_extract_archives $gentop $convenience 10046c63293b5Smrg func_append libobjs " $func_extract_archives_result" 10047e169010aSmrg test "X$libobjs" = "X " && libobjs= 10048e169010aSmrg fi 10049e169010aSmrg fi 100507914d74bSmrg 100519d0ccd10Smrg if test yes = "$thread_safe" && test -n "$thread_safe_flag_spec"; then 10052e169010aSmrg eval flag=\"$thread_safe_flag_spec\" 10053c63293b5Smrg func_append linker_flags " $flag" 10054e169010aSmrg fi 100557914d74bSmrg 10056e169010aSmrg # Make a backup of the uninstalled library when relinking 100579d0ccd10Smrg if test relink = "$opt_mode"; then 10058e169010aSmrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? 100597914d74bSmrg fi 100607914d74bSmrg 10061e169010aSmrg # Do each of the archive commands. 100629d0ccd10Smrg if test yes = "$module" && test -n "$module_cmds"; then 10063e169010aSmrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 10064e169010aSmrg eval test_cmds=\"$module_expsym_cmds\" 10065e169010aSmrg cmds=$module_expsym_cmds 10066e169010aSmrg else 10067e169010aSmrg eval test_cmds=\"$module_cmds\" 10068e169010aSmrg cmds=$module_cmds 10069e169010aSmrg fi 10070e169010aSmrg else 10071e169010aSmrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 10072e169010aSmrg eval test_cmds=\"$archive_expsym_cmds\" 10073e169010aSmrg cmds=$archive_expsym_cmds 10074e169010aSmrg else 10075e169010aSmrg eval test_cmds=\"$archive_cmds\" 10076e169010aSmrg cmds=$archive_cmds 10077e169010aSmrg fi 100787914d74bSmrg fi 100797914d74bSmrg 100809d0ccd10Smrg if test : != "$skipped_export" && 10081e169010aSmrg func_len " $test_cmds" && 10082e169010aSmrg len=$func_len_result && 10083e169010aSmrg test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 10084e169010aSmrg : 10085e169010aSmrg else 10086e169010aSmrg # The command line is too long to link in one step, link piecewise 10087e169010aSmrg # or, if using GNU ld and skipped_export is not :, use a linker 10088e169010aSmrg # script. 100897914d74bSmrg 10090e169010aSmrg # Save the value of $output and $libobjs because we want to 10091e169010aSmrg # use them later. If we have whole_archive_flag_spec, we 10092e169010aSmrg # want to use save_libobjs as it was before 10093e169010aSmrg # whole_archive_flag_spec was expanded, because we can't 10094e169010aSmrg # assume the linker understands whole_archive_flag_spec. 10095e169010aSmrg # This may have to be revisited, in case too many 10096e169010aSmrg # convenience libraries get linked in and end up exceeding 10097e169010aSmrg # the spec. 10098e169010aSmrg if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then 10099e169010aSmrg save_libobjs=$libobjs 10100e169010aSmrg fi 10101e169010aSmrg save_output=$output 10102e8ead290Smrg func_basename "$output" 10103e8ead290Smrg output_la=$func_basename_result 101047914d74bSmrg 10105e169010aSmrg # Clear the reloadable object creation command queue and 10106e169010aSmrg # initialize k to one. 10107e169010aSmrg test_cmds= 10108e169010aSmrg concat_cmds= 10109e169010aSmrg objlist= 10110e169010aSmrg last_robj= 10111e169010aSmrg k=1 101127914d74bSmrg 101139d0ccd10Smrg if test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then 101149d0ccd10Smrg output=$output_objdir/$output_la.lnkscript 10115e169010aSmrg func_verbose "creating GNU ld script: $output" 10116e8ead290Smrg echo 'INPUT (' > $output 10117e169010aSmrg for obj in $save_libobjs 10118e169010aSmrg do 10119c63293b5Smrg func_to_tool_file "$obj" 10120c63293b5Smrg $ECHO "$func_to_tool_file_result" >> $output 10121e169010aSmrg done 10122e8ead290Smrg echo ')' >> $output 10123c63293b5Smrg func_append delfiles " $output" 10124c63293b5Smrg func_to_tool_file "$output" 10125c63293b5Smrg output=$func_to_tool_file_result 101269d0ccd10Smrg elif test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then 101279d0ccd10Smrg output=$output_objdir/$output_la.lnk 10128e169010aSmrg func_verbose "creating linker input file list: $output" 10129e169010aSmrg : > $output 10130e169010aSmrg set x $save_libobjs 10131e169010aSmrg shift 10132e169010aSmrg firstobj= 101339d0ccd10Smrg if test yes = "$compiler_needs_object"; then 10134e169010aSmrg firstobj="$1 " 10135e169010aSmrg shift 10136e169010aSmrg fi 10137e169010aSmrg for obj 10138e169010aSmrg do 10139c63293b5Smrg func_to_tool_file "$obj" 10140c63293b5Smrg $ECHO "$func_to_tool_file_result" >> $output 10141e169010aSmrg done 10142c63293b5Smrg func_append delfiles " $output" 10143c63293b5Smrg func_to_tool_file "$output" 10144c63293b5Smrg output=$firstobj\"$file_list_spec$func_to_tool_file_result\" 10145e169010aSmrg else 10146e169010aSmrg if test -n "$save_libobjs"; then 10147e169010aSmrg func_verbose "creating reloadable object files..." 101489d0ccd10Smrg output=$output_objdir/$output_la-$k.$objext 10149e169010aSmrg eval test_cmds=\"$reload_cmds\" 10150e169010aSmrg func_len " $test_cmds" 10151e169010aSmrg len0=$func_len_result 10152e169010aSmrg len=$len0 10153e169010aSmrg 10154e169010aSmrg # Loop over the list of objects to be linked. 10155e169010aSmrg for obj in $save_libobjs 10156e169010aSmrg do 10157e169010aSmrg func_len " $obj" 10158e169010aSmrg func_arith $len + $func_len_result 10159e169010aSmrg len=$func_arith_result 101609d0ccd10Smrg if test -z "$objlist" || 10161e169010aSmrg test "$len" -lt "$max_cmd_len"; then 10162e169010aSmrg func_append objlist " $obj" 10163e169010aSmrg else 10164e169010aSmrg # The command $test_cmds is almost too long, add a 10165e169010aSmrg # command to the queue. 101669d0ccd10Smrg if test 1 -eq "$k"; then 10167e169010aSmrg # The first file doesn't have a previous command to add. 10168e8ead290Smrg reload_objs=$objlist 10169e8ead290Smrg eval concat_cmds=\"$reload_cmds\" 10170e169010aSmrg else 10171e169010aSmrg # All subsequent reloadable object files will link in 10172e169010aSmrg # the last one created. 10173e8ead290Smrg reload_objs="$objlist $last_robj" 10174e8ead290Smrg eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" 10175e169010aSmrg fi 101769d0ccd10Smrg last_robj=$output_objdir/$output_la-$k.$objext 10177e169010aSmrg func_arith $k + 1 10178e169010aSmrg k=$func_arith_result 101799d0ccd10Smrg output=$output_objdir/$output_la-$k.$objext 10180e8ead290Smrg objlist=" $obj" 10181e169010aSmrg func_len " $last_robj" 10182e169010aSmrg func_arith $len0 + $func_len_result 10183e169010aSmrg len=$func_arith_result 10184e169010aSmrg fi 10185e169010aSmrg done 10186e169010aSmrg # Handle the remaining objects by creating one last 10187e169010aSmrg # reloadable object file. All subsequent reloadable object 10188e169010aSmrg # files will link in the last one created. 10189e169010aSmrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 10190e8ead290Smrg reload_objs="$objlist $last_robj" 101919d0ccd10Smrg eval concat_cmds=\"\$concat_cmds$reload_cmds\" 10192e169010aSmrg if test -n "$last_robj"; then 101939d0ccd10Smrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 10194e169010aSmrg fi 10195c63293b5Smrg func_append delfiles " $output" 101967914d74bSmrg 10197e169010aSmrg else 10198e169010aSmrg output= 10199e169010aSmrg fi 102007914d74bSmrg 102019d0ccd10Smrg ${skipped_export-false} && { 102029d0ccd10Smrg func_verbose "generating symbol list for '$libname.la'" 102039d0ccd10Smrg export_symbols=$output_objdir/$libname.exp 10204e169010aSmrg $opt_dry_run || $RM $export_symbols 10205e169010aSmrg libobjs=$output 10206e169010aSmrg # Append the command to create the export file. 10207e169010aSmrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 10208e169010aSmrg eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" 10209e169010aSmrg if test -n "$last_robj"; then 10210e169010aSmrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 10211e169010aSmrg fi 102129d0ccd10Smrg } 102137914d74bSmrg 10214e169010aSmrg test -n "$save_libobjs" && 10215e169010aSmrg func_verbose "creating a temporary reloadable object file: $output" 102167914d74bSmrg 10217e169010aSmrg # Loop through the commands generated above and execute them. 102189d0ccd10Smrg save_ifs=$IFS; IFS='~' 10219e169010aSmrg for cmd in $concat_cmds; do 102209d0ccd10Smrg IFS=$save_ifs 102219d0ccd10Smrg $opt_quiet || { 102220ea508b1Smrg func_quote_arg expand,pretty "$cmd" 102230ea508b1Smrg eval "func_echo $func_quote_arg_result" 10224e169010aSmrg } 10225e169010aSmrg $opt_dry_run || eval "$cmd" || { 10226e169010aSmrg lt_exit=$? 10227e169010aSmrg 10228e169010aSmrg # Restore the uninstalled library and exit 102299d0ccd10Smrg if test relink = "$opt_mode"; then 10230e169010aSmrg ( cd "$output_objdir" && \ 10231e169010aSmrg $RM "${realname}T" && \ 10232e169010aSmrg $MV "${realname}U" "$realname" ) 10233e169010aSmrg fi 102347914d74bSmrg 10235e169010aSmrg exit $lt_exit 10236e169010aSmrg } 10237e169010aSmrg done 102389d0ccd10Smrg IFS=$save_ifs 10239e169010aSmrg 10240e169010aSmrg if test -n "$export_symbols_regex" && ${skipped_export-false}; then 10241e169010aSmrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 10242e169010aSmrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 102437914d74bSmrg fi 102447914d74bSmrg fi 102457914d74bSmrg 102469d0ccd10Smrg ${skipped_export-false} && { 10247e169010aSmrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 102489d0ccd10Smrg tmp_export_symbols=$export_symbols 102499d0ccd10Smrg test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols 10250e8ead290Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 10251e169010aSmrg fi 102527914d74bSmrg 10253e169010aSmrg if test -n "$orig_export_symbols"; then 10254e169010aSmrg # The given exports_symbols file has to be filtered, so filter it. 102559d0ccd10Smrg func_verbose "filter symbol list for '$libname.la' to tag DATA exports" 10256e169010aSmrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 102579d0ccd10Smrg # 's' commands, which not all seds can handle. GNU sed should be fine 10258e169010aSmrg # though. Also, the filter scales superlinearly with the number of 10259e169010aSmrg # global variables. join(1) would be nice here, but unfortunately 10260e169010aSmrg # isn't a blessed tool. 10261e169010aSmrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 10262c63293b5Smrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 10263e169010aSmrg export_symbols=$output_objdir/$libname.def 10264e169010aSmrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 10265e169010aSmrg fi 102669d0ccd10Smrg } 102677914d74bSmrg 10268e169010aSmrg libobjs=$output 10269e169010aSmrg # Restore the value of output. 10270e169010aSmrg output=$save_output 102717914d74bSmrg 10272e169010aSmrg if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then 10273e169010aSmrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 10274e169010aSmrg test "X$libobjs" = "X " && libobjs= 10275e169010aSmrg fi 10276e169010aSmrg # Expand the library linking commands again to reset the 10277e169010aSmrg # value of $libobjs for piecewise linking. 10278e169010aSmrg 10279e169010aSmrg # Do each of the archive commands. 102809d0ccd10Smrg if test yes = "$module" && test -n "$module_cmds"; then 10281e169010aSmrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 10282e169010aSmrg cmds=$module_expsym_cmds 102837914d74bSmrg else 10284e169010aSmrg cmds=$module_cmds 102857914d74bSmrg fi 102867914d74bSmrg else 10287e169010aSmrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 10288e169010aSmrg cmds=$archive_expsym_cmds 10289e169010aSmrg else 10290e169010aSmrg cmds=$archive_cmds 10291e169010aSmrg fi 102927914d74bSmrg fi 102937914d74bSmrg fi 102947914d74bSmrg 10295e169010aSmrg if test -n "$delfiles"; then 10296e169010aSmrg # Append the command to remove temporary files to $cmds. 10297e169010aSmrg eval cmds=\"\$cmds~\$RM $delfiles\" 10298e169010aSmrg fi 102997914d74bSmrg 10300e169010aSmrg # Add any objects from preloaded convenience libraries 10301e169010aSmrg if test -n "$dlprefiles"; then 103029d0ccd10Smrg gentop=$output_objdir/${outputname}x 10303c63293b5Smrg func_append generated " $gentop" 103047914d74bSmrg 10305e169010aSmrg func_extract_archives $gentop $dlprefiles 10306c63293b5Smrg func_append libobjs " $func_extract_archives_result" 10307e169010aSmrg test "X$libobjs" = "X " && libobjs= 103087914d74bSmrg fi 103097914d74bSmrg 103109d0ccd10Smrg save_ifs=$IFS; IFS='~' 10311e169010aSmrg for cmd in $cmds; do 103129d0ccd10Smrg IFS=$sp$nl 10313e169010aSmrg eval cmd=\"$cmd\" 103149d0ccd10Smrg IFS=$save_ifs 103159d0ccd10Smrg $opt_quiet || { 103160ea508b1Smrg func_quote_arg expand,pretty "$cmd" 103170ea508b1Smrg eval "func_echo $func_quote_arg_result" 10318e169010aSmrg } 10319e169010aSmrg $opt_dry_run || eval "$cmd" || { 10320e169010aSmrg lt_exit=$? 103217914d74bSmrg 10322e169010aSmrg # Restore the uninstalled library and exit 103239d0ccd10Smrg if test relink = "$opt_mode"; then 10324e169010aSmrg ( cd "$output_objdir" && \ 10325e169010aSmrg $RM "${realname}T" && \ 10326e169010aSmrg $MV "${realname}U" "$realname" ) 10327e169010aSmrg fi 10328e169010aSmrg 10329e169010aSmrg exit $lt_exit 10330e169010aSmrg } 10331e169010aSmrg done 103329d0ccd10Smrg IFS=$save_ifs 10333e169010aSmrg 10334e169010aSmrg # Restore the uninstalled library and exit 103359d0ccd10Smrg if test relink = "$opt_mode"; then 10336e169010aSmrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? 10337e169010aSmrg 10338e169010aSmrg if test -n "$convenience"; then 10339e169010aSmrg if test -z "$whole_archive_flag_spec"; then 10340e169010aSmrg func_show_eval '${RM}r "$gentop"' 103417914d74bSmrg fi 103427914d74bSmrg fi 103437914d74bSmrg 10344e169010aSmrg exit $EXIT_SUCCESS 10345e169010aSmrg fi 103467914d74bSmrg 10347e169010aSmrg # Create links to the real library. 10348e169010aSmrg for linkname in $linknames; do 10349e169010aSmrg if test "$realname" != "$linkname"; then 10350e169010aSmrg func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' 10351e169010aSmrg fi 10352e169010aSmrg done 10353e169010aSmrg 10354e169010aSmrg # If -module or -export-dynamic was specified, set the dlname. 103559d0ccd10Smrg if test yes = "$module" || test yes = "$export_dynamic"; then 10356e169010aSmrg # On all known operating systems, these are identical. 103579d0ccd10Smrg dlname=$soname 10358e169010aSmrg fi 10359e169010aSmrg fi 10360e169010aSmrg ;; 10361e169010aSmrg 10362e169010aSmrg obj) 103639d0ccd10Smrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 103649d0ccd10Smrg func_warning "'-dlopen' is ignored for objects" 10365e169010aSmrg fi 10366e169010aSmrg 10367e169010aSmrg case " $deplibs" in 10368e169010aSmrg *\ -l* | *\ -L*) 103699d0ccd10Smrg func_warning "'-l' and '-L' are ignored for objects" ;; 10370e169010aSmrg esac 10371e169010aSmrg 10372e169010aSmrg test -n "$rpath" && \ 103739d0ccd10Smrg func_warning "'-rpath' is ignored for objects" 10374e169010aSmrg 10375e169010aSmrg test -n "$xrpath" && \ 103769d0ccd10Smrg func_warning "'-R' is ignored for objects" 10377e169010aSmrg 10378e169010aSmrg test -n "$vinfo" && \ 103799d0ccd10Smrg func_warning "'-version-info' is ignored for objects" 10380e169010aSmrg 10381e169010aSmrg test -n "$release" && \ 103829d0ccd10Smrg func_warning "'-release' is ignored for objects" 10383e169010aSmrg 10384e169010aSmrg case $output in 10385e169010aSmrg *.lo) 10386e169010aSmrg test -n "$objs$old_deplibs" && \ 103879d0ccd10Smrg func_fatal_error "cannot build library object '$output' from non-libtool objects" 10388e169010aSmrg 10389e169010aSmrg libobj=$output 10390e169010aSmrg func_lo2o "$libobj" 10391e169010aSmrg obj=$func_lo2o_result 10392e169010aSmrg ;; 10393e169010aSmrg *) 10394e169010aSmrg libobj= 103959d0ccd10Smrg obj=$output 10396e169010aSmrg ;; 10397e169010aSmrg esac 10398e169010aSmrg 10399e169010aSmrg # Delete the old objects. 10400e169010aSmrg $opt_dry_run || $RM $obj $libobj 10401e169010aSmrg 10402e169010aSmrg # Objects from convenience libraries. This assumes 10403e169010aSmrg # single-version convenience libraries. Whenever we create 10404e169010aSmrg # different ones for PIC/non-PIC, this we'll have to duplicate 10405e169010aSmrg # the extraction. 10406e169010aSmrg reload_conv_objs= 10407e169010aSmrg gentop= 104089d0ccd10Smrg # if reload_cmds runs $LD directly, get rid of -Wl from 104099d0ccd10Smrg # whole_archive_flag_spec and hope we can get by with turning comma 104109d0ccd10Smrg # into space. 104119d0ccd10Smrg case $reload_cmds in 104129d0ccd10Smrg *\$LD[\ \$]*) wl= ;; 104139d0ccd10Smrg esac 10414e169010aSmrg if test -n "$convenience"; then 10415e169010aSmrg if test -n "$whole_archive_flag_spec"; then 10416e169010aSmrg eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" 104179d0ccd10Smrg test -n "$wl" || tmp_whole_archive_flags=`$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` 104189d0ccd10Smrg reload_conv_objs=$reload_objs\ $tmp_whole_archive_flags 10419e169010aSmrg else 104209d0ccd10Smrg gentop=$output_objdir/${obj}x 10421c63293b5Smrg func_append generated " $gentop" 10422e169010aSmrg 10423e169010aSmrg func_extract_archives $gentop $convenience 10424e169010aSmrg reload_conv_objs="$reload_objs $func_extract_archives_result" 10425e169010aSmrg fi 10426e169010aSmrg fi 104277914d74bSmrg 10428c63293b5Smrg # If we're not building shared, we need to use non_pic_objs 104299d0ccd10Smrg test yes = "$build_libtool_libs" || libobjs=$non_pic_objects 10430c63293b5Smrg 10431e169010aSmrg # Create the old-style object. 104329d0ccd10Smrg reload_objs=$objs$old_deplibs' '`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; /\.lib$/d; $lo2o" | $NL2SP`' '$reload_conv_objs 104337914d74bSmrg 104349d0ccd10Smrg output=$obj 10435e169010aSmrg func_execute_cmds "$reload_cmds" 'exit $?' 104367914d74bSmrg 10437e169010aSmrg # Exit if we aren't doing a library object file. 10438e169010aSmrg if test -z "$libobj"; then 10439e169010aSmrg if test -n "$gentop"; then 10440e169010aSmrg func_show_eval '${RM}r "$gentop"' 10441e169010aSmrg fi 104427914d74bSmrg 10443e169010aSmrg exit $EXIT_SUCCESS 10444e169010aSmrg fi 104457914d74bSmrg 104469d0ccd10Smrg test yes = "$build_libtool_libs" || { 10447e169010aSmrg if test -n "$gentop"; then 10448e169010aSmrg func_show_eval '${RM}r "$gentop"' 10449e169010aSmrg fi 104507914d74bSmrg 10451e169010aSmrg # Create an invalid libtool object if no PIC, so that we don't 10452e169010aSmrg # accidentally link it into a program. 10453e169010aSmrg # $show "echo timestamp > $libobj" 10454e169010aSmrg # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? 10455e169010aSmrg exit $EXIT_SUCCESS 104569d0ccd10Smrg } 104577914d74bSmrg 104589d0ccd10Smrg if test -n "$pic_flag" || test default != "$pic_mode"; then 10459e169010aSmrg # Only do commands if we really have different PIC objects. 10460e169010aSmrg reload_objs="$libobjs $reload_conv_objs" 104619d0ccd10Smrg output=$libobj 10462e169010aSmrg func_execute_cmds "$reload_cmds" 'exit $?' 104637914d74bSmrg fi 104647914d74bSmrg 10465e169010aSmrg if test -n "$gentop"; then 10466e169010aSmrg func_show_eval '${RM}r "$gentop"' 10467e169010aSmrg fi 104687914d74bSmrg 10469e169010aSmrg exit $EXIT_SUCCESS 10470e169010aSmrg ;; 104717914d74bSmrg 10472e169010aSmrg prog) 10473e169010aSmrg case $host in 10474e169010aSmrg *cygwin*) func_stripname '' '.exe' "$output" 10475e169010aSmrg output=$func_stripname_result.exe;; 104767914d74bSmrg esac 10477e169010aSmrg test -n "$vinfo" && \ 104789d0ccd10Smrg func_warning "'-version-info' is ignored for programs" 104797914d74bSmrg 10480e169010aSmrg test -n "$release" && \ 104819d0ccd10Smrg func_warning "'-release' is ignored for programs" 104827914d74bSmrg 104839d0ccd10Smrg $preload \ 104849d0ccd10Smrg && test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \ 104859d0ccd10Smrg && func_warning "'LT_INIT([dlopen])' not used. Assuming no dlopen support." 104867914d74bSmrg 10487e169010aSmrg case $host in 10488e169010aSmrg *-*-rhapsody* | *-*-darwin1.[012]) 10489e169010aSmrg # On Rhapsody replace the C library is the System framework 10490e8ead290Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` 10491e8ead290Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` 104927914d74bSmrg ;; 104937914d74bSmrg esac 104947914d74bSmrg 10495e169010aSmrg case $host in 10496e169010aSmrg *-*-darwin*) 10497e169010aSmrg # Don't allow lazy linking, it breaks C++ global constructors 10498e169010aSmrg # But is supposedly fixed on 10.4 or later (yay!). 104999d0ccd10Smrg if test CXX = "$tagname"; then 10500e169010aSmrg case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 10501e169010aSmrg 10.[0123]) 105029d0ccd10Smrg func_append compile_command " $wl-bind_at_load" 105039d0ccd10Smrg func_append finalize_command " $wl-bind_at_load" 10504e169010aSmrg ;; 10505e169010aSmrg esac 10506e169010aSmrg fi 10507e169010aSmrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 10508e8ead290Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 10509e8ead290Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 105107914d74bSmrg ;; 105117914d74bSmrg esac 105127914d74bSmrg 105137914d74bSmrg 10514e169010aSmrg # move library search paths that coincide with paths to not yet 10515e169010aSmrg # installed libraries to the beginning of the library search list 10516e169010aSmrg new_libs= 10517e169010aSmrg for path in $notinst_path; do 10518e169010aSmrg case " $new_libs " in 10519e169010aSmrg *" -L$path/$objdir "*) ;; 105207914d74bSmrg *) 10521e169010aSmrg case " $compile_deplibs " in 10522e169010aSmrg *" -L$path/$objdir "*) 10523c63293b5Smrg func_append new_libs " -L$path/$objdir" ;; 10524e169010aSmrg esac 105257914d74bSmrg ;; 105267914d74bSmrg esac 105277914d74bSmrg done 10528e169010aSmrg for deplib in $compile_deplibs; do 10529e169010aSmrg case $deplib in 10530e169010aSmrg -L*) 10531e169010aSmrg case " $new_libs " in 10532e169010aSmrg *" $deplib "*) ;; 10533c63293b5Smrg *) func_append new_libs " $deplib" ;; 10534e169010aSmrg esac 10535e169010aSmrg ;; 10536c63293b5Smrg *) func_append new_libs " $deplib" ;; 10537e169010aSmrg esac 10538e169010aSmrg done 105399d0ccd10Smrg compile_deplibs=$new_libs 105407914d74bSmrg 105417914d74bSmrg 10542c63293b5Smrg func_append compile_command " $compile_deplibs" 10543c63293b5Smrg func_append finalize_command " $finalize_deplibs" 105447914d74bSmrg 10545e169010aSmrg if test -n "$rpath$xrpath"; then 10546e169010aSmrg # If the user specified any rpath flags, then add them. 10547e169010aSmrg for libdir in $rpath $xrpath; do 10548e169010aSmrg # This is the magic to use -rpath. 10549e169010aSmrg case "$finalize_rpath " in 10550e169010aSmrg *" $libdir "*) ;; 10551c63293b5Smrg *) func_append finalize_rpath " $libdir" ;; 10552e169010aSmrg esac 10553e169010aSmrg done 10554e169010aSmrg fi 105557914d74bSmrg 10556e169010aSmrg # Now hardcode the library paths 10557e169010aSmrg rpath= 10558e169010aSmrg hardcode_libdirs= 10559e169010aSmrg for libdir in $compile_rpath $finalize_rpath; do 10560e169010aSmrg if test -n "$hardcode_libdir_flag_spec"; then 10561e169010aSmrg if test -n "$hardcode_libdir_separator"; then 10562e169010aSmrg if test -z "$hardcode_libdirs"; then 105639d0ccd10Smrg hardcode_libdirs=$libdir 10564e169010aSmrg else 10565e169010aSmrg # Just accumulate the unique libdirs. 10566e169010aSmrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 10567e169010aSmrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 10568e169010aSmrg ;; 10569e169010aSmrg *) 10570c63293b5Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 10571e169010aSmrg ;; 10572e169010aSmrg esac 10573e169010aSmrg fi 10574e169010aSmrg else 10575e169010aSmrg eval flag=\"$hardcode_libdir_flag_spec\" 10576c63293b5Smrg func_append rpath " $flag" 10577e169010aSmrg fi 10578e169010aSmrg elif test -n "$runpath_var"; then 10579e169010aSmrg case "$perm_rpath " in 105807914d74bSmrg *" $libdir "*) ;; 10581c63293b5Smrg *) func_append perm_rpath " $libdir" ;; 105827914d74bSmrg esac 10583e169010aSmrg fi 10584e169010aSmrg case $host in 10585e169010aSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 105869d0ccd10Smrg testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'` 10587e169010aSmrg case :$dllsearchpath: in 10588e169010aSmrg *":$libdir:"*) ;; 10589e169010aSmrg ::) dllsearchpath=$libdir;; 10590c63293b5Smrg *) func_append dllsearchpath ":$libdir";; 10591e169010aSmrg esac 10592e169010aSmrg case :$dllsearchpath: in 10593e169010aSmrg *":$testbindir:"*) ;; 10594e169010aSmrg ::) dllsearchpath=$testbindir;; 10595c63293b5Smrg *) func_append dllsearchpath ":$testbindir";; 10596e169010aSmrg esac 10597e169010aSmrg ;; 10598e169010aSmrg esac 10599e169010aSmrg done 10600e169010aSmrg # Substitute the hardcoded libdirs into the rpath. 10601e169010aSmrg if test -n "$hardcode_libdir_separator" && 10602e169010aSmrg test -n "$hardcode_libdirs"; then 106039d0ccd10Smrg libdir=$hardcode_libdirs 10604e169010aSmrg eval rpath=\" $hardcode_libdir_flag_spec\" 10605e169010aSmrg fi 106069d0ccd10Smrg compile_rpath=$rpath 10607e169010aSmrg 10608e169010aSmrg rpath= 10609e169010aSmrg hardcode_libdirs= 10610e169010aSmrg for libdir in $finalize_rpath; do 10611e169010aSmrg if test -n "$hardcode_libdir_flag_spec"; then 10612e169010aSmrg if test -n "$hardcode_libdir_separator"; then 10613e169010aSmrg if test -z "$hardcode_libdirs"; then 106149d0ccd10Smrg hardcode_libdirs=$libdir 10615e169010aSmrg else 10616e169010aSmrg # Just accumulate the unique libdirs. 10617e169010aSmrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 10618e169010aSmrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 10619e169010aSmrg ;; 10620e169010aSmrg *) 10621c63293b5Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 10622e169010aSmrg ;; 10623e169010aSmrg esac 10624e169010aSmrg fi 10625e169010aSmrg else 10626e169010aSmrg eval flag=\"$hardcode_libdir_flag_spec\" 10627c63293b5Smrg func_append rpath " $flag" 10628e169010aSmrg fi 10629e169010aSmrg elif test -n "$runpath_var"; then 10630e169010aSmrg case "$finalize_perm_rpath " in 106317914d74bSmrg *" $libdir "*) ;; 10632c63293b5Smrg *) func_append finalize_perm_rpath " $libdir" ;; 106337914d74bSmrg esac 106347914d74bSmrg fi 10635e169010aSmrg done 10636e169010aSmrg # Substitute the hardcoded libdirs into the rpath. 10637e169010aSmrg if test -n "$hardcode_libdir_separator" && 10638e169010aSmrg test -n "$hardcode_libdirs"; then 106399d0ccd10Smrg libdir=$hardcode_libdirs 10640e169010aSmrg eval rpath=\" $hardcode_libdir_flag_spec\" 10641e169010aSmrg fi 106429d0ccd10Smrg finalize_rpath=$rpath 106437914d74bSmrg 106449d0ccd10Smrg if test -n "$libobjs" && test yes = "$build_old_libs"; then 10645e169010aSmrg # Transform all the library objects into standard objects. 10646e8ead290Smrg compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 10647e8ead290Smrg finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 10648e169010aSmrg fi 106497914d74bSmrg 106509d0ccd10Smrg func_generate_dlsyms "$outputname" "@PROGRAM@" false 106517914d74bSmrg 10652e169010aSmrg # template prelinking step 10653e169010aSmrg if test -n "$prelink_cmds"; then 10654e169010aSmrg func_execute_cmds "$prelink_cmds" 'exit $?' 10655e169010aSmrg fi 106567914d74bSmrg 106579d0ccd10Smrg wrappers_required=: 10658e169010aSmrg case $host in 10659e8ead290Smrg *cegcc* | *mingw32ce*) 10660e8ead290Smrg # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. 106619d0ccd10Smrg wrappers_required=false 10662e8ead290Smrg ;; 10663e169010aSmrg *cygwin* | *mingw* ) 106649d0ccd10Smrg test yes = "$build_libtool_libs" || wrappers_required=false 10665e169010aSmrg ;; 10666e169010aSmrg *) 106679d0ccd10Smrg if test no = "$need_relink" || test yes != "$build_libtool_libs"; then 106689d0ccd10Smrg wrappers_required=false 10669e169010aSmrg fi 10670e169010aSmrg ;; 10671e169010aSmrg esac 106729d0ccd10Smrg $wrappers_required || { 10673e169010aSmrg # Replace the output file specification. 10674e8ead290Smrg compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 106759d0ccd10Smrg link_command=$compile_command$compile_rpath 106767914d74bSmrg 10677e169010aSmrg # We have no uninstalled library dependencies, so finalize right now. 10678e169010aSmrg exit_status=0 10679e169010aSmrg func_show_eval "$link_command" 'exit_status=$?' 106807914d74bSmrg 10681c63293b5Smrg if test -n "$postlink_cmds"; then 10682c63293b5Smrg func_to_tool_file "$output" 10683c63293b5Smrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 10684c63293b5Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 10685c63293b5Smrg fi 10686c63293b5Smrg 10687e169010aSmrg # Delete the generated files. 106889d0ccd10Smrg if test -f "$output_objdir/${outputname}S.$objext"; then 106899d0ccd10Smrg func_show_eval '$RM "$output_objdir/${outputname}S.$objext"' 10690e169010aSmrg fi 106917914d74bSmrg 10692e169010aSmrg exit $exit_status 106939d0ccd10Smrg } 106947914d74bSmrg 10695e169010aSmrg if test -n "$compile_shlibpath$finalize_shlibpath"; then 10696e169010aSmrg compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" 10697e169010aSmrg fi 10698e169010aSmrg if test -n "$finalize_shlibpath"; then 10699e169010aSmrg finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" 10700e169010aSmrg fi 107017914d74bSmrg 10702e169010aSmrg compile_var= 10703e169010aSmrg finalize_var= 10704e169010aSmrg if test -n "$runpath_var"; then 10705e169010aSmrg if test -n "$perm_rpath"; then 10706e169010aSmrg # We should set the runpath_var. 10707e169010aSmrg rpath= 10708e169010aSmrg for dir in $perm_rpath; do 10709c63293b5Smrg func_append rpath "$dir:" 107107914d74bSmrg done 10711e169010aSmrg compile_var="$runpath_var=\"$rpath\$$runpath_var\" " 107127914d74bSmrg fi 10713e169010aSmrg if test -n "$finalize_perm_rpath"; then 10714e169010aSmrg # We should set the runpath_var. 10715e169010aSmrg rpath= 10716e169010aSmrg for dir in $finalize_perm_rpath; do 10717c63293b5Smrg func_append rpath "$dir:" 10718e169010aSmrg done 10719e169010aSmrg finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " 10720e169010aSmrg fi 10721e169010aSmrg fi 107227914d74bSmrg 107239d0ccd10Smrg if test yes = "$no_install"; then 10724e169010aSmrg # We don't need to create a wrapper script. 107259d0ccd10Smrg link_command=$compile_var$compile_command$compile_rpath 10726e169010aSmrg # Replace the output file specification. 10727e8ead290Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 10728e169010aSmrg # Delete the old output file. 10729e169010aSmrg $opt_dry_run || $RM $output 10730e169010aSmrg # Link the executable and exit 10731e169010aSmrg func_show_eval "$link_command" 'exit $?' 10732c63293b5Smrg 10733c63293b5Smrg if test -n "$postlink_cmds"; then 10734c63293b5Smrg func_to_tool_file "$output" 10735c63293b5Smrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 10736c63293b5Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 10737c63293b5Smrg fi 10738c63293b5Smrg 10739e169010aSmrg exit $EXIT_SUCCESS 10740e169010aSmrg fi 107417914d74bSmrg 107429d0ccd10Smrg case $hardcode_action,$fast_install in 107439d0ccd10Smrg relink,*) 107449d0ccd10Smrg # Fast installation is not supported 107459d0ccd10Smrg link_command=$compile_var$compile_command$compile_rpath 107469d0ccd10Smrg relink_command=$finalize_var$finalize_command$finalize_rpath 107477914d74bSmrg 107489d0ccd10Smrg func_warning "this platform does not like uninstalled shared libraries" 107499d0ccd10Smrg func_warning "'$output' will be relinked during installation" 107509d0ccd10Smrg ;; 107519d0ccd10Smrg *,yes) 107529d0ccd10Smrg link_command=$finalize_var$compile_command$finalize_rpath 107539d0ccd10Smrg relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` 107549d0ccd10Smrg ;; 107559d0ccd10Smrg *,no) 107569d0ccd10Smrg link_command=$compile_var$compile_command$compile_rpath 107579d0ccd10Smrg relink_command=$finalize_var$finalize_command$finalize_rpath 107589d0ccd10Smrg ;; 107599d0ccd10Smrg *,needless) 107609d0ccd10Smrg link_command=$finalize_var$compile_command$finalize_rpath 107619d0ccd10Smrg relink_command= 107629d0ccd10Smrg ;; 107639d0ccd10Smrg esac 107647914d74bSmrg 10765e169010aSmrg # Replace the output file specification. 10766e8ead290Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` 107677914d74bSmrg 10768e169010aSmrg # Delete the old output files. 10769e169010aSmrg $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname 107707914d74bSmrg 10771e169010aSmrg func_show_eval "$link_command" 'exit $?' 107727914d74bSmrg 10773c63293b5Smrg if test -n "$postlink_cmds"; then 10774c63293b5Smrg func_to_tool_file "$output_objdir/$outputname" 10775c63293b5Smrg 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'` 10776c63293b5Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 10777c63293b5Smrg fi 10778c63293b5Smrg 10779e169010aSmrg # Now create the wrapper script. 10780e169010aSmrg func_verbose "creating $output" 107817914d74bSmrg 10782e169010aSmrg # Quote the relink command for shipping. 10783e169010aSmrg if test -n "$relink_command"; then 10784e169010aSmrg # Preserve any variables that may affect compiler behavior 10785e169010aSmrg for var in $variables_saved_for_relink; do 10786e169010aSmrg if eval test -z \"\${$var+set}\"; then 10787e169010aSmrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 10788e169010aSmrg elif eval var_value=\$$var; test -z "$var_value"; then 10789e169010aSmrg relink_command="$var=; export $var; $relink_command" 10790e169010aSmrg else 107910ea508b1Smrg func_quote_arg pretty "$var_value" 107920ea508b1Smrg relink_command="$var=$func_quote_arg_result; export $var; $relink_command" 10793e169010aSmrg fi 10794e169010aSmrg done 107950ea508b1Smrg func_quote eval cd "`pwd`" 107960ea508b1Smrg func_quote_arg pretty,unquoted "($func_quote_result; $relink_command)" 107970ea508b1Smrg relink_command=$func_quote_arg_unquoted_result 10798e169010aSmrg fi 107997914d74bSmrg 10800e169010aSmrg # Only actually do things if not in dry run mode. 10801e169010aSmrg $opt_dry_run || { 10802e169010aSmrg # win32 will think the script is a binary if it has 10803e169010aSmrg # a .exe suffix, so we strip it off here. 10804e169010aSmrg case $output in 10805e169010aSmrg *.exe) func_stripname '' '.exe' "$output" 10806e169010aSmrg output=$func_stripname_result ;; 10807e169010aSmrg esac 10808e169010aSmrg # test for cygwin because mv fails w/o .exe extensions 108097914d74bSmrg case $host in 10810e169010aSmrg *cygwin*) 10811e169010aSmrg exeext=.exe 10812e169010aSmrg func_stripname '' '.exe' "$outputname" 10813e169010aSmrg outputname=$func_stripname_result ;; 10814e169010aSmrg *) exeext= ;; 108157914d74bSmrg esac 10816e169010aSmrg case $host in 10817e169010aSmrg *cygwin* | *mingw* ) 10818e169010aSmrg func_dirname_and_basename "$output" "" "." 10819e169010aSmrg output_name=$func_basename_result 10820e169010aSmrg output_path=$func_dirname_result 108219d0ccd10Smrg cwrappersource=$output_path/$objdir/lt-$output_name.c 108229d0ccd10Smrg cwrapper=$output_path/$output_name.exe 10823e169010aSmrg $RM $cwrappersource $cwrapper 10824e169010aSmrg trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 10825e169010aSmrg 10826e169010aSmrg func_emit_cwrapperexe_src > $cwrappersource 10827e169010aSmrg 10828e169010aSmrg # The wrapper executable is built using the $host compiler, 10829e169010aSmrg # because it contains $host paths and files. If cross- 10830e169010aSmrg # compiling, it, like the target executable, must be 10831e169010aSmrg # executed on the $host or under an emulation environment. 10832e169010aSmrg $opt_dry_run || { 10833e169010aSmrg $LTCC $LTCFLAGS -o $cwrapper $cwrappersource 10834e169010aSmrg $STRIP $cwrapper 10835e169010aSmrg } 108367914d74bSmrg 10837e169010aSmrg # Now, create the wrapper script for func_source use: 10838e169010aSmrg func_ltwrapper_scriptname $cwrapper 10839e169010aSmrg $RM $func_ltwrapper_scriptname_result 10840e169010aSmrg trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 10841e169010aSmrg $opt_dry_run || { 10842e169010aSmrg # note: this script will not be executed, so do not chmod. 108439d0ccd10Smrg if test "x$build" = "x$host"; then 10844e169010aSmrg $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result 108457914d74bSmrg else 10846e169010aSmrg func_emit_wrapper no > $func_ltwrapper_scriptname_result 108477914d74bSmrg fi 10848e169010aSmrg } 10849e169010aSmrg ;; 10850e169010aSmrg * ) 10851e169010aSmrg $RM $output 10852e169010aSmrg trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 108537914d74bSmrg 10854e169010aSmrg func_emit_wrapper no > $output 10855e169010aSmrg chmod +x $output 108567914d74bSmrg ;; 108577914d74bSmrg esac 10858e169010aSmrg } 10859e169010aSmrg exit $EXIT_SUCCESS 10860e169010aSmrg ;; 10861e169010aSmrg esac 108627914d74bSmrg 10863e169010aSmrg # See if we need to build an old-fashioned archive. 10864e169010aSmrg for oldlib in $oldlibs; do 108657914d74bSmrg 108669d0ccd10Smrg case $build_libtool_libs in 108679d0ccd10Smrg convenience) 108689d0ccd10Smrg oldobjs="$libobjs_save $symfileobj" 108699d0ccd10Smrg addlibs=$convenience 10870e169010aSmrg build_libtool_libs=no 108719d0ccd10Smrg ;; 108729d0ccd10Smrg module) 108739d0ccd10Smrg oldobjs=$libobjs_save 108749d0ccd10Smrg addlibs=$old_convenience 108759d0ccd10Smrg build_libtool_libs=no 108769d0ccd10Smrg ;; 108779d0ccd10Smrg *) 10878e169010aSmrg oldobjs="$old_deplibs $non_pic_objects" 108799d0ccd10Smrg $preload && test -f "$symfileobj" \ 108809d0ccd10Smrg && func_append oldobjs " $symfileobj" 108819d0ccd10Smrg addlibs=$old_convenience 108829d0ccd10Smrg ;; 108839d0ccd10Smrg esac 108847914d74bSmrg 10885e169010aSmrg if test -n "$addlibs"; then 108869d0ccd10Smrg gentop=$output_objdir/${outputname}x 10887c63293b5Smrg func_append generated " $gentop" 108887914d74bSmrg 10889e169010aSmrg func_extract_archives $gentop $addlibs 10890c63293b5Smrg func_append oldobjs " $func_extract_archives_result" 10891e169010aSmrg fi 108927914d74bSmrg 10893e169010aSmrg # Do each command in the archive commands. 108949d0ccd10Smrg if test -n "$old_archive_from_new_cmds" && test yes = "$build_libtool_libs"; then 10895e169010aSmrg cmds=$old_archive_from_new_cmds 10896e169010aSmrg else 108977914d74bSmrg 10898e169010aSmrg # Add any objects from preloaded convenience libraries 10899e169010aSmrg if test -n "$dlprefiles"; then 109009d0ccd10Smrg gentop=$output_objdir/${outputname}x 10901c63293b5Smrg func_append generated " $gentop" 109027914d74bSmrg 10903e169010aSmrg func_extract_archives $gentop $dlprefiles 10904c63293b5Smrg func_append oldobjs " $func_extract_archives_result" 10905e169010aSmrg fi 109067914d74bSmrg 10907e169010aSmrg # POSIX demands no paths to be encoded in archives. We have 10908e169010aSmrg # to avoid creating archives with duplicate basenames if we 10909e169010aSmrg # might have to extract them afterwards, e.g., when creating a 10910e169010aSmrg # static archive out of a convenience library, or when linking 10911e169010aSmrg # the entirety of a libtool archive into another (currently 10912e169010aSmrg # not supported by libtool). 10913e169010aSmrg if (for obj in $oldobjs 10914e169010aSmrg do 10915e169010aSmrg func_basename "$obj" 10916e169010aSmrg $ECHO "$func_basename_result" 10917e169010aSmrg done | sort | sort -uc >/dev/null 2>&1); then 10918e169010aSmrg : 10919e169010aSmrg else 10920e8ead290Smrg echo "copying selected object files to avoid basename conflicts..." 109219d0ccd10Smrg gentop=$output_objdir/${outputname}x 10922c63293b5Smrg func_append generated " $gentop" 10923e169010aSmrg func_mkdir_p "$gentop" 10924e169010aSmrg save_oldobjs=$oldobjs 10925e169010aSmrg oldobjs= 10926e169010aSmrg counter=1 10927e169010aSmrg for obj in $save_oldobjs 10928e169010aSmrg do 10929e169010aSmrg func_basename "$obj" 109309d0ccd10Smrg objbase=$func_basename_result 10931e169010aSmrg case " $oldobjs " in 10932e169010aSmrg " ") oldobjs=$obj ;; 10933e169010aSmrg *[\ /]"$objbase "*) 10934e169010aSmrg while :; do 10935e169010aSmrg # Make sure we don't pick an alternate name that also 10936e169010aSmrg # overlaps. 10937e169010aSmrg newobj=lt$counter-$objbase 10938e169010aSmrg func_arith $counter + 1 10939e169010aSmrg counter=$func_arith_result 10940e169010aSmrg case " $oldobjs " in 10941e169010aSmrg *[\ /]"$newobj "*) ;; 10942e169010aSmrg *) if test ! -f "$gentop/$newobj"; then break; fi ;; 10943e169010aSmrg esac 10944e169010aSmrg done 10945e169010aSmrg func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" 10946c63293b5Smrg func_append oldobjs " $gentop/$newobj" 10947e169010aSmrg ;; 10948c63293b5Smrg *) func_append oldobjs " $obj" ;; 10949e169010aSmrg esac 109507914d74bSmrg done 109517914d74bSmrg fi 10952e6d5e4e0Smrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 10953e6d5e4e0Smrg tool_oldlib=$func_to_tool_file_result 10954e169010aSmrg eval cmds=\"$old_archive_cmds\" 109557914d74bSmrg 10956e169010aSmrg func_len " $cmds" 10957e169010aSmrg len=$func_len_result 10958e169010aSmrg if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 10959e169010aSmrg cmds=$old_archive_cmds 10960c63293b5Smrg elif test -n "$archiver_list_spec"; then 10961c63293b5Smrg func_verbose "using command file archive linking..." 10962c63293b5Smrg for obj in $oldobjs 10963c63293b5Smrg do 10964c63293b5Smrg func_to_tool_file "$obj" 10965c63293b5Smrg $ECHO "$func_to_tool_file_result" 10966c63293b5Smrg done > $output_objdir/$libname.libcmd 10967c63293b5Smrg func_to_tool_file "$output_objdir/$libname.libcmd" 10968c63293b5Smrg oldobjs=" $archiver_list_spec$func_to_tool_file_result" 10969c63293b5Smrg cmds=$old_archive_cmds 10970e169010aSmrg else 10971e169010aSmrg # the command line is too long to link in one step, link in parts 10972e169010aSmrg func_verbose "using piecewise archive linking..." 10973e169010aSmrg save_RANLIB=$RANLIB 10974e169010aSmrg RANLIB=: 10975e169010aSmrg objlist= 10976e169010aSmrg concat_cmds= 10977e169010aSmrg save_oldobjs=$oldobjs 10978e169010aSmrg oldobjs= 10979e169010aSmrg # Is there a better way of finding the last object in the list? 10980e169010aSmrg for obj in $save_oldobjs 10981e169010aSmrg do 10982e169010aSmrg last_oldobj=$obj 10983e169010aSmrg done 10984e169010aSmrg eval test_cmds=\"$old_archive_cmds\" 10985e169010aSmrg func_len " $test_cmds" 10986e169010aSmrg len0=$func_len_result 10987e169010aSmrg len=$len0 10988e169010aSmrg for obj in $save_oldobjs 10989e169010aSmrg do 10990e169010aSmrg func_len " $obj" 10991e169010aSmrg func_arith $len + $func_len_result 10992e169010aSmrg len=$func_arith_result 10993e169010aSmrg func_append objlist " $obj" 10994e169010aSmrg if test "$len" -lt "$max_cmd_len"; then 10995e169010aSmrg : 10996e169010aSmrg else 10997e169010aSmrg # the above command should be used before it gets too long 10998e169010aSmrg oldobjs=$objlist 109999d0ccd10Smrg if test "$obj" = "$last_oldobj"; then 11000e169010aSmrg RANLIB=$save_RANLIB 11001e169010aSmrg fi 11002e169010aSmrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 110039d0ccd10Smrg eval concat_cmds=\"\$concat_cmds$old_archive_cmds\" 11004e169010aSmrg objlist= 11005e169010aSmrg len=$len0 11006e169010aSmrg fi 11007e169010aSmrg done 11008e169010aSmrg RANLIB=$save_RANLIB 11009e169010aSmrg oldobjs=$objlist 110109d0ccd10Smrg if test -z "$oldobjs"; then 11011e169010aSmrg eval cmds=\"\$concat_cmds\" 11012e169010aSmrg else 11013e169010aSmrg eval cmds=\"\$concat_cmds~\$old_archive_cmds\" 11014e169010aSmrg fi 11015e169010aSmrg fi 11016e169010aSmrg fi 11017e169010aSmrg func_execute_cmds "$cmds" 'exit $?' 110187914d74bSmrg done 110197914d74bSmrg 11020e169010aSmrg test -n "$generated" && \ 11021e169010aSmrg func_show_eval "${RM}r$generated" 110227914d74bSmrg 11023e169010aSmrg # Now create the libtool archive. 11024e169010aSmrg case $output in 11025e169010aSmrg *.la) 11026e169010aSmrg old_library= 110279d0ccd10Smrg test yes = "$build_old_libs" && old_library=$libname.$libext 11028e169010aSmrg func_verbose "creating $output" 110297914d74bSmrg 11030e169010aSmrg # Preserve any variables that may affect compiler behavior 11031e169010aSmrg for var in $variables_saved_for_relink; do 11032e169010aSmrg if eval test -z \"\${$var+set}\"; then 11033e169010aSmrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 11034e169010aSmrg elif eval var_value=\$$var; test -z "$var_value"; then 11035e169010aSmrg relink_command="$var=; export $var; $relink_command" 110367914d74bSmrg else 110370ea508b1Smrg func_quote_arg pretty,unquoted "$var_value" 110380ea508b1Smrg relink_command="$var=$func_quote_arg_unquoted_result; export $var; $relink_command" 110397914d74bSmrg fi 11040e169010aSmrg done 11041e169010aSmrg # Quote the link command for shipping. 110420ea508b1Smrg func_quote eval cd "`pwd`" 110430ea508b1Smrg relink_command="($func_quote_result; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" 110440ea508b1Smrg func_quote_arg pretty,unquoted "$relink_command" 110450ea508b1Smrg relink_command=$func_quote_arg_unquoted_result 110469d0ccd10Smrg if test yes = "$hardcode_automatic"; then 11047e169010aSmrg relink_command= 11048e169010aSmrg fi 110497914d74bSmrg 11050e169010aSmrg # Only create the output if not a dry run. 11051e169010aSmrg $opt_dry_run || { 11052e169010aSmrg for installed in no yes; do 110539d0ccd10Smrg if test yes = "$installed"; then 11054e169010aSmrg if test -z "$install_libdir"; then 11055e169010aSmrg break 11056e169010aSmrg fi 110579d0ccd10Smrg output=$output_objdir/${outputname}i 11058e169010aSmrg # Replace all uninstalled libtool libraries with the installed ones 11059e169010aSmrg newdependency_libs= 11060e169010aSmrg for deplib in $dependency_libs; do 11061e169010aSmrg case $deplib in 11062e169010aSmrg *.la) 11063e169010aSmrg func_basename "$deplib" 110649d0ccd10Smrg name=$func_basename_result 11065e6d5e4e0Smrg func_resolve_sysroot "$deplib" 110669d0ccd10Smrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` 11067e169010aSmrg test -z "$libdir" && \ 110689d0ccd10Smrg func_fatal_error "'$deplib' is not a valid libtool archive" 11069c63293b5Smrg func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" 11070c63293b5Smrg ;; 11071c63293b5Smrg -L*) 11072c63293b5Smrg func_stripname -L '' "$deplib" 11073c63293b5Smrg func_replace_sysroot "$func_stripname_result" 11074c63293b5Smrg func_append newdependency_libs " -L$func_replace_sysroot_result" 11075c63293b5Smrg ;; 11076c63293b5Smrg -R*) 11077c63293b5Smrg func_stripname -R '' "$deplib" 11078c63293b5Smrg func_replace_sysroot "$func_stripname_result" 11079c63293b5Smrg func_append newdependency_libs " -R$func_replace_sysroot_result" 11080e169010aSmrg ;; 11081c63293b5Smrg *) func_append newdependency_libs " $deplib" ;; 11082e169010aSmrg esac 11083e169010aSmrg done 110849d0ccd10Smrg dependency_libs=$newdependency_libs 11085e169010aSmrg newdlfiles= 11086e169010aSmrg 11087e169010aSmrg for lib in $dlfiles; do 11088e169010aSmrg case $lib in 11089e169010aSmrg *.la) 11090e169010aSmrg func_basename "$lib" 110919d0ccd10Smrg name=$func_basename_result 110929d0ccd10Smrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 11093e169010aSmrg test -z "$libdir" && \ 110949d0ccd10Smrg func_fatal_error "'$lib' is not a valid libtool archive" 11095c63293b5Smrg func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" 11096e169010aSmrg ;; 11097c63293b5Smrg *) func_append newdlfiles " $lib" ;; 11098e169010aSmrg esac 11099e169010aSmrg done 111009d0ccd10Smrg dlfiles=$newdlfiles 11101e169010aSmrg newdlprefiles= 11102e169010aSmrg for lib in $dlprefiles; do 11103e169010aSmrg case $lib in 11104e169010aSmrg *.la) 11105e169010aSmrg # Only pass preopened files to the pseudo-archive (for 11106e169010aSmrg # eventual linking with the app. that links it) if we 11107e169010aSmrg # didn't already link the preopened objects directly into 11108e169010aSmrg # the library: 11109e169010aSmrg func_basename "$lib" 111109d0ccd10Smrg name=$func_basename_result 111119d0ccd10Smrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 11112e169010aSmrg test -z "$libdir" && \ 111139d0ccd10Smrg func_fatal_error "'$lib' is not a valid libtool archive" 11114c63293b5Smrg func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" 11115e169010aSmrg ;; 11116e169010aSmrg esac 11117e169010aSmrg done 111189d0ccd10Smrg dlprefiles=$newdlprefiles 11119e169010aSmrg else 11120e169010aSmrg newdlfiles= 11121e169010aSmrg for lib in $dlfiles; do 11122e169010aSmrg case $lib in 111239d0ccd10Smrg [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; 11124e169010aSmrg *) abs=`pwd`"/$lib" ;; 11125e169010aSmrg esac 11126c63293b5Smrg func_append newdlfiles " $abs" 11127e169010aSmrg done 111289d0ccd10Smrg dlfiles=$newdlfiles 11129e169010aSmrg newdlprefiles= 11130e169010aSmrg for lib in $dlprefiles; do 11131e169010aSmrg case $lib in 111329d0ccd10Smrg [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; 11133e169010aSmrg *) abs=`pwd`"/$lib" ;; 11134e169010aSmrg esac 11135c63293b5Smrg func_append newdlprefiles " $abs" 11136e169010aSmrg done 111379d0ccd10Smrg dlprefiles=$newdlprefiles 11138e169010aSmrg fi 11139e169010aSmrg $RM $output 11140e169010aSmrg # place dlname in correct position for cygwin 11141e8ead290Smrg # In fact, it would be nice if we could use this code for all target 11142e8ead290Smrg # systems that can't hard-code library paths into their executables 11143e8ead290Smrg # and that have no shared library path variable independent of PATH, 11144e8ead290Smrg # but it turns out we can't easily determine that from inspecting 11145e8ead290Smrg # libtool variables, so we have to hard-code the OSs to which it 11146e8ead290Smrg # applies here; at the moment, that means platforms that use the PE 11147e8ead290Smrg # object format with DLL files. See the long comment at the top of 11148e8ead290Smrg # tests/bindir.at for full details. 11149e169010aSmrg tdlname=$dlname 11150e169010aSmrg case $host,$output,$installed,$module,$dlname in 11151e8ead290Smrg *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) 11152e8ead290Smrg # If a -bindir argument was supplied, place the dll there. 111539d0ccd10Smrg if test -n "$bindir"; then 11154e8ead290Smrg func_relative_path "$install_libdir" "$bindir" 111559d0ccd10Smrg tdlname=$func_relative_path_result/$dlname 11156e8ead290Smrg else 11157e8ead290Smrg # Otherwise fall back on heuristic. 11158e8ead290Smrg tdlname=../bin/$dlname 11159e8ead290Smrg fi 11160e8ead290Smrg ;; 11161e169010aSmrg esac 11162e169010aSmrg $ECHO > $output "\ 11163e169010aSmrg# $outputname - a libtool library file 111649d0ccd10Smrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 11165e169010aSmrg# 11166e169010aSmrg# Please DO NOT delete this file! 11167e169010aSmrg# It is necessary for linking the library. 111687914d74bSmrg 11169e169010aSmrg# The name that we can dlopen(3). 11170e169010aSmrgdlname='$tdlname' 111717914d74bSmrg 11172e169010aSmrg# Names of this library. 11173e169010aSmrglibrary_names='$library_names' 111747914d74bSmrg 11175e169010aSmrg# The name of the static archive. 11176e169010aSmrgold_library='$old_library' 111777914d74bSmrg 111789d0ccd10Smrg# Linker flags that cannot go in dependency_libs. 11179e169010aSmrginherited_linker_flags='$new_inherited_linker_flags' 111807914d74bSmrg 11181e169010aSmrg# Libraries that this one depends upon. 11182e169010aSmrgdependency_libs='$dependency_libs' 111837914d74bSmrg 11184e169010aSmrg# Names of additional weak libraries provided by this library 11185e169010aSmrgweak_library_names='$weak_libs' 111867914d74bSmrg 11187e169010aSmrg# Version information for $libname. 11188e169010aSmrgcurrent=$current 11189e169010aSmrgage=$age 11190e169010aSmrgrevision=$revision 111917914d74bSmrg 11192e169010aSmrg# Is this an already installed library? 11193e169010aSmrginstalled=$installed 111947914d74bSmrg 11195e169010aSmrg# Should we warn about portability when linking against -modules? 11196e169010aSmrgshouldnotlink=$module 111977914d74bSmrg 11198e169010aSmrg# Files to dlopen/dlpreopen 11199e169010aSmrgdlopen='$dlfiles' 11200e169010aSmrgdlpreopen='$dlprefiles' 112017914d74bSmrg 11202e169010aSmrg# Directory that this library needs to be installed in: 11203e169010aSmrglibdir='$install_libdir'" 112049d0ccd10Smrg if test no,yes = "$installed,$need_relink"; then 11205e169010aSmrg $ECHO >> $output "\ 11206e169010aSmrgrelink_command=\"$relink_command\"" 11207e169010aSmrg fi 11208e169010aSmrg done 11209e169010aSmrg } 112107914d74bSmrg 11211e169010aSmrg # Do a symbolic link so that the libtool archive can be found in 11212e169010aSmrg # LD_LIBRARY_PATH before the program is installed. 11213e169010aSmrg func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' 11214e169010aSmrg ;; 11215e169010aSmrg esac 11216e169010aSmrg exit $EXIT_SUCCESS 11217e169010aSmrg} 112187914d74bSmrg 112199d0ccd10Smrgif test link = "$opt_mode" || test relink = "$opt_mode"; then 112209d0ccd10Smrg func_mode_link ${1+"$@"} 112219d0ccd10Smrgfi 112227914d74bSmrg 112237914d74bSmrg 11224e169010aSmrg# func_mode_uninstall arg... 11225e169010aSmrgfunc_mode_uninstall () 11226e169010aSmrg{ 112279d0ccd10Smrg $debug_cmd 112289d0ccd10Smrg 112299d0ccd10Smrg RM=$nonopt 112307914d74bSmrg files= 112319d0ccd10Smrg rmforce=false 112327914d74bSmrg exit_status=0 112337914d74bSmrg 112347914d74bSmrg # This variable tells wrapper scripts just to set variables rather 112357914d74bSmrg # than running their programs. 112369d0ccd10Smrg libtool_install_magic=$magic 112377914d74bSmrg 112387914d74bSmrg for arg 112397914d74bSmrg do 112407914d74bSmrg case $arg in 112419d0ccd10Smrg -f) func_append RM " $arg"; rmforce=: ;; 11242c63293b5Smrg -*) func_append RM " $arg" ;; 11243c63293b5Smrg *) func_append files " $arg" ;; 112447914d74bSmrg esac 112457914d74bSmrg done 112467914d74bSmrg 11247e169010aSmrg test -z "$RM" && \ 11248e169010aSmrg func_fatal_help "you must specify an RM program" 112497914d74bSmrg 112507914d74bSmrg rmdirs= 112517914d74bSmrg 112527914d74bSmrg for file in $files; do 11253e169010aSmrg func_dirname "$file" "" "." 112549d0ccd10Smrg dir=$func_dirname_result 112559d0ccd10Smrg if test . = "$dir"; then 112569d0ccd10Smrg odir=$objdir 112577914d74bSmrg else 112589d0ccd10Smrg odir=$dir/$objdir 112597914d74bSmrg fi 11260e169010aSmrg func_basename "$file" 112619d0ccd10Smrg name=$func_basename_result 112629d0ccd10Smrg test uninstall = "$opt_mode" && odir=$dir 112637914d74bSmrg 11264c63293b5Smrg # Remember odir for removal later, being careful to avoid duplicates 112659d0ccd10Smrg if test clean = "$opt_mode"; then 112667914d74bSmrg case " $rmdirs " in 11267c63293b5Smrg *" $odir "*) ;; 11268c63293b5Smrg *) func_append rmdirs " $odir" ;; 112697914d74bSmrg esac 112707914d74bSmrg fi 112717914d74bSmrg 112727914d74bSmrg # Don't error if the file doesn't exist and rm -f was used. 11273e169010aSmrg if { test -L "$file"; } >/dev/null 2>&1 || 11274e169010aSmrg { test -h "$file"; } >/dev/null 2>&1 || 11275e169010aSmrg test -f "$file"; then 112767914d74bSmrg : 112777914d74bSmrg elif test -d "$file"; then 112787914d74bSmrg exit_status=1 112797914d74bSmrg continue 112809d0ccd10Smrg elif $rmforce; then 112817914d74bSmrg continue 112827914d74bSmrg fi 112837914d74bSmrg 112849d0ccd10Smrg rmfiles=$file 112857914d74bSmrg 112867914d74bSmrg case $name in 112877914d74bSmrg *.la) 112887914d74bSmrg # Possibly a libtool archive, so verify it. 11289e169010aSmrg if func_lalib_p "$file"; then 11290e169010aSmrg func_source $dir/$name 112917914d74bSmrg 112927914d74bSmrg # Delete the libtool libraries and symlinks. 112937914d74bSmrg for n in $library_names; do 11294c63293b5Smrg func_append rmfiles " $odir/$n" 112957914d74bSmrg done 11296c63293b5Smrg test -n "$old_library" && func_append rmfiles " $odir/$old_library" 112977914d74bSmrg 112989d0ccd10Smrg case $opt_mode in 112997914d74bSmrg clean) 11300c63293b5Smrg case " $library_names " in 113017914d74bSmrg *" $dlname "*) ;; 11302c63293b5Smrg *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; 113037914d74bSmrg esac 11304c63293b5Smrg test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" 113057914d74bSmrg ;; 113067914d74bSmrg uninstall) 113077914d74bSmrg if test -n "$library_names"; then 113087914d74bSmrg # Do each command in the postuninstall commands. 113099d0ccd10Smrg func_execute_cmds "$postuninstall_cmds" '$rmforce || exit_status=1' 113107914d74bSmrg fi 113117914d74bSmrg 113127914d74bSmrg if test -n "$old_library"; then 113137914d74bSmrg # Do each command in the old_postuninstall commands. 113149d0ccd10Smrg func_execute_cmds "$old_postuninstall_cmds" '$rmforce || exit_status=1' 113157914d74bSmrg fi 113167914d74bSmrg # FIXME: should reinstall the best remaining shared library. 113177914d74bSmrg ;; 113187914d74bSmrg esac 113197914d74bSmrg fi 113207914d74bSmrg ;; 113217914d74bSmrg 113227914d74bSmrg *.lo) 113237914d74bSmrg # Possibly a libtool object, so verify it. 11324e169010aSmrg if func_lalib_p "$file"; then 113257914d74bSmrg 113267914d74bSmrg # Read the .lo file 11327e169010aSmrg func_source $dir/$name 113287914d74bSmrg 113297914d74bSmrg # Add PIC object to the list of files to remove. 113309d0ccd10Smrg if test -n "$pic_object" && test none != "$pic_object"; then 11331c63293b5Smrg func_append rmfiles " $dir/$pic_object" 113327914d74bSmrg fi 113337914d74bSmrg 113347914d74bSmrg # Add non-PIC object to the list of files to remove. 113359d0ccd10Smrg if test -n "$non_pic_object" && test none != "$non_pic_object"; then 11336c63293b5Smrg func_append rmfiles " $dir/$non_pic_object" 113377914d74bSmrg fi 113387914d74bSmrg fi 113397914d74bSmrg ;; 113407914d74bSmrg 113417914d74bSmrg *) 113429d0ccd10Smrg if test clean = "$opt_mode"; then 113437914d74bSmrg noexename=$name 113447914d74bSmrg case $file in 113457914d74bSmrg *.exe) 11346e169010aSmrg func_stripname '' '.exe' "$file" 11347e169010aSmrg file=$func_stripname_result 11348e169010aSmrg func_stripname '' '.exe' "$name" 11349e169010aSmrg noexename=$func_stripname_result 113507914d74bSmrg # $file with .exe has already been added to rmfiles, 113517914d74bSmrg # add $file without .exe 11352c63293b5Smrg func_append rmfiles " $file" 113537914d74bSmrg ;; 113547914d74bSmrg esac 113557914d74bSmrg # Do a test to see if this is a libtool program. 11356e169010aSmrg if func_ltwrapper_p "$file"; then 11357e169010aSmrg if func_ltwrapper_executable_p "$file"; then 11358e169010aSmrg func_ltwrapper_scriptname "$file" 11359e169010aSmrg relink_command= 11360e169010aSmrg func_source $func_ltwrapper_scriptname_result 11361c63293b5Smrg func_append rmfiles " $func_ltwrapper_scriptname_result" 11362e169010aSmrg else 11363e169010aSmrg relink_command= 11364e169010aSmrg func_source $dir/$noexename 11365e169010aSmrg fi 113667914d74bSmrg 113677914d74bSmrg # note $name still contains .exe if it was in $file originally 113687914d74bSmrg # as does the version of $file that was added into $rmfiles 113699d0ccd10Smrg func_append rmfiles " $odir/$name $odir/${name}S.$objext" 113709d0ccd10Smrg if test yes = "$fast_install" && test -n "$relink_command"; then 11371c63293b5Smrg func_append rmfiles " $odir/lt-$name" 113727914d74bSmrg fi 113739d0ccd10Smrg if test "X$noexename" != "X$name"; then 113749d0ccd10Smrg func_append rmfiles " $odir/lt-$noexename.c" 113757914d74bSmrg fi 113767914d74bSmrg fi 113777914d74bSmrg fi 113787914d74bSmrg ;; 113797914d74bSmrg esac 11380e169010aSmrg func_show_eval "$RM $rmfiles" 'exit_status=1' 113817914d74bSmrg done 113827914d74bSmrg 113839d0ccd10Smrg # Try to remove the $objdir's in the directories where we deleted files 113847914d74bSmrg for dir in $rmdirs; do 113857914d74bSmrg if test -d "$dir"; then 11386e169010aSmrg func_show_eval "rmdir $dir >/dev/null 2>&1" 113877914d74bSmrg fi 113887914d74bSmrg done 113897914d74bSmrg 113907914d74bSmrg exit $exit_status 11391e169010aSmrg} 113927914d74bSmrg 113939d0ccd10Smrgif test uninstall = "$opt_mode" || test clean = "$opt_mode"; then 113949d0ccd10Smrg func_mode_uninstall ${1+"$@"} 113959d0ccd10Smrgfi 113967914d74bSmrg 11397c63293b5Smrgtest -z "$opt_mode" && { 113989d0ccd10Smrg help=$generic_help 11399e169010aSmrg func_fatal_help "you must specify a MODE" 11400e169010aSmrg} 11401e169010aSmrg 11402e169010aSmrgtest -z "$exec_cmd" && \ 114039d0ccd10Smrg func_fatal_help "invalid operation mode '$opt_mode'" 114047914d74bSmrg 114057914d74bSmrgif test -n "$exec_cmd"; then 11406e169010aSmrg eval exec "$exec_cmd" 114077914d74bSmrg exit $EXIT_FAILURE 114087914d74bSmrgfi 114097914d74bSmrg 11410e169010aSmrgexit $exit_status 114117914d74bSmrg 114127914d74bSmrg 114137914d74bSmrg# The TAGs below are defined such that we never get into a situation 114149d0ccd10Smrg# where we disable both kinds of libraries. Given conflicting 114157914d74bSmrg# choices, we go for a static library, that is the most portable, 114167914d74bSmrg# since we can't tell whether shared libraries were disabled because 114177914d74bSmrg# the user asked for that or because the platform doesn't support 114187914d74bSmrg# them. This is particularly important on AIX, because we don't 114197914d74bSmrg# support having both static and shared libraries enabled at the same 114207914d74bSmrg# time on that platform, so we default to a shared-only configuration. 114217914d74bSmrg# If a disable-shared tag is given, we'll fallback to a static-only 114227914d74bSmrg# configuration. But we'll never go from static-only to shared-only. 114237914d74bSmrg 114247914d74bSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared 11425e169010aSmrgbuild_libtool_libs=no 11426e169010aSmrgbuild_old_libs=yes 114277914d74bSmrg# ### END LIBTOOL TAG CONFIG: disable-shared 114287914d74bSmrg 114297914d74bSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static 11430e169010aSmrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` 114317914d74bSmrg# ### END LIBTOOL TAG CONFIG: disable-static 114327914d74bSmrg 114337914d74bSmrg# Local Variables: 114347914d74bSmrg# mode:shell-script 114357914d74bSmrg# sh-indentation:2 114367914d74bSmrg# End: 11437