ltmain.sh revision 0ea508b1
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 340ea508b1SmrgVERSION=2.4.7 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# 4339d0ccd10Smrg# debug_cmd='eval 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 # We should try to minimise forks, especially on Windows where they are 5769d0ccd10Smrg # unreasonably slow, so skip the feature probes when bash or zsh are 5779d0ccd10Smrg # being used: 5789d0ccd10Smrg if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then 5799d0ccd10Smrg : ${_G_HAVE_ARITH_OP="yes"} 5809d0ccd10Smrg : ${_G_HAVE_XSI_OPS="yes"} 5819d0ccd10Smrg # The += operator was introduced in bash 3.1 5829d0ccd10Smrg case $BASH_VERSION in 5839d0ccd10Smrg [12].* | 3.0 | 3.0*) ;; 5849d0ccd10Smrg *) 5859d0ccd10Smrg : ${_G_HAVE_PLUSEQ_OP="yes"} 5869d0ccd10Smrg ;; 5879d0ccd10Smrg esac 5889d0ccd10Smrg fi 5899d0ccd10Smrg 5909d0ccd10Smrg # _G_HAVE_PLUSEQ_OP 5919d0ccd10Smrg # Can be empty, in which case the shell is probed, "yes" if += is 5929d0ccd10Smrg # useable or anything else if it does not work. 5939d0ccd10Smrg test -z "$_G_HAVE_PLUSEQ_OP" \ 5949d0ccd10Smrg && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \ 5959d0ccd10Smrg && _G_HAVE_PLUSEQ_OP=yes 5969d0ccd10Smrg 5979d0ccd10Smrgif test yes = "$_G_HAVE_PLUSEQ_OP" 5989d0ccd10Smrgthen 5999d0ccd10Smrg # This is an XSI compatible shell, allowing a faster implementation... 6009d0ccd10Smrg eval 'func_append () 6019d0ccd10Smrg { 6029d0ccd10Smrg $debug_cmd 6039d0ccd10Smrg 6049d0ccd10Smrg eval "$1+=\$2" 6059d0ccd10Smrg }' 6069d0ccd10Smrgelse 6079d0ccd10Smrg # ...otherwise fall back to using expr, which is often a shell builtin. 6089d0ccd10Smrg func_append () 6099d0ccd10Smrg { 6109d0ccd10Smrg $debug_cmd 6119d0ccd10Smrg 6129d0ccd10Smrg eval "$1=\$$1\$2" 6139d0ccd10Smrg } 6149d0ccd10Smrgfi 6159d0ccd10Smrg 6169d0ccd10Smrg 6179d0ccd10Smrg# func_append_quoted VAR VALUE 6189d0ccd10Smrg# ---------------------------- 6199d0ccd10Smrg# Quote VALUE and append to the end of shell variable VAR, separated 6209d0ccd10Smrg# by a space. 6219d0ccd10Smrgif test yes = "$_G_HAVE_PLUSEQ_OP"; then 6229d0ccd10Smrg eval 'func_append_quoted () 6239d0ccd10Smrg { 6249d0ccd10Smrg $debug_cmd 6259d0ccd10Smrg 6260ea508b1Smrg func_quote_arg pretty "$2" 6270ea508b1Smrg eval "$1+=\\ \$func_quote_arg_result" 6289d0ccd10Smrg }' 6299d0ccd10Smrgelse 6309d0ccd10Smrg func_append_quoted () 6319d0ccd10Smrg { 6329d0ccd10Smrg $debug_cmd 6339d0ccd10Smrg 6340ea508b1Smrg func_quote_arg pretty "$2" 6350ea508b1Smrg eval "$1=\$$1\\ \$func_quote_arg_result" 6369d0ccd10Smrg } 6379d0ccd10Smrgfi 6389d0ccd10Smrg 6399d0ccd10Smrg 6409d0ccd10Smrg# func_append_uniq VAR VALUE 6419d0ccd10Smrg# -------------------------- 6429d0ccd10Smrg# Append unique VALUE onto the existing contents of VAR, assuming 6439d0ccd10Smrg# entries are delimited by the first character of VALUE. For example: 6449d0ccd10Smrg# 6459d0ccd10Smrg# func_append_uniq options " --another-option option-argument" 6469d0ccd10Smrg# 6479d0ccd10Smrg# will only append to $options if " --another-option option-argument " 6489d0ccd10Smrg# is not already present somewhere in $options already (note spaces at 6499d0ccd10Smrg# each end implied by leading space in second argument). 6509d0ccd10Smrgfunc_append_uniq () 6519d0ccd10Smrg{ 6529d0ccd10Smrg $debug_cmd 6539d0ccd10Smrg 6549d0ccd10Smrg eval _G_current_value='`$ECHO $'$1'`' 6559d0ccd10Smrg _G_delim=`expr "$2" : '\(.\)'` 6569d0ccd10Smrg 6579d0ccd10Smrg case $_G_delim$_G_current_value$_G_delim in 6589d0ccd10Smrg *"$2$_G_delim"*) ;; 6599d0ccd10Smrg *) func_append "$@" ;; 6609d0ccd10Smrg esac 6619d0ccd10Smrg} 6629d0ccd10Smrg 6639d0ccd10Smrg 6649d0ccd10Smrg# func_arith TERM... 6659d0ccd10Smrg# ------------------ 6669d0ccd10Smrg# Set func_arith_result to the result of evaluating TERMs. 6679d0ccd10Smrg test -z "$_G_HAVE_ARITH_OP" \ 6689d0ccd10Smrg && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \ 6699d0ccd10Smrg && _G_HAVE_ARITH_OP=yes 6709d0ccd10Smrg 6719d0ccd10Smrgif test yes = "$_G_HAVE_ARITH_OP"; then 6729d0ccd10Smrg eval 'func_arith () 6739d0ccd10Smrg { 6749d0ccd10Smrg $debug_cmd 6759d0ccd10Smrg 6769d0ccd10Smrg func_arith_result=$(( $* )) 6779d0ccd10Smrg }' 6789d0ccd10Smrgelse 6799d0ccd10Smrg func_arith () 6809d0ccd10Smrg { 6819d0ccd10Smrg $debug_cmd 6829d0ccd10Smrg 6839d0ccd10Smrg func_arith_result=`expr "$@"` 6849d0ccd10Smrg } 6859d0ccd10Smrgfi 6869d0ccd10Smrg 6879d0ccd10Smrg 6889d0ccd10Smrg# func_basename FILE 6899d0ccd10Smrg# ------------------ 6909d0ccd10Smrg# Set func_basename_result to FILE with everything up to and including 6919d0ccd10Smrg# the last / stripped. 6929d0ccd10Smrgif test yes = "$_G_HAVE_XSI_OPS"; then 6939d0ccd10Smrg # If this shell supports suffix pattern removal, then use it to avoid 6949d0ccd10Smrg # forking. Hide the definitions single quotes in case the shell chokes 6959d0ccd10Smrg # on unsupported syntax... 6969d0ccd10Smrg _b='func_basename_result=${1##*/}' 6979d0ccd10Smrg _d='case $1 in 6989d0ccd10Smrg */*) func_dirname_result=${1%/*}$2 ;; 6999d0ccd10Smrg * ) func_dirname_result=$3 ;; 7009d0ccd10Smrg esac' 7019d0ccd10Smrg 7029d0ccd10Smrgelse 7039d0ccd10Smrg # ...otherwise fall back to using sed. 7049d0ccd10Smrg _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`' 7059d0ccd10Smrg _d='func_dirname_result=`$ECHO "$1" |$SED "$sed_dirname"` 7069d0ccd10Smrg if test "X$func_dirname_result" = "X$1"; then 7079d0ccd10Smrg func_dirname_result=$3 7089d0ccd10Smrg else 7099d0ccd10Smrg func_append func_dirname_result "$2" 7109d0ccd10Smrg fi' 7119d0ccd10Smrgfi 7129d0ccd10Smrg 7139d0ccd10Smrgeval 'func_basename () 7149d0ccd10Smrg{ 7159d0ccd10Smrg $debug_cmd 7169d0ccd10Smrg 7179d0ccd10Smrg '"$_b"' 7189d0ccd10Smrg}' 7199d0ccd10Smrg 7209d0ccd10Smrg 7219d0ccd10Smrg# func_dirname FILE APPEND NONDIR_REPLACEMENT 7229d0ccd10Smrg# ------------------------------------------- 7239d0ccd10Smrg# Compute the dirname of FILE. If nonempty, add APPEND to the result, 7249d0ccd10Smrg# otherwise set result to NONDIR_REPLACEMENT. 7259d0ccd10Smrgeval 'func_dirname () 7269d0ccd10Smrg{ 7279d0ccd10Smrg $debug_cmd 7289d0ccd10Smrg 7299d0ccd10Smrg '"$_d"' 7309d0ccd10Smrg}' 7319d0ccd10Smrg 7329d0ccd10Smrg 7339d0ccd10Smrg# func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT 7349d0ccd10Smrg# -------------------------------------------------------- 7359d0ccd10Smrg# Perform func_basename and func_dirname in a single function 7369d0ccd10Smrg# call: 7379d0ccd10Smrg# dirname: Compute the dirname of FILE. If nonempty, 7389d0ccd10Smrg# add APPEND to the result, otherwise set result 7399d0ccd10Smrg# to NONDIR_REPLACEMENT. 7409d0ccd10Smrg# value returned in "$func_dirname_result" 7419d0ccd10Smrg# basename: Compute filename of FILE. 7429d0ccd10Smrg# value retuned in "$func_basename_result" 7439d0ccd10Smrg# For efficiency, we do not delegate to the functions above but instead 7449d0ccd10Smrg# duplicate the functionality here. 7459d0ccd10Smrgeval 'func_dirname_and_basename () 7469d0ccd10Smrg{ 7479d0ccd10Smrg $debug_cmd 7489d0ccd10Smrg 7499d0ccd10Smrg '"$_b"' 7509d0ccd10Smrg '"$_d"' 7519d0ccd10Smrg}' 7529d0ccd10Smrg 7539d0ccd10Smrg 7549d0ccd10Smrg# func_echo ARG... 7559d0ccd10Smrg# ---------------- 7569d0ccd10Smrg# Echo program name prefixed message. 7579d0ccd10Smrgfunc_echo () 7589d0ccd10Smrg{ 7599d0ccd10Smrg $debug_cmd 7609d0ccd10Smrg 7619d0ccd10Smrg _G_message=$* 7629d0ccd10Smrg 7639d0ccd10Smrg func_echo_IFS=$IFS 7649d0ccd10Smrg IFS=$nl 7659d0ccd10Smrg for _G_line in $_G_message; do 7669d0ccd10Smrg IFS=$func_echo_IFS 7679d0ccd10Smrg $ECHO "$progname: $_G_line" 7689d0ccd10Smrg done 7699d0ccd10Smrg IFS=$func_echo_IFS 7709d0ccd10Smrg} 7719d0ccd10Smrg 7729d0ccd10Smrg 7739d0ccd10Smrg# func_echo_all ARG... 7749d0ccd10Smrg# -------------------- 7759d0ccd10Smrg# Invoke $ECHO with all args, space-separated. 7769d0ccd10Smrgfunc_echo_all () 7779d0ccd10Smrg{ 7789d0ccd10Smrg $ECHO "$*" 7799d0ccd10Smrg} 7809d0ccd10Smrg 7819d0ccd10Smrg 7829d0ccd10Smrg# func_echo_infix_1 INFIX ARG... 7839d0ccd10Smrg# ------------------------------ 7849d0ccd10Smrg# Echo program name, followed by INFIX on the first line, with any 7859d0ccd10Smrg# additional lines not showing INFIX. 7869d0ccd10Smrgfunc_echo_infix_1 () 7879d0ccd10Smrg{ 7889d0ccd10Smrg $debug_cmd 7899d0ccd10Smrg 7909d0ccd10Smrg $require_term_colors 7919d0ccd10Smrg 7929d0ccd10Smrg _G_infix=$1; shift 7939d0ccd10Smrg _G_indent=$_G_infix 7949d0ccd10Smrg _G_prefix="$progname: $_G_infix: " 7959d0ccd10Smrg _G_message=$* 7969d0ccd10Smrg 7979d0ccd10Smrg # Strip color escape sequences before counting printable length 7989d0ccd10Smrg for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan" 7999d0ccd10Smrg do 8009d0ccd10Smrg test -n "$_G_tc" && { 8019d0ccd10Smrg _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"` 8029d0ccd10Smrg _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"` 8039d0ccd10Smrg } 8049d0ccd10Smrg done 8059d0ccd10Smrg _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`" " ## exclude from sc_prohibit_nested_quotes 8069d0ccd10Smrg 8079d0ccd10Smrg func_echo_infix_1_IFS=$IFS 8089d0ccd10Smrg IFS=$nl 8099d0ccd10Smrg for _G_line in $_G_message; do 8109d0ccd10Smrg IFS=$func_echo_infix_1_IFS 8119d0ccd10Smrg $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2 8129d0ccd10Smrg _G_prefix=$_G_indent 8139d0ccd10Smrg done 8149d0ccd10Smrg IFS=$func_echo_infix_1_IFS 8159d0ccd10Smrg} 8169d0ccd10Smrg 8179d0ccd10Smrg 8189d0ccd10Smrg# func_error ARG... 8199d0ccd10Smrg# ----------------- 8209d0ccd10Smrg# Echo program name prefixed message to standard error. 8219d0ccd10Smrgfunc_error () 8229d0ccd10Smrg{ 8239d0ccd10Smrg $debug_cmd 8249d0ccd10Smrg 8259d0ccd10Smrg $require_term_colors 8269d0ccd10Smrg 8279d0ccd10Smrg func_echo_infix_1 " $tc_standout${tc_red}error$tc_reset" "$*" >&2 8289d0ccd10Smrg} 8299d0ccd10Smrg 8309d0ccd10Smrg 8319d0ccd10Smrg# func_fatal_error ARG... 8329d0ccd10Smrg# ----------------------- 8339d0ccd10Smrg# Echo program name prefixed message to standard error, and exit. 8349d0ccd10Smrgfunc_fatal_error () 8359d0ccd10Smrg{ 8369d0ccd10Smrg $debug_cmd 8379d0ccd10Smrg 8389d0ccd10Smrg func_error "$*" 8399d0ccd10Smrg exit $EXIT_FAILURE 8409d0ccd10Smrg} 8419d0ccd10Smrg 8429d0ccd10Smrg 8439d0ccd10Smrg# func_grep EXPRESSION FILENAME 8449d0ccd10Smrg# ----------------------------- 845e169010aSmrg# Check whether EXPRESSION matches any line of FILENAME, without output. 846e169010aSmrgfunc_grep () 847e169010aSmrg{ 8489d0ccd10Smrg $debug_cmd 8499d0ccd10Smrg 850e169010aSmrg $GREP "$1" "$2" >/dev/null 2>&1 851e169010aSmrg} 852e169010aSmrg 853e169010aSmrg 8549d0ccd10Smrg# func_len STRING 8559d0ccd10Smrg# --------------- 8569d0ccd10Smrg# Set func_len_result to the length of STRING. STRING may not 8579d0ccd10Smrg# start with a hyphen. 8589d0ccd10Smrg test -z "$_G_HAVE_XSI_OPS" \ 8599d0ccd10Smrg && (eval 'x=a/b/c; 8609d0ccd10Smrg test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ 8619d0ccd10Smrg && _G_HAVE_XSI_OPS=yes 8629d0ccd10Smrg 8639d0ccd10Smrgif test yes = "$_G_HAVE_XSI_OPS"; then 8649d0ccd10Smrg eval 'func_len () 8659d0ccd10Smrg { 8669d0ccd10Smrg $debug_cmd 8679d0ccd10Smrg 8689d0ccd10Smrg func_len_result=${#1} 8699d0ccd10Smrg }' 8709d0ccd10Smrgelse 8719d0ccd10Smrg func_len () 8729d0ccd10Smrg { 8739d0ccd10Smrg $debug_cmd 8749d0ccd10Smrg 8759d0ccd10Smrg func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len` 8769d0ccd10Smrg } 8779d0ccd10Smrgfi 8789d0ccd10Smrg 8799d0ccd10Smrg 8809d0ccd10Smrg# func_mkdir_p DIRECTORY-PATH 8819d0ccd10Smrg# --------------------------- 882e169010aSmrg# Make sure the entire path to DIRECTORY-PATH is available. 883e169010aSmrgfunc_mkdir_p () 884e169010aSmrg{ 8859d0ccd10Smrg $debug_cmd 8869d0ccd10Smrg 8879d0ccd10Smrg _G_directory_path=$1 8889d0ccd10Smrg _G_dir_list= 889e169010aSmrg 8909d0ccd10Smrg if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then 891e169010aSmrg 8929d0ccd10Smrg # Protect directory names starting with '-' 8939d0ccd10Smrg case $_G_directory_path in 8949d0ccd10Smrg -*) _G_directory_path=./$_G_directory_path ;; 895e169010aSmrg esac 896e169010aSmrg 897e169010aSmrg # While some portion of DIR does not yet exist... 8989d0ccd10Smrg while test ! -d "$_G_directory_path"; do 899e169010aSmrg # ...make a list in topmost first order. Use a colon delimited 900e169010aSmrg # list incase some portion of path contains whitespace. 9019d0ccd10Smrg _G_dir_list=$_G_directory_path:$_G_dir_list 902e169010aSmrg 903e169010aSmrg # If the last portion added has no slash in it, the list is done 9049d0ccd10Smrg case $_G_directory_path in */*) ;; *) break ;; esac 905e169010aSmrg 906e169010aSmrg # ...otherwise throw away the child directory and loop 9079d0ccd10Smrg _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"` 908e169010aSmrg done 9099d0ccd10Smrg _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'` 910e169010aSmrg 9119d0ccd10Smrg func_mkdir_p_IFS=$IFS; IFS=: 9129d0ccd10Smrg for _G_dir in $_G_dir_list; do 9139d0ccd10Smrg IFS=$func_mkdir_p_IFS 9149d0ccd10Smrg # mkdir can fail with a 'File exist' error if two processes 915e169010aSmrg # try to create one of the directories concurrently. Don't 916e169010aSmrg # stop in that case! 9179d0ccd10Smrg $MKDIR "$_G_dir" 2>/dev/null || : 918e169010aSmrg done 9199d0ccd10Smrg IFS=$func_mkdir_p_IFS 920e169010aSmrg 921e169010aSmrg # Bail out if we (or some other process) failed to create a directory. 9229d0ccd10Smrg test -d "$_G_directory_path" || \ 9239d0ccd10Smrg func_fatal_error "Failed to create '$1'" 924e169010aSmrg fi 925e169010aSmrg} 9267914d74bSmrg 9277914d74bSmrg 9289d0ccd10Smrg# func_mktempdir [BASENAME] 9299d0ccd10Smrg# ------------------------- 9307914d74bSmrg# Make a temporary directory that won't clash with other running 9317914d74bSmrg# libtool processes, and avoids race conditions if possible. If 9329d0ccd10Smrg# given, BASENAME is the basename for that directory. 9337914d74bSmrgfunc_mktempdir () 9347914d74bSmrg{ 9359d0ccd10Smrg $debug_cmd 9369d0ccd10Smrg 9379d0ccd10Smrg _G_template=${TMPDIR-/tmp}/${1-$progname} 9387914d74bSmrg 9399d0ccd10Smrg if test : = "$opt_dry_run"; then 9407914d74bSmrg # Return a directory name, but don't create it in dry-run mode 9419d0ccd10Smrg _G_tmpdir=$_G_template-$$ 9427914d74bSmrg else 9437914d74bSmrg 9447914d74bSmrg # If mktemp works, use that first and foremost 9459d0ccd10Smrg _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null` 9467914d74bSmrg 9479d0ccd10Smrg if test ! -d "$_G_tmpdir"; then 948e169010aSmrg # Failing that, at least try and use $RANDOM to avoid a race 9499d0ccd10Smrg _G_tmpdir=$_G_template-${RANDOM-0}$$ 9507914d74bSmrg 9519d0ccd10Smrg func_mktempdir_umask=`umask` 952e169010aSmrg umask 0077 9539d0ccd10Smrg $MKDIR "$_G_tmpdir" 9549d0ccd10Smrg umask $func_mktempdir_umask 9557914d74bSmrg fi 9567914d74bSmrg 9577914d74bSmrg # If we're not in dry-run mode, bomb out on failure 9589d0ccd10Smrg test -d "$_G_tmpdir" || \ 9599d0ccd10Smrg func_fatal_error "cannot create temporary directory '$_G_tmpdir'" 9607914d74bSmrg fi 9617914d74bSmrg 9629d0ccd10Smrg $ECHO "$_G_tmpdir" 9637914d74bSmrg} 9647914d74bSmrg 9657914d74bSmrg 9669d0ccd10Smrg# func_normal_abspath PATH 9679d0ccd10Smrg# ------------------------ 9689d0ccd10Smrg# Remove doubled-up and trailing slashes, "." path components, 9699d0ccd10Smrg# and cancel out any ".." path components in PATH after making 9709d0ccd10Smrg# it an absolute path. 9719d0ccd10Smrgfunc_normal_abspath () 9727914d74bSmrg{ 9739d0ccd10Smrg $debug_cmd 974e169010aSmrg 9759d0ccd10Smrg # These SED scripts presuppose an absolute path with a trailing slash. 9769d0ccd10Smrg _G_pathcar='s|^/\([^/]*\).*$|\1|' 9779d0ccd10Smrg _G_pathcdr='s|^/[^/]*||' 9789d0ccd10Smrg _G_removedotparts=':dotsl 9799d0ccd10Smrg s|/\./|/|g 9809d0ccd10Smrg t dotsl 9819d0ccd10Smrg s|/\.$|/|' 9829d0ccd10Smrg _G_collapseslashes='s|/\{1,\}|/|g' 9839d0ccd10Smrg _G_finalslash='s|/*$|/|' 9849d0ccd10Smrg 9859d0ccd10Smrg # Start from root dir and reassemble the path. 9869d0ccd10Smrg func_normal_abspath_result= 9879d0ccd10Smrg func_normal_abspath_tpath=$1 9889d0ccd10Smrg func_normal_abspath_altnamespace= 9899d0ccd10Smrg case $func_normal_abspath_tpath in 9909d0ccd10Smrg "") 9919d0ccd10Smrg # Empty path, that just means $cwd. 9929d0ccd10Smrg func_stripname '' '/' "`pwd`" 9939d0ccd10Smrg func_normal_abspath_result=$func_stripname_result 9949d0ccd10Smrg return 9959d0ccd10Smrg ;; 9969d0ccd10Smrg # The next three entries are used to spot a run of precisely 9979d0ccd10Smrg # two leading slashes without using negated character classes; 9989d0ccd10Smrg # we take advantage of case's first-match behaviour. 9999d0ccd10Smrg ///*) 10009d0ccd10Smrg # Unusual form of absolute path, do nothing. 10019d0ccd10Smrg ;; 10029d0ccd10Smrg //*) 10039d0ccd10Smrg # Not necessarily an ordinary path; POSIX reserves leading '//' 10049d0ccd10Smrg # and for example Cygwin uses it to access remote file shares 10059d0ccd10Smrg # over CIFS/SMB, so we conserve a leading double slash if found. 10069d0ccd10Smrg func_normal_abspath_altnamespace=/ 10079d0ccd10Smrg ;; 10089d0ccd10Smrg /*) 10099d0ccd10Smrg # Absolute path, do nothing. 1010e169010aSmrg ;; 1011e169010aSmrg *) 10129d0ccd10Smrg # Relative path, prepend $cwd. 10139d0ccd10Smrg func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath 10149d0ccd10Smrg ;; 10157914d74bSmrg esac 10169d0ccd10Smrg 10179d0ccd10Smrg # Cancel out all the simple stuff to save iterations. We also want 10189d0ccd10Smrg # the path to end with a slash for ease of parsing, so make sure 10199d0ccd10Smrg # there is one (and only one) here. 10209d0ccd10Smrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 10219d0ccd10Smrg -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"` 10229d0ccd10Smrg while :; do 10239d0ccd10Smrg # Processed it all yet? 10249d0ccd10Smrg if test / = "$func_normal_abspath_tpath"; then 10259d0ccd10Smrg # If we ascended to the root using ".." the result may be empty now. 10269d0ccd10Smrg if test -z "$func_normal_abspath_result"; then 10279d0ccd10Smrg func_normal_abspath_result=/ 10289d0ccd10Smrg fi 10299d0ccd10Smrg break 10309d0ccd10Smrg fi 10319d0ccd10Smrg func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ 10329d0ccd10Smrg -e "$_G_pathcar"` 10339d0ccd10Smrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 10349d0ccd10Smrg -e "$_G_pathcdr"` 10359d0ccd10Smrg # Figure out what to do with it 10369d0ccd10Smrg case $func_normal_abspath_tcomponent in 10379d0ccd10Smrg "") 10389d0ccd10Smrg # Trailing empty path component, ignore it. 10399d0ccd10Smrg ;; 10409d0ccd10Smrg ..) 10419d0ccd10Smrg # Parent dir; strip last assembled component from result. 10429d0ccd10Smrg func_dirname "$func_normal_abspath_result" 10439d0ccd10Smrg func_normal_abspath_result=$func_dirname_result 10449d0ccd10Smrg ;; 10459d0ccd10Smrg *) 10469d0ccd10Smrg # Actual path component, append it. 10479d0ccd10Smrg func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent" 10489d0ccd10Smrg ;; 10499d0ccd10Smrg esac 10509d0ccd10Smrg done 10519d0ccd10Smrg # Restore leading double-slash if one was found on entry. 10529d0ccd10Smrg func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result 10539d0ccd10Smrg} 10549d0ccd10Smrg 10559d0ccd10Smrg 10569d0ccd10Smrg# func_notquiet ARG... 10579d0ccd10Smrg# -------------------- 10589d0ccd10Smrg# Echo program name prefixed message only when not in quiet mode. 10599d0ccd10Smrgfunc_notquiet () 10609d0ccd10Smrg{ 10619d0ccd10Smrg $debug_cmd 10629d0ccd10Smrg 10639d0ccd10Smrg $opt_quiet || func_echo ${1+"$@"} 10649d0ccd10Smrg 10659d0ccd10Smrg # A bug in bash halts the script if the last line of a function 10669d0ccd10Smrg # fails when set -e is in force, so we need another command to 10679d0ccd10Smrg # work around that: 10689d0ccd10Smrg : 10699d0ccd10Smrg} 10709d0ccd10Smrg 10719d0ccd10Smrg 10729d0ccd10Smrg# func_relative_path SRCDIR DSTDIR 10739d0ccd10Smrg# -------------------------------- 10749d0ccd10Smrg# Set func_relative_path_result to the relative path from SRCDIR to DSTDIR. 10759d0ccd10Smrgfunc_relative_path () 10769d0ccd10Smrg{ 10779d0ccd10Smrg $debug_cmd 10789d0ccd10Smrg 10799d0ccd10Smrg func_relative_path_result= 10809d0ccd10Smrg func_normal_abspath "$1" 10819d0ccd10Smrg func_relative_path_tlibdir=$func_normal_abspath_result 10829d0ccd10Smrg func_normal_abspath "$2" 10839d0ccd10Smrg func_relative_path_tbindir=$func_normal_abspath_result 10849d0ccd10Smrg 10859d0ccd10Smrg # Ascend the tree starting from libdir 10869d0ccd10Smrg while :; do 10879d0ccd10Smrg # check if we have found a prefix of bindir 10889d0ccd10Smrg case $func_relative_path_tbindir in 10899d0ccd10Smrg $func_relative_path_tlibdir) 10909d0ccd10Smrg # found an exact match 10919d0ccd10Smrg func_relative_path_tcancelled= 10929d0ccd10Smrg break 10939d0ccd10Smrg ;; 10949d0ccd10Smrg $func_relative_path_tlibdir*) 10959d0ccd10Smrg # found a matching prefix 10969d0ccd10Smrg func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" 10979d0ccd10Smrg func_relative_path_tcancelled=$func_stripname_result 10989d0ccd10Smrg if test -z "$func_relative_path_result"; then 10999d0ccd10Smrg func_relative_path_result=. 11009d0ccd10Smrg fi 11019d0ccd10Smrg break 11029d0ccd10Smrg ;; 11039d0ccd10Smrg *) 11049d0ccd10Smrg func_dirname $func_relative_path_tlibdir 11059d0ccd10Smrg func_relative_path_tlibdir=$func_dirname_result 11069d0ccd10Smrg if test -z "$func_relative_path_tlibdir"; then 11079d0ccd10Smrg # Have to descend all the way to the root! 11089d0ccd10Smrg func_relative_path_result=../$func_relative_path_result 11099d0ccd10Smrg func_relative_path_tcancelled=$func_relative_path_tbindir 11109d0ccd10Smrg break 11119d0ccd10Smrg fi 11129d0ccd10Smrg func_relative_path_result=../$func_relative_path_result 11139d0ccd10Smrg ;; 11149d0ccd10Smrg esac 11159d0ccd10Smrg done 11169d0ccd10Smrg 11179d0ccd10Smrg # Now calculate path; take care to avoid doubling-up slashes. 11189d0ccd10Smrg func_stripname '' '/' "$func_relative_path_result" 11199d0ccd10Smrg func_relative_path_result=$func_stripname_result 11209d0ccd10Smrg func_stripname '/' '/' "$func_relative_path_tcancelled" 11219d0ccd10Smrg if test -n "$func_stripname_result"; then 11229d0ccd10Smrg func_append func_relative_path_result "/$func_stripname_result" 11239d0ccd10Smrg fi 11249d0ccd10Smrg 11259d0ccd10Smrg # Normalisation. If bindir is libdir, return '.' else relative path. 11269d0ccd10Smrg if test -n "$func_relative_path_result"; then 11279d0ccd10Smrg func_stripname './' '' "$func_relative_path_result" 11289d0ccd10Smrg func_relative_path_result=$func_stripname_result 11299d0ccd10Smrg fi 11309d0ccd10Smrg 11319d0ccd10Smrg test -n "$func_relative_path_result" || func_relative_path_result=. 11329d0ccd10Smrg 11339d0ccd10Smrg : 11347914d74bSmrg} 11357914d74bSmrg 11367914d74bSmrg 11370ea508b1Smrg# func_quote_portable EVAL ARG 11380ea508b1Smrg# ---------------------------- 11390ea508b1Smrg# Internal function to portably implement func_quote_arg. Note that we still 11400ea508b1Smrg# keep attention to performance here so we as much as possible try to avoid 11410ea508b1Smrg# calling sed binary (so far O(N) complexity as long as func_append is O(1)). 11420ea508b1Smrgfunc_quote_portable () 11439d0ccd10Smrg{ 11449d0ccd10Smrg $debug_cmd 11459d0ccd10Smrg 11460ea508b1Smrg $require_check_ifs_backslash 11470ea508b1Smrg 11480ea508b1Smrg func_quote_portable_result=$2 11490ea508b1Smrg 11500ea508b1Smrg # one-time-loop (easy break) 11510ea508b1Smrg while true 11520ea508b1Smrg do 11530ea508b1Smrg if $1; then 11540ea508b1Smrg func_quote_portable_result=`$ECHO "$2" | $SED \ 11550ea508b1Smrg -e "$sed_double_quote_subst" -e "$sed_double_backslash"` 11560ea508b1Smrg break 11579d0ccd10Smrg fi 11589d0ccd10Smrg 11590ea508b1Smrg # Quote for eval. 11600ea508b1Smrg case $func_quote_portable_result in 11610ea508b1Smrg *[\\\`\"\$]*) 11620ea508b1Smrg # Fallback to sed for $func_check_bs_ifs_broken=:, or when the string 11630ea508b1Smrg # contains the shell wildcard characters. 11640ea508b1Smrg case $check_ifs_backshlash_broken$func_quote_portable_result in 11650ea508b1Smrg :*|*[\[\*\?]*) 11660ea508b1Smrg func_quote_portable_result=`$ECHO "$func_quote_portable_result" \ 11670ea508b1Smrg | $SED "$sed_quote_subst"` 11680ea508b1Smrg break 11690ea508b1Smrg ;; 11700ea508b1Smrg esac 11710ea508b1Smrg 11720ea508b1Smrg func_quote_portable_old_IFS=$IFS 11730ea508b1Smrg for _G_char in '\' '`' '"' '$' 11740ea508b1Smrg do 11750ea508b1Smrg # STATE($1) PREV($2) SEPARATOR($3) 11760ea508b1Smrg set start "" "" 11770ea508b1Smrg func_quote_portable_result=dummy"$_G_char$func_quote_portable_result$_G_char"dummy 11780ea508b1Smrg IFS=$_G_char 11790ea508b1Smrg for _G_part in $func_quote_portable_result 11800ea508b1Smrg do 11810ea508b1Smrg case $1 in 11820ea508b1Smrg quote) 11830ea508b1Smrg func_append func_quote_portable_result "$3$2" 11840ea508b1Smrg set quote "$_G_part" "\\$_G_char" 11850ea508b1Smrg ;; 11860ea508b1Smrg start) 11870ea508b1Smrg set first "" "" 11880ea508b1Smrg func_quote_portable_result= 11890ea508b1Smrg ;; 11900ea508b1Smrg first) 11910ea508b1Smrg set quote "$_G_part" "" 11920ea508b1Smrg ;; 11930ea508b1Smrg esac 11940ea508b1Smrg done 11950ea508b1Smrg done 11960ea508b1Smrg IFS=$func_quote_portable_old_IFS 11979d0ccd10Smrg ;; 11980ea508b1Smrg *) ;; 11999d0ccd10Smrg esac 12000ea508b1Smrg break 12019d0ccd10Smrg done 12020ea508b1Smrg 12030ea508b1Smrg func_quote_portable_unquoted_result=$func_quote_portable_result 12040ea508b1Smrg case $func_quote_portable_result in 12050ea508b1Smrg # double-quote args containing shell metacharacters to delay 12060ea508b1Smrg # word splitting, command substitution and variable expansion 12070ea508b1Smrg # for a subsequent eval. 12080ea508b1Smrg # many bourne shells cannot handle close brackets correctly 12090ea508b1Smrg # in scan sets, so we specify it separately. 12100ea508b1Smrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 12110ea508b1Smrg func_quote_portable_result=\"$func_quote_portable_result\" 12120ea508b1Smrg ;; 12130ea508b1Smrg esac 12149d0ccd10Smrg} 12159d0ccd10Smrg 12169d0ccd10Smrg 12170ea508b1Smrg# func_quotefast_eval ARG 12180ea508b1Smrg# ----------------------- 12190ea508b1Smrg# Quote one ARG (internal). This is equivalent to 'func_quote_arg eval ARG', 12200ea508b1Smrg# but optimized for speed. Result is stored in $func_quotefast_eval. 12210ea508b1Smrgif test xyes = `(x=; printf -v x %q yes; echo x"$x") 2>/dev/null`; then 12220ea508b1Smrg printf -v _GL_test_printf_tilde %q '~' 12230ea508b1Smrg if test '\~' = "$_GL_test_printf_tilde"; then 12240ea508b1Smrg func_quotefast_eval () 12250ea508b1Smrg { 12260ea508b1Smrg printf -v func_quotefast_eval_result %q "$1" 12270ea508b1Smrg } 12280ea508b1Smrg else 12290ea508b1Smrg # Broken older Bash implementations. Make those faster too if possible. 12300ea508b1Smrg func_quotefast_eval () 12310ea508b1Smrg { 12320ea508b1Smrg case $1 in 12330ea508b1Smrg '~'*) 12340ea508b1Smrg func_quote_portable false "$1" 12350ea508b1Smrg func_quotefast_eval_result=$func_quote_portable_result 12360ea508b1Smrg ;; 12370ea508b1Smrg *) 12380ea508b1Smrg printf -v func_quotefast_eval_result %q "$1" 12390ea508b1Smrg ;; 12400ea508b1Smrg esac 12410ea508b1Smrg } 12420ea508b1Smrg fi 12430ea508b1Smrgelse 12440ea508b1Smrg func_quotefast_eval () 12450ea508b1Smrg { 12460ea508b1Smrg func_quote_portable false "$1" 12470ea508b1Smrg func_quotefast_eval_result=$func_quote_portable_result 12480ea508b1Smrg } 12490ea508b1Smrgfi 12509d0ccd10Smrg 12510ea508b1Smrg 12520ea508b1Smrg# func_quote_arg MODEs ARG 12530ea508b1Smrg# ------------------------ 12540ea508b1Smrg# Quote one ARG to be evaled later. MODEs argument may contain zero or more 12550ea508b1Smrg# specifiers listed below separated by ',' character. This function returns two 12560ea508b1Smrg# values: 12570ea508b1Smrg# i) func_quote_arg_result 12580ea508b1Smrg# double-quoted (when needed), suitable for a subsequent eval 12590ea508b1Smrg# ii) func_quote_arg_unquoted_result 12600ea508b1Smrg# has all characters that are still active within double 12610ea508b1Smrg# quotes backslashified. Available only if 'unquoted' is specified. 12620ea508b1Smrg# 12630ea508b1Smrg# Available modes: 12640ea508b1Smrg# ---------------- 12650ea508b1Smrg# 'eval' (default) 12660ea508b1Smrg# - escape shell special characters 12670ea508b1Smrg# 'expand' 12680ea508b1Smrg# - the same as 'eval'; but do not quote variable references 12690ea508b1Smrg# 'pretty' 12700ea508b1Smrg# - request aesthetic output, i.e. '"a b"' instead of 'a\ b'. This might 12710ea508b1Smrg# be used later in func_quote to get output like: 'echo "a b"' instead 12720ea508b1Smrg# of 'echo a\ b'. This is slower than default on some shells. 12730ea508b1Smrg# 'unquoted' 12740ea508b1Smrg# - produce also $func_quote_arg_unquoted_result which does not contain 12750ea508b1Smrg# wrapping double-quotes. 12760ea508b1Smrg# 12770ea508b1Smrg# Examples for 'func_quote_arg pretty,unquoted string': 12780ea508b1Smrg# 12790ea508b1Smrg# string | *_result | *_unquoted_result 12800ea508b1Smrg# ------------+-----------------------+------------------- 12810ea508b1Smrg# " | \" | \" 12820ea508b1Smrg# a b | "a b" | a b 12830ea508b1Smrg# "a b" | "\"a b\"" | \"a b\" 12840ea508b1Smrg# * | "*" | * 12850ea508b1Smrg# z="${x-$y}" | "z=\"\${x-\$y}\"" | z=\"\${x-\$y}\" 12860ea508b1Smrg# 12870ea508b1Smrg# Examples for 'func_quote_arg pretty,unquoted,expand string': 12880ea508b1Smrg# 12890ea508b1Smrg# string | *_result | *_unquoted_result 12900ea508b1Smrg# --------------+---------------------+-------------------- 12910ea508b1Smrg# z="${x-$y}" | "z=\"${x-$y}\"" | z=\"${x-$y}\" 12920ea508b1Smrgfunc_quote_arg () 12930ea508b1Smrg{ 12940ea508b1Smrg _G_quote_expand=false 12950ea508b1Smrg case ,$1, in 12960ea508b1Smrg *,expand,*) 12970ea508b1Smrg _G_quote_expand=: 12980ea508b1Smrg ;; 1299e169010aSmrg esac 1300e169010aSmrg 13010ea508b1Smrg case ,$1, in 13020ea508b1Smrg *,pretty,*|*,expand,*|*,unquoted,*) 13030ea508b1Smrg func_quote_portable $_G_quote_expand "$2" 13040ea508b1Smrg func_quote_arg_result=$func_quote_portable_result 13050ea508b1Smrg func_quote_arg_unquoted_result=$func_quote_portable_unquoted_result 13060ea508b1Smrg ;; 13070ea508b1Smrg *) 13080ea508b1Smrg # Faster quote-for-eval for some shells. 13090ea508b1Smrg func_quotefast_eval "$2" 13100ea508b1Smrg func_quote_arg_result=$func_quotefast_eval_result 1311e169010aSmrg ;; 1312e169010aSmrg esac 13130ea508b1Smrg} 13140ea508b1Smrg 1315e169010aSmrg 13160ea508b1Smrg# func_quote MODEs ARGs... 13170ea508b1Smrg# ------------------------ 13180ea508b1Smrg# Quote all ARGs to be evaled later and join them into single command. See 13190ea508b1Smrg# func_quote_arg's description for more info. 13200ea508b1Smrgfunc_quote () 13210ea508b1Smrg{ 13220ea508b1Smrg $debug_cmd 13230ea508b1Smrg _G_func_quote_mode=$1 ; shift 13240ea508b1Smrg func_quote_result= 13250ea508b1Smrg while test 0 -lt $#; do 13260ea508b1Smrg func_quote_arg "$_G_func_quote_mode" "$1" 13270ea508b1Smrg if test -n "$func_quote_result"; then 13280ea508b1Smrg func_append func_quote_result " $func_quote_arg_result" 13290ea508b1Smrg else 13300ea508b1Smrg func_append func_quote_result "$func_quote_arg_result" 13310ea508b1Smrg fi 13320ea508b1Smrg shift 13330ea508b1Smrg done 13349d0ccd10Smrg} 13359d0ccd10Smrg 13369d0ccd10Smrg 13379d0ccd10Smrg# func_stripname PREFIX SUFFIX NAME 13389d0ccd10Smrg# --------------------------------- 13399d0ccd10Smrg# strip PREFIX and SUFFIX from NAME, and store in func_stripname_result. 13409d0ccd10Smrg# PREFIX and SUFFIX must not contain globbing or regex special 13419d0ccd10Smrg# characters, hashes, percent signs, but SUFFIX may contain a leading 13429d0ccd10Smrg# dot (in which case that matches only a dot). 13439d0ccd10Smrgif test yes = "$_G_HAVE_XSI_OPS"; then 13449d0ccd10Smrg eval 'func_stripname () 13459d0ccd10Smrg { 13469d0ccd10Smrg $debug_cmd 13479d0ccd10Smrg 13489d0ccd10Smrg # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are 13499d0ccd10Smrg # positional parameters, so assign one to ordinary variable first. 13509d0ccd10Smrg func_stripname_result=$3 13519d0ccd10Smrg func_stripname_result=${func_stripname_result#"$1"} 13529d0ccd10Smrg func_stripname_result=${func_stripname_result%"$2"} 13539d0ccd10Smrg }' 13549d0ccd10Smrgelse 13559d0ccd10Smrg func_stripname () 13569d0ccd10Smrg { 13579d0ccd10Smrg $debug_cmd 13589d0ccd10Smrg 13599d0ccd10Smrg case $2 in 13609d0ccd10Smrg .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;; 13619d0ccd10Smrg *) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;; 13629d0ccd10Smrg esac 13639d0ccd10Smrg } 13649d0ccd10Smrgfi 13659d0ccd10Smrg 13669d0ccd10Smrg 13679d0ccd10Smrg# func_show_eval CMD [FAIL_EXP] 13689d0ccd10Smrg# ----------------------------- 13699d0ccd10Smrg# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is 13709d0ccd10Smrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 13719d0ccd10Smrg# is given, then evaluate it. 13729d0ccd10Smrgfunc_show_eval () 13739d0ccd10Smrg{ 13749d0ccd10Smrg $debug_cmd 13759d0ccd10Smrg 13769d0ccd10Smrg _G_cmd=$1 13779d0ccd10Smrg _G_fail_exp=${2-':'} 13789d0ccd10Smrg 13790ea508b1Smrg func_quote_arg pretty,expand "$_G_cmd" 13800ea508b1Smrg eval "func_notquiet $func_quote_arg_result" 13819d0ccd10Smrg 13829d0ccd10Smrg $opt_dry_run || { 13839d0ccd10Smrg eval "$_G_cmd" 13849d0ccd10Smrg _G_status=$? 13859d0ccd10Smrg if test 0 -ne "$_G_status"; then 13869d0ccd10Smrg eval "(exit $_G_status); $_G_fail_exp" 13879d0ccd10Smrg fi 13889d0ccd10Smrg } 13899d0ccd10Smrg} 13909d0ccd10Smrg 13919d0ccd10Smrg 13929d0ccd10Smrg# func_show_eval_locale CMD [FAIL_EXP] 13939d0ccd10Smrg# ------------------------------------ 13949d0ccd10Smrg# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is 13959d0ccd10Smrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 13969d0ccd10Smrg# is given, then evaluate it. Use the saved locale for evaluation. 13979d0ccd10Smrgfunc_show_eval_locale () 13989d0ccd10Smrg{ 13999d0ccd10Smrg $debug_cmd 14009d0ccd10Smrg 14019d0ccd10Smrg _G_cmd=$1 14029d0ccd10Smrg _G_fail_exp=${2-':'} 14039d0ccd10Smrg 14049d0ccd10Smrg $opt_quiet || { 14050ea508b1Smrg func_quote_arg expand,pretty "$_G_cmd" 14060ea508b1Smrg eval "func_echo $func_quote_arg_result" 14079d0ccd10Smrg } 14089d0ccd10Smrg 14099d0ccd10Smrg $opt_dry_run || { 14109d0ccd10Smrg eval "$_G_user_locale 14119d0ccd10Smrg $_G_cmd" 14129d0ccd10Smrg _G_status=$? 14139d0ccd10Smrg eval "$_G_safe_locale" 14149d0ccd10Smrg if test 0 -ne "$_G_status"; then 14159d0ccd10Smrg eval "(exit $_G_status); $_G_fail_exp" 14169d0ccd10Smrg fi 14179d0ccd10Smrg } 14189d0ccd10Smrg} 14199d0ccd10Smrg 14209d0ccd10Smrg 14219d0ccd10Smrg# func_tr_sh 14229d0ccd10Smrg# ---------- 14239d0ccd10Smrg# Turn $1 into a string suitable for a shell variable name. 14249d0ccd10Smrg# Result is stored in $func_tr_sh_result. All characters 14259d0ccd10Smrg# not in the set a-zA-Z0-9_ are replaced with '_'. Further, 14269d0ccd10Smrg# if $1 begins with a digit, a '_' is prepended as well. 14279d0ccd10Smrgfunc_tr_sh () 14289d0ccd10Smrg{ 14299d0ccd10Smrg $debug_cmd 14309d0ccd10Smrg 14319d0ccd10Smrg case $1 in 14329d0ccd10Smrg [0-9]* | *[!a-zA-Z0-9_]*) 14339d0ccd10Smrg func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'` 14349d0ccd10Smrg ;; 14359d0ccd10Smrg * ) 14369d0ccd10Smrg func_tr_sh_result=$1 14379d0ccd10Smrg ;; 14389d0ccd10Smrg esac 14399d0ccd10Smrg} 14409d0ccd10Smrg 14419d0ccd10Smrg 14429d0ccd10Smrg# func_verbose ARG... 14439d0ccd10Smrg# ------------------- 14449d0ccd10Smrg# Echo program name prefixed message in verbose mode only. 14459d0ccd10Smrgfunc_verbose () 14469d0ccd10Smrg{ 14479d0ccd10Smrg $debug_cmd 14489d0ccd10Smrg 14499d0ccd10Smrg $opt_verbose && func_echo "$*" 14509d0ccd10Smrg 14519d0ccd10Smrg : 14529d0ccd10Smrg} 14539d0ccd10Smrg 14549d0ccd10Smrg 14559d0ccd10Smrg# func_warn_and_continue ARG... 14569d0ccd10Smrg# ----------------------------- 14579d0ccd10Smrg# Echo program name prefixed warning message to standard error. 14589d0ccd10Smrgfunc_warn_and_continue () 14599d0ccd10Smrg{ 14609d0ccd10Smrg $debug_cmd 14619d0ccd10Smrg 14629d0ccd10Smrg $require_term_colors 14639d0ccd10Smrg 14649d0ccd10Smrg func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2 14659d0ccd10Smrg} 14669d0ccd10Smrg 14679d0ccd10Smrg 14689d0ccd10Smrg# func_warning CATEGORY ARG... 14699d0ccd10Smrg# ---------------------------- 14709d0ccd10Smrg# Echo program name prefixed warning message to standard error. Warning 14719d0ccd10Smrg# messages can be filtered according to CATEGORY, where this function 14729d0ccd10Smrg# elides messages where CATEGORY is not listed in the global variable 14739d0ccd10Smrg# 'opt_warning_types'. 14749d0ccd10Smrgfunc_warning () 14759d0ccd10Smrg{ 14769d0ccd10Smrg $debug_cmd 14779d0ccd10Smrg 14789d0ccd10Smrg # CATEGORY must be in the warning_categories list! 14799d0ccd10Smrg case " $warning_categories " in 14809d0ccd10Smrg *" $1 "*) ;; 14819d0ccd10Smrg *) func_internal_error "invalid warning category '$1'" ;; 14829d0ccd10Smrg esac 14839d0ccd10Smrg 14849d0ccd10Smrg _G_category=$1 14859d0ccd10Smrg shift 14869d0ccd10Smrg 14879d0ccd10Smrg case " $opt_warning_types " in 14889d0ccd10Smrg *" $_G_category "*) $warning_func ${1+"$@"} ;; 14899d0ccd10Smrg esac 14907914d74bSmrg} 14917914d74bSmrg 14927914d74bSmrg 14939d0ccd10Smrg# func_sort_ver VER1 VER2 14949d0ccd10Smrg# ----------------------- 14959d0ccd10Smrg# 'sort -V' is not generally available. 14969d0ccd10Smrg# Note this deviates from the version comparison in automake 14979d0ccd10Smrg# in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a 14989d0ccd10Smrg# but this should suffice as we won't be specifying old 14999d0ccd10Smrg# version formats or redundant trailing .0 in bootstrap.conf. 15009d0ccd10Smrg# If we did want full compatibility then we should probably 15019d0ccd10Smrg# use m4_version_compare from autoconf. 15029d0ccd10Smrgfunc_sort_ver () 15039d0ccd10Smrg{ 15049d0ccd10Smrg $debug_cmd 15059d0ccd10Smrg 15069d0ccd10Smrg printf '%s\n%s\n' "$1" "$2" \ 15079d0ccd10Smrg | 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 15089d0ccd10Smrg} 15099d0ccd10Smrg 15109d0ccd10Smrg# func_lt_ver PREV CURR 15119d0ccd10Smrg# --------------------- 15129d0ccd10Smrg# Return true if PREV and CURR are in the correct order according to 15139d0ccd10Smrg# func_sort_ver, otherwise false. Use it like this: 15149d0ccd10Smrg# 15159d0ccd10Smrg# func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..." 15169d0ccd10Smrgfunc_lt_ver () 15179d0ccd10Smrg{ 15189d0ccd10Smrg $debug_cmd 15199d0ccd10Smrg 15209d0ccd10Smrg test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q` 15219d0ccd10Smrg} 15229d0ccd10Smrg 15239d0ccd10Smrg 15249d0ccd10Smrg# Local variables: 15259d0ccd10Smrg# mode: shell-script 15269d0ccd10Smrg# sh-indentation: 2 15279d0ccd10Smrg# eval: (add-hook 'before-save-hook 'time-stamp) 15289d0ccd10Smrg# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" 15299d0ccd10Smrg# time-stamp-time-zone: "UTC" 15309d0ccd10Smrg# End: 15319d0ccd10Smrg#! /bin/sh 15329d0ccd10Smrg 15339d0ccd10Smrg# A portable, pluggable option parser for Bourne shell. 15349d0ccd10Smrg# Written by Gary V. Vaughan, 2010 15359d0ccd10Smrg 15360ea508b1Smrg# This is free software. There is NO warranty; not even for 15370ea508b1Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 15380ea508b1Smrg# 15390ea508b1Smrg# Copyright (C) 2010-2019, 2021 Bootstrap Authors 15400ea508b1Smrg# 15410ea508b1Smrg# This file is dual licensed under the terms of the MIT license 15420ea508b1Smrg# <https://opensource.org/license/MIT>, and GPL version 2 or later 15430ea508b1Smrg# <http://www.gnu.org/licenses/gpl-2.0.html>. You must apply one of 15440ea508b1Smrg# these licenses when using or redistributing this software or any of 15450ea508b1Smrg# the files within it. See the URLs above, or the file `LICENSE` 15460ea508b1Smrg# included in the Bootstrap distribution for the full license texts. 15479d0ccd10Smrg 15480ea508b1Smrg# Please report bugs or propose patches to: 15490ea508b1Smrg# <https://github.com/gnulib-modules/bootstrap/issues> 15509d0ccd10Smrg 15510ea508b1Smrg# Set a version string for this script. 15520ea508b1Smrgscriptversion=2019-02-19.15; # UTC 15539d0ccd10Smrg 15549d0ccd10Smrg 15559d0ccd10Smrg## ------ ## 15569d0ccd10Smrg## Usage. ## 15579d0ccd10Smrg## ------ ## 15589d0ccd10Smrg 15599d0ccd10Smrg# This file is a library for parsing options in your shell scripts along 15609d0ccd10Smrg# with assorted other useful supporting features that you can make use 15619d0ccd10Smrg# of too. 15629d0ccd10Smrg# 15639d0ccd10Smrg# For the simplest scripts you might need only: 15649d0ccd10Smrg# 15659d0ccd10Smrg# #!/bin/sh 15669d0ccd10Smrg# . relative/path/to/funclib.sh 15679d0ccd10Smrg# . relative/path/to/options-parser 15689d0ccd10Smrg# scriptversion=1.0 15699d0ccd10Smrg# func_options ${1+"$@"} 15709d0ccd10Smrg# eval set dummy "$func_options_result"; shift 15719d0ccd10Smrg# ...rest of your script... 15729d0ccd10Smrg# 15739d0ccd10Smrg# In order for the '--version' option to work, you will need to have a 15749d0ccd10Smrg# suitably formatted comment like the one at the top of this file 15750ea508b1Smrg# starting with '# Written by ' and ending with '# Copyright'. 15769d0ccd10Smrg# 15779d0ccd10Smrg# For '-h' and '--help' to work, you will also need a one line 15789d0ccd10Smrg# description of your script's purpose in a comment directly above the 15799d0ccd10Smrg# '# Written by ' line, like the one at the top of this file. 15809d0ccd10Smrg# 15819d0ccd10Smrg# The default options also support '--debug', which will turn on shell 15829d0ccd10Smrg# execution tracing (see the comment above debug_cmd below for another 15839d0ccd10Smrg# use), and '--verbose' and the func_verbose function to allow your script 15849d0ccd10Smrg# to display verbose messages only when your user has specified 15859d0ccd10Smrg# '--verbose'. 15869d0ccd10Smrg# 15870ea508b1Smrg# After sourcing this file, you can plug in processing for additional 15889d0ccd10Smrg# options by amending the variables from the 'Configuration' section 15899d0ccd10Smrg# below, and following the instructions in the 'Option parsing' 15909d0ccd10Smrg# section further down. 15919d0ccd10Smrg 15929d0ccd10Smrg## -------------- ## 15939d0ccd10Smrg## Configuration. ## 15949d0ccd10Smrg## -------------- ## 15959d0ccd10Smrg 15969d0ccd10Smrg# You should override these variables in your script after sourcing this 15979d0ccd10Smrg# file so that they reflect the customisations you have added to the 15989d0ccd10Smrg# option parser. 15999d0ccd10Smrg 16009d0ccd10Smrg# The usage line for option parsing errors and the start of '-h' and 16019d0ccd10Smrg# '--help' output messages. You can embed shell variables for delayed 16029d0ccd10Smrg# expansion at the time the message is displayed, but you will need to 16039d0ccd10Smrg# quote other shell meta-characters carefully to prevent them being 16049d0ccd10Smrg# expanded when the contents are evaled. 16059d0ccd10Smrgusage='$progpath [OPTION]...' 16069d0ccd10Smrg 16079d0ccd10Smrg# Short help message in response to '-h' and '--help'. Add to this or 16089d0ccd10Smrg# override it after sourcing this library to reflect the full set of 16099d0ccd10Smrg# options your script accepts. 16109d0ccd10Smrgusage_message="\ 16119d0ccd10Smrg --debug enable verbose shell tracing 16129d0ccd10Smrg -W, --warnings=CATEGORY 16139d0ccd10Smrg report the warnings falling in CATEGORY [all] 16149d0ccd10Smrg -v, --verbose verbosely report processing 16159d0ccd10Smrg --version print version information and exit 16169d0ccd10Smrg -h, --help print short or long help message and exit 16179d0ccd10Smrg" 16189d0ccd10Smrg 16199d0ccd10Smrg# Additional text appended to 'usage_message' in response to '--help'. 16209d0ccd10Smrglong_help_message=" 16219d0ccd10SmrgWarning categories include: 16229d0ccd10Smrg 'all' show all warnings 16239d0ccd10Smrg 'none' turn off all the warnings 16249d0ccd10Smrg 'error' warnings are treated as fatal errors" 16259d0ccd10Smrg 16269d0ccd10Smrg# Help message printed before fatal option parsing errors. 16279d0ccd10Smrgfatal_help="Try '\$progname --help' for more information." 16289d0ccd10Smrg 16299d0ccd10Smrg 16309d0ccd10Smrg 16319d0ccd10Smrg## ------------------------- ## 16329d0ccd10Smrg## Hook function management. ## 16339d0ccd10Smrg## ------------------------- ## 16349d0ccd10Smrg 16359d0ccd10Smrg# This section contains functions for adding, removing, and running hooks 16360ea508b1Smrg# in the main code. A hook is just a list of function names that can be 16370ea508b1Smrg# run in order later on. 16389d0ccd10Smrg 16399d0ccd10Smrg# func_hookable FUNC_NAME 16409d0ccd10Smrg# ----------------------- 16419d0ccd10Smrg# Declare that FUNC_NAME will run hooks added with 16429d0ccd10Smrg# 'func_add_hook FUNC_NAME ...'. 16439d0ccd10Smrgfunc_hookable () 16449d0ccd10Smrg{ 16459d0ccd10Smrg $debug_cmd 16469d0ccd10Smrg 16479d0ccd10Smrg func_append hookable_fns " $1" 16489d0ccd10Smrg} 16499d0ccd10Smrg 16509d0ccd10Smrg 16519d0ccd10Smrg# func_add_hook FUNC_NAME HOOK_FUNC 16529d0ccd10Smrg# --------------------------------- 16539d0ccd10Smrg# Request that FUNC_NAME call HOOK_FUNC before it returns. FUNC_NAME must 16549d0ccd10Smrg# first have been declared "hookable" by a call to 'func_hookable'. 16559d0ccd10Smrgfunc_add_hook () 16569d0ccd10Smrg{ 16579d0ccd10Smrg $debug_cmd 16589d0ccd10Smrg 16599d0ccd10Smrg case " $hookable_fns " in 16609d0ccd10Smrg *" $1 "*) ;; 16619d0ccd10Smrg *) func_fatal_error "'$1' does not accept hook functions." ;; 16629d0ccd10Smrg esac 16639d0ccd10Smrg 16649d0ccd10Smrg eval func_append ${1}_hooks '" $2"' 16659d0ccd10Smrg} 16669d0ccd10Smrg 16679d0ccd10Smrg 16689d0ccd10Smrg# func_remove_hook FUNC_NAME HOOK_FUNC 16699d0ccd10Smrg# ------------------------------------ 16700ea508b1Smrg# Remove HOOK_FUNC from the list of hook functions to be called by 16710ea508b1Smrg# FUNC_NAME. 16729d0ccd10Smrgfunc_remove_hook () 16739d0ccd10Smrg{ 16749d0ccd10Smrg $debug_cmd 16759d0ccd10Smrg 16769d0ccd10Smrg eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`' 16779d0ccd10Smrg} 16789d0ccd10Smrg 16799d0ccd10Smrg 16800ea508b1Smrg# func_propagate_result FUNC_NAME_A FUNC_NAME_B 16810ea508b1Smrg# --------------------------------------------- 16820ea508b1Smrg# If the *_result variable of FUNC_NAME_A _is set_, assign its value to 16830ea508b1Smrg# *_result variable of FUNC_NAME_B. 16840ea508b1Smrgfunc_propagate_result () 16850ea508b1Smrg{ 16860ea508b1Smrg $debug_cmd 16870ea508b1Smrg 16880ea508b1Smrg func_propagate_result_result=: 16890ea508b1Smrg if eval "test \"\${${1}_result+set}\" = set" 16900ea508b1Smrg then 16910ea508b1Smrg eval "${2}_result=\$${1}_result" 16920ea508b1Smrg else 16930ea508b1Smrg func_propagate_result_result=false 16940ea508b1Smrg fi 16950ea508b1Smrg} 16960ea508b1Smrg 16970ea508b1Smrg 16989d0ccd10Smrg# func_run_hooks FUNC_NAME [ARG]... 16999d0ccd10Smrg# --------------------------------- 17009d0ccd10Smrg# Run all hook functions registered to FUNC_NAME. 17010ea508b1Smrg# It's assumed that the list of hook functions contains nothing more 17029d0ccd10Smrg# than a whitespace-delimited list of legal shell function names, and 17039d0ccd10Smrg# no effort is wasted trying to catch shell meta-characters or preserve 17049d0ccd10Smrg# whitespace. 17059d0ccd10Smrgfunc_run_hooks () 17069d0ccd10Smrg{ 17079d0ccd10Smrg $debug_cmd 17089d0ccd10Smrg 17099d0ccd10Smrg case " $hookable_fns " in 17109d0ccd10Smrg *" $1 "*) ;; 17110ea508b1Smrg *) func_fatal_error "'$1' does not support hook functions." ;; 17129d0ccd10Smrg esac 17139d0ccd10Smrg 17149d0ccd10Smrg eval _G_hook_fns=\$$1_hooks; shift 17159d0ccd10Smrg 17169d0ccd10Smrg for _G_hook in $_G_hook_fns; do 17170ea508b1Smrg func_unset "${_G_hook}_result" 17180ea508b1Smrg eval $_G_hook '${1+"$@"}' 17190ea508b1Smrg func_propagate_result $_G_hook func_run_hooks 17200ea508b1Smrg if $func_propagate_result_result; then 17210ea508b1Smrg eval set dummy "$func_run_hooks_result"; shift 17220ea508b1Smrg fi 17239d0ccd10Smrg done 17249d0ccd10Smrg} 17259d0ccd10Smrg 17269d0ccd10Smrg 17279d0ccd10Smrg 17289d0ccd10Smrg## --------------- ## 17299d0ccd10Smrg## Option parsing. ## 17309d0ccd10Smrg## --------------- ## 17319d0ccd10Smrg 17329d0ccd10Smrg# In order to add your own option parsing hooks, you must accept the 17330ea508b1Smrg# full positional parameter list from your hook function. You may remove 17340ea508b1Smrg# or edit any options that you action, and then pass back the remaining 17350ea508b1Smrg# unprocessed options in '<hooked_function_name>_result', escaped 17360ea508b1Smrg# suitably for 'eval'. 17370ea508b1Smrg# 17380ea508b1Smrg# The '<hooked_function_name>_result' variable is automatically unset 17390ea508b1Smrg# before your hook gets called; for best performance, only set the 17400ea508b1Smrg# *_result variable when necessary (i.e. don't call the 'func_quote' 17410ea508b1Smrg# function unnecessarily because it can be an expensive operation on some 17420ea508b1Smrg# machines). 17430ea508b1Smrg# 17440ea508b1Smrg# Like this: 17459d0ccd10Smrg# 17469d0ccd10Smrg# my_options_prep () 17479d0ccd10Smrg# { 17489d0ccd10Smrg# $debug_cmd 17499d0ccd10Smrg# 17509d0ccd10Smrg# # Extend the existing usage message. 17519d0ccd10Smrg# usage_message=$usage_message' 17529d0ccd10Smrg# -s, --silent don'\''t print informational messages 17539d0ccd10Smrg# ' 17540ea508b1Smrg# # No change in '$@' (ignored completely by this hook). Leave 17550ea508b1Smrg# # my_options_prep_result variable intact. 17569d0ccd10Smrg# } 17579d0ccd10Smrg# func_add_hook func_options_prep my_options_prep 17589d0ccd10Smrg# 17599d0ccd10Smrg# 17609d0ccd10Smrg# my_silent_option () 17619d0ccd10Smrg# { 17629d0ccd10Smrg# $debug_cmd 17639d0ccd10Smrg# 17640ea508b1Smrg# args_changed=false 17650ea508b1Smrg# 17660ea508b1Smrg# # Note that, for efficiency, we parse as many options as we can 17679d0ccd10Smrg# # recognise in a loop before passing the remainder back to the 17689d0ccd10Smrg# # caller on the first unrecognised argument we encounter. 17699d0ccd10Smrg# while test $# -gt 0; do 17709d0ccd10Smrg# opt=$1; shift 17719d0ccd10Smrg# case $opt in 17720ea508b1Smrg# --silent|-s) opt_silent=: 17730ea508b1Smrg# args_changed=: 17740ea508b1Smrg# ;; 17759d0ccd10Smrg# # Separate non-argument short options: 17769d0ccd10Smrg# -s*) func_split_short_opt "$_G_opt" 17779d0ccd10Smrg# set dummy "$func_split_short_opt_name" \ 17789d0ccd10Smrg# "-$func_split_short_opt_arg" ${1+"$@"} 17799d0ccd10Smrg# shift 17800ea508b1Smrg# args_changed=: 17819d0ccd10Smrg# ;; 17820ea508b1Smrg# *) # Make sure the first unrecognised option "$_G_opt" 17830ea508b1Smrg# # is added back to "$@" in case we need it later, 17840ea508b1Smrg# # if $args_changed was set to 'true'. 17850ea508b1Smrg# set dummy "$_G_opt" ${1+"$@"}; shift; break ;; 17869d0ccd10Smrg# esac 17879d0ccd10Smrg# done 17889d0ccd10Smrg# 17890ea508b1Smrg# # Only call 'func_quote' here if we processed at least one argument. 17900ea508b1Smrg# if $args_changed; then 17910ea508b1Smrg# func_quote eval ${1+"$@"} 17920ea508b1Smrg# my_silent_option_result=$func_quote_result 17930ea508b1Smrg# fi 17949d0ccd10Smrg# } 17959d0ccd10Smrg# func_add_hook func_parse_options my_silent_option 17969d0ccd10Smrg# 17979d0ccd10Smrg# 17989d0ccd10Smrg# my_option_validation () 17999d0ccd10Smrg# { 18009d0ccd10Smrg# $debug_cmd 18019d0ccd10Smrg# 18029d0ccd10Smrg# $opt_silent && $opt_verbose && func_fatal_help "\ 18039d0ccd10Smrg# '--silent' and '--verbose' options are mutually exclusive." 18049d0ccd10Smrg# } 18059d0ccd10Smrg# func_add_hook func_validate_options my_option_validation 18069d0ccd10Smrg# 18070ea508b1Smrg# You'll also need to manually amend $usage_message to reflect the extra 18089d0ccd10Smrg# options you parse. It's preferable to append if you can, so that 18099d0ccd10Smrg# multiple option parsing hooks can be added safely. 18109d0ccd10Smrg 18119d0ccd10Smrg 18120ea508b1Smrg# func_options_finish [ARG]... 18130ea508b1Smrg# ---------------------------- 18140ea508b1Smrg# Finishing the option parse loop (call 'func_options' hooks ATM). 18150ea508b1Smrgfunc_options_finish () 18160ea508b1Smrg{ 18170ea508b1Smrg $debug_cmd 18180ea508b1Smrg 18190ea508b1Smrg func_run_hooks func_options ${1+"$@"} 18200ea508b1Smrg func_propagate_result func_run_hooks func_options_finish 18210ea508b1Smrg} 18220ea508b1Smrg 18230ea508b1Smrg 18249d0ccd10Smrg# func_options [ARG]... 18259d0ccd10Smrg# --------------------- 18269d0ccd10Smrg# All the functions called inside func_options are hookable. See the 18279d0ccd10Smrg# individual implementations for details. 18289d0ccd10Smrgfunc_hookable func_options 18299d0ccd10Smrgfunc_options () 18307914d74bSmrg{ 18319d0ccd10Smrg $debug_cmd 18327914d74bSmrg 18330ea508b1Smrg _G_options_quoted=false 1834e169010aSmrg 18350ea508b1Smrg for my_func in options_prep parse_options validate_options options_finish 18360ea508b1Smrg do 18370ea508b1Smrg func_unset func_${my_func}_result 18380ea508b1Smrg func_unset func_run_hooks_result 18390ea508b1Smrg eval func_$my_func '${1+"$@"}' 18400ea508b1Smrg func_propagate_result func_$my_func func_options 18410ea508b1Smrg if $func_propagate_result_result; then 18420ea508b1Smrg eval set dummy "$func_options_result"; shift 18430ea508b1Smrg _G_options_quoted=: 18440ea508b1Smrg fi 18450ea508b1Smrg done 18469d0ccd10Smrg 18470ea508b1Smrg $_G_options_quoted || { 18480ea508b1Smrg # As we (func_options) are top-level options-parser function and 18490ea508b1Smrg # nobody quoted "$@" for us yet, we need to do it explicitly for 18500ea508b1Smrg # caller. 18510ea508b1Smrg func_quote eval ${1+"$@"} 18520ea508b1Smrg func_options_result=$func_quote_result 18530ea508b1Smrg } 18547914d74bSmrg} 18557914d74bSmrg 1856e169010aSmrg 18579d0ccd10Smrg# func_options_prep [ARG]... 18589d0ccd10Smrg# -------------------------- 18599d0ccd10Smrg# All initialisations required before starting the option parse loop. 18609d0ccd10Smrg# Note that when calling hook functions, we pass through the list of 18619d0ccd10Smrg# positional parameters. If a hook function modifies that list, and 18620ea508b1Smrg# needs to propagate that back to rest of this script, then the complete 18630ea508b1Smrg# modified list must be put in 'func_run_hooks_result' before returning. 18649d0ccd10Smrgfunc_hookable func_options_prep 18659d0ccd10Smrgfunc_options_prep () 18667914d74bSmrg{ 18679d0ccd10Smrg $debug_cmd 18687914d74bSmrg 18699d0ccd10Smrg # Option defaults: 18709d0ccd10Smrg opt_verbose=false 18719d0ccd10Smrg opt_warning_types= 1872e169010aSmrg 18739d0ccd10Smrg func_run_hooks func_options_prep ${1+"$@"} 18740ea508b1Smrg func_propagate_result func_run_hooks func_options_prep 18757914d74bSmrg} 18767914d74bSmrg 18779d0ccd10Smrg 18789d0ccd10Smrg# func_parse_options [ARG]... 18799d0ccd10Smrg# --------------------------- 18809d0ccd10Smrg# The main option parsing loop. 18819d0ccd10Smrgfunc_hookable func_parse_options 18829d0ccd10Smrgfunc_parse_options () 1883c63293b5Smrg{ 18849d0ccd10Smrg $debug_cmd 18859d0ccd10Smrg 18860ea508b1Smrg _G_parse_options_requote=false 18879d0ccd10Smrg # this just eases exit handling 18889d0ccd10Smrg while test $# -gt 0; do 18899d0ccd10Smrg # Defer to hook functions for initial option parsing, so they 18909d0ccd10Smrg # get priority in the event of reusing an option name. 18919d0ccd10Smrg func_run_hooks func_parse_options ${1+"$@"} 18920ea508b1Smrg func_propagate_result func_run_hooks func_parse_options 18930ea508b1Smrg if $func_propagate_result_result; then 18940ea508b1Smrg eval set dummy "$func_parse_options_result"; shift 18950ea508b1Smrg # Even though we may have changed "$@", we passed the "$@" array 18960ea508b1Smrg # down into the hook and it quoted it for us (because we are in 18970ea508b1Smrg # this if-branch). No need to quote it again. 18980ea508b1Smrg _G_parse_options_requote=false 18990ea508b1Smrg fi 19009d0ccd10Smrg 19019d0ccd10Smrg # Break out of the loop if we already parsed every option. 19029d0ccd10Smrg test $# -gt 0 || break 19039d0ccd10Smrg 19040ea508b1Smrg # We expect that one of the options parsed in this function matches 19050ea508b1Smrg # and thus we remove _G_opt from "$@" and need to re-quote. 19060ea508b1Smrg _G_match_parse_options=: 19079d0ccd10Smrg _G_opt=$1 19089d0ccd10Smrg shift 19099d0ccd10Smrg case $_G_opt in 19109d0ccd10Smrg --debug|-x) debug_cmd='set -x' 19110ea508b1Smrg func_echo "enabling shell trace mode" >&2 19129d0ccd10Smrg $debug_cmd 19139d0ccd10Smrg ;; 19149d0ccd10Smrg 19159d0ccd10Smrg --no-warnings|--no-warning|--no-warn) 19169d0ccd10Smrg set dummy --warnings none ${1+"$@"} 19179d0ccd10Smrg shift 19189d0ccd10Smrg ;; 19199d0ccd10Smrg 19209d0ccd10Smrg --warnings|--warning|-W) 19210ea508b1Smrg if test $# = 0 && func_missing_arg $_G_opt; then 19220ea508b1Smrg _G_parse_options_requote=: 19230ea508b1Smrg break 19240ea508b1Smrg fi 19259d0ccd10Smrg case " $warning_categories $1" in 19269d0ccd10Smrg *" $1 "*) 19279d0ccd10Smrg # trailing space prevents matching last $1 above 19289d0ccd10Smrg func_append_uniq opt_warning_types " $1" 19299d0ccd10Smrg ;; 19309d0ccd10Smrg *all) 19319d0ccd10Smrg opt_warning_types=$warning_categories 19329d0ccd10Smrg ;; 19339d0ccd10Smrg *none) 19349d0ccd10Smrg opt_warning_types=none 19359d0ccd10Smrg warning_func=: 19369d0ccd10Smrg ;; 19379d0ccd10Smrg *error) 19389d0ccd10Smrg opt_warning_types=$warning_categories 19399d0ccd10Smrg warning_func=func_fatal_error 19409d0ccd10Smrg ;; 19419d0ccd10Smrg *) 19429d0ccd10Smrg func_fatal_error \ 19439d0ccd10Smrg "unsupported warning category: '$1'" 19449d0ccd10Smrg ;; 19459d0ccd10Smrg esac 19469d0ccd10Smrg shift 19479d0ccd10Smrg ;; 19489d0ccd10Smrg 19499d0ccd10Smrg --verbose|-v) opt_verbose=: ;; 19509d0ccd10Smrg --version) func_version ;; 19519d0ccd10Smrg -\?|-h) func_usage ;; 19529d0ccd10Smrg --help) func_help ;; 19539d0ccd10Smrg 19549d0ccd10Smrg # Separate optargs to long options (plugins may need this): 19559d0ccd10Smrg --*=*) func_split_equals "$_G_opt" 19569d0ccd10Smrg set dummy "$func_split_equals_lhs" \ 19579d0ccd10Smrg "$func_split_equals_rhs" ${1+"$@"} 19589d0ccd10Smrg shift 19599d0ccd10Smrg ;; 19609d0ccd10Smrg 19619d0ccd10Smrg # Separate optargs to short options: 19629d0ccd10Smrg -W*) 19639d0ccd10Smrg func_split_short_opt "$_G_opt" 19649d0ccd10Smrg set dummy "$func_split_short_opt_name" \ 19659d0ccd10Smrg "$func_split_short_opt_arg" ${1+"$@"} 19669d0ccd10Smrg shift 19679d0ccd10Smrg ;; 19689d0ccd10Smrg 19699d0ccd10Smrg # Separate non-argument short options: 19709d0ccd10Smrg -\?*|-h*|-v*|-x*) 19719d0ccd10Smrg func_split_short_opt "$_G_opt" 19729d0ccd10Smrg set dummy "$func_split_short_opt_name" \ 19739d0ccd10Smrg "-$func_split_short_opt_arg" ${1+"$@"} 19749d0ccd10Smrg shift 19759d0ccd10Smrg ;; 19769d0ccd10Smrg 19770ea508b1Smrg --) _G_parse_options_requote=: ; break ;; 19789d0ccd10Smrg -*) func_fatal_help "unrecognised option: '$_G_opt'" ;; 19790ea508b1Smrg *) set dummy "$_G_opt" ${1+"$@"}; shift 19800ea508b1Smrg _G_match_parse_options=false 19810ea508b1Smrg break 19820ea508b1Smrg ;; 19839d0ccd10Smrg esac 19840ea508b1Smrg 19850ea508b1Smrg if $_G_match_parse_options; then 19860ea508b1Smrg _G_parse_options_requote=: 19870ea508b1Smrg fi 19889d0ccd10Smrg done 19899d0ccd10Smrg 19900ea508b1Smrg if $_G_parse_options_requote; then 19910ea508b1Smrg # save modified positional parameters for caller 19920ea508b1Smrg func_quote eval ${1+"$@"} 19930ea508b1Smrg func_parse_options_result=$func_quote_result 19940ea508b1Smrg fi 1995c63293b5Smrg} 1996c63293b5Smrg 19977914d74bSmrg 19989d0ccd10Smrg# func_validate_options [ARG]... 19999d0ccd10Smrg# ------------------------------ 20009d0ccd10Smrg# Perform any sanity checks on option settings and/or unconsumed 20019d0ccd10Smrg# arguments. 20029d0ccd10Smrgfunc_hookable func_validate_options 20039d0ccd10Smrgfunc_validate_options () 2004e169010aSmrg{ 20059d0ccd10Smrg $debug_cmd 2006c63293b5Smrg 20079d0ccd10Smrg # Display all warnings if -W was not given. 20089d0ccd10Smrg test -n "$opt_warning_types" || opt_warning_types=" $warning_categories" 20099d0ccd10Smrg 20109d0ccd10Smrg func_run_hooks func_validate_options ${1+"$@"} 20110ea508b1Smrg func_propagate_result func_run_hooks func_validate_options 20129d0ccd10Smrg 20139d0ccd10Smrg # Bail if the options were screwed! 20149d0ccd10Smrg $exit_cmd $EXIT_FAILURE 2015e169010aSmrg} 2016e169010aSmrg 20179d0ccd10Smrg 20189d0ccd10Smrg 20199d0ccd10Smrg## ----------------- ## 20209d0ccd10Smrg## Helper functions. ## 20219d0ccd10Smrg## ----------------- ## 20229d0ccd10Smrg 20239d0ccd10Smrg# This section contains the helper functions used by the rest of the 20249d0ccd10Smrg# hookable option parser framework in ascii-betical order. 20259d0ccd10Smrg 20269d0ccd10Smrg 20279d0ccd10Smrg# func_fatal_help ARG... 20289d0ccd10Smrg# ---------------------- 20299d0ccd10Smrg# Echo program name prefixed message to standard error, followed by 20309d0ccd10Smrg# a help hint, and exit. 20319d0ccd10Smrgfunc_fatal_help () 2032e169010aSmrg{ 20339d0ccd10Smrg $debug_cmd 2034c63293b5Smrg 20359d0ccd10Smrg eval \$ECHO \""Usage: $usage"\" 20369d0ccd10Smrg eval \$ECHO \""$fatal_help"\" 20379d0ccd10Smrg func_error ${1+"$@"} 20389d0ccd10Smrg exit $EXIT_FAILURE 2039e169010aSmrg} 2040e169010aSmrg 20419d0ccd10Smrg 20429d0ccd10Smrg# func_help 20439d0ccd10Smrg# --------- 20449d0ccd10Smrg# Echo long help message to standard output and exit. 2045e169010aSmrgfunc_help () 2046e169010aSmrg{ 20479d0ccd10Smrg $debug_cmd 20489d0ccd10Smrg 20499d0ccd10Smrg func_usage_message 20509d0ccd10Smrg $ECHO "$long_help_message" 20519d0ccd10Smrg exit 0 2052e169010aSmrg} 2053e169010aSmrg 20549d0ccd10Smrg 20559d0ccd10Smrg# func_missing_arg ARGNAME 20569d0ccd10Smrg# ------------------------ 2057e169010aSmrg# Echo program name prefixed message to standard error and set global 2058e169010aSmrg# exit_cmd. 2059e169010aSmrgfunc_missing_arg () 2060e169010aSmrg{ 20619d0ccd10Smrg $debug_cmd 2062c63293b5Smrg 20639d0ccd10Smrg func_error "Missing argument for '$1'." 2064e169010aSmrg exit_cmd=exit 2065e169010aSmrg} 2066e169010aSmrg 2067e169010aSmrg 20689d0ccd10Smrg# func_split_equals STRING 20699d0ccd10Smrg# ------------------------ 20700ea508b1Smrg# Set func_split_equals_lhs and func_split_equals_rhs shell variables 20710ea508b1Smrg# after splitting STRING at the '=' sign. 20729d0ccd10Smrgtest -z "$_G_HAVE_XSI_OPS" \ 20739d0ccd10Smrg && (eval 'x=a/b/c; 20749d0ccd10Smrg test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ 20759d0ccd10Smrg && _G_HAVE_XSI_OPS=yes 20769d0ccd10Smrg 20779d0ccd10Smrgif test yes = "$_G_HAVE_XSI_OPS" 20789d0ccd10Smrgthen 20799d0ccd10Smrg # This is an XSI compatible shell, allowing a faster implementation... 20809d0ccd10Smrg eval 'func_split_equals () 20819d0ccd10Smrg { 20829d0ccd10Smrg $debug_cmd 20839d0ccd10Smrg 20849d0ccd10Smrg func_split_equals_lhs=${1%%=*} 20859d0ccd10Smrg func_split_equals_rhs=${1#*=} 20860ea508b1Smrg if test "x$func_split_equals_lhs" = "x$1"; then 20870ea508b1Smrg func_split_equals_rhs= 20880ea508b1Smrg fi 20899d0ccd10Smrg }' 20909d0ccd10Smrgelse 20919d0ccd10Smrg # ...otherwise fall back to using expr, which is often a shell builtin. 20929d0ccd10Smrg func_split_equals () 20939d0ccd10Smrg { 20949d0ccd10Smrg $debug_cmd 20959d0ccd10Smrg 20969d0ccd10Smrg func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'` 20979d0ccd10Smrg func_split_equals_rhs= 20980ea508b1Smrg test "x$func_split_equals_lhs=" = "x$1" \ 20999d0ccd10Smrg || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'` 21009d0ccd10Smrg } 21019d0ccd10Smrgfi #func_split_equals 21029d0ccd10Smrg 21039d0ccd10Smrg 21049d0ccd10Smrg# func_split_short_opt SHORTOPT 21059d0ccd10Smrg# ----------------------------- 2106c63293b5Smrg# Set func_split_short_opt_name and func_split_short_opt_arg shell 2107c63293b5Smrg# variables after splitting SHORTOPT after the 2nd character. 21089d0ccd10Smrgif test yes = "$_G_HAVE_XSI_OPS" 21099d0ccd10Smrgthen 21109d0ccd10Smrg # This is an XSI compatible shell, allowing a faster implementation... 21119d0ccd10Smrg eval 'func_split_short_opt () 21129d0ccd10Smrg { 21139d0ccd10Smrg $debug_cmd 21149d0ccd10Smrg 21159d0ccd10Smrg func_split_short_opt_arg=${1#??} 21169d0ccd10Smrg func_split_short_opt_name=${1%"$func_split_short_opt_arg"} 21179d0ccd10Smrg }' 21189d0ccd10Smrgelse 21199d0ccd10Smrg # ...otherwise fall back to using expr, which is often a shell builtin. 21209d0ccd10Smrg func_split_short_opt () 21219d0ccd10Smrg { 21229d0ccd10Smrg $debug_cmd 21239d0ccd10Smrg 21240ea508b1Smrg func_split_short_opt_name=`expr "x$1" : 'x\(-.\)'` 21259d0ccd10Smrg func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'` 21269d0ccd10Smrg } 21279d0ccd10Smrgfi #func_split_short_opt 21289d0ccd10Smrg 21299d0ccd10Smrg 21309d0ccd10Smrg# func_usage 21319d0ccd10Smrg# ---------- 21329d0ccd10Smrg# Echo short help message to standard output and exit. 21339d0ccd10Smrgfunc_usage () 2134c63293b5Smrg{ 21359d0ccd10Smrg $debug_cmd 2136c63293b5Smrg 21379d0ccd10Smrg func_usage_message 21389d0ccd10Smrg $ECHO "Run '$progname --help |${PAGER-more}' for full usage" 21399d0ccd10Smrg exit 0 21409d0ccd10Smrg} 2141c63293b5Smrg 2142c63293b5Smrg 21439d0ccd10Smrg# func_usage_message 21449d0ccd10Smrg# ------------------ 21459d0ccd10Smrg# Echo short help message to standard output. 21469d0ccd10Smrgfunc_usage_message () 2147c63293b5Smrg{ 21489d0ccd10Smrg $debug_cmd 2149c63293b5Smrg 21509d0ccd10Smrg eval \$ECHO \""Usage: $usage"\" 21519d0ccd10Smrg echo 21529d0ccd10Smrg $SED -n 's|^# || 21539d0ccd10Smrg /^Written by/{ 21549d0ccd10Smrg x;p;x 21559d0ccd10Smrg } 21569d0ccd10Smrg h 21579d0ccd10Smrg /^Written by/q' < "$progpath" 21589d0ccd10Smrg echo 21599d0ccd10Smrg eval \$ECHO \""$usage_message"\" 21609d0ccd10Smrg} 2161c63293b5Smrg 2162e169010aSmrg 21639d0ccd10Smrg# func_version 21649d0ccd10Smrg# ------------ 21659d0ccd10Smrg# Echo version message to standard output and exit. 21660ea508b1Smrg# The version message is extracted from the calling file's header 21670ea508b1Smrg# comments, with leading '# ' stripped: 21680ea508b1Smrg# 1. First display the progname and version 21690ea508b1Smrg# 2. Followed by the header comment line matching /^# Written by / 21700ea508b1Smrg# 3. Then a blank line followed by the first following line matching 21710ea508b1Smrg# /^# Copyright / 21720ea508b1Smrg# 4. Immediately followed by any lines between the previous matches, 21730ea508b1Smrg# except lines preceding the intervening completely blank line. 21740ea508b1Smrg# For example, see the header comments of this file. 21759d0ccd10Smrgfunc_version () 21769d0ccd10Smrg{ 21779d0ccd10Smrg $debug_cmd 2178e169010aSmrg 21799d0ccd10Smrg printf '%s\n' "$progname $scriptversion" 21809d0ccd10Smrg $SED -n ' 21810ea508b1Smrg /^# Written by /!b 21820ea508b1Smrg s|^# ||; p; n 21830ea508b1Smrg 21840ea508b1Smrg :fwd2blnk 21850ea508b1Smrg /./ { 21860ea508b1Smrg n 21870ea508b1Smrg b fwd2blnk 21889d0ccd10Smrg } 21890ea508b1Smrg p; n 21900ea508b1Smrg 21910ea508b1Smrg :holdwrnt 21920ea508b1Smrg s|^# || 21930ea508b1Smrg s|^# *$|| 21940ea508b1Smrg /^Copyright /!{ 21950ea508b1Smrg /./H 21960ea508b1Smrg n 21970ea508b1Smrg b holdwrnt 21989d0ccd10Smrg } 21990ea508b1Smrg 22000ea508b1Smrg s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2| 22010ea508b1Smrg G 22020ea508b1Smrg s|\(\n\)\n*|\1|g 22030ea508b1Smrg p; q' < "$progpath" 2204e169010aSmrg 22059d0ccd10Smrg exit $? 22069d0ccd10Smrg} 2207e169010aSmrg 22087914d74bSmrg 22099d0ccd10Smrg# Local variables: 22109d0ccd10Smrg# mode: shell-script 22119d0ccd10Smrg# sh-indentation: 2 22129d0ccd10Smrg# eval: (add-hook 'before-save-hook 'time-stamp) 22130ea508b1Smrg# time-stamp-pattern: "30/scriptversion=%:y-%02m-%02d.%02H; # UTC" 22149d0ccd10Smrg# time-stamp-time-zone: "UTC" 22159d0ccd10Smrg# End: 22167914d74bSmrg 22179d0ccd10Smrg# Set a version string. 22180ea508b1Smrgscriptversion='(GNU libtool) 2.4.7' 22197914d74bSmrg 22207914d74bSmrg 22219d0ccd10Smrg# func_echo ARG... 22229d0ccd10Smrg# ---------------- 22239d0ccd10Smrg# Libtool also displays the current mode in messages, so override 22249d0ccd10Smrg# funclib.sh func_echo with this custom definition. 22259d0ccd10Smrgfunc_echo () 2226c63293b5Smrg{ 22279d0ccd10Smrg $debug_cmd 2228c63293b5Smrg 22299d0ccd10Smrg _G_message=$* 22309d0ccd10Smrg 22319d0ccd10Smrg func_echo_IFS=$IFS 22329d0ccd10Smrg IFS=$nl 22339d0ccd10Smrg for _G_line in $_G_message; do 22349d0ccd10Smrg IFS=$func_echo_IFS 22359d0ccd10Smrg $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line" 22369d0ccd10Smrg done 22379d0ccd10Smrg IFS=$func_echo_IFS 22389d0ccd10Smrg} 2239c63293b5Smrg 2240c63293b5Smrg 22419d0ccd10Smrg# func_warning ARG... 22429d0ccd10Smrg# ------------------- 22439d0ccd10Smrg# Libtool warnings are not categorized, so override funclib.sh 22449d0ccd10Smrg# func_warning with this simpler definition. 22459d0ccd10Smrgfunc_warning () 2246c63293b5Smrg{ 22479d0ccd10Smrg $debug_cmd 22489d0ccd10Smrg 22499d0ccd10Smrg $warning_func ${1+"$@"} 22509d0ccd10Smrg} 22519d0ccd10Smrg 2252c63293b5Smrg 22539d0ccd10Smrg## ---------------- ## 22549d0ccd10Smrg## Options parsing. ## 22559d0ccd10Smrg## ---------------- ## 22569d0ccd10Smrg 22579d0ccd10Smrg# Hook in the functions to make sure our own options are parsed during 22589d0ccd10Smrg# the option parsing loop. 22599d0ccd10Smrg 22609d0ccd10Smrgusage='$progpath [OPTION]... [MODE-ARG]...' 22619d0ccd10Smrg 22629d0ccd10Smrg# Short help message in response to '-h'. 22639d0ccd10Smrgusage_message="Options: 22649d0ccd10Smrg --config show all configuration variables 22659d0ccd10Smrg --debug enable verbose shell tracing 22669d0ccd10Smrg -n, --dry-run display commands without modifying any files 22679d0ccd10Smrg --features display basic configuration information and exit 22689d0ccd10Smrg --mode=MODE use operation mode MODE 22699d0ccd10Smrg --no-warnings equivalent to '-Wnone' 22709d0ccd10Smrg --preserve-dup-deps don't remove duplicate dependency libraries 22719d0ccd10Smrg --quiet, --silent don't print informational messages 22729d0ccd10Smrg --tag=TAG use configuration variables from tag TAG 22739d0ccd10Smrg -v, --verbose print more informational messages than default 22749d0ccd10Smrg --version print version information 22759d0ccd10Smrg -W, --warnings=CATEGORY report the warnings falling in CATEGORY [all] 22769d0ccd10Smrg -h, --help, --help-all print short, long, or detailed help message 22779d0ccd10Smrg" 2278c63293b5Smrg 22799d0ccd10Smrg# Additional text appended to 'usage_message' in response to '--help'. 22809d0ccd10Smrgfunc_help () 2281c63293b5Smrg{ 22829d0ccd10Smrg $debug_cmd 22839d0ccd10Smrg 22849d0ccd10Smrg func_usage_message 22859d0ccd10Smrg $ECHO "$long_help_message 22869d0ccd10Smrg 22879d0ccd10SmrgMODE must be one of the following: 22889d0ccd10Smrg 22899d0ccd10Smrg clean remove files from the build directory 22909d0ccd10Smrg compile compile a source file into a libtool object 22919d0ccd10Smrg execute automatically set library path, then run a program 22929d0ccd10Smrg finish complete the installation of libtool libraries 22939d0ccd10Smrg install install libraries or executables 22949d0ccd10Smrg link create a library or an executable 22959d0ccd10Smrg uninstall remove libraries from an installed directory 22969d0ccd10Smrg 22979d0ccd10SmrgMODE-ARGS vary depending on the MODE. When passed as first option, 22989d0ccd10Smrg'--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that. 22999d0ccd10SmrgTry '$progname --help --mode=MODE' for a more detailed description of MODE. 23009d0ccd10Smrg 23019d0ccd10SmrgWhen reporting a bug, please describe a test case to reproduce it and 23029d0ccd10Smrginclude the following information: 23039d0ccd10Smrg 23049d0ccd10Smrg host-triplet: $host 23059d0ccd10Smrg shell: $SHELL 23069d0ccd10Smrg compiler: $LTCC 23079d0ccd10Smrg compiler flags: $LTCFLAGS 23089d0ccd10Smrg linker: $LD (gnu? $with_gnu_ld) 23090ea508b1Smrg version: $progname (GNU libtool) 2.4.7 23109d0ccd10Smrg automake: `($AUTOMAKE --version) 2>/dev/null |$SED 1q` 23119d0ccd10Smrg autoconf: `($AUTOCONF --version) 2>/dev/null |$SED 1q` 23129d0ccd10Smrg 23139d0ccd10SmrgReport bugs to <bug-libtool@gnu.org>. 23140ea508b1SmrgGNU libtool home page: <http://www.gnu.org/software/libtool/>. 23159d0ccd10SmrgGeneral help using GNU software: <http://www.gnu.org/gethelp/>." 23169d0ccd10Smrg exit 0 23179d0ccd10Smrg} 2318c63293b5Smrg 2319c63293b5Smrg 23209d0ccd10Smrg# func_lo2o OBJECT-NAME 23219d0ccd10Smrg# --------------------- 23229d0ccd10Smrg# Transform OBJECT-NAME from a '.lo' suffix to the platform specific 23239d0ccd10Smrg# object suffix. 2324c63293b5Smrg 23259d0ccd10Smrglo2o=s/\\.lo\$/.$objext/ 23269d0ccd10Smrgo2lo=s/\\.$objext\$/.lo/ 2327c63293b5Smrg 23289d0ccd10Smrgif test yes = "$_G_HAVE_XSI_OPS"; then 23299d0ccd10Smrg eval 'func_lo2o () 23309d0ccd10Smrg { 23319d0ccd10Smrg case $1 in 23329d0ccd10Smrg *.lo) func_lo2o_result=${1%.lo}.$objext ;; 23339d0ccd10Smrg * ) func_lo2o_result=$1 ;; 23349d0ccd10Smrg esac 23359d0ccd10Smrg }' 23369d0ccd10Smrg 23379d0ccd10Smrg # func_xform LIBOBJ-OR-SOURCE 23389d0ccd10Smrg # --------------------------- 23399d0ccd10Smrg # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise) 23409d0ccd10Smrg # suffix to a '.lo' libtool-object suffix. 23419d0ccd10Smrg eval 'func_xform () 23429d0ccd10Smrg { 23439d0ccd10Smrg func_xform_result=${1%.*}.lo 23449d0ccd10Smrg }' 23459d0ccd10Smrgelse 23469d0ccd10Smrg # ...otherwise fall back to using sed. 23479d0ccd10Smrg func_lo2o () 23489d0ccd10Smrg { 23499d0ccd10Smrg func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"` 23509d0ccd10Smrg } 23519d0ccd10Smrg 23529d0ccd10Smrg func_xform () 23539d0ccd10Smrg { 23549d0ccd10Smrg func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'` 23559d0ccd10Smrg } 23569d0ccd10Smrgfi 2357c63293b5Smrg 2358c63293b5Smrg 23599d0ccd10Smrg# func_fatal_configuration ARG... 23609d0ccd10Smrg# ------------------------------- 2361e169010aSmrg# Echo program name prefixed message to standard error, followed by 2362e169010aSmrg# a configuration failure hint, and exit. 2363e169010aSmrgfunc_fatal_configuration () 2364e169010aSmrg{ 23650ea508b1Smrg func_fatal_error ${1+"$@"} \ 23669d0ccd10Smrg "See the $PACKAGE documentation for more information." \ 23679d0ccd10Smrg "Fatal configuration error." 2368e169010aSmrg} 2369e169010aSmrg 2370e169010aSmrg 2371e169010aSmrg# func_config 23729d0ccd10Smrg# ----------- 2373e169010aSmrg# Display the configuration for all the tags in this script. 2374e169010aSmrgfunc_config () 2375e169010aSmrg{ 2376e169010aSmrg re_begincf='^# ### BEGIN LIBTOOL' 2377e169010aSmrg re_endcf='^# ### END LIBTOOL' 2378e169010aSmrg 2379e169010aSmrg # Default configuration. 2380e169010aSmrg $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" 23817914d74bSmrg 23827914d74bSmrg # Now print the configurations for the tags. 23837914d74bSmrg for tagname in $taglist; do 2384e169010aSmrg $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" 23857914d74bSmrg done 23867914d74bSmrg 2387e169010aSmrg exit $? 2388e169010aSmrg} 23897914d74bSmrg 23909d0ccd10Smrg 2391e169010aSmrg# func_features 23929d0ccd10Smrg# ------------- 2393e169010aSmrg# Display the features supported by this script. 2394e169010aSmrgfunc_features () 2395e169010aSmrg{ 2396e8ead290Smrg echo "host: $host" 23979d0ccd10Smrg if test yes = "$build_libtool_libs"; then 2398e8ead290Smrg echo "enable shared libraries" 23997914d74bSmrg else 2400e8ead290Smrg echo "disable shared libraries" 24017914d74bSmrg fi 24029d0ccd10Smrg if test yes = "$build_old_libs"; then 2403e8ead290Smrg echo "enable static libraries" 24047914d74bSmrg else 2405e8ead290Smrg echo "disable static libraries" 24067914d74bSmrg fi 2407e169010aSmrg 24087914d74bSmrg exit $? 2409e169010aSmrg} 2410e169010aSmrg 24119d0ccd10Smrg 24129d0ccd10Smrg# func_enable_tag TAGNAME 24139d0ccd10Smrg# ----------------------- 2414e169010aSmrg# Verify that TAGNAME is valid, and either flag an error and exit, or 2415e169010aSmrg# enable the TAGNAME tag. We also add TAGNAME to the global $taglist 2416e169010aSmrg# variable here. 2417e169010aSmrgfunc_enable_tag () 2418e169010aSmrg{ 24199d0ccd10Smrg # Global variable: 24209d0ccd10Smrg tagname=$1 24217914d74bSmrg 24229d0ccd10Smrg re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" 24239d0ccd10Smrg re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" 24249d0ccd10Smrg sed_extractcf=/$re_begincf/,/$re_endcf/p 24257914d74bSmrg 24269d0ccd10Smrg # Validate tagname. 24279d0ccd10Smrg case $tagname in 24289d0ccd10Smrg *[!-_A-Za-z0-9,/]*) 24299d0ccd10Smrg func_fatal_error "invalid tag name: $tagname" 24309d0ccd10Smrg ;; 24319d0ccd10Smrg esac 24327914d74bSmrg 24339d0ccd10Smrg # Don't test for the "default" C tag, as we know it's 24349d0ccd10Smrg # there but not specially marked. 24359d0ccd10Smrg case $tagname in 24369d0ccd10Smrg CC) ;; 2437e169010aSmrg *) 24389d0ccd10Smrg if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then 24399d0ccd10Smrg taglist="$taglist $tagname" 24409d0ccd10Smrg 24419d0ccd10Smrg # Evaluate the configuration. Be careful to quote the path 24429d0ccd10Smrg # and the sed script, to avoid splitting on whitespace, but 24439d0ccd10Smrg # also don't use non-portable quotes within backquotes within 24449d0ccd10Smrg # quotes we have to do it in 2 steps: 24459d0ccd10Smrg extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` 24469d0ccd10Smrg eval "$extractedcf" 24479d0ccd10Smrg else 24489d0ccd10Smrg func_error "ignoring unknown tag $tagname" 24499d0ccd10Smrg fi 24509d0ccd10Smrg ;; 24519d0ccd10Smrg esac 2452e169010aSmrg} 24537914d74bSmrg 24549d0ccd10Smrg 2455c63293b5Smrg# func_check_version_match 24569d0ccd10Smrg# ------------------------ 2457c63293b5Smrg# Ensure that we are using m4 macros, and libtool script from the same 2458c63293b5Smrg# release of libtool. 2459c63293b5Smrgfunc_check_version_match () 2460e169010aSmrg{ 24619d0ccd10Smrg if test "$package_revision" != "$macro_revision"; then 24629d0ccd10Smrg if test "$VERSION" != "$macro_version"; then 24639d0ccd10Smrg if test -z "$macro_version"; then 24649d0ccd10Smrg cat >&2 <<_LT_EOF 2465c63293b5Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 2466c63293b5Smrg$progname: definition of this LT_INIT comes from an older release. 2467c63293b5Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 2468c63293b5Smrg$progname: and run autoconf again. 2469c63293b5Smrg_LT_EOF 24709d0ccd10Smrg else 24719d0ccd10Smrg cat >&2 <<_LT_EOF 2472c63293b5Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 2473c63293b5Smrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version. 2474c63293b5Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 2475c63293b5Smrg$progname: and run autoconf again. 2476c63293b5Smrg_LT_EOF 24779d0ccd10Smrg fi 24789d0ccd10Smrg else 24799d0ccd10Smrg cat >&2 <<_LT_EOF 2480c63293b5Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, 2481c63293b5Smrg$progname: but the definition of this LT_INIT comes from revision $macro_revision. 2482c63293b5Smrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision 2483c63293b5Smrg$progname: of $PACKAGE $VERSION and run autoconf again. 2484c63293b5Smrg_LT_EOF 24859d0ccd10Smrg fi 24867914d74bSmrg 24879d0ccd10Smrg exit $EXIT_MISMATCH 24889d0ccd10Smrg fi 2489c63293b5Smrg} 2490c63293b5Smrg 2491c63293b5Smrg 24929d0ccd10Smrg# libtool_options_prep [ARG]... 24939d0ccd10Smrg# ----------------------------- 24949d0ccd10Smrg# Preparation for options parsed by libtool. 24959d0ccd10Smrglibtool_options_prep () 24969d0ccd10Smrg{ 24979d0ccd10Smrg $debug_mode 24987914d74bSmrg 24999d0ccd10Smrg # Option defaults: 25009d0ccd10Smrg opt_config=false 25019d0ccd10Smrg opt_dlopen= 25029d0ccd10Smrg opt_dry_run=false 25039d0ccd10Smrg opt_help=false 25049d0ccd10Smrg opt_mode= 25059d0ccd10Smrg opt_preserve_dup_deps=false 25069d0ccd10Smrg opt_quiet=false 2507c63293b5Smrg 25089d0ccd10Smrg nonopt= 25099d0ccd10Smrg preserve_args= 2510c63293b5Smrg 25110ea508b1Smrg _G_rc_lt_options_prep=: 25120ea508b1Smrg 25139d0ccd10Smrg # Shorthand for --mode=foo, only valid as the first argument 25149d0ccd10Smrg case $1 in 25159d0ccd10Smrg clean|clea|cle|cl) 25169d0ccd10Smrg shift; set dummy --mode clean ${1+"$@"}; shift 25179d0ccd10Smrg ;; 25189d0ccd10Smrg compile|compil|compi|comp|com|co|c) 25199d0ccd10Smrg shift; set dummy --mode compile ${1+"$@"}; shift 25209d0ccd10Smrg ;; 25219d0ccd10Smrg execute|execut|execu|exec|exe|ex|e) 25229d0ccd10Smrg shift; set dummy --mode execute ${1+"$@"}; shift 25239d0ccd10Smrg ;; 25249d0ccd10Smrg finish|finis|fini|fin|fi|f) 25259d0ccd10Smrg shift; set dummy --mode finish ${1+"$@"}; shift 25269d0ccd10Smrg ;; 25279d0ccd10Smrg install|instal|insta|inst|ins|in|i) 25289d0ccd10Smrg shift; set dummy --mode install ${1+"$@"}; shift 25299d0ccd10Smrg ;; 25309d0ccd10Smrg link|lin|li|l) 25319d0ccd10Smrg shift; set dummy --mode link ${1+"$@"}; shift 25329d0ccd10Smrg ;; 25339d0ccd10Smrg uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) 25349d0ccd10Smrg shift; set dummy --mode uninstall ${1+"$@"}; shift 25359d0ccd10Smrg ;; 25360ea508b1Smrg *) 25370ea508b1Smrg _G_rc_lt_options_prep=false 25380ea508b1Smrg ;; 25399d0ccd10Smrg esac 25409d0ccd10Smrg 25410ea508b1Smrg if $_G_rc_lt_options_prep; then 25420ea508b1Smrg # Pass back the list of options. 25430ea508b1Smrg func_quote eval ${1+"$@"} 25440ea508b1Smrg libtool_options_prep_result=$func_quote_result 25450ea508b1Smrg fi 25469d0ccd10Smrg} 25479d0ccd10Smrgfunc_add_hook func_options_prep libtool_options_prep 2548c63293b5Smrg 2549c63293b5Smrg 25509d0ccd10Smrg# libtool_parse_options [ARG]... 25519d0ccd10Smrg# --------------------------------- 25529d0ccd10Smrg# Provide handling for libtool specific options. 25539d0ccd10Smrglibtool_parse_options () 2554c63293b5Smrg{ 25559d0ccd10Smrg $debug_cmd 2556e169010aSmrg 25570ea508b1Smrg _G_rc_lt_parse_options=false 25580ea508b1Smrg 25599d0ccd10Smrg # Perform our own loop to consume as many options as possible in 25609d0ccd10Smrg # each iteration. 25619d0ccd10Smrg while test $# -gt 0; do 25620ea508b1Smrg _G_match_lt_parse_options=: 25639d0ccd10Smrg _G_opt=$1 25649d0ccd10Smrg shift 25659d0ccd10Smrg case $_G_opt in 25669d0ccd10Smrg --dry-run|--dryrun|-n) 25679d0ccd10Smrg opt_dry_run=: 25689d0ccd10Smrg ;; 25699d0ccd10Smrg 25709d0ccd10Smrg --config) func_config ;; 25719d0ccd10Smrg 25729d0ccd10Smrg --dlopen|-dlopen) 25739d0ccd10Smrg opt_dlopen="${opt_dlopen+$opt_dlopen 25749d0ccd10Smrg}$1" 25759d0ccd10Smrg shift 25769d0ccd10Smrg ;; 25779d0ccd10Smrg 25789d0ccd10Smrg --preserve-dup-deps) 25799d0ccd10Smrg opt_preserve_dup_deps=: ;; 25809d0ccd10Smrg 25819d0ccd10Smrg --features) func_features ;; 25829d0ccd10Smrg 25839d0ccd10Smrg --finish) set dummy --mode finish ${1+"$@"}; shift ;; 25849d0ccd10Smrg 25859d0ccd10Smrg --help) opt_help=: ;; 25869d0ccd10Smrg 25879d0ccd10Smrg --help-all) opt_help=': help-all' ;; 25889d0ccd10Smrg 25899d0ccd10Smrg --mode) test $# = 0 && func_missing_arg $_G_opt && break 25909d0ccd10Smrg opt_mode=$1 25919d0ccd10Smrg case $1 in 25929d0ccd10Smrg # Valid mode arguments: 25939d0ccd10Smrg clean|compile|execute|finish|install|link|relink|uninstall) ;; 25949d0ccd10Smrg 25959d0ccd10Smrg # Catch anything else as an error 25969d0ccd10Smrg *) func_error "invalid argument for $_G_opt" 25979d0ccd10Smrg exit_cmd=exit 25989d0ccd10Smrg break 25999d0ccd10Smrg ;; 26009d0ccd10Smrg esac 26019d0ccd10Smrg shift 26029d0ccd10Smrg ;; 26039d0ccd10Smrg 26049d0ccd10Smrg --no-silent|--no-quiet) 26059d0ccd10Smrg opt_quiet=false 26069d0ccd10Smrg func_append preserve_args " $_G_opt" 26079d0ccd10Smrg ;; 26089d0ccd10Smrg 26099d0ccd10Smrg --no-warnings|--no-warning|--no-warn) 26109d0ccd10Smrg opt_warning=false 26119d0ccd10Smrg func_append preserve_args " $_G_opt" 26129d0ccd10Smrg ;; 26139d0ccd10Smrg 26149d0ccd10Smrg --no-verbose) 26159d0ccd10Smrg opt_verbose=false 26169d0ccd10Smrg func_append preserve_args " $_G_opt" 26179d0ccd10Smrg ;; 26189d0ccd10Smrg 26199d0ccd10Smrg --silent|--quiet) 26209d0ccd10Smrg opt_quiet=: 26219d0ccd10Smrg opt_verbose=false 26229d0ccd10Smrg func_append preserve_args " $_G_opt" 26239d0ccd10Smrg ;; 26249d0ccd10Smrg 26259d0ccd10Smrg --tag) test $# = 0 && func_missing_arg $_G_opt && break 26269d0ccd10Smrg opt_tag=$1 26279d0ccd10Smrg func_append preserve_args " $_G_opt $1" 26289d0ccd10Smrg func_enable_tag "$1" 26299d0ccd10Smrg shift 26309d0ccd10Smrg ;; 26319d0ccd10Smrg 26329d0ccd10Smrg --verbose|-v) opt_quiet=false 26339d0ccd10Smrg opt_verbose=: 26349d0ccd10Smrg func_append preserve_args " $_G_opt" 26359d0ccd10Smrg ;; 26369d0ccd10Smrg 26370ea508b1Smrg # An option not handled by this hook function: 26380ea508b1Smrg *) set dummy "$_G_opt" ${1+"$@"} ; shift 26390ea508b1Smrg _G_match_lt_parse_options=false 26400ea508b1Smrg break 26410ea508b1Smrg ;; 26429d0ccd10Smrg esac 26430ea508b1Smrg $_G_match_lt_parse_options && _G_rc_lt_parse_options=: 26449d0ccd10Smrg done 2645c63293b5Smrg 26460ea508b1Smrg if $_G_rc_lt_parse_options; then 26470ea508b1Smrg # save modified positional parameters for caller 26480ea508b1Smrg func_quote eval ${1+"$@"} 26490ea508b1Smrg libtool_parse_options_result=$func_quote_result 26500ea508b1Smrg fi 26519d0ccd10Smrg} 26529d0ccd10Smrgfunc_add_hook func_parse_options libtool_parse_options 2653e169010aSmrg 26547914d74bSmrg 2655e169010aSmrg 26569d0ccd10Smrg# libtool_validate_options [ARG]... 26579d0ccd10Smrg# --------------------------------- 26589d0ccd10Smrg# Perform any sanity checks on option settings and/or unconsumed 26599d0ccd10Smrg# arguments. 26609d0ccd10Smrglibtool_validate_options () 26619d0ccd10Smrg{ 26629d0ccd10Smrg # save first non-option argument 26639d0ccd10Smrg if test 0 -lt $#; then 26649d0ccd10Smrg nonopt=$1 26659d0ccd10Smrg shift 2666e169010aSmrg fi 2667e169010aSmrg 26689d0ccd10Smrg # preserve --debug 26699d0ccd10Smrg test : = "$debug_cmd" || func_append preserve_args " --debug" 2670e169010aSmrg 26719d0ccd10Smrg case $host in 26729d0ccd10Smrg # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452 26739d0ccd10Smrg # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788 26749d0ccd10Smrg *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*) 26759d0ccd10Smrg # don't eliminate duplications in $postdeps and $predeps 26769d0ccd10Smrg opt_duplicate_compiler_generated_deps=: 26779d0ccd10Smrg ;; 26789d0ccd10Smrg *) 26799d0ccd10Smrg opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps 26809d0ccd10Smrg ;; 26819d0ccd10Smrg esac 2682e169010aSmrg 26839d0ccd10Smrg $opt_help || { 26849d0ccd10Smrg # Sanity checks first: 26859d0ccd10Smrg func_check_version_match 2686e169010aSmrg 26879d0ccd10Smrg test yes != "$build_libtool_libs" \ 26889d0ccd10Smrg && test yes != "$build_old_libs" \ 26899d0ccd10Smrg && func_fatal_configuration "not configured to build any kind of library" 2690e169010aSmrg 26919d0ccd10Smrg # Darwin sucks 26929d0ccd10Smrg eval std_shrext=\"$shrext_cmds\" 26939d0ccd10Smrg 26949d0ccd10Smrg # Only execute mode is allowed to have -dlopen flags. 26959d0ccd10Smrg if test -n "$opt_dlopen" && test execute != "$opt_mode"; then 26969d0ccd10Smrg func_error "unrecognized option '-dlopen'" 26979d0ccd10Smrg $ECHO "$help" 1>&2 26989d0ccd10Smrg exit $EXIT_FAILURE 26999d0ccd10Smrg fi 27009d0ccd10Smrg 27019d0ccd10Smrg # Change the help message to a mode-specific one. 27029d0ccd10Smrg generic_help=$help 27039d0ccd10Smrg help="Try '$progname --help --mode=$opt_mode' for more information." 27049d0ccd10Smrg } 27059d0ccd10Smrg 27069d0ccd10Smrg # Pass back the unparsed argument list 27070ea508b1Smrg func_quote eval ${1+"$@"} 27080ea508b1Smrg libtool_validate_options_result=$func_quote_result 2709c63293b5Smrg} 27109d0ccd10Smrgfunc_add_hook func_validate_options libtool_validate_options 27119d0ccd10Smrg 2712e169010aSmrg 27139d0ccd10Smrg# Process options as early as possible so that --help and --version 27149d0ccd10Smrg# can return quickly. 27159d0ccd10Smrgfunc_options ${1+"$@"} 27169d0ccd10Smrgeval set dummy "$func_options_result"; shift 2717e169010aSmrg 27187914d74bSmrg 27197914d74bSmrg 2720c63293b5Smrg## ----------- ## 2721c63293b5Smrg## Main. ## 2722c63293b5Smrg## ----------- ## 27237914d74bSmrg 27249d0ccd10Smrgmagic='%%%MAGIC variable%%%' 27259d0ccd10Smrgmagic_exe='%%%MAGIC EXE variable%%%' 27269d0ccd10Smrg 27279d0ccd10Smrg# Global variables. 27289d0ccd10Smrgextracted_archives= 27299d0ccd10Smrgextracted_serial=0 27309d0ccd10Smrg 27319d0ccd10Smrg# If this variable is set in any of the actions, the command in it 27329d0ccd10Smrg# will be execed at the end. This prevents here-documents from being 27339d0ccd10Smrg# left over by shells. 27349d0ccd10Smrgexec_cmd= 27359d0ccd10Smrg 27369d0ccd10Smrg 27379d0ccd10Smrg# A function that is used when there is no print builtin or printf. 27389d0ccd10Smrgfunc_fallback_echo () 27399d0ccd10Smrg{ 27409d0ccd10Smrg eval 'cat <<_LTECHO_EOF 27419d0ccd10Smrg$1 27429d0ccd10Smrg_LTECHO_EOF' 27439d0ccd10Smrg} 27449d0ccd10Smrg 27459d0ccd10Smrg# func_generated_by_libtool 27469d0ccd10Smrg# True iff stdin has been generated by Libtool. This function is only 27479d0ccd10Smrg# a basic sanity check; it will hardly flush out determined imposters. 27489d0ccd10Smrgfunc_generated_by_libtool_p () 27499d0ccd10Smrg{ 27509d0ccd10Smrg $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 27519d0ccd10Smrg} 27529d0ccd10Smrg 2753e169010aSmrg# func_lalib_p file 27549d0ccd10Smrg# True iff FILE is a libtool '.la' library or '.lo' object file. 2755e169010aSmrg# This function is only a basic sanity check; it will hardly flush out 2756e169010aSmrg# determined imposters. 2757e169010aSmrgfunc_lalib_p () 2758e169010aSmrg{ 2759e169010aSmrg test -f "$1" && 27609d0ccd10Smrg $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p 2761e169010aSmrg} 27627914d74bSmrg 2763e169010aSmrg# func_lalib_unsafe_p file 27649d0ccd10Smrg# True iff FILE is a libtool '.la' library or '.lo' object file. 2765e169010aSmrg# This function implements the same check as func_lalib_p without 2766e169010aSmrg# resorting to external programs. To this end, it redirects stdin and 2767e169010aSmrg# closes it afterwards, without saving the original file descriptor. 2768e169010aSmrg# As a safety measure, use it only where a negative result would be 27699d0ccd10Smrg# fatal anyway. Works if 'file' does not exist. 2770e169010aSmrgfunc_lalib_unsafe_p () 2771e169010aSmrg{ 2772e169010aSmrg lalib_p=no 2773e169010aSmrg if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then 2774e169010aSmrg for lalib_p_l in 1 2 3 4 2775e169010aSmrg do 2776e169010aSmrg read lalib_p_line 27779d0ccd10Smrg case $lalib_p_line in 2778e169010aSmrg \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; 2779e169010aSmrg esac 2780e169010aSmrg done 2781e169010aSmrg exec 0<&5 5<&- 2782e169010aSmrg fi 27839d0ccd10Smrg test yes = "$lalib_p" 2784e169010aSmrg} 27857914d74bSmrg 2786e169010aSmrg# func_ltwrapper_script_p file 2787e169010aSmrg# True iff FILE is a libtool wrapper script 2788e169010aSmrg# This function is only a basic sanity check; it will hardly flush out 2789e169010aSmrg# determined imposters. 2790e169010aSmrgfunc_ltwrapper_script_p () 2791e169010aSmrg{ 27929d0ccd10Smrg test -f "$1" && 27939d0ccd10Smrg $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p 2794e169010aSmrg} 27957914d74bSmrg 2796e169010aSmrg# func_ltwrapper_executable_p file 2797e169010aSmrg# True iff FILE is a libtool wrapper executable 2798e169010aSmrg# This function is only a basic sanity check; it will hardly flush out 2799e169010aSmrg# determined imposters. 2800e169010aSmrgfunc_ltwrapper_executable_p () 2801e169010aSmrg{ 2802e169010aSmrg func_ltwrapper_exec_suffix= 2803e169010aSmrg case $1 in 2804e169010aSmrg *.exe) ;; 2805e169010aSmrg *) func_ltwrapper_exec_suffix=.exe ;; 2806e169010aSmrg esac 2807e169010aSmrg $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 2808e169010aSmrg} 28097914d74bSmrg 2810e169010aSmrg# func_ltwrapper_scriptname file 2811e169010aSmrg# Assumes file is an ltwrapper_executable 2812e169010aSmrg# uses $file to determine the appropriate filename for a 2813e169010aSmrg# temporary ltwrapper_script. 2814e169010aSmrgfunc_ltwrapper_scriptname () 2815e169010aSmrg{ 2816c63293b5Smrg func_dirname_and_basename "$1" "" "." 2817c63293b5Smrg func_stripname '' '.exe' "$func_basename_result" 28189d0ccd10Smrg func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper 2819e169010aSmrg} 28207914d74bSmrg 2821e169010aSmrg# func_ltwrapper_p file 2822e169010aSmrg# True iff FILE is a libtool wrapper script or wrapper executable 2823e169010aSmrg# This function is only a basic sanity check; it will hardly flush out 2824e169010aSmrg# determined imposters. 2825e169010aSmrgfunc_ltwrapper_p () 2826e169010aSmrg{ 2827e169010aSmrg func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" 2828e169010aSmrg} 28297914d74bSmrg 28307914d74bSmrg 2831e169010aSmrg# func_execute_cmds commands fail_cmd 2832e169010aSmrg# Execute tilde-delimited COMMANDS. 2833e169010aSmrg# If FAIL_CMD is given, eval that upon failure. 2834e169010aSmrg# FAIL_CMD may read-access the current command in variable CMD! 2835e169010aSmrgfunc_execute_cmds () 2836e169010aSmrg{ 28379d0ccd10Smrg $debug_cmd 28389d0ccd10Smrg 2839e169010aSmrg save_ifs=$IFS; IFS='~' 2840e169010aSmrg for cmd in $1; do 28419d0ccd10Smrg IFS=$sp$nl 2842e169010aSmrg eval cmd=\"$cmd\" 28439d0ccd10Smrg IFS=$save_ifs 2844e169010aSmrg func_show_eval "$cmd" "${2-:}" 2845e169010aSmrg done 2846e169010aSmrg IFS=$save_ifs 2847e169010aSmrg} 2848e169010aSmrg 2849e169010aSmrg 2850e169010aSmrg# func_source file 2851e169010aSmrg# Source FILE, adding directory component if necessary. 2852e169010aSmrg# Note that it is not necessary on cygwin/mingw to append a dot to 2853e169010aSmrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe 2854e169010aSmrg# behavior happens only for exec(3), not for open(2)! Also, sourcing 28559d0ccd10Smrg# 'FILE.' does not work on cygwin managed mounts. 2856e169010aSmrgfunc_source () 2857e169010aSmrg{ 28589d0ccd10Smrg $debug_cmd 28599d0ccd10Smrg 2860e169010aSmrg case $1 in 2861e169010aSmrg */* | *\\*) . "$1" ;; 2862e169010aSmrg *) . "./$1" ;; 2863e169010aSmrg esac 2864e169010aSmrg} 2865e169010aSmrg 2866e169010aSmrg 2867c63293b5Smrg# func_resolve_sysroot PATH 2868c63293b5Smrg# Replace a leading = in PATH with a sysroot. Store the result into 2869c63293b5Smrg# func_resolve_sysroot_result 2870c63293b5Smrgfunc_resolve_sysroot () 2871c63293b5Smrg{ 2872c63293b5Smrg func_resolve_sysroot_result=$1 2873c63293b5Smrg case $func_resolve_sysroot_result in 2874c63293b5Smrg =*) 2875c63293b5Smrg func_stripname '=' '' "$func_resolve_sysroot_result" 2876c63293b5Smrg func_resolve_sysroot_result=$lt_sysroot$func_stripname_result 2877c63293b5Smrg ;; 2878c63293b5Smrg esac 2879c63293b5Smrg} 2880c63293b5Smrg 2881c63293b5Smrg# func_replace_sysroot PATH 2882c63293b5Smrg# If PATH begins with the sysroot, replace it with = and 2883c63293b5Smrg# store the result into func_replace_sysroot_result. 2884c63293b5Smrgfunc_replace_sysroot () 2885c63293b5Smrg{ 28869d0ccd10Smrg case $lt_sysroot:$1 in 2887c63293b5Smrg ?*:"$lt_sysroot"*) 2888c63293b5Smrg func_stripname "$lt_sysroot" '' "$1" 28899d0ccd10Smrg func_replace_sysroot_result='='$func_stripname_result 2890c63293b5Smrg ;; 2891c63293b5Smrg *) 2892c63293b5Smrg # Including no sysroot. 2893c63293b5Smrg func_replace_sysroot_result=$1 2894c63293b5Smrg ;; 2895c63293b5Smrg esac 2896c63293b5Smrg} 2897c63293b5Smrg 2898e169010aSmrg# func_infer_tag arg 2899e169010aSmrg# Infer tagged configuration to use if any are available and 2900e169010aSmrg# if one wasn't chosen via the "--tag" command line option. 2901e169010aSmrg# Only attempt this if the compiler in the base compile 2902e169010aSmrg# command doesn't match the default compiler. 2903e169010aSmrg# arg is usually of the form 'gcc ...' 2904e169010aSmrgfunc_infer_tag () 2905e169010aSmrg{ 29069d0ccd10Smrg $debug_cmd 29079d0ccd10Smrg 2908e169010aSmrg if test -n "$available_tags" && test -z "$tagname"; then 2909e169010aSmrg CC_quoted= 2910e169010aSmrg for arg in $CC; do 2911c63293b5Smrg func_append_quoted CC_quoted "$arg" 2912e169010aSmrg done 2913e8ead290Smrg CC_expanded=`func_echo_all $CC` 2914e8ead290Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 2915e169010aSmrg case $@ in 2916e169010aSmrg # Blanks in the command may have been stripped by the calling shell, 2917e169010aSmrg # but not from the CC environment variable when configure was run. 2918e8ead290Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 2919e8ead290Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; 2920e169010aSmrg # Blanks at the start of $base_compile will cause this to fail 2921e169010aSmrg # if we don't check for them as well. 2922e169010aSmrg *) 2923e169010aSmrg for z in $available_tags; do 2924e169010aSmrg if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then 2925e169010aSmrg # Evaluate the configuration. 29269d0ccd10Smrg eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" 2927e169010aSmrg CC_quoted= 2928e169010aSmrg for arg in $CC; do 2929e169010aSmrg # Double-quote args containing other shell metacharacters. 2930c63293b5Smrg func_append_quoted CC_quoted "$arg" 2931e169010aSmrg done 2932e8ead290Smrg CC_expanded=`func_echo_all $CC` 2933e8ead290Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 2934e169010aSmrg case "$@ " in 2935e8ead290Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 2936e8ead290Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) 2937e169010aSmrg # The compiler in the base compile command matches 2938e169010aSmrg # the one in the tagged configuration. 2939e169010aSmrg # Assume this is the tagged configuration we want. 2940e169010aSmrg tagname=$z 2941e169010aSmrg break 2942e169010aSmrg ;; 29437914d74bSmrg esac 2944e169010aSmrg fi 2945e169010aSmrg done 2946e169010aSmrg # If $tagname still isn't set, then no tagged configuration 2947e169010aSmrg # was found and let the user know that the "--tag" command 2948e169010aSmrg # line option must be used. 2949e169010aSmrg if test -z "$tagname"; then 2950e169010aSmrg func_echo "unable to infer tagged configuration" 29519d0ccd10Smrg func_fatal_error "specify a tag with '--tag'" 2952e169010aSmrg# else 2953e169010aSmrg# func_verbose "using $tagname tagged configuration" 2954e169010aSmrg fi 2955e169010aSmrg ;; 2956e169010aSmrg esac 2957e169010aSmrg fi 2958e169010aSmrg} 2959e169010aSmrg 2960e169010aSmrg 2961e169010aSmrg 2962c63293b5Smrg# func_write_libtool_object output_name pic_name nonpic_name 2963c63293b5Smrg# Create a libtool object file (analogous to a ".la" file), 2964c63293b5Smrg# but don't create it if we're doing a dry run. 2965c63293b5Smrgfunc_write_libtool_object () 2966c63293b5Smrg{ 29679d0ccd10Smrg write_libobj=$1 29689d0ccd10Smrg if test yes = "$build_libtool_libs"; then 29699d0ccd10Smrg write_lobj=\'$2\' 2970c63293b5Smrg else 2971c63293b5Smrg write_lobj=none 2972c63293b5Smrg fi 2973c63293b5Smrg 29749d0ccd10Smrg if test yes = "$build_old_libs"; then 29759d0ccd10Smrg write_oldobj=\'$3\' 2976c63293b5Smrg else 2977c63293b5Smrg write_oldobj=none 2978c63293b5Smrg fi 2979c63293b5Smrg 2980c63293b5Smrg $opt_dry_run || { 2981c63293b5Smrg cat >${write_libobj}T <<EOF 2982c63293b5Smrg# $write_libobj - a libtool object file 29839d0ccd10Smrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 2984c63293b5Smrg# 2985c63293b5Smrg# Please DO NOT delete this file! 2986c63293b5Smrg# It is necessary for linking the library. 2987c63293b5Smrg 2988c63293b5Smrg# Name of the PIC object. 2989c63293b5Smrgpic_object=$write_lobj 2990c63293b5Smrg 2991c63293b5Smrg# Name of the non-PIC object 2992c63293b5Smrgnon_pic_object=$write_oldobj 2993c63293b5Smrg 2994c63293b5SmrgEOF 29959d0ccd10Smrg $MV "${write_libobj}T" "$write_libobj" 2996c63293b5Smrg } 2997c63293b5Smrg} 2998c63293b5Smrg 2999c63293b5Smrg 3000c63293b5Smrg################################################## 3001c63293b5Smrg# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS # 3002c63293b5Smrg################################################## 3003c63293b5Smrg 3004c63293b5Smrg# func_convert_core_file_wine_to_w32 ARG 3005c63293b5Smrg# Helper function used by file name conversion functions when $build is *nix, 3006c63293b5Smrg# and $host is mingw, cygwin, or some other w32 environment. Relies on a 3007c63293b5Smrg# correctly configured wine environment available, with the winepath program 3008c63293b5Smrg# in $build's $PATH. 3009c63293b5Smrg# 3010c63293b5Smrg# ARG is the $build file name to be converted to w32 format. 3011c63293b5Smrg# Result is available in $func_convert_core_file_wine_to_w32_result, and will 3012c63293b5Smrg# be empty on error (or when ARG is empty) 3013c63293b5Smrgfunc_convert_core_file_wine_to_w32 () 3014c63293b5Smrg{ 30159d0ccd10Smrg $debug_cmd 30169d0ccd10Smrg 30179d0ccd10Smrg func_convert_core_file_wine_to_w32_result=$1 3018c63293b5Smrg if test -n "$1"; then 3019c63293b5Smrg # Unfortunately, winepath does not exit with a non-zero error code, so we 3020c63293b5Smrg # are forced to check the contents of stdout. On the other hand, if the 3021c63293b5Smrg # command is not found, the shell will set an exit code of 127 and print 3022c63293b5Smrg # *an error message* to stdout. So we must check for both error code of 3023c63293b5Smrg # zero AND non-empty stdout, which explains the odd construction: 3024c63293b5Smrg func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null` 30259d0ccd10Smrg if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then 3026c63293b5Smrg func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | 30279d0ccd10Smrg $SED -e "$sed_naive_backslashify"` 3028c63293b5Smrg else 3029c63293b5Smrg func_convert_core_file_wine_to_w32_result= 3030c63293b5Smrg fi 3031c63293b5Smrg fi 3032c63293b5Smrg} 3033c63293b5Smrg# end: func_convert_core_file_wine_to_w32 3034c63293b5Smrg 3035c63293b5Smrg 3036c63293b5Smrg# func_convert_core_path_wine_to_w32 ARG 3037c63293b5Smrg# Helper function used by path conversion functions when $build is *nix, and 3038c63293b5Smrg# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly 3039c63293b5Smrg# configured wine environment available, with the winepath program in $build's 3040c63293b5Smrg# $PATH. Assumes ARG has no leading or trailing path separator characters. 3041c63293b5Smrg# 3042c63293b5Smrg# ARG is path to be converted from $build format to win32. 3043c63293b5Smrg# Result is available in $func_convert_core_path_wine_to_w32_result. 3044c63293b5Smrg# Unconvertible file (directory) names in ARG are skipped; if no directory names 3045c63293b5Smrg# are convertible, then the result may be empty. 3046c63293b5Smrgfunc_convert_core_path_wine_to_w32 () 3047c63293b5Smrg{ 30489d0ccd10Smrg $debug_cmd 30499d0ccd10Smrg 3050c63293b5Smrg # unfortunately, winepath doesn't convert paths, only file names 30519d0ccd10Smrg func_convert_core_path_wine_to_w32_result= 3052c63293b5Smrg if test -n "$1"; then 3053c63293b5Smrg oldIFS=$IFS 3054c63293b5Smrg IFS=: 3055c63293b5Smrg for func_convert_core_path_wine_to_w32_f in $1; do 3056c63293b5Smrg IFS=$oldIFS 3057c63293b5Smrg func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" 30589d0ccd10Smrg if test -n "$func_convert_core_file_wine_to_w32_result"; then 3059c63293b5Smrg if test -z "$func_convert_core_path_wine_to_w32_result"; then 30609d0ccd10Smrg func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result 3061c63293b5Smrg else 3062c63293b5Smrg func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" 3063c63293b5Smrg fi 3064c63293b5Smrg fi 3065c63293b5Smrg done 3066c63293b5Smrg IFS=$oldIFS 3067c63293b5Smrg fi 3068c63293b5Smrg} 3069c63293b5Smrg# end: func_convert_core_path_wine_to_w32 3070c63293b5Smrg 3071c63293b5Smrg 3072c63293b5Smrg# func_cygpath ARGS... 3073c63293b5Smrg# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when 3074c63293b5Smrg# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) 3075c63293b5Smrg# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or 3076c63293b5Smrg# (2), returns the Cygwin file name or path in func_cygpath_result (input 3077c63293b5Smrg# file name or path is assumed to be in w32 format, as previously converted 3078c63293b5Smrg# from $build's *nix or MSYS format). In case (3), returns the w32 file name 3079c63293b5Smrg# or path in func_cygpath_result (input file name or path is assumed to be in 3080c63293b5Smrg# Cygwin format). Returns an empty string on error. 3081c63293b5Smrg# 3082c63293b5Smrg# ARGS are passed to cygpath, with the last one being the file name or path to 3083c63293b5Smrg# be converted. 3084c63293b5Smrg# 3085c63293b5Smrg# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH 3086c63293b5Smrg# environment variable; do not put it in $PATH. 3087c63293b5Smrgfunc_cygpath () 3088c63293b5Smrg{ 30899d0ccd10Smrg $debug_cmd 30909d0ccd10Smrg 3091c63293b5Smrg if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then 3092c63293b5Smrg func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` 3093c63293b5Smrg if test "$?" -ne 0; then 3094c63293b5Smrg # on failure, ensure result is empty 3095c63293b5Smrg func_cygpath_result= 3096c63293b5Smrg fi 3097c63293b5Smrg else 3098c63293b5Smrg func_cygpath_result= 30999d0ccd10Smrg func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'" 3100c63293b5Smrg fi 3101c63293b5Smrg} 3102c63293b5Smrg#end: func_cygpath 3103c63293b5Smrg 3104c63293b5Smrg 3105c63293b5Smrg# func_convert_core_msys_to_w32 ARG 3106c63293b5Smrg# Convert file name or path ARG from MSYS format to w32 format. Return 3107c63293b5Smrg# result in func_convert_core_msys_to_w32_result. 3108c63293b5Smrgfunc_convert_core_msys_to_w32 () 3109c63293b5Smrg{ 31109d0ccd10Smrg $debug_cmd 31119d0ccd10Smrg 3112c63293b5Smrg # awkward: cmd appends spaces to result 3113c63293b5Smrg func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | 31149d0ccd10Smrg $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"` 3115c63293b5Smrg} 3116c63293b5Smrg#end: func_convert_core_msys_to_w32 3117c63293b5Smrg 3118c63293b5Smrg 3119c63293b5Smrg# func_convert_file_check ARG1 ARG2 3120c63293b5Smrg# Verify that ARG1 (a file name in $build format) was converted to $host 3121c63293b5Smrg# format in ARG2. Otherwise, emit an error message, but continue (resetting 3122c63293b5Smrg# func_to_host_file_result to ARG1). 3123c63293b5Smrgfunc_convert_file_check () 3124c63293b5Smrg{ 31259d0ccd10Smrg $debug_cmd 31269d0ccd10Smrg 31279d0ccd10Smrg if test -z "$2" && test -n "$1"; then 3128c63293b5Smrg func_error "Could not determine host file name corresponding to" 31299d0ccd10Smrg func_error " '$1'" 3130c63293b5Smrg func_error "Continuing, but uninstalled executables may not work." 3131c63293b5Smrg # Fallback: 31329d0ccd10Smrg func_to_host_file_result=$1 3133c63293b5Smrg fi 3134c63293b5Smrg} 3135c63293b5Smrg# end func_convert_file_check 3136c63293b5Smrg 3137c63293b5Smrg 3138c63293b5Smrg# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH 3139c63293b5Smrg# Verify that FROM_PATH (a path in $build format) was converted to $host 3140c63293b5Smrg# format in TO_PATH. Otherwise, emit an error message, but continue, resetting 3141c63293b5Smrg# func_to_host_file_result to a simplistic fallback value (see below). 3142c63293b5Smrgfunc_convert_path_check () 3143c63293b5Smrg{ 31449d0ccd10Smrg $debug_cmd 31459d0ccd10Smrg 3146c63293b5Smrg if test -z "$4" && test -n "$3"; then 3147c63293b5Smrg func_error "Could not determine the host path corresponding to" 31489d0ccd10Smrg func_error " '$3'" 3149c63293b5Smrg func_error "Continuing, but uninstalled executables may not work." 3150c63293b5Smrg # Fallback. This is a deliberately simplistic "conversion" and 3151c63293b5Smrg # should not be "improved". See libtool.info. 3152c63293b5Smrg if test "x$1" != "x$2"; then 3153c63293b5Smrg lt_replace_pathsep_chars="s|$1|$2|g" 3154c63293b5Smrg func_to_host_path_result=`echo "$3" | 3155c63293b5Smrg $SED -e "$lt_replace_pathsep_chars"` 3156c63293b5Smrg else 31579d0ccd10Smrg func_to_host_path_result=$3 3158c63293b5Smrg fi 3159c63293b5Smrg fi 3160c63293b5Smrg} 3161c63293b5Smrg# end func_convert_path_check 3162c63293b5Smrg 3163c63293b5Smrg 3164c63293b5Smrg# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG 3165c63293b5Smrg# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT 3166c63293b5Smrg# and appending REPL if ORIG matches BACKPAT. 3167c63293b5Smrgfunc_convert_path_front_back_pathsep () 3168c63293b5Smrg{ 31699d0ccd10Smrg $debug_cmd 31709d0ccd10Smrg 3171c63293b5Smrg case $4 in 31729d0ccd10Smrg $1 ) func_to_host_path_result=$3$func_to_host_path_result 3173c63293b5Smrg ;; 3174c63293b5Smrg esac 3175c63293b5Smrg case $4 in 3176c63293b5Smrg $2 ) func_append func_to_host_path_result "$3" 3177c63293b5Smrg ;; 3178c63293b5Smrg esac 3179c63293b5Smrg} 3180c63293b5Smrg# end func_convert_path_front_back_pathsep 3181c63293b5Smrg 3182c63293b5Smrg 3183c63293b5Smrg################################################## 3184c63293b5Smrg# $build to $host FILE NAME CONVERSION FUNCTIONS # 3185c63293b5Smrg################################################## 31869d0ccd10Smrg# invoked via '$to_host_file_cmd ARG' 3187c63293b5Smrg# 3188c63293b5Smrg# In each case, ARG is the path to be converted from $build to $host format. 3189c63293b5Smrg# Result will be available in $func_to_host_file_result. 3190c63293b5Smrg 3191c63293b5Smrg 3192c63293b5Smrg# func_to_host_file ARG 3193c63293b5Smrg# Converts the file name ARG from $build format to $host format. Return result 3194c63293b5Smrg# in func_to_host_file_result. 3195c63293b5Smrgfunc_to_host_file () 3196c63293b5Smrg{ 31979d0ccd10Smrg $debug_cmd 31989d0ccd10Smrg 3199c63293b5Smrg $to_host_file_cmd "$1" 3200c63293b5Smrg} 3201c63293b5Smrg# end func_to_host_file 3202c63293b5Smrg 3203c63293b5Smrg 3204c63293b5Smrg# func_to_tool_file ARG LAZY 3205c63293b5Smrg# converts the file name ARG from $build format to toolchain format. Return 3206c63293b5Smrg# result in func_to_tool_file_result. If the conversion in use is listed 3207c63293b5Smrg# in (the comma separated) LAZY, no conversion takes place. 3208c63293b5Smrgfunc_to_tool_file () 3209c63293b5Smrg{ 32109d0ccd10Smrg $debug_cmd 32119d0ccd10Smrg 3212c63293b5Smrg case ,$2, in 3213c63293b5Smrg *,"$to_tool_file_cmd",*) 3214c63293b5Smrg func_to_tool_file_result=$1 3215c63293b5Smrg ;; 3216c63293b5Smrg *) 3217c63293b5Smrg $to_tool_file_cmd "$1" 3218c63293b5Smrg func_to_tool_file_result=$func_to_host_file_result 3219c63293b5Smrg ;; 3220c63293b5Smrg esac 3221c63293b5Smrg} 3222c63293b5Smrg# end func_to_tool_file 3223c63293b5Smrg 3224c63293b5Smrg 3225c63293b5Smrg# func_convert_file_noop ARG 3226c63293b5Smrg# Copy ARG to func_to_host_file_result. 3227c63293b5Smrgfunc_convert_file_noop () 3228c63293b5Smrg{ 32299d0ccd10Smrg func_to_host_file_result=$1 3230c63293b5Smrg} 3231c63293b5Smrg# end func_convert_file_noop 3232c63293b5Smrg 3233c63293b5Smrg 3234c63293b5Smrg# func_convert_file_msys_to_w32 ARG 3235c63293b5Smrg# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic 3236c63293b5Smrg# conversion to w32 is not available inside the cwrapper. Returns result in 3237c63293b5Smrg# func_to_host_file_result. 3238c63293b5Smrgfunc_convert_file_msys_to_w32 () 3239c63293b5Smrg{ 32409d0ccd10Smrg $debug_cmd 32419d0ccd10Smrg 32429d0ccd10Smrg func_to_host_file_result=$1 3243c63293b5Smrg if test -n "$1"; then 3244c63293b5Smrg func_convert_core_msys_to_w32 "$1" 32459d0ccd10Smrg func_to_host_file_result=$func_convert_core_msys_to_w32_result 3246c63293b5Smrg fi 3247c63293b5Smrg func_convert_file_check "$1" "$func_to_host_file_result" 3248c63293b5Smrg} 3249c63293b5Smrg# end func_convert_file_msys_to_w32 3250c63293b5Smrg 3251c63293b5Smrg 3252c63293b5Smrg# func_convert_file_cygwin_to_w32 ARG 3253c63293b5Smrg# Convert file name ARG from Cygwin to w32 format. Returns result in 3254c63293b5Smrg# func_to_host_file_result. 3255c63293b5Smrgfunc_convert_file_cygwin_to_w32 () 3256c63293b5Smrg{ 32579d0ccd10Smrg $debug_cmd 32589d0ccd10Smrg 32599d0ccd10Smrg func_to_host_file_result=$1 3260c63293b5Smrg if test -n "$1"; then 3261c63293b5Smrg # because $build is cygwin, we call "the" cygpath in $PATH; no need to use 3262c63293b5Smrg # LT_CYGPATH in this case. 3263c63293b5Smrg func_to_host_file_result=`cygpath -m "$1"` 3264c63293b5Smrg fi 3265c63293b5Smrg func_convert_file_check "$1" "$func_to_host_file_result" 3266c63293b5Smrg} 3267c63293b5Smrg# end func_convert_file_cygwin_to_w32 3268c63293b5Smrg 3269c63293b5Smrg 3270c63293b5Smrg# func_convert_file_nix_to_w32 ARG 3271c63293b5Smrg# Convert file name ARG from *nix to w32 format. Requires a wine environment 3272c63293b5Smrg# and a working winepath. Returns result in func_to_host_file_result. 3273c63293b5Smrgfunc_convert_file_nix_to_w32 () 3274c63293b5Smrg{ 32759d0ccd10Smrg $debug_cmd 32769d0ccd10Smrg 32779d0ccd10Smrg func_to_host_file_result=$1 3278c63293b5Smrg if test -n "$1"; then 3279c63293b5Smrg func_convert_core_file_wine_to_w32 "$1" 32809d0ccd10Smrg func_to_host_file_result=$func_convert_core_file_wine_to_w32_result 3281c63293b5Smrg fi 3282c63293b5Smrg func_convert_file_check "$1" "$func_to_host_file_result" 3283c63293b5Smrg} 3284c63293b5Smrg# end func_convert_file_nix_to_w32 3285c63293b5Smrg 3286c63293b5Smrg 3287c63293b5Smrg# func_convert_file_msys_to_cygwin ARG 3288c63293b5Smrg# Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 3289c63293b5Smrg# Returns result in func_to_host_file_result. 3290c63293b5Smrgfunc_convert_file_msys_to_cygwin () 3291c63293b5Smrg{ 32929d0ccd10Smrg $debug_cmd 32939d0ccd10Smrg 32949d0ccd10Smrg func_to_host_file_result=$1 3295c63293b5Smrg if test -n "$1"; then 3296c63293b5Smrg func_convert_core_msys_to_w32 "$1" 3297c63293b5Smrg func_cygpath -u "$func_convert_core_msys_to_w32_result" 32989d0ccd10Smrg func_to_host_file_result=$func_cygpath_result 3299c63293b5Smrg fi 3300c63293b5Smrg func_convert_file_check "$1" "$func_to_host_file_result" 3301c63293b5Smrg} 3302c63293b5Smrg# end func_convert_file_msys_to_cygwin 3303c63293b5Smrg 3304c63293b5Smrg 3305c63293b5Smrg# func_convert_file_nix_to_cygwin ARG 3306c63293b5Smrg# Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed 3307c63293b5Smrg# in a wine environment, working winepath, and LT_CYGPATH set. Returns result 3308c63293b5Smrg# in func_to_host_file_result. 3309c63293b5Smrgfunc_convert_file_nix_to_cygwin () 3310c63293b5Smrg{ 33119d0ccd10Smrg $debug_cmd 33129d0ccd10Smrg 33139d0ccd10Smrg func_to_host_file_result=$1 3314c63293b5Smrg if test -n "$1"; then 3315c63293b5Smrg # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. 3316c63293b5Smrg func_convert_core_file_wine_to_w32 "$1" 3317c63293b5Smrg func_cygpath -u "$func_convert_core_file_wine_to_w32_result" 33189d0ccd10Smrg func_to_host_file_result=$func_cygpath_result 3319c63293b5Smrg fi 3320c63293b5Smrg func_convert_file_check "$1" "$func_to_host_file_result" 3321c63293b5Smrg} 3322c63293b5Smrg# end func_convert_file_nix_to_cygwin 3323c63293b5Smrg 3324c63293b5Smrg 3325c63293b5Smrg############################################# 3326c63293b5Smrg# $build to $host PATH CONVERSION FUNCTIONS # 3327c63293b5Smrg############################################# 33289d0ccd10Smrg# invoked via '$to_host_path_cmd ARG' 3329c63293b5Smrg# 3330c63293b5Smrg# In each case, ARG is the path to be converted from $build to $host format. 3331c63293b5Smrg# The result will be available in $func_to_host_path_result. 3332c63293b5Smrg# 3333c63293b5Smrg# Path separators are also converted from $build format to $host format. If 3334c63293b5Smrg# ARG begins or ends with a path separator character, it is preserved (but 3335c63293b5Smrg# converted to $host format) on output. 3336c63293b5Smrg# 3337c63293b5Smrg# All path conversion functions are named using the following convention: 3338c63293b5Smrg# file name conversion function : func_convert_file_X_to_Y () 3339c63293b5Smrg# path conversion function : func_convert_path_X_to_Y () 3340c63293b5Smrg# where, for any given $build/$host combination the 'X_to_Y' value is the 3341c63293b5Smrg# same. If conversion functions are added for new $build/$host combinations, 3342c63293b5Smrg# the two new functions must follow this pattern, or func_init_to_host_path_cmd 3343c63293b5Smrg# will break. 3344c63293b5Smrg 3345c63293b5Smrg 3346c63293b5Smrg# func_init_to_host_path_cmd 3347c63293b5Smrg# Ensures that function "pointer" variable $to_host_path_cmd is set to the 3348c63293b5Smrg# appropriate value, based on the value of $to_host_file_cmd. 3349c63293b5Smrgto_host_path_cmd= 3350c63293b5Smrgfunc_init_to_host_path_cmd () 3351c63293b5Smrg{ 33529d0ccd10Smrg $debug_cmd 33539d0ccd10Smrg 3354c63293b5Smrg if test -z "$to_host_path_cmd"; then 3355c63293b5Smrg func_stripname 'func_convert_file_' '' "$to_host_file_cmd" 33569d0ccd10Smrg to_host_path_cmd=func_convert_path_$func_stripname_result 3357c63293b5Smrg fi 3358c63293b5Smrg} 3359c63293b5Smrg 3360c63293b5Smrg 3361c63293b5Smrg# func_to_host_path ARG 3362c63293b5Smrg# Converts the path ARG from $build format to $host format. Return result 3363c63293b5Smrg# in func_to_host_path_result. 3364c63293b5Smrgfunc_to_host_path () 3365c63293b5Smrg{ 33669d0ccd10Smrg $debug_cmd 33679d0ccd10Smrg 3368c63293b5Smrg func_init_to_host_path_cmd 3369c63293b5Smrg $to_host_path_cmd "$1" 3370c63293b5Smrg} 3371c63293b5Smrg# end func_to_host_path 3372c63293b5Smrg 3373c63293b5Smrg 3374c63293b5Smrg# func_convert_path_noop ARG 3375c63293b5Smrg# Copy ARG to func_to_host_path_result. 3376c63293b5Smrgfunc_convert_path_noop () 3377c63293b5Smrg{ 33789d0ccd10Smrg func_to_host_path_result=$1 3379c63293b5Smrg} 3380c63293b5Smrg# end func_convert_path_noop 3381c63293b5Smrg 3382c63293b5Smrg 3383c63293b5Smrg# func_convert_path_msys_to_w32 ARG 3384c63293b5Smrg# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic 3385c63293b5Smrg# conversion to w32 is not available inside the cwrapper. Returns result in 3386c63293b5Smrg# func_to_host_path_result. 3387c63293b5Smrgfunc_convert_path_msys_to_w32 () 3388e169010aSmrg{ 33899d0ccd10Smrg $debug_cmd 33909d0ccd10Smrg 33919d0ccd10Smrg func_to_host_path_result=$1 3392c63293b5Smrg if test -n "$1"; then 3393c63293b5Smrg # Remove leading and trailing path separator characters from ARG. MSYS 3394c63293b5Smrg # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; 3395c63293b5Smrg # and winepath ignores them completely. 3396c63293b5Smrg func_stripname : : "$1" 3397c63293b5Smrg func_to_host_path_tmp1=$func_stripname_result 3398c63293b5Smrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 33999d0ccd10Smrg func_to_host_path_result=$func_convert_core_msys_to_w32_result 3400c63293b5Smrg func_convert_path_check : ";" \ 3401c63293b5Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3402c63293b5Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 3403c63293b5Smrg fi 3404c63293b5Smrg} 3405c63293b5Smrg# end func_convert_path_msys_to_w32 3406e169010aSmrg 3407e169010aSmrg 3408c63293b5Smrg# func_convert_path_cygwin_to_w32 ARG 3409c63293b5Smrg# Convert path ARG from Cygwin to w32 format. Returns result in 3410c63293b5Smrg# func_to_host_file_result. 3411c63293b5Smrgfunc_convert_path_cygwin_to_w32 () 3412c63293b5Smrg{ 34139d0ccd10Smrg $debug_cmd 34149d0ccd10Smrg 34159d0ccd10Smrg func_to_host_path_result=$1 3416c63293b5Smrg if test -n "$1"; then 3417c63293b5Smrg # See func_convert_path_msys_to_w32: 3418c63293b5Smrg func_stripname : : "$1" 3419c63293b5Smrg func_to_host_path_tmp1=$func_stripname_result 3420c63293b5Smrg func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` 3421c63293b5Smrg func_convert_path_check : ";" \ 3422c63293b5Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3423c63293b5Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 3424c63293b5Smrg fi 3425c63293b5Smrg} 3426c63293b5Smrg# end func_convert_path_cygwin_to_w32 3427e169010aSmrg 3428e169010aSmrg 3429c63293b5Smrg# func_convert_path_nix_to_w32 ARG 3430c63293b5Smrg# Convert path ARG from *nix to w32 format. Requires a wine environment and 3431c63293b5Smrg# a working winepath. Returns result in func_to_host_file_result. 3432c63293b5Smrgfunc_convert_path_nix_to_w32 () 3433c63293b5Smrg{ 34349d0ccd10Smrg $debug_cmd 34359d0ccd10Smrg 34369d0ccd10Smrg func_to_host_path_result=$1 3437c63293b5Smrg if test -n "$1"; then 3438c63293b5Smrg # See func_convert_path_msys_to_w32: 3439c63293b5Smrg func_stripname : : "$1" 3440c63293b5Smrg func_to_host_path_tmp1=$func_stripname_result 3441c63293b5Smrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 34429d0ccd10Smrg func_to_host_path_result=$func_convert_core_path_wine_to_w32_result 3443c63293b5Smrg func_convert_path_check : ";" \ 3444c63293b5Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3445c63293b5Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 3446c63293b5Smrg fi 3447c63293b5Smrg} 3448c63293b5Smrg# end func_convert_path_nix_to_w32 3449e169010aSmrg 3450c63293b5Smrg 3451c63293b5Smrg# func_convert_path_msys_to_cygwin ARG 3452c63293b5Smrg# Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 3453c63293b5Smrg# Returns result in func_to_host_file_result. 3454c63293b5Smrgfunc_convert_path_msys_to_cygwin () 3455c63293b5Smrg{ 34569d0ccd10Smrg $debug_cmd 34579d0ccd10Smrg 34589d0ccd10Smrg func_to_host_path_result=$1 3459c63293b5Smrg if test -n "$1"; then 3460c63293b5Smrg # See func_convert_path_msys_to_w32: 3461c63293b5Smrg func_stripname : : "$1" 3462c63293b5Smrg func_to_host_path_tmp1=$func_stripname_result 3463c63293b5Smrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 3464c63293b5Smrg func_cygpath -u -p "$func_convert_core_msys_to_w32_result" 34659d0ccd10Smrg func_to_host_path_result=$func_cygpath_result 3466c63293b5Smrg func_convert_path_check : : \ 3467c63293b5Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3468c63293b5Smrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 3469c63293b5Smrg fi 3470c63293b5Smrg} 3471c63293b5Smrg# end func_convert_path_msys_to_cygwin 3472c63293b5Smrg 3473c63293b5Smrg 3474c63293b5Smrg# func_convert_path_nix_to_cygwin ARG 3475c63293b5Smrg# Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a 3476c63293b5Smrg# a wine environment, working winepath, and LT_CYGPATH set. Returns result in 3477c63293b5Smrg# func_to_host_file_result. 3478c63293b5Smrgfunc_convert_path_nix_to_cygwin () 3479c63293b5Smrg{ 34809d0ccd10Smrg $debug_cmd 34819d0ccd10Smrg 34829d0ccd10Smrg func_to_host_path_result=$1 3483c63293b5Smrg if test -n "$1"; then 3484c63293b5Smrg # Remove leading and trailing path separator characters from 3485c63293b5Smrg # ARG. msys behavior is inconsistent here, cygpath turns them 3486c63293b5Smrg # into '.;' and ';.', and winepath ignores them completely. 3487c63293b5Smrg func_stripname : : "$1" 3488c63293b5Smrg func_to_host_path_tmp1=$func_stripname_result 3489c63293b5Smrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 3490c63293b5Smrg func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" 34919d0ccd10Smrg func_to_host_path_result=$func_cygpath_result 3492c63293b5Smrg func_convert_path_check : : \ 3493c63293b5Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3494c63293b5Smrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 3495c63293b5Smrg fi 3496e169010aSmrg} 3497c63293b5Smrg# end func_convert_path_nix_to_cygwin 3498c63293b5Smrg 3499e169010aSmrg 35009d0ccd10Smrg# func_dll_def_p FILE 35019d0ccd10Smrg# True iff FILE is a Windows DLL '.def' file. 35029d0ccd10Smrg# Keep in sync with _LT_DLL_DEF_P in libtool.m4 35039d0ccd10Smrgfunc_dll_def_p () 35049d0ccd10Smrg{ 35059d0ccd10Smrg $debug_cmd 35069d0ccd10Smrg 35079d0ccd10Smrg func_dll_def_p_tmp=`$SED -n \ 35089d0ccd10Smrg -e 's/^[ ]*//' \ 35099d0ccd10Smrg -e '/^\(;.*\)*$/d' \ 35109d0ccd10Smrg -e 's/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p' \ 35119d0ccd10Smrg -e q \ 35129d0ccd10Smrg "$1"` 35139d0ccd10Smrg test DEF = "$func_dll_def_p_tmp" 35149d0ccd10Smrg} 35159d0ccd10Smrg 35169d0ccd10Smrg 3517e169010aSmrg# func_mode_compile arg... 3518e169010aSmrgfunc_mode_compile () 3519e169010aSmrg{ 35209d0ccd10Smrg $debug_cmd 35219d0ccd10Smrg 3522e169010aSmrg # Get the compilation command and the source file. 3523e169010aSmrg base_compile= 35249d0ccd10Smrg srcfile=$nonopt # always keep a non-empty value in "srcfile" 3525e169010aSmrg suppress_opt=yes 3526e169010aSmrg suppress_output= 3527e169010aSmrg arg_mode=normal 3528e169010aSmrg libobj= 3529e169010aSmrg later= 3530e169010aSmrg pie_flag= 3531e169010aSmrg 3532e169010aSmrg for arg 3533e169010aSmrg do 3534e169010aSmrg case $arg_mode in 3535e169010aSmrg arg ) 3536e169010aSmrg # do not "continue". Instead, add this to base_compile 35379d0ccd10Smrg lastarg=$arg 3538e169010aSmrg arg_mode=normal 3539e169010aSmrg ;; 3540e169010aSmrg 3541e169010aSmrg target ) 35429d0ccd10Smrg libobj=$arg 3543e169010aSmrg arg_mode=normal 3544e169010aSmrg continue 3545e169010aSmrg ;; 3546e169010aSmrg 3547e169010aSmrg normal ) 3548e169010aSmrg # Accept any command-line options. 3549e169010aSmrg case $arg in 3550e169010aSmrg -o) 3551e169010aSmrg test -n "$libobj" && \ 35529d0ccd10Smrg func_fatal_error "you cannot specify '-o' more than once" 3553e169010aSmrg arg_mode=target 3554e169010aSmrg continue 3555e169010aSmrg ;; 3556e169010aSmrg 3557e169010aSmrg -pie | -fpie | -fPIE) 3558c63293b5Smrg func_append pie_flag " $arg" 3559e169010aSmrg continue 3560e169010aSmrg ;; 3561e169010aSmrg 3562e169010aSmrg -shared | -static | -prefer-pic | -prefer-non-pic) 3563c63293b5Smrg func_append later " $arg" 3564e169010aSmrg continue 3565e169010aSmrg ;; 3566e169010aSmrg 3567e169010aSmrg -no-suppress) 3568e169010aSmrg suppress_opt=no 3569e169010aSmrg continue 3570e169010aSmrg ;; 3571e169010aSmrg 3572e169010aSmrg -Xcompiler) 3573e169010aSmrg arg_mode=arg # the next one goes into the "base_compile" arg list 3574e169010aSmrg continue # The current "srcfile" will either be retained or 3575e169010aSmrg ;; # replaced later. I would guess that would be a bug. 3576e169010aSmrg 3577e169010aSmrg -Wc,*) 3578e169010aSmrg func_stripname '-Wc,' '' "$arg" 3579e169010aSmrg args=$func_stripname_result 3580e169010aSmrg lastarg= 35819d0ccd10Smrg save_ifs=$IFS; IFS=, 3582e169010aSmrg for arg in $args; do 35839d0ccd10Smrg IFS=$save_ifs 3584c63293b5Smrg func_append_quoted lastarg "$arg" 35857914d74bSmrg done 35869d0ccd10Smrg IFS=$save_ifs 3587e169010aSmrg func_stripname ' ' '' "$lastarg" 3588e169010aSmrg lastarg=$func_stripname_result 35897914d74bSmrg 35907914d74bSmrg # Add the arguments to base_compile. 3591c63293b5Smrg func_append base_compile " $lastarg" 35927914d74bSmrg continue 35937914d74bSmrg ;; 35947914d74bSmrg 3595e169010aSmrg *) 35967914d74bSmrg # Accept the current argument as the source file. 35977914d74bSmrg # The previous "srcfile" becomes the current argument. 35987914d74bSmrg # 35999d0ccd10Smrg lastarg=$srcfile 36009d0ccd10Smrg srcfile=$arg 36017914d74bSmrg ;; 36027914d74bSmrg esac # case $arg 36037914d74bSmrg ;; 36047914d74bSmrg esac # case $arg_mode 36057914d74bSmrg 36067914d74bSmrg # Aesthetically quote the previous argument. 3607c63293b5Smrg func_append_quoted base_compile "$lastarg" 36087914d74bSmrg done # for arg 36097914d74bSmrg 36107914d74bSmrg case $arg_mode in 36117914d74bSmrg arg) 3612e169010aSmrg func_fatal_error "you must specify an argument for -Xcompile" 36137914d74bSmrg ;; 36147914d74bSmrg target) 36159d0ccd10Smrg func_fatal_error "you must specify a target with '-o'" 36167914d74bSmrg ;; 36177914d74bSmrg *) 36187914d74bSmrg # Get the name of the library object. 3619e169010aSmrg test -z "$libobj" && { 3620e169010aSmrg func_basename "$srcfile" 36219d0ccd10Smrg libobj=$func_basename_result 3622e169010aSmrg } 36237914d74bSmrg ;; 36247914d74bSmrg esac 36257914d74bSmrg 36267914d74bSmrg # Recognize several different file suffixes. 36277914d74bSmrg # If the user specifies -o file.o, it is replaced with file.lo 36287914d74bSmrg case $libobj in 3629e169010aSmrg *.[cCFSifmso] | \ 3630e169010aSmrg *.ada | *.adb | *.ads | *.asm | \ 3631e169010aSmrg *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ 3632e6d5e4e0Smrg *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup) 3633e169010aSmrg func_xform "$libobj" 3634e169010aSmrg libobj=$func_xform_result 3635e169010aSmrg ;; 36367914d74bSmrg esac 36377914d74bSmrg 36387914d74bSmrg case $libobj in 3639e169010aSmrg *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; 36407914d74bSmrg *) 36419d0ccd10Smrg func_fatal_error "cannot determine name of library object from '$libobj'" 36427914d74bSmrg ;; 36437914d74bSmrg esac 36447914d74bSmrg 36457914d74bSmrg func_infer_tag $base_compile 36467914d74bSmrg 36477914d74bSmrg for arg in $later; do 36487914d74bSmrg case $arg in 3649e169010aSmrg -shared) 36509d0ccd10Smrg test yes = "$build_libtool_libs" \ 36519d0ccd10Smrg || func_fatal_configuration "cannot build a shared library" 3652e169010aSmrg build_old_libs=no 3653e169010aSmrg continue 3654e169010aSmrg ;; 3655e169010aSmrg 36567914d74bSmrg -static) 3657e169010aSmrg build_libtool_libs=no 36587914d74bSmrg build_old_libs=yes 36597914d74bSmrg continue 36607914d74bSmrg ;; 36617914d74bSmrg 36627914d74bSmrg -prefer-pic) 36637914d74bSmrg pic_mode=yes 36647914d74bSmrg continue 36657914d74bSmrg ;; 36667914d74bSmrg 36677914d74bSmrg -prefer-non-pic) 36687914d74bSmrg pic_mode=no 36697914d74bSmrg continue 36707914d74bSmrg ;; 36717914d74bSmrg esac 36727914d74bSmrg done 36737914d74bSmrg 36740ea508b1Smrg func_quote_arg pretty "$libobj" 36750ea508b1Smrg test "X$libobj" != "X$func_quote_arg_result" \ 3676e169010aSmrg && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ 36779d0ccd10Smrg && func_warning "libobj name '$libobj' may not contain shell special characters." 3678e169010aSmrg func_dirname_and_basename "$obj" "/" "" 36799d0ccd10Smrg objname=$func_basename_result 36809d0ccd10Smrg xdir=$func_dirname_result 36819d0ccd10Smrg lobj=$xdir$objdir/$objname 36827914d74bSmrg 3683e169010aSmrg test -z "$base_compile" && \ 3684e169010aSmrg func_fatal_help "you must specify a compilation command" 36857914d74bSmrg 36867914d74bSmrg # Delete any leftover library objects. 36879d0ccd10Smrg if test yes = "$build_old_libs"; then 36887914d74bSmrg removelist="$obj $lobj $libobj ${libobj}T" 36897914d74bSmrg else 36907914d74bSmrg removelist="$lobj $libobj ${libobj}T" 36917914d74bSmrg fi 36927914d74bSmrg 36937914d74bSmrg # On Cygwin there's no "real" PIC flag so we must build both object types 36947914d74bSmrg case $host_os in 3695e169010aSmrg cygwin* | mingw* | pw32* | os2* | cegcc*) 36967914d74bSmrg pic_mode=default 36977914d74bSmrg ;; 36987914d74bSmrg esac 36999d0ccd10Smrg if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then 37007914d74bSmrg # non-PIC code in shared libraries is not supported 37017914d74bSmrg pic_mode=default 37027914d74bSmrg fi 37037914d74bSmrg 37047914d74bSmrg # Calculate the filename of the output object if compiler does 37057914d74bSmrg # not support -o with -c 37069d0ccd10Smrg if test no = "$compiler_c_o"; then 37079d0ccd10Smrg output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext 37089d0ccd10Smrg lockfile=$output_obj.lock 37097914d74bSmrg else 37107914d74bSmrg output_obj= 37117914d74bSmrg need_locks=no 37127914d74bSmrg lockfile= 37137914d74bSmrg fi 37147914d74bSmrg 37157914d74bSmrg # Lock this critical section if it is needed 37167914d74bSmrg # We use this script file to make the link, it avoids creating a new file 37179d0ccd10Smrg if test yes = "$need_locks"; then 3718e169010aSmrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 3719e169010aSmrg func_echo "Waiting for $lockfile to be removed" 37207914d74bSmrg sleep 2 37217914d74bSmrg done 37229d0ccd10Smrg elif test warn = "$need_locks"; then 37237914d74bSmrg if test -f "$lockfile"; then 3724e169010aSmrg $ECHO "\ 37257914d74bSmrg*** ERROR, $lockfile exists and contains: 37267914d74bSmrg`cat $lockfile 2>/dev/null` 37277914d74bSmrg 37287914d74bSmrgThis indicates that another process is trying to use the same 37297914d74bSmrgtemporary object file, and libtool could not work around it because 37309d0ccd10Smrgyour compiler does not support '-c' and '-o' together. If you 37317914d74bSmrgrepeat this compilation, it may succeed, by chance, but you had better 37327914d74bSmrgavoid parallel builds (make -j) in this platform, or get a better 37337914d74bSmrgcompiler." 37347914d74bSmrg 3735e169010aSmrg $opt_dry_run || $RM $removelist 37367914d74bSmrg exit $EXIT_FAILURE 37377914d74bSmrg fi 3738c63293b5Smrg func_append removelist " $output_obj" 3739e169010aSmrg $ECHO "$srcfile" > "$lockfile" 37407914d74bSmrg fi 37417914d74bSmrg 3742e169010aSmrg $opt_dry_run || $RM $removelist 3743c63293b5Smrg func_append removelist " $lockfile" 3744e169010aSmrg trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 3745e169010aSmrg 3746c63293b5Smrg func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 3747c63293b5Smrg srcfile=$func_to_tool_file_result 37480ea508b1Smrg func_quote_arg pretty "$srcfile" 37490ea508b1Smrg qsrcfile=$func_quote_arg_result 37507914d74bSmrg 37517914d74bSmrg # Only build a PIC object if we are building libtool libraries. 37529d0ccd10Smrg if test yes = "$build_libtool_libs"; then 37537914d74bSmrg # Without this assignment, base_compile gets emptied. 37547914d74bSmrg fbsd_hideous_sh_bug=$base_compile 37557914d74bSmrg 37569d0ccd10Smrg if test no != "$pic_mode"; then 37577914d74bSmrg command="$base_compile $qsrcfile $pic_flag" 37587914d74bSmrg else 37597914d74bSmrg # Don't build PIC code 37607914d74bSmrg command="$base_compile $qsrcfile" 37617914d74bSmrg fi 37627914d74bSmrg 3763e169010aSmrg func_mkdir_p "$xdir$objdir" 37647914d74bSmrg 37657914d74bSmrg if test -z "$output_obj"; then 37667914d74bSmrg # Place PIC objects in $objdir 3767c63293b5Smrg func_append command " -o $lobj" 37687914d74bSmrg fi 37697914d74bSmrg 3770e169010aSmrg func_show_eval_locale "$command" \ 3771e169010aSmrg 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' 37727914d74bSmrg 37739d0ccd10Smrg if test warn = "$need_locks" && 37747914d74bSmrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 3775e169010aSmrg $ECHO "\ 37767914d74bSmrg*** ERROR, $lockfile contains: 37777914d74bSmrg`cat $lockfile 2>/dev/null` 37787914d74bSmrg 37797914d74bSmrgbut it should contain: 37807914d74bSmrg$srcfile 37817914d74bSmrg 37827914d74bSmrgThis indicates that another process is trying to use the same 37837914d74bSmrgtemporary object file, and libtool could not work around it because 37849d0ccd10Smrgyour compiler does not support '-c' and '-o' together. If you 37857914d74bSmrgrepeat this compilation, it may succeed, by chance, but you had better 37867914d74bSmrgavoid parallel builds (make -j) in this platform, or get a better 37877914d74bSmrgcompiler." 37887914d74bSmrg 3789e169010aSmrg $opt_dry_run || $RM $removelist 37907914d74bSmrg exit $EXIT_FAILURE 37917914d74bSmrg fi 37927914d74bSmrg 37937914d74bSmrg # Just move the object if needed, then go on to compile the next one 37947914d74bSmrg if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then 3795e169010aSmrg func_show_eval '$MV "$output_obj" "$lobj"' \ 3796e169010aSmrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 37977914d74bSmrg fi 37987914d74bSmrg 37997914d74bSmrg # Allow error messages only from the first compilation. 38009d0ccd10Smrg if test yes = "$suppress_opt"; then 3801e169010aSmrg suppress_output=' >/dev/null 2>&1' 38027914d74bSmrg fi 38037914d74bSmrg fi 38047914d74bSmrg 38057914d74bSmrg # Only build a position-dependent object if we build old libraries. 38069d0ccd10Smrg if test yes = "$build_old_libs"; then 38079d0ccd10Smrg if test yes != "$pic_mode"; then 38087914d74bSmrg # Don't build PIC code 3809e169010aSmrg command="$base_compile $qsrcfile$pie_flag" 38107914d74bSmrg else 38117914d74bSmrg command="$base_compile $qsrcfile $pic_flag" 38127914d74bSmrg fi 38139d0ccd10Smrg if test yes = "$compiler_c_o"; then 3814c63293b5Smrg func_append command " -o $obj" 38157914d74bSmrg fi 38167914d74bSmrg 38177914d74bSmrg # Suppress compiler output if we already did a PIC compilation. 3818c63293b5Smrg func_append command "$suppress_output" 3819e169010aSmrg func_show_eval_locale "$command" \ 3820e169010aSmrg '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 38217914d74bSmrg 38229d0ccd10Smrg if test warn = "$need_locks" && 38237914d74bSmrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 3824e169010aSmrg $ECHO "\ 38257914d74bSmrg*** ERROR, $lockfile contains: 38267914d74bSmrg`cat $lockfile 2>/dev/null` 38277914d74bSmrg 38287914d74bSmrgbut it should contain: 38297914d74bSmrg$srcfile 38307914d74bSmrg 38317914d74bSmrgThis indicates that another process is trying to use the same 38327914d74bSmrgtemporary object file, and libtool could not work around it because 38339d0ccd10Smrgyour compiler does not support '-c' and '-o' together. If you 38347914d74bSmrgrepeat this compilation, it may succeed, by chance, but you had better 38357914d74bSmrgavoid parallel builds (make -j) in this platform, or get a better 38367914d74bSmrgcompiler." 38377914d74bSmrg 3838e169010aSmrg $opt_dry_run || $RM $removelist 38397914d74bSmrg exit $EXIT_FAILURE 38407914d74bSmrg fi 38417914d74bSmrg 38427914d74bSmrg # Just move the object if needed 38437914d74bSmrg if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then 3844e169010aSmrg func_show_eval '$MV "$output_obj" "$obj"' \ 3845e169010aSmrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 38467914d74bSmrg fi 38477914d74bSmrg fi 38487914d74bSmrg 3849e169010aSmrg $opt_dry_run || { 3850e169010aSmrg func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" 38517914d74bSmrg 3852e169010aSmrg # Unlock the critical section if it was locked 38539d0ccd10Smrg if test no != "$need_locks"; then 3854e169010aSmrg removelist=$lockfile 3855e169010aSmrg $RM "$lockfile" 3856e169010aSmrg fi 3857e169010aSmrg } 38587914d74bSmrg 38597914d74bSmrg exit $EXIT_SUCCESS 3860e169010aSmrg} 38617914d74bSmrg 3862e169010aSmrg$opt_help || { 38639d0ccd10Smrg test compile = "$opt_mode" && func_mode_compile ${1+"$@"} 3864e169010aSmrg} 38657914d74bSmrg 3866e169010aSmrgfunc_mode_help () 3867e169010aSmrg{ 3868e169010aSmrg # We need to display help for each of the modes. 3869c63293b5Smrg case $opt_mode in 3870e169010aSmrg "") 3871e169010aSmrg # Generic help is extracted from the usage comments 3872e169010aSmrg # at the start of this file. 3873e169010aSmrg func_help 3874e169010aSmrg ;; 38757914d74bSmrg 3876e169010aSmrg clean) 3877e169010aSmrg $ECHO \ 3878e169010aSmrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... 38797914d74bSmrg 3880e169010aSmrgRemove files from the build directory. 38817914d74bSmrg 3882e169010aSmrgRM is the name of the program to use to delete files associated with each FILE 38839d0ccd10Smrg(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 3884e169010aSmrgto RM. 38857914d74bSmrg 3886e169010aSmrgIf FILE is a libtool library, object or program, all the files associated 3887e169010aSmrgwith it are deleted. Otherwise, only FILE itself is deleted using RM." 3888e169010aSmrg ;; 38897914d74bSmrg 3890e169010aSmrg compile) 3891e169010aSmrg $ECHO \ 3892e169010aSmrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE 38937914d74bSmrg 3894e169010aSmrgCompile a source file into a libtool library object. 38957914d74bSmrg 3896e169010aSmrgThis mode accepts the following additional options: 38977914d74bSmrg 3898e169010aSmrg -o OUTPUT-FILE set the output file name to OUTPUT-FILE 3899e169010aSmrg -no-suppress do not suppress compiler output for multiple passes 3900e8ead290Smrg -prefer-pic try to build PIC objects only 3901e8ead290Smrg -prefer-non-pic try to build non-PIC objects only 39029d0ccd10Smrg -shared do not build a '.o' file suitable for static linking 39039d0ccd10Smrg -static only build a '.o' file suitable for static linking 39040ea508b1Smrg -Wc,FLAG 39050ea508b1Smrg -Xcompiler FLAG pass FLAG directly to the compiler 39067914d74bSmrg 39079d0ccd10SmrgCOMPILE-COMMAND is a command to be used in creating a 'standard' object file 3908e169010aSmrgfrom the given SOURCEFILE. 39097914d74bSmrg 3910e169010aSmrgThe output file name is determined by removing the directory component from 39119d0ccd10SmrgSOURCEFILE, then substituting the C source code suffix '.c' with the 39129d0ccd10Smrglibrary object suffix, '.lo'." 3913e169010aSmrg ;; 39147914d74bSmrg 3915e169010aSmrg execute) 3916e169010aSmrg $ECHO \ 3917e169010aSmrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... 39187914d74bSmrg 3919e169010aSmrgAutomatically set library path, then run a program. 39207914d74bSmrg 3921e169010aSmrgThis mode accepts the following additional options: 39227914d74bSmrg 3923e169010aSmrg -dlopen FILE add the directory containing FILE to the library path 39247914d74bSmrg 39259d0ccd10SmrgThis mode sets the library path environment variable according to '-dlopen' 3926e169010aSmrgflags. 39277914d74bSmrg 3928e169010aSmrgIf any of the ARGS are libtool executable wrappers, then they are translated 3929e169010aSmrginto their corresponding uninstalled binary, and any of their required library 3930e169010aSmrgdirectories are added to the library path. 39317914d74bSmrg 3932e169010aSmrgThen, COMMAND is executed, with ARGS as arguments." 3933e169010aSmrg ;; 39347914d74bSmrg 3935e169010aSmrg finish) 3936e169010aSmrg $ECHO \ 3937e169010aSmrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]... 39387914d74bSmrg 3939e169010aSmrgComplete the installation of libtool libraries. 39407914d74bSmrg 3941e169010aSmrgEach LIBDIR is a directory that contains libtool libraries. 39427914d74bSmrg 3943e169010aSmrgThe commands that this mode executes may require superuser privileges. Use 39449d0ccd10Smrgthe '--dry-run' option if you just want to see what would be executed." 3945e169010aSmrg ;; 39467914d74bSmrg 3947e169010aSmrg install) 3948e169010aSmrg $ECHO \ 3949e169010aSmrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... 39507914d74bSmrg 3951e169010aSmrgInstall executables or libraries. 39527914d74bSmrg 3953e169010aSmrgINSTALL-COMMAND is the installation command. The first component should be 39549d0ccd10Smrgeither the 'install' or 'cp' program. 39557914d74bSmrg 3956e169010aSmrgThe following components of INSTALL-COMMAND are treated specially: 39577914d74bSmrg 3958e8ead290Smrg -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation 39597914d74bSmrg 3960e169010aSmrgThe rest of the components are interpreted as arguments to that command (only 3961e169010aSmrgBSD-compatible install options are recognized)." 3962e169010aSmrg ;; 39637914d74bSmrg 3964e169010aSmrg link) 3965e169010aSmrg $ECHO \ 3966e169010aSmrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND... 39677914d74bSmrg 3968e169010aSmrgLink object files or libraries together to form another library, or to 3969e169010aSmrgcreate an executable program. 39707914d74bSmrg 3971e169010aSmrgLINK-COMMAND is a command using the C compiler that you would use to create 3972e169010aSmrga program from several object files. 39737914d74bSmrg 3974e169010aSmrgThe following components of LINK-COMMAND are treated specially: 39757914d74bSmrg 3976e169010aSmrg -all-static do not do any dynamic linking at all 3977e169010aSmrg -avoid-version do not add a version suffix if possible 3978e8ead290Smrg -bindir BINDIR specify path to binaries directory (for systems where 3979e8ead290Smrg libraries must be found in the PATH setting at runtime) 39809d0ccd10Smrg -dlopen FILE '-dlpreopen' FILE if it cannot be dlopened at runtime 3981e169010aSmrg -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols 3982e169010aSmrg -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) 3983e169010aSmrg -export-symbols SYMFILE 3984e169010aSmrg try to export only the symbols listed in SYMFILE 3985e169010aSmrg -export-symbols-regex REGEX 3986e169010aSmrg try to export only the symbols matching REGEX 3987e169010aSmrg -LLIBDIR search LIBDIR for required installed libraries 3988e169010aSmrg -lNAME OUTPUT-FILE requires the installed library libNAME 3989e169010aSmrg -module build a library that can dlopened 3990e169010aSmrg -no-fast-install disable the fast-install mode 3991e169010aSmrg -no-install link a not-installable executable 3992e169010aSmrg -no-undefined declare that a library does not refer to external symbols 3993e169010aSmrg -o OUTPUT-FILE create OUTPUT-FILE from the specified objects 39949d0ccd10Smrg -objectlist FILE use a list of object files found in FILE to specify objects 39959d0ccd10Smrg -os2dllname NAME force a short DLL name on OS/2 (no effect on other OSes) 3996e169010aSmrg -precious-files-regex REGEX 3997e169010aSmrg don't remove output files matching REGEX 3998e169010aSmrg -release RELEASE specify package release information 3999e169010aSmrg -rpath LIBDIR the created library will eventually be installed in LIBDIR 4000e169010aSmrg -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries 4001e169010aSmrg -shared only do dynamic linking of libtool libraries 4002e169010aSmrg -shrext SUFFIX override the standard shared library file extension 4003e169010aSmrg -static do not do any dynamic linking of uninstalled libtool libraries 4004e169010aSmrg -static-libtool-libs 4005e169010aSmrg do not do any dynamic linking of libtool libraries 4006e169010aSmrg -version-info CURRENT[:REVISION[:AGE]] 4007e169010aSmrg specify library version info [each variable defaults to 0] 4008e169010aSmrg -weak LIBNAME declare that the target provides the LIBNAME interface 4009e8ead290Smrg -Wc,FLAG 4010e8ead290Smrg -Xcompiler FLAG pass linker-specific FLAG directly to the compiler 40110ea508b1Smrg -Wa,FLAG 40120ea508b1Smrg -Xassembler FLAG pass linker-specific FLAG directly to the assembler 4013e8ead290Smrg -Wl,FLAG 4014e8ead290Smrg -Xlinker FLAG pass linker-specific FLAG directly to the linker 4015e8ead290Smrg -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) 40167914d74bSmrg 40179d0ccd10SmrgAll other options (arguments beginning with '-') are ignored. 40187914d74bSmrg 40199d0ccd10SmrgEvery other argument is treated as a filename. Files ending in '.la' are 4020e169010aSmrgtreated as uninstalled libtool libraries, other files are standard or library 4021e169010aSmrgobject files. 40227914d74bSmrg 40239d0ccd10SmrgIf the OUTPUT-FILE ends in '.la', then a libtool library is created, 40249d0ccd10Smrgonly library objects ('.lo' files) may be specified, and '-rpath' is 4025e169010aSmrgrequired, except when creating a convenience library. 40267914d74bSmrg 40279d0ccd10SmrgIf OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created 40289d0ccd10Smrgusing 'ar' and 'ranlib', or on Windows using 'lib'. 40297914d74bSmrg 40309d0ccd10SmrgIf OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file 4031e169010aSmrgis created, otherwise an executable program is created." 40327914d74bSmrg ;; 40337914d74bSmrg 4034e169010aSmrg uninstall) 4035e169010aSmrg $ECHO \ 4036e169010aSmrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... 40377914d74bSmrg 4038e169010aSmrgRemove libraries from an installation directory. 40397914d74bSmrg 4040e169010aSmrgRM is the name of the program to use to delete files associated with each FILE 40419d0ccd10Smrg(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 4042e169010aSmrgto RM. 40437914d74bSmrg 4044e169010aSmrgIf FILE is a libtool library, all the files associated with it are deleted. 4045e169010aSmrgOtherwise, only FILE itself is deleted using RM." 4046e169010aSmrg ;; 40477914d74bSmrg 4048e169010aSmrg *) 40499d0ccd10Smrg func_fatal_help "invalid operation mode '$opt_mode'" 4050e169010aSmrg ;; 4051e169010aSmrg esac 40527914d74bSmrg 4053e8ead290Smrg echo 40549d0ccd10Smrg $ECHO "Try '$progname --help' for more information about other modes." 4055e169010aSmrg} 40567914d74bSmrg 4057e8ead290Smrg# Now that we've collected a possible --mode arg, show help if necessary 4058e8ead290Smrgif $opt_help; then 40599d0ccd10Smrg if test : = "$opt_help"; then 4060e8ead290Smrg func_mode_help 4061e8ead290Smrg else 4062e8ead290Smrg { 4063e8ead290Smrg func_help noexit 4064c63293b5Smrg for opt_mode in compile link execute install finish uninstall clean; do 4065e8ead290Smrg func_mode_help 4066e8ead290Smrg done 40679d0ccd10Smrg } | $SED -n '1p; 2,$s/^Usage:/ or: /p' 4068e8ead290Smrg { 4069e8ead290Smrg func_help noexit 4070c63293b5Smrg for opt_mode in compile link execute install finish uninstall clean; do 4071e8ead290Smrg echo 4072e8ead290Smrg func_mode_help 4073e8ead290Smrg done 4074e8ead290Smrg } | 40759d0ccd10Smrg $SED '1d 4076e8ead290Smrg /^When reporting/,/^Report/{ 4077e8ead290Smrg H 4078e8ead290Smrg d 4079e8ead290Smrg } 4080e8ead290Smrg $x 4081e8ead290Smrg /information about other modes/d 4082e8ead290Smrg /more detailed .*MODE/d 4083e8ead290Smrg s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' 4084e8ead290Smrg fi 4085e8ead290Smrg exit $? 4086e8ead290Smrgfi 40877914d74bSmrg 40887914d74bSmrg 4089e169010aSmrg# func_mode_execute arg... 4090e169010aSmrgfunc_mode_execute () 4091e169010aSmrg{ 40929d0ccd10Smrg $debug_cmd 40939d0ccd10Smrg 4094e169010aSmrg # The first argument is the command name. 40959d0ccd10Smrg cmd=$nonopt 4096e169010aSmrg test -z "$cmd" && \ 4097e169010aSmrg func_fatal_help "you must specify a COMMAND" 40987914d74bSmrg 4099e169010aSmrg # Handle -dlopen flags immediately. 4100c63293b5Smrg for file in $opt_dlopen; do 4101e169010aSmrg test -f "$file" \ 41029d0ccd10Smrg || func_fatal_help "'$file' is not a file" 41037914d74bSmrg 4104e169010aSmrg dir= 4105e169010aSmrg case $file in 4106e169010aSmrg *.la) 4107c63293b5Smrg func_resolve_sysroot "$file" 4108c63293b5Smrg file=$func_resolve_sysroot_result 4109c63293b5Smrg 4110e169010aSmrg # Check to see that this really is a libtool archive. 4111e169010aSmrg func_lalib_unsafe_p "$file" \ 41129d0ccd10Smrg || func_fatal_help "'$lib' is not a valid libtool archive" 41137914d74bSmrg 4114e169010aSmrg # Read the libtool library. 4115e169010aSmrg dlname= 4116e169010aSmrg library_names= 4117e169010aSmrg func_source "$file" 41187914d74bSmrg 4119e169010aSmrg # Skip this library if it cannot be dlopened. 4120e169010aSmrg if test -z "$dlname"; then 4121e169010aSmrg # Warn if it was a shared library. 4122e169010aSmrg test -n "$library_names" && \ 41239d0ccd10Smrg func_warning "'$file' was not linked with '-export-dynamic'" 4124e169010aSmrg continue 4125e169010aSmrg fi 41267914d74bSmrg 4127e169010aSmrg func_dirname "$file" "" "." 41289d0ccd10Smrg dir=$func_dirname_result 41297914d74bSmrg 4130e169010aSmrg if test -f "$dir/$objdir/$dlname"; then 4131c63293b5Smrg func_append dir "/$objdir" 4132e169010aSmrg else 4133e169010aSmrg if test ! -f "$dir/$dlname"; then 41349d0ccd10Smrg func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'" 4135e169010aSmrg fi 4136e169010aSmrg fi 41377914d74bSmrg ;; 41387914d74bSmrg 4139e169010aSmrg *.lo) 4140e169010aSmrg # Just add the directory containing the .lo file. 4141e169010aSmrg func_dirname "$file" "" "." 41429d0ccd10Smrg dir=$func_dirname_result 41437914d74bSmrg ;; 41447914d74bSmrg 4145e169010aSmrg *) 41469d0ccd10Smrg func_warning "'-dlopen' is ignored for non-libtool libraries and objects" 41477914d74bSmrg continue 41487914d74bSmrg ;; 4149e169010aSmrg esac 41507914d74bSmrg 4151e169010aSmrg # Get the absolute pathname. 4152e169010aSmrg absdir=`cd "$dir" && pwd` 41539d0ccd10Smrg test -n "$absdir" && dir=$absdir 41547914d74bSmrg 4155e169010aSmrg # Now add the directory to shlibpath_var. 4156e169010aSmrg if eval "test -z \"\$$shlibpath_var\""; then 4157e169010aSmrg eval "$shlibpath_var=\"\$dir\"" 4158e169010aSmrg else 4159e169010aSmrg eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" 4160e169010aSmrg fi 4161e169010aSmrg done 41627914d74bSmrg 4163e169010aSmrg # This variable tells wrapper scripts just to set shlibpath_var 4164e169010aSmrg # rather than running their programs. 41659d0ccd10Smrg libtool_execute_magic=$magic 41667914d74bSmrg 4167e169010aSmrg # Check if any of the arguments is a wrapper script. 4168e169010aSmrg args= 4169e169010aSmrg for file 4170e169010aSmrg do 4171e169010aSmrg case $file in 4172e8ead290Smrg -* | *.la | *.lo ) ;; 4173e169010aSmrg *) 4174e169010aSmrg # Do a test to see if this is really a libtool program. 4175e169010aSmrg if func_ltwrapper_script_p "$file"; then 4176e169010aSmrg func_source "$file" 4177e169010aSmrg # Transform arg to wrapped name. 41789d0ccd10Smrg file=$progdir/$program 4179e169010aSmrg elif func_ltwrapper_executable_p "$file"; then 4180e169010aSmrg func_ltwrapper_scriptname "$file" 4181e169010aSmrg func_source "$func_ltwrapper_scriptname_result" 4182e169010aSmrg # Transform arg to wrapped name. 41839d0ccd10Smrg file=$progdir/$program 4184e169010aSmrg fi 4185e169010aSmrg ;; 4186e169010aSmrg esac 4187e169010aSmrg # Quote arguments (to preserve shell metacharacters). 4188c63293b5Smrg func_append_quoted args "$file" 4189e169010aSmrg done 41907914d74bSmrg 41919d0ccd10Smrg if $opt_dry_run; then 41929d0ccd10Smrg # Display what would be done. 41939d0ccd10Smrg if test -n "$shlibpath_var"; then 41949d0ccd10Smrg eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" 41959d0ccd10Smrg echo "export $shlibpath_var" 41969d0ccd10Smrg fi 41979d0ccd10Smrg $ECHO "$cmd$args" 41989d0ccd10Smrg exit $EXIT_SUCCESS 41999d0ccd10Smrg else 4200e169010aSmrg if test -n "$shlibpath_var"; then 4201e169010aSmrg # Export the shlibpath_var. 4202e169010aSmrg eval "export $shlibpath_var" 4203e169010aSmrg fi 42047914d74bSmrg 4205e169010aSmrg # Restore saved environment variables 4206e169010aSmrg for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 4207e169010aSmrg do 4208e169010aSmrg eval "if test \"\${save_$lt_var+set}\" = set; then 4209e169010aSmrg $lt_var=\$save_$lt_var; export $lt_var 4210e169010aSmrg else 4211e169010aSmrg $lt_unset $lt_var 4212e169010aSmrg fi" 4213e169010aSmrg done 42147914d74bSmrg 4215e169010aSmrg # Now prepare to actually exec the command. 42169d0ccd10Smrg exec_cmd=\$cmd$args 4217e169010aSmrg fi 4218e169010aSmrg} 42197914d74bSmrg 42209d0ccd10Smrgtest execute = "$opt_mode" && func_mode_execute ${1+"$@"} 42217914d74bSmrg 42227914d74bSmrg 4223e169010aSmrg# func_mode_finish arg... 4224e169010aSmrgfunc_mode_finish () 4225e169010aSmrg{ 42269d0ccd10Smrg $debug_cmd 42279d0ccd10Smrg 4228c63293b5Smrg libs= 4229c63293b5Smrg libdirs= 4230e169010aSmrg admincmds= 42317914d74bSmrg 4232c63293b5Smrg for opt in "$nonopt" ${1+"$@"} 4233c63293b5Smrg do 4234c63293b5Smrg if test -d "$opt"; then 4235c63293b5Smrg func_append libdirs " $opt" 4236c63293b5Smrg 4237c63293b5Smrg elif test -f "$opt"; then 4238c63293b5Smrg if func_lalib_unsafe_p "$opt"; then 4239c63293b5Smrg func_append libs " $opt" 4240c63293b5Smrg else 42419d0ccd10Smrg func_warning "'$opt' is not a valid libtool archive" 4242c63293b5Smrg fi 4243c63293b5Smrg 4244c63293b5Smrg else 42459d0ccd10Smrg func_fatal_error "invalid argument '$opt'" 4246c63293b5Smrg fi 4247c63293b5Smrg done 4248c63293b5Smrg 4249c63293b5Smrg if test -n "$libs"; then 4250c63293b5Smrg if test -n "$lt_sysroot"; then 4251c63293b5Smrg sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` 4252c63293b5Smrg sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" 4253c63293b5Smrg else 4254c63293b5Smrg sysroot_cmd= 4255c63293b5Smrg fi 4256c63293b5Smrg 4257c63293b5Smrg # Remove sysroot references 4258c63293b5Smrg if $opt_dry_run; then 4259c63293b5Smrg for lib in $libs; do 42609d0ccd10Smrg echo "removing references to $lt_sysroot and '=' prefixes from $lib" 4261c63293b5Smrg done 4262c63293b5Smrg else 4263c63293b5Smrg tmpdir=`func_mktempdir` 4264c63293b5Smrg for lib in $libs; do 42659d0ccd10Smrg $SED -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ 4266c63293b5Smrg > $tmpdir/tmp-la 4267c63293b5Smrg mv -f $tmpdir/tmp-la $lib 4268c63293b5Smrg done 4269c63293b5Smrg ${RM}r "$tmpdir" 4270c63293b5Smrg fi 4271c63293b5Smrg fi 42727914d74bSmrg 4273c63293b5Smrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 4274e169010aSmrg for libdir in $libdirs; do 4275e169010aSmrg if test -n "$finish_cmds"; then 4276e169010aSmrg # Do each command in the finish commands. 4277e169010aSmrg func_execute_cmds "$finish_cmds" 'admincmds="$admincmds 4278e169010aSmrg'"$cmd"'"' 4279e169010aSmrg fi 4280e169010aSmrg if test -n "$finish_eval"; then 4281e169010aSmrg # Do the single finish_eval. 4282e169010aSmrg eval cmds=\"$finish_eval\" 4283c63293b5Smrg $opt_dry_run || eval "$cmds" || func_append admincmds " 4284e169010aSmrg $cmds" 4285e169010aSmrg fi 4286e169010aSmrg done 4287e169010aSmrg fi 42887914d74bSmrg 4289e169010aSmrg # Exit here if they wanted silent mode. 42909d0ccd10Smrg $opt_quiet && exit $EXIT_SUCCESS 42917914d74bSmrg 4292c63293b5Smrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 4293c63293b5Smrg echo "----------------------------------------------------------------------" 4294c63293b5Smrg echo "Libraries have been installed in:" 4295c63293b5Smrg for libdir in $libdirs; do 4296c63293b5Smrg $ECHO " $libdir" 4297c63293b5Smrg done 4298c63293b5Smrg echo 4299c63293b5Smrg echo "If you ever happen to want to link against installed libraries" 4300c63293b5Smrg echo "in a given directory, LIBDIR, you must either use libtool, and" 43019d0ccd10Smrg echo "specify the full pathname of the library, or use the '-LLIBDIR'" 4302c63293b5Smrg echo "flag during linking and do at least one of the following:" 4303c63293b5Smrg if test -n "$shlibpath_var"; then 43049d0ccd10Smrg echo " - add LIBDIR to the '$shlibpath_var' environment variable" 4305c63293b5Smrg echo " during execution" 4306c63293b5Smrg fi 4307c63293b5Smrg if test -n "$runpath_var"; then 43089d0ccd10Smrg echo " - add LIBDIR to the '$runpath_var' environment variable" 4309c63293b5Smrg echo " during linking" 4310c63293b5Smrg fi 4311c63293b5Smrg if test -n "$hardcode_libdir_flag_spec"; then 4312c63293b5Smrg libdir=LIBDIR 4313c63293b5Smrg eval flag=\"$hardcode_libdir_flag_spec\" 43147914d74bSmrg 43159d0ccd10Smrg $ECHO " - use the '$flag' linker flag" 4316c63293b5Smrg fi 4317c63293b5Smrg if test -n "$admincmds"; then 4318c63293b5Smrg $ECHO " - have your system administrator run these commands:$admincmds" 4319c63293b5Smrg fi 4320c63293b5Smrg if test -f /etc/ld.so.conf; then 43219d0ccd10Smrg echo " - have your system administrator add LIBDIR to '/etc/ld.so.conf'" 4322c63293b5Smrg fi 4323c63293b5Smrg echo 43247914d74bSmrg 4325c63293b5Smrg echo "See any operating system documentation about shared libraries for" 4326c63293b5Smrg case $host in 4327c63293b5Smrg solaris2.[6789]|solaris2.1[0-9]) 4328c63293b5Smrg echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" 4329c63293b5Smrg echo "pages." 4330c63293b5Smrg ;; 4331c63293b5Smrg *) 4332c63293b5Smrg echo "more information, such as the ld(1) and ld.so(8) manual pages." 4333c63293b5Smrg ;; 4334c63293b5Smrg esac 4335c63293b5Smrg echo "----------------------------------------------------------------------" 4336c63293b5Smrg fi 4337e169010aSmrg exit $EXIT_SUCCESS 4338e169010aSmrg} 43397914d74bSmrg 43409d0ccd10Smrgtest finish = "$opt_mode" && func_mode_finish ${1+"$@"} 43417914d74bSmrg 43427914d74bSmrg 4343e169010aSmrg# func_mode_install arg... 4344e169010aSmrgfunc_mode_install () 4345e169010aSmrg{ 43469d0ccd10Smrg $debug_cmd 43479d0ccd10Smrg 4348e169010aSmrg # There may be an optional sh(1) argument at the beginning of 4349e169010aSmrg # install_prog (especially on Windows NT). 43509d0ccd10Smrg if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" || 4351e169010aSmrg # Allow the use of GNU shtool's install command. 43529d0ccd10Smrg case $nonopt in *shtool*) :;; *) false;; esac 43539d0ccd10Smrg then 4354e169010aSmrg # Aesthetically quote it. 43550ea508b1Smrg func_quote_arg pretty "$nonopt" 43560ea508b1Smrg install_prog="$func_quote_arg_result " 4357e169010aSmrg arg=$1 4358e169010aSmrg shift 4359e169010aSmrg else 4360e169010aSmrg install_prog= 4361e169010aSmrg arg=$nonopt 4362e169010aSmrg fi 43637914d74bSmrg 4364e169010aSmrg # The real first argument should be the name of the installation program. 4365e169010aSmrg # Aesthetically quote it. 43660ea508b1Smrg func_quote_arg pretty "$arg" 43670ea508b1Smrg func_append install_prog "$func_quote_arg_result" 4368e8ead290Smrg install_shared_prog=$install_prog 4369e8ead290Smrg case " $install_prog " in 4370e8ead290Smrg *[\\\ /]cp\ *) install_cp=: ;; 4371e8ead290Smrg *) install_cp=false ;; 4372e8ead290Smrg esac 4373e169010aSmrg 4374e169010aSmrg # We need to accept at least all the BSD install flags. 4375e169010aSmrg dest= 4376e169010aSmrg files= 4377e169010aSmrg opts= 4378e169010aSmrg prev= 4379e169010aSmrg install_type= 43809d0ccd10Smrg isdir=false 4381e169010aSmrg stripme= 4382e8ead290Smrg no_mode=: 4383e169010aSmrg for arg 4384e169010aSmrg do 4385e8ead290Smrg arg2= 4386e169010aSmrg if test -n "$dest"; then 4387c63293b5Smrg func_append files " $dest" 4388e169010aSmrg dest=$arg 4389e169010aSmrg continue 43907914d74bSmrg fi 43917914d74bSmrg 4392e169010aSmrg case $arg in 43939d0ccd10Smrg -d) isdir=: ;; 4394e169010aSmrg -f) 4395e8ead290Smrg if $install_cp; then :; else 4396e8ead290Smrg prev=$arg 4397e8ead290Smrg fi 4398e169010aSmrg ;; 4399e169010aSmrg -g | -m | -o) 4400e169010aSmrg prev=$arg 4401e169010aSmrg ;; 4402e169010aSmrg -s) 4403e169010aSmrg stripme=" -s" 4404e169010aSmrg continue 4405e169010aSmrg ;; 4406e169010aSmrg -*) 4407e169010aSmrg ;; 4408e169010aSmrg *) 4409e169010aSmrg # If the previous option needed an argument, then skip it. 4410e169010aSmrg if test -n "$prev"; then 44119d0ccd10Smrg if test X-m = "X$prev" && test -n "$install_override_mode"; then 4412e8ead290Smrg arg2=$install_override_mode 4413e8ead290Smrg no_mode=false 4414e8ead290Smrg fi 4415e169010aSmrg prev= 4416e169010aSmrg else 4417e169010aSmrg dest=$arg 4418e169010aSmrg continue 4419e169010aSmrg fi 4420e169010aSmrg ;; 4421e169010aSmrg esac 44227914d74bSmrg 4423e169010aSmrg # Aesthetically quote the argument. 44240ea508b1Smrg func_quote_arg pretty "$arg" 44250ea508b1Smrg func_append install_prog " $func_quote_arg_result" 4426e8ead290Smrg if test -n "$arg2"; then 44270ea508b1Smrg func_quote_arg pretty "$arg2" 4428e8ead290Smrg fi 44290ea508b1Smrg func_append install_shared_prog " $func_quote_arg_result" 4430e169010aSmrg done 44317914d74bSmrg 4432e169010aSmrg test -z "$install_prog" && \ 4433e169010aSmrg func_fatal_help "you must specify an install program" 44347914d74bSmrg 4435e169010aSmrg test -n "$prev" && \ 44369d0ccd10Smrg func_fatal_help "the '$prev' option requires an argument" 44377914d74bSmrg 4438e8ead290Smrg if test -n "$install_override_mode" && $no_mode; then 4439e8ead290Smrg if $install_cp; then :; else 44400ea508b1Smrg func_quote_arg pretty "$install_override_mode" 44410ea508b1Smrg func_append install_shared_prog " -m $func_quote_arg_result" 4442e8ead290Smrg fi 4443e8ead290Smrg fi 4444e8ead290Smrg 4445e169010aSmrg if test -z "$files"; then 4446e169010aSmrg if test -z "$dest"; then 4447e169010aSmrg func_fatal_help "no file or destination specified" 4448e169010aSmrg else 4449e169010aSmrg func_fatal_help "you must specify a destination" 44507914d74bSmrg fi 44517914d74bSmrg fi 44527914d74bSmrg 4453e169010aSmrg # Strip any trailing slash from the destination. 4454e169010aSmrg func_stripname '' '/' "$dest" 4455e169010aSmrg dest=$func_stripname_result 44567914d74bSmrg 4457e169010aSmrg # Check to see that the destination is a directory. 44589d0ccd10Smrg test -d "$dest" && isdir=: 44599d0ccd10Smrg if $isdir; then 44609d0ccd10Smrg destdir=$dest 4461e169010aSmrg destname= 4462e169010aSmrg else 4463e169010aSmrg func_dirname_and_basename "$dest" "" "." 44649d0ccd10Smrg destdir=$func_dirname_result 44659d0ccd10Smrg destname=$func_basename_result 4466e169010aSmrg 4467e169010aSmrg # Not a directory, so check to see that there is only one file specified. 4468e169010aSmrg set dummy $files; shift 4469e169010aSmrg test "$#" -gt 1 && \ 44709d0ccd10Smrg func_fatal_help "'$dest' is not a directory" 4471e169010aSmrg fi 4472e169010aSmrg case $destdir in 4473e169010aSmrg [\\/]* | [A-Za-z]:[\\/]*) ;; 44747914d74bSmrg *) 4475e169010aSmrg for file in $files; do 4476e169010aSmrg case $file in 4477e169010aSmrg *.lo) ;; 4478e169010aSmrg *) 44799d0ccd10Smrg func_fatal_help "'$destdir' must be an absolute directory name" 4480e169010aSmrg ;; 4481e169010aSmrg esac 4482e169010aSmrg done 44837914d74bSmrg ;; 44847914d74bSmrg esac 44857914d74bSmrg 4486e169010aSmrg # This variable tells wrapper scripts just to set variables rather 4487e169010aSmrg # than running their programs. 44889d0ccd10Smrg libtool_install_magic=$magic 44897914d74bSmrg 4490e169010aSmrg staticlibs= 4491e169010aSmrg future_libdirs= 4492e169010aSmrg current_libdirs= 4493e169010aSmrg for file in $files; do 44947914d74bSmrg 4495e169010aSmrg # Do each installation. 4496e169010aSmrg case $file in 4497e169010aSmrg *.$libext) 4498e169010aSmrg # Do the static libraries later. 4499c63293b5Smrg func_append staticlibs " $file" 4500e169010aSmrg ;; 4501e169010aSmrg 4502e169010aSmrg *.la) 4503c63293b5Smrg func_resolve_sysroot "$file" 4504c63293b5Smrg file=$func_resolve_sysroot_result 4505c63293b5Smrg 4506e169010aSmrg # Check to see that this really is a libtool archive. 4507e169010aSmrg func_lalib_unsafe_p "$file" \ 45089d0ccd10Smrg || func_fatal_help "'$file' is not a valid libtool archive" 4509e169010aSmrg 4510e169010aSmrg library_names= 4511e169010aSmrg old_library= 4512e169010aSmrg relink_command= 4513e169010aSmrg func_source "$file" 4514e169010aSmrg 4515e169010aSmrg # Add the libdir to current_libdirs if it is the destination. 4516e169010aSmrg if test "X$destdir" = "X$libdir"; then 4517e169010aSmrg case "$current_libdirs " in 4518e169010aSmrg *" $libdir "*) ;; 4519c63293b5Smrg *) func_append current_libdirs " $libdir" ;; 45207914d74bSmrg esac 4521e169010aSmrg else 4522e169010aSmrg # Note the libdir as a future libdir. 4523e169010aSmrg case "$future_libdirs " in 4524e169010aSmrg *" $libdir "*) ;; 4525c63293b5Smrg *) func_append future_libdirs " $libdir" ;; 4526e169010aSmrg esac 4527e169010aSmrg fi 45287914d74bSmrg 4529e169010aSmrg func_dirname "$file" "/" "" 45309d0ccd10Smrg dir=$func_dirname_result 4531c63293b5Smrg func_append dir "$objdir" 4532e169010aSmrg 4533e169010aSmrg if test -n "$relink_command"; then 4534e169010aSmrg # Determine the prefix the user has applied to our future dir. 4535e8ead290Smrg inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` 4536e169010aSmrg 4537e169010aSmrg # Don't allow the user to place us outside of our expected 4538e169010aSmrg # location b/c this prevents finding dependent libraries that 4539e169010aSmrg # are installed to the same prefix. 4540e169010aSmrg # At present, this check doesn't affect windows .dll's that 4541e169010aSmrg # are installed into $libdir/../bin (currently, that works fine) 4542e169010aSmrg # but it's something to keep an eye on. 4543e169010aSmrg test "$inst_prefix_dir" = "$destdir" && \ 45449d0ccd10Smrg func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir" 4545e169010aSmrg 4546e169010aSmrg if test -n "$inst_prefix_dir"; then 4547e169010aSmrg # Stick the inst_prefix_dir data into the link command. 4548e8ead290Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` 4549e169010aSmrg else 4550e8ead290Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` 4551e169010aSmrg fi 4552e169010aSmrg 45539d0ccd10Smrg func_warning "relinking '$file'" 4554e169010aSmrg func_show_eval "$relink_command" \ 45559d0ccd10Smrg 'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"' 4556e169010aSmrg fi 4557e169010aSmrg 4558e169010aSmrg # See the names of the shared library. 4559e169010aSmrg set dummy $library_names; shift 4560e169010aSmrg if test -n "$1"; then 45619d0ccd10Smrg realname=$1 4562e169010aSmrg shift 4563e169010aSmrg 45649d0ccd10Smrg srcname=$realname 45659d0ccd10Smrg test -n "$relink_command" && srcname=${realname}T 4566e169010aSmrg 4567e169010aSmrg # Install the shared library and build the symlinks. 4568e8ead290Smrg func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ 4569e169010aSmrg 'exit $?' 45709d0ccd10Smrg tstripme=$stripme 4571e169010aSmrg case $host_os in 4572e169010aSmrg cygwin* | mingw* | pw32* | cegcc*) 4573e169010aSmrg case $realname in 4574e169010aSmrg *.dll.a) 45759d0ccd10Smrg tstripme= 45769d0ccd10Smrg ;; 45779d0ccd10Smrg esac 45789d0ccd10Smrg ;; 45799d0ccd10Smrg os2*) 45809d0ccd10Smrg case $realname in 45819d0ccd10Smrg *_dll.a) 45829d0ccd10Smrg tstripme= 4583e169010aSmrg ;; 4584e169010aSmrg esac 45857914d74bSmrg ;; 45867914d74bSmrg esac 4587e169010aSmrg if test -n "$tstripme" && test -n "$striplib"; then 4588e169010aSmrg func_show_eval "$striplib $destdir/$realname" 'exit $?' 45897914d74bSmrg fi 4590e169010aSmrg 4591e169010aSmrg if test "$#" -gt 0; then 4592e169010aSmrg # Delete the old symlinks, and create new ones. 45939d0ccd10Smrg # Try 'ln -sf' first, because the 'ln' binary might depend on 4594e169010aSmrg # the symlink we replace! Solaris /bin/ln does not understand -f, 4595e169010aSmrg # so we also need to try rm && ln -s. 4596e169010aSmrg for linkname 4597e169010aSmrg do 4598e169010aSmrg test "$linkname" != "$realname" \ 4599e169010aSmrg && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" 46007914d74bSmrg done 46017914d74bSmrg fi 46027914d74bSmrg 4603e169010aSmrg # Do each command in the postinstall commands. 46049d0ccd10Smrg lib=$destdir/$realname 4605e169010aSmrg func_execute_cmds "$postinstall_cmds" 'exit $?' 46067914d74bSmrg fi 46077914d74bSmrg 4608e169010aSmrg # Install the pseudo-library for information purposes. 4609e169010aSmrg func_basename "$file" 46109d0ccd10Smrg name=$func_basename_result 46119d0ccd10Smrg instname=$dir/${name}i 4612e169010aSmrg func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' 46137914d74bSmrg 4614e169010aSmrg # Maybe install the static library, too. 4615c63293b5Smrg test -n "$old_library" && func_append staticlibs " $dir/$old_library" 4616e169010aSmrg ;; 46177914d74bSmrg 4618e169010aSmrg *.lo) 4619e169010aSmrg # Install (i.e. copy) a libtool object. 46207914d74bSmrg 4621e169010aSmrg # Figure out destination file name, if it wasn't already specified. 4622e169010aSmrg if test -n "$destname"; then 46239d0ccd10Smrg destfile=$destdir/$destname 4624e169010aSmrg else 4625e169010aSmrg func_basename "$file" 46269d0ccd10Smrg destfile=$func_basename_result 46279d0ccd10Smrg destfile=$destdir/$destfile 4628e169010aSmrg fi 4629e169010aSmrg 4630e169010aSmrg # Deduce the name of the destination old-style object file. 4631e169010aSmrg case $destfile in 4632e169010aSmrg *.lo) 4633e169010aSmrg func_lo2o "$destfile" 4634e169010aSmrg staticdest=$func_lo2o_result 4635e169010aSmrg ;; 4636e169010aSmrg *.$objext) 46379d0ccd10Smrg staticdest=$destfile 4638e169010aSmrg destfile= 4639e169010aSmrg ;; 4640e169010aSmrg *) 46419d0ccd10Smrg func_fatal_help "cannot copy a libtool object to '$destfile'" 4642e169010aSmrg ;; 46437914d74bSmrg esac 46447914d74bSmrg 4645e169010aSmrg # Install the libtool object if requested. 4646e169010aSmrg test -n "$destfile" && \ 4647e169010aSmrg func_show_eval "$install_prog $file $destfile" 'exit $?' 4648e169010aSmrg 4649e169010aSmrg # Install the old object if enabled. 46509d0ccd10Smrg if test yes = "$build_old_libs"; then 4651e169010aSmrg # Deduce the name of the old-style object file. 4652e169010aSmrg func_lo2o "$file" 4653e169010aSmrg staticobj=$func_lo2o_result 4654e169010aSmrg func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' 46557914d74bSmrg fi 4656e169010aSmrg exit $EXIT_SUCCESS 4657e169010aSmrg ;; 46587914d74bSmrg 4659e169010aSmrg *) 4660e169010aSmrg # Figure out destination file name, if it wasn't already specified. 4661e169010aSmrg if test -n "$destname"; then 46629d0ccd10Smrg destfile=$destdir/$destname 4663e169010aSmrg else 4664e169010aSmrg func_basename "$file" 46659d0ccd10Smrg destfile=$func_basename_result 46669d0ccd10Smrg destfile=$destdir/$destfile 4667e169010aSmrg fi 4668e169010aSmrg 4669e169010aSmrg # If the file is missing, and there is a .exe on the end, strip it 4670e169010aSmrg # because it is most likely a libtool script we actually want to 4671e169010aSmrg # install 46729d0ccd10Smrg stripped_ext= 4673e169010aSmrg case $file in 4674e169010aSmrg *.exe) 4675e169010aSmrg if test ! -f "$file"; then 4676e169010aSmrg func_stripname '' '.exe' "$file" 4677e169010aSmrg file=$func_stripname_result 46789d0ccd10Smrg stripped_ext=.exe 46797914d74bSmrg fi 4680e169010aSmrg ;; 4681e169010aSmrg esac 46827914d74bSmrg 4683e169010aSmrg # Do a test to see if this is really a libtool program. 4684e169010aSmrg case $host in 4685e169010aSmrg *cygwin* | *mingw*) 4686e169010aSmrg if func_ltwrapper_executable_p "$file"; then 4687e169010aSmrg func_ltwrapper_scriptname "$file" 4688e169010aSmrg wrapper=$func_ltwrapper_scriptname_result 4689e169010aSmrg else 4690e169010aSmrg func_stripname '' '.exe' "$file" 4691e169010aSmrg wrapper=$func_stripname_result 4692e169010aSmrg fi 4693e169010aSmrg ;; 4694e169010aSmrg *) 4695e169010aSmrg wrapper=$file 4696e169010aSmrg ;; 4697e169010aSmrg esac 4698e169010aSmrg if func_ltwrapper_script_p "$wrapper"; then 4699e169010aSmrg notinst_deplibs= 4700e169010aSmrg relink_command= 47017914d74bSmrg 4702e169010aSmrg func_source "$wrapper" 47037914d74bSmrg 4704e169010aSmrg # Check the variables that should have been set. 4705e169010aSmrg test -z "$generated_by_libtool_version" && \ 47069d0ccd10Smrg func_fatal_error "invalid libtool wrapper script '$wrapper'" 4707e169010aSmrg 47089d0ccd10Smrg finalize=: 4709e169010aSmrg for lib in $notinst_deplibs; do 4710e169010aSmrg # Check to see that each library is installed. 4711e169010aSmrg libdir= 4712e169010aSmrg if test -f "$lib"; then 4713e169010aSmrg func_source "$lib" 4714e169010aSmrg fi 47159d0ccd10Smrg libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'` 4716e169010aSmrg if test -n "$libdir" && test ! -f "$libfile"; then 47179d0ccd10Smrg func_warning "'$lib' has not been installed in '$libdir'" 47189d0ccd10Smrg finalize=false 4719e169010aSmrg fi 4720e169010aSmrg done 4721e169010aSmrg 4722e169010aSmrg relink_command= 4723e169010aSmrg func_source "$wrapper" 4724e169010aSmrg 4725e169010aSmrg outputname= 47269d0ccd10Smrg if test no = "$fast_install" && test -n "$relink_command"; then 4727e169010aSmrg $opt_dry_run || { 47289d0ccd10Smrg if $finalize; then 4729e169010aSmrg tmpdir=`func_mktempdir` 4730e169010aSmrg func_basename "$file$stripped_ext" 47319d0ccd10Smrg file=$func_basename_result 47329d0ccd10Smrg outputname=$tmpdir/$file 4733e169010aSmrg # Replace the output file specification. 4734e8ead290Smrg relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` 4735e169010aSmrg 47369d0ccd10Smrg $opt_quiet || { 47370ea508b1Smrg func_quote_arg expand,pretty "$relink_command" 47380ea508b1Smrg eval "func_echo $func_quote_arg_result" 4739e169010aSmrg } 4740e169010aSmrg if eval "$relink_command"; then : 4741e169010aSmrg else 47429d0ccd10Smrg func_error "error: relink '$file' with the above command before installing it" 4743e169010aSmrg $opt_dry_run || ${RM}r "$tmpdir" 4744e169010aSmrg continue 4745e169010aSmrg fi 47469d0ccd10Smrg file=$outputname 4747e169010aSmrg else 47489d0ccd10Smrg func_warning "cannot relink '$file'" 4749e169010aSmrg fi 4750e169010aSmrg } 47517914d74bSmrg else 4752e169010aSmrg # Install the binary that we compiled earlier. 4753e8ead290Smrg file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` 47547914d74bSmrg fi 4755e169010aSmrg fi 47567914d74bSmrg 4757e169010aSmrg # remove .exe since cygwin /usr/bin/install will append another 4758e169010aSmrg # one anyway 4759e169010aSmrg case $install_prog,$host in 4760e169010aSmrg */usr/bin/install*,*cygwin*) 4761e169010aSmrg case $file:$destfile in 4762e169010aSmrg *.exe:*.exe) 4763e169010aSmrg # this is ok 4764e169010aSmrg ;; 4765e169010aSmrg *.exe:*) 4766e169010aSmrg destfile=$destfile.exe 4767e169010aSmrg ;; 4768e169010aSmrg *:*.exe) 4769e169010aSmrg func_stripname '' '.exe' "$destfile" 4770e169010aSmrg destfile=$func_stripname_result 4771e169010aSmrg ;; 4772e169010aSmrg esac 47737914d74bSmrg ;; 47747914d74bSmrg esac 4775e169010aSmrg func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' 4776e169010aSmrg $opt_dry_run || if test -n "$outputname"; then 4777e169010aSmrg ${RM}r "$tmpdir" 4778e169010aSmrg fi 4779e169010aSmrg ;; 4780e169010aSmrg esac 4781e169010aSmrg done 47827914d74bSmrg 4783e169010aSmrg for file in $staticlibs; do 4784e169010aSmrg func_basename "$file" 47859d0ccd10Smrg name=$func_basename_result 47867914d74bSmrg 4787e169010aSmrg # Set up the ranlib parameters. 47889d0ccd10Smrg oldlib=$destdir/$name 4789e6d5e4e0Smrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 4790e6d5e4e0Smrg tool_oldlib=$func_to_tool_file_result 47917914d74bSmrg 4792e169010aSmrg func_show_eval "$install_prog \$file \$oldlib" 'exit $?' 47937914d74bSmrg 4794e169010aSmrg if test -n "$stripme" && test -n "$old_striplib"; then 4795e6d5e4e0Smrg func_show_eval "$old_striplib $tool_oldlib" 'exit $?' 4796e169010aSmrg fi 47977914d74bSmrg 4798e169010aSmrg # Do each command in the postinstall commands. 4799e169010aSmrg func_execute_cmds "$old_postinstall_cmds" 'exit $?' 4800e169010aSmrg done 48017914d74bSmrg 4802e169010aSmrg test -n "$future_libdirs" && \ 48039d0ccd10Smrg func_warning "remember to run '$progname --finish$future_libdirs'" 48047914d74bSmrg 4805e169010aSmrg if test -n "$current_libdirs"; then 4806e169010aSmrg # Maybe just do a dry run. 4807e169010aSmrg $opt_dry_run && current_libdirs=" -n$current_libdirs" 48089d0ccd10Smrg exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs' 4809e169010aSmrg else 4810e169010aSmrg exit $EXIT_SUCCESS 4811e169010aSmrg fi 4812e169010aSmrg} 48137914d74bSmrg 48149d0ccd10Smrgtest install = "$opt_mode" && func_mode_install ${1+"$@"} 48157914d74bSmrg 48167914d74bSmrg 4817e169010aSmrg# func_generate_dlsyms outputname originator pic_p 4818e169010aSmrg# Extract symbols from dlprefiles and create ${outputname}S.o with 4819e169010aSmrg# a dlpreopen symbol table. 4820e169010aSmrgfunc_generate_dlsyms () 4821e169010aSmrg{ 48229d0ccd10Smrg $debug_cmd 48239d0ccd10Smrg 48249d0ccd10Smrg my_outputname=$1 48259d0ccd10Smrg my_originator=$2 48269d0ccd10Smrg my_pic_p=${3-false} 48279d0ccd10Smrg my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'` 4828e169010aSmrg my_dlsyms= 4829e169010aSmrg 48309d0ccd10Smrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 4831e169010aSmrg if test -n "$NM" && test -n "$global_symbol_pipe"; then 48329d0ccd10Smrg my_dlsyms=${my_outputname}S.c 4833e169010aSmrg else 4834e169010aSmrg func_error "not configured to extract global symbols from dlpreopened files" 4835e169010aSmrg fi 4836e169010aSmrg fi 48377914d74bSmrg 4838e169010aSmrg if test -n "$my_dlsyms"; then 4839e169010aSmrg case $my_dlsyms in 4840e169010aSmrg "") ;; 4841e169010aSmrg *.c) 4842e169010aSmrg # Discover the nlist of each of the dlfiles. 48439d0ccd10Smrg nlist=$output_objdir/$my_outputname.nm 4844e169010aSmrg 4845e169010aSmrg func_show_eval "$RM $nlist ${nlist}S ${nlist}T" 4846e169010aSmrg 4847e169010aSmrg # Parse the name list into a source file. 4848e169010aSmrg func_verbose "creating $output_objdir/$my_dlsyms" 4849e169010aSmrg 4850e169010aSmrg $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ 48519d0ccd10Smrg/* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */ 48529d0ccd10Smrg/* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */ 4853e169010aSmrg 4854e169010aSmrg#ifdef __cplusplus 4855e169010aSmrgextern \"C\" { 4856e169010aSmrg#endif 4857e169010aSmrg 48589d0ccd10Smrg#if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) 4859e8ead290Smrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\" 4860e8ead290Smrg#endif 4861e8ead290Smrg 4862c63293b5Smrg/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ 48639d0ccd10Smrg#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE 48649d0ccd10Smrg/* DATA imports from DLLs on WIN32 can't be const, because runtime 4865c63293b5Smrg relocations are performed -- see ld's documentation on pseudo-relocs. */ 4866c63293b5Smrg# define LT_DLSYM_CONST 48679d0ccd10Smrg#elif defined __osf__ 4868c63293b5Smrg/* This system does not cope well with relocations in const data. */ 4869c63293b5Smrg# define LT_DLSYM_CONST 4870c63293b5Smrg#else 4871c63293b5Smrg# define LT_DLSYM_CONST const 4872c63293b5Smrg#endif 4873c63293b5Smrg 48749d0ccd10Smrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 48759d0ccd10Smrg 4876e169010aSmrg/* External symbol declarations for the compiler. */\ 4877e169010aSmrg" 4878e169010aSmrg 48799d0ccd10Smrg if test yes = "$dlself"; then 48809d0ccd10Smrg func_verbose "generating symbol list for '$output'" 4881e169010aSmrg 4882e169010aSmrg $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" 4883e169010aSmrg 4884e169010aSmrg # Add our own program objects to the symbol list. 4885e8ead290Smrg progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` 4886e169010aSmrg for progfile in $progfiles; do 4887c63293b5Smrg func_to_tool_file "$progfile" func_convert_file_msys_to_w32 48889d0ccd10Smrg func_verbose "extracting global C symbols from '$func_to_tool_file_result'" 4889c63293b5Smrg $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" 4890e169010aSmrg done 4891e169010aSmrg 4892e169010aSmrg if test -n "$exclude_expsyms"; then 4893e169010aSmrg $opt_dry_run || { 4894e169010aSmrg eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' 4895e169010aSmrg eval '$MV "$nlist"T "$nlist"' 4896e169010aSmrg } 48977914d74bSmrg fi 48987914d74bSmrg 4899e169010aSmrg if test -n "$export_symbols_regex"; then 4900e169010aSmrg $opt_dry_run || { 4901e169010aSmrg eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' 4902e169010aSmrg eval '$MV "$nlist"T "$nlist"' 4903e169010aSmrg } 49047914d74bSmrg fi 4905e169010aSmrg 4906e169010aSmrg # Prepare the list of exported symbols 4907e169010aSmrg if test -z "$export_symbols"; then 49089d0ccd10Smrg export_symbols=$output_objdir/$outputname.exp 4909e169010aSmrg $opt_dry_run || { 4910e169010aSmrg $RM $export_symbols 49119d0ccd10Smrg eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' 4912e169010aSmrg case $host in 4913e169010aSmrg *cygwin* | *mingw* | *cegcc* ) 4914e169010aSmrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 4915e169010aSmrg eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' 4916e169010aSmrg ;; 49177914d74bSmrg esac 4918e169010aSmrg } 4919e169010aSmrg else 4920e169010aSmrg $opt_dry_run || { 49219d0ccd10Smrg eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' 4922e169010aSmrg eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' 4923e169010aSmrg eval '$MV "$nlist"T "$nlist"' 4924e169010aSmrg case $host in 4925e8ead290Smrg *cygwin* | *mingw* | *cegcc* ) 4926e169010aSmrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 4927e169010aSmrg eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' 4928e169010aSmrg ;; 49297914d74bSmrg esac 4930e169010aSmrg } 49317914d74bSmrg fi 4932e169010aSmrg fi 49337914d74bSmrg 4934e169010aSmrg for dlprefile in $dlprefiles; do 49359d0ccd10Smrg func_verbose "extracting global C symbols from '$dlprefile'" 4936e169010aSmrg func_basename "$dlprefile" 49379d0ccd10Smrg name=$func_basename_result 4938c63293b5Smrg case $host in 4939c63293b5Smrg *cygwin* | *mingw* | *cegcc* ) 4940c63293b5Smrg # if an import library, we need to obtain dlname 4941c63293b5Smrg if func_win32_import_lib_p "$dlprefile"; then 4942c63293b5Smrg func_tr_sh "$dlprefile" 4943c63293b5Smrg eval "curr_lafile=\$libfile_$func_tr_sh_result" 49449d0ccd10Smrg dlprefile_dlbasename= 4945c63293b5Smrg if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then 4946c63293b5Smrg # Use subshell, to avoid clobbering current variable values 4947c63293b5Smrg dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` 49489d0ccd10Smrg if test -n "$dlprefile_dlname"; then 4949c63293b5Smrg func_basename "$dlprefile_dlname" 49509d0ccd10Smrg dlprefile_dlbasename=$func_basename_result 4951c63293b5Smrg else 4952c63293b5Smrg # no lafile. user explicitly requested -dlpreopen <import library>. 4953c63293b5Smrg $sharedlib_from_linklib_cmd "$dlprefile" 4954c63293b5Smrg dlprefile_dlbasename=$sharedlib_from_linklib_result 4955c63293b5Smrg fi 4956c63293b5Smrg fi 4957c63293b5Smrg $opt_dry_run || { 49589d0ccd10Smrg if test -n "$dlprefile_dlbasename"; then 4959c63293b5Smrg eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' 4960c63293b5Smrg else 4961c63293b5Smrg func_warning "Could not compute DLL name from $name" 4962c63293b5Smrg eval '$ECHO ": $name " >> "$nlist"' 4963c63293b5Smrg fi 4964c63293b5Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 4965c63293b5Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | 4966c63293b5Smrg $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" 4967c63293b5Smrg } 4968c63293b5Smrg else # not an import lib 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 fi 4975c63293b5Smrg ;; 4976c63293b5Smrg *) 4977c63293b5Smrg $opt_dry_run || { 4978c63293b5Smrg eval '$ECHO ": $name " >> "$nlist"' 4979c63293b5Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 4980c63293b5Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 4981c63293b5Smrg } 4982c63293b5Smrg ;; 4983c63293b5Smrg esac 4984e169010aSmrg done 49857914d74bSmrg 4986e169010aSmrg $opt_dry_run || { 4987e169010aSmrg # Make sure we have at least an empty file. 4988e169010aSmrg test -f "$nlist" || : > "$nlist" 49897914d74bSmrg 4990e169010aSmrg if test -n "$exclude_expsyms"; then 4991e169010aSmrg $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T 4992e169010aSmrg $MV "$nlist"T "$nlist" 49937914d74bSmrg fi 49947914d74bSmrg 4995e169010aSmrg # Try sorting and uniquifying the output. 4996e169010aSmrg if $GREP -v "^: " < "$nlist" | 4997e169010aSmrg if sort -k 3 </dev/null >/dev/null 2>&1; then 4998e169010aSmrg sort -k 3 49997914d74bSmrg else 5000e169010aSmrg sort +2 5001e169010aSmrg fi | 5002e169010aSmrg uniq > "$nlist"S; then 5003e169010aSmrg : 50047914d74bSmrg else 5005e169010aSmrg $GREP -v "^: " < "$nlist" > "$nlist"S 50067914d74bSmrg fi 50077914d74bSmrg 5008e169010aSmrg if test -f "$nlist"S; then 5009e169010aSmrg eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' 50107914d74bSmrg else 5011e8ead290Smrg echo '/* NONE */' >> "$output_objdir/$my_dlsyms" 50127914d74bSmrg fi 50137914d74bSmrg 50149d0ccd10Smrg func_show_eval '$RM "${nlist}I"' 50159d0ccd10Smrg if test -n "$global_symbol_to_import"; then 50169d0ccd10Smrg eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I' 50179d0ccd10Smrg fi 50189d0ccd10Smrg 5019e8ead290Smrg echo >> "$output_objdir/$my_dlsyms" "\ 50207914d74bSmrg 5021e169010aSmrg/* The mapping between symbol names and symbols. */ 5022e169010aSmrgtypedef struct { 5023e169010aSmrg const char *name; 5024e169010aSmrg void *address; 5025e169010aSmrg} lt_dlsymlist; 5026c63293b5Smrgextern LT_DLSYM_CONST lt_dlsymlist 50279d0ccd10Smrglt_${my_prefix}_LTX_preloaded_symbols[];\ 50289d0ccd10Smrg" 50299d0ccd10Smrg 50309d0ccd10Smrg if test -s "$nlist"I; then 50319d0ccd10Smrg echo >> "$output_objdir/$my_dlsyms" "\ 50329d0ccd10Smrgstatic void lt_syminit(void) 50339d0ccd10Smrg{ 50349d0ccd10Smrg LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols; 50359d0ccd10Smrg for (; symbol->name; ++symbol) 50369d0ccd10Smrg {" 50379d0ccd10Smrg $SED 's/.*/ if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms" 50389d0ccd10Smrg echo >> "$output_objdir/$my_dlsyms" "\ 50399d0ccd10Smrg } 50409d0ccd10Smrg}" 50419d0ccd10Smrg fi 50429d0ccd10Smrg echo >> "$output_objdir/$my_dlsyms" "\ 5043c63293b5SmrgLT_DLSYM_CONST lt_dlsymlist 5044e169010aSmrglt_${my_prefix}_LTX_preloaded_symbols[] = 50459d0ccd10Smrg{ {\"$my_originator\", (void *) 0}," 50469d0ccd10Smrg 50479d0ccd10Smrg if test -s "$nlist"I; then 50489d0ccd10Smrg echo >> "$output_objdir/$my_dlsyms" "\ 50499d0ccd10Smrg {\"@INIT@\", (void *) <_syminit}," 50509d0ccd10Smrg fi 5051e169010aSmrg 5052e169010aSmrg case $need_lib_prefix in 5053e169010aSmrg no) 5054e169010aSmrg eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" 5055e169010aSmrg ;; 5056e169010aSmrg *) 5057e169010aSmrg eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" 5058e169010aSmrg ;; 5059e169010aSmrg esac 5060e8ead290Smrg echo >> "$output_objdir/$my_dlsyms" "\ 5061e169010aSmrg {0, (void *) 0} 5062e169010aSmrg}; 5063e169010aSmrg 5064e169010aSmrg/* This works around a problem in FreeBSD linker */ 5065e169010aSmrg#ifdef FREEBSD_WORKAROUND 5066e169010aSmrgstatic const void *lt_preloaded_setup() { 5067e169010aSmrg return lt_${my_prefix}_LTX_preloaded_symbols; 5068e169010aSmrg} 5069e169010aSmrg#endif 5070e169010aSmrg 5071e169010aSmrg#ifdef __cplusplus 5072e169010aSmrg} 5073e169010aSmrg#endif\ 5074e169010aSmrg" 5075e169010aSmrg } # !$opt_dry_run 5076e169010aSmrg 5077e169010aSmrg pic_flag_for_symtable= 5078e169010aSmrg case "$compile_command " in 5079e169010aSmrg *" -static "*) ;; 5080e169010aSmrg *) 5081e169010aSmrg case $host in 5082e169010aSmrg # compiling the symbol table file with pic_flag works around 5083e169010aSmrg # a FreeBSD bug that causes programs to crash when -lm is 5084e169010aSmrg # linked before any other PIC object. But we must not use 5085e169010aSmrg # pic_flag when linking with -static. The problem exists in 5086e169010aSmrg # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. 5087e6d5e4e0Smrg *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) 5088e169010aSmrg pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; 5089e169010aSmrg *-*-hpux*) 5090e169010aSmrg pic_flag_for_symtable=" $pic_flag" ;; 5091e169010aSmrg *) 50929d0ccd10Smrg $my_pic_p && pic_flag_for_symtable=" $pic_flag" 5093e169010aSmrg ;; 5094e169010aSmrg esac 5095e169010aSmrg ;; 5096e169010aSmrg esac 5097e169010aSmrg symtab_cflags= 5098e169010aSmrg for arg in $LTCFLAGS; do 5099e169010aSmrg case $arg in 5100e169010aSmrg -pie | -fpie | -fPIE) ;; 5101c63293b5Smrg *) func_append symtab_cflags " $arg" ;; 5102e169010aSmrg esac 5103e169010aSmrg done 51047914d74bSmrg 5105e169010aSmrg # Now compile the dynamic symbol file. 5106e169010aSmrg func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' 51077914d74bSmrg 5108e169010aSmrg # Clean up the generated files. 51099d0ccd10Smrg func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"' 5110e169010aSmrg 5111e169010aSmrg # Transform the symbol file into the correct name. 51129d0ccd10Smrg symfileobj=$output_objdir/${my_outputname}S.$objext 5113e169010aSmrg case $host in 5114e169010aSmrg *cygwin* | *mingw* | *cegcc* ) 5115e169010aSmrg if test -f "$output_objdir/$my_outputname.def"; then 5116e8ead290Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 5117e8ead290Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 5118e169010aSmrg else 5119e8ead290Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 5120e8ead290Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 5121e169010aSmrg fi 5122e169010aSmrg ;; 5123e169010aSmrg *) 5124e8ead290Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 5125e8ead290Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 51267914d74bSmrg ;; 51277914d74bSmrg esac 5128e169010aSmrg ;; 5129e169010aSmrg *) 51309d0ccd10Smrg func_fatal_error "unknown suffix for '$my_dlsyms'" 5131e169010aSmrg ;; 5132e169010aSmrg esac 5133e169010aSmrg else 5134e169010aSmrg # We keep going just in case the user didn't refer to 5135e169010aSmrg # lt_preloaded_symbols. The linker will fail if global_symbol_pipe 5136e169010aSmrg # really was required. 5137e169010aSmrg 5138e169010aSmrg # Nullify the symbol file. 5139e8ead290Smrg compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` 5140e8ead290Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` 51417914d74bSmrg fi 5142e169010aSmrg} 51437914d74bSmrg 51449d0ccd10Smrg# func_cygming_gnu_implib_p ARG 51459d0ccd10Smrg# This predicate returns with zero status (TRUE) if 51469d0ccd10Smrg# ARG is a GNU/binutils-style import library. Returns 51479d0ccd10Smrg# with nonzero status (FALSE) otherwise. 51489d0ccd10Smrgfunc_cygming_gnu_implib_p () 51499d0ccd10Smrg{ 51509d0ccd10Smrg $debug_cmd 51519d0ccd10Smrg 51529d0ccd10Smrg func_to_tool_file "$1" func_convert_file_msys_to_w32 51539d0ccd10Smrg 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)$'` 51549d0ccd10Smrg test -n "$func_cygming_gnu_implib_tmp" 51559d0ccd10Smrg} 51569d0ccd10Smrg 51579d0ccd10Smrg# func_cygming_ms_implib_p ARG 51589d0ccd10Smrg# This predicate returns with zero status (TRUE) if 51599d0ccd10Smrg# ARG is an MS-style import library. Returns 51609d0ccd10Smrg# with nonzero status (FALSE) otherwise. 51619d0ccd10Smrgfunc_cygming_ms_implib_p () 51629d0ccd10Smrg{ 51639d0ccd10Smrg $debug_cmd 51649d0ccd10Smrg 51659d0ccd10Smrg func_to_tool_file "$1" func_convert_file_msys_to_w32 51669d0ccd10Smrg func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` 51679d0ccd10Smrg test -n "$func_cygming_ms_implib_tmp" 51689d0ccd10Smrg} 51699d0ccd10Smrg 5170e169010aSmrg# func_win32_libid arg 5171e169010aSmrg# return the library type of file 'arg' 5172e169010aSmrg# 5173e169010aSmrg# Need a lot of goo to handle *both* DLLs and import libs 5174e169010aSmrg# Has to be a shell function in order to 'eat' the argument 5175e169010aSmrg# that is supplied when $file_magic_command is called. 5176e8ead290Smrg# Despite the name, also deal with 64 bit binaries. 5177e169010aSmrgfunc_win32_libid () 5178e169010aSmrg{ 51799d0ccd10Smrg $debug_cmd 51809d0ccd10Smrg 51819d0ccd10Smrg win32_libid_type=unknown 5182e169010aSmrg win32_fileres=`file -L $1 2>/dev/null` 5183e169010aSmrg case $win32_fileres in 5184e169010aSmrg *ar\ archive\ import\ library*) # definitely import 5185e169010aSmrg win32_libid_type="x86 archive import" 5186e169010aSmrg ;; 5187e169010aSmrg *ar\ archive*) # could be an import, or static 5188e8ead290Smrg # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. 5189e169010aSmrg if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | 5190e8ead290Smrg $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then 51919d0ccd10Smrg case $nm_interface in 51929d0ccd10Smrg "MS dumpbin") 51939d0ccd10Smrg if func_cygming_ms_implib_p "$1" || 51949d0ccd10Smrg func_cygming_gnu_implib_p "$1" 51959d0ccd10Smrg then 51969d0ccd10Smrg win32_nmres=import 51979d0ccd10Smrg else 51989d0ccd10Smrg win32_nmres= 51999d0ccd10Smrg fi 52009d0ccd10Smrg ;; 52019d0ccd10Smrg *) 52029d0ccd10Smrg func_to_tool_file "$1" func_convert_file_msys_to_w32 52039d0ccd10Smrg win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | 52049d0ccd10Smrg $SED -n -e ' 5205e169010aSmrg 1,100{ 5206e169010aSmrg / I /{ 52079d0ccd10Smrg s|.*|import| 5208e169010aSmrg p 5209e169010aSmrg q 5210e169010aSmrg } 5211e169010aSmrg }'` 52129d0ccd10Smrg ;; 52139d0ccd10Smrg esac 5214e169010aSmrg case $win32_nmres in 5215e169010aSmrg import*) win32_libid_type="x86 archive import";; 5216e169010aSmrg *) win32_libid_type="x86 archive static";; 5217e169010aSmrg esac 5218e169010aSmrg fi 5219e169010aSmrg ;; 5220e169010aSmrg *DLL*) 5221e169010aSmrg win32_libid_type="x86 DLL" 5222e169010aSmrg ;; 5223e169010aSmrg *executable*) # but shell scripts are "executable" too... 5224e169010aSmrg case $win32_fileres in 5225e169010aSmrg *MS\ Windows\ PE\ Intel*) 5226e169010aSmrg win32_libid_type="x86 DLL" 5227e169010aSmrg ;; 5228e169010aSmrg esac 5229e169010aSmrg ;; 5230e169010aSmrg esac 5231e169010aSmrg $ECHO "$win32_libid_type" 5232e169010aSmrg} 52337914d74bSmrg 5234c63293b5Smrg# func_cygming_dll_for_implib ARG 5235c63293b5Smrg# 5236c63293b5Smrg# Platform-specific function to extract the 5237c63293b5Smrg# name of the DLL associated with the specified 5238c63293b5Smrg# import library ARG. 5239c63293b5Smrg# Invoked by eval'ing the libtool variable 5240c63293b5Smrg# $sharedlib_from_linklib_cmd 5241c63293b5Smrg# Result is available in the variable 5242c63293b5Smrg# $sharedlib_from_linklib_result 5243c63293b5Smrgfunc_cygming_dll_for_implib () 5244c63293b5Smrg{ 52459d0ccd10Smrg $debug_cmd 52469d0ccd10Smrg 5247c63293b5Smrg sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` 5248c63293b5Smrg} 5249c63293b5Smrg 5250c63293b5Smrg# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs 5251c63293b5Smrg# 5252c63293b5Smrg# The is the core of a fallback implementation of a 5253c63293b5Smrg# platform-specific function to extract the name of the 5254c63293b5Smrg# DLL associated with the specified import library LIBNAME. 5255c63293b5Smrg# 5256c63293b5Smrg# SECTION_NAME is either .idata$6 or .idata$7, depending 5257c63293b5Smrg# on the platform and compiler that created the implib. 5258c63293b5Smrg# 5259c63293b5Smrg# Echos the name of the DLL associated with the 5260c63293b5Smrg# specified import library. 5261c63293b5Smrgfunc_cygming_dll_for_implib_fallback_core () 5262c63293b5Smrg{ 52639d0ccd10Smrg $debug_cmd 52649d0ccd10Smrg 5265c63293b5Smrg match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` 5266c63293b5Smrg $OBJDUMP -s --section "$1" "$2" 2>/dev/null | 5267c63293b5Smrg $SED '/^Contents of section '"$match_literal"':/{ 5268c63293b5Smrg # Place marker at beginning of archive member dllname section 5269c63293b5Smrg s/.*/====MARK====/ 5270c63293b5Smrg p 5271c63293b5Smrg d 5272c63293b5Smrg } 5273c63293b5Smrg # These lines can sometimes be longer than 43 characters, but 5274c63293b5Smrg # are always uninteresting 5275c63293b5Smrg /:[ ]*file format pe[i]\{,1\}-/d 5276c63293b5Smrg /^In archive [^:]*:/d 5277c63293b5Smrg # Ensure marker is printed 5278c63293b5Smrg /^====MARK====/p 5279c63293b5Smrg # Remove all lines with less than 43 characters 5280c63293b5Smrg /^.\{43\}/!d 5281c63293b5Smrg # From remaining lines, remove first 43 characters 5282c63293b5Smrg s/^.\{43\}//' | 5283c63293b5Smrg $SED -n ' 5284c63293b5Smrg # Join marker and all lines until next marker into a single line 5285c63293b5Smrg /^====MARK====/ b para 5286c63293b5Smrg H 5287c63293b5Smrg $ b para 5288c63293b5Smrg b 5289c63293b5Smrg :para 5290c63293b5Smrg x 5291c63293b5Smrg s/\n//g 5292c63293b5Smrg # Remove the marker 5293c63293b5Smrg s/^====MARK====// 5294c63293b5Smrg # Remove trailing dots and whitespace 5295c63293b5Smrg s/[\. \t]*$// 5296c63293b5Smrg # Print 5297c63293b5Smrg /./p' | 5298c63293b5Smrg # we now have a list, one entry per line, of the stringified 5299c63293b5Smrg # contents of the appropriate section of all members of the 53009d0ccd10Smrg # archive that possess that section. Heuristic: eliminate 53019d0ccd10Smrg # all those that have a first or second character that is 5302c63293b5Smrg # a '.' (that is, objdump's representation of an unprintable 5303c63293b5Smrg # character.) This should work for all archives with less than 5304c63293b5Smrg # 0x302f exports -- but will fail for DLLs whose name actually 5305c63293b5Smrg # begins with a literal '.' or a single character followed by 5306c63293b5Smrg # a '.'. 5307c63293b5Smrg # 5308c63293b5Smrg # Of those that remain, print the first one. 5309c63293b5Smrg $SED -e '/^\./d;/^.\./d;q' 5310c63293b5Smrg} 5311c63293b5Smrg 5312c63293b5Smrg# func_cygming_dll_for_implib_fallback ARG 5313c63293b5Smrg# Platform-specific function to extract the 5314c63293b5Smrg# name of the DLL associated with the specified 5315c63293b5Smrg# import library ARG. 5316c63293b5Smrg# 5317c63293b5Smrg# This fallback implementation is for use when $DLLTOOL 5318c63293b5Smrg# does not support the --identify-strict option. 5319c63293b5Smrg# Invoked by eval'ing the libtool variable 5320c63293b5Smrg# $sharedlib_from_linklib_cmd 5321c63293b5Smrg# Result is available in the variable 5322c63293b5Smrg# $sharedlib_from_linklib_result 5323c63293b5Smrgfunc_cygming_dll_for_implib_fallback () 5324c63293b5Smrg{ 53259d0ccd10Smrg $debug_cmd 53269d0ccd10Smrg 53279d0ccd10Smrg if func_cygming_gnu_implib_p "$1"; then 5328c63293b5Smrg # binutils import library 5329c63293b5Smrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` 53309d0ccd10Smrg elif func_cygming_ms_implib_p "$1"; then 5331c63293b5Smrg # ms-generated import library 5332c63293b5Smrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` 5333c63293b5Smrg else 5334c63293b5Smrg # unknown 53359d0ccd10Smrg sharedlib_from_linklib_result= 5336c63293b5Smrg fi 5337c63293b5Smrg} 53387914d74bSmrg 53397914d74bSmrg 5340e169010aSmrg# func_extract_an_archive dir oldlib 5341e169010aSmrgfunc_extract_an_archive () 5342e169010aSmrg{ 53439d0ccd10Smrg $debug_cmd 53449d0ccd10Smrg 53459d0ccd10Smrg f_ex_an_ar_dir=$1; shift 53469d0ccd10Smrg f_ex_an_ar_oldlib=$1 53479d0ccd10Smrg if test yes = "$lock_old_archive_extraction"; then 5348e8ead290Smrg lockfile=$f_ex_an_ar_oldlib.lock 5349e8ead290Smrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 5350e8ead290Smrg func_echo "Waiting for $lockfile to be removed" 5351e8ead290Smrg sleep 2 5352e8ead290Smrg done 5353e8ead290Smrg fi 5354e8ead290Smrg func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ 5355e8ead290Smrg 'stat=$?; rm -f "$lockfile"; exit $stat' 53569d0ccd10Smrg if test yes = "$lock_old_archive_extraction"; then 5357e8ead290Smrg $opt_dry_run || rm -f "$lockfile" 5358e8ead290Smrg fi 5359e169010aSmrg if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then 5360e169010aSmrg : 5361e169010aSmrg else 5362e169010aSmrg func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 5363e169010aSmrg fi 5364e169010aSmrg} 53657914d74bSmrg 53667914d74bSmrg 5367e169010aSmrg# func_extract_archives gentop oldlib ... 5368e169010aSmrgfunc_extract_archives () 5369e169010aSmrg{ 53709d0ccd10Smrg $debug_cmd 53719d0ccd10Smrg 53729d0ccd10Smrg my_gentop=$1; shift 5373e169010aSmrg my_oldlibs=${1+"$@"} 53749d0ccd10Smrg my_oldobjs= 53759d0ccd10Smrg my_xlib= 53769d0ccd10Smrg my_xabs= 53779d0ccd10Smrg my_xdir= 53787914d74bSmrg 5379e169010aSmrg for my_xlib in $my_oldlibs; do 5380e169010aSmrg # Extract the objects. 5381e169010aSmrg case $my_xlib in 53829d0ccd10Smrg [\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;; 5383e169010aSmrg *) my_xabs=`pwd`"/$my_xlib" ;; 5384e169010aSmrg esac 5385e169010aSmrg func_basename "$my_xlib" 53869d0ccd10Smrg my_xlib=$func_basename_result 5387e169010aSmrg my_xlib_u=$my_xlib 5388e169010aSmrg while :; do 5389e169010aSmrg case " $extracted_archives " in 5390e169010aSmrg *" $my_xlib_u "*) 5391e169010aSmrg func_arith $extracted_serial + 1 5392e169010aSmrg extracted_serial=$func_arith_result 5393e169010aSmrg my_xlib_u=lt$extracted_serial-$my_xlib ;; 5394e169010aSmrg *) break ;; 5395e169010aSmrg esac 5396e169010aSmrg done 5397e169010aSmrg extracted_archives="$extracted_archives $my_xlib_u" 53989d0ccd10Smrg my_xdir=$my_gentop/$my_xlib_u 53997914d74bSmrg 5400e169010aSmrg func_mkdir_p "$my_xdir" 54017914d74bSmrg 5402e169010aSmrg case $host in 5403e169010aSmrg *-darwin*) 5404e169010aSmrg func_verbose "Extracting $my_xabs" 5405e169010aSmrg # Do not bother doing anything if just a dry run 5406e169010aSmrg $opt_dry_run || { 5407e169010aSmrg darwin_orig_dir=`pwd` 5408e169010aSmrg cd $my_xdir || exit $? 5409e169010aSmrg darwin_archive=$my_xabs 5410e169010aSmrg darwin_curdir=`pwd` 54119d0ccd10Smrg func_basename "$darwin_archive" 54129d0ccd10Smrg darwin_base_archive=$func_basename_result 5413e169010aSmrg darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` 5414e169010aSmrg if test -n "$darwin_arches"; then 5415e169010aSmrg darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` 5416e169010aSmrg darwin_arch= 5417e169010aSmrg func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" 54189d0ccd10Smrg for darwin_arch in $darwin_arches; do 54199d0ccd10Smrg func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch" 54209d0ccd10Smrg $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive" 54219d0ccd10Smrg cd "unfat-$$/$darwin_base_archive-$darwin_arch" 54229d0ccd10Smrg func_extract_an_archive "`pwd`" "$darwin_base_archive" 5423e169010aSmrg cd "$darwin_curdir" 54249d0ccd10Smrg $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" 5425e169010aSmrg done # $darwin_arches 5426e169010aSmrg ## Okay now we've a bunch of thin objects, gotta fatten them up :) 54279d0ccd10Smrg darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$sed_basename" | sort -u` 5428e169010aSmrg darwin_file= 5429e169010aSmrg darwin_files= 5430e169010aSmrg for darwin_file in $darwin_filelist; do 5431e8ead290Smrg darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` 5432e169010aSmrg $LIPO -create -output "$darwin_file" $darwin_files 5433e169010aSmrg done # $darwin_filelist 5434e169010aSmrg $RM -rf unfat-$$ 5435e169010aSmrg cd "$darwin_orig_dir" 5436e169010aSmrg else 5437e169010aSmrg cd $darwin_orig_dir 5438e169010aSmrg func_extract_an_archive "$my_xdir" "$my_xabs" 5439e169010aSmrg fi # $darwin_arches 5440e169010aSmrg } # !$opt_dry_run 5441e169010aSmrg ;; 5442e169010aSmrg *) 5443e169010aSmrg func_extract_an_archive "$my_xdir" "$my_xabs" 5444e169010aSmrg ;; 54457914d74bSmrg esac 5446e8ead290Smrg my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` 5447e169010aSmrg done 54487914d74bSmrg 54499d0ccd10Smrg func_extract_archives_result=$my_oldobjs 5450e169010aSmrg} 54517914d74bSmrg 54527914d74bSmrg 5453e8ead290Smrg# func_emit_wrapper [arg=no] 5454e8ead290Smrg# 5455e8ead290Smrg# Emit a libtool wrapper script on stdout. 5456e8ead290Smrg# Don't directly open a file because we may want to 5457e8ead290Smrg# incorporate the script contents within a cygwin/mingw 5458e8ead290Smrg# wrapper executable. Must ONLY be called from within 5459e8ead290Smrg# func_mode_link because it depends on a number of variables 5460e8ead290Smrg# set therein. 5461e169010aSmrg# 5462e8ead290Smrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR 5463e8ead290Smrg# variable will take. If 'yes', then the emitted script 54649d0ccd10Smrg# will assume that the directory where it is stored is 5465e8ead290Smrg# the $objdir directory. This is a cygwin/mingw-specific 5466e8ead290Smrg# behavior. 5467e8ead290Smrgfunc_emit_wrapper () 5468e169010aSmrg{ 5469e8ead290Smrg func_emit_wrapper_arg1=${1-no} 54707914d74bSmrg 5471e169010aSmrg $ECHO "\ 5472e169010aSmrg#! $SHELL 54737914d74bSmrg 5474e169010aSmrg# $output - temporary wrapper script for $objdir/$outputname 54759d0ccd10Smrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 5476e169010aSmrg# 5477e169010aSmrg# The $output program cannot be directly executed until all the libtool 5478e169010aSmrg# libraries that it depends on are installed. 5479e169010aSmrg# 5480e169010aSmrg# This wrapper script should never be moved out of the build directory. 5481e169010aSmrg# If it is, it will not operate correctly. 54827914d74bSmrg 5483e169010aSmrg# Sed substitution that helps us do robust quoting. It backslashifies 5484e169010aSmrg# metacharacters that are still active within double-quoted strings. 5485e169010aSmrgsed_quote_subst='$sed_quote_subst' 54867914d74bSmrg 5487e169010aSmrg# Be Bourne compatible 5488e169010aSmrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then 5489e169010aSmrg emulate sh 5490e169010aSmrg NULLCMD=: 5491e169010aSmrg # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which 5492e169010aSmrg # is contrary to our usage. Disable this feature. 5493e169010aSmrg alias -g '\${1+\"\$@\"}'='\"\$@\"' 5494e169010aSmrg setopt NO_GLOB_SUBST 5495e169010aSmrgelse 5496e169010aSmrg case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac 5497e169010aSmrgfi 5498e169010aSmrgBIN_SH=xpg4; export BIN_SH # for Tru64 5499e169010aSmrgDUALCASE=1; export DUALCASE # for MKS sh 55007914d74bSmrg 5501e169010aSmrg# The HP-UX ksh and POSIX shell print the target directory to stdout 5502e169010aSmrg# if CDPATH is set. 5503e169010aSmrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 55047914d74bSmrg 5505e169010aSmrgrelink_command=\"$relink_command\" 55067914d74bSmrg 5507e169010aSmrg# This environment variable determines our operation mode. 5508e169010aSmrgif test \"\$libtool_install_magic\" = \"$magic\"; then 5509e169010aSmrg # install mode needs the following variables: 5510e169010aSmrg generated_by_libtool_version='$macro_version' 5511e169010aSmrg notinst_deplibs='$notinst_deplibs' 5512e169010aSmrgelse 5513e169010aSmrg # When we are sourced in execute mode, \$file and \$ECHO are already set. 5514e169010aSmrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 5515e8ead290Smrg file=\"\$0\"" 5516e8ead290Smrg 55170ea508b1Smrg func_quote_arg pretty "$ECHO" 55180ea508b1Smrg qECHO=$func_quote_arg_result 5519e8ead290Smrg $ECHO "\ 5520e8ead290Smrg 5521e8ead290Smrg# A function that is used when there is no print builtin or printf. 5522e8ead290Smrgfunc_fallback_echo () 5523e8ead290Smrg{ 5524e8ead290Smrg eval 'cat <<_LTECHO_EOF 5525e8ead290Smrg\$1 5526e8ead290Smrg_LTECHO_EOF' 5527e8ead290Smrg} 55280ea508b1Smrg ECHO=$qECHO 5529e8ead290Smrg fi 5530e8ead290Smrg 5531e8ead290Smrg# Very basic option parsing. These options are (a) specific to 5532e8ead290Smrg# the libtool wrapper, (b) are identical between the wrapper 55339d0ccd10Smrg# /script/ and the wrapper /executable/ that is used only on 5534e8ead290Smrg# windows platforms, and (c) all begin with the string "--lt-" 55359d0ccd10Smrg# (application programs are unlikely to have options that match 5536e8ead290Smrg# this pattern). 5537e8ead290Smrg# 5538e8ead290Smrg# There are only two supported options: --lt-debug and 5539e8ead290Smrg# --lt-dump-script. There is, deliberately, no --lt-help. 5540e8ead290Smrg# 5541e8ead290Smrg# The first argument to this parsing function should be the 5542e8ead290Smrg# script's $0 value, followed by "$@". 5543e8ead290Smrglt_option_debug= 5544e8ead290Smrgfunc_parse_lt_options () 5545e8ead290Smrg{ 5546e8ead290Smrg lt_script_arg0=\$0 5547e8ead290Smrg shift 5548e8ead290Smrg for lt_opt 5549e8ead290Smrg do 5550e8ead290Smrg case \"\$lt_opt\" in 5551e8ead290Smrg --lt-debug) lt_option_debug=1 ;; 5552e8ead290Smrg --lt-dump-script) 5553e8ead290Smrg lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` 5554e8ead290Smrg test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. 5555e8ead290Smrg lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` 5556e8ead290Smrg cat \"\$lt_dump_D/\$lt_dump_F\" 5557e8ead290Smrg exit 0 5558e8ead290Smrg ;; 5559e8ead290Smrg --lt-*) 5560e8ead290Smrg \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 5561e8ead290Smrg exit 1 5562e8ead290Smrg ;; 5563e8ead290Smrg esac 5564e8ead290Smrg done 5565e8ead290Smrg 5566e8ead290Smrg # Print the debug banner immediately: 5567e8ead290Smrg if test -n \"\$lt_option_debug\"; then 55689d0ccd10Smrg echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2 5569e8ead290Smrg fi 5570e8ead290Smrg} 5571e8ead290Smrg 5572e8ead290Smrg# Used when --lt-debug. Prints its arguments to stdout 5573e8ead290Smrg# (redirection is the responsibility of the caller) 5574e8ead290Smrgfunc_lt_dump_args () 5575e8ead290Smrg{ 5576e8ead290Smrg lt_dump_args_N=1; 5577e8ead290Smrg for lt_arg 5578e8ead290Smrg do 55799d0ccd10Smrg \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\" 5580e8ead290Smrg lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` 5581e8ead290Smrg done 5582e8ead290Smrg} 5583e8ead290Smrg 5584e8ead290Smrg# Core function for launching the target application 5585e8ead290Smrgfunc_exec_program_core () 5586e8ead290Smrg{ 5587e169010aSmrg" 5588e8ead290Smrg case $host in 5589e8ead290Smrg # Backslashes separate directories on plain windows 5590e8ead290Smrg *-*-mingw | *-*-os2* | *-cegcc*) 5591e8ead290Smrg $ECHO "\ 5592e8ead290Smrg if test -n \"\$lt_option_debug\"; then 55939d0ccd10Smrg \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2 5594e8ead290Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 5595e8ead290Smrg fi 5596e8ead290Smrg exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} 5597e8ead290Smrg" 5598e8ead290Smrg ;; 5599e8ead290Smrg 5600e8ead290Smrg *) 5601e8ead290Smrg $ECHO "\ 5602e8ead290Smrg if test -n \"\$lt_option_debug\"; then 56039d0ccd10Smrg \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2 5604e8ead290Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 5605e8ead290Smrg fi 5606e8ead290Smrg exec \"\$progdir/\$program\" \${1+\"\$@\"} 5607e8ead290Smrg" 5608e8ead290Smrg ;; 5609e8ead290Smrg esac 5610e8ead290Smrg $ECHO "\ 5611e8ead290Smrg \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 5612e8ead290Smrg exit 1 5613e8ead290Smrg} 5614e8ead290Smrg 5615e8ead290Smrg# A function to encapsulate launching the target application 5616e8ead290Smrg# Strips options in the --lt-* namespace from \$@ and 5617e8ead290Smrg# launches target application with the remaining arguments. 5618e8ead290Smrgfunc_exec_program () 5619e8ead290Smrg{ 5620e6d5e4e0Smrg case \" \$* \" in 5621e6d5e4e0Smrg *\\ --lt-*) 5622e6d5e4e0Smrg for lt_wr_arg 5623e6d5e4e0Smrg do 5624e6d5e4e0Smrg case \$lt_wr_arg in 5625e6d5e4e0Smrg --lt-*) ;; 5626e6d5e4e0Smrg *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; 5627e6d5e4e0Smrg esac 5628e6d5e4e0Smrg shift 5629e6d5e4e0Smrg done ;; 5630e6d5e4e0Smrg esac 5631e8ead290Smrg func_exec_program_core \${1+\"\$@\"} 5632e8ead290Smrg} 5633e8ead290Smrg 5634e8ead290Smrg # Parse options 5635e8ead290Smrg func_parse_lt_options \"\$0\" \${1+\"\$@\"} 56367914d74bSmrg 5637e169010aSmrg # Find the directory that this script lives in. 5638e8ead290Smrg thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` 5639e169010aSmrg test \"x\$thisdir\" = \"x\$file\" && thisdir=. 56407914d74bSmrg 5641e169010aSmrg # Follow symbolic links until we get to the real thisdir. 5642e8ead290Smrg file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` 5643e169010aSmrg while test -n \"\$file\"; do 5644e8ead290Smrg destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` 56457914d74bSmrg 5646e169010aSmrg # If there was a directory component, then change thisdir. 5647e169010aSmrg if test \"x\$destdir\" != \"x\$file\"; then 5648e169010aSmrg case \"\$destdir\" in 5649e169010aSmrg [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; 5650e169010aSmrg *) thisdir=\"\$thisdir/\$destdir\" ;; 5651e169010aSmrg esac 5652e169010aSmrg fi 56537914d74bSmrg 5654e8ead290Smrg file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` 5655e8ead290Smrg file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` 5656e169010aSmrg done 56577914d74bSmrg 5658e169010aSmrg # Usually 'no', except on cygwin/mingw when embedded into 5659e169010aSmrg # the cwrapper. 5660e8ead290Smrg WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 5661e169010aSmrg if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then 5662e169010aSmrg # special case for '.' 5663e169010aSmrg if test \"\$thisdir\" = \".\"; then 5664e169010aSmrg thisdir=\`pwd\` 5665e169010aSmrg fi 5666e169010aSmrg # remove .libs from thisdir 5667e169010aSmrg case \"\$thisdir\" in 5668e8ead290Smrg *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; 5669e169010aSmrg $objdir ) thisdir=. ;; 5670e169010aSmrg esac 5671e169010aSmrg fi 56727914d74bSmrg 5673e169010aSmrg # Try to get the absolute directory name. 5674e169010aSmrg absdir=\`cd \"\$thisdir\" && pwd\` 5675e169010aSmrg test -n \"\$absdir\" && thisdir=\"\$absdir\" 5676e169010aSmrg" 56777914d74bSmrg 56789d0ccd10Smrg if test yes = "$fast_install"; then 5679e169010aSmrg $ECHO "\ 5680e169010aSmrg program=lt-'$outputname'$exeext 5681e169010aSmrg progdir=\"\$thisdir/$objdir\" 56827914d74bSmrg 5683e169010aSmrg if test ! -f \"\$progdir/\$program\" || 56849d0ccd10Smrg { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\ 5685e169010aSmrg test \"X\$file\" != \"X\$progdir/\$program\"; }; then 56867914d74bSmrg 5687e169010aSmrg file=\"\$\$-\$program\" 56887914d74bSmrg 5689e169010aSmrg if test ! -d \"\$progdir\"; then 5690e169010aSmrg $MKDIR \"\$progdir\" 5691e169010aSmrg else 5692e169010aSmrg $RM \"\$progdir/\$file\" 5693e169010aSmrg fi" 56947914d74bSmrg 5695e169010aSmrg $ECHO "\ 56967914d74bSmrg 5697e169010aSmrg # relink executable if necessary 5698e169010aSmrg if test -n \"\$relink_command\"; then 5699e169010aSmrg if relink_command_output=\`eval \$relink_command 2>&1\`; then : 5700e169010aSmrg else 57019d0ccd10Smrg \$ECHO \"\$relink_command_output\" >&2 5702e169010aSmrg $RM \"\$progdir/\$file\" 5703e169010aSmrg exit 1 5704e169010aSmrg fi 5705e169010aSmrg fi 57067914d74bSmrg 5707e169010aSmrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || 5708e169010aSmrg { $RM \"\$progdir/\$program\"; 5709e169010aSmrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } 5710e169010aSmrg $RM \"\$progdir/\$file\" 5711e169010aSmrg fi" 5712e169010aSmrg else 5713e169010aSmrg $ECHO "\ 5714e169010aSmrg program='$outputname' 5715e169010aSmrg progdir=\"\$thisdir/$objdir\" 5716e169010aSmrg" 5717e169010aSmrg fi 57187914d74bSmrg 5719e169010aSmrg $ECHO "\ 57207914d74bSmrg 5721e169010aSmrg if test -f \"\$progdir/\$program\"; then" 57227914d74bSmrg 5723c63293b5Smrg # fixup the dll searchpath if we need to. 5724c63293b5Smrg # 5725c63293b5Smrg # Fix the DLL searchpath if we need to. Do this before prepending 5726c63293b5Smrg # to shlibpath, because on Windows, both are PATH and uninstalled 5727c63293b5Smrg # libraries must come first. 5728c63293b5Smrg if test -n "$dllsearchpath"; then 5729c63293b5Smrg $ECHO "\ 5730c63293b5Smrg # Add the dll search path components to the executable PATH 5731c63293b5Smrg PATH=$dllsearchpath:\$PATH 5732c63293b5Smrg" 5733c63293b5Smrg fi 5734c63293b5Smrg 5735e169010aSmrg # Export our shlibpath_var if we have one. 57369d0ccd10Smrg if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 5737e169010aSmrg $ECHO "\ 5738e169010aSmrg # Add our own library path to $shlibpath_var 5739e169010aSmrg $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" 57407914d74bSmrg 5741e169010aSmrg # Some systems cannot cope with colon-terminated $shlibpath_var 5742e169010aSmrg # The second colon is a workaround for a bug in BeOS R4 sed 5743e8ead290Smrg $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` 57447914d74bSmrg 5745e169010aSmrg export $shlibpath_var 5746e169010aSmrg" 57477914d74bSmrg fi 57487914d74bSmrg 5749e169010aSmrg $ECHO "\ 5750e169010aSmrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 5751e169010aSmrg # Run the actual program with our arguments. 5752e8ead290Smrg func_exec_program \${1+\"\$@\"} 5753e169010aSmrg fi 5754e169010aSmrg else 5755e169010aSmrg # The program doesn't exist. 57569d0ccd10Smrg \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2 5757e169010aSmrg \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 5758e8ead290Smrg \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 5759e169010aSmrg exit 1 5760e169010aSmrg fi 5761e169010aSmrgfi\ 5762e169010aSmrg" 5763e169010aSmrg} 57647914d74bSmrg 57657914d74bSmrg 5766e169010aSmrg# func_emit_cwrapperexe_src 5767e169010aSmrg# emit the source code for a wrapper executable on stdout 5768e169010aSmrg# Must ONLY be called from within func_mode_link because 5769e169010aSmrg# it depends on a number of variable set therein. 5770e169010aSmrgfunc_emit_cwrapperexe_src () 5771e169010aSmrg{ 5772e169010aSmrg cat <<EOF 57737914d74bSmrg 5774e169010aSmrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname 57759d0ccd10Smrg Generated by $PROGRAM (GNU $PACKAGE) $VERSION 57767914d74bSmrg 5777e169010aSmrg The $output program cannot be directly executed until all the libtool 5778e169010aSmrg libraries that it depends on are installed. 57797914d74bSmrg 5780e169010aSmrg This wrapper executable should never be moved out of the build directory. 5781e169010aSmrg If it is, it will not operate correctly. 5782e169010aSmrg*/ 5783e169010aSmrgEOF 5784e169010aSmrg cat <<"EOF" 5785e8ead290Smrg#ifdef _MSC_VER 5786e8ead290Smrg# define _CRT_SECURE_NO_DEPRECATE 1 5787e8ead290Smrg#endif 5788e169010aSmrg#include <stdio.h> 5789e169010aSmrg#include <stdlib.h> 5790e169010aSmrg#ifdef _MSC_VER 5791e169010aSmrg# include <direct.h> 5792e169010aSmrg# include <process.h> 5793e169010aSmrg# include <io.h> 5794e169010aSmrg#else 5795e169010aSmrg# include <unistd.h> 5796e169010aSmrg# include <stdint.h> 5797e169010aSmrg# ifdef __CYGWIN__ 5798e169010aSmrg# include <io.h> 5799e169010aSmrg# endif 5800e169010aSmrg#endif 5801e169010aSmrg#include <malloc.h> 5802e169010aSmrg#include <stdarg.h> 5803e169010aSmrg#include <assert.h> 5804e169010aSmrg#include <string.h> 5805e169010aSmrg#include <ctype.h> 5806e169010aSmrg#include <errno.h> 5807e169010aSmrg#include <fcntl.h> 5808e169010aSmrg#include <sys/stat.h> 5809e169010aSmrg 58109d0ccd10Smrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 58119d0ccd10Smrg 5812e8ead290Smrg/* declarations of non-ANSI functions */ 58139d0ccd10Smrg#if defined __MINGW32__ 5814e8ead290Smrg# ifdef __STRICT_ANSI__ 5815e8ead290Smrgint _putenv (const char *); 5816e8ead290Smrg# endif 58179d0ccd10Smrg#elif defined __CYGWIN__ 5818e8ead290Smrg# ifdef __STRICT_ANSI__ 5819e8ead290Smrgchar *realpath (const char *, char *); 5820e8ead290Smrgint putenv (char *); 5821e8ead290Smrgint setenv (const char *, const char *, int); 5822e8ead290Smrg# endif 58239d0ccd10Smrg/* #elif defined other_platform || defined ... */ 5824e8ead290Smrg#endif 5825e8ead290Smrg 5826e8ead290Smrg/* portability defines, excluding path handling macros */ 58279d0ccd10Smrg#if defined _MSC_VER 5828e8ead290Smrg# define setmode _setmode 5829e8ead290Smrg# define stat _stat 5830e8ead290Smrg# define chmod _chmod 5831e8ead290Smrg# define getcwd _getcwd 5832e8ead290Smrg# define putenv _putenv 5833e8ead290Smrg# define S_IXUSR _S_IEXEC 58349d0ccd10Smrg#elif defined __MINGW32__ 5835e8ead290Smrg# define setmode _setmode 5836e8ead290Smrg# define stat _stat 5837e8ead290Smrg# define chmod _chmod 5838e8ead290Smrg# define getcwd _getcwd 5839e8ead290Smrg# define putenv _putenv 58409d0ccd10Smrg#elif defined __CYGWIN__ 5841e8ead290Smrg# define HAVE_SETENV 5842e8ead290Smrg# define FOPEN_WB "wb" 58439d0ccd10Smrg/* #elif defined other platforms ... */ 5844e8ead290Smrg#endif 5845e8ead290Smrg 58469d0ccd10Smrg#if defined PATH_MAX 5847e169010aSmrg# define LT_PATHMAX PATH_MAX 58489d0ccd10Smrg#elif defined MAXPATHLEN 5849e169010aSmrg# define LT_PATHMAX MAXPATHLEN 5850e169010aSmrg#else 5851e169010aSmrg# define LT_PATHMAX 1024 5852e169010aSmrg#endif 5853e169010aSmrg 5854e169010aSmrg#ifndef S_IXOTH 5855e169010aSmrg# define S_IXOTH 0 5856e169010aSmrg#endif 5857e169010aSmrg#ifndef S_IXGRP 5858e169010aSmrg# define S_IXGRP 0 5859e169010aSmrg#endif 5860e169010aSmrg 5861e8ead290Smrg/* path handling portability macros */ 5862e169010aSmrg#ifndef DIR_SEPARATOR 5863e169010aSmrg# define DIR_SEPARATOR '/' 5864e169010aSmrg# define PATH_SEPARATOR ':' 5865e169010aSmrg#endif 5866e169010aSmrg 58679d0ccd10Smrg#if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \ 58689d0ccd10Smrg defined __OS2__ 5869e169010aSmrg# define HAVE_DOS_BASED_FILE_SYSTEM 5870e169010aSmrg# define FOPEN_WB "wb" 5871e169010aSmrg# ifndef DIR_SEPARATOR_2 5872e169010aSmrg# define DIR_SEPARATOR_2 '\\' 5873e169010aSmrg# endif 5874e169010aSmrg# ifndef PATH_SEPARATOR_2 5875e169010aSmrg# define PATH_SEPARATOR_2 ';' 5876e169010aSmrg# endif 5877e169010aSmrg#endif 5878e169010aSmrg 5879e169010aSmrg#ifndef DIR_SEPARATOR_2 5880e169010aSmrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) 5881e169010aSmrg#else /* DIR_SEPARATOR_2 */ 5882e169010aSmrg# define IS_DIR_SEPARATOR(ch) \ 5883e169010aSmrg (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) 5884e169010aSmrg#endif /* DIR_SEPARATOR_2 */ 5885e169010aSmrg 5886e169010aSmrg#ifndef PATH_SEPARATOR_2 5887e169010aSmrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) 5888e169010aSmrg#else /* PATH_SEPARATOR_2 */ 5889e169010aSmrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) 5890e169010aSmrg#endif /* PATH_SEPARATOR_2 */ 5891e169010aSmrg 5892e169010aSmrg#ifndef FOPEN_WB 5893e169010aSmrg# define FOPEN_WB "w" 5894e169010aSmrg#endif 5895e169010aSmrg#ifndef _O_BINARY 5896e169010aSmrg# define _O_BINARY 0 5897e169010aSmrg#endif 5898e169010aSmrg 5899e169010aSmrg#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) 5900e169010aSmrg#define XFREE(stale) do { \ 59019d0ccd10Smrg if (stale) { free (stale); stale = 0; } \ 5902e169010aSmrg} while (0) 5903e169010aSmrg 59049d0ccd10Smrg#if defined LT_DEBUGWRAPPER 5905e8ead290Smrgstatic int lt_debug = 1; 5906e169010aSmrg#else 5907e8ead290Smrgstatic int lt_debug = 0; 5908e169010aSmrg#endif 5909e169010aSmrg 5910e8ead290Smrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ 5911e169010aSmrg 5912e169010aSmrgvoid *xmalloc (size_t num); 5913e169010aSmrgchar *xstrdup (const char *string); 5914e169010aSmrgconst char *base_name (const char *name); 5915e169010aSmrgchar *find_executable (const char *wrapper); 5916e169010aSmrgchar *chase_symlinks (const char *pathspec); 5917e169010aSmrgint make_executable (const char *path); 5918e169010aSmrgint check_executable (const char *path); 5919e169010aSmrgchar *strendzap (char *str, const char *pat); 5920e8ead290Smrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...); 5921e8ead290Smrgvoid lt_fatal (const char *file, int line, const char *message, ...); 5922e8ead290Smrgstatic const char *nonnull (const char *s); 5923e8ead290Smrgstatic const char *nonempty (const char *s); 5924e169010aSmrgvoid lt_setenv (const char *name, const char *value); 5925e169010aSmrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end); 5926e169010aSmrgvoid lt_update_exe_path (const char *name, const char *value); 5927e169010aSmrgvoid lt_update_lib_path (const char *name, const char *value); 5928e8ead290Smrgchar **prepare_spawn (char **argv); 5929e8ead290Smrgvoid lt_dump_script (FILE *f); 5930e169010aSmrgEOF 5931e169010aSmrg 5932e169010aSmrg cat <<EOF 59339d0ccd10Smrg#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5) 59349d0ccd10Smrg# define externally_visible volatile 59359d0ccd10Smrg#else 59369d0ccd10Smrg# define externally_visible __attribute__((externally_visible)) volatile 59379d0ccd10Smrg#endif 59389d0ccd10Smrgexternally_visible const char * MAGIC_EXE = "$magic_exe"; 5939e169010aSmrgconst char * LIB_PATH_VARNAME = "$shlibpath_var"; 5940e169010aSmrgEOF 5941e169010aSmrg 59429d0ccd10Smrg if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 5943c63293b5Smrg func_to_host_path "$temp_rpath" 5944e169010aSmrg cat <<EOF 5945c63293b5Smrgconst char * LIB_PATH_VALUE = "$func_to_host_path_result"; 59467914d74bSmrgEOF 59477914d74bSmrg else 5948e169010aSmrg cat <<"EOF" 5949e169010aSmrgconst char * LIB_PATH_VALUE = ""; 5950e169010aSmrgEOF 59517914d74bSmrg fi 5952e169010aSmrg 5953e169010aSmrg if test -n "$dllsearchpath"; then 5954c63293b5Smrg func_to_host_path "$dllsearchpath:" 5955e169010aSmrg cat <<EOF 5956e169010aSmrgconst char * EXE_PATH_VARNAME = "PATH"; 5957c63293b5Smrgconst char * EXE_PATH_VALUE = "$func_to_host_path_result"; 5958e169010aSmrgEOF 59597914d74bSmrg else 5960e169010aSmrg cat <<"EOF" 5961e169010aSmrgconst char * EXE_PATH_VARNAME = ""; 5962e169010aSmrgconst char * EXE_PATH_VALUE = ""; 5963e169010aSmrgEOF 59647914d74bSmrg fi 5965e169010aSmrg 59669d0ccd10Smrg if test yes = "$fast_install"; then 5967e169010aSmrg cat <<EOF 5968e169010aSmrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */ 5969e169010aSmrgEOF 59707914d74bSmrg else 5971e169010aSmrg cat <<EOF 5972e169010aSmrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */ 5973e169010aSmrgEOF 59747914d74bSmrg fi 59757914d74bSmrg 59767914d74bSmrg 5977e169010aSmrg cat <<"EOF" 59787914d74bSmrg 5979e169010aSmrg#define LTWRAPPER_OPTION_PREFIX "--lt-" 59807914d74bSmrg 5981e169010aSmrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX; 5982e169010aSmrgstatic const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script"; 5983e8ead290Smrgstatic const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug"; 59847914d74bSmrg 5985e169010aSmrgint 5986e169010aSmrgmain (int argc, char *argv[]) 5987e169010aSmrg{ 5988e169010aSmrg char **newargz; 5989e169010aSmrg int newargc; 5990e169010aSmrg char *tmp_pathspec; 5991e169010aSmrg char *actual_cwrapper_path; 5992e169010aSmrg char *actual_cwrapper_name; 5993e169010aSmrg char *target_name; 5994e169010aSmrg char *lt_argv_zero; 59959d0ccd10Smrg int rval = 127; 59967914d74bSmrg 5997e169010aSmrg int i; 59987914d74bSmrg 5999e169010aSmrg program_name = (char *) xstrdup (base_name (argv[0])); 60009d0ccd10Smrg newargz = XMALLOC (char *, (size_t) argc + 1); 60017914d74bSmrg 6002e8ead290Smrg /* very simple arg parsing; don't want to rely on getopt 6003e8ead290Smrg * also, copy all non cwrapper options to newargz, except 6004e8ead290Smrg * argz[0], which is handled differently 6005e8ead290Smrg */ 6006e8ead290Smrg newargc=0; 6007e169010aSmrg for (i = 1; i < argc; i++) 6008e169010aSmrg { 60099d0ccd10Smrg if (STREQ (argv[i], dumpscript_opt)) 6010e169010aSmrg { 6011e169010aSmrgEOF 60129d0ccd10Smrg case $host in 6013e169010aSmrg *mingw* | *cygwin* ) 6014e169010aSmrg # make stdout use "unix" line endings 6015e169010aSmrg echo " setmode(1,_O_BINARY);" 6016e169010aSmrg ;; 6017e169010aSmrg esac 60187914d74bSmrg 6019e169010aSmrg cat <<"EOF" 6020e8ead290Smrg lt_dump_script (stdout); 6021e169010aSmrg return 0; 6022e169010aSmrg } 60239d0ccd10Smrg if (STREQ (argv[i], debug_opt)) 6024e8ead290Smrg { 6025e8ead290Smrg lt_debug = 1; 6026e8ead290Smrg continue; 6027e8ead290Smrg } 60289d0ccd10Smrg if (STREQ (argv[i], ltwrapper_option_prefix)) 6029e8ead290Smrg { 6030e8ead290Smrg /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX 6031e8ead290Smrg namespace, but it is not one of the ones we know about and 6032e8ead290Smrg have already dealt with, above (inluding dump-script), then 6033e8ead290Smrg report an error. Otherwise, targets might begin to believe 6034e8ead290Smrg they are allowed to use options in the LTWRAPPER_OPTION_PREFIX 6035e8ead290Smrg namespace. The first time any user complains about this, we'll 6036e8ead290Smrg need to make LTWRAPPER_OPTION_PREFIX a configure-time option 6037e8ead290Smrg or a configure.ac-settable value. 6038e8ead290Smrg */ 6039e8ead290Smrg lt_fatal (__FILE__, __LINE__, 6040e8ead290Smrg "unrecognized %s option: '%s'", 6041e8ead290Smrg ltwrapper_option_prefix, argv[i]); 6042e8ead290Smrg } 6043e8ead290Smrg /* otherwise ... */ 6044e8ead290Smrg newargz[++newargc] = xstrdup (argv[i]); 6045e169010aSmrg } 6046e8ead290Smrg newargz[++newargc] = NULL; 6047e8ead290Smrg 6048e8ead290SmrgEOF 6049e8ead290Smrg cat <<EOF 6050e8ead290Smrg /* The GNU banner must be the first non-error debug message */ 60519d0ccd10Smrg lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE) $VERSION\n"); 6052e8ead290SmrgEOF 6053e8ead290Smrg cat <<"EOF" 6054e8ead290Smrg lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]); 6055e8ead290Smrg lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name); 60567914d74bSmrg 6057e169010aSmrg tmp_pathspec = find_executable (argv[0]); 6058e169010aSmrg if (tmp_pathspec == NULL) 6059e8ead290Smrg lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]); 6060e8ead290Smrg lt_debugprintf (__FILE__, __LINE__, 6061e8ead290Smrg "(main) found exe (before symlink chase) at: %s\n", 6062e8ead290Smrg tmp_pathspec); 6063e169010aSmrg 6064e169010aSmrg actual_cwrapper_path = chase_symlinks (tmp_pathspec); 6065e8ead290Smrg lt_debugprintf (__FILE__, __LINE__, 6066e8ead290Smrg "(main) found exe (after symlink chase) at: %s\n", 6067e8ead290Smrg actual_cwrapper_path); 6068e169010aSmrg XFREE (tmp_pathspec); 6069e169010aSmrg 6070e8ead290Smrg actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path)); 6071e169010aSmrg strendzap (actual_cwrapper_path, actual_cwrapper_name); 6072e169010aSmrg 6073e169010aSmrg /* wrapper name transforms */ 6074e169010aSmrg strendzap (actual_cwrapper_name, ".exe"); 6075e169010aSmrg tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1); 6076e169010aSmrg XFREE (actual_cwrapper_name); 6077e169010aSmrg actual_cwrapper_name = tmp_pathspec; 6078e169010aSmrg tmp_pathspec = 0; 6079e169010aSmrg 6080e169010aSmrg /* target_name transforms -- use actual target program name; might have lt- prefix */ 6081e169010aSmrg target_name = xstrdup (base_name (TARGET_PROGRAM_NAME)); 6082e169010aSmrg strendzap (target_name, ".exe"); 6083e169010aSmrg tmp_pathspec = lt_extend_str (target_name, ".exe", 1); 6084e169010aSmrg XFREE (target_name); 6085e169010aSmrg target_name = tmp_pathspec; 6086e169010aSmrg tmp_pathspec = 0; 6087e169010aSmrg 6088e8ead290Smrg lt_debugprintf (__FILE__, __LINE__, 6089e8ead290Smrg "(main) libtool target name: %s\n", 6090e8ead290Smrg target_name); 6091e169010aSmrgEOF 60927914d74bSmrg 6093e169010aSmrg cat <<EOF 6094e169010aSmrg newargz[0] = 6095e169010aSmrg XMALLOC (char, (strlen (actual_cwrapper_path) + 6096e169010aSmrg strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1)); 6097e169010aSmrg strcpy (newargz[0], actual_cwrapper_path); 6098e169010aSmrg strcat (newargz[0], "$objdir"); 6099e169010aSmrg strcat (newargz[0], "/"); 6100e169010aSmrgEOF 61017914d74bSmrg 6102e169010aSmrg cat <<"EOF" 6103e169010aSmrg /* stop here, and copy so we don't have to do this twice */ 6104e169010aSmrg tmp_pathspec = xstrdup (newargz[0]); 61057914d74bSmrg 6106e169010aSmrg /* do NOT want the lt- prefix here, so use actual_cwrapper_name */ 6107e169010aSmrg strcat (newargz[0], actual_cwrapper_name); 61087914d74bSmrg 6109e169010aSmrg /* DO want the lt- prefix here if it exists, so use target_name */ 6110e169010aSmrg lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1); 6111e169010aSmrg XFREE (tmp_pathspec); 6112e169010aSmrg tmp_pathspec = NULL; 6113e169010aSmrgEOF 61147914d74bSmrg 6115e169010aSmrg case $host_os in 6116e169010aSmrg mingw*) 6117e169010aSmrg cat <<"EOF" 6118e169010aSmrg { 6119e169010aSmrg char* p; 6120e169010aSmrg while ((p = strchr (newargz[0], '\\')) != NULL) 6121e169010aSmrg { 6122e169010aSmrg *p = '/'; 6123e169010aSmrg } 6124e169010aSmrg while ((p = strchr (lt_argv_zero, '\\')) != NULL) 6125e169010aSmrg { 6126e169010aSmrg *p = '/'; 6127e169010aSmrg } 6128e169010aSmrg } 6129e169010aSmrgEOF 6130e169010aSmrg ;; 6131e169010aSmrg esac 61327914d74bSmrg 6133e169010aSmrg cat <<"EOF" 6134e169010aSmrg XFREE (target_name); 6135e169010aSmrg XFREE (actual_cwrapper_path); 6136e169010aSmrg XFREE (actual_cwrapper_name); 61377914d74bSmrg 6138e169010aSmrg lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */ 6139e169010aSmrg lt_setenv ("DUALCASE", "1"); /* for MSK sh */ 6140c63293b5Smrg /* Update the DLL searchpath. EXE_PATH_VALUE ($dllsearchpath) must 6141c63293b5Smrg be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath) 6142c63293b5Smrg because on Windows, both *_VARNAMEs are PATH but uninstalled 6143c63293b5Smrg libraries must come first. */ 6144e169010aSmrg lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE); 6145c63293b5Smrg lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE); 61467914d74bSmrg 6147e8ead290Smrg lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n", 6148e8ead290Smrg nonnull (lt_argv_zero)); 6149e169010aSmrg for (i = 0; i < newargc; i++) 6150e169010aSmrg { 6151e8ead290Smrg lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n", 6152e8ead290Smrg i, nonnull (newargz[i])); 6153e169010aSmrg } 61547914d74bSmrg 6155e169010aSmrgEOF 61567914d74bSmrg 6157e169010aSmrg case $host_os in 6158e169010aSmrg mingw*) 6159e169010aSmrg cat <<"EOF" 6160e169010aSmrg /* execv doesn't actually work on mingw as expected on unix */ 6161e8ead290Smrg newargz = prepare_spawn (newargz); 61629d0ccd10Smrg rval = (int) _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz); 6163e169010aSmrg if (rval == -1) 6164e169010aSmrg { 6165e169010aSmrg /* failed to start process */ 6166e8ead290Smrg lt_debugprintf (__FILE__, __LINE__, 6167e8ead290Smrg "(main) failed to launch target \"%s\": %s\n", 6168e8ead290Smrg lt_argv_zero, nonnull (strerror (errno))); 6169e169010aSmrg return 127; 6170e169010aSmrg } 6171e169010aSmrg return rval; 6172e169010aSmrgEOF 6173e169010aSmrg ;; 6174e169010aSmrg *) 6175e169010aSmrg cat <<"EOF" 6176e169010aSmrg execv (lt_argv_zero, newargz); 6177e169010aSmrg return rval; /* =127, but avoids unused variable warning */ 6178e169010aSmrgEOF 6179e169010aSmrg ;; 6180e169010aSmrg esac 61817914d74bSmrg 6182e169010aSmrg cat <<"EOF" 6183e169010aSmrg} 61847914d74bSmrg 6185e169010aSmrgvoid * 6186e169010aSmrgxmalloc (size_t num) 6187e169010aSmrg{ 6188e169010aSmrg void *p = (void *) malloc (num); 6189e169010aSmrg if (!p) 6190e8ead290Smrg lt_fatal (__FILE__, __LINE__, "memory exhausted"); 61917914d74bSmrg 6192e169010aSmrg return p; 6193e169010aSmrg} 61947914d74bSmrg 6195e169010aSmrgchar * 6196e169010aSmrgxstrdup (const char *string) 6197e169010aSmrg{ 6198e169010aSmrg return string ? strcpy ((char *) xmalloc (strlen (string) + 1), 6199e169010aSmrg string) : NULL; 6200e169010aSmrg} 62017914d74bSmrg 6202e169010aSmrgconst char * 6203e169010aSmrgbase_name (const char *name) 6204e169010aSmrg{ 6205e169010aSmrg const char *base; 62067914d74bSmrg 62079d0ccd10Smrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 6208e169010aSmrg /* Skip over the disk name in MSDOS pathnames. */ 6209e169010aSmrg if (isalpha ((unsigned char) name[0]) && name[1] == ':') 6210e169010aSmrg name += 2; 6211e169010aSmrg#endif 62127914d74bSmrg 6213e169010aSmrg for (base = name; *name; name++) 6214e169010aSmrg if (IS_DIR_SEPARATOR (*name)) 6215e169010aSmrg base = name + 1; 6216e169010aSmrg return base; 6217e169010aSmrg} 62187914d74bSmrg 6219e169010aSmrgint 6220e169010aSmrgcheck_executable (const char *path) 6221e169010aSmrg{ 6222e169010aSmrg struct stat st; 62237914d74bSmrg 6224e8ead290Smrg lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n", 6225e8ead290Smrg nonempty (path)); 6226e169010aSmrg if ((!path) || (!*path)) 6227e169010aSmrg return 0; 62287914d74bSmrg 6229e169010aSmrg if ((stat (path, &st) >= 0) 6230e169010aSmrg && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) 6231e169010aSmrg return 1; 6232e169010aSmrg else 6233e169010aSmrg return 0; 6234e169010aSmrg} 62357914d74bSmrg 6236e169010aSmrgint 6237e169010aSmrgmake_executable (const char *path) 6238e169010aSmrg{ 6239e169010aSmrg int rval = 0; 6240e169010aSmrg struct stat st; 62417914d74bSmrg 6242e8ead290Smrg lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", 6243e8ead290Smrg nonempty (path)); 6244e169010aSmrg if ((!path) || (!*path)) 6245e169010aSmrg return 0; 62467914d74bSmrg 6247e169010aSmrg if (stat (path, &st) >= 0) 6248e169010aSmrg { 6249e169010aSmrg rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); 6250e169010aSmrg } 6251e169010aSmrg return rval; 6252e169010aSmrg} 62537914d74bSmrg 6254e169010aSmrg/* Searches for the full path of the wrapper. Returns 6255e169010aSmrg newly allocated full path name if found, NULL otherwise 6256e169010aSmrg Does not chase symlinks, even on platforms that support them. 6257e169010aSmrg*/ 6258e169010aSmrgchar * 6259e169010aSmrgfind_executable (const char *wrapper) 6260e169010aSmrg{ 6261e169010aSmrg int has_slash = 0; 6262e169010aSmrg const char *p; 6263e169010aSmrg const char *p_next; 6264e169010aSmrg /* static buffer for getcwd */ 6265e169010aSmrg char tmp[LT_PATHMAX + 1]; 62669d0ccd10Smrg size_t tmp_len; 6267e169010aSmrg char *concat_name; 62687914d74bSmrg 6269e8ead290Smrg lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", 6270e8ead290Smrg nonempty (wrapper)); 62717914d74bSmrg 6272e169010aSmrg if ((wrapper == NULL) || (*wrapper == '\0')) 6273e169010aSmrg return NULL; 62747914d74bSmrg 6275e169010aSmrg /* Absolute path? */ 62769d0ccd10Smrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 6277e169010aSmrg if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') 6278e169010aSmrg { 6279e169010aSmrg concat_name = xstrdup (wrapper); 6280e169010aSmrg if (check_executable (concat_name)) 6281e169010aSmrg return concat_name; 6282e169010aSmrg XFREE (concat_name); 6283e169010aSmrg } 6284e169010aSmrg else 6285e169010aSmrg { 6286e169010aSmrg#endif 6287e169010aSmrg if (IS_DIR_SEPARATOR (wrapper[0])) 6288e169010aSmrg { 6289e169010aSmrg concat_name = xstrdup (wrapper); 6290e169010aSmrg if (check_executable (concat_name)) 6291e169010aSmrg return concat_name; 6292e169010aSmrg XFREE (concat_name); 6293e169010aSmrg } 62949d0ccd10Smrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 6295e169010aSmrg } 6296e169010aSmrg#endif 62977914d74bSmrg 6298e169010aSmrg for (p = wrapper; *p; p++) 6299e169010aSmrg if (*p == '/') 6300e169010aSmrg { 6301e169010aSmrg has_slash = 1; 6302e169010aSmrg break; 6303e169010aSmrg } 6304e169010aSmrg if (!has_slash) 6305e169010aSmrg { 6306e169010aSmrg /* no slashes; search PATH */ 6307e169010aSmrg const char *path = getenv ("PATH"); 6308e169010aSmrg if (path != NULL) 6309e169010aSmrg { 6310e169010aSmrg for (p = path; *p; p = p_next) 6311e169010aSmrg { 6312e169010aSmrg const char *q; 6313e169010aSmrg size_t p_len; 6314e169010aSmrg for (q = p; *q; q++) 6315e169010aSmrg if (IS_PATH_SEPARATOR (*q)) 6316e169010aSmrg break; 63179d0ccd10Smrg p_len = (size_t) (q - p); 6318e169010aSmrg p_next = (*q == '\0' ? q : q + 1); 6319e169010aSmrg if (p_len == 0) 6320e169010aSmrg { 6321e169010aSmrg /* empty path: current directory */ 6322e169010aSmrg if (getcwd (tmp, LT_PATHMAX) == NULL) 6323e8ead290Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 6324e8ead290Smrg nonnull (strerror (errno))); 6325e169010aSmrg tmp_len = strlen (tmp); 6326e169010aSmrg concat_name = 6327e169010aSmrg XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 6328e169010aSmrg memcpy (concat_name, tmp, tmp_len); 6329e169010aSmrg concat_name[tmp_len] = '/'; 6330e169010aSmrg strcpy (concat_name + tmp_len + 1, wrapper); 6331e169010aSmrg } 6332e169010aSmrg else 6333e169010aSmrg { 6334e169010aSmrg concat_name = 6335e169010aSmrg XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); 6336e169010aSmrg memcpy (concat_name, p, p_len); 6337e169010aSmrg concat_name[p_len] = '/'; 6338e169010aSmrg strcpy (concat_name + p_len + 1, wrapper); 6339e169010aSmrg } 6340e169010aSmrg if (check_executable (concat_name)) 6341e169010aSmrg return concat_name; 6342e169010aSmrg XFREE (concat_name); 6343e169010aSmrg } 6344e169010aSmrg } 6345e169010aSmrg /* not found in PATH; assume curdir */ 6346e169010aSmrg } 6347e169010aSmrg /* Relative path | not found in path: prepend cwd */ 6348e169010aSmrg if (getcwd (tmp, LT_PATHMAX) == NULL) 6349e8ead290Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 6350e8ead290Smrg nonnull (strerror (errno))); 6351e169010aSmrg tmp_len = strlen (tmp); 6352e169010aSmrg concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 6353e169010aSmrg memcpy (concat_name, tmp, tmp_len); 6354e169010aSmrg concat_name[tmp_len] = '/'; 6355e169010aSmrg strcpy (concat_name + tmp_len + 1, wrapper); 63567914d74bSmrg 6357e169010aSmrg if (check_executable (concat_name)) 6358e169010aSmrg return concat_name; 6359e169010aSmrg XFREE (concat_name); 6360e169010aSmrg return NULL; 6361e169010aSmrg} 63627914d74bSmrg 6363e169010aSmrgchar * 6364e169010aSmrgchase_symlinks (const char *pathspec) 6365e169010aSmrg{ 6366e169010aSmrg#ifndef S_ISLNK 6367e169010aSmrg return xstrdup (pathspec); 6368e169010aSmrg#else 6369e169010aSmrg char buf[LT_PATHMAX]; 6370e169010aSmrg struct stat s; 6371e169010aSmrg char *tmp_pathspec = xstrdup (pathspec); 6372e169010aSmrg char *p; 6373e169010aSmrg int has_symlinks = 0; 6374e169010aSmrg while (strlen (tmp_pathspec) && !has_symlinks) 6375e169010aSmrg { 6376e8ead290Smrg lt_debugprintf (__FILE__, __LINE__, 6377e8ead290Smrg "checking path component for symlinks: %s\n", 6378e8ead290Smrg tmp_pathspec); 6379e169010aSmrg if (lstat (tmp_pathspec, &s) == 0) 6380e169010aSmrg { 6381e169010aSmrg if (S_ISLNK (s.st_mode) != 0) 6382e169010aSmrg { 6383e169010aSmrg has_symlinks = 1; 6384e169010aSmrg break; 6385e169010aSmrg } 63867914d74bSmrg 6387e169010aSmrg /* search backwards for last DIR_SEPARATOR */ 6388e169010aSmrg p = tmp_pathspec + strlen (tmp_pathspec) - 1; 6389e169010aSmrg while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 6390e169010aSmrg p--; 6391e169010aSmrg if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 6392e169010aSmrg { 6393e169010aSmrg /* no more DIR_SEPARATORS left */ 6394e169010aSmrg break; 6395e169010aSmrg } 6396e169010aSmrg *p = '\0'; 6397e169010aSmrg } 6398e169010aSmrg else 6399e169010aSmrg { 6400e8ead290Smrg lt_fatal (__FILE__, __LINE__, 6401e8ead290Smrg "error accessing file \"%s\": %s", 6402e8ead290Smrg tmp_pathspec, nonnull (strerror (errno))); 6403e169010aSmrg } 6404e169010aSmrg } 6405e169010aSmrg XFREE (tmp_pathspec); 64067914d74bSmrg 6407e169010aSmrg if (!has_symlinks) 6408e169010aSmrg { 6409e169010aSmrg return xstrdup (pathspec); 6410e169010aSmrg } 64117914d74bSmrg 6412e169010aSmrg tmp_pathspec = realpath (pathspec, buf); 6413e169010aSmrg if (tmp_pathspec == 0) 6414e169010aSmrg { 6415e8ead290Smrg lt_fatal (__FILE__, __LINE__, 6416e8ead290Smrg "could not follow symlinks for %s", pathspec); 6417e169010aSmrg } 6418e169010aSmrg return xstrdup (tmp_pathspec); 6419e169010aSmrg#endif 6420e169010aSmrg} 64217914d74bSmrg 6422e169010aSmrgchar * 6423e169010aSmrgstrendzap (char *str, const char *pat) 6424e169010aSmrg{ 6425e169010aSmrg size_t len, patlen; 64267914d74bSmrg 6427e169010aSmrg assert (str != NULL); 6428e169010aSmrg assert (pat != NULL); 64297914d74bSmrg 6430e169010aSmrg len = strlen (str); 6431e169010aSmrg patlen = strlen (pat); 64327914d74bSmrg 6433e169010aSmrg if (patlen <= len) 6434e169010aSmrg { 6435e169010aSmrg str += len - patlen; 64369d0ccd10Smrg if (STREQ (str, pat)) 6437e169010aSmrg *str = '\0'; 6438e169010aSmrg } 6439e169010aSmrg return str; 6440e169010aSmrg} 64417914d74bSmrg 6442e8ead290Smrgvoid 6443e8ead290Smrglt_debugprintf (const char *file, int line, const char *fmt, ...) 6444e8ead290Smrg{ 6445e8ead290Smrg va_list args; 6446e8ead290Smrg if (lt_debug) 6447e8ead290Smrg { 6448e8ead290Smrg (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); 6449e8ead290Smrg va_start (args, fmt); 6450e8ead290Smrg (void) vfprintf (stderr, fmt, args); 6451e8ead290Smrg va_end (args); 6452e8ead290Smrg } 6453e8ead290Smrg} 6454e8ead290Smrg 6455e169010aSmrgstatic void 6456e8ead290Smrglt_error_core (int exit_status, const char *file, 6457e8ead290Smrg int line, const char *mode, 6458e169010aSmrg const char *message, va_list ap) 6459e169010aSmrg{ 6460e8ead290Smrg fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); 6461e169010aSmrg vfprintf (stderr, message, ap); 6462e169010aSmrg fprintf (stderr, ".\n"); 64637914d74bSmrg 6464e169010aSmrg if (exit_status >= 0) 6465e169010aSmrg exit (exit_status); 6466e169010aSmrg} 64677914d74bSmrg 6468e169010aSmrgvoid 6469e8ead290Smrglt_fatal (const char *file, int line, const char *message, ...) 6470e169010aSmrg{ 6471e169010aSmrg va_list ap; 6472e169010aSmrg va_start (ap, message); 6473e8ead290Smrg lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); 6474e169010aSmrg va_end (ap); 6475e169010aSmrg} 64767914d74bSmrg 6477e8ead290Smrgstatic const char * 6478e8ead290Smrgnonnull (const char *s) 6479e8ead290Smrg{ 6480e8ead290Smrg return s ? s : "(null)"; 6481e8ead290Smrg} 6482e8ead290Smrg 6483e8ead290Smrgstatic const char * 6484e8ead290Smrgnonempty (const char *s) 6485e8ead290Smrg{ 6486e8ead290Smrg return (s && !*s) ? "(empty)" : nonnull (s); 6487e8ead290Smrg} 6488e8ead290Smrg 6489e169010aSmrgvoid 6490e169010aSmrglt_setenv (const char *name, const char *value) 6491e169010aSmrg{ 6492e8ead290Smrg lt_debugprintf (__FILE__, __LINE__, 6493e8ead290Smrg "(lt_setenv) setting '%s' to '%s'\n", 6494e8ead290Smrg nonnull (name), nonnull (value)); 6495e169010aSmrg { 6496e169010aSmrg#ifdef HAVE_SETENV 6497e169010aSmrg /* always make a copy, for consistency with !HAVE_SETENV */ 6498e169010aSmrg char *str = xstrdup (value); 6499e169010aSmrg setenv (name, str, 1); 6500e169010aSmrg#else 65019d0ccd10Smrg size_t len = strlen (name) + 1 + strlen (value) + 1; 6502e169010aSmrg char *str = XMALLOC (char, len); 6503e169010aSmrg sprintf (str, "%s=%s", name, value); 6504e169010aSmrg if (putenv (str) != EXIT_SUCCESS) 6505e169010aSmrg { 6506e169010aSmrg XFREE (str); 6507e169010aSmrg } 6508e169010aSmrg#endif 6509e169010aSmrg } 6510e169010aSmrg} 65117914d74bSmrg 6512e169010aSmrgchar * 6513e169010aSmrglt_extend_str (const char *orig_value, const char *add, int to_end) 6514e169010aSmrg{ 6515e169010aSmrg char *new_value; 6516e169010aSmrg if (orig_value && *orig_value) 6517e169010aSmrg { 65189d0ccd10Smrg size_t orig_value_len = strlen (orig_value); 65199d0ccd10Smrg size_t add_len = strlen (add); 6520e169010aSmrg new_value = XMALLOC (char, add_len + orig_value_len + 1); 6521e169010aSmrg if (to_end) 6522e169010aSmrg { 6523e169010aSmrg strcpy (new_value, orig_value); 6524e169010aSmrg strcpy (new_value + orig_value_len, add); 6525e169010aSmrg } 6526e169010aSmrg else 6527e169010aSmrg { 6528e169010aSmrg strcpy (new_value, add); 6529e169010aSmrg strcpy (new_value + add_len, orig_value); 6530e169010aSmrg } 6531e169010aSmrg } 6532e169010aSmrg else 6533e169010aSmrg { 6534e169010aSmrg new_value = xstrdup (add); 6535e169010aSmrg } 6536e169010aSmrg return new_value; 6537e169010aSmrg} 65387914d74bSmrg 6539e169010aSmrgvoid 6540e169010aSmrglt_update_exe_path (const char *name, const char *value) 6541e169010aSmrg{ 6542e8ead290Smrg lt_debugprintf (__FILE__, __LINE__, 6543e8ead290Smrg "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", 6544e8ead290Smrg nonnull (name), nonnull (value)); 65457914d74bSmrg 6546e169010aSmrg if (name && *name && value && *value) 6547e169010aSmrg { 6548e169010aSmrg char *new_value = lt_extend_str (getenv (name), value, 0); 6549e169010aSmrg /* some systems can't cope with a ':'-terminated path #' */ 65509d0ccd10Smrg size_t len = strlen (new_value); 65519d0ccd10Smrg while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1])) 6552e169010aSmrg { 65539d0ccd10Smrg new_value[--len] = '\0'; 6554e169010aSmrg } 6555e169010aSmrg lt_setenv (name, new_value); 6556e169010aSmrg XFREE (new_value); 6557e169010aSmrg } 6558e169010aSmrg} 65597914d74bSmrg 6560e169010aSmrgvoid 6561e169010aSmrglt_update_lib_path (const char *name, const char *value) 6562e169010aSmrg{ 6563e8ead290Smrg lt_debugprintf (__FILE__, __LINE__, 6564e8ead290Smrg "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", 6565e8ead290Smrg nonnull (name), nonnull (value)); 65667914d74bSmrg 6567e169010aSmrg if (name && *name && value && *value) 6568e169010aSmrg { 6569e169010aSmrg char *new_value = lt_extend_str (getenv (name), value, 0); 6570e169010aSmrg lt_setenv (name, new_value); 6571e169010aSmrg XFREE (new_value); 6572e169010aSmrg } 6573e169010aSmrg} 65747914d74bSmrg 6575e8ead290SmrgEOF 6576e8ead290Smrg case $host_os in 6577e8ead290Smrg mingw*) 6578e8ead290Smrg cat <<"EOF" 6579e8ead290Smrg 6580e8ead290Smrg/* Prepares an argument vector before calling spawn(). 6581e8ead290Smrg Note that spawn() does not by itself call the command interpreter 6582e8ead290Smrg (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : 6583e8ead290Smrg ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); 6584e8ead290Smrg GetVersionEx(&v); 6585e8ead290Smrg v.dwPlatformId == VER_PLATFORM_WIN32_NT; 6586e8ead290Smrg }) ? "cmd.exe" : "command.com"). 6587e8ead290Smrg Instead it simply concatenates the arguments, separated by ' ', and calls 6588e8ead290Smrg CreateProcess(). We must quote the arguments since Win32 CreateProcess() 6589e8ead290Smrg interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a 6590e8ead290Smrg special way: 6591e8ead290Smrg - Space and tab are interpreted as delimiters. They are not treated as 6592e8ead290Smrg delimiters if they are surrounded by double quotes: "...". 6593e8ead290Smrg - Unescaped double quotes are removed from the input. Their only effect is 6594e8ead290Smrg that within double quotes, space and tab are treated like normal 6595e8ead290Smrg characters. 6596e8ead290Smrg - Backslashes not followed by double quotes are not special. 6597e8ead290Smrg - But 2*n+1 backslashes followed by a double quote become 6598e8ead290Smrg n backslashes followed by a double quote (n >= 0): 6599e8ead290Smrg \" -> " 6600e8ead290Smrg \\\" -> \" 6601e8ead290Smrg \\\\\" -> \\" 6602e8ead290Smrg */ 6603e8ead290Smrg#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" 6604e8ead290Smrg#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" 6605e8ead290Smrgchar ** 6606e8ead290Smrgprepare_spawn (char **argv) 6607e8ead290Smrg{ 6608e8ead290Smrg size_t argc; 6609e8ead290Smrg char **new_argv; 6610e8ead290Smrg size_t i; 6611e8ead290Smrg 6612e8ead290Smrg /* Count number of arguments. */ 6613e8ead290Smrg for (argc = 0; argv[argc] != NULL; argc++) 6614e8ead290Smrg ; 6615e8ead290Smrg 6616e8ead290Smrg /* Allocate new argument vector. */ 6617e8ead290Smrg new_argv = XMALLOC (char *, argc + 1); 6618e8ead290Smrg 6619e8ead290Smrg /* Put quoted arguments into the new argument vector. */ 6620e8ead290Smrg for (i = 0; i < argc; i++) 6621e8ead290Smrg { 6622e8ead290Smrg const char *string = argv[i]; 6623e8ead290Smrg 6624e8ead290Smrg if (string[0] == '\0') 6625e8ead290Smrg new_argv[i] = xstrdup ("\"\""); 6626e8ead290Smrg else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) 6627e8ead290Smrg { 6628e8ead290Smrg int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); 6629e8ead290Smrg size_t length; 6630e8ead290Smrg unsigned int backslashes; 6631e8ead290Smrg const char *s; 6632e8ead290Smrg char *quoted_string; 6633e8ead290Smrg char *p; 6634e8ead290Smrg 6635e8ead290Smrg length = 0; 6636e8ead290Smrg backslashes = 0; 6637e8ead290Smrg if (quote_around) 6638e8ead290Smrg length++; 6639e8ead290Smrg for (s = string; *s != '\0'; s++) 6640e8ead290Smrg { 6641e8ead290Smrg char c = *s; 6642e8ead290Smrg if (c == '"') 6643e8ead290Smrg length += backslashes + 1; 6644e8ead290Smrg length++; 6645e8ead290Smrg if (c == '\\') 6646e8ead290Smrg backslashes++; 6647e8ead290Smrg else 6648e8ead290Smrg backslashes = 0; 6649e8ead290Smrg } 6650e8ead290Smrg if (quote_around) 6651e8ead290Smrg length += backslashes + 1; 6652e8ead290Smrg 6653e8ead290Smrg quoted_string = XMALLOC (char, length + 1); 6654e8ead290Smrg 6655e8ead290Smrg p = quoted_string; 6656e8ead290Smrg backslashes = 0; 6657e8ead290Smrg if (quote_around) 6658e8ead290Smrg *p++ = '"'; 6659e8ead290Smrg for (s = string; *s != '\0'; s++) 6660e8ead290Smrg { 6661e8ead290Smrg char c = *s; 6662e8ead290Smrg if (c == '"') 6663e8ead290Smrg { 6664e8ead290Smrg unsigned int j; 6665e8ead290Smrg for (j = backslashes + 1; j > 0; j--) 6666e8ead290Smrg *p++ = '\\'; 6667e8ead290Smrg } 6668e8ead290Smrg *p++ = c; 6669e8ead290Smrg if (c == '\\') 6670e8ead290Smrg backslashes++; 6671e8ead290Smrg else 6672e8ead290Smrg backslashes = 0; 6673e8ead290Smrg } 6674e8ead290Smrg if (quote_around) 6675e8ead290Smrg { 6676e8ead290Smrg unsigned int j; 6677e8ead290Smrg for (j = backslashes; j > 0; j--) 6678e8ead290Smrg *p++ = '\\'; 6679e8ead290Smrg *p++ = '"'; 6680e8ead290Smrg } 6681e8ead290Smrg *p = '\0'; 6682e8ead290Smrg 6683e8ead290Smrg new_argv[i] = quoted_string; 6684e8ead290Smrg } 6685e8ead290Smrg else 6686e8ead290Smrg new_argv[i] = (char *) string; 6687e8ead290Smrg } 6688e8ead290Smrg new_argv[argc] = NULL; 6689e8ead290Smrg 6690e8ead290Smrg return new_argv; 6691e8ead290Smrg} 6692e8ead290SmrgEOF 6693e8ead290Smrg ;; 6694e8ead290Smrg esac 6695e8ead290Smrg 6696e8ead290Smrg cat <<"EOF" 6697e8ead290Smrgvoid lt_dump_script (FILE* f) 6698e8ead290Smrg{ 6699e8ead290SmrgEOF 6700e8ead290Smrg func_emit_wrapper yes | 6701e6d5e4e0Smrg $SED -n -e ' 6702e6d5e4e0Smrgs/^\(.\{79\}\)\(..*\)/\1\ 6703e6d5e4e0Smrg\2/ 6704e6d5e4e0Smrgh 6705e6d5e4e0Smrgs/\([\\"]\)/\\\1/g 6706e6d5e4e0Smrgs/$/\\n/ 6707e6d5e4e0Smrgs/\([^\n]*\).*/ fputs ("\1", f);/p 6708e6d5e4e0Smrgg 6709e6d5e4e0SmrgD' 6710e8ead290Smrg cat <<"EOF" 6711e8ead290Smrg} 6712e169010aSmrgEOF 6713e169010aSmrg} 6714e169010aSmrg# end: func_emit_cwrapperexe_src 67157914d74bSmrg 6716e8ead290Smrg# func_win32_import_lib_p ARG 6717e8ead290Smrg# True if ARG is an import lib, as indicated by $file_magic_cmd 6718e8ead290Smrgfunc_win32_import_lib_p () 6719e8ead290Smrg{ 67209d0ccd10Smrg $debug_cmd 67219d0ccd10Smrg 6722e8ead290Smrg case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in 6723e8ead290Smrg *import*) : ;; 6724e8ead290Smrg *) false ;; 6725e8ead290Smrg esac 6726e8ead290Smrg} 6727e8ead290Smrg 67289d0ccd10Smrg# func_suncc_cstd_abi 67299d0ccd10Smrg# !!ONLY CALL THIS FOR SUN CC AFTER $compile_command IS FULLY EXPANDED!! 67309d0ccd10Smrg# Several compiler flags select an ABI that is incompatible with the 67319d0ccd10Smrg# Cstd library. Avoid specifying it if any are in CXXFLAGS. 67329d0ccd10Smrgfunc_suncc_cstd_abi () 67339d0ccd10Smrg{ 67349d0ccd10Smrg $debug_cmd 67359d0ccd10Smrg 67369d0ccd10Smrg case " $compile_command " in 67379d0ccd10Smrg *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*) 67389d0ccd10Smrg suncc_use_cstd_abi=no 67399d0ccd10Smrg ;; 67409d0ccd10Smrg *) 67419d0ccd10Smrg suncc_use_cstd_abi=yes 67429d0ccd10Smrg ;; 67439d0ccd10Smrg esac 67449d0ccd10Smrg} 67459d0ccd10Smrg 6746e169010aSmrg# func_mode_link arg... 6747e169010aSmrgfunc_mode_link () 6748e169010aSmrg{ 67499d0ccd10Smrg $debug_cmd 67509d0ccd10Smrg 6751e169010aSmrg case $host in 6752e169010aSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 6753e169010aSmrg # It is impossible to link a dll without this setting, and 6754e169010aSmrg # we shouldn't force the makefile maintainer to figure out 67559d0ccd10Smrg # what system we are compiling for in order to pass an extra 6756e169010aSmrg # flag for every libtool invocation. 6757e169010aSmrg # allow_undefined=no 67587914d74bSmrg 6759e169010aSmrg # FIXME: Unfortunately, there are problems with the above when trying 67609d0ccd10Smrg # to make a dll that has undefined symbols, in which case not 6761e169010aSmrg # even a static library is built. For now, we need to specify 6762e169010aSmrg # -no-undefined on the libtool link line when we can be certain 6763e169010aSmrg # that all symbols are satisfied, otherwise we get a static library. 6764e169010aSmrg allow_undefined=yes 6765e169010aSmrg ;; 6766e169010aSmrg *) 6767e169010aSmrg allow_undefined=yes 6768e169010aSmrg ;; 6769e169010aSmrg esac 6770e169010aSmrg libtool_args=$nonopt 6771e169010aSmrg base_compile="$nonopt $@" 6772e169010aSmrg compile_command=$nonopt 6773e169010aSmrg finalize_command=$nonopt 67747914d74bSmrg 6775e169010aSmrg compile_rpath= 6776e169010aSmrg finalize_rpath= 6777e169010aSmrg compile_shlibpath= 6778e169010aSmrg finalize_shlibpath= 6779e169010aSmrg convenience= 6780e169010aSmrg old_convenience= 6781e169010aSmrg deplibs= 6782e169010aSmrg old_deplibs= 6783e169010aSmrg compiler_flags= 6784e169010aSmrg linker_flags= 6785e169010aSmrg dllsearchpath= 6786e169010aSmrg lib_search_path=`pwd` 6787e169010aSmrg inst_prefix_dir= 6788e169010aSmrg new_inherited_linker_flags= 67897914d74bSmrg 6790e169010aSmrg avoid_version=no 6791e8ead290Smrg bindir= 6792e169010aSmrg dlfiles= 6793e169010aSmrg dlprefiles= 6794e169010aSmrg dlself=no 6795e169010aSmrg export_dynamic=no 6796e169010aSmrg export_symbols= 6797e169010aSmrg export_symbols_regex= 6798e169010aSmrg generated= 6799e169010aSmrg libobjs= 6800e169010aSmrg ltlibs= 6801e169010aSmrg module=no 6802e169010aSmrg no_install=no 6803e169010aSmrg objs= 68049d0ccd10Smrg os2dllname= 6805e169010aSmrg non_pic_objects= 6806e169010aSmrg precious_files_regex= 6807e169010aSmrg prefer_static_libs=no 68089d0ccd10Smrg preload=false 6809e169010aSmrg prev= 6810e169010aSmrg prevarg= 6811e169010aSmrg release= 6812e169010aSmrg rpath= 6813e169010aSmrg xrpath= 6814e169010aSmrg perm_rpath= 6815e169010aSmrg temp_rpath= 6816e169010aSmrg thread_safe=no 6817e169010aSmrg vinfo= 6818e169010aSmrg vinfo_number=no 6819e169010aSmrg weak_libs= 68209d0ccd10Smrg single_module=$wl-single_module 6821e169010aSmrg func_infer_tag $base_compile 68227914d74bSmrg 6823e169010aSmrg # We need to know -static, to get the right output filenames. 6824e169010aSmrg for arg 6825e169010aSmrg do 6826e169010aSmrg case $arg in 6827e169010aSmrg -shared) 68289d0ccd10Smrg test yes != "$build_libtool_libs" \ 68299d0ccd10Smrg && func_fatal_configuration "cannot build a shared library" 6830e169010aSmrg build_old_libs=no 6831e169010aSmrg break 6832e169010aSmrg ;; 6833e169010aSmrg -all-static | -static | -static-libtool-libs) 6834e169010aSmrg case $arg in 6835e169010aSmrg -all-static) 68369d0ccd10Smrg if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then 6837e169010aSmrg func_warning "complete static linking is impossible in this configuration" 68387914d74bSmrg fi 6839e169010aSmrg if test -n "$link_static_flag"; then 6840e169010aSmrg dlopen_self=$dlopen_self_static 68417914d74bSmrg fi 6842e169010aSmrg prefer_static_libs=yes 68437914d74bSmrg ;; 6844e169010aSmrg -static) 6845e169010aSmrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 6846e169010aSmrg dlopen_self=$dlopen_self_static 6847e169010aSmrg fi 6848e169010aSmrg prefer_static_libs=built 6849e169010aSmrg ;; 6850e169010aSmrg -static-libtool-libs) 6851e169010aSmrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 6852e169010aSmrg dlopen_self=$dlopen_self_static 6853e169010aSmrg fi 6854e169010aSmrg prefer_static_libs=yes 68557914d74bSmrg ;; 68567914d74bSmrg esac 6857e169010aSmrg build_libtool_libs=no 6858e169010aSmrg build_old_libs=yes 6859e169010aSmrg break 6860e169010aSmrg ;; 6861e169010aSmrg esac 6862e169010aSmrg done 68637914d74bSmrg 6864e169010aSmrg # See if our shared archives depend on static archives. 6865e169010aSmrg test -n "$old_archive_from_new_cmds" && build_old_libs=yes 68667914d74bSmrg 6867e169010aSmrg # Go through the arguments, transforming them on the way. 6868e169010aSmrg while test "$#" -gt 0; do 68699d0ccd10Smrg arg=$1 6870e169010aSmrg shift 68710ea508b1Smrg func_quote_arg pretty,unquoted "$arg" 68720ea508b1Smrg qarg=$func_quote_arg_unquoted_result 68730ea508b1Smrg func_append libtool_args " $func_quote_arg_result" 68747914d74bSmrg 6875e169010aSmrg # If the previous option needs an argument, assign it. 6876e169010aSmrg if test -n "$prev"; then 6877e169010aSmrg case $prev in 6878e169010aSmrg output) 6879e169010aSmrg func_append compile_command " @OUTPUT@" 6880e169010aSmrg func_append finalize_command " @OUTPUT@" 6881e169010aSmrg ;; 6882e169010aSmrg esac 68837914d74bSmrg 6884e169010aSmrg case $prev in 6885e8ead290Smrg bindir) 68869d0ccd10Smrg bindir=$arg 6887e8ead290Smrg prev= 6888e8ead290Smrg continue 6889e8ead290Smrg ;; 6890e169010aSmrg dlfiles|dlprefiles) 68919d0ccd10Smrg $preload || { 6892e169010aSmrg # Add the symbol object into the linking commands. 6893e169010aSmrg func_append compile_command " @SYMFILE@" 6894e169010aSmrg func_append finalize_command " @SYMFILE@" 68959d0ccd10Smrg preload=: 68969d0ccd10Smrg } 6897e169010aSmrg case $arg in 6898e169010aSmrg *.la | *.lo) ;; # We handle these cases below. 6899e169010aSmrg force) 69009d0ccd10Smrg if test no = "$dlself"; then 6901e169010aSmrg dlself=needless 6902e169010aSmrg export_dynamic=yes 6903e169010aSmrg fi 6904e169010aSmrg prev= 6905e169010aSmrg continue 6906e169010aSmrg ;; 6907e169010aSmrg self) 69089d0ccd10Smrg if test dlprefiles = "$prev"; then 6909e169010aSmrg dlself=yes 69109d0ccd10Smrg elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then 6911e169010aSmrg dlself=yes 6912e169010aSmrg else 6913e169010aSmrg dlself=needless 6914e169010aSmrg export_dynamic=yes 6915e169010aSmrg fi 6916e169010aSmrg prev= 6917e169010aSmrg continue 69187914d74bSmrg ;; 69197914d74bSmrg *) 69209d0ccd10Smrg if test dlfiles = "$prev"; then 6921c63293b5Smrg func_append dlfiles " $arg" 6922e169010aSmrg else 6923c63293b5Smrg func_append dlprefiles " $arg" 6924e169010aSmrg fi 6925e169010aSmrg prev= 6926e169010aSmrg continue 69277914d74bSmrg ;; 69287914d74bSmrg esac 6929e169010aSmrg ;; 6930e169010aSmrg expsyms) 69319d0ccd10Smrg export_symbols=$arg 6932e169010aSmrg test -f "$arg" \ 69339d0ccd10Smrg || func_fatal_error "symbol file '$arg' does not exist" 6934e169010aSmrg prev= 6935e169010aSmrg continue 6936e169010aSmrg ;; 6937e169010aSmrg expsyms_regex) 69389d0ccd10Smrg export_symbols_regex=$arg 6939e169010aSmrg prev= 6940e169010aSmrg continue 6941e169010aSmrg ;; 6942e169010aSmrg framework) 6943e169010aSmrg case $host in 6944e169010aSmrg *-*-darwin*) 6945e169010aSmrg case "$deplibs " in 6946e169010aSmrg *" $qarg.ltframework "*) ;; 6947c63293b5Smrg *) func_append deplibs " $qarg.ltframework" # this is fixed later 6948e169010aSmrg ;; 6949e169010aSmrg esac 6950e169010aSmrg ;; 6951e169010aSmrg esac 6952e169010aSmrg prev= 6953e169010aSmrg continue 6954e169010aSmrg ;; 6955e169010aSmrg inst_prefix) 69569d0ccd10Smrg inst_prefix_dir=$arg 69579d0ccd10Smrg prev= 69589d0ccd10Smrg continue 69599d0ccd10Smrg ;; 69609d0ccd10Smrg mllvm) 69619d0ccd10Smrg # Clang does not use LLVM to link, so we can simply discard any 69629d0ccd10Smrg # '-mllvm $arg' options when doing the link step. 6963e169010aSmrg prev= 6964e169010aSmrg continue 6965e169010aSmrg ;; 6966e169010aSmrg objectlist) 6967e169010aSmrg if test -f "$arg"; then 6968e169010aSmrg save_arg=$arg 6969e169010aSmrg moreargs= 6970e169010aSmrg for fil in `cat "$save_arg"` 6971e169010aSmrg do 6972c63293b5Smrg# func_append moreargs " $fil" 6973e169010aSmrg arg=$fil 6974e169010aSmrg # A libtool-controlled object. 69757914d74bSmrg 6976e169010aSmrg # Check to see that this really is a libtool object. 6977e169010aSmrg if func_lalib_unsafe_p "$arg"; then 6978e169010aSmrg pic_object= 6979e169010aSmrg non_pic_object= 69807914d74bSmrg 6981e169010aSmrg # Read the .lo file 6982e169010aSmrg func_source "$arg" 69837914d74bSmrg 6984e169010aSmrg if test -z "$pic_object" || 6985e169010aSmrg test -z "$non_pic_object" || 69869d0ccd10Smrg test none = "$pic_object" && 69879d0ccd10Smrg test none = "$non_pic_object"; then 69889d0ccd10Smrg func_fatal_error "cannot find name of object for '$arg'" 6989e169010aSmrg fi 69907914d74bSmrg 6991e169010aSmrg # Extract subdirectory from the argument. 6992e169010aSmrg func_dirname "$arg" "/" "" 69939d0ccd10Smrg xdir=$func_dirname_result 69947914d74bSmrg 69959d0ccd10Smrg if test none != "$pic_object"; then 6996e169010aSmrg # Prepend the subdirectory the object is found in. 69979d0ccd10Smrg pic_object=$xdir$pic_object 69987914d74bSmrg 69999d0ccd10Smrg if test dlfiles = "$prev"; then 70009d0ccd10Smrg if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 7001c63293b5Smrg func_append dlfiles " $pic_object" 7002e169010aSmrg prev= 7003e169010aSmrg continue 7004e169010aSmrg else 7005e169010aSmrg # If libtool objects are unsupported, then we need to preload. 7006e169010aSmrg prev=dlprefiles 7007e169010aSmrg fi 7008e169010aSmrg fi 70097914d74bSmrg 7010e169010aSmrg # CHECK ME: I think I busted this. -Ossama 70119d0ccd10Smrg if test dlprefiles = "$prev"; then 7012e169010aSmrg # Preload the old-style object. 7013c63293b5Smrg func_append dlprefiles " $pic_object" 7014e169010aSmrg prev= 7015e169010aSmrg fi 70167914d74bSmrg 7017e169010aSmrg # A PIC object. 7018e169010aSmrg func_append libobjs " $pic_object" 70199d0ccd10Smrg arg=$pic_object 7020e169010aSmrg fi 70217914d74bSmrg 7022e169010aSmrg # Non-PIC object. 70239d0ccd10Smrg if test none != "$non_pic_object"; then 7024e169010aSmrg # Prepend the subdirectory the object is found in. 70259d0ccd10Smrg non_pic_object=$xdir$non_pic_object 70267914d74bSmrg 7027e169010aSmrg # A standard non-PIC object 7028e169010aSmrg func_append non_pic_objects " $non_pic_object" 70299d0ccd10Smrg if test -z "$pic_object" || test none = "$pic_object"; then 70309d0ccd10Smrg arg=$non_pic_object 7031e169010aSmrg fi 7032e169010aSmrg else 7033e169010aSmrg # If the PIC object exists, use it instead. 7034e169010aSmrg # $xdir was prepended to $pic_object above. 70359d0ccd10Smrg non_pic_object=$pic_object 7036e169010aSmrg func_append non_pic_objects " $non_pic_object" 7037e169010aSmrg fi 7038e169010aSmrg else 7039e169010aSmrg # Only an error if not doing a dry-run. 7040e169010aSmrg if $opt_dry_run; then 7041e169010aSmrg # Extract subdirectory from the argument. 7042e169010aSmrg func_dirname "$arg" "/" "" 70439d0ccd10Smrg xdir=$func_dirname_result 7044e169010aSmrg 7045e169010aSmrg func_lo2o "$arg" 7046e169010aSmrg pic_object=$xdir$objdir/$func_lo2o_result 7047e169010aSmrg non_pic_object=$xdir$func_lo2o_result 7048e169010aSmrg func_append libobjs " $pic_object" 7049e169010aSmrg func_append non_pic_objects " $non_pic_object" 7050e169010aSmrg else 70519d0ccd10Smrg func_fatal_error "'$arg' is not a valid libtool object" 7052e169010aSmrg fi 7053e169010aSmrg fi 7054e169010aSmrg done 7055e169010aSmrg else 70569d0ccd10Smrg func_fatal_error "link input file '$arg' does not exist" 7057e169010aSmrg fi 7058e169010aSmrg arg=$save_arg 7059e169010aSmrg prev= 7060e169010aSmrg continue 7061e169010aSmrg ;; 70629d0ccd10Smrg os2dllname) 70639d0ccd10Smrg os2dllname=$arg 70649d0ccd10Smrg prev= 70659d0ccd10Smrg continue 70669d0ccd10Smrg ;; 7067e169010aSmrg precious_regex) 70689d0ccd10Smrg precious_files_regex=$arg 7069e169010aSmrg prev= 7070e169010aSmrg continue 7071e169010aSmrg ;; 7072e169010aSmrg release) 70739d0ccd10Smrg release=-$arg 7074e169010aSmrg prev= 7075e169010aSmrg continue 7076e169010aSmrg ;; 7077e169010aSmrg rpath | xrpath) 7078e169010aSmrg # We need an absolute path. 7079e169010aSmrg case $arg in 7080e169010aSmrg [\\/]* | [A-Za-z]:[\\/]*) ;; 7081e169010aSmrg *) 7082e169010aSmrg func_fatal_error "only absolute run-paths are allowed" 7083e169010aSmrg ;; 7084e169010aSmrg esac 70859d0ccd10Smrg if test rpath = "$prev"; then 7086e169010aSmrg case "$rpath " in 7087e169010aSmrg *" $arg "*) ;; 7088c63293b5Smrg *) func_append rpath " $arg" ;; 7089e169010aSmrg esac 7090e169010aSmrg else 7091e169010aSmrg case "$xrpath " in 7092e169010aSmrg *" $arg "*) ;; 7093c63293b5Smrg *) func_append xrpath " $arg" ;; 7094e169010aSmrg esac 7095e169010aSmrg fi 7096e169010aSmrg prev= 7097e169010aSmrg continue 7098e169010aSmrg ;; 7099e169010aSmrg shrext) 71009d0ccd10Smrg shrext_cmds=$arg 7101e169010aSmrg prev= 7102e169010aSmrg continue 7103e169010aSmrg ;; 7104e169010aSmrg weak) 7105c63293b5Smrg func_append weak_libs " $arg" 7106e169010aSmrg prev= 7107e169010aSmrg continue 7108e169010aSmrg ;; 71090ea508b1Smrg xassembler) 71100ea508b1Smrg func_append compiler_flags " -Xassembler $qarg" 71110ea508b1Smrg prev= 71120ea508b1Smrg func_append compile_command " -Xassembler $qarg" 71130ea508b1Smrg func_append finalize_command " -Xassembler $qarg" 71140ea508b1Smrg continue 71150ea508b1Smrg ;; 7116e169010aSmrg xcclinker) 7117c63293b5Smrg func_append linker_flags " $qarg" 7118c63293b5Smrg func_append compiler_flags " $qarg" 7119e169010aSmrg prev= 7120e169010aSmrg func_append compile_command " $qarg" 7121e169010aSmrg func_append finalize_command " $qarg" 7122e169010aSmrg continue 7123e169010aSmrg ;; 7124e169010aSmrg xcompiler) 7125c63293b5Smrg func_append compiler_flags " $qarg" 7126e169010aSmrg prev= 7127e169010aSmrg func_append compile_command " $qarg" 7128e169010aSmrg func_append finalize_command " $qarg" 7129e169010aSmrg continue 7130e169010aSmrg ;; 7131e169010aSmrg xlinker) 7132c63293b5Smrg func_append linker_flags " $qarg" 7133c63293b5Smrg func_append compiler_flags " $wl$qarg" 7134e169010aSmrg prev= 7135e169010aSmrg func_append compile_command " $wl$qarg" 7136e169010aSmrg func_append finalize_command " $wl$qarg" 7137e169010aSmrg continue 7138e169010aSmrg ;; 7139e169010aSmrg *) 7140e169010aSmrg eval "$prev=\"\$arg\"" 7141e169010aSmrg prev= 7142e169010aSmrg continue 7143e169010aSmrg ;; 71447914d74bSmrg esac 7145e169010aSmrg fi # test -n "$prev" 71467914d74bSmrg 71479d0ccd10Smrg prevarg=$arg 71487914d74bSmrg 7149e169010aSmrg case $arg in 7150e169010aSmrg -all-static) 7151e169010aSmrg if test -n "$link_static_flag"; then 7152e169010aSmrg # See comment for -static flag below, for more details. 7153e169010aSmrg func_append compile_command " $link_static_flag" 7154e169010aSmrg func_append finalize_command " $link_static_flag" 7155e169010aSmrg fi 7156e169010aSmrg continue 7157e169010aSmrg ;; 71587914d74bSmrg 7159e169010aSmrg -allow-undefined) 7160e169010aSmrg # FIXME: remove this flag sometime in the future. 71619d0ccd10Smrg func_fatal_error "'-allow-undefined' must not be used because it is the default" 7162e169010aSmrg ;; 71637914d74bSmrg 7164e169010aSmrg -avoid-version) 7165e169010aSmrg avoid_version=yes 7166e169010aSmrg continue 7167e169010aSmrg ;; 71687914d74bSmrg 7169e8ead290Smrg -bindir) 7170e8ead290Smrg prev=bindir 7171e8ead290Smrg continue 7172e8ead290Smrg ;; 7173e8ead290Smrg 7174e169010aSmrg -dlopen) 7175e169010aSmrg prev=dlfiles 7176e169010aSmrg continue 7177e169010aSmrg ;; 71787914d74bSmrg 7179e169010aSmrg -dlpreopen) 7180e169010aSmrg prev=dlprefiles 7181e169010aSmrg continue 7182e169010aSmrg ;; 71837914d74bSmrg 7184e169010aSmrg -export-dynamic) 7185e169010aSmrg export_dynamic=yes 7186e169010aSmrg continue 7187e169010aSmrg ;; 71887914d74bSmrg 7189e169010aSmrg -export-symbols | -export-symbols-regex) 7190e169010aSmrg if test -n "$export_symbols" || test -n "$export_symbols_regex"; then 7191e169010aSmrg func_fatal_error "more than one -exported-symbols argument is not allowed" 7192e169010aSmrg fi 71939d0ccd10Smrg if test X-export-symbols = "X$arg"; then 7194e169010aSmrg prev=expsyms 7195e169010aSmrg else 7196e169010aSmrg prev=expsyms_regex 7197e169010aSmrg fi 7198e169010aSmrg continue 7199e169010aSmrg ;; 72007914d74bSmrg 7201e169010aSmrg -framework) 7202e169010aSmrg prev=framework 7203e169010aSmrg continue 7204e169010aSmrg ;; 72057914d74bSmrg 7206e169010aSmrg -inst-prefix-dir) 7207e169010aSmrg prev=inst_prefix 7208e169010aSmrg continue 7209e169010aSmrg ;; 72107914d74bSmrg 7211e169010aSmrg # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* 7212e169010aSmrg # so, if we see these flags be careful not to treat them like -L 7213e169010aSmrg -L[A-Z][A-Z]*:*) 7214e169010aSmrg case $with_gcc/$host in 7215e169010aSmrg no/*-*-irix* | /*-*-irix*) 7216e169010aSmrg func_append compile_command " $arg" 7217e169010aSmrg func_append finalize_command " $arg" 7218e169010aSmrg ;; 7219e169010aSmrg esac 7220e169010aSmrg continue 7221e169010aSmrg ;; 72227914d74bSmrg 7223e169010aSmrg -L*) 7224c63293b5Smrg func_stripname "-L" '' "$arg" 7225c63293b5Smrg if test -z "$func_stripname_result"; then 7226e169010aSmrg if test "$#" -gt 0; then 72279d0ccd10Smrg func_fatal_error "require no space between '-L' and '$1'" 7228e169010aSmrg else 72299d0ccd10Smrg func_fatal_error "need path for '-L' option" 7230e169010aSmrg fi 7231e169010aSmrg fi 7232c63293b5Smrg func_resolve_sysroot "$func_stripname_result" 7233c63293b5Smrg dir=$func_resolve_sysroot_result 7234e169010aSmrg # We need an absolute path. 7235e169010aSmrg case $dir in 7236e169010aSmrg [\\/]* | [A-Za-z]:[\\/]*) ;; 7237e169010aSmrg *) 7238e169010aSmrg absdir=`cd "$dir" && pwd` 7239e169010aSmrg test -z "$absdir" && \ 72409d0ccd10Smrg func_fatal_error "cannot determine absolute directory name of '$dir'" 72419d0ccd10Smrg dir=$absdir 7242e169010aSmrg ;; 7243e169010aSmrg esac 7244e169010aSmrg case "$deplibs " in 7245c63293b5Smrg *" -L$dir "* | *" $arg "*) 7246c63293b5Smrg # Will only happen for absolute or sysroot arguments 7247c63293b5Smrg ;; 7248e169010aSmrg *) 7249c63293b5Smrg # Preserve sysroot, but never include relative directories 7250c63293b5Smrg case $dir in 7251c63293b5Smrg [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; 7252c63293b5Smrg *) func_append deplibs " -L$dir" ;; 7253c63293b5Smrg esac 7254c63293b5Smrg func_append lib_search_path " $dir" 7255e169010aSmrg ;; 7256e169010aSmrg esac 7257e169010aSmrg case $host in 7258e169010aSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 7259e8ead290Smrg testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` 7260e169010aSmrg case :$dllsearchpath: in 7261e169010aSmrg *":$dir:"*) ;; 7262e169010aSmrg ::) dllsearchpath=$dir;; 7263c63293b5Smrg *) func_append dllsearchpath ":$dir";; 7264e169010aSmrg esac 7265e169010aSmrg case :$dllsearchpath: in 7266e169010aSmrg *":$testbindir:"*) ;; 7267e169010aSmrg ::) dllsearchpath=$testbindir;; 7268c63293b5Smrg *) func_append dllsearchpath ":$testbindir";; 7269e169010aSmrg esac 7270e169010aSmrg ;; 7271e169010aSmrg esac 7272e169010aSmrg continue 7273e169010aSmrg ;; 72747914d74bSmrg 7275e169010aSmrg -l*) 72769d0ccd10Smrg if test X-lc = "X$arg" || test X-lm = "X$arg"; then 7277e169010aSmrg case $host in 7278e8ead290Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) 7279e169010aSmrg # These systems don't actually have a C or math library (as such) 7280e169010aSmrg continue 7281e169010aSmrg ;; 7282e169010aSmrg *-*-os2*) 7283e169010aSmrg # These systems don't actually have a C library (as such) 72849d0ccd10Smrg test X-lc = "X$arg" && continue 7285e169010aSmrg ;; 72860ea508b1Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig* | *-*-midnightbsd*) 7287e169010aSmrg # Do not include libc due to us having libc/libc_r. 72889d0ccd10Smrg test X-lc = "X$arg" && continue 7289e169010aSmrg ;; 7290e169010aSmrg *-*-rhapsody* | *-*-darwin1.[012]) 7291e169010aSmrg # Rhapsody C and math libraries are in the System framework 7292c63293b5Smrg func_append deplibs " System.ltframework" 7293e169010aSmrg continue 7294e169010aSmrg ;; 7295e169010aSmrg *-*-sco3.2v5* | *-*-sco5v6*) 7296e169010aSmrg # Causes problems with __ctype 72979d0ccd10Smrg test X-lc = "X$arg" && continue 7298e169010aSmrg ;; 7299e169010aSmrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 7300e169010aSmrg # Compiler inserts libc in the correct place for threads to work 73019d0ccd10Smrg test X-lc = "X$arg" && continue 7302e169010aSmrg ;; 7303e169010aSmrg esac 73049d0ccd10Smrg elif test X-lc_r = "X$arg"; then 7305e169010aSmrg case $host in 73060ea508b1Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig* | *-*-midnightbsd*) 7307e169010aSmrg # Do not include libc_r directly, use -pthread flag. 7308e169010aSmrg continue 7309e169010aSmrg ;; 7310e169010aSmrg esac 7311e169010aSmrg fi 7312c63293b5Smrg func_append deplibs " $arg" 7313e169010aSmrg continue 7314e169010aSmrg ;; 73157914d74bSmrg 73169d0ccd10Smrg -mllvm) 73179d0ccd10Smrg prev=mllvm 73189d0ccd10Smrg continue 73199d0ccd10Smrg ;; 73209d0ccd10Smrg 7321e169010aSmrg -module) 7322e169010aSmrg module=yes 7323e169010aSmrg continue 7324e169010aSmrg ;; 73257914d74bSmrg 7326e169010aSmrg # Tru64 UNIX uses -model [arg] to determine the layout of C++ 7327e169010aSmrg # classes, name mangling, and exception handling. 7328e169010aSmrg # Darwin uses the -arch flag to determine output architecture. 7329c63293b5Smrg -model|-arch|-isysroot|--sysroot) 7330c63293b5Smrg func_append compiler_flags " $arg" 7331e169010aSmrg func_append compile_command " $arg" 7332e169010aSmrg func_append finalize_command " $arg" 7333e169010aSmrg prev=xcompiler 7334e169010aSmrg continue 7335e169010aSmrg ;; 73360ea508b1Smrg # Solaris ld rejects as of 11.4. Refer to Oracle bug 22985199. 73370ea508b1Smrg -pthread) 73380ea508b1Smrg case $host in 73390ea508b1Smrg *solaris2*) ;; 73400ea508b1Smrg *) 73410ea508b1Smrg case "$new_inherited_linker_flags " in 73420ea508b1Smrg *" $arg "*) ;; 73430ea508b1Smrg * ) func_append new_inherited_linker_flags " $arg" ;; 73440ea508b1Smrg esac 73450ea508b1Smrg ;; 73460ea508b1Smrg esac 73470ea508b1Smrg continue 73480ea508b1Smrg ;; 73490ea508b1Smrg -mt|-mthreads|-kthread|-Kthread|-pthreads|--thread-safe \ 7350e6d5e4e0Smrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 7351c63293b5Smrg func_append compiler_flags " $arg" 7352e169010aSmrg func_append compile_command " $arg" 7353e169010aSmrg func_append finalize_command " $arg" 7354e169010aSmrg case "$new_inherited_linker_flags " in 7355e169010aSmrg *" $arg "*) ;; 7356c63293b5Smrg * ) func_append new_inherited_linker_flags " $arg" ;; 7357e169010aSmrg esac 7358e169010aSmrg continue 7359e169010aSmrg ;; 73607914d74bSmrg 7361e169010aSmrg -multi_module) 73629d0ccd10Smrg single_module=$wl-multi_module 7363e169010aSmrg continue 7364e169010aSmrg ;; 73657914d74bSmrg 7366e169010aSmrg -no-fast-install) 7367e169010aSmrg fast_install=no 7368e169010aSmrg continue 7369e169010aSmrg ;; 73707914d74bSmrg 7371e169010aSmrg -no-install) 7372e169010aSmrg case $host in 7373e169010aSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) 7374e169010aSmrg # The PATH hackery in wrapper scripts is required on Windows 7375e169010aSmrg # and Darwin in order for the loader to find any dlls it needs. 73769d0ccd10Smrg func_warning "'-no-install' is ignored for $host" 73779d0ccd10Smrg func_warning "assuming '-no-fast-install' instead" 7378e169010aSmrg fast_install=no 7379e169010aSmrg ;; 7380e169010aSmrg *) no_install=yes ;; 7381e169010aSmrg esac 7382e169010aSmrg continue 7383e169010aSmrg ;; 73847914d74bSmrg 7385e169010aSmrg -no-undefined) 7386e169010aSmrg allow_undefined=no 7387e169010aSmrg continue 7388e169010aSmrg ;; 73897914d74bSmrg 7390e169010aSmrg -objectlist) 7391e169010aSmrg prev=objectlist 7392e169010aSmrg continue 7393e169010aSmrg ;; 73947914d74bSmrg 73959d0ccd10Smrg -os2dllname) 73969d0ccd10Smrg prev=os2dllname 73979d0ccd10Smrg continue 73989d0ccd10Smrg ;; 73999d0ccd10Smrg 7400e169010aSmrg -o) prev=output ;; 74017914d74bSmrg 7402e169010aSmrg -precious-files-regex) 7403e169010aSmrg prev=precious_regex 7404e169010aSmrg continue 7405e169010aSmrg ;; 74067914d74bSmrg 7407e169010aSmrg -release) 7408e169010aSmrg prev=release 7409e169010aSmrg continue 7410e169010aSmrg ;; 74117914d74bSmrg 7412e169010aSmrg -rpath) 7413e169010aSmrg prev=rpath 7414e169010aSmrg continue 7415e169010aSmrg ;; 74167914d74bSmrg 7417e169010aSmrg -R) 7418e169010aSmrg prev=xrpath 7419e169010aSmrg continue 7420e169010aSmrg ;; 74217914d74bSmrg 7422e169010aSmrg -R*) 7423e169010aSmrg func_stripname '-R' '' "$arg" 7424e169010aSmrg dir=$func_stripname_result 7425e169010aSmrg # We need an absolute path. 7426e169010aSmrg case $dir in 7427e169010aSmrg [\\/]* | [A-Za-z]:[\\/]*) ;; 7428c63293b5Smrg =*) 7429c63293b5Smrg func_stripname '=' '' "$dir" 7430c63293b5Smrg dir=$lt_sysroot$func_stripname_result 7431c63293b5Smrg ;; 7432e169010aSmrg *) 7433e169010aSmrg func_fatal_error "only absolute run-paths are allowed" 7434e169010aSmrg ;; 7435e169010aSmrg esac 7436e169010aSmrg case "$xrpath " in 7437e169010aSmrg *" $dir "*) ;; 7438c63293b5Smrg *) func_append xrpath " $dir" ;; 7439e169010aSmrg esac 7440e169010aSmrg continue 7441e169010aSmrg ;; 74427914d74bSmrg 7443e169010aSmrg -shared) 7444e169010aSmrg # The effects of -shared are defined in a previous loop. 7445e169010aSmrg continue 7446e169010aSmrg ;; 74477914d74bSmrg 7448e169010aSmrg -shrext) 7449e169010aSmrg prev=shrext 7450e169010aSmrg continue 7451e169010aSmrg ;; 74527914d74bSmrg 7453e169010aSmrg -static | -static-libtool-libs) 7454e169010aSmrg # The effects of -static are defined in a previous loop. 7455e169010aSmrg # We used to do the same as -all-static on platforms that 7456e169010aSmrg # didn't have a PIC flag, but the assumption that the effects 7457e169010aSmrg # would be equivalent was wrong. It would break on at least 7458e169010aSmrg # Digital Unix and AIX. 7459e169010aSmrg continue 7460e169010aSmrg ;; 74617914d74bSmrg 7462e169010aSmrg -thread-safe) 7463e169010aSmrg thread_safe=yes 7464e169010aSmrg continue 7465e169010aSmrg ;; 74667914d74bSmrg 7467e169010aSmrg -version-info) 7468e169010aSmrg prev=vinfo 7469e169010aSmrg continue 7470e169010aSmrg ;; 74717914d74bSmrg 7472e169010aSmrg -version-number) 7473e169010aSmrg prev=vinfo 7474e169010aSmrg vinfo_number=yes 7475e169010aSmrg continue 7476e169010aSmrg ;; 74777914d74bSmrg 7478e169010aSmrg -weak) 7479e169010aSmrg prev=weak 7480e169010aSmrg continue 7481e169010aSmrg ;; 74827914d74bSmrg 7483e169010aSmrg -Wc,*) 7484e169010aSmrg func_stripname '-Wc,' '' "$arg" 7485e169010aSmrg args=$func_stripname_result 7486e169010aSmrg arg= 74879d0ccd10Smrg save_ifs=$IFS; IFS=, 7488e169010aSmrg for flag in $args; do 74899d0ccd10Smrg IFS=$save_ifs 74900ea508b1Smrg func_quote_arg pretty "$flag" 74910ea508b1Smrg func_append arg " $func_quote_arg_result" 74920ea508b1Smrg func_append compiler_flags " $func_quote_arg_result" 7493e169010aSmrg done 74949d0ccd10Smrg IFS=$save_ifs 7495e169010aSmrg func_stripname ' ' '' "$arg" 7496e169010aSmrg arg=$func_stripname_result 7497e169010aSmrg ;; 74987914d74bSmrg 7499e169010aSmrg -Wl,*) 7500e169010aSmrg func_stripname '-Wl,' '' "$arg" 7501e169010aSmrg args=$func_stripname_result 7502e169010aSmrg arg= 75039d0ccd10Smrg save_ifs=$IFS; IFS=, 7504e169010aSmrg for flag in $args; do 75059d0ccd10Smrg IFS=$save_ifs 75060ea508b1Smrg func_quote_arg pretty "$flag" 75070ea508b1Smrg func_append arg " $wl$func_quote_arg_result" 75080ea508b1Smrg func_append compiler_flags " $wl$func_quote_arg_result" 75090ea508b1Smrg func_append linker_flags " $func_quote_arg_result" 7510e169010aSmrg done 75119d0ccd10Smrg IFS=$save_ifs 7512e169010aSmrg func_stripname ' ' '' "$arg" 7513e169010aSmrg arg=$func_stripname_result 7514e169010aSmrg ;; 75157914d74bSmrg 75160ea508b1Smrg -Xassembler) 75170ea508b1Smrg prev=xassembler 75180ea508b1Smrg continue 75190ea508b1Smrg ;; 75200ea508b1Smrg 7521e169010aSmrg -Xcompiler) 7522e169010aSmrg prev=xcompiler 7523e169010aSmrg continue 7524e169010aSmrg ;; 75257914d74bSmrg 7526e169010aSmrg -Xlinker) 7527e169010aSmrg prev=xlinker 7528e169010aSmrg continue 7529e169010aSmrg ;; 75307914d74bSmrg 7531e169010aSmrg -XCClinker) 7532e169010aSmrg prev=xcclinker 7533e169010aSmrg continue 7534e169010aSmrg ;; 75357914d74bSmrg 7536e169010aSmrg # -msg_* for osf cc 7537e169010aSmrg -msg_*) 75380ea508b1Smrg func_quote_arg pretty "$arg" 75390ea508b1Smrg arg=$func_quote_arg_result 7540e169010aSmrg ;; 75417914d74bSmrg 7542e8ead290Smrg # Flags to be passed through unchanged, with rationale: 7543e8ead290Smrg # -64, -mips[0-9] enable 64-bit mode for the SGI compiler 7544e8ead290Smrg # -r[0-9][0-9]* specify processor for the SGI compiler 7545e8ead290Smrg # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler 7546e8ead290Smrg # +DA*, +DD* enable 64-bit mode for the HP compiler 7547e8ead290Smrg # -q* compiler args for the IBM compiler 7548e8ead290Smrg # -m*, -t[45]*, -txscale* architecture-specific flags for GCC 7549e8ead290Smrg # -F/path path to uninstalled frameworks, gcc on darwin 7550e8ead290Smrg # -p, -pg, --coverage, -fprofile-* profiling flags for GCC 75519d0ccd10Smrg # -fstack-protector* stack protector flags for GCC 7552e8ead290Smrg # @file GCC response files 7553e8ead290Smrg # -tp=* Portland pgcc target processor selection 7554c63293b5Smrg # --sysroot=* for sysroot support 75559d0ccd10Smrg # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization 75560ea508b1Smrg # -specs=* GCC specs files 75579d0ccd10Smrg # -stdlib=* select c++ std lib with clang 75580ea508b1Smrg # -fsanitize=* Clang/GCC memory and address sanitizer 75590ea508b1Smrg # -fuse-ld=* Linker select flags for GCC 75600ea508b1Smrg # -Wa,* Pass flags directly to the assembler 7561e169010aSmrg -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ 7562c63293b5Smrg -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ 75630ea508b1Smrg -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*| \ 75640ea508b1Smrg -specs=*|-fsanitize=*|-fuse-ld=*|-Wa,*) 75650ea508b1Smrg func_quote_arg pretty "$arg" 75660ea508b1Smrg arg=$func_quote_arg_result 7567e169010aSmrg func_append compile_command " $arg" 7568e169010aSmrg func_append finalize_command " $arg" 7569c63293b5Smrg func_append compiler_flags " $arg" 7570e169010aSmrg continue 7571e169010aSmrg ;; 75727914d74bSmrg 75739d0ccd10Smrg -Z*) 75749d0ccd10Smrg if test os2 = "`expr $host : '.*\(os2\)'`"; then 75759d0ccd10Smrg # OS/2 uses -Zxxx to specify OS/2-specific options 75769d0ccd10Smrg compiler_flags="$compiler_flags $arg" 75779d0ccd10Smrg func_append compile_command " $arg" 75789d0ccd10Smrg func_append finalize_command " $arg" 75799d0ccd10Smrg case $arg in 75809d0ccd10Smrg -Zlinker | -Zstack) 75819d0ccd10Smrg prev=xcompiler 75829d0ccd10Smrg ;; 75839d0ccd10Smrg esac 75849d0ccd10Smrg continue 75859d0ccd10Smrg else 75869d0ccd10Smrg # Otherwise treat like 'Some other compiler flag' below 75870ea508b1Smrg func_quote_arg pretty "$arg" 75880ea508b1Smrg arg=$func_quote_arg_result 75899d0ccd10Smrg fi 75909d0ccd10Smrg ;; 75919d0ccd10Smrg 7592e169010aSmrg # Some other compiler flag. 7593e169010aSmrg -* | +*) 75940ea508b1Smrg func_quote_arg pretty "$arg" 75950ea508b1Smrg arg=$func_quote_arg_result 7596e169010aSmrg ;; 75977914d74bSmrg 7598e169010aSmrg *.$objext) 7599e169010aSmrg # A standard object. 7600c63293b5Smrg func_append objs " $arg" 7601e169010aSmrg ;; 7602e169010aSmrg 7603e169010aSmrg *.lo) 7604e169010aSmrg # A libtool-controlled object. 7605e169010aSmrg 7606e169010aSmrg # Check to see that this really is a libtool object. 7607e169010aSmrg if func_lalib_unsafe_p "$arg"; then 7608e169010aSmrg pic_object= 7609e169010aSmrg non_pic_object= 7610e169010aSmrg 7611e169010aSmrg # Read the .lo file 7612e169010aSmrg func_source "$arg" 7613e169010aSmrg 7614e169010aSmrg if test -z "$pic_object" || 7615e169010aSmrg test -z "$non_pic_object" || 76169d0ccd10Smrg test none = "$pic_object" && 76179d0ccd10Smrg test none = "$non_pic_object"; then 76189d0ccd10Smrg func_fatal_error "cannot find name of object for '$arg'" 7619e169010aSmrg fi 7620e169010aSmrg 7621e169010aSmrg # Extract subdirectory from the argument. 7622e169010aSmrg func_dirname "$arg" "/" "" 76239d0ccd10Smrg xdir=$func_dirname_result 7624e169010aSmrg 76259d0ccd10Smrg test none = "$pic_object" || { 7626e169010aSmrg # Prepend the subdirectory the object is found in. 76279d0ccd10Smrg pic_object=$xdir$pic_object 7628e169010aSmrg 76299d0ccd10Smrg if test dlfiles = "$prev"; then 76309d0ccd10Smrg if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 7631c63293b5Smrg func_append dlfiles " $pic_object" 7632e169010aSmrg prev= 7633e169010aSmrg continue 7634e169010aSmrg else 7635e169010aSmrg # If libtool objects are unsupported, then we need to preload. 7636e169010aSmrg prev=dlprefiles 7637e169010aSmrg fi 7638e169010aSmrg fi 7639e169010aSmrg 7640e169010aSmrg # CHECK ME: I think I busted this. -Ossama 76419d0ccd10Smrg if test dlprefiles = "$prev"; then 7642e169010aSmrg # Preload the old-style object. 7643c63293b5Smrg func_append dlprefiles " $pic_object" 7644e169010aSmrg prev= 7645e169010aSmrg fi 7646e169010aSmrg 7647e169010aSmrg # A PIC object. 7648e169010aSmrg func_append libobjs " $pic_object" 76499d0ccd10Smrg arg=$pic_object 76509d0ccd10Smrg } 7651e169010aSmrg 7652e169010aSmrg # Non-PIC object. 76539d0ccd10Smrg if test none != "$non_pic_object"; then 7654e169010aSmrg # Prepend the subdirectory the object is found in. 76559d0ccd10Smrg non_pic_object=$xdir$non_pic_object 7656e169010aSmrg 7657e169010aSmrg # A standard non-PIC object 7658e169010aSmrg func_append non_pic_objects " $non_pic_object" 76599d0ccd10Smrg if test -z "$pic_object" || test none = "$pic_object"; then 76609d0ccd10Smrg arg=$non_pic_object 7661e169010aSmrg fi 7662e169010aSmrg else 7663e169010aSmrg # If the PIC object exists, use it instead. 7664e169010aSmrg # $xdir was prepended to $pic_object above. 76659d0ccd10Smrg non_pic_object=$pic_object 7666e169010aSmrg func_append non_pic_objects " $non_pic_object" 7667e169010aSmrg fi 7668e169010aSmrg else 7669e169010aSmrg # Only an error if not doing a dry-run. 7670e169010aSmrg if $opt_dry_run; then 7671e169010aSmrg # Extract subdirectory from the argument. 7672e169010aSmrg func_dirname "$arg" "/" "" 76739d0ccd10Smrg xdir=$func_dirname_result 7674e169010aSmrg 7675e169010aSmrg func_lo2o "$arg" 7676e169010aSmrg pic_object=$xdir$objdir/$func_lo2o_result 7677e169010aSmrg non_pic_object=$xdir$func_lo2o_result 7678e169010aSmrg func_append libobjs " $pic_object" 7679e169010aSmrg func_append non_pic_objects " $non_pic_object" 7680e169010aSmrg else 76819d0ccd10Smrg func_fatal_error "'$arg' is not a valid libtool object" 7682e169010aSmrg fi 7683e169010aSmrg fi 7684e169010aSmrg ;; 7685e169010aSmrg 7686e169010aSmrg *.$libext) 7687e169010aSmrg # An archive. 7688c63293b5Smrg func_append deplibs " $arg" 7689c63293b5Smrg func_append old_deplibs " $arg" 7690e169010aSmrg continue 7691e169010aSmrg ;; 7692e169010aSmrg 7693e169010aSmrg *.la) 7694e169010aSmrg # A libtool-controlled library. 7695e169010aSmrg 7696c63293b5Smrg func_resolve_sysroot "$arg" 76979d0ccd10Smrg if test dlfiles = "$prev"; then 7698e169010aSmrg # This library was specified with -dlopen. 7699c63293b5Smrg func_append dlfiles " $func_resolve_sysroot_result" 7700e169010aSmrg prev= 77019d0ccd10Smrg elif test dlprefiles = "$prev"; then 7702e169010aSmrg # The library was specified with -dlpreopen. 7703c63293b5Smrg func_append dlprefiles " $func_resolve_sysroot_result" 7704e169010aSmrg prev= 7705e169010aSmrg else 7706c63293b5Smrg func_append deplibs " $func_resolve_sysroot_result" 7707e169010aSmrg fi 7708e169010aSmrg continue 7709e169010aSmrg ;; 7710e169010aSmrg 7711e169010aSmrg # Some other compiler argument. 7712e169010aSmrg *) 7713e169010aSmrg # Unknown arguments in both finalize_command and compile_command need 7714e169010aSmrg # to be aesthetically quoted because they are evaled later. 77150ea508b1Smrg func_quote_arg pretty "$arg" 77160ea508b1Smrg arg=$func_quote_arg_result 7717e169010aSmrg ;; 7718e169010aSmrg esac # arg 7719e169010aSmrg 7720e169010aSmrg # Now actually substitute the argument into the commands. 7721e169010aSmrg if test -n "$arg"; then 7722e169010aSmrg func_append compile_command " $arg" 7723e169010aSmrg func_append finalize_command " $arg" 7724e169010aSmrg fi 7725e169010aSmrg done # argument parsing loop 7726e169010aSmrg 7727e169010aSmrg test -n "$prev" && \ 77289d0ccd10Smrg func_fatal_help "the '$prevarg' option requires an argument" 7729e169010aSmrg 77309d0ccd10Smrg if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then 7731e169010aSmrg eval arg=\"$export_dynamic_flag_spec\" 7732e169010aSmrg func_append compile_command " $arg" 7733e169010aSmrg func_append finalize_command " $arg" 7734e169010aSmrg fi 7735e169010aSmrg 7736e169010aSmrg oldlibs= 7737e169010aSmrg # calculate the name of the file, without its directory 7738e169010aSmrg func_basename "$output" 77399d0ccd10Smrg outputname=$func_basename_result 77409d0ccd10Smrg libobjs_save=$libobjs 7741e169010aSmrg 7742e169010aSmrg if test -n "$shlibpath_var"; then 7743e169010aSmrg # get the directories listed in $shlibpath_var 77449d0ccd10Smrg eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\` 77457914d74bSmrg else 7746e169010aSmrg shlib_search_path= 77477914d74bSmrg fi 7748e169010aSmrg eval sys_lib_search_path=\"$sys_lib_search_path_spec\" 7749e169010aSmrg eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" 77507914d74bSmrg 77519d0ccd10Smrg # Definition is injected by LT_CONFIG during libtool generation. 77529d0ccd10Smrg func_munge_path_list sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH" 77539d0ccd10Smrg 7754e169010aSmrg func_dirname "$output" "/" "" 77559d0ccd10Smrg output_objdir=$func_dirname_result$objdir 7756c63293b5Smrg func_to_tool_file "$output_objdir/" 7757c63293b5Smrg tool_output_objdir=$func_to_tool_file_result 7758e169010aSmrg # Create the object directory. 7759e169010aSmrg func_mkdir_p "$output_objdir" 77607914d74bSmrg 7761e169010aSmrg # Determine the type of output 7762e169010aSmrg case $output in 7763e169010aSmrg "") 7764e169010aSmrg func_fatal_help "you must specify an output file" 7765e169010aSmrg ;; 7766e169010aSmrg *.$libext) linkmode=oldlib ;; 7767e169010aSmrg *.lo | *.$objext) linkmode=obj ;; 7768e169010aSmrg *.la) linkmode=lib ;; 7769e169010aSmrg *) linkmode=prog ;; # Anything else should be a program. 7770e169010aSmrg esac 7771e169010aSmrg 7772e169010aSmrg specialdeplibs= 7773e169010aSmrg 7774e169010aSmrg libs= 7775e169010aSmrg # Find all interdependent deplibs by searching for libraries 7776e169010aSmrg # that are linked more than once (e.g. -la -lb -la) 7777e169010aSmrg for deplib in $deplibs; do 77789d0ccd10Smrg if $opt_preserve_dup_deps; then 7779e169010aSmrg case "$libs " in 7780c63293b5Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 7781e169010aSmrg esac 7782e169010aSmrg fi 7783c63293b5Smrg func_append libs " $deplib" 7784e169010aSmrg done 7785e169010aSmrg 77869d0ccd10Smrg if test lib = "$linkmode"; then 7787e169010aSmrg libs="$predeps $libs $compiler_lib_search_path $postdeps" 7788e169010aSmrg 7789e169010aSmrg # Compute libraries that are listed more than once in $predeps 7790e169010aSmrg # $postdeps and mark them as special (i.e., whose duplicates are 7791e169010aSmrg # not to be eliminated). 7792e169010aSmrg pre_post_deps= 7793e169010aSmrg if $opt_duplicate_compiler_generated_deps; then 7794e169010aSmrg for pre_post_dep in $predeps $postdeps; do 7795e169010aSmrg case "$pre_post_deps " in 7796c63293b5Smrg *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; 7797e169010aSmrg esac 7798c63293b5Smrg func_append pre_post_deps " $pre_post_dep" 7799e169010aSmrg done 7800e169010aSmrg fi 7801e169010aSmrg pre_post_deps= 7802e169010aSmrg fi 7803e169010aSmrg 7804e169010aSmrg deplibs= 7805e169010aSmrg newdependency_libs= 7806e169010aSmrg newlib_search_path= 7807e169010aSmrg need_relink=no # whether we're linking any uninstalled libtool libraries 7808e169010aSmrg notinst_deplibs= # not-installed libtool libraries 7809e169010aSmrg notinst_path= # paths that contain not-installed libtool libraries 7810e169010aSmrg 7811e169010aSmrg case $linkmode in 7812e169010aSmrg lib) 7813e169010aSmrg passes="conv dlpreopen link" 7814e169010aSmrg for file in $dlfiles $dlprefiles; do 7815e169010aSmrg case $file in 7816e169010aSmrg *.la) ;; 7817e169010aSmrg *) 78189d0ccd10Smrg func_fatal_help "libraries can '-dlopen' only libtool libraries: $file" 7819e169010aSmrg ;; 7820e169010aSmrg esac 7821e169010aSmrg done 7822e169010aSmrg ;; 7823e169010aSmrg prog) 7824e169010aSmrg compile_deplibs= 7825e169010aSmrg finalize_deplibs= 78269d0ccd10Smrg alldeplibs=false 7827e169010aSmrg newdlfiles= 7828e169010aSmrg newdlprefiles= 7829e169010aSmrg passes="conv scan dlopen dlpreopen link" 7830e169010aSmrg ;; 7831e169010aSmrg *) passes="conv" 7832e169010aSmrg ;; 7833e169010aSmrg esac 7834e169010aSmrg 7835e169010aSmrg for pass in $passes; do 7836e169010aSmrg # The preopen pass in lib mode reverses $deplibs; put it back here 7837e169010aSmrg # so that -L comes before libs that need it for instance... 78389d0ccd10Smrg if test lib,link = "$linkmode,$pass"; then 7839e169010aSmrg ## FIXME: Find the place where the list is rebuilt in the wrong 7840e169010aSmrg ## order, and fix it there properly 7841e169010aSmrg tmp_deplibs= 7842e169010aSmrg for deplib in $deplibs; do 7843e169010aSmrg tmp_deplibs="$deplib $tmp_deplibs" 7844e169010aSmrg done 78459d0ccd10Smrg deplibs=$tmp_deplibs 7846e169010aSmrg fi 7847e169010aSmrg 78489d0ccd10Smrg if test lib,link = "$linkmode,$pass" || 78499d0ccd10Smrg test prog,scan = "$linkmode,$pass"; then 78509d0ccd10Smrg libs=$deplibs 7851e169010aSmrg deplibs= 7852e169010aSmrg fi 78539d0ccd10Smrg if test prog = "$linkmode"; then 7854e169010aSmrg case $pass in 78559d0ccd10Smrg dlopen) libs=$dlfiles ;; 78569d0ccd10Smrg dlpreopen) libs=$dlprefiles ;; 7857cdce750aSmrg link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; 7858e169010aSmrg esac 7859e169010aSmrg fi 78609d0ccd10Smrg if test lib,dlpreopen = "$linkmode,$pass"; then 7861e169010aSmrg # Collect and forward deplibs of preopened libtool libs 7862e169010aSmrg for lib in $dlprefiles; do 7863e169010aSmrg # Ignore non-libtool-libs 7864e169010aSmrg dependency_libs= 7865c63293b5Smrg func_resolve_sysroot "$lib" 7866e169010aSmrg case $lib in 7867c63293b5Smrg *.la) func_source "$func_resolve_sysroot_result" ;; 7868e169010aSmrg esac 7869e169010aSmrg 7870e169010aSmrg # Collect preopened libtool deplibs, except any this library 7871e169010aSmrg # has declared as weak libs 7872e169010aSmrg for deplib in $dependency_libs; do 7873e8ead290Smrg func_basename "$deplib" 7874e8ead290Smrg deplib_base=$func_basename_result 7875e169010aSmrg case " $weak_libs " in 7876e169010aSmrg *" $deplib_base "*) ;; 7877c63293b5Smrg *) func_append deplibs " $deplib" ;; 7878e169010aSmrg esac 7879e169010aSmrg done 7880e169010aSmrg done 78819d0ccd10Smrg libs=$dlprefiles 7882e169010aSmrg fi 78839d0ccd10Smrg if test dlopen = "$pass"; then 7884e169010aSmrg # Collect dlpreopened libraries 78859d0ccd10Smrg save_deplibs=$deplibs 7886e169010aSmrg deplibs= 7887e169010aSmrg fi 7888e169010aSmrg 7889e169010aSmrg for deplib in $libs; do 7890e169010aSmrg lib= 78919d0ccd10Smrg found=false 7892e169010aSmrg case $deplib in 7893e6d5e4e0Smrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 7894e6d5e4e0Smrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 78959d0ccd10Smrg if test prog,link = "$linkmode,$pass"; then 7896e169010aSmrg compile_deplibs="$deplib $compile_deplibs" 7897e169010aSmrg finalize_deplibs="$deplib $finalize_deplibs" 7898e169010aSmrg else 7899c63293b5Smrg func_append compiler_flags " $deplib" 79009d0ccd10Smrg if test lib = "$linkmode"; then 7901e169010aSmrg case "$new_inherited_linker_flags " in 7902e169010aSmrg *" $deplib "*) ;; 7903c63293b5Smrg * ) func_append new_inherited_linker_flags " $deplib" ;; 7904e169010aSmrg esac 7905e169010aSmrg fi 7906e169010aSmrg fi 7907e169010aSmrg continue 7908e169010aSmrg ;; 7909e169010aSmrg -l*) 79109d0ccd10Smrg if test lib != "$linkmode" && test prog != "$linkmode"; then 79119d0ccd10Smrg func_warning "'-l' is ignored for archives/objects" 7912e169010aSmrg continue 7913e169010aSmrg fi 7914e169010aSmrg func_stripname '-l' '' "$deplib" 7915e169010aSmrg name=$func_stripname_result 79169d0ccd10Smrg if test lib = "$linkmode"; then 7917e169010aSmrg searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" 7918e169010aSmrg else 7919e169010aSmrg searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" 7920e169010aSmrg fi 7921e169010aSmrg for searchdir in $searchdirs; do 7922e169010aSmrg for search_ext in .la $std_shrext .so .a; do 7923e169010aSmrg # Search the libtool library 79249d0ccd10Smrg lib=$searchdir/lib$name$search_ext 7925e169010aSmrg if test -f "$lib"; then 79269d0ccd10Smrg if test .la = "$search_ext"; then 79279d0ccd10Smrg found=: 7928e169010aSmrg else 79299d0ccd10Smrg found=false 7930e169010aSmrg fi 7931e169010aSmrg break 2 7932e169010aSmrg fi 7933e169010aSmrg done 7934e169010aSmrg done 79359d0ccd10Smrg if $found; then 79369d0ccd10Smrg # deplib is a libtool library 7937e169010aSmrg # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, 7938e169010aSmrg # We need to do some special things here, and not later. 79399d0ccd10Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 7940e169010aSmrg case " $predeps $postdeps " in 7941e169010aSmrg *" $deplib "*) 7942e169010aSmrg if func_lalib_p "$lib"; then 7943e169010aSmrg library_names= 7944e169010aSmrg old_library= 7945e169010aSmrg func_source "$lib" 7946e169010aSmrg for l in $old_library $library_names; do 79479d0ccd10Smrg ll=$l 7948e169010aSmrg done 79499d0ccd10Smrg if test "X$ll" = "X$old_library"; then # only static version available 79509d0ccd10Smrg found=false 7951e169010aSmrg func_dirname "$lib" "" "." 79529d0ccd10Smrg ladir=$func_dirname_result 7953e169010aSmrg lib=$ladir/$old_library 79549d0ccd10Smrg if test prog,link = "$linkmode,$pass"; then 7955e169010aSmrg compile_deplibs="$deplib $compile_deplibs" 7956e169010aSmrg finalize_deplibs="$deplib $finalize_deplibs" 7957e169010aSmrg else 7958e169010aSmrg deplibs="$deplib $deplibs" 79599d0ccd10Smrg test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 7960e169010aSmrg fi 7961e169010aSmrg continue 7962e169010aSmrg fi 7963e169010aSmrg fi 7964e169010aSmrg ;; 7965e169010aSmrg *) ;; 7966e169010aSmrg esac 7967e169010aSmrg fi 79689d0ccd10Smrg else 79699d0ccd10Smrg # deplib doesn't seem to be a libtool library 79709d0ccd10Smrg if test prog,link = "$linkmode,$pass"; then 79719d0ccd10Smrg compile_deplibs="$deplib $compile_deplibs" 79729d0ccd10Smrg finalize_deplibs="$deplib $finalize_deplibs" 79739d0ccd10Smrg else 79749d0ccd10Smrg deplibs="$deplib $deplibs" 79759d0ccd10Smrg test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 79769d0ccd10Smrg fi 79779d0ccd10Smrg continue 7978e169010aSmrg fi 7979e169010aSmrg ;; # -l 7980e169010aSmrg *.ltframework) 79819d0ccd10Smrg if test prog,link = "$linkmode,$pass"; then 7982e169010aSmrg compile_deplibs="$deplib $compile_deplibs" 7983e169010aSmrg finalize_deplibs="$deplib $finalize_deplibs" 7984e169010aSmrg else 7985e169010aSmrg deplibs="$deplib $deplibs" 79869d0ccd10Smrg if test lib = "$linkmode"; then 7987e169010aSmrg case "$new_inherited_linker_flags " in 7988e169010aSmrg *" $deplib "*) ;; 7989c63293b5Smrg * ) func_append new_inherited_linker_flags " $deplib" ;; 7990e169010aSmrg esac 7991e169010aSmrg fi 7992e169010aSmrg fi 7993e169010aSmrg continue 7994e169010aSmrg ;; 7995e169010aSmrg -L*) 7996e169010aSmrg case $linkmode in 7997e169010aSmrg lib) 7998e169010aSmrg deplibs="$deplib $deplibs" 79999d0ccd10Smrg test conv = "$pass" && continue 8000e169010aSmrg newdependency_libs="$deplib $newdependency_libs" 8001e169010aSmrg func_stripname '-L' '' "$deplib" 8002c63293b5Smrg func_resolve_sysroot "$func_stripname_result" 8003c63293b5Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 8004e169010aSmrg ;; 8005e169010aSmrg prog) 80069d0ccd10Smrg if test conv = "$pass"; then 8007e169010aSmrg deplibs="$deplib $deplibs" 8008e169010aSmrg continue 8009e169010aSmrg fi 80109d0ccd10Smrg if test scan = "$pass"; then 8011e169010aSmrg deplibs="$deplib $deplibs" 8012e169010aSmrg else 8013e169010aSmrg compile_deplibs="$deplib $compile_deplibs" 8014e169010aSmrg finalize_deplibs="$deplib $finalize_deplibs" 8015e169010aSmrg fi 8016e169010aSmrg func_stripname '-L' '' "$deplib" 8017c63293b5Smrg func_resolve_sysroot "$func_stripname_result" 8018c63293b5Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 8019e169010aSmrg ;; 8020e169010aSmrg *) 80219d0ccd10Smrg func_warning "'-L' is ignored for archives/objects" 8022e169010aSmrg ;; 8023e169010aSmrg esac # linkmode 8024e169010aSmrg continue 8025e169010aSmrg ;; # -L 8026e169010aSmrg -R*) 80279d0ccd10Smrg if test link = "$pass"; then 8028e169010aSmrg func_stripname '-R' '' "$deplib" 8029c63293b5Smrg func_resolve_sysroot "$func_stripname_result" 8030c63293b5Smrg dir=$func_resolve_sysroot_result 8031e169010aSmrg # Make sure the xrpath contains only unique directories. 8032e169010aSmrg case "$xrpath " in 8033e169010aSmrg *" $dir "*) ;; 8034c63293b5Smrg *) func_append xrpath " $dir" ;; 8035e169010aSmrg esac 8036e169010aSmrg fi 8037e169010aSmrg deplibs="$deplib $deplibs" 8038e169010aSmrg continue 8039e169010aSmrg ;; 8040c63293b5Smrg *.la) 8041c63293b5Smrg func_resolve_sysroot "$deplib" 8042c63293b5Smrg lib=$func_resolve_sysroot_result 8043c63293b5Smrg ;; 8044e169010aSmrg *.$libext) 80459d0ccd10Smrg if test conv = "$pass"; then 8046e169010aSmrg deplibs="$deplib $deplibs" 8047e169010aSmrg continue 8048e169010aSmrg fi 8049e169010aSmrg case $linkmode in 8050e169010aSmrg lib) 8051e169010aSmrg # Linking convenience modules into shared libraries is allowed, 8052e169010aSmrg # but linking other static libraries is non-portable. 8053e169010aSmrg case " $dlpreconveniencelibs " in 8054e169010aSmrg *" $deplib "*) ;; 8055e169010aSmrg *) 80569d0ccd10Smrg valid_a_lib=false 8057e169010aSmrg case $deplibs_check_method in 8058e169010aSmrg match_pattern*) 8059e169010aSmrg set dummy $deplibs_check_method; shift 8060e169010aSmrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 8061e8ead290Smrg if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ 8062e169010aSmrg | $EGREP "$match_pattern_regex" > /dev/null; then 80639d0ccd10Smrg valid_a_lib=: 8064e169010aSmrg fi 8065e169010aSmrg ;; 8066e169010aSmrg pass_all) 80679d0ccd10Smrg valid_a_lib=: 8068e169010aSmrg ;; 8069e169010aSmrg esac 80709d0ccd10Smrg if $valid_a_lib; then 80719d0ccd10Smrg echo 80729d0ccd10Smrg $ECHO "*** Warning: Linking the shared library $output against the" 80739d0ccd10Smrg $ECHO "*** static library $deplib is not portable!" 80749d0ccd10Smrg deplibs="$deplib $deplibs" 80759d0ccd10Smrg else 8076e8ead290Smrg echo 8077e169010aSmrg $ECHO "*** Warning: Trying to link with static lib archive $deplib." 8078e8ead290Smrg echo "*** I have the capability to make that library automatically link in when" 8079e8ead290Smrg echo "*** you link to this library. But I can only do this if you have a" 8080e8ead290Smrg echo "*** shared version of the library, which you do not appear to have" 8081e8ead290Smrg echo "*** because the file extensions .$libext of this argument makes me believe" 8082e8ead290Smrg echo "*** that it is just a static archive that I should not use here." 8083e169010aSmrg fi 8084e169010aSmrg ;; 8085e169010aSmrg esac 8086e169010aSmrg continue 8087e169010aSmrg ;; 8088e169010aSmrg prog) 80899d0ccd10Smrg if test link != "$pass"; then 8090e169010aSmrg deplibs="$deplib $deplibs" 8091e169010aSmrg else 8092e169010aSmrg compile_deplibs="$deplib $compile_deplibs" 8093e169010aSmrg finalize_deplibs="$deplib $finalize_deplibs" 8094e169010aSmrg fi 8095e169010aSmrg continue 8096e169010aSmrg ;; 8097e169010aSmrg esac # linkmode 8098e169010aSmrg ;; # *.$libext 8099e169010aSmrg *.lo | *.$objext) 81009d0ccd10Smrg if test conv = "$pass"; then 8101e169010aSmrg deplibs="$deplib $deplibs" 81029d0ccd10Smrg elif test prog = "$linkmode"; then 81039d0ccd10Smrg if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then 8104e169010aSmrg # If there is no dlopen support or we're linking statically, 8105e169010aSmrg # we need to preload. 8106c63293b5Smrg func_append newdlprefiles " $deplib" 8107e169010aSmrg compile_deplibs="$deplib $compile_deplibs" 8108e169010aSmrg finalize_deplibs="$deplib $finalize_deplibs" 8109e169010aSmrg else 8110c63293b5Smrg func_append newdlfiles " $deplib" 8111e169010aSmrg fi 8112e169010aSmrg fi 8113e169010aSmrg continue 8114e169010aSmrg ;; 8115e169010aSmrg %DEPLIBS%) 81169d0ccd10Smrg alldeplibs=: 8117e169010aSmrg continue 8118e169010aSmrg ;; 8119e169010aSmrg esac # case $deplib 8120e169010aSmrg 81219d0ccd10Smrg $found || test -f "$lib" \ 81229d0ccd10Smrg || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'" 8123e169010aSmrg 8124e169010aSmrg # Check to see that this really is a libtool archive. 8125e169010aSmrg func_lalib_unsafe_p "$lib" \ 81269d0ccd10Smrg || func_fatal_error "'$lib' is not a valid libtool archive" 8127e169010aSmrg 8128e169010aSmrg func_dirname "$lib" "" "." 81299d0ccd10Smrg ladir=$func_dirname_result 8130e169010aSmrg 8131e169010aSmrg dlname= 8132e169010aSmrg dlopen= 8133e169010aSmrg dlpreopen= 8134e169010aSmrg libdir= 8135e169010aSmrg library_names= 8136e169010aSmrg old_library= 8137e169010aSmrg inherited_linker_flags= 8138e169010aSmrg # If the library was installed with an old release of libtool, 8139e169010aSmrg # it will not redefine variables installed, or shouldnotlink 8140e169010aSmrg installed=yes 8141e169010aSmrg shouldnotlink=no 8142e169010aSmrg avoidtemprpath= 8143e169010aSmrg 8144e169010aSmrg 8145e169010aSmrg # Read the .la file 8146e169010aSmrg func_source "$lib" 8147e169010aSmrg 8148e169010aSmrg # Convert "-framework foo" to "foo.ltframework" 8149e169010aSmrg if test -n "$inherited_linker_flags"; then 8150e8ead290Smrg tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` 8151e169010aSmrg for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do 8152e169010aSmrg case " $new_inherited_linker_flags " in 8153e169010aSmrg *" $tmp_inherited_linker_flag "*) ;; 8154c63293b5Smrg *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; 8155e169010aSmrg esac 8156e169010aSmrg done 8157e169010aSmrg fi 8158e8ead290Smrg dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 81599d0ccd10Smrg if test lib,link = "$linkmode,$pass" || 81609d0ccd10Smrg test prog,scan = "$linkmode,$pass" || 81619d0ccd10Smrg { test prog != "$linkmode" && test lib != "$linkmode"; }; then 8162c63293b5Smrg test -n "$dlopen" && func_append dlfiles " $dlopen" 8163c63293b5Smrg test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" 8164e169010aSmrg fi 8165e169010aSmrg 81669d0ccd10Smrg if test conv = "$pass"; then 8167e169010aSmrg # Only check for convenience libraries 8168e169010aSmrg deplibs="$lib $deplibs" 8169e169010aSmrg if test -z "$libdir"; then 8170e169010aSmrg if test -z "$old_library"; then 81719d0ccd10Smrg func_fatal_error "cannot find name of link library for '$lib'" 8172e169010aSmrg fi 8173e169010aSmrg # It is a libtool convenience library, so add in its objects. 8174c63293b5Smrg func_append convenience " $ladir/$objdir/$old_library" 8175c63293b5Smrg func_append old_convenience " $ladir/$objdir/$old_library" 81769d0ccd10Smrg elif test prog != "$linkmode" && test lib != "$linkmode"; then 81779d0ccd10Smrg func_fatal_error "'$lib' is not a convenience library" 8178e169010aSmrg fi 8179cdce750aSmrg tmp_libs= 8180cdce750aSmrg for deplib in $dependency_libs; do 8181cdce750aSmrg deplibs="$deplib $deplibs" 8182cdce750aSmrg if $opt_preserve_dup_deps; then 8183cdce750aSmrg case "$tmp_libs " in 8184cdce750aSmrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 8185cdce750aSmrg esac 8186cdce750aSmrg fi 8187cdce750aSmrg func_append tmp_libs " $deplib" 8188cdce750aSmrg done 8189e169010aSmrg continue 8190e169010aSmrg fi # $pass = conv 8191e169010aSmrg 8192e169010aSmrg 8193e169010aSmrg # Get the name of the library we link against. 8194e169010aSmrg linklib= 8195c63293b5Smrg if test -n "$old_library" && 81969d0ccd10Smrg { test yes = "$prefer_static_libs" || 81979d0ccd10Smrg test built,no = "$prefer_static_libs,$installed"; }; then 8198c63293b5Smrg linklib=$old_library 8199c63293b5Smrg else 8200c63293b5Smrg for l in $old_library $library_names; do 82019d0ccd10Smrg linklib=$l 8202c63293b5Smrg done 8203c63293b5Smrg fi 8204e169010aSmrg if test -z "$linklib"; then 82059d0ccd10Smrg func_fatal_error "cannot find name of link library for '$lib'" 8206e169010aSmrg fi 8207e169010aSmrg 8208e169010aSmrg # This library was specified with -dlopen. 82099d0ccd10Smrg if test dlopen = "$pass"; then 82109d0ccd10Smrg test -z "$libdir" \ 82119d0ccd10Smrg && func_fatal_error "cannot -dlopen a convenience library: '$lib'" 8212e169010aSmrg if test -z "$dlname" || 82139d0ccd10Smrg test yes != "$dlopen_support" || 82149d0ccd10Smrg test no = "$build_libtool_libs" 82159d0ccd10Smrg then 8216e169010aSmrg # If there is no dlname, no dlopen support or we're linking 8217e169010aSmrg # statically, we need to preload. We also need to preload any 8218e169010aSmrg # dependent libraries so libltdl's deplib preloader doesn't 8219e169010aSmrg # bomb out in the load deplibs phase. 8220c63293b5Smrg func_append dlprefiles " $lib $dependency_libs" 8221e169010aSmrg else 8222c63293b5Smrg func_append newdlfiles " $lib" 8223e169010aSmrg fi 8224e169010aSmrg continue 8225e169010aSmrg fi # $pass = dlopen 8226e169010aSmrg 8227e169010aSmrg # We need an absolute path. 8228e169010aSmrg case $ladir in 82299d0ccd10Smrg [\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;; 8230e169010aSmrg *) 8231e169010aSmrg abs_ladir=`cd "$ladir" && pwd` 8232e169010aSmrg if test -z "$abs_ladir"; then 82339d0ccd10Smrg func_warning "cannot determine absolute directory name of '$ladir'" 8234e169010aSmrg func_warning "passing it literally to the linker, although it might fail" 82359d0ccd10Smrg abs_ladir=$ladir 8236e169010aSmrg fi 8237e169010aSmrg ;; 8238e169010aSmrg esac 8239e169010aSmrg func_basename "$lib" 82409d0ccd10Smrg laname=$func_basename_result 8241e169010aSmrg 8242e169010aSmrg # Find the relevant object directory and library name. 82439d0ccd10Smrg if test yes = "$installed"; then 8244c63293b5Smrg if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then 82459d0ccd10Smrg func_warning "library '$lib' was moved." 82469d0ccd10Smrg dir=$ladir 82479d0ccd10Smrg absdir=$abs_ladir 82489d0ccd10Smrg libdir=$abs_ladir 8249e169010aSmrg else 82509d0ccd10Smrg dir=$lt_sysroot$libdir 82519d0ccd10Smrg absdir=$lt_sysroot$libdir 8252e169010aSmrg fi 82539d0ccd10Smrg test yes = "$hardcode_automatic" && avoidtemprpath=yes 8254e169010aSmrg else 8255e169010aSmrg if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then 82569d0ccd10Smrg dir=$ladir 82579d0ccd10Smrg absdir=$abs_ladir 8258e169010aSmrg # Remove this search path later 8259c63293b5Smrg func_append notinst_path " $abs_ladir" 8260e169010aSmrg else 82619d0ccd10Smrg dir=$ladir/$objdir 82629d0ccd10Smrg absdir=$abs_ladir/$objdir 8263e169010aSmrg # Remove this search path later 8264c63293b5Smrg func_append notinst_path " $abs_ladir" 8265e169010aSmrg fi 8266e169010aSmrg fi # $installed = yes 8267e169010aSmrg func_stripname 'lib' '.la' "$laname" 8268e169010aSmrg name=$func_stripname_result 8269e169010aSmrg 8270e169010aSmrg # This library was specified with -dlpreopen. 82719d0ccd10Smrg if test dlpreopen = "$pass"; then 82729d0ccd10Smrg if test -z "$libdir" && test prog = "$linkmode"; then 82739d0ccd10Smrg func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'" 8274e169010aSmrg fi 82759d0ccd10Smrg case $host in 8276c63293b5Smrg # special handling for platforms with PE-DLLs. 8277c63293b5Smrg *cygwin* | *mingw* | *cegcc* ) 8278c63293b5Smrg # Linker will automatically link against shared library if both 8279c63293b5Smrg # static and shared are present. Therefore, ensure we extract 8280c63293b5Smrg # symbols from the import library if a shared library is present 8281c63293b5Smrg # (otherwise, the dlopen module name will be incorrect). We do 8282c63293b5Smrg # this by putting the import library name into $newdlprefiles. 8283c63293b5Smrg # We recover the dlopen module name by 'saving' the la file 8284c63293b5Smrg # name in a special purpose variable, and (later) extracting the 8285c63293b5Smrg # dlname from the la file. 8286c63293b5Smrg if test -n "$dlname"; then 8287c63293b5Smrg func_tr_sh "$dir/$linklib" 8288c63293b5Smrg eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" 8289c63293b5Smrg func_append newdlprefiles " $dir/$linklib" 8290c63293b5Smrg else 8291c63293b5Smrg func_append newdlprefiles " $dir/$old_library" 8292c63293b5Smrg # Keep a list of preopened convenience libraries to check 8293c63293b5Smrg # that they are being used correctly in the link pass. 8294c63293b5Smrg test -z "$libdir" && \ 8295c63293b5Smrg func_append dlpreconveniencelibs " $dir/$old_library" 8296c63293b5Smrg fi 8297c63293b5Smrg ;; 8298c63293b5Smrg * ) 8299c63293b5Smrg # Prefer using a static library (so that no silly _DYNAMIC symbols 8300c63293b5Smrg # are required to link). 8301c63293b5Smrg if test -n "$old_library"; then 8302c63293b5Smrg func_append newdlprefiles " $dir/$old_library" 8303c63293b5Smrg # Keep a list of preopened convenience libraries to check 8304c63293b5Smrg # that they are being used correctly in the link pass. 8305c63293b5Smrg test -z "$libdir" && \ 8306c63293b5Smrg func_append dlpreconveniencelibs " $dir/$old_library" 8307c63293b5Smrg # Otherwise, use the dlname, so that lt_dlopen finds it. 8308c63293b5Smrg elif test -n "$dlname"; then 8309c63293b5Smrg func_append newdlprefiles " $dir/$dlname" 8310c63293b5Smrg else 8311c63293b5Smrg func_append newdlprefiles " $dir/$linklib" 8312c63293b5Smrg fi 8313c63293b5Smrg ;; 8314c63293b5Smrg esac 8315e169010aSmrg fi # $pass = dlpreopen 8316e169010aSmrg 8317e169010aSmrg if test -z "$libdir"; then 8318e169010aSmrg # Link the convenience library 83199d0ccd10Smrg if test lib = "$linkmode"; then 8320e169010aSmrg deplibs="$dir/$old_library $deplibs" 83219d0ccd10Smrg elif test prog,link = "$linkmode,$pass"; then 8322e169010aSmrg compile_deplibs="$dir/$old_library $compile_deplibs" 8323e169010aSmrg finalize_deplibs="$dir/$old_library $finalize_deplibs" 8324e169010aSmrg else 8325e169010aSmrg deplibs="$lib $deplibs" # used for prog,scan pass 8326e169010aSmrg fi 8327e169010aSmrg continue 8328e169010aSmrg fi 8329e169010aSmrg 8330e169010aSmrg 83319d0ccd10Smrg if test prog = "$linkmode" && test link != "$pass"; then 8332c63293b5Smrg func_append newlib_search_path " $ladir" 8333e169010aSmrg deplibs="$lib $deplibs" 8334e169010aSmrg 83359d0ccd10Smrg linkalldeplibs=false 83369d0ccd10Smrg if test no != "$link_all_deplibs" || test -z "$library_names" || 83379d0ccd10Smrg test no = "$build_libtool_libs"; then 83389d0ccd10Smrg linkalldeplibs=: 8339e169010aSmrg fi 8340e169010aSmrg 8341e169010aSmrg tmp_libs= 8342e169010aSmrg for deplib in $dependency_libs; do 8343e169010aSmrg case $deplib in 8344e169010aSmrg -L*) func_stripname '-L' '' "$deplib" 8345c63293b5Smrg func_resolve_sysroot "$func_stripname_result" 8346c63293b5Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 8347e169010aSmrg ;; 8348e169010aSmrg esac 8349e169010aSmrg # Need to link against all dependency_libs? 83509d0ccd10Smrg if $linkalldeplibs; then 8351e169010aSmrg deplibs="$deplib $deplibs" 8352e169010aSmrg else 8353e169010aSmrg # Need to hardcode shared library paths 8354e169010aSmrg # or/and link against static libraries 8355e169010aSmrg newdependency_libs="$deplib $newdependency_libs" 8356e169010aSmrg fi 83579d0ccd10Smrg if $opt_preserve_dup_deps; then 8358e169010aSmrg case "$tmp_libs " in 8359c63293b5Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 8360e169010aSmrg esac 8361e169010aSmrg fi 8362c63293b5Smrg func_append tmp_libs " $deplib" 8363e169010aSmrg done # for deplib 8364e169010aSmrg continue 8365e169010aSmrg fi # $linkmode = prog... 8366e169010aSmrg 83679d0ccd10Smrg if test prog,link = "$linkmode,$pass"; then 8368e169010aSmrg if test -n "$library_names" && 83699d0ccd10Smrg { { test no = "$prefer_static_libs" || 83709d0ccd10Smrg test built,yes = "$prefer_static_libs,$installed"; } || 8371e169010aSmrg test -z "$old_library"; }; then 8372e169010aSmrg # We need to hardcode the library path 83739d0ccd10Smrg if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then 8374e169010aSmrg # Make sure the rpath contains only unique directories. 83759d0ccd10Smrg case $temp_rpath: in 8376e169010aSmrg *"$absdir:"*) ;; 8377c63293b5Smrg *) func_append temp_rpath "$absdir:" ;; 8378e169010aSmrg esac 8379e169010aSmrg fi 8380e169010aSmrg 8381e169010aSmrg # Hardcode the library path. 8382e169010aSmrg # Skip directories that are in the system default run-time 8383e169010aSmrg # search path. 8384e169010aSmrg case " $sys_lib_dlsearch_path " in 8385e169010aSmrg *" $absdir "*) ;; 8386e169010aSmrg *) 8387e169010aSmrg case "$compile_rpath " in 8388e169010aSmrg *" $absdir "*) ;; 8389c63293b5Smrg *) func_append compile_rpath " $absdir" ;; 8390e169010aSmrg esac 8391e169010aSmrg ;; 8392e169010aSmrg esac 8393e169010aSmrg case " $sys_lib_dlsearch_path " in 8394e169010aSmrg *" $libdir "*) ;; 8395e169010aSmrg *) 8396e169010aSmrg case "$finalize_rpath " in 8397e169010aSmrg *" $libdir "*) ;; 8398c63293b5Smrg *) func_append finalize_rpath " $libdir" ;; 8399e169010aSmrg esac 8400e169010aSmrg ;; 8401e169010aSmrg esac 8402e169010aSmrg fi # $linkmode,$pass = prog,link... 8403e169010aSmrg 84049d0ccd10Smrg if $alldeplibs && 84059d0ccd10Smrg { test pass_all = "$deplibs_check_method" || 84069d0ccd10Smrg { test yes = "$build_libtool_libs" && 8407e169010aSmrg test -n "$library_names"; }; }; then 8408e169010aSmrg # We only need to search for static libraries 8409e169010aSmrg continue 8410e169010aSmrg fi 8411e169010aSmrg fi 8412e169010aSmrg 8413e169010aSmrg link_static=no # Whether the deplib will be linked statically 8414e169010aSmrg use_static_libs=$prefer_static_libs 84159d0ccd10Smrg if test built = "$use_static_libs" && test yes = "$installed"; then 8416e169010aSmrg use_static_libs=no 8417e169010aSmrg fi 8418e169010aSmrg if test -n "$library_names" && 84199d0ccd10Smrg { test no = "$use_static_libs" || test -z "$old_library"; }; then 8420e169010aSmrg case $host in 84219d0ccd10Smrg *cygwin* | *mingw* | *cegcc* | *os2*) 8422e169010aSmrg # No point in relinking DLLs because paths are not encoded 8423c63293b5Smrg func_append notinst_deplibs " $lib" 8424e169010aSmrg need_relink=no 8425e169010aSmrg ;; 8426e169010aSmrg *) 84279d0ccd10Smrg if test no = "$installed"; then 8428c63293b5Smrg func_append notinst_deplibs " $lib" 8429e169010aSmrg need_relink=yes 8430e169010aSmrg fi 8431e169010aSmrg ;; 8432e169010aSmrg esac 8433e169010aSmrg # This is a shared library 8434e169010aSmrg 8435e169010aSmrg # Warn about portability, can't link against -module's on some 8436e169010aSmrg # systems (darwin). Don't bleat about dlopened modules though! 84379d0ccd10Smrg dlopenmodule= 8438e169010aSmrg for dlpremoduletest in $dlprefiles; do 8439e169010aSmrg if test "X$dlpremoduletest" = "X$lib"; then 84409d0ccd10Smrg dlopenmodule=$dlpremoduletest 8441e169010aSmrg break 8442e169010aSmrg fi 8443e169010aSmrg done 84449d0ccd10Smrg if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then 8445e8ead290Smrg echo 84469d0ccd10Smrg if test prog = "$linkmode"; then 8447e169010aSmrg $ECHO "*** Warning: Linking the executable $output against the loadable module" 8448e169010aSmrg else 8449e169010aSmrg $ECHO "*** Warning: Linking the shared library $output against the loadable module" 8450e169010aSmrg fi 8451e169010aSmrg $ECHO "*** $linklib is not portable!" 8452e169010aSmrg fi 84539d0ccd10Smrg if test lib = "$linkmode" && 84549d0ccd10Smrg test yes = "$hardcode_into_libs"; then 8455e169010aSmrg # Hardcode the library path. 8456e169010aSmrg # Skip directories that are in the system default run-time 8457e169010aSmrg # search path. 8458e169010aSmrg case " $sys_lib_dlsearch_path " in 8459e169010aSmrg *" $absdir "*) ;; 8460e169010aSmrg *) 8461e169010aSmrg case "$compile_rpath " in 8462e169010aSmrg *" $absdir "*) ;; 8463c63293b5Smrg *) func_append compile_rpath " $absdir" ;; 8464e169010aSmrg esac 8465e169010aSmrg ;; 8466e169010aSmrg esac 8467e169010aSmrg case " $sys_lib_dlsearch_path " in 8468e169010aSmrg *" $libdir "*) ;; 8469e169010aSmrg *) 8470e169010aSmrg case "$finalize_rpath " in 8471e169010aSmrg *" $libdir "*) ;; 8472c63293b5Smrg *) func_append finalize_rpath " $libdir" ;; 8473e169010aSmrg esac 8474e169010aSmrg ;; 8475e169010aSmrg esac 8476e169010aSmrg fi 8477e169010aSmrg 8478e169010aSmrg if test -n "$old_archive_from_expsyms_cmds"; then 8479e169010aSmrg # figure out the soname 8480e169010aSmrg set dummy $library_names 8481e169010aSmrg shift 84829d0ccd10Smrg realname=$1 8483e169010aSmrg shift 8484e169010aSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 8485e169010aSmrg # use dlname if we got it. it's perfectly good, no? 8486e169010aSmrg if test -n "$dlname"; then 84879d0ccd10Smrg soname=$dlname 8488e169010aSmrg elif test -n "$soname_spec"; then 8489e169010aSmrg # bleh windows 8490e169010aSmrg case $host in 84919d0ccd10Smrg *cygwin* | mingw* | *cegcc* | *os2*) 8492e169010aSmrg func_arith $current - $age 8493e169010aSmrg major=$func_arith_result 84949d0ccd10Smrg versuffix=-$major 8495e169010aSmrg ;; 8496e169010aSmrg esac 8497e169010aSmrg eval soname=\"$soname_spec\" 8498e169010aSmrg else 84999d0ccd10Smrg soname=$realname 8500e169010aSmrg fi 8501e169010aSmrg 8502e169010aSmrg # Make a new name for the extract_expsyms_cmds to use 85039d0ccd10Smrg soroot=$soname 8504e169010aSmrg func_basename "$soroot" 85059d0ccd10Smrg soname=$func_basename_result 8506e169010aSmrg func_stripname 'lib' '.dll' "$soname" 8507e169010aSmrg newlib=libimp-$func_stripname_result.a 8508e169010aSmrg 8509e169010aSmrg # If the library has no export list, then create one now 8510e169010aSmrg if test -f "$output_objdir/$soname-def"; then : 8511e169010aSmrg else 85129d0ccd10Smrg func_verbose "extracting exported symbol list from '$soname'" 8513e169010aSmrg func_execute_cmds "$extract_expsyms_cmds" 'exit $?' 8514e169010aSmrg fi 8515e169010aSmrg 8516e169010aSmrg # Create $newlib 8517e169010aSmrg if test -f "$output_objdir/$newlib"; then :; else 85189d0ccd10Smrg func_verbose "generating import library for '$soname'" 8519e169010aSmrg func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' 8520e169010aSmrg fi 8521e169010aSmrg # make sure the library variables are pointing to the new library 8522e169010aSmrg dir=$output_objdir 8523e169010aSmrg linklib=$newlib 8524e169010aSmrg fi # test -n "$old_archive_from_expsyms_cmds" 8525e169010aSmrg 85269d0ccd10Smrg if test prog = "$linkmode" || test relink != "$opt_mode"; then 8527e169010aSmrg add_shlibpath= 8528e169010aSmrg add_dir= 8529e169010aSmrg add= 8530e169010aSmrg lib_linked=yes 8531e169010aSmrg case $hardcode_action in 8532e169010aSmrg immediate | unsupported) 85339d0ccd10Smrg if test no = "$hardcode_direct"; then 85349d0ccd10Smrg add=$dir/$linklib 8535e169010aSmrg case $host in 85369d0ccd10Smrg *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;; 85379d0ccd10Smrg *-*-sysv4*uw2*) add_dir=-L$dir ;; 8538e169010aSmrg *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ 85399d0ccd10Smrg *-*-unixware7*) add_dir=-L$dir ;; 8540e169010aSmrg *-*-darwin* ) 85419d0ccd10Smrg # if the lib is a (non-dlopened) module then we cannot 8542e169010aSmrg # link against it, someone is ignoring the earlier warnings 8543e169010aSmrg if /usr/bin/file -L $add 2> /dev/null | 85449d0ccd10Smrg $GREP ": [^:]* bundle" >/dev/null; then 8545e169010aSmrg if test "X$dlopenmodule" != "X$lib"; then 8546e169010aSmrg $ECHO "*** Warning: lib $linklib is a module, not a shared library" 85479d0ccd10Smrg if test -z "$old_library"; then 8548e8ead290Smrg echo 8549e8ead290Smrg echo "*** And there doesn't seem to be a static archive available" 8550e8ead290Smrg echo "*** The link will probably fail, sorry" 8551e169010aSmrg else 85529d0ccd10Smrg add=$dir/$old_library 8553e169010aSmrg fi 8554e169010aSmrg elif test -n "$old_library"; then 85559d0ccd10Smrg add=$dir/$old_library 8556e169010aSmrg fi 8557e169010aSmrg fi 8558e169010aSmrg esac 85599d0ccd10Smrg elif test no = "$hardcode_minus_L"; then 8560e169010aSmrg case $host in 85619d0ccd10Smrg *-*-sunos*) add_shlibpath=$dir ;; 8562e169010aSmrg esac 85639d0ccd10Smrg add_dir=-L$dir 85649d0ccd10Smrg add=-l$name 85659d0ccd10Smrg elif test no = "$hardcode_shlibpath_var"; then 85669d0ccd10Smrg add_shlibpath=$dir 85679d0ccd10Smrg add=-l$name 8568e169010aSmrg else 8569e169010aSmrg lib_linked=no 8570e169010aSmrg fi 8571e169010aSmrg ;; 8572e169010aSmrg relink) 85739d0ccd10Smrg if test yes = "$hardcode_direct" && 85749d0ccd10Smrg test no = "$hardcode_direct_absolute"; then 85759d0ccd10Smrg add=$dir/$linklib 85769d0ccd10Smrg elif test yes = "$hardcode_minus_L"; then 85779d0ccd10Smrg add_dir=-L$absdir 8578e169010aSmrg # Try looking first in the location we're being installed to. 8579e169010aSmrg if test -n "$inst_prefix_dir"; then 8580e169010aSmrg case $libdir in 8581e169010aSmrg [\\/]*) 8582c63293b5Smrg func_append add_dir " -L$inst_prefix_dir$libdir" 8583e169010aSmrg ;; 8584e169010aSmrg esac 8585e169010aSmrg fi 85869d0ccd10Smrg add=-l$name 85879d0ccd10Smrg elif test yes = "$hardcode_shlibpath_var"; then 85889d0ccd10Smrg add_shlibpath=$dir 85899d0ccd10Smrg add=-l$name 8590e169010aSmrg else 8591e169010aSmrg lib_linked=no 8592e169010aSmrg fi 8593e169010aSmrg ;; 8594e169010aSmrg *) lib_linked=no ;; 8595e169010aSmrg esac 8596e169010aSmrg 85979d0ccd10Smrg if test yes != "$lib_linked"; then 8598e169010aSmrg func_fatal_configuration "unsupported hardcode properties" 8599e169010aSmrg fi 8600e169010aSmrg 8601e169010aSmrg if test -n "$add_shlibpath"; then 8602e169010aSmrg case :$compile_shlibpath: in 8603e169010aSmrg *":$add_shlibpath:"*) ;; 8604c63293b5Smrg *) func_append compile_shlibpath "$add_shlibpath:" ;; 8605e169010aSmrg esac 8606e169010aSmrg fi 86079d0ccd10Smrg if test prog = "$linkmode"; then 8608e169010aSmrg test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" 8609e169010aSmrg test -n "$add" && compile_deplibs="$add $compile_deplibs" 8610e169010aSmrg else 8611e169010aSmrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 8612e169010aSmrg test -n "$add" && deplibs="$add $deplibs" 86139d0ccd10Smrg if test yes != "$hardcode_direct" && 86149d0ccd10Smrg test yes != "$hardcode_minus_L" && 86159d0ccd10Smrg test yes = "$hardcode_shlibpath_var"; then 8616e169010aSmrg case :$finalize_shlibpath: in 8617e169010aSmrg *":$libdir:"*) ;; 8618c63293b5Smrg *) func_append finalize_shlibpath "$libdir:" ;; 8619e169010aSmrg esac 8620e169010aSmrg fi 8621e169010aSmrg fi 8622e169010aSmrg fi 8623e169010aSmrg 86249d0ccd10Smrg if test prog = "$linkmode" || test relink = "$opt_mode"; then 8625e169010aSmrg add_shlibpath= 8626e169010aSmrg add_dir= 8627e169010aSmrg add= 8628e169010aSmrg # Finalize command for both is simple: just hardcode it. 86299d0ccd10Smrg if test yes = "$hardcode_direct" && 86309d0ccd10Smrg test no = "$hardcode_direct_absolute"; then 86319d0ccd10Smrg add=$libdir/$linklib 86329d0ccd10Smrg elif test yes = "$hardcode_minus_L"; then 86339d0ccd10Smrg add_dir=-L$libdir 86349d0ccd10Smrg add=-l$name 86359d0ccd10Smrg elif test yes = "$hardcode_shlibpath_var"; then 8636e169010aSmrg case :$finalize_shlibpath: in 8637e169010aSmrg *":$libdir:"*) ;; 8638c63293b5Smrg *) func_append finalize_shlibpath "$libdir:" ;; 8639e169010aSmrg esac 86409d0ccd10Smrg add=-l$name 86419d0ccd10Smrg elif test yes = "$hardcode_automatic"; then 8642e169010aSmrg if test -n "$inst_prefix_dir" && 86439d0ccd10Smrg test -f "$inst_prefix_dir$libdir/$linklib"; then 86449d0ccd10Smrg add=$inst_prefix_dir$libdir/$linklib 8645e169010aSmrg else 86469d0ccd10Smrg add=$libdir/$linklib 8647e169010aSmrg fi 8648e169010aSmrg else 8649e169010aSmrg # We cannot seem to hardcode it, guess we'll fake it. 86509d0ccd10Smrg add_dir=-L$libdir 8651e169010aSmrg # Try looking first in the location we're being installed to. 8652e169010aSmrg if test -n "$inst_prefix_dir"; then 8653e169010aSmrg case $libdir in 8654e169010aSmrg [\\/]*) 8655c63293b5Smrg func_append add_dir " -L$inst_prefix_dir$libdir" 8656e169010aSmrg ;; 8657e169010aSmrg esac 8658e169010aSmrg fi 86599d0ccd10Smrg add=-l$name 8660e169010aSmrg fi 8661e169010aSmrg 86629d0ccd10Smrg if test prog = "$linkmode"; then 8663e169010aSmrg test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" 8664e169010aSmrg test -n "$add" && finalize_deplibs="$add $finalize_deplibs" 8665e169010aSmrg else 8666e169010aSmrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 8667e169010aSmrg test -n "$add" && deplibs="$add $deplibs" 8668e169010aSmrg fi 8669e169010aSmrg fi 86709d0ccd10Smrg elif test prog = "$linkmode"; then 8671e169010aSmrg # Here we assume that one of hardcode_direct or hardcode_minus_L 8672e169010aSmrg # is not unsupported. This is valid on all known static and 8673e169010aSmrg # shared platforms. 86749d0ccd10Smrg if test unsupported != "$hardcode_direct"; then 86759d0ccd10Smrg test -n "$old_library" && linklib=$old_library 8676e169010aSmrg compile_deplibs="$dir/$linklib $compile_deplibs" 8677e169010aSmrg finalize_deplibs="$dir/$linklib $finalize_deplibs" 8678e169010aSmrg else 8679e169010aSmrg compile_deplibs="-l$name -L$dir $compile_deplibs" 8680e169010aSmrg finalize_deplibs="-l$name -L$dir $finalize_deplibs" 8681e169010aSmrg fi 86829d0ccd10Smrg elif test yes = "$build_libtool_libs"; then 8683e169010aSmrg # Not a shared library 86849d0ccd10Smrg if test pass_all != "$deplibs_check_method"; then 8685e169010aSmrg # We're trying link a shared library against a static one 8686e169010aSmrg # but the system doesn't support it. 8687e169010aSmrg 8688e169010aSmrg # Just print a warning and add the library to dependency_libs so 8689e169010aSmrg # that the program can be linked against the static library. 8690e8ead290Smrg echo 86919d0ccd10Smrg $ECHO "*** Warning: This system cannot link to static lib archive $lib." 8692e8ead290Smrg echo "*** I have the capability to make that library automatically link in when" 8693e8ead290Smrg echo "*** you link to this library. But I can only do this if you have a" 8694e8ead290Smrg echo "*** shared version of the library, which you do not appear to have." 86959d0ccd10Smrg if test yes = "$module"; then 8696e8ead290Smrg echo "*** But as you try to build a module library, libtool will still create " 8697e8ead290Smrg echo "*** a static module, that should work as long as the dlopening application" 8698e8ead290Smrg echo "*** is linked with the -dlopen flag to resolve symbols at runtime." 8699e169010aSmrg if test -z "$global_symbol_pipe"; then 8700e8ead290Smrg echo 8701e8ead290Smrg echo "*** However, this would only work if libtool was able to extract symbol" 87029d0ccd10Smrg echo "*** lists from a program, using 'nm' or equivalent, but libtool could" 8703e8ead290Smrg echo "*** not find such a program. So, this module is probably useless." 87049d0ccd10Smrg echo "*** 'nm' from GNU binutils and a full rebuild may help." 8705e169010aSmrg fi 87069d0ccd10Smrg if test no = "$build_old_libs"; then 8707e169010aSmrg build_libtool_libs=module 8708e169010aSmrg build_old_libs=yes 8709e169010aSmrg else 8710e169010aSmrg build_libtool_libs=no 8711e169010aSmrg fi 8712e169010aSmrg fi 8713e169010aSmrg else 8714e169010aSmrg deplibs="$dir/$old_library $deplibs" 8715e169010aSmrg link_static=yes 8716e169010aSmrg fi 8717e169010aSmrg fi # link shared/static library? 8718e169010aSmrg 87199d0ccd10Smrg if test lib = "$linkmode"; then 8720e169010aSmrg if test -n "$dependency_libs" && 87219d0ccd10Smrg { test yes != "$hardcode_into_libs" || 87229d0ccd10Smrg test yes = "$build_old_libs" || 87239d0ccd10Smrg test yes = "$link_static"; }; then 8724e169010aSmrg # Extract -R from dependency_libs 8725e169010aSmrg temp_deplibs= 8726e169010aSmrg for libdir in $dependency_libs; do 8727e169010aSmrg case $libdir in 8728e169010aSmrg -R*) func_stripname '-R' '' "$libdir" 8729e169010aSmrg temp_xrpath=$func_stripname_result 8730e169010aSmrg case " $xrpath " in 8731e169010aSmrg *" $temp_xrpath "*) ;; 8732c63293b5Smrg *) func_append xrpath " $temp_xrpath";; 8733e169010aSmrg esac;; 8734c63293b5Smrg *) func_append temp_deplibs " $libdir";; 8735e169010aSmrg esac 8736e169010aSmrg done 87379d0ccd10Smrg dependency_libs=$temp_deplibs 8738e169010aSmrg fi 8739e169010aSmrg 8740c63293b5Smrg func_append newlib_search_path " $absdir" 8741e169010aSmrg # Link against this library 87429d0ccd10Smrg test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs" 8743e169010aSmrg # ... and its dependency_libs 8744e169010aSmrg tmp_libs= 8745e169010aSmrg for deplib in $dependency_libs; do 8746e169010aSmrg newdependency_libs="$deplib $newdependency_libs" 8747c63293b5Smrg case $deplib in 8748c63293b5Smrg -L*) func_stripname '-L' '' "$deplib" 8749c63293b5Smrg func_resolve_sysroot "$func_stripname_result";; 8750c63293b5Smrg *) func_resolve_sysroot "$deplib" ;; 8751c63293b5Smrg esac 87529d0ccd10Smrg if $opt_preserve_dup_deps; then 8753e169010aSmrg case "$tmp_libs " in 8754c63293b5Smrg *" $func_resolve_sysroot_result "*) 8755c63293b5Smrg func_append specialdeplibs " $func_resolve_sysroot_result" ;; 8756e169010aSmrg esac 8757e169010aSmrg fi 8758c63293b5Smrg func_append tmp_libs " $func_resolve_sysroot_result" 8759e169010aSmrg done 8760e169010aSmrg 87619d0ccd10Smrg if test no != "$link_all_deplibs"; then 8762e169010aSmrg # Add the search paths of all dependency libraries 8763e169010aSmrg for deplib in $dependency_libs; do 8764e8ead290Smrg path= 8765e169010aSmrg case $deplib in 87669d0ccd10Smrg -L*) path=$deplib ;; 8767e169010aSmrg *.la) 8768c63293b5Smrg func_resolve_sysroot "$deplib" 8769c63293b5Smrg deplib=$func_resolve_sysroot_result 8770e169010aSmrg func_dirname "$deplib" "" "." 8771c63293b5Smrg dir=$func_dirname_result 8772e169010aSmrg # We need an absolute path. 8773e169010aSmrg case $dir in 87749d0ccd10Smrg [\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;; 8775e169010aSmrg *) 8776e169010aSmrg absdir=`cd "$dir" && pwd` 8777e169010aSmrg if test -z "$absdir"; then 87789d0ccd10Smrg func_warning "cannot determine absolute directory name of '$dir'" 87799d0ccd10Smrg absdir=$dir 8780e169010aSmrg fi 8781e169010aSmrg ;; 8782e169010aSmrg esac 8783e169010aSmrg if $GREP "^installed=no" $deplib > /dev/null; then 8784e169010aSmrg case $host in 8785e169010aSmrg *-*-darwin*) 8786e169010aSmrg depdepl= 87879d0ccd10Smrg eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` 87889d0ccd10Smrg if test -n "$deplibrary_names"; then 87899d0ccd10Smrg for tmp in $deplibrary_names; do 8790e169010aSmrg depdepl=$tmp 8791e169010aSmrg done 87929d0ccd10Smrg if test -f "$absdir/$objdir/$depdepl"; then 87939d0ccd10Smrg depdepl=$absdir/$objdir/$depdepl 87949d0ccd10Smrg darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 8795e169010aSmrg if test -z "$darwin_install_name"; then 87969d0ccd10Smrg darwin_install_name=`$OTOOL64 -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 8797e169010aSmrg fi 87989d0ccd10Smrg func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl" 87999d0ccd10Smrg func_append linker_flags " -dylib_file $darwin_install_name:$depdepl" 8800e169010aSmrg path= 8801e169010aSmrg fi 8802e169010aSmrg fi 8803e169010aSmrg ;; 8804e169010aSmrg *) 88059d0ccd10Smrg path=-L$absdir/$objdir 8806e169010aSmrg ;; 8807e169010aSmrg esac 8808e169010aSmrg else 88099d0ccd10Smrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` 8810e169010aSmrg test -z "$libdir" && \ 88119d0ccd10Smrg func_fatal_error "'$deplib' is not a valid libtool archive" 8812e169010aSmrg test "$absdir" != "$libdir" && \ 88139d0ccd10Smrg func_warning "'$deplib' seems to be moved" 8814e169010aSmrg 88159d0ccd10Smrg path=-L$absdir 8816e169010aSmrg fi 8817e169010aSmrg ;; 8818e169010aSmrg esac 8819e169010aSmrg case " $deplibs " in 8820e169010aSmrg *" $path "*) ;; 8821e169010aSmrg *) deplibs="$path $deplibs" ;; 8822e169010aSmrg esac 8823e169010aSmrg done 8824e169010aSmrg fi # link_all_deplibs != no 8825e169010aSmrg fi # linkmode = lib 8826e169010aSmrg done # for deplib in $libs 88279d0ccd10Smrg if test link = "$pass"; then 88289d0ccd10Smrg if test prog = "$linkmode"; then 8829e169010aSmrg compile_deplibs="$new_inherited_linker_flags $compile_deplibs" 8830e169010aSmrg finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" 8831e169010aSmrg else 8832e8ead290Smrg compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 8833e169010aSmrg fi 8834e169010aSmrg fi 88359d0ccd10Smrg dependency_libs=$newdependency_libs 88369d0ccd10Smrg if test dlpreopen = "$pass"; then 8837e169010aSmrg # Link the dlpreopened libraries before other libraries 8838e169010aSmrg for deplib in $save_deplibs; do 8839e169010aSmrg deplibs="$deplib $deplibs" 8840e169010aSmrg done 8841e169010aSmrg fi 88429d0ccd10Smrg if test dlopen != "$pass"; then 88439d0ccd10Smrg test conv = "$pass" || { 8844e169010aSmrg # Make sure lib_search_path contains only unique directories. 8845e169010aSmrg lib_search_path= 8846e169010aSmrg for dir in $newlib_search_path; do 8847e169010aSmrg case "$lib_search_path " in 8848e169010aSmrg *" $dir "*) ;; 8849c63293b5Smrg *) func_append lib_search_path " $dir" ;; 8850e169010aSmrg esac 8851e169010aSmrg done 8852e169010aSmrg newlib_search_path= 88539d0ccd10Smrg } 8854e169010aSmrg 88559d0ccd10Smrg if test prog,link = "$linkmode,$pass"; then 8856e169010aSmrg vars="compile_deplibs finalize_deplibs" 88579d0ccd10Smrg else 88589d0ccd10Smrg vars=deplibs 8859e169010aSmrg fi 8860e169010aSmrg for var in $vars dependency_libs; do 8861e169010aSmrg # Add libraries to $var in reverse order 8862e169010aSmrg eval tmp_libs=\"\$$var\" 8863e169010aSmrg new_libs= 8864e169010aSmrg for deplib in $tmp_libs; do 8865e169010aSmrg # FIXME: Pedantically, this is the right thing to do, so 8866e169010aSmrg # that some nasty dependency loop isn't accidentally 8867e169010aSmrg # broken: 8868e169010aSmrg #new_libs="$deplib $new_libs" 8869e169010aSmrg # Pragmatically, this seems to cause very few problems in 8870e169010aSmrg # practice: 8871e169010aSmrg case $deplib in 8872e169010aSmrg -L*) new_libs="$deplib $new_libs" ;; 8873e169010aSmrg -R*) ;; 8874e169010aSmrg *) 8875e169010aSmrg # And here is the reason: when a library appears more 8876e169010aSmrg # than once as an explicit dependence of a library, or 8877e169010aSmrg # is implicitly linked in more than once by the 8878e169010aSmrg # compiler, it is considered special, and multiple 8879e169010aSmrg # occurrences thereof are not removed. Compare this 8880e169010aSmrg # with having the same library being listed as a 8881e169010aSmrg # dependency of multiple other libraries: in this case, 8882e169010aSmrg # we know (pedantically, we assume) the library does not 8883e169010aSmrg # need to be listed more than once, so we keep only the 8884e169010aSmrg # last copy. This is not always right, but it is rare 8885e169010aSmrg # enough that we require users that really mean to play 8886e169010aSmrg # such unportable linking tricks to link the library 8887e169010aSmrg # using -Wl,-lname, so that libtool does not consider it 8888e169010aSmrg # for duplicate removal. 8889e169010aSmrg case " $specialdeplibs " in 8890e169010aSmrg *" $deplib "*) new_libs="$deplib $new_libs" ;; 8891e169010aSmrg *) 8892e169010aSmrg case " $new_libs " in 8893e169010aSmrg *" $deplib "*) ;; 8894e169010aSmrg *) new_libs="$deplib $new_libs" ;; 8895e169010aSmrg esac 8896e169010aSmrg ;; 8897e169010aSmrg esac 8898e169010aSmrg ;; 8899e169010aSmrg esac 8900e169010aSmrg done 8901e169010aSmrg tmp_libs= 8902e169010aSmrg for deplib in $new_libs; do 8903e169010aSmrg case $deplib in 8904e169010aSmrg -L*) 8905e169010aSmrg case " $tmp_libs " in 8906e169010aSmrg *" $deplib "*) ;; 8907c63293b5Smrg *) func_append tmp_libs " $deplib" ;; 8908e169010aSmrg esac 8909e169010aSmrg ;; 8910c63293b5Smrg *) func_append tmp_libs " $deplib" ;; 8911e169010aSmrg esac 8912e169010aSmrg done 8913e169010aSmrg eval $var=\"$tmp_libs\" 8914e169010aSmrg done # for var 8915e169010aSmrg fi 89169d0ccd10Smrg 89179d0ccd10Smrg # Add Sun CC postdeps if required: 89189d0ccd10Smrg test CXX = "$tagname" && { 89199d0ccd10Smrg case $host_os in 89209d0ccd10Smrg linux*) 89210ea508b1Smrg case `$CC -V 2>&1 | $SED 5q` in 89229d0ccd10Smrg *Sun\ C*) # Sun C++ 5.9 89239d0ccd10Smrg func_suncc_cstd_abi 89249d0ccd10Smrg 89259d0ccd10Smrg if test no != "$suncc_use_cstd_abi"; then 89269d0ccd10Smrg func_append postdeps ' -library=Cstd -library=Crun' 89279d0ccd10Smrg fi 89289d0ccd10Smrg ;; 89299d0ccd10Smrg esac 89309d0ccd10Smrg ;; 89319d0ccd10Smrg 89329d0ccd10Smrg solaris*) 89339d0ccd10Smrg func_cc_basename "$CC" 89349d0ccd10Smrg case $func_cc_basename_result in 89359d0ccd10Smrg CC* | sunCC*) 89369d0ccd10Smrg func_suncc_cstd_abi 89379d0ccd10Smrg 89389d0ccd10Smrg if test no != "$suncc_use_cstd_abi"; then 89399d0ccd10Smrg func_append postdeps ' -library=Cstd -library=Crun' 89409d0ccd10Smrg fi 89419d0ccd10Smrg ;; 89429d0ccd10Smrg esac 89439d0ccd10Smrg ;; 89449d0ccd10Smrg esac 89459d0ccd10Smrg } 89469d0ccd10Smrg 8947e169010aSmrg # Last step: remove runtime libs from dependency_libs 8948e169010aSmrg # (they stay in deplibs) 8949e169010aSmrg tmp_libs= 89509d0ccd10Smrg for i in $dependency_libs; do 8951e169010aSmrg case " $predeps $postdeps $compiler_lib_search_path " in 8952e169010aSmrg *" $i "*) 89539d0ccd10Smrg i= 8954e169010aSmrg ;; 8955e169010aSmrg esac 89569d0ccd10Smrg if test -n "$i"; then 8957c63293b5Smrg func_append tmp_libs " $i" 8958e169010aSmrg fi 8959e169010aSmrg done 8960e169010aSmrg dependency_libs=$tmp_libs 8961e169010aSmrg done # for pass 89629d0ccd10Smrg if test prog = "$linkmode"; then 89639d0ccd10Smrg dlfiles=$newdlfiles 8964e169010aSmrg fi 89659d0ccd10Smrg if test prog = "$linkmode" || test lib = "$linkmode"; then 89669d0ccd10Smrg dlprefiles=$newdlprefiles 8967e169010aSmrg fi 8968e169010aSmrg 8969e169010aSmrg case $linkmode in 8970e169010aSmrg oldlib) 89719d0ccd10Smrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 89729d0ccd10Smrg func_warning "'-dlopen' is ignored for archives" 8973e169010aSmrg fi 8974e169010aSmrg 8975e169010aSmrg case " $deplibs" in 8976e169010aSmrg *\ -l* | *\ -L*) 89779d0ccd10Smrg func_warning "'-l' and '-L' are ignored for archives" ;; 8978e169010aSmrg esac 8979e169010aSmrg 8980e169010aSmrg test -n "$rpath" && \ 89819d0ccd10Smrg func_warning "'-rpath' is ignored for archives" 8982e169010aSmrg 8983e169010aSmrg test -n "$xrpath" && \ 89849d0ccd10Smrg func_warning "'-R' is ignored for archives" 8985e169010aSmrg 8986e169010aSmrg test -n "$vinfo" && \ 89879d0ccd10Smrg func_warning "'-version-info/-version-number' is ignored for archives" 8988e169010aSmrg 8989e169010aSmrg test -n "$release" && \ 89909d0ccd10Smrg func_warning "'-release' is ignored for archives" 8991e169010aSmrg 8992e169010aSmrg test -n "$export_symbols$export_symbols_regex" && \ 89939d0ccd10Smrg func_warning "'-export-symbols' is ignored for archives" 8994e169010aSmrg 8995e169010aSmrg # Now set the variables for building old libraries. 8996e169010aSmrg build_libtool_libs=no 89979d0ccd10Smrg oldlibs=$output 8998c63293b5Smrg func_append objs "$old_deplibs" 8999e169010aSmrg ;; 9000e169010aSmrg 9001e169010aSmrg lib) 90029d0ccd10Smrg # Make sure we only generate libraries of the form 'libNAME.la'. 9003e169010aSmrg case $outputname in 9004e169010aSmrg lib*) 9005e169010aSmrg func_stripname 'lib' '.la' "$outputname" 9006e169010aSmrg name=$func_stripname_result 9007e169010aSmrg eval shared_ext=\"$shrext_cmds\" 9008e169010aSmrg eval libname=\"$libname_spec\" 9009e169010aSmrg ;; 9010e169010aSmrg *) 90119d0ccd10Smrg test no = "$module" \ 90129d0ccd10Smrg && func_fatal_help "libtool library '$output' must begin with 'lib'" 9013e169010aSmrg 90149d0ccd10Smrg if test no != "$need_lib_prefix"; then 9015e169010aSmrg # Add the "lib" prefix for modules if required 9016e169010aSmrg func_stripname '' '.la' "$outputname" 9017e169010aSmrg name=$func_stripname_result 9018e169010aSmrg eval shared_ext=\"$shrext_cmds\" 9019e169010aSmrg eval libname=\"$libname_spec\" 9020e169010aSmrg else 9021e169010aSmrg func_stripname '' '.la' "$outputname" 9022e169010aSmrg libname=$func_stripname_result 9023e169010aSmrg fi 9024e169010aSmrg ;; 9025e169010aSmrg esac 9026e169010aSmrg 9027e169010aSmrg if test -n "$objs"; then 90289d0ccd10Smrg if test pass_all != "$deplibs_check_method"; then 90299d0ccd10Smrg func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs" 9030e169010aSmrg else 9031e8ead290Smrg echo 9032e169010aSmrg $ECHO "*** Warning: Linking the shared library $output against the non-libtool" 9033e169010aSmrg $ECHO "*** objects $objs is not portable!" 9034c63293b5Smrg func_append libobjs " $objs" 9035e169010aSmrg fi 9036e169010aSmrg fi 9037e169010aSmrg 90389d0ccd10Smrg test no = "$dlself" \ 90399d0ccd10Smrg || func_warning "'-dlopen self' is ignored for libtool libraries" 9040e169010aSmrg 9041e169010aSmrg set dummy $rpath 9042e169010aSmrg shift 90439d0ccd10Smrg test 1 -lt "$#" \ 90449d0ccd10Smrg && func_warning "ignoring multiple '-rpath's for a libtool library" 9045e169010aSmrg 90469d0ccd10Smrg install_libdir=$1 9047e169010aSmrg 9048e169010aSmrg oldlibs= 9049e169010aSmrg if test -z "$rpath"; then 90509d0ccd10Smrg if test yes = "$build_libtool_libs"; then 9051e169010aSmrg # Building a libtool convenience library. 90529d0ccd10Smrg # Some compilers have problems with a '.al' extension so 9053e169010aSmrg # convenience libraries should have the same extension an 9054e169010aSmrg # archive normally would. 9055e169010aSmrg oldlibs="$output_objdir/$libname.$libext $oldlibs" 9056e169010aSmrg build_libtool_libs=convenience 9057e169010aSmrg build_old_libs=yes 9058e169010aSmrg fi 9059e169010aSmrg 9060e169010aSmrg test -n "$vinfo" && \ 90619d0ccd10Smrg func_warning "'-version-info/-version-number' is ignored for convenience libraries" 9062e169010aSmrg 9063e169010aSmrg test -n "$release" && \ 90649d0ccd10Smrg func_warning "'-release' is ignored for convenience libraries" 9065e169010aSmrg else 9066e169010aSmrg 9067e169010aSmrg # Parse the version information argument. 90689d0ccd10Smrg save_ifs=$IFS; IFS=: 9069e169010aSmrg set dummy $vinfo 0 0 0 9070e169010aSmrg shift 90719d0ccd10Smrg IFS=$save_ifs 9072e169010aSmrg 9073e169010aSmrg test -n "$7" && \ 90749d0ccd10Smrg func_fatal_help "too many parameters to '-version-info'" 9075e169010aSmrg 9076e169010aSmrg # convert absolute version numbers to libtool ages 9077e169010aSmrg # this retains compatibility with .la files and attempts 9078e169010aSmrg # to make the code below a bit more comprehensible 9079e169010aSmrg 9080e169010aSmrg case $vinfo_number in 9081e169010aSmrg yes) 90829d0ccd10Smrg number_major=$1 90839d0ccd10Smrg number_minor=$2 90849d0ccd10Smrg number_revision=$3 9085e169010aSmrg # 9086e169010aSmrg # There are really only two kinds -- those that 9087e169010aSmrg # use the current revision as the major version 9088e169010aSmrg # and those that subtract age and use age as 9089e169010aSmrg # a minor version. But, then there is irix 90909d0ccd10Smrg # that has an extra 1 added just for fun 9091e169010aSmrg # 9092e169010aSmrg case $version_type in 9093e6d5e4e0Smrg # correct linux to gnu/linux during the next big refactor 90940ea508b1Smrg darwin|freebsd-elf|linux|midnightbsd-elf|osf|windows|none) 9095e169010aSmrg func_arith $number_major + $number_minor 9096e169010aSmrg current=$func_arith_result 90979d0ccd10Smrg age=$number_minor 90989d0ccd10Smrg revision=$number_revision 9099e169010aSmrg ;; 91009d0ccd10Smrg freebsd-aout|qnx|sunos) 91019d0ccd10Smrg current=$number_major 91029d0ccd10Smrg revision=$number_minor 91039d0ccd10Smrg age=0 9104e169010aSmrg ;; 9105e169010aSmrg irix|nonstopux) 9106e169010aSmrg func_arith $number_major + $number_minor 9107e169010aSmrg current=$func_arith_result 91089d0ccd10Smrg age=$number_minor 91099d0ccd10Smrg revision=$number_minor 9110e169010aSmrg lt_irix_increment=no 9111e169010aSmrg ;; 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