1515ec619Smrg#! /usr/bin/env sh 26fc0178dSmrg## DO NOT EDIT - This file generated from ./build-aux/ltmain.in 3515ec619Smrg## by inline-source v2019-02-19.15 47a3b38f7Smrg 5515ec619Smrg# libtool (GNU libtool) 2.4.7 66fc0178dSmrg# Provide generalized library-building support services. 77a3b38f7Smrg# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 87a3b38f7Smrg 9515ec619Smrg# Copyright (C) 1996-2019, 2021-2022 Free Software Foundation, Inc. 107a3b38f7Smrg# This is free software; see the source for copying conditions. There is NO 117a3b38f7Smrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 127a3b38f7Smrg 137a3b38f7Smrg# GNU Libtool is free software; you can redistribute it and/or modify 14ff559fabSmrg# it under the terms of the GNU General Public License as published by 15ff559fabSmrg# the Free Software Foundation; either version 2 of the License, or 16ff559fabSmrg# (at your option) any later version. 17ff559fabSmrg# 187a3b38f7Smrg# As a special exception to the GNU General Public License, 197a3b38f7Smrg# if you distribute this file as part of a program or library that 207a3b38f7Smrg# is built using GNU Libtool, you may include this file under the 217a3b38f7Smrg# same distribution terms that you use for the rest of that program. 227a3b38f7Smrg# 237a3b38f7Smrg# GNU Libtool is distributed in the hope that it will be useful, but 24ff559fabSmrg# WITHOUT ANY WARRANTY; without even the implied warranty of 25ff559fabSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 26ff559fabSmrg# General Public License for more details. 27ff559fabSmrg# 28ff559fabSmrg# You should have received a copy of the GNU General Public License 296fc0178dSmrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 307a3b38f7Smrg 317a3b38f7Smrg 3244dda7b2SmrgPROGRAM=libtool 337a3b38f7SmrgPACKAGE=libtool 34515ec619SmrgVERSION=2.4.7 35515ec619Smrgpackage_revision=2.4.7 367a3b38f7Smrg 376fc0178dSmrg 386fc0178dSmrg## ------ ## 396fc0178dSmrg## Usage. ## 406fc0178dSmrg## ------ ## 416fc0178dSmrg 426fc0178dSmrg# Run './libtool --help' for help with using this script from the 436fc0178dSmrg# command line. 446fc0178dSmrg 456fc0178dSmrg 466fc0178dSmrg## ------------------------------- ## 476fc0178dSmrg## User overridable command paths. ## 486fc0178dSmrg## ------------------------------- ## 496fc0178dSmrg 506fc0178dSmrg# After configure completes, it has a better idea of some of the 516fc0178dSmrg# shell tools we need than the defaults used by the functions shared 526fc0178dSmrg# with bootstrap, so set those here where they can still be over- 536fc0178dSmrg# ridden by the user, but otherwise take precedence. 546fc0178dSmrg 556fc0178dSmrg: ${AUTOCONF="autoconf"} 566fc0178dSmrg: ${AUTOMAKE="automake"} 576fc0178dSmrg 586fc0178dSmrg 596fc0178dSmrg## -------------------------- ## 606fc0178dSmrg## Source external libraries. ## 616fc0178dSmrg## -------------------------- ## 626fc0178dSmrg 636fc0178dSmrg# Much of our low-level functionality needs to be sourced from external 646fc0178dSmrg# libraries, which are installed to $pkgauxdir. 656fc0178dSmrg 666fc0178dSmrg# Set a version string for this script. 67515ec619Smrgscriptversion=2019-02-19.15; # UTC 686fc0178dSmrg 696fc0178dSmrg# General shell script boiler plate, and helper functions. 706fc0178dSmrg# Written by Gary V. Vaughan, 2004 716fc0178dSmrg 72515ec619Smrg# This is free software. There is NO warranty; not even for 73515ec619Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 74515ec619Smrg# 75515ec619Smrg# Copyright (C) 2004-2019, 2021 Bootstrap Authors 76515ec619Smrg# 77515ec619Smrg# This file is dual licensed under the terms of the MIT license 78515ec619Smrg# <https://opensource.org/license/MIT>, and GPL version 2 or later 79515ec619Smrg# <http://www.gnu.org/licenses/gpl-2.0.html>. You must apply one of 80515ec619Smrg# these licenses when using or redistributing this software or any of 81515ec619Smrg# the files within it. See the URLs above, or the file `LICENSE` 82515ec619Smrg# included in the Bootstrap distribution for the full license texts. 836fc0178dSmrg 84515ec619Smrg# Please report bugs or propose patches to: 85515ec619Smrg# <https://github.com/gnulib-modules/bootstrap/issues> 866fc0178dSmrg 876fc0178dSmrg 886fc0178dSmrg## ------ ## 896fc0178dSmrg## Usage. ## 906fc0178dSmrg## ------ ## 916fc0178dSmrg 926fc0178dSmrg# Evaluate this file near the top of your script to gain access to 936fc0178dSmrg# the functions and variables defined here: 946fc0178dSmrg# 956fc0178dSmrg# . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh 966fc0178dSmrg# 976fc0178dSmrg# If you need to override any of the default environment variable 986fc0178dSmrg# settings, do that before evaluating this file. 996fc0178dSmrg 1006fc0178dSmrg 1016fc0178dSmrg## -------------------- ## 1026fc0178dSmrg## Shell normalisation. ## 1036fc0178dSmrg## -------------------- ## 1046fc0178dSmrg 1056fc0178dSmrg# Some shells need a little help to be as Bourne compatible as possible. 1066fc0178dSmrg# Before doing anything else, make sure all that help has been provided! 1076fc0178dSmrg 1086fc0178dSmrgDUALCASE=1; export DUALCASE # for MKS sh 1096fc0178dSmrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : 1107a3b38f7Smrg emulate sh 1117a3b38f7Smrg NULLCMD=: 1126fc0178dSmrg # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which 1137a3b38f7Smrg # is contrary to our usage. Disable this feature. 1147a3b38f7Smrg alias -g '${1+"$@"}'='"$@"' 1157a3b38f7Smrg setopt NO_GLOB_SUBST 1167a3b38f7Smrgelse 1176fc0178dSmrg case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac 1187a3b38f7Smrgfi 11944dda7b2Smrg 1206fc0178dSmrg# NLS nuisances: We save the old values in case they are required later. 1216fc0178dSmrg_G_user_locale= 1226fc0178dSmrg_G_safe_locale= 1236fc0178dSmrgfor _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 1247a3b38f7Smrgdo 1256fc0178dSmrg eval "if test set = \"\${$_G_var+set}\"; then 1266fc0178dSmrg save_$_G_var=\$$_G_var 1276fc0178dSmrg $_G_var=C 1286fc0178dSmrg export $_G_var 1296fc0178dSmrg _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\" 1306fc0178dSmrg _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\" 1317a3b38f7Smrg fi" 1327a3b38f7Smrgdone 133515ec619Smrg# These NLS vars are set unconditionally (bootstrap issue #24). Unset those 134515ec619Smrg# in case the environment reset is needed later and the $save_* variant is not 135515ec619Smrg# defined (see the code above). 136515ec619SmrgLC_ALL=C 137515ec619SmrgLANGUAGE=C 138515ec619Smrgexport LANGUAGE LC_ALL 1397a3b38f7Smrg 1406fc0178dSmrg# Make sure IFS has a sensible default 1416fc0178dSmrgsp=' ' 1426fc0178dSmrgnl=' 1436fc0178dSmrg' 1446fc0178dSmrgIFS="$sp $nl" 1456fc0178dSmrg 1466fc0178dSmrg# There are apparently some retarded systems that use ';' as a PATH separator! 1476fc0178dSmrgif test "${PATH_SEPARATOR+set}" != set; then 1486fc0178dSmrg PATH_SEPARATOR=: 1496fc0178dSmrg (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { 1506fc0178dSmrg (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || 1516fc0178dSmrg PATH_SEPARATOR=';' 1526fc0178dSmrg } 1536fc0178dSmrgfi 1547a3b38f7Smrg 1557a3b38f7Smrg 156515ec619Smrg# func_unset VAR 157515ec619Smrg# -------------- 158515ec619Smrg# Portably unset VAR. 159515ec619Smrg# In some shells, an 'unset VAR' statement leaves a non-zero return 160515ec619Smrg# status if VAR is already unset, which might be problematic if the 161515ec619Smrg# statement is used at the end of a function (thus poisoning its return 162515ec619Smrg# value) or when 'set -e' is active (causing even a spurious abort of 163515ec619Smrg# the script in this case). 164515ec619Smrgfunc_unset () 165515ec619Smrg{ 166515ec619Smrg { eval $1=; (eval unset $1) >/dev/null 2>&1 && eval unset $1 || : ; } 167515ec619Smrg} 168515ec619Smrg 169515ec619Smrg 170515ec619Smrg# Make sure CDPATH doesn't cause `cd` commands to output the target dir. 171515ec619Smrgfunc_unset CDPATH 172515ec619Smrg 173515ec619Smrg# Make sure ${,E,F}GREP behave sanely. 174515ec619Smrgfunc_unset GREP_OPTIONS 175515ec619Smrg 1767a3b38f7Smrg 1776fc0178dSmrg## ------------------------- ## 1786fc0178dSmrg## Locate command utilities. ## 1796fc0178dSmrg## ------------------------- ## 1806fc0178dSmrg 1816fc0178dSmrg 1826fc0178dSmrg# func_executable_p FILE 1836fc0178dSmrg# ---------------------- 1846fc0178dSmrg# Check that FILE is an executable regular file. 1856fc0178dSmrgfunc_executable_p () 1866fc0178dSmrg{ 1876fc0178dSmrg test -f "$1" && test -x "$1" 1886fc0178dSmrg} 1896fc0178dSmrg 1906fc0178dSmrg 1916fc0178dSmrg# func_path_progs PROGS_LIST CHECK_FUNC [PATH] 1926fc0178dSmrg# -------------------------------------------- 1936fc0178dSmrg# Search for either a program that responds to --version with output 1946fc0178dSmrg# containing "GNU", or else returned by CHECK_FUNC otherwise, by 1956fc0178dSmrg# trying all the directories in PATH with each of the elements of 1966fc0178dSmrg# PROGS_LIST. 1976fc0178dSmrg# 1986fc0178dSmrg# CHECK_FUNC should accept the path to a candidate program, and 1996fc0178dSmrg# set $func_check_prog_result if it truncates its output less than 2006fc0178dSmrg# $_G_path_prog_max characters. 2016fc0178dSmrgfunc_path_progs () 2026fc0178dSmrg{ 2036fc0178dSmrg _G_progs_list=$1 2046fc0178dSmrg _G_check_func=$2 2056fc0178dSmrg _G_PATH=${3-"$PATH"} 2066fc0178dSmrg 2076fc0178dSmrg _G_path_prog_max=0 2086fc0178dSmrg _G_path_prog_found=false 2096fc0178dSmrg _G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:} 2106fc0178dSmrg for _G_dir in $_G_PATH; do 2116fc0178dSmrg IFS=$_G_save_IFS 2126fc0178dSmrg test -z "$_G_dir" && _G_dir=. 2136fc0178dSmrg for _G_prog_name in $_G_progs_list; do 2146fc0178dSmrg for _exeext in '' .EXE; do 2156fc0178dSmrg _G_path_prog=$_G_dir/$_G_prog_name$_exeext 2166fc0178dSmrg func_executable_p "$_G_path_prog" || continue 2176fc0178dSmrg case `"$_G_path_prog" --version 2>&1` in 2186fc0178dSmrg *GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;; 2196fc0178dSmrg *) $_G_check_func $_G_path_prog 2206fc0178dSmrg func_path_progs_result=$func_check_prog_result 2216fc0178dSmrg ;; 2226fc0178dSmrg esac 2236fc0178dSmrg $_G_path_prog_found && break 3 2246fc0178dSmrg done 2256fc0178dSmrg done 2266fc0178dSmrg done 2276fc0178dSmrg IFS=$_G_save_IFS 2286fc0178dSmrg test -z "$func_path_progs_result" && { 2296fc0178dSmrg echo "no acceptable sed could be found in \$PATH" >&2 2306fc0178dSmrg exit 1 2316fc0178dSmrg } 2326fc0178dSmrg} 2336fc0178dSmrg 2346fc0178dSmrg 2356fc0178dSmrg# We want to be able to use the functions in this file before configure 2366fc0178dSmrg# has figured out where the best binaries are kept, which means we have 2376fc0178dSmrg# to search for them ourselves - except when the results are already set 2386fc0178dSmrg# where we skip the searches. 2396fc0178dSmrg 2406fc0178dSmrg# Unless the user overrides by setting SED, search the path for either GNU 2416fc0178dSmrg# sed, or the sed that truncates its output the least. 2426fc0178dSmrgtest -z "$SED" && { 2436fc0178dSmrg _G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ 2446fc0178dSmrg for _G_i in 1 2 3 4 5 6 7; do 2456fc0178dSmrg _G_sed_script=$_G_sed_script$nl$_G_sed_script 2466fc0178dSmrg done 2476fc0178dSmrg echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed 2486fc0178dSmrg _G_sed_script= 2496fc0178dSmrg 2506fc0178dSmrg func_check_prog_sed () 2516fc0178dSmrg { 2526fc0178dSmrg _G_path_prog=$1 2536fc0178dSmrg 2546fc0178dSmrg _G_count=0 2556fc0178dSmrg printf 0123456789 >conftest.in 2566fc0178dSmrg while : 2576fc0178dSmrg do 2586fc0178dSmrg cat conftest.in conftest.in >conftest.tmp 2596fc0178dSmrg mv conftest.tmp conftest.in 2606fc0178dSmrg cp conftest.in conftest.nl 2616fc0178dSmrg echo '' >> conftest.nl 2626fc0178dSmrg "$_G_path_prog" -f conftest.sed <conftest.nl >conftest.out 2>/dev/null || break 2636fc0178dSmrg diff conftest.out conftest.nl >/dev/null 2>&1 || break 2646fc0178dSmrg _G_count=`expr $_G_count + 1` 2656fc0178dSmrg if test "$_G_count" -gt "$_G_path_prog_max"; then 2666fc0178dSmrg # Best one so far, save it but keep looking for a better one 2676fc0178dSmrg func_check_prog_result=$_G_path_prog 2686fc0178dSmrg _G_path_prog_max=$_G_count 2696fc0178dSmrg fi 2706fc0178dSmrg # 10*(2^10) chars as input seems more than enough 2716fc0178dSmrg test 10 -lt "$_G_count" && break 2726fc0178dSmrg done 2736fc0178dSmrg rm -f conftest.in conftest.tmp conftest.nl conftest.out 2746fc0178dSmrg } 2756fc0178dSmrg 276515ec619Smrg func_path_progs "sed gsed" func_check_prog_sed "$PATH:/usr/xpg4/bin" 2776fc0178dSmrg rm -f conftest.sed 2786fc0178dSmrg SED=$func_path_progs_result 2796fc0178dSmrg} 2806fc0178dSmrg 2816fc0178dSmrg 2826fc0178dSmrg# Unless the user overrides by setting GREP, search the path for either GNU 2836fc0178dSmrg# grep, or the grep that truncates its output the least. 2846fc0178dSmrgtest -z "$GREP" && { 2856fc0178dSmrg func_check_prog_grep () 2866fc0178dSmrg { 2876fc0178dSmrg _G_path_prog=$1 2886fc0178dSmrg 2896fc0178dSmrg _G_count=0 2906fc0178dSmrg _G_path_prog_max=0 2916fc0178dSmrg printf 0123456789 >conftest.in 2926fc0178dSmrg while : 2936fc0178dSmrg do 2946fc0178dSmrg cat conftest.in conftest.in >conftest.tmp 2956fc0178dSmrg mv conftest.tmp conftest.in 2966fc0178dSmrg cp conftest.in conftest.nl 2976fc0178dSmrg echo 'GREP' >> conftest.nl 2986fc0178dSmrg "$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' <conftest.nl >conftest.out 2>/dev/null || break 2996fc0178dSmrg diff conftest.out conftest.nl >/dev/null 2>&1 || break 3006fc0178dSmrg _G_count=`expr $_G_count + 1` 3016fc0178dSmrg if test "$_G_count" -gt "$_G_path_prog_max"; then 3026fc0178dSmrg # Best one so far, save it but keep looking for a better one 3036fc0178dSmrg func_check_prog_result=$_G_path_prog 3046fc0178dSmrg _G_path_prog_max=$_G_count 3056fc0178dSmrg fi 3066fc0178dSmrg # 10*(2^10) chars as input seems more than enough 3076fc0178dSmrg test 10 -lt "$_G_count" && break 3086fc0178dSmrg done 3096fc0178dSmrg rm -f conftest.in conftest.tmp conftest.nl conftest.out 3106fc0178dSmrg } 3116fc0178dSmrg 312515ec619Smrg func_path_progs "grep ggrep" func_check_prog_grep "$PATH:/usr/xpg4/bin" 3136fc0178dSmrg GREP=$func_path_progs_result 3146fc0178dSmrg} 3156fc0178dSmrg 3166fc0178dSmrg 3176fc0178dSmrg## ------------------------------- ## 3186fc0178dSmrg## User overridable command paths. ## 3196fc0178dSmrg## ------------------------------- ## 3206fc0178dSmrg 3216fc0178dSmrg# All uppercase variable names are used for environment variables. These 3226fc0178dSmrg# variables can be overridden by the user before calling a script that 3236fc0178dSmrg# uses them if a suitable command of that name is not already available 3246fc0178dSmrg# in the command search PATH. 3257a3b38f7Smrg 3267a3b38f7Smrg: ${CP="cp -f"} 3276fc0178dSmrg: ${ECHO="printf %s\n"} 3286fc0178dSmrg: ${EGREP="$GREP -E"} 3296fc0178dSmrg: ${FGREP="$GREP -F"} 3306fc0178dSmrg: ${LN_S="ln -s"} 3317a3b38f7Smrg: ${MAKE="make"} 3327a3b38f7Smrg: ${MKDIR="mkdir"} 3337a3b38f7Smrg: ${MV="mv -f"} 3347a3b38f7Smrg: ${RM="rm -f"} 3357a3b38f7Smrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"} 3367a3b38f7Smrg 3377a3b38f7Smrg 3386fc0178dSmrg## -------------------- ## 3396fc0178dSmrg## Useful sed snippets. ## 3406fc0178dSmrg## -------------------- ## 341862f5301Smrg 3426fc0178dSmrgsed_dirname='s|/[^/]*$||' 3436fc0178dSmrgsed_basename='s|^.*/||' 344862f5301Smrg 3456fc0178dSmrg# Sed substitution that helps us do robust quoting. It backslashifies 3466fc0178dSmrg# metacharacters that are still active within double-quoted strings. 3476fc0178dSmrgsed_quote_subst='s|\([`"$\\]\)|\\\1|g' 348862f5301Smrg 3496fc0178dSmrg# Same as above, but do not quote variable references. 3506fc0178dSmrgsed_double_quote_subst='s/\(["`\\]\)/\\\1/g' 351862f5301Smrg 3526fc0178dSmrg# Sed substitution that turns a string into a regex matching for the 3536fc0178dSmrg# string literally. 3546fc0178dSmrgsed_make_literal_regex='s|[].[^$\\*\/]|\\&|g' 355862f5301Smrg 3566fc0178dSmrg# Sed substitution that converts a w32 file name or path 3576fc0178dSmrg# that contains forward slashes, into one that contains 3586fc0178dSmrg# (escaped) backslashes. A very naive implementation. 3596fc0178dSmrgsed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' 3606fc0178dSmrg 3616fc0178dSmrg# Re-'\' parameter expansions in output of sed_double_quote_subst that 3626fc0178dSmrg# were '\'-ed in input to the same. If an odd number of '\' preceded a 3636fc0178dSmrg# '$' in input to sed_double_quote_subst, that '$' was protected from 3646fc0178dSmrg# expansion. Since each input '\' is now two '\'s, look for any number 3656fc0178dSmrg# of runs of four '\'s followed by two '\'s and then a '$'. '\' that '$'. 3666fc0178dSmrg_G_bs='\\' 3676fc0178dSmrg_G_bs2='\\\\' 3686fc0178dSmrg_G_bs4='\\\\\\\\' 3696fc0178dSmrg_G_dollar='\$' 3706fc0178dSmrgsed_double_backslash="\ 3716fc0178dSmrg s/$_G_bs4/&\\ 3726fc0178dSmrg/g 3736fc0178dSmrg s/^$_G_bs2$_G_dollar/$_G_bs&/ 3746fc0178dSmrg s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g 3756fc0178dSmrg s/\n//g" 376862f5301Smrg 377515ec619Smrg# require_check_ifs_backslash 378515ec619Smrg# --------------------------- 379515ec619Smrg# Check if we can use backslash as IFS='\' separator, and set 380515ec619Smrg# $check_ifs_backshlash_broken to ':' or 'false'. 381515ec619Smrgrequire_check_ifs_backslash=func_require_check_ifs_backslash 382515ec619Smrgfunc_require_check_ifs_backslash () 383515ec619Smrg{ 384515ec619Smrg _G_save_IFS=$IFS 385515ec619Smrg IFS='\' 386515ec619Smrg _G_check_ifs_backshlash='a\\b' 387515ec619Smrg for _G_i in $_G_check_ifs_backshlash 388515ec619Smrg do 389515ec619Smrg case $_G_i in 390515ec619Smrg a) 391515ec619Smrg check_ifs_backshlash_broken=false 392515ec619Smrg ;; 393515ec619Smrg '') 394515ec619Smrg break 395515ec619Smrg ;; 396515ec619Smrg *) 397515ec619Smrg check_ifs_backshlash_broken=: 398515ec619Smrg break 399515ec619Smrg ;; 400515ec619Smrg esac 401515ec619Smrg done 402515ec619Smrg IFS=$_G_save_IFS 403515ec619Smrg require_check_ifs_backslash=: 404515ec619Smrg} 405515ec619Smrg 4067a3b38f7Smrg 4076fc0178dSmrg## ----------------- ## 4086fc0178dSmrg## Global variables. ## 4096fc0178dSmrg## ----------------- ## 410ff559fabSmrg 4116fc0178dSmrg# Except for the global variables explicitly listed below, the following 4126fc0178dSmrg# functions in the '^func_' namespace, and the '^require_' namespace 4136fc0178dSmrg# variables initialised in the 'Resource management' section, sourcing 4146fc0178dSmrg# this file will not pollute your global namespace with anything 4156fc0178dSmrg# else. There's no portable way to scope variables in Bourne shell 4166fc0178dSmrg# though, so actually running these functions will sometimes place 4176fc0178dSmrg# results into a variable named after the function, and often use 4186fc0178dSmrg# temporary variables in the '^_G_' namespace. If you are careful to 4196fc0178dSmrg# avoid using those namespaces casually in your sourcing script, things 4206fc0178dSmrg# should continue to work as you expect. And, of course, you can freely 4216fc0178dSmrg# overwrite any of the functions or variables defined here before 4226fc0178dSmrg# calling anything to customize them. 42344dda7b2Smrg 4246fc0178dSmrgEXIT_SUCCESS=0 4256fc0178dSmrgEXIT_FAILURE=1 4266fc0178dSmrgEXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. 4276fc0178dSmrgEXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. 42844dda7b2Smrg 4296fc0178dSmrg# Allow overriding, eg assuming that you follow the convention of 4306fc0178dSmrg# putting '$debug_cmd' at the start of all your functions, you can get 4316fc0178dSmrg# bash to show function call trace with: 4326fc0178dSmrg# 4336fc0178dSmrg# debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name 4346fc0178dSmrgdebug_cmd=${debug_cmd-":"} 4356fc0178dSmrgexit_cmd=: 43644dda7b2Smrg 4376fc0178dSmrg# By convention, finish your script with: 4386fc0178dSmrg# 4396fc0178dSmrg# exit $exit_status 4406fc0178dSmrg# 4416fc0178dSmrg# so that you can set exit_status to non-zero if you want to indicate 4426fc0178dSmrg# something went wrong during execution without actually bailing out at 4436fc0178dSmrg# the point of failure. 4446fc0178dSmrgexit_status=$EXIT_SUCCESS 44544dda7b2Smrg 4466fc0178dSmrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh 4476fc0178dSmrg# is ksh but when the shell is invoked as "sh" and the current value of 4486fc0178dSmrg# the _XPG environment variable is not equal to 1 (one), the special 4496fc0178dSmrg# positional parameter $0, within a function call, is the name of the 4506fc0178dSmrg# function. 4516fc0178dSmrgprogpath=$0 452ff559fabSmrg 4536fc0178dSmrg# The name of this program. 4546fc0178dSmrgprogname=`$ECHO "$progpath" |$SED "$sed_basename"` 455ff559fabSmrg 4566fc0178dSmrg# Make sure we have an absolute progpath for reexecution: 4577a3b38f7Smrgcase $progpath in 4587a3b38f7Smrg [\\/]*|[A-Za-z]:\\*) ;; 4597a3b38f7Smrg *[\\/]*) 4606fc0178dSmrg progdir=`$ECHO "$progpath" |$SED "$sed_dirname"` 4617a3b38f7Smrg progdir=`cd "$progdir" && pwd` 4626fc0178dSmrg progpath=$progdir/$progname 4637a3b38f7Smrg ;; 4647a3b38f7Smrg *) 4656fc0178dSmrg _G_IFS=$IFS 466fc544a13Smrg IFS=${PATH_SEPARATOR-:} 4677a3b38f7Smrg for progdir in $PATH; do 4686fc0178dSmrg IFS=$_G_IFS 4697a3b38f7Smrg test -x "$progdir/$progname" && break 4707a3b38f7Smrg done 4716fc0178dSmrg IFS=$_G_IFS 4727a3b38f7Smrg test -n "$progdir" || progdir=`pwd` 4736fc0178dSmrg progpath=$progdir/$progname 4747a3b38f7Smrg ;; 4757a3b38f7Smrgesac 476ff559fabSmrg 4777a3b38f7Smrg 4786fc0178dSmrg## ----------------- ## 4796fc0178dSmrg## Standard options. ## 4806fc0178dSmrg## ----------------- ## 481862f5301Smrg 4826fc0178dSmrg# The following options affect the operation of the functions defined 4836fc0178dSmrg# below, and should be set appropriately depending on run-time para- 4846fc0178dSmrg# meters passed on the command line. 4857a3b38f7Smrg 4867a3b38f7Smrgopt_dry_run=false 4877a3b38f7Smrgopt_quiet=false 4887a3b38f7Smrgopt_verbose=false 4897a3b38f7Smrg 4906fc0178dSmrg# Categories 'all' and 'none' are always available. Append any others 4916fc0178dSmrg# you will pass as the first argument to func_warning from your own 4926fc0178dSmrg# code. 4936fc0178dSmrgwarning_categories= 494ff559fabSmrg 4956fc0178dSmrg# By default, display warnings according to 'opt_warning_types'. Set 4966fc0178dSmrg# 'warning_func' to ':' to elide all warnings, or func_fatal_error to 4976fc0178dSmrg# treat the next displayed warning as a fatal error. 4986fc0178dSmrgwarning_func=func_warn_and_continue 499ff559fabSmrg 5006fc0178dSmrg# Set to 'all' to display all warnings, 'none' to suppress all 5016fc0178dSmrg# warnings, or a space delimited list of some subset of 5026fc0178dSmrg# 'warning_categories' to display only the listed warnings. 5036fc0178dSmrgopt_warning_types=all 504ff559fabSmrg 50544dda7b2Smrg 5066fc0178dSmrg## -------------------- ## 5076fc0178dSmrg## Resource management. ## 5086fc0178dSmrg## -------------------- ## 509ff559fabSmrg 5106fc0178dSmrg# This section contains definitions for functions that each ensure a 5116fc0178dSmrg# particular resource (a file, or a non-empty configuration variable for 5126fc0178dSmrg# example) is available, and if appropriate to extract default values 5136fc0178dSmrg# from pertinent package files. Call them using their associated 5146fc0178dSmrg# 'require_*' variable to ensure that they are executed, at most, once. 5156fc0178dSmrg# 5166fc0178dSmrg# It's entirely deliberate that calling these functions can set 5176fc0178dSmrg# variables that don't obey the namespace limitations obeyed by the rest 5186fc0178dSmrg# of this file, in order that that they be as useful as possible to 5196fc0178dSmrg# callers. 520ff559fabSmrg 521ff559fabSmrg 5226fc0178dSmrg# require_term_colors 5236fc0178dSmrg# ------------------- 5246fc0178dSmrg# Allow display of bold text on terminals that support it. 5256fc0178dSmrgrequire_term_colors=func_require_term_colors 5266fc0178dSmrgfunc_require_term_colors () 5277a3b38f7Smrg{ 5286fc0178dSmrg $debug_cmd 5296fc0178dSmrg 5306fc0178dSmrg test -t 1 && { 5316fc0178dSmrg # COLORTERM and USE_ANSI_COLORS environment variables take 5326fc0178dSmrg # precedence, because most terminfo databases neglect to describe 5336fc0178dSmrg # whether color sequences are supported. 5346fc0178dSmrg test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"} 5356fc0178dSmrg 5366fc0178dSmrg if test 1 = "$USE_ANSI_COLORS"; then 5376fc0178dSmrg # Standard ANSI escape sequences 5386fc0178dSmrg tc_reset='[0m' 5396fc0178dSmrg tc_bold='[1m'; tc_standout='[7m' 5406fc0178dSmrg tc_red='[31m'; tc_green='[32m' 5416fc0178dSmrg tc_blue='[34m'; tc_cyan='[36m' 5426fc0178dSmrg else 5436fc0178dSmrg # Otherwise trust the terminfo database after all. 5446fc0178dSmrg test -n "`tput sgr0 2>/dev/null`" && { 5456fc0178dSmrg tc_reset=`tput sgr0` 5466fc0178dSmrg test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold` 5476fc0178dSmrg tc_standout=$tc_bold 5486fc0178dSmrg test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso` 5496fc0178dSmrg test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1` 5506fc0178dSmrg test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2` 5516fc0178dSmrg test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4` 5526fc0178dSmrg test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5` 5536fc0178dSmrg } 5546fc0178dSmrg fi 5556fc0178dSmrg } 556ff559fabSmrg 5576fc0178dSmrg require_term_colors=: 5587a3b38f7Smrg} 559ff559fabSmrg 560ff559fabSmrg 5616fc0178dSmrg## ----------------- ## 5626fc0178dSmrg## Function library. ## 5636fc0178dSmrg## ----------------- ## 5646fc0178dSmrg 5656fc0178dSmrg# This section contains a variety of useful functions to call in your 5666fc0178dSmrg# scripts. Take note of the portable wrappers for features provided by 5676fc0178dSmrg# some modern shells, which will fall back to slower equivalents on 5686fc0178dSmrg# less featureful shells. 5696fc0178dSmrg 5706fc0178dSmrg 5716fc0178dSmrg# func_append VAR VALUE 5726fc0178dSmrg# --------------------- 5736fc0178dSmrg# Append VALUE onto the existing contents of VAR. 5746fc0178dSmrg 5756fc0178dSmrg # We should try to minimise forks, especially on Windows where they are 5766fc0178dSmrg # unreasonably slow, so skip the feature probes when bash or zsh are 5776fc0178dSmrg # being used: 5786fc0178dSmrg if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then 5796fc0178dSmrg : ${_G_HAVE_ARITH_OP="yes"} 5806fc0178dSmrg : ${_G_HAVE_XSI_OPS="yes"} 5816fc0178dSmrg # The += operator was introduced in bash 3.1 5826fc0178dSmrg case $BASH_VERSION in 5836fc0178dSmrg [12].* | 3.0 | 3.0*) ;; 5846fc0178dSmrg *) 5856fc0178dSmrg : ${_G_HAVE_PLUSEQ_OP="yes"} 5866fc0178dSmrg ;; 5876fc0178dSmrg esac 5886fc0178dSmrg fi 5896fc0178dSmrg 5906fc0178dSmrg # _G_HAVE_PLUSEQ_OP 5916fc0178dSmrg # Can be empty, in which case the shell is probed, "yes" if += is 5926fc0178dSmrg # useable or anything else if it does not work. 5936fc0178dSmrg test -z "$_G_HAVE_PLUSEQ_OP" \ 5946fc0178dSmrg && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \ 5956fc0178dSmrg && _G_HAVE_PLUSEQ_OP=yes 5966fc0178dSmrg 5976fc0178dSmrgif test yes = "$_G_HAVE_PLUSEQ_OP" 5986fc0178dSmrgthen 5996fc0178dSmrg # This is an XSI compatible shell, allowing a faster implementation... 6006fc0178dSmrg eval 'func_append () 6016fc0178dSmrg { 6026fc0178dSmrg $debug_cmd 6036fc0178dSmrg 6046fc0178dSmrg eval "$1+=\$2" 6056fc0178dSmrg }' 6066fc0178dSmrgelse 6076fc0178dSmrg # ...otherwise fall back to using expr, which is often a shell builtin. 6086fc0178dSmrg func_append () 6096fc0178dSmrg { 6106fc0178dSmrg $debug_cmd 6116fc0178dSmrg 6126fc0178dSmrg eval "$1=\$$1\$2" 6136fc0178dSmrg } 6146fc0178dSmrgfi 6156fc0178dSmrg 6166fc0178dSmrg 6176fc0178dSmrg# func_append_quoted VAR VALUE 6186fc0178dSmrg# ---------------------------- 6196fc0178dSmrg# Quote VALUE and append to the end of shell variable VAR, separated 6206fc0178dSmrg# by a space. 6216fc0178dSmrgif test yes = "$_G_HAVE_PLUSEQ_OP"; then 6226fc0178dSmrg eval 'func_append_quoted () 6236fc0178dSmrg { 6246fc0178dSmrg $debug_cmd 6256fc0178dSmrg 626515ec619Smrg func_quote_arg pretty "$2" 627515ec619Smrg eval "$1+=\\ \$func_quote_arg_result" 6286fc0178dSmrg }' 6296fc0178dSmrgelse 6306fc0178dSmrg func_append_quoted () 6316fc0178dSmrg { 6326fc0178dSmrg $debug_cmd 6336fc0178dSmrg 634515ec619Smrg func_quote_arg pretty "$2" 635515ec619Smrg eval "$1=\$$1\\ \$func_quote_arg_result" 6366fc0178dSmrg } 6376fc0178dSmrgfi 6386fc0178dSmrg 6396fc0178dSmrg 6406fc0178dSmrg# func_append_uniq VAR VALUE 6416fc0178dSmrg# -------------------------- 6426fc0178dSmrg# Append unique VALUE onto the existing contents of VAR, assuming 6436fc0178dSmrg# entries are delimited by the first character of VALUE. For example: 6446fc0178dSmrg# 6456fc0178dSmrg# func_append_uniq options " --another-option option-argument" 6466fc0178dSmrg# 6476fc0178dSmrg# will only append to $options if " --another-option option-argument " 6486fc0178dSmrg# is not already present somewhere in $options already (note spaces at 6496fc0178dSmrg# each end implied by leading space in second argument). 6506fc0178dSmrgfunc_append_uniq () 6516fc0178dSmrg{ 6526fc0178dSmrg $debug_cmd 6536fc0178dSmrg 6546fc0178dSmrg eval _G_current_value='`$ECHO $'$1'`' 6556fc0178dSmrg _G_delim=`expr "$2" : '\(.\)'` 6566fc0178dSmrg 6576fc0178dSmrg case $_G_delim$_G_current_value$_G_delim in 6586fc0178dSmrg *"$2$_G_delim"*) ;; 6596fc0178dSmrg *) func_append "$@" ;; 6606fc0178dSmrg esac 6616fc0178dSmrg} 6626fc0178dSmrg 6636fc0178dSmrg 6646fc0178dSmrg# func_arith TERM... 6656fc0178dSmrg# ------------------ 6666fc0178dSmrg# Set func_arith_result to the result of evaluating TERMs. 6676fc0178dSmrg test -z "$_G_HAVE_ARITH_OP" \ 6686fc0178dSmrg && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \ 6696fc0178dSmrg && _G_HAVE_ARITH_OP=yes 6706fc0178dSmrg 6716fc0178dSmrgif test yes = "$_G_HAVE_ARITH_OP"; then 6726fc0178dSmrg eval 'func_arith () 6736fc0178dSmrg { 6746fc0178dSmrg $debug_cmd 6756fc0178dSmrg 6766fc0178dSmrg func_arith_result=$(( $* )) 6776fc0178dSmrg }' 6786fc0178dSmrgelse 6796fc0178dSmrg func_arith () 6806fc0178dSmrg { 6816fc0178dSmrg $debug_cmd 6826fc0178dSmrg 6836fc0178dSmrg func_arith_result=`expr "$@"` 6846fc0178dSmrg } 6856fc0178dSmrgfi 6866fc0178dSmrg 6876fc0178dSmrg 6886fc0178dSmrg# func_basename FILE 6896fc0178dSmrg# ------------------ 6906fc0178dSmrg# Set func_basename_result to FILE with everything up to and including 6916fc0178dSmrg# the last / stripped. 6926fc0178dSmrgif test yes = "$_G_HAVE_XSI_OPS"; then 6936fc0178dSmrg # If this shell supports suffix pattern removal, then use it to avoid 6946fc0178dSmrg # forking. Hide the definitions single quotes in case the shell chokes 6956fc0178dSmrg # on unsupported syntax... 6966fc0178dSmrg _b='func_basename_result=${1##*/}' 6976fc0178dSmrg _d='case $1 in 6986fc0178dSmrg */*) func_dirname_result=${1%/*}$2 ;; 6996fc0178dSmrg * ) func_dirname_result=$3 ;; 7006fc0178dSmrg esac' 7016fc0178dSmrg 7026fc0178dSmrgelse 7036fc0178dSmrg # ...otherwise fall back to using sed. 7046fc0178dSmrg _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`' 7056fc0178dSmrg _d='func_dirname_result=`$ECHO "$1" |$SED "$sed_dirname"` 7066fc0178dSmrg if test "X$func_dirname_result" = "X$1"; then 7076fc0178dSmrg func_dirname_result=$3 7086fc0178dSmrg else 7096fc0178dSmrg func_append func_dirname_result "$2" 7106fc0178dSmrg fi' 7116fc0178dSmrgfi 7126fc0178dSmrg 7136fc0178dSmrgeval 'func_basename () 7146fc0178dSmrg{ 7156fc0178dSmrg $debug_cmd 7166fc0178dSmrg 7176fc0178dSmrg '"$_b"' 7186fc0178dSmrg}' 7196fc0178dSmrg 7206fc0178dSmrg 7216fc0178dSmrg# func_dirname FILE APPEND NONDIR_REPLACEMENT 7226fc0178dSmrg# ------------------------------------------- 7236fc0178dSmrg# Compute the dirname of FILE. If nonempty, add APPEND to the result, 7246fc0178dSmrg# otherwise set result to NONDIR_REPLACEMENT. 7256fc0178dSmrgeval 'func_dirname () 7266fc0178dSmrg{ 7276fc0178dSmrg $debug_cmd 7286fc0178dSmrg 7296fc0178dSmrg '"$_d"' 7306fc0178dSmrg}' 7316fc0178dSmrg 7326fc0178dSmrg 7336fc0178dSmrg# func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT 7346fc0178dSmrg# -------------------------------------------------------- 7356fc0178dSmrg# Perform func_basename and func_dirname in a single function 7366fc0178dSmrg# call: 7376fc0178dSmrg# dirname: Compute the dirname of FILE. If nonempty, 7386fc0178dSmrg# add APPEND to the result, otherwise set result 7396fc0178dSmrg# to NONDIR_REPLACEMENT. 7406fc0178dSmrg# value returned in "$func_dirname_result" 7416fc0178dSmrg# basename: Compute filename of FILE. 7426fc0178dSmrg# value retuned in "$func_basename_result" 7436fc0178dSmrg# For efficiency, we do not delegate to the functions above but instead 7446fc0178dSmrg# duplicate the functionality here. 7456fc0178dSmrgeval 'func_dirname_and_basename () 7466fc0178dSmrg{ 7476fc0178dSmrg $debug_cmd 7486fc0178dSmrg 7496fc0178dSmrg '"$_b"' 7506fc0178dSmrg '"$_d"' 7516fc0178dSmrg}' 7526fc0178dSmrg 7536fc0178dSmrg 7546fc0178dSmrg# func_echo ARG... 7556fc0178dSmrg# ---------------- 7566fc0178dSmrg# Echo program name prefixed message. 7576fc0178dSmrgfunc_echo () 7586fc0178dSmrg{ 7596fc0178dSmrg $debug_cmd 7606fc0178dSmrg 7616fc0178dSmrg _G_message=$* 7626fc0178dSmrg 7636fc0178dSmrg func_echo_IFS=$IFS 7646fc0178dSmrg IFS=$nl 7656fc0178dSmrg for _G_line in $_G_message; do 7666fc0178dSmrg IFS=$func_echo_IFS 7676fc0178dSmrg $ECHO "$progname: $_G_line" 7686fc0178dSmrg done 7696fc0178dSmrg IFS=$func_echo_IFS 7706fc0178dSmrg} 7716fc0178dSmrg 7726fc0178dSmrg 7736fc0178dSmrg# func_echo_all ARG... 7746fc0178dSmrg# -------------------- 7756fc0178dSmrg# Invoke $ECHO with all args, space-separated. 7766fc0178dSmrgfunc_echo_all () 7776fc0178dSmrg{ 7786fc0178dSmrg $ECHO "$*" 7796fc0178dSmrg} 7806fc0178dSmrg 7816fc0178dSmrg 7826fc0178dSmrg# func_echo_infix_1 INFIX ARG... 7836fc0178dSmrg# ------------------------------ 7846fc0178dSmrg# Echo program name, followed by INFIX on the first line, with any 7856fc0178dSmrg# additional lines not showing INFIX. 7866fc0178dSmrgfunc_echo_infix_1 () 7876fc0178dSmrg{ 7886fc0178dSmrg $debug_cmd 7896fc0178dSmrg 7906fc0178dSmrg $require_term_colors 7916fc0178dSmrg 7926fc0178dSmrg _G_infix=$1; shift 7936fc0178dSmrg _G_indent=$_G_infix 7946fc0178dSmrg _G_prefix="$progname: $_G_infix: " 7956fc0178dSmrg _G_message=$* 7966fc0178dSmrg 7976fc0178dSmrg # Strip color escape sequences before counting printable length 7986fc0178dSmrg for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan" 7996fc0178dSmrg do 8006fc0178dSmrg test -n "$_G_tc" && { 8016fc0178dSmrg _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"` 8026fc0178dSmrg _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"` 8036fc0178dSmrg } 8046fc0178dSmrg done 8056fc0178dSmrg _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`" " ## exclude from sc_prohibit_nested_quotes 8066fc0178dSmrg 8076fc0178dSmrg func_echo_infix_1_IFS=$IFS 8086fc0178dSmrg IFS=$nl 8096fc0178dSmrg for _G_line in $_G_message; do 8106fc0178dSmrg IFS=$func_echo_infix_1_IFS 8116fc0178dSmrg $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2 8126fc0178dSmrg _G_prefix=$_G_indent 8136fc0178dSmrg done 8146fc0178dSmrg IFS=$func_echo_infix_1_IFS 8156fc0178dSmrg} 8166fc0178dSmrg 8176fc0178dSmrg 8186fc0178dSmrg# func_error ARG... 8196fc0178dSmrg# ----------------- 8206fc0178dSmrg# Echo program name prefixed message to standard error. 8216fc0178dSmrgfunc_error () 8226fc0178dSmrg{ 8236fc0178dSmrg $debug_cmd 8246fc0178dSmrg 8256fc0178dSmrg $require_term_colors 8266fc0178dSmrg 8276fc0178dSmrg func_echo_infix_1 " $tc_standout${tc_red}error$tc_reset" "$*" >&2 8286fc0178dSmrg} 8296fc0178dSmrg 8306fc0178dSmrg 8316fc0178dSmrg# func_fatal_error ARG... 8326fc0178dSmrg# ----------------------- 8336fc0178dSmrg# Echo program name prefixed message to standard error, and exit. 8346fc0178dSmrgfunc_fatal_error () 8356fc0178dSmrg{ 8366fc0178dSmrg $debug_cmd 8376fc0178dSmrg 8386fc0178dSmrg func_error "$*" 8396fc0178dSmrg exit $EXIT_FAILURE 8406fc0178dSmrg} 8416fc0178dSmrg 8426fc0178dSmrg 8436fc0178dSmrg# func_grep EXPRESSION FILENAME 8446fc0178dSmrg# ----------------------------- 8457a3b38f7Smrg# Check whether EXPRESSION matches any line of FILENAME, without output. 8467a3b38f7Smrgfunc_grep () 8477a3b38f7Smrg{ 8486fc0178dSmrg $debug_cmd 8496fc0178dSmrg 8507a3b38f7Smrg $GREP "$1" "$2" >/dev/null 2>&1 8517a3b38f7Smrg} 8527a3b38f7Smrg 8537a3b38f7Smrg 8546fc0178dSmrg# func_len STRING 8556fc0178dSmrg# --------------- 8566fc0178dSmrg# Set func_len_result to the length of STRING. STRING may not 8576fc0178dSmrg# start with a hyphen. 8586fc0178dSmrg test -z "$_G_HAVE_XSI_OPS" \ 8596fc0178dSmrg && (eval 'x=a/b/c; 8606fc0178dSmrg test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ 8616fc0178dSmrg && _G_HAVE_XSI_OPS=yes 8626fc0178dSmrg 8636fc0178dSmrgif test yes = "$_G_HAVE_XSI_OPS"; then 8646fc0178dSmrg eval 'func_len () 8656fc0178dSmrg { 8666fc0178dSmrg $debug_cmd 8676fc0178dSmrg 8686fc0178dSmrg func_len_result=${#1} 8696fc0178dSmrg }' 8706fc0178dSmrgelse 8716fc0178dSmrg func_len () 8726fc0178dSmrg { 8736fc0178dSmrg $debug_cmd 8746fc0178dSmrg 8756fc0178dSmrg func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len` 8766fc0178dSmrg } 8776fc0178dSmrgfi 8786fc0178dSmrg 8796fc0178dSmrg 8806fc0178dSmrg# func_mkdir_p DIRECTORY-PATH 8816fc0178dSmrg# --------------------------- 8827a3b38f7Smrg# Make sure the entire path to DIRECTORY-PATH is available. 8837a3b38f7Smrgfunc_mkdir_p () 8847a3b38f7Smrg{ 8856fc0178dSmrg $debug_cmd 8867a3b38f7Smrg 8876fc0178dSmrg _G_directory_path=$1 8886fc0178dSmrg _G_dir_list= 8897a3b38f7Smrg 8906fc0178dSmrg if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then 8916fc0178dSmrg 8926fc0178dSmrg # Protect directory names starting with '-' 8936fc0178dSmrg case $_G_directory_path in 8946fc0178dSmrg -*) _G_directory_path=./$_G_directory_path ;; 8957a3b38f7Smrg esac 8967a3b38f7Smrg 8977a3b38f7Smrg # While some portion of DIR does not yet exist... 8986fc0178dSmrg while test ! -d "$_G_directory_path"; do 8997a3b38f7Smrg # ...make a list in topmost first order. Use a colon delimited 9007a3b38f7Smrg # list incase some portion of path contains whitespace. 9016fc0178dSmrg _G_dir_list=$_G_directory_path:$_G_dir_list 9027a3b38f7Smrg 9037a3b38f7Smrg # If the last portion added has no slash in it, the list is done 9046fc0178dSmrg case $_G_directory_path in */*) ;; *) break ;; esac 9057a3b38f7Smrg 9067a3b38f7Smrg # ...otherwise throw away the child directory and loop 9076fc0178dSmrg _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"` 9087a3b38f7Smrg done 9096fc0178dSmrg _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'` 9107a3b38f7Smrg 9116fc0178dSmrg func_mkdir_p_IFS=$IFS; IFS=: 9126fc0178dSmrg for _G_dir in $_G_dir_list; do 9136fc0178dSmrg IFS=$func_mkdir_p_IFS 9146fc0178dSmrg # mkdir can fail with a 'File exist' error if two processes 9157a3b38f7Smrg # try to create one of the directories concurrently. Don't 9167a3b38f7Smrg # stop in that case! 9176fc0178dSmrg $MKDIR "$_G_dir" 2>/dev/null || : 9187a3b38f7Smrg done 9196fc0178dSmrg IFS=$func_mkdir_p_IFS 9207a3b38f7Smrg 9217a3b38f7Smrg # Bail out if we (or some other process) failed to create a directory. 9226fc0178dSmrg test -d "$_G_directory_path" || \ 9236fc0178dSmrg func_fatal_error "Failed to create '$1'" 9247a3b38f7Smrg fi 9257a3b38f7Smrg} 926ff559fabSmrg 927ff559fabSmrg 9286fc0178dSmrg# func_mktempdir [BASENAME] 9296fc0178dSmrg# ------------------------- 930ff559fabSmrg# Make a temporary directory that won't clash with other running 931ff559fabSmrg# libtool processes, and avoids race conditions if possible. If 9326fc0178dSmrg# given, BASENAME is the basename for that directory. 933ff559fabSmrgfunc_mktempdir () 934ff559fabSmrg{ 9356fc0178dSmrg $debug_cmd 9366fc0178dSmrg 9376fc0178dSmrg _G_template=${TMPDIR-/tmp}/${1-$progname} 938ff559fabSmrg 9396fc0178dSmrg if test : = "$opt_dry_run"; then 940ff559fabSmrg # Return a directory name, but don't create it in dry-run mode 9416fc0178dSmrg _G_tmpdir=$_G_template-$$ 942ff559fabSmrg else 943ff559fabSmrg 944ff559fabSmrg # If mktemp works, use that first and foremost 9456fc0178dSmrg _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null` 946ff559fabSmrg 9476fc0178dSmrg if test ! -d "$_G_tmpdir"; then 9487a3b38f7Smrg # Failing that, at least try and use $RANDOM to avoid a race 9496fc0178dSmrg _G_tmpdir=$_G_template-${RANDOM-0}$$ 950ff559fabSmrg 9516fc0178dSmrg func_mktempdir_umask=`umask` 9527a3b38f7Smrg umask 0077 9536fc0178dSmrg $MKDIR "$_G_tmpdir" 9546fc0178dSmrg umask $func_mktempdir_umask 955ff559fabSmrg fi 956ff559fabSmrg 957ff559fabSmrg # If we're not in dry-run mode, bomb out on failure 9586fc0178dSmrg test -d "$_G_tmpdir" || \ 9596fc0178dSmrg func_fatal_error "cannot create temporary directory '$_G_tmpdir'" 9606fc0178dSmrg fi 9616fc0178dSmrg 9626fc0178dSmrg $ECHO "$_G_tmpdir" 9636fc0178dSmrg} 9646fc0178dSmrg 9656fc0178dSmrg 9666fc0178dSmrg# func_normal_abspath PATH 9676fc0178dSmrg# ------------------------ 9686fc0178dSmrg# Remove doubled-up and trailing slashes, "." path components, 9696fc0178dSmrg# and cancel out any ".." path components in PATH after making 9706fc0178dSmrg# it an absolute path. 9716fc0178dSmrgfunc_normal_abspath () 9726fc0178dSmrg{ 9736fc0178dSmrg $debug_cmd 9746fc0178dSmrg 9756fc0178dSmrg # These SED scripts presuppose an absolute path with a trailing slash. 9766fc0178dSmrg _G_pathcar='s|^/\([^/]*\).*$|\1|' 9776fc0178dSmrg _G_pathcdr='s|^/[^/]*||' 9786fc0178dSmrg _G_removedotparts=':dotsl 9796fc0178dSmrg s|/\./|/|g 9806fc0178dSmrg t dotsl 9816fc0178dSmrg s|/\.$|/|' 9826fc0178dSmrg _G_collapseslashes='s|/\{1,\}|/|g' 9836fc0178dSmrg _G_finalslash='s|/*$|/|' 9846fc0178dSmrg 9856fc0178dSmrg # Start from root dir and reassemble the path. 9866fc0178dSmrg func_normal_abspath_result= 9876fc0178dSmrg func_normal_abspath_tpath=$1 9886fc0178dSmrg func_normal_abspath_altnamespace= 9896fc0178dSmrg case $func_normal_abspath_tpath in 9906fc0178dSmrg "") 9916fc0178dSmrg # Empty path, that just means $cwd. 9926fc0178dSmrg func_stripname '' '/' "`pwd`" 9936fc0178dSmrg func_normal_abspath_result=$func_stripname_result 9946fc0178dSmrg return 9956fc0178dSmrg ;; 9966fc0178dSmrg # The next three entries are used to spot a run of precisely 9976fc0178dSmrg # two leading slashes without using negated character classes; 9986fc0178dSmrg # we take advantage of case's first-match behaviour. 9996fc0178dSmrg ///*) 10006fc0178dSmrg # Unusual form of absolute path, do nothing. 10016fc0178dSmrg ;; 10026fc0178dSmrg //*) 10036fc0178dSmrg # Not necessarily an ordinary path; POSIX reserves leading '//' 10046fc0178dSmrg # and for example Cygwin uses it to access remote file shares 10056fc0178dSmrg # over CIFS/SMB, so we conserve a leading double slash if found. 10066fc0178dSmrg func_normal_abspath_altnamespace=/ 10076fc0178dSmrg ;; 10086fc0178dSmrg /*) 10096fc0178dSmrg # Absolute path, do nothing. 10106fc0178dSmrg ;; 10116fc0178dSmrg *) 10126fc0178dSmrg # Relative path, prepend $cwd. 10136fc0178dSmrg func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath 10146fc0178dSmrg ;; 10156fc0178dSmrg esac 10166fc0178dSmrg 10176fc0178dSmrg # Cancel out all the simple stuff to save iterations. We also want 10186fc0178dSmrg # the path to end with a slash for ease of parsing, so make sure 10196fc0178dSmrg # there is one (and only one) here. 10206fc0178dSmrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 10216fc0178dSmrg -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"` 10226fc0178dSmrg while :; do 10236fc0178dSmrg # Processed it all yet? 10246fc0178dSmrg if test / = "$func_normal_abspath_tpath"; then 10256fc0178dSmrg # If we ascended to the root using ".." the result may be empty now. 10266fc0178dSmrg if test -z "$func_normal_abspath_result"; then 10276fc0178dSmrg func_normal_abspath_result=/ 10286fc0178dSmrg fi 10296fc0178dSmrg break 10306fc0178dSmrg fi 10316fc0178dSmrg func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ 10326fc0178dSmrg -e "$_G_pathcar"` 10336fc0178dSmrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 10346fc0178dSmrg -e "$_G_pathcdr"` 10356fc0178dSmrg # Figure out what to do with it 10366fc0178dSmrg case $func_normal_abspath_tcomponent in 10376fc0178dSmrg "") 10386fc0178dSmrg # Trailing empty path component, ignore it. 10396fc0178dSmrg ;; 10406fc0178dSmrg ..) 10416fc0178dSmrg # Parent dir; strip last assembled component from result. 10426fc0178dSmrg func_dirname "$func_normal_abspath_result" 10436fc0178dSmrg func_normal_abspath_result=$func_dirname_result 10446fc0178dSmrg ;; 10456fc0178dSmrg *) 10466fc0178dSmrg # Actual path component, append it. 10476fc0178dSmrg func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent" 10486fc0178dSmrg ;; 10496fc0178dSmrg esac 10506fc0178dSmrg done 10516fc0178dSmrg # Restore leading double-slash if one was found on entry. 10526fc0178dSmrg func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result 10536fc0178dSmrg} 10546fc0178dSmrg 10556fc0178dSmrg 10566fc0178dSmrg# func_notquiet ARG... 10576fc0178dSmrg# -------------------- 10586fc0178dSmrg# Echo program name prefixed message only when not in quiet mode. 10596fc0178dSmrgfunc_notquiet () 10606fc0178dSmrg{ 10616fc0178dSmrg $debug_cmd 10626fc0178dSmrg 10636fc0178dSmrg $opt_quiet || func_echo ${1+"$@"} 10646fc0178dSmrg 10656fc0178dSmrg # A bug in bash halts the script if the last line of a function 10666fc0178dSmrg # fails when set -e is in force, so we need another command to 10676fc0178dSmrg # work around that: 10686fc0178dSmrg : 10696fc0178dSmrg} 10706fc0178dSmrg 10716fc0178dSmrg 10726fc0178dSmrg# func_relative_path SRCDIR DSTDIR 10736fc0178dSmrg# -------------------------------- 10746fc0178dSmrg# Set func_relative_path_result to the relative path from SRCDIR to DSTDIR. 10756fc0178dSmrgfunc_relative_path () 10766fc0178dSmrg{ 10776fc0178dSmrg $debug_cmd 10786fc0178dSmrg 10796fc0178dSmrg func_relative_path_result= 10806fc0178dSmrg func_normal_abspath "$1" 10816fc0178dSmrg func_relative_path_tlibdir=$func_normal_abspath_result 10826fc0178dSmrg func_normal_abspath "$2" 10836fc0178dSmrg func_relative_path_tbindir=$func_normal_abspath_result 10846fc0178dSmrg 10856fc0178dSmrg # Ascend the tree starting from libdir 10866fc0178dSmrg while :; do 10876fc0178dSmrg # check if we have found a prefix of bindir 10886fc0178dSmrg case $func_relative_path_tbindir in 10896fc0178dSmrg $func_relative_path_tlibdir) 10906fc0178dSmrg # found an exact match 10916fc0178dSmrg func_relative_path_tcancelled= 10926fc0178dSmrg break 10936fc0178dSmrg ;; 10946fc0178dSmrg $func_relative_path_tlibdir*) 10956fc0178dSmrg # found a matching prefix 10966fc0178dSmrg func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" 10976fc0178dSmrg func_relative_path_tcancelled=$func_stripname_result 10986fc0178dSmrg if test -z "$func_relative_path_result"; then 10996fc0178dSmrg func_relative_path_result=. 11006fc0178dSmrg fi 11016fc0178dSmrg break 11026fc0178dSmrg ;; 11036fc0178dSmrg *) 11046fc0178dSmrg func_dirname $func_relative_path_tlibdir 11056fc0178dSmrg func_relative_path_tlibdir=$func_dirname_result 11066fc0178dSmrg if test -z "$func_relative_path_tlibdir"; then 11076fc0178dSmrg # Have to descend all the way to the root! 11086fc0178dSmrg func_relative_path_result=../$func_relative_path_result 11096fc0178dSmrg func_relative_path_tcancelled=$func_relative_path_tbindir 11106fc0178dSmrg break 11116fc0178dSmrg fi 11126fc0178dSmrg func_relative_path_result=../$func_relative_path_result 11136fc0178dSmrg ;; 11146fc0178dSmrg esac 11156fc0178dSmrg done 11166fc0178dSmrg 11176fc0178dSmrg # Now calculate path; take care to avoid doubling-up slashes. 11186fc0178dSmrg func_stripname '' '/' "$func_relative_path_result" 11196fc0178dSmrg func_relative_path_result=$func_stripname_result 11206fc0178dSmrg func_stripname '/' '/' "$func_relative_path_tcancelled" 11216fc0178dSmrg if test -n "$func_stripname_result"; then 11226fc0178dSmrg func_append func_relative_path_result "/$func_stripname_result" 11236fc0178dSmrg fi 11246fc0178dSmrg 11256fc0178dSmrg # Normalisation. If bindir is libdir, return '.' else relative path. 11266fc0178dSmrg if test -n "$func_relative_path_result"; then 11276fc0178dSmrg func_stripname './' '' "$func_relative_path_result" 11286fc0178dSmrg func_relative_path_result=$func_stripname_result 1129ff559fabSmrg fi 1130ff559fabSmrg 11316fc0178dSmrg test -n "$func_relative_path_result" || func_relative_path_result=. 11326fc0178dSmrg 11336fc0178dSmrg : 11346fc0178dSmrg} 11356fc0178dSmrg 11366fc0178dSmrg 1137515ec619Smrg# func_quote_portable EVAL ARG 1138515ec619Smrg# ---------------------------- 1139515ec619Smrg# Internal function to portably implement func_quote_arg. Note that we still 1140515ec619Smrg# keep attention to performance here so we as much as possible try to avoid 1141515ec619Smrg# calling sed binary (so far O(N) complexity as long as func_append is O(1)). 1142515ec619Smrgfunc_quote_portable () 11436fc0178dSmrg{ 11446fc0178dSmrg $debug_cmd 11456fc0178dSmrg 1146515ec619Smrg $require_check_ifs_backslash 1147515ec619Smrg 1148515ec619Smrg func_quote_portable_result=$2 1149515ec619Smrg 1150515ec619Smrg # one-time-loop (easy break) 1151515ec619Smrg while true 1152515ec619Smrg do 1153515ec619Smrg if $1; then 1154515ec619Smrg func_quote_portable_result=`$ECHO "$2" | $SED \ 1155515ec619Smrg -e "$sed_double_quote_subst" -e "$sed_double_backslash"` 1156515ec619Smrg break 11576fc0178dSmrg fi 11586fc0178dSmrg 1159515ec619Smrg # Quote for eval. 1160515ec619Smrg case $func_quote_portable_result in 1161515ec619Smrg *[\\\`\"\$]*) 1162515ec619Smrg # Fallback to sed for $func_check_bs_ifs_broken=:, or when the string 1163515ec619Smrg # contains the shell wildcard characters. 1164515ec619Smrg case $check_ifs_backshlash_broken$func_quote_portable_result in 1165515ec619Smrg :*|*[\[\*\?]*) 1166515ec619Smrg func_quote_portable_result=`$ECHO "$func_quote_portable_result" \ 1167515ec619Smrg | $SED "$sed_quote_subst"` 1168515ec619Smrg break 1169515ec619Smrg ;; 1170515ec619Smrg esac 1171515ec619Smrg 1172515ec619Smrg func_quote_portable_old_IFS=$IFS 1173515ec619Smrg for _G_char in '\' '`' '"' '$' 1174515ec619Smrg do 1175515ec619Smrg # STATE($1) PREV($2) SEPARATOR($3) 1176515ec619Smrg set start "" "" 1177515ec619Smrg func_quote_portable_result=dummy"$_G_char$func_quote_portable_result$_G_char"dummy 1178515ec619Smrg IFS=$_G_char 1179515ec619Smrg for _G_part in $func_quote_portable_result 1180515ec619Smrg do 1181515ec619Smrg case $1 in 1182515ec619Smrg quote) 1183515ec619Smrg func_append func_quote_portable_result "$3$2" 1184515ec619Smrg set quote "$_G_part" "\\$_G_char" 1185515ec619Smrg ;; 1186515ec619Smrg start) 1187515ec619Smrg set first "" "" 1188515ec619Smrg func_quote_portable_result= 1189515ec619Smrg ;; 1190515ec619Smrg first) 1191515ec619Smrg set quote "$_G_part" "" 1192515ec619Smrg ;; 1193515ec619Smrg esac 1194515ec619Smrg done 1195515ec619Smrg done 1196515ec619Smrg IFS=$func_quote_portable_old_IFS 11976fc0178dSmrg ;; 1198515ec619Smrg *) ;; 11996fc0178dSmrg esac 1200515ec619Smrg break 12016fc0178dSmrg done 1202515ec619Smrg 1203515ec619Smrg func_quote_portable_unquoted_result=$func_quote_portable_result 1204515ec619Smrg case $func_quote_portable_result in 1205515ec619Smrg # double-quote args containing shell metacharacters to delay 1206515ec619Smrg # word splitting, command substitution and variable expansion 1207515ec619Smrg # for a subsequent eval. 1208515ec619Smrg # many bourne shells cannot handle close brackets correctly 1209515ec619Smrg # in scan sets, so we specify it separately. 1210515ec619Smrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 1211515ec619Smrg func_quote_portable_result=\"$func_quote_portable_result\" 1212515ec619Smrg ;; 1213515ec619Smrg esac 12146fc0178dSmrg} 12156fc0178dSmrg 12166fc0178dSmrg 1217515ec619Smrg# func_quotefast_eval ARG 1218515ec619Smrg# ----------------------- 1219515ec619Smrg# Quote one ARG (internal). This is equivalent to 'func_quote_arg eval ARG', 1220515ec619Smrg# but optimized for speed. Result is stored in $func_quotefast_eval. 1221515ec619Smrgif test xyes = `(x=; printf -v x %q yes; echo x"$x") 2>/dev/null`; then 1222515ec619Smrg printf -v _GL_test_printf_tilde %q '~' 1223515ec619Smrg if test '\~' = "$_GL_test_printf_tilde"; then 1224515ec619Smrg func_quotefast_eval () 1225515ec619Smrg { 1226515ec619Smrg printf -v func_quotefast_eval_result %q "$1" 1227515ec619Smrg } 1228515ec619Smrg else 1229515ec619Smrg # Broken older Bash implementations. Make those faster too if possible. 1230515ec619Smrg func_quotefast_eval () 1231515ec619Smrg { 1232515ec619Smrg case $1 in 1233515ec619Smrg '~'*) 1234515ec619Smrg func_quote_portable false "$1" 1235515ec619Smrg func_quotefast_eval_result=$func_quote_portable_result 1236515ec619Smrg ;; 1237515ec619Smrg *) 1238515ec619Smrg printf -v func_quotefast_eval_result %q "$1" 1239515ec619Smrg ;; 1240515ec619Smrg esac 1241515ec619Smrg } 1242515ec619Smrg fi 1243515ec619Smrgelse 1244515ec619Smrg func_quotefast_eval () 1245515ec619Smrg { 1246515ec619Smrg func_quote_portable false "$1" 1247515ec619Smrg func_quotefast_eval_result=$func_quote_portable_result 1248515ec619Smrg } 1249515ec619Smrgfi 12506fc0178dSmrg 1251515ec619Smrg 1252515ec619Smrg# func_quote_arg MODEs ARG 1253515ec619Smrg# ------------------------ 1254515ec619Smrg# Quote one ARG to be evaled later. MODEs argument may contain zero or more 1255515ec619Smrg# specifiers listed below separated by ',' character. This function returns two 1256515ec619Smrg# values: 1257515ec619Smrg# i) func_quote_arg_result 1258515ec619Smrg# double-quoted (when needed), suitable for a subsequent eval 1259515ec619Smrg# ii) func_quote_arg_unquoted_result 1260515ec619Smrg# has all characters that are still active within double 1261515ec619Smrg# quotes backslashified. Available only if 'unquoted' is specified. 1262515ec619Smrg# 1263515ec619Smrg# Available modes: 1264515ec619Smrg# ---------------- 1265515ec619Smrg# 'eval' (default) 1266515ec619Smrg# - escape shell special characters 1267515ec619Smrg# 'expand' 1268515ec619Smrg# - the same as 'eval'; but do not quote variable references 1269515ec619Smrg# 'pretty' 1270515ec619Smrg# - request aesthetic output, i.e. '"a b"' instead of 'a\ b'. This might 1271515ec619Smrg# be used later in func_quote to get output like: 'echo "a b"' instead 1272515ec619Smrg# of 'echo a\ b'. This is slower than default on some shells. 1273515ec619Smrg# 'unquoted' 1274515ec619Smrg# - produce also $func_quote_arg_unquoted_result which does not contain 1275515ec619Smrg# wrapping double-quotes. 1276515ec619Smrg# 1277515ec619Smrg# Examples for 'func_quote_arg pretty,unquoted string': 1278515ec619Smrg# 1279515ec619Smrg# string | *_result | *_unquoted_result 1280515ec619Smrg# ------------+-----------------------+------------------- 1281515ec619Smrg# " | \" | \" 1282515ec619Smrg# a b | "a b" | a b 1283515ec619Smrg# "a b" | "\"a b\"" | \"a b\" 1284515ec619Smrg# * | "*" | * 1285515ec619Smrg# z="${x-$y}" | "z=\"\${x-\$y}\"" | z=\"\${x-\$y}\" 1286515ec619Smrg# 1287515ec619Smrg# Examples for 'func_quote_arg pretty,unquoted,expand string': 1288515ec619Smrg# 1289515ec619Smrg# string | *_result | *_unquoted_result 1290515ec619Smrg# --------------+---------------------+-------------------- 1291515ec619Smrg# z="${x-$y}" | "z=\"${x-$y}\"" | z=\"${x-$y}\" 1292515ec619Smrgfunc_quote_arg () 1293515ec619Smrg{ 1294515ec619Smrg _G_quote_expand=false 1295515ec619Smrg case ,$1, in 1296515ec619Smrg *,expand,*) 1297515ec619Smrg _G_quote_expand=: 1298515ec619Smrg ;; 12996fc0178dSmrg esac 13006fc0178dSmrg 1301515ec619Smrg case ,$1, in 1302515ec619Smrg *,pretty,*|*,expand,*|*,unquoted,*) 1303515ec619Smrg func_quote_portable $_G_quote_expand "$2" 1304515ec619Smrg func_quote_arg_result=$func_quote_portable_result 1305515ec619Smrg func_quote_arg_unquoted_result=$func_quote_portable_unquoted_result 1306515ec619Smrg ;; 1307515ec619Smrg *) 1308515ec619Smrg # Faster quote-for-eval for some shells. 1309515ec619Smrg func_quotefast_eval "$2" 1310515ec619Smrg func_quote_arg_result=$func_quotefast_eval_result 13116fc0178dSmrg ;; 13126fc0178dSmrg esac 1313515ec619Smrg} 1314515ec619Smrg 13156fc0178dSmrg 1316515ec619Smrg# func_quote MODEs ARGs... 1317515ec619Smrg# ------------------------ 1318515ec619Smrg# Quote all ARGs to be evaled later and join them into single command. See 1319515ec619Smrg# func_quote_arg's description for more info. 1320515ec619Smrgfunc_quote () 1321515ec619Smrg{ 1322515ec619Smrg $debug_cmd 1323515ec619Smrg _G_func_quote_mode=$1 ; shift 1324515ec619Smrg func_quote_result= 1325515ec619Smrg while test 0 -lt $#; do 1326515ec619Smrg func_quote_arg "$_G_func_quote_mode" "$1" 1327515ec619Smrg if test -n "$func_quote_result"; then 1328515ec619Smrg func_append func_quote_result " $func_quote_arg_result" 1329515ec619Smrg else 1330515ec619Smrg func_append func_quote_result "$func_quote_arg_result" 1331515ec619Smrg fi 1332515ec619Smrg shift 1333515ec619Smrg done 13346fc0178dSmrg} 13356fc0178dSmrg 13366fc0178dSmrg 13376fc0178dSmrg# func_stripname PREFIX SUFFIX NAME 13386fc0178dSmrg# --------------------------------- 13396fc0178dSmrg# strip PREFIX and SUFFIX from NAME, and store in func_stripname_result. 13406fc0178dSmrg# PREFIX and SUFFIX must not contain globbing or regex special 13416fc0178dSmrg# characters, hashes, percent signs, but SUFFIX may contain a leading 13426fc0178dSmrg# dot (in which case that matches only a dot). 13436fc0178dSmrgif test yes = "$_G_HAVE_XSI_OPS"; then 13446fc0178dSmrg eval 'func_stripname () 13456fc0178dSmrg { 13466fc0178dSmrg $debug_cmd 13476fc0178dSmrg 13486fc0178dSmrg # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are 13496fc0178dSmrg # positional parameters, so assign one to ordinary variable first. 13506fc0178dSmrg func_stripname_result=$3 13516fc0178dSmrg func_stripname_result=${func_stripname_result#"$1"} 13526fc0178dSmrg func_stripname_result=${func_stripname_result%"$2"} 13536fc0178dSmrg }' 13546fc0178dSmrgelse 13556fc0178dSmrg func_stripname () 13566fc0178dSmrg { 13576fc0178dSmrg $debug_cmd 13586fc0178dSmrg 13596fc0178dSmrg case $2 in 13606fc0178dSmrg .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;; 13616fc0178dSmrg *) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;; 13626fc0178dSmrg esac 13636fc0178dSmrg } 13646fc0178dSmrgfi 13656fc0178dSmrg 13666fc0178dSmrg 13676fc0178dSmrg# func_show_eval CMD [FAIL_EXP] 13686fc0178dSmrg# ----------------------------- 13696fc0178dSmrg# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is 13706fc0178dSmrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 13716fc0178dSmrg# is given, then evaluate it. 13726fc0178dSmrgfunc_show_eval () 13736fc0178dSmrg{ 13746fc0178dSmrg $debug_cmd 13756fc0178dSmrg 13766fc0178dSmrg _G_cmd=$1 13776fc0178dSmrg _G_fail_exp=${2-':'} 13786fc0178dSmrg 1379515ec619Smrg func_quote_arg pretty,expand "$_G_cmd" 1380515ec619Smrg eval "func_notquiet $func_quote_arg_result" 13816fc0178dSmrg 13826fc0178dSmrg $opt_dry_run || { 13836fc0178dSmrg eval "$_G_cmd" 13846fc0178dSmrg _G_status=$? 13856fc0178dSmrg if test 0 -ne "$_G_status"; then 13866fc0178dSmrg eval "(exit $_G_status); $_G_fail_exp" 13876fc0178dSmrg fi 13886fc0178dSmrg } 13896fc0178dSmrg} 13906fc0178dSmrg 13916fc0178dSmrg 13926fc0178dSmrg# func_show_eval_locale CMD [FAIL_EXP] 13936fc0178dSmrg# ------------------------------------ 13946fc0178dSmrg# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is 13956fc0178dSmrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 13966fc0178dSmrg# is given, then evaluate it. Use the saved locale for evaluation. 13976fc0178dSmrgfunc_show_eval_locale () 13986fc0178dSmrg{ 13996fc0178dSmrg $debug_cmd 14006fc0178dSmrg 14016fc0178dSmrg _G_cmd=$1 14026fc0178dSmrg _G_fail_exp=${2-':'} 14036fc0178dSmrg 14046fc0178dSmrg $opt_quiet || { 1405515ec619Smrg func_quote_arg expand,pretty "$_G_cmd" 1406515ec619Smrg eval "func_echo $func_quote_arg_result" 14076fc0178dSmrg } 14086fc0178dSmrg 14096fc0178dSmrg $opt_dry_run || { 14106fc0178dSmrg eval "$_G_user_locale 14116fc0178dSmrg $_G_cmd" 14126fc0178dSmrg _G_status=$? 14136fc0178dSmrg eval "$_G_safe_locale" 14146fc0178dSmrg if test 0 -ne "$_G_status"; then 14156fc0178dSmrg eval "(exit $_G_status); $_G_fail_exp" 14166fc0178dSmrg fi 14176fc0178dSmrg } 14186fc0178dSmrg} 14196fc0178dSmrg 14206fc0178dSmrg 14216fc0178dSmrg# func_tr_sh 14226fc0178dSmrg# ---------- 14236fc0178dSmrg# Turn $1 into a string suitable for a shell variable name. 14246fc0178dSmrg# Result is stored in $func_tr_sh_result. All characters 14256fc0178dSmrg# not in the set a-zA-Z0-9_ are replaced with '_'. Further, 14266fc0178dSmrg# if $1 begins with a digit, a '_' is prepended as well. 14276fc0178dSmrgfunc_tr_sh () 14286fc0178dSmrg{ 14296fc0178dSmrg $debug_cmd 14306fc0178dSmrg 14316fc0178dSmrg case $1 in 14326fc0178dSmrg [0-9]* | *[!a-zA-Z0-9_]*) 14336fc0178dSmrg func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'` 14346fc0178dSmrg ;; 14356fc0178dSmrg * ) 14366fc0178dSmrg func_tr_sh_result=$1 14376fc0178dSmrg ;; 14386fc0178dSmrg esac 14396fc0178dSmrg} 14406fc0178dSmrg 14416fc0178dSmrg 14426fc0178dSmrg# func_verbose ARG... 14436fc0178dSmrg# ------------------- 14446fc0178dSmrg# Echo program name prefixed message in verbose mode only. 14456fc0178dSmrgfunc_verbose () 14466fc0178dSmrg{ 14476fc0178dSmrg $debug_cmd 14486fc0178dSmrg 14496fc0178dSmrg $opt_verbose && func_echo "$*" 14506fc0178dSmrg 14516fc0178dSmrg : 14526fc0178dSmrg} 14536fc0178dSmrg 14546fc0178dSmrg 14556fc0178dSmrg# func_warn_and_continue ARG... 14566fc0178dSmrg# ----------------------------- 14576fc0178dSmrg# Echo program name prefixed warning message to standard error. 14586fc0178dSmrgfunc_warn_and_continue () 14596fc0178dSmrg{ 14606fc0178dSmrg $debug_cmd 14616fc0178dSmrg 14626fc0178dSmrg $require_term_colors 14636fc0178dSmrg 14646fc0178dSmrg func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2 14656fc0178dSmrg} 14666fc0178dSmrg 14676fc0178dSmrg 14686fc0178dSmrg# func_warning CATEGORY ARG... 14696fc0178dSmrg# ---------------------------- 14706fc0178dSmrg# Echo program name prefixed warning message to standard error. Warning 14716fc0178dSmrg# messages can be filtered according to CATEGORY, where this function 14726fc0178dSmrg# elides messages where CATEGORY is not listed in the global variable 14736fc0178dSmrg# 'opt_warning_types'. 14746fc0178dSmrgfunc_warning () 14756fc0178dSmrg{ 14766fc0178dSmrg $debug_cmd 14776fc0178dSmrg 14786fc0178dSmrg # CATEGORY must be in the warning_categories list! 14796fc0178dSmrg case " $warning_categories " in 14806fc0178dSmrg *" $1 "*) ;; 14816fc0178dSmrg *) func_internal_error "invalid warning category '$1'" ;; 14826fc0178dSmrg esac 14836fc0178dSmrg 14846fc0178dSmrg _G_category=$1 14856fc0178dSmrg shift 14866fc0178dSmrg 14876fc0178dSmrg case " $opt_warning_types " in 14886fc0178dSmrg *" $_G_category "*) $warning_func ${1+"$@"} ;; 14896fc0178dSmrg esac 14906fc0178dSmrg} 14916fc0178dSmrg 14926fc0178dSmrg 14936fc0178dSmrg# func_sort_ver VER1 VER2 14946fc0178dSmrg# ----------------------- 14956fc0178dSmrg# 'sort -V' is not generally available. 14966fc0178dSmrg# Note this deviates from the version comparison in automake 14976fc0178dSmrg# in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a 14986fc0178dSmrg# but this should suffice as we won't be specifying old 14996fc0178dSmrg# version formats or redundant trailing .0 in bootstrap.conf. 15006fc0178dSmrg# If we did want full compatibility then we should probably 15016fc0178dSmrg# use m4_version_compare from autoconf. 15026fc0178dSmrgfunc_sort_ver () 15036fc0178dSmrg{ 15046fc0178dSmrg $debug_cmd 15056fc0178dSmrg 15066fc0178dSmrg printf '%s\n%s\n' "$1" "$2" \ 15076fc0178dSmrg | 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 15086fc0178dSmrg} 15096fc0178dSmrg 15106fc0178dSmrg# func_lt_ver PREV CURR 15116fc0178dSmrg# --------------------- 15126fc0178dSmrg# Return true if PREV and CURR are in the correct order according to 15136fc0178dSmrg# func_sort_ver, otherwise false. Use it like this: 15146fc0178dSmrg# 15156fc0178dSmrg# func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..." 15166fc0178dSmrgfunc_lt_ver () 15176fc0178dSmrg{ 15186fc0178dSmrg $debug_cmd 15196fc0178dSmrg 15206fc0178dSmrg test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q` 15216fc0178dSmrg} 15226fc0178dSmrg 15236fc0178dSmrg 15246fc0178dSmrg# Local variables: 15256fc0178dSmrg# mode: shell-script 15266fc0178dSmrg# sh-indentation: 2 15276fc0178dSmrg# eval: (add-hook 'before-save-hook 'time-stamp) 15286fc0178dSmrg# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" 15296fc0178dSmrg# time-stamp-time-zone: "UTC" 15306fc0178dSmrg# End: 15316fc0178dSmrg#! /bin/sh 15326fc0178dSmrg 15336fc0178dSmrg# A portable, pluggable option parser for Bourne shell. 15346fc0178dSmrg# Written by Gary V. Vaughan, 2010 15356fc0178dSmrg 1536515ec619Smrg# This is free software. There is NO warranty; not even for 1537515ec619Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 1538515ec619Smrg# 1539515ec619Smrg# Copyright (C) 2010-2019, 2021 Bootstrap Authors 1540515ec619Smrg# 1541515ec619Smrg# This file is dual licensed under the terms of the MIT license 1542515ec619Smrg# <https://opensource.org/license/MIT>, and GPL version 2 or later 1543515ec619Smrg# <http://www.gnu.org/licenses/gpl-2.0.html>. You must apply one of 1544515ec619Smrg# these licenses when using or redistributing this software or any of 1545515ec619Smrg# the files within it. See the URLs above, or the file `LICENSE` 1546515ec619Smrg# included in the Bootstrap distribution for the full license texts. 15476fc0178dSmrg 1548515ec619Smrg# Please report bugs or propose patches to: 1549515ec619Smrg# <https://github.com/gnulib-modules/bootstrap/issues> 15506fc0178dSmrg 1551515ec619Smrg# Set a version string for this script. 1552515ec619Smrgscriptversion=2019-02-19.15; # UTC 15536fc0178dSmrg 15546fc0178dSmrg 15556fc0178dSmrg## ------ ## 15566fc0178dSmrg## Usage. ## 15576fc0178dSmrg## ------ ## 15586fc0178dSmrg 15596fc0178dSmrg# This file is a library for parsing options in your shell scripts along 15606fc0178dSmrg# with assorted other useful supporting features that you can make use 15616fc0178dSmrg# of too. 15626fc0178dSmrg# 15636fc0178dSmrg# For the simplest scripts you might need only: 15646fc0178dSmrg# 15656fc0178dSmrg# #!/bin/sh 15666fc0178dSmrg# . relative/path/to/funclib.sh 15676fc0178dSmrg# . relative/path/to/options-parser 15686fc0178dSmrg# scriptversion=1.0 15696fc0178dSmrg# func_options ${1+"$@"} 15706fc0178dSmrg# eval set dummy "$func_options_result"; shift 15716fc0178dSmrg# ...rest of your script... 15726fc0178dSmrg# 15736fc0178dSmrg# In order for the '--version' option to work, you will need to have a 15746fc0178dSmrg# suitably formatted comment like the one at the top of this file 1575515ec619Smrg# starting with '# Written by ' and ending with '# Copyright'. 15766fc0178dSmrg# 15776fc0178dSmrg# For '-h' and '--help' to work, you will also need a one line 15786fc0178dSmrg# description of your script's purpose in a comment directly above the 15796fc0178dSmrg# '# Written by ' line, like the one at the top of this file. 15806fc0178dSmrg# 15816fc0178dSmrg# The default options also support '--debug', which will turn on shell 15826fc0178dSmrg# execution tracing (see the comment above debug_cmd below for another 15836fc0178dSmrg# use), and '--verbose' and the func_verbose function to allow your script 15846fc0178dSmrg# to display verbose messages only when your user has specified 15856fc0178dSmrg# '--verbose'. 15866fc0178dSmrg# 1587515ec619Smrg# After sourcing this file, you can plug in processing for additional 15886fc0178dSmrg# options by amending the variables from the 'Configuration' section 15896fc0178dSmrg# below, and following the instructions in the 'Option parsing' 15906fc0178dSmrg# section further down. 15916fc0178dSmrg 15926fc0178dSmrg## -------------- ## 15936fc0178dSmrg## Configuration. ## 15946fc0178dSmrg## -------------- ## 15956fc0178dSmrg 15966fc0178dSmrg# You should override these variables in your script after sourcing this 15976fc0178dSmrg# file so that they reflect the customisations you have added to the 15986fc0178dSmrg# option parser. 15996fc0178dSmrg 16006fc0178dSmrg# The usage line for option parsing errors and the start of '-h' and 16016fc0178dSmrg# '--help' output messages. You can embed shell variables for delayed 16026fc0178dSmrg# expansion at the time the message is displayed, but you will need to 16036fc0178dSmrg# quote other shell meta-characters carefully to prevent them being 16046fc0178dSmrg# expanded when the contents are evaled. 16056fc0178dSmrgusage='$progpath [OPTION]...' 16066fc0178dSmrg 16076fc0178dSmrg# Short help message in response to '-h' and '--help'. Add to this or 16086fc0178dSmrg# override it after sourcing this library to reflect the full set of 16096fc0178dSmrg# options your script accepts. 16106fc0178dSmrgusage_message="\ 16116fc0178dSmrg --debug enable verbose shell tracing 16126fc0178dSmrg -W, --warnings=CATEGORY 16136fc0178dSmrg report the warnings falling in CATEGORY [all] 16146fc0178dSmrg -v, --verbose verbosely report processing 16156fc0178dSmrg --version print version information and exit 16166fc0178dSmrg -h, --help print short or long help message and exit 16176fc0178dSmrg" 16186fc0178dSmrg 16196fc0178dSmrg# Additional text appended to 'usage_message' in response to '--help'. 16206fc0178dSmrglong_help_message=" 16216fc0178dSmrgWarning categories include: 16226fc0178dSmrg 'all' show all warnings 16236fc0178dSmrg 'none' turn off all the warnings 16246fc0178dSmrg 'error' warnings are treated as fatal errors" 16256fc0178dSmrg 16266fc0178dSmrg# Help message printed before fatal option parsing errors. 16276fc0178dSmrgfatal_help="Try '\$progname --help' for more information." 16286fc0178dSmrg 16296fc0178dSmrg 16306fc0178dSmrg 16316fc0178dSmrg## ------------------------- ## 16326fc0178dSmrg## Hook function management. ## 16336fc0178dSmrg## ------------------------- ## 16346fc0178dSmrg 16356fc0178dSmrg# This section contains functions for adding, removing, and running hooks 1636515ec619Smrg# in the main code. A hook is just a list of function names that can be 1637515ec619Smrg# run in order later on. 16386fc0178dSmrg 16396fc0178dSmrg# func_hookable FUNC_NAME 16406fc0178dSmrg# ----------------------- 16416fc0178dSmrg# Declare that FUNC_NAME will run hooks added with 16426fc0178dSmrg# 'func_add_hook FUNC_NAME ...'. 16436fc0178dSmrgfunc_hookable () 16446fc0178dSmrg{ 16456fc0178dSmrg $debug_cmd 16466fc0178dSmrg 16476fc0178dSmrg func_append hookable_fns " $1" 16486fc0178dSmrg} 16496fc0178dSmrg 16506fc0178dSmrg 16516fc0178dSmrg# func_add_hook FUNC_NAME HOOK_FUNC 16526fc0178dSmrg# --------------------------------- 16536fc0178dSmrg# Request that FUNC_NAME call HOOK_FUNC before it returns. FUNC_NAME must 16546fc0178dSmrg# first have been declared "hookable" by a call to 'func_hookable'. 16556fc0178dSmrgfunc_add_hook () 16566fc0178dSmrg{ 16576fc0178dSmrg $debug_cmd 16586fc0178dSmrg 16596fc0178dSmrg case " $hookable_fns " in 16606fc0178dSmrg *" $1 "*) ;; 16616fc0178dSmrg *) func_fatal_error "'$1' does not accept hook functions." ;; 16626fc0178dSmrg esac 16636fc0178dSmrg 16646fc0178dSmrg eval func_append ${1}_hooks '" $2"' 16656fc0178dSmrg} 16666fc0178dSmrg 16676fc0178dSmrg 16686fc0178dSmrg# func_remove_hook FUNC_NAME HOOK_FUNC 16696fc0178dSmrg# ------------------------------------ 1670515ec619Smrg# Remove HOOK_FUNC from the list of hook functions to be called by 1671515ec619Smrg# FUNC_NAME. 16726fc0178dSmrgfunc_remove_hook () 16736fc0178dSmrg{ 16746fc0178dSmrg $debug_cmd 16756fc0178dSmrg 16766fc0178dSmrg eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`' 16776fc0178dSmrg} 16786fc0178dSmrg 16796fc0178dSmrg 1680515ec619Smrg# func_propagate_result FUNC_NAME_A FUNC_NAME_B 1681515ec619Smrg# --------------------------------------------- 1682515ec619Smrg# If the *_result variable of FUNC_NAME_A _is set_, assign its value to 1683515ec619Smrg# *_result variable of FUNC_NAME_B. 1684515ec619Smrgfunc_propagate_result () 1685515ec619Smrg{ 1686515ec619Smrg $debug_cmd 1687515ec619Smrg 1688515ec619Smrg func_propagate_result_result=: 1689515ec619Smrg if eval "test \"\${${1}_result+set}\" = set" 1690515ec619Smrg then 1691515ec619Smrg eval "${2}_result=\$${1}_result" 1692515ec619Smrg else 1693515ec619Smrg func_propagate_result_result=false 1694515ec619Smrg fi 1695515ec619Smrg} 1696515ec619Smrg 1697515ec619Smrg 16986fc0178dSmrg# func_run_hooks FUNC_NAME [ARG]... 16996fc0178dSmrg# --------------------------------- 17006fc0178dSmrg# Run all hook functions registered to FUNC_NAME. 1701515ec619Smrg# It's assumed that the list of hook functions contains nothing more 17026fc0178dSmrg# than a whitespace-delimited list of legal shell function names, and 17036fc0178dSmrg# no effort is wasted trying to catch shell meta-characters or preserve 17046fc0178dSmrg# whitespace. 17056fc0178dSmrgfunc_run_hooks () 17066fc0178dSmrg{ 17076fc0178dSmrg $debug_cmd 17086fc0178dSmrg 17096fc0178dSmrg case " $hookable_fns " in 17106fc0178dSmrg *" $1 "*) ;; 1711515ec619Smrg *) func_fatal_error "'$1' does not support hook functions." ;; 17126fc0178dSmrg esac 17136fc0178dSmrg 17146fc0178dSmrg eval _G_hook_fns=\$$1_hooks; shift 17156fc0178dSmrg 17166fc0178dSmrg for _G_hook in $_G_hook_fns; do 1717515ec619Smrg func_unset "${_G_hook}_result" 1718515ec619Smrg eval $_G_hook '${1+"$@"}' 1719515ec619Smrg func_propagate_result $_G_hook func_run_hooks 1720515ec619Smrg if $func_propagate_result_result; then 1721515ec619Smrg eval set dummy "$func_run_hooks_result"; shift 1722515ec619Smrg fi 17236fc0178dSmrg done 17246fc0178dSmrg} 17256fc0178dSmrg 17266fc0178dSmrg 17276fc0178dSmrg 17286fc0178dSmrg## --------------- ## 17296fc0178dSmrg## Option parsing. ## 17306fc0178dSmrg## --------------- ## 17316fc0178dSmrg 17326fc0178dSmrg# In order to add your own option parsing hooks, you must accept the 1733515ec619Smrg# full positional parameter list from your hook function. You may remove 1734515ec619Smrg# or edit any options that you action, and then pass back the remaining 1735515ec619Smrg# unprocessed options in '<hooked_function_name>_result', escaped 1736515ec619Smrg# suitably for 'eval'. 1737515ec619Smrg# 1738515ec619Smrg# The '<hooked_function_name>_result' variable is automatically unset 1739515ec619Smrg# before your hook gets called; for best performance, only set the 1740515ec619Smrg# *_result variable when necessary (i.e. don't call the 'func_quote' 1741515ec619Smrg# function unnecessarily because it can be an expensive operation on some 1742515ec619Smrg# machines). 1743515ec619Smrg# 1744515ec619Smrg# Like this: 17456fc0178dSmrg# 17466fc0178dSmrg# my_options_prep () 17476fc0178dSmrg# { 17486fc0178dSmrg# $debug_cmd 17496fc0178dSmrg# 17506fc0178dSmrg# # Extend the existing usage message. 17516fc0178dSmrg# usage_message=$usage_message' 17526fc0178dSmrg# -s, --silent don'\''t print informational messages 17536fc0178dSmrg# ' 1754515ec619Smrg# # No change in '$@' (ignored completely by this hook). Leave 1755515ec619Smrg# # my_options_prep_result variable intact. 17566fc0178dSmrg# } 17576fc0178dSmrg# func_add_hook func_options_prep my_options_prep 17586fc0178dSmrg# 17596fc0178dSmrg# 17606fc0178dSmrg# my_silent_option () 17616fc0178dSmrg# { 17626fc0178dSmrg# $debug_cmd 17636fc0178dSmrg# 1764515ec619Smrg# args_changed=false 1765515ec619Smrg# 1766515ec619Smrg# # Note that, for efficiency, we parse as many options as we can 17676fc0178dSmrg# # recognise in a loop before passing the remainder back to the 17686fc0178dSmrg# # caller on the first unrecognised argument we encounter. 17696fc0178dSmrg# while test $# -gt 0; do 17706fc0178dSmrg# opt=$1; shift 17716fc0178dSmrg# case $opt in 1772515ec619Smrg# --silent|-s) opt_silent=: 1773515ec619Smrg# args_changed=: 1774515ec619Smrg# ;; 17756fc0178dSmrg# # Separate non-argument short options: 17766fc0178dSmrg# -s*) func_split_short_opt "$_G_opt" 17776fc0178dSmrg# set dummy "$func_split_short_opt_name" \ 17786fc0178dSmrg# "-$func_split_short_opt_arg" ${1+"$@"} 17796fc0178dSmrg# shift 1780515ec619Smrg# args_changed=: 17816fc0178dSmrg# ;; 1782515ec619Smrg# *) # Make sure the first unrecognised option "$_G_opt" 1783515ec619Smrg# # is added back to "$@" in case we need it later, 1784515ec619Smrg# # if $args_changed was set to 'true'. 1785515ec619Smrg# set dummy "$_G_opt" ${1+"$@"}; shift; break ;; 17866fc0178dSmrg# esac 17876fc0178dSmrg# done 17886fc0178dSmrg# 1789515ec619Smrg# # Only call 'func_quote' here if we processed at least one argument. 1790515ec619Smrg# if $args_changed; then 1791515ec619Smrg# func_quote eval ${1+"$@"} 1792515ec619Smrg# my_silent_option_result=$func_quote_result 1793515ec619Smrg# fi 17946fc0178dSmrg# } 17956fc0178dSmrg# func_add_hook func_parse_options my_silent_option 17966fc0178dSmrg# 17976fc0178dSmrg# 17986fc0178dSmrg# my_option_validation () 17996fc0178dSmrg# { 18006fc0178dSmrg# $debug_cmd 18016fc0178dSmrg# 18026fc0178dSmrg# $opt_silent && $opt_verbose && func_fatal_help "\ 18036fc0178dSmrg# '--silent' and '--verbose' options are mutually exclusive." 18046fc0178dSmrg# } 18056fc0178dSmrg# func_add_hook func_validate_options my_option_validation 18066fc0178dSmrg# 1807515ec619Smrg# You'll also need to manually amend $usage_message to reflect the extra 18086fc0178dSmrg# options you parse. It's preferable to append if you can, so that 18096fc0178dSmrg# multiple option parsing hooks can be added safely. 18106fc0178dSmrg 18116fc0178dSmrg 1812515ec619Smrg# func_options_finish [ARG]... 1813515ec619Smrg# ---------------------------- 1814515ec619Smrg# Finishing the option parse loop (call 'func_options' hooks ATM). 1815515ec619Smrgfunc_options_finish () 1816515ec619Smrg{ 1817515ec619Smrg $debug_cmd 1818515ec619Smrg 1819515ec619Smrg func_run_hooks func_options ${1+"$@"} 1820515ec619Smrg func_propagate_result func_run_hooks func_options_finish 1821515ec619Smrg} 1822515ec619Smrg 1823515ec619Smrg 18246fc0178dSmrg# func_options [ARG]... 18256fc0178dSmrg# --------------------- 18266fc0178dSmrg# All the functions called inside func_options are hookable. See the 18276fc0178dSmrg# individual implementations for details. 18286fc0178dSmrgfunc_hookable func_options 18296fc0178dSmrgfunc_options () 18306fc0178dSmrg{ 18316fc0178dSmrg $debug_cmd 18326fc0178dSmrg 1833515ec619Smrg _G_options_quoted=false 18346fc0178dSmrg 1835515ec619Smrg for my_func in options_prep parse_options validate_options options_finish 1836515ec619Smrg do 1837515ec619Smrg func_unset func_${my_func}_result 1838515ec619Smrg func_unset func_run_hooks_result 1839515ec619Smrg eval func_$my_func '${1+"$@"}' 1840515ec619Smrg func_propagate_result func_$my_func func_options 1841515ec619Smrg if $func_propagate_result_result; then 1842515ec619Smrg eval set dummy "$func_options_result"; shift 1843515ec619Smrg _G_options_quoted=: 1844515ec619Smrg fi 1845515ec619Smrg done 18466fc0178dSmrg 1847515ec619Smrg $_G_options_quoted || { 1848515ec619Smrg # As we (func_options) are top-level options-parser function and 1849515ec619Smrg # nobody quoted "$@" for us yet, we need to do it explicitly for 1850515ec619Smrg # caller. 1851515ec619Smrg func_quote eval ${1+"$@"} 1852515ec619Smrg func_options_result=$func_quote_result 1853515ec619Smrg } 1854ff559fabSmrg} 1855ff559fabSmrg 1856ff559fabSmrg 18576fc0178dSmrg# func_options_prep [ARG]... 18586fc0178dSmrg# -------------------------- 18596fc0178dSmrg# All initialisations required before starting the option parse loop. 18606fc0178dSmrg# Note that when calling hook functions, we pass through the list of 18616fc0178dSmrg# positional parameters. If a hook function modifies that list, and 1862515ec619Smrg# needs to propagate that back to rest of this script, then the complete 1863515ec619Smrg# modified list must be put in 'func_run_hooks_result' before returning. 18646fc0178dSmrgfunc_hookable func_options_prep 18656fc0178dSmrgfunc_options_prep () 1866ff559fabSmrg{ 18676fc0178dSmrg $debug_cmd 18687a3b38f7Smrg 18696fc0178dSmrg # Option defaults: 18706fc0178dSmrg opt_verbose=false 18716fc0178dSmrg opt_warning_types= 18726fc0178dSmrg 18736fc0178dSmrg func_run_hooks func_options_prep ${1+"$@"} 1874515ec619Smrg func_propagate_result func_run_hooks func_options_prep 1875ff559fabSmrg} 1876ff559fabSmrg 1877ff559fabSmrg 18786fc0178dSmrg# func_parse_options [ARG]... 18796fc0178dSmrg# --------------------------- 18806fc0178dSmrg# The main option parsing loop. 18816fc0178dSmrgfunc_hookable func_parse_options 18826fc0178dSmrgfunc_parse_options () 1883ff559fabSmrg{ 18846fc0178dSmrg $debug_cmd 18857a3b38f7Smrg 1886515ec619Smrg _G_parse_options_requote=false 18876fc0178dSmrg # this just eases exit handling 18886fc0178dSmrg while test $# -gt 0; do 18896fc0178dSmrg # Defer to hook functions for initial option parsing, so they 18906fc0178dSmrg # get priority in the event of reusing an option name. 18916fc0178dSmrg func_run_hooks func_parse_options ${1+"$@"} 1892515ec619Smrg func_propagate_result func_run_hooks func_parse_options 1893515ec619Smrg if $func_propagate_result_result; then 1894515ec619Smrg eval set dummy "$func_parse_options_result"; shift 1895515ec619Smrg # Even though we may have changed "$@", we passed the "$@" array 1896515ec619Smrg # down into the hook and it quoted it for us (because we are in 1897515ec619Smrg # this if-branch). No need to quote it again. 1898515ec619Smrg _G_parse_options_requote=false 1899515ec619Smrg fi 1900ff559fabSmrg 19016fc0178dSmrg # Break out of the loop if we already parsed every option. 19026fc0178dSmrg test $# -gt 0 || break 1903ff559fabSmrg 1904515ec619Smrg # We expect that one of the options parsed in this function matches 1905515ec619Smrg # and thus we remove _G_opt from "$@" and need to re-quote. 1906515ec619Smrg _G_match_parse_options=: 19076fc0178dSmrg _G_opt=$1 19086fc0178dSmrg shift 19096fc0178dSmrg case $_G_opt in 19106fc0178dSmrg --debug|-x) debug_cmd='set -x' 1911515ec619Smrg func_echo "enabling shell trace mode" >&2 19126fc0178dSmrg $debug_cmd 19136fc0178dSmrg ;; 19146fc0178dSmrg 19156fc0178dSmrg --no-warnings|--no-warning|--no-warn) 19166fc0178dSmrg set dummy --warnings none ${1+"$@"} 19176fc0178dSmrg shift 19186fc0178dSmrg ;; 19197a3b38f7Smrg 19206fc0178dSmrg --warnings|--warning|-W) 1921515ec619Smrg if test $# = 0 && func_missing_arg $_G_opt; then 1922515ec619Smrg _G_parse_options_requote=: 1923515ec619Smrg break 1924515ec619Smrg fi 19256fc0178dSmrg case " $warning_categories $1" in 19266fc0178dSmrg *" $1 "*) 19276fc0178dSmrg # trailing space prevents matching last $1 above 19286fc0178dSmrg func_append_uniq opt_warning_types " $1" 19296fc0178dSmrg ;; 19306fc0178dSmrg *all) 19316fc0178dSmrg opt_warning_types=$warning_categories 19326fc0178dSmrg ;; 19336fc0178dSmrg *none) 19346fc0178dSmrg opt_warning_types=none 19356fc0178dSmrg warning_func=: 19366fc0178dSmrg ;; 19376fc0178dSmrg *error) 19386fc0178dSmrg opt_warning_types=$warning_categories 19396fc0178dSmrg warning_func=func_fatal_error 19406fc0178dSmrg ;; 19416fc0178dSmrg *) 19426fc0178dSmrg func_fatal_error \ 19436fc0178dSmrg "unsupported warning category: '$1'" 19446fc0178dSmrg ;; 19456fc0178dSmrg esac 19466fc0178dSmrg shift 19476fc0178dSmrg ;; 19486fc0178dSmrg 19496fc0178dSmrg --verbose|-v) opt_verbose=: ;; 19506fc0178dSmrg --version) func_version ;; 19516fc0178dSmrg -\?|-h) func_usage ;; 19526fc0178dSmrg --help) func_help ;; 19536fc0178dSmrg 19546fc0178dSmrg # Separate optargs to long options (plugins may need this): 19556fc0178dSmrg --*=*) func_split_equals "$_G_opt" 19566fc0178dSmrg set dummy "$func_split_equals_lhs" \ 19576fc0178dSmrg "$func_split_equals_rhs" ${1+"$@"} 19586fc0178dSmrg shift 19596fc0178dSmrg ;; 19606fc0178dSmrg 19616fc0178dSmrg # Separate optargs to short options: 19626fc0178dSmrg -W*) 19636fc0178dSmrg func_split_short_opt "$_G_opt" 19646fc0178dSmrg set dummy "$func_split_short_opt_name" \ 19656fc0178dSmrg "$func_split_short_opt_arg" ${1+"$@"} 19666fc0178dSmrg shift 19676fc0178dSmrg ;; 19686fc0178dSmrg 19696fc0178dSmrg # Separate non-argument short options: 19706fc0178dSmrg -\?*|-h*|-v*|-x*) 19716fc0178dSmrg func_split_short_opt "$_G_opt" 19726fc0178dSmrg set dummy "$func_split_short_opt_name" \ 19736fc0178dSmrg "-$func_split_short_opt_arg" ${1+"$@"} 19746fc0178dSmrg shift 19756fc0178dSmrg ;; 19766fc0178dSmrg 1977515ec619Smrg --) _G_parse_options_requote=: ; break ;; 19786fc0178dSmrg -*) func_fatal_help "unrecognised option: '$_G_opt'" ;; 1979515ec619Smrg *) set dummy "$_G_opt" ${1+"$@"}; shift 1980515ec619Smrg _G_match_parse_options=false 1981515ec619Smrg break 1982515ec619Smrg ;; 19836fc0178dSmrg esac 1984515ec619Smrg 1985515ec619Smrg if $_G_match_parse_options; then 1986515ec619Smrg _G_parse_options_requote=: 1987515ec619Smrg fi 19886fc0178dSmrg done 19896fc0178dSmrg 1990515ec619Smrg if $_G_parse_options_requote; then 1991515ec619Smrg # save modified positional parameters for caller 1992515ec619Smrg func_quote eval ${1+"$@"} 1993515ec619Smrg func_parse_options_result=$func_quote_result 1994515ec619Smrg fi 1995ff559fabSmrg} 1996ff559fabSmrg 19977a3b38f7Smrg 19986fc0178dSmrg# func_validate_options [ARG]... 19996fc0178dSmrg# ------------------------------ 20006fc0178dSmrg# Perform any sanity checks on option settings and/or unconsumed 20016fc0178dSmrg# arguments. 20026fc0178dSmrgfunc_hookable func_validate_options 20036fc0178dSmrgfunc_validate_options () 2004ff559fabSmrg{ 20056fc0178dSmrg $debug_cmd 2006ff559fabSmrg 20076fc0178dSmrg # Display all warnings if -W was not given. 20086fc0178dSmrg test -n "$opt_warning_types" || opt_warning_types=" $warning_categories" 20097a3b38f7Smrg 20106fc0178dSmrg func_run_hooks func_validate_options ${1+"$@"} 2011515ec619Smrg func_propagate_result func_run_hooks func_validate_options 2012ff559fabSmrg 20136fc0178dSmrg # Bail if the options were screwed! 20146fc0178dSmrg $exit_cmd $EXIT_FAILURE 2015862f5301Smrg} 2016862f5301Smrg 2017ff559fabSmrg 2018862f5301Smrg 20196fc0178dSmrg## ----------------- ## 20206fc0178dSmrg## Helper functions. ## 20216fc0178dSmrg## ----------------- ## 20227a3b38f7Smrg 20236fc0178dSmrg# This section contains the helper functions used by the rest of the 20246fc0178dSmrg# hookable option parser framework in ascii-betical order. 20256fc0178dSmrg 20266fc0178dSmrg 20276fc0178dSmrg# func_fatal_help ARG... 20286fc0178dSmrg# ---------------------- 20296fc0178dSmrg# Echo program name prefixed message to standard error, followed by 20306fc0178dSmrg# a help hint, and exit. 20316fc0178dSmrgfunc_fatal_help () 20327a3b38f7Smrg{ 20336fc0178dSmrg $debug_cmd 2034862f5301Smrg 20356fc0178dSmrg eval \$ECHO \""Usage: $usage"\" 20366fc0178dSmrg eval \$ECHO \""$fatal_help"\" 20376fc0178dSmrg func_error ${1+"$@"} 20386fc0178dSmrg exit $EXIT_FAILURE 20397a3b38f7Smrg} 20407a3b38f7Smrg 20416fc0178dSmrg 20426fc0178dSmrg# func_help 20436fc0178dSmrg# --------- 20446fc0178dSmrg# Echo long help message to standard output and exit. 20457a3b38f7Smrgfunc_help () 20467a3b38f7Smrg{ 20476fc0178dSmrg $debug_cmd 20486fc0178dSmrg 20496fc0178dSmrg func_usage_message 20506fc0178dSmrg $ECHO "$long_help_message" 20516fc0178dSmrg exit 0 20527a3b38f7Smrg} 20537a3b38f7Smrg 20546fc0178dSmrg 20556fc0178dSmrg# func_missing_arg ARGNAME 20566fc0178dSmrg# ------------------------ 20577a3b38f7Smrg# Echo program name prefixed message to standard error and set global 20587a3b38f7Smrg# exit_cmd. 20597a3b38f7Smrgfunc_missing_arg () 20607a3b38f7Smrg{ 20616fc0178dSmrg $debug_cmd 2062862f5301Smrg 20636fc0178dSmrg func_error "Missing argument for '$1'." 20647a3b38f7Smrg exit_cmd=exit 20657a3b38f7Smrg} 20667a3b38f7Smrg 20677a3b38f7Smrg 20686fc0178dSmrg# func_split_equals STRING 20696fc0178dSmrg# ------------------------ 2070515ec619Smrg# Set func_split_equals_lhs and func_split_equals_rhs shell variables 2071515ec619Smrg# after splitting STRING at the '=' sign. 20726fc0178dSmrgtest -z "$_G_HAVE_XSI_OPS" \ 20736fc0178dSmrg && (eval 'x=a/b/c; 20746fc0178dSmrg test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ 20756fc0178dSmrg && _G_HAVE_XSI_OPS=yes 20766fc0178dSmrg 20776fc0178dSmrgif test yes = "$_G_HAVE_XSI_OPS" 20786fc0178dSmrgthen 20796fc0178dSmrg # This is an XSI compatible shell, allowing a faster implementation... 20806fc0178dSmrg eval 'func_split_equals () 20816fc0178dSmrg { 20826fc0178dSmrg $debug_cmd 20836fc0178dSmrg 20846fc0178dSmrg func_split_equals_lhs=${1%%=*} 20856fc0178dSmrg func_split_equals_rhs=${1#*=} 2086515ec619Smrg if test "x$func_split_equals_lhs" = "x$1"; then 2087515ec619Smrg func_split_equals_rhs= 2088515ec619Smrg fi 20896fc0178dSmrg }' 20906fc0178dSmrgelse 20916fc0178dSmrg # ...otherwise fall back to using expr, which is often a shell builtin. 20926fc0178dSmrg func_split_equals () 20936fc0178dSmrg { 20946fc0178dSmrg $debug_cmd 20956fc0178dSmrg 20966fc0178dSmrg func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'` 20976fc0178dSmrg func_split_equals_rhs= 2098515ec619Smrg test "x$func_split_equals_lhs=" = "x$1" \ 20996fc0178dSmrg || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'` 21006fc0178dSmrg } 21016fc0178dSmrgfi #func_split_equals 21026fc0178dSmrg 21036fc0178dSmrg 21046fc0178dSmrg# func_split_short_opt SHORTOPT 21056fc0178dSmrg# ----------------------------- 2106862f5301Smrg# Set func_split_short_opt_name and func_split_short_opt_arg shell 2107862f5301Smrg# variables after splitting SHORTOPT after the 2nd character. 21086fc0178dSmrgif test yes = "$_G_HAVE_XSI_OPS" 21096fc0178dSmrgthen 21106fc0178dSmrg # This is an XSI compatible shell, allowing a faster implementation... 21116fc0178dSmrg eval 'func_split_short_opt () 21126fc0178dSmrg { 21136fc0178dSmrg $debug_cmd 21146fc0178dSmrg 21156fc0178dSmrg func_split_short_opt_arg=${1#??} 21166fc0178dSmrg func_split_short_opt_name=${1%"$func_split_short_opt_arg"} 21176fc0178dSmrg }' 21186fc0178dSmrgelse 21196fc0178dSmrg # ...otherwise fall back to using expr, which is often a shell builtin. 21206fc0178dSmrg func_split_short_opt () 21216fc0178dSmrg { 21226fc0178dSmrg $debug_cmd 21236fc0178dSmrg 2124515ec619Smrg func_split_short_opt_name=`expr "x$1" : 'x\(-.\)'` 21256fc0178dSmrg func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'` 21266fc0178dSmrg } 21276fc0178dSmrgfi #func_split_short_opt 21286fc0178dSmrg 21296fc0178dSmrg 21306fc0178dSmrg# func_usage 21316fc0178dSmrg# ---------- 21326fc0178dSmrg# Echo short help message to standard output and exit. 21336fc0178dSmrgfunc_usage () 2134862f5301Smrg{ 21356fc0178dSmrg $debug_cmd 2136862f5301Smrg 21376fc0178dSmrg func_usage_message 21386fc0178dSmrg $ECHO "Run '$progname --help |${PAGER-more}' for full usage" 21396fc0178dSmrg exit 0 21406fc0178dSmrg} 2141862f5301Smrg 2142862f5301Smrg 21436fc0178dSmrg# func_usage_message 21446fc0178dSmrg# ------------------ 21456fc0178dSmrg# Echo short help message to standard output. 21466fc0178dSmrgfunc_usage_message () 2147862f5301Smrg{ 21486fc0178dSmrg $debug_cmd 2149862f5301Smrg 21506fc0178dSmrg eval \$ECHO \""Usage: $usage"\" 21516fc0178dSmrg echo 21526fc0178dSmrg $SED -n 's|^# || 21536fc0178dSmrg /^Written by/{ 21546fc0178dSmrg x;p;x 21556fc0178dSmrg } 21566fc0178dSmrg h 21576fc0178dSmrg /^Written by/q' < "$progpath" 21586fc0178dSmrg echo 21596fc0178dSmrg eval \$ECHO \""$usage_message"\" 21606fc0178dSmrg} 2161862f5301Smrg 21627a3b38f7Smrg 21636fc0178dSmrg# func_version 21646fc0178dSmrg# ------------ 21656fc0178dSmrg# Echo version message to standard output and exit. 2166515ec619Smrg# The version message is extracted from the calling file's header 2167515ec619Smrg# comments, with leading '# ' stripped: 2168515ec619Smrg# 1. First display the progname and version 2169515ec619Smrg# 2. Followed by the header comment line matching /^# Written by / 2170515ec619Smrg# 3. Then a blank line followed by the first following line matching 2171515ec619Smrg# /^# Copyright / 2172515ec619Smrg# 4. Immediately followed by any lines between the previous matches, 2173515ec619Smrg# except lines preceding the intervening completely blank line. 2174515ec619Smrg# For example, see the header comments of this file. 21756fc0178dSmrgfunc_version () 21766fc0178dSmrg{ 21776fc0178dSmrg $debug_cmd 21787a3b38f7Smrg 21796fc0178dSmrg printf '%s\n' "$progname $scriptversion" 21806fc0178dSmrg $SED -n ' 2181515ec619Smrg /^# Written by /!b 2182515ec619Smrg s|^# ||; p; n 2183515ec619Smrg 2184515ec619Smrg :fwd2blnk 2185515ec619Smrg /./ { 2186515ec619Smrg n 2187515ec619Smrg b fwd2blnk 21886fc0178dSmrg } 2189515ec619Smrg p; n 2190515ec619Smrg 2191515ec619Smrg :holdwrnt 2192515ec619Smrg s|^# || 2193515ec619Smrg s|^# *$|| 2194515ec619Smrg /^Copyright /!{ 2195515ec619Smrg /./H 2196515ec619Smrg n 2197515ec619Smrg b holdwrnt 21986fc0178dSmrg } 2199515ec619Smrg 2200515ec619Smrg s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2| 2201515ec619Smrg G 2202515ec619Smrg s|\(\n\)\n*|\1|g 2203515ec619Smrg p; q' < "$progpath" 22047a3b38f7Smrg 22056fc0178dSmrg exit $? 22066fc0178dSmrg} 22077a3b38f7Smrg 2208ff559fabSmrg 22096fc0178dSmrg# Local variables: 22106fc0178dSmrg# mode: shell-script 22116fc0178dSmrg# sh-indentation: 2 22126fc0178dSmrg# eval: (add-hook 'before-save-hook 'time-stamp) 2213515ec619Smrg# time-stamp-pattern: "30/scriptversion=%:y-%02m-%02d.%02H; # UTC" 22146fc0178dSmrg# time-stamp-time-zone: "UTC" 22156fc0178dSmrg# End: 2216ff559fabSmrg 22176fc0178dSmrg# Set a version string. 2218515ec619Smrgscriptversion='(GNU libtool) 2.4.7' 2219ff559fabSmrg 2220ff559fabSmrg 22216fc0178dSmrg# func_echo ARG... 22226fc0178dSmrg# ---------------- 22236fc0178dSmrg# Libtool also displays the current mode in messages, so override 22246fc0178dSmrg# funclib.sh func_echo with this custom definition. 22256fc0178dSmrgfunc_echo () 2226862f5301Smrg{ 22276fc0178dSmrg $debug_cmd 2228862f5301Smrg 22296fc0178dSmrg _G_message=$* 2230862f5301Smrg 22316fc0178dSmrg func_echo_IFS=$IFS 22326fc0178dSmrg IFS=$nl 22336fc0178dSmrg for _G_line in $_G_message; do 22346fc0178dSmrg IFS=$func_echo_IFS 22356fc0178dSmrg $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line" 22366fc0178dSmrg done 22376fc0178dSmrg IFS=$func_echo_IFS 22386fc0178dSmrg} 2239862f5301Smrg 22406fc0178dSmrg 22416fc0178dSmrg# func_warning ARG... 22426fc0178dSmrg# ------------------- 22436fc0178dSmrg# Libtool warnings are not categorized, so override funclib.sh 22446fc0178dSmrg# func_warning with this simpler definition. 22456fc0178dSmrgfunc_warning () 2246862f5301Smrg{ 22476fc0178dSmrg $debug_cmd 2248862f5301Smrg 22496fc0178dSmrg $warning_func ${1+"$@"} 22506fc0178dSmrg} 2251862f5301Smrg 2252862f5301Smrg 22536fc0178dSmrg## ---------------- ## 22546fc0178dSmrg## Options parsing. ## 22556fc0178dSmrg## ---------------- ## 22566fc0178dSmrg 22576fc0178dSmrg# Hook in the functions to make sure our own options are parsed during 22586fc0178dSmrg# the option parsing loop. 22596fc0178dSmrg 22606fc0178dSmrgusage='$progpath [OPTION]... [MODE-ARG]...' 22616fc0178dSmrg 22626fc0178dSmrg# Short help message in response to '-h'. 22636fc0178dSmrgusage_message="Options: 22646fc0178dSmrg --config show all configuration variables 22656fc0178dSmrg --debug enable verbose shell tracing 22666fc0178dSmrg -n, --dry-run display commands without modifying any files 22676fc0178dSmrg --features display basic configuration information and exit 22686fc0178dSmrg --mode=MODE use operation mode MODE 22696fc0178dSmrg --no-warnings equivalent to '-Wnone' 22706fc0178dSmrg --preserve-dup-deps don't remove duplicate dependency libraries 22716fc0178dSmrg --quiet, --silent don't print informational messages 22726fc0178dSmrg --tag=TAG use configuration variables from tag TAG 22736fc0178dSmrg -v, --verbose print more informational messages than default 22746fc0178dSmrg --version print version information 22756fc0178dSmrg -W, --warnings=CATEGORY report the warnings falling in CATEGORY [all] 22766fc0178dSmrg -h, --help, --help-all print short, long, or detailed help message 22776fc0178dSmrg" 2278862f5301Smrg 22796fc0178dSmrg# Additional text appended to 'usage_message' in response to '--help'. 22806fc0178dSmrgfunc_help () 2281862f5301Smrg{ 22826fc0178dSmrg $debug_cmd 22836fc0178dSmrg 22846fc0178dSmrg func_usage_message 22856fc0178dSmrg $ECHO "$long_help_message 22866fc0178dSmrg 22876fc0178dSmrgMODE must be one of the following: 22886fc0178dSmrg 22896fc0178dSmrg clean remove files from the build directory 22906fc0178dSmrg compile compile a source file into a libtool object 22916fc0178dSmrg execute automatically set library path, then run a program 22926fc0178dSmrg finish complete the installation of libtool libraries 22936fc0178dSmrg install install libraries or executables 22946fc0178dSmrg link create a library or an executable 22956fc0178dSmrg uninstall remove libraries from an installed directory 22966fc0178dSmrg 22976fc0178dSmrgMODE-ARGS vary depending on the MODE. When passed as first option, 22986fc0178dSmrg'--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that. 22996fc0178dSmrgTry '$progname --help --mode=MODE' for a more detailed description of MODE. 23006fc0178dSmrg 23016fc0178dSmrgWhen reporting a bug, please describe a test case to reproduce it and 23026fc0178dSmrginclude the following information: 23036fc0178dSmrg 23046fc0178dSmrg host-triplet: $host 23056fc0178dSmrg shell: $SHELL 23066fc0178dSmrg compiler: $LTCC 23076fc0178dSmrg compiler flags: $LTCFLAGS 23086fc0178dSmrg linker: $LD (gnu? $with_gnu_ld) 2309515ec619Smrg version: $progname (GNU libtool) 2.4.7 23106fc0178dSmrg automake: `($AUTOMAKE --version) 2>/dev/null |$SED 1q` 23116fc0178dSmrg autoconf: `($AUTOCONF --version) 2>/dev/null |$SED 1q` 23126fc0178dSmrg 23136fc0178dSmrgReport bugs to <bug-libtool@gnu.org>. 2314515ec619SmrgGNU libtool home page: <http://www.gnu.org/software/libtool/>. 23156fc0178dSmrgGeneral help using GNU software: <http://www.gnu.org/gethelp/>." 23166fc0178dSmrg exit 0 23176fc0178dSmrg} 2318862f5301Smrg 2319862f5301Smrg 23206fc0178dSmrg# func_lo2o OBJECT-NAME 23216fc0178dSmrg# --------------------- 23226fc0178dSmrg# Transform OBJECT-NAME from a '.lo' suffix to the platform specific 23236fc0178dSmrg# object suffix. 23246fc0178dSmrg 23256fc0178dSmrglo2o=s/\\.lo\$/.$objext/ 23266fc0178dSmrgo2lo=s/\\.$objext\$/.lo/ 23276fc0178dSmrg 23286fc0178dSmrgif test yes = "$_G_HAVE_XSI_OPS"; then 23296fc0178dSmrg eval 'func_lo2o () 23306fc0178dSmrg { 23316fc0178dSmrg case $1 in 23326fc0178dSmrg *.lo) func_lo2o_result=${1%.lo}.$objext ;; 23336fc0178dSmrg * ) func_lo2o_result=$1 ;; 23346fc0178dSmrg esac 23356fc0178dSmrg }' 23366fc0178dSmrg 23376fc0178dSmrg # func_xform LIBOBJ-OR-SOURCE 23386fc0178dSmrg # --------------------------- 23396fc0178dSmrg # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise) 23406fc0178dSmrg # suffix to a '.lo' libtool-object suffix. 23416fc0178dSmrg eval 'func_xform () 23426fc0178dSmrg { 23436fc0178dSmrg func_xform_result=${1%.*}.lo 23446fc0178dSmrg }' 23456fc0178dSmrgelse 23466fc0178dSmrg # ...otherwise fall back to using sed. 23476fc0178dSmrg func_lo2o () 23486fc0178dSmrg { 23496fc0178dSmrg func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"` 23506fc0178dSmrg } 23516fc0178dSmrg 23526fc0178dSmrg func_xform () 23536fc0178dSmrg { 23546fc0178dSmrg func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'` 23556fc0178dSmrg } 23566fc0178dSmrgfi 2357862f5301Smrg 2358862f5301Smrg 23596fc0178dSmrg# func_fatal_configuration ARG... 23606fc0178dSmrg# ------------------------------- 23617a3b38f7Smrg# Echo program name prefixed message to standard error, followed by 23627a3b38f7Smrg# a configuration failure hint, and exit. 23637a3b38f7Smrgfunc_fatal_configuration () 23647a3b38f7Smrg{ 2365515ec619Smrg func_fatal_error ${1+"$@"} \ 23666fc0178dSmrg "See the $PACKAGE documentation for more information." \ 23676fc0178dSmrg "Fatal configuration error." 23687a3b38f7Smrg} 23697a3b38f7Smrg 23707a3b38f7Smrg 23717a3b38f7Smrg# func_config 23726fc0178dSmrg# ----------- 23737a3b38f7Smrg# Display the configuration for all the tags in this script. 23747a3b38f7Smrgfunc_config () 23757a3b38f7Smrg{ 23767a3b38f7Smrg re_begincf='^# ### BEGIN LIBTOOL' 23777a3b38f7Smrg re_endcf='^# ### END LIBTOOL' 23787a3b38f7Smrg 23797a3b38f7Smrg # Default configuration. 23807a3b38f7Smrg $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" 2381ff559fabSmrg 2382ff559fabSmrg # Now print the configurations for the tags. 2383ff559fabSmrg for tagname in $taglist; do 23847a3b38f7Smrg $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" 2385ff559fabSmrg done 2386ff559fabSmrg 23877a3b38f7Smrg exit $? 23887a3b38f7Smrg} 2389ff559fabSmrg 23906fc0178dSmrg 23917a3b38f7Smrg# func_features 23926fc0178dSmrg# ------------- 23937a3b38f7Smrg# Display the features supported by this script. 23947a3b38f7Smrgfunc_features () 23957a3b38f7Smrg{ 239644dda7b2Smrg echo "host: $host" 23976fc0178dSmrg if test yes = "$build_libtool_libs"; then 239844dda7b2Smrg echo "enable shared libraries" 2399ff559fabSmrg else 240044dda7b2Smrg echo "disable shared libraries" 2401ff559fabSmrg fi 24026fc0178dSmrg if test yes = "$build_old_libs"; then 240344dda7b2Smrg echo "enable static libraries" 2404ff559fabSmrg else 240544dda7b2Smrg echo "disable static libraries" 2406ff559fabSmrg fi 24077a3b38f7Smrg 2408ff559fabSmrg exit $? 24097a3b38f7Smrg} 24107a3b38f7Smrg 24116fc0178dSmrg 24126fc0178dSmrg# func_enable_tag TAGNAME 24136fc0178dSmrg# ----------------------- 24147a3b38f7Smrg# Verify that TAGNAME is valid, and either flag an error and exit, or 24157a3b38f7Smrg# enable the TAGNAME tag. We also add TAGNAME to the global $taglist 24167a3b38f7Smrg# variable here. 24177a3b38f7Smrgfunc_enable_tag () 24187a3b38f7Smrg{ 24196fc0178dSmrg # Global variable: 24206fc0178dSmrg tagname=$1 2421ff559fabSmrg 24226fc0178dSmrg re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" 24236fc0178dSmrg re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" 24246fc0178dSmrg sed_extractcf=/$re_begincf/,/$re_endcf/p 2425ff559fabSmrg 24266fc0178dSmrg # Validate tagname. 24276fc0178dSmrg case $tagname in 24286fc0178dSmrg *[!-_A-Za-z0-9,/]*) 24296fc0178dSmrg func_fatal_error "invalid tag name: $tagname" 24306fc0178dSmrg ;; 24316fc0178dSmrg esac 2432ff559fabSmrg 24336fc0178dSmrg # Don't test for the "default" C tag, as we know it's 24346fc0178dSmrg # there but not specially marked. 24356fc0178dSmrg case $tagname in 24366fc0178dSmrg CC) ;; 24377a3b38f7Smrg *) 24386fc0178dSmrg if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then 24396fc0178dSmrg taglist="$taglist $tagname" 24406fc0178dSmrg 24416fc0178dSmrg # Evaluate the configuration. Be careful to quote the path 24426fc0178dSmrg # and the sed script, to avoid splitting on whitespace, but 24436fc0178dSmrg # also don't use non-portable quotes within backquotes within 24446fc0178dSmrg # quotes we have to do it in 2 steps: 24456fc0178dSmrg extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` 24466fc0178dSmrg eval "$extractedcf" 24476fc0178dSmrg else 24486fc0178dSmrg func_error "ignoring unknown tag $tagname" 24496fc0178dSmrg fi 24506fc0178dSmrg ;; 24516fc0178dSmrg esac 24527a3b38f7Smrg} 2453ff559fabSmrg 24546fc0178dSmrg 2455862f5301Smrg# func_check_version_match 24566fc0178dSmrg# ------------------------ 2457862f5301Smrg# Ensure that we are using m4 macros, and libtool script from the same 2458862f5301Smrg# release of libtool. 2459862f5301Smrgfunc_check_version_match () 24607a3b38f7Smrg{ 24616fc0178dSmrg if test "$package_revision" != "$macro_revision"; then 24626fc0178dSmrg if test "$VERSION" != "$macro_version"; then 24636fc0178dSmrg if test -z "$macro_version"; then 24646fc0178dSmrg cat >&2 <<_LT_EOF 2465862f5301Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 2466862f5301Smrg$progname: definition of this LT_INIT comes from an older release. 2467862f5301Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 2468862f5301Smrg$progname: and run autoconf again. 2469862f5301Smrg_LT_EOF 24706fc0178dSmrg else 24716fc0178dSmrg cat >&2 <<_LT_EOF 2472862f5301Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 2473862f5301Smrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version. 2474862f5301Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 2475862f5301Smrg$progname: and run autoconf again. 2476862f5301Smrg_LT_EOF 24776fc0178dSmrg fi 24786fc0178dSmrg else 24796fc0178dSmrg cat >&2 <<_LT_EOF 2480862f5301Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, 2481862f5301Smrg$progname: but the definition of this LT_INIT comes from revision $macro_revision. 2482862f5301Smrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision 2483862f5301Smrg$progname: of $PACKAGE $VERSION and run autoconf again. 2484862f5301Smrg_LT_EOF 24856fc0178dSmrg fi 2486ff559fabSmrg 24876fc0178dSmrg exit $EXIT_MISMATCH 24886fc0178dSmrg fi 2489862f5301Smrg} 2490862f5301Smrg 2491862f5301Smrg 24926fc0178dSmrg# libtool_options_prep [ARG]... 24936fc0178dSmrg# ----------------------------- 24946fc0178dSmrg# Preparation for options parsed by libtool. 24956fc0178dSmrglibtool_options_prep () 24966fc0178dSmrg{ 24976fc0178dSmrg $debug_mode 2498ff559fabSmrg 24996fc0178dSmrg # Option defaults: 25006fc0178dSmrg opt_config=false 25016fc0178dSmrg opt_dlopen= 25026fc0178dSmrg opt_dry_run=false 25036fc0178dSmrg opt_help=false 25046fc0178dSmrg opt_mode= 25056fc0178dSmrg opt_preserve_dup_deps=false 25066fc0178dSmrg opt_quiet=false 2507862f5301Smrg 25086fc0178dSmrg nonopt= 25096fc0178dSmrg preserve_args= 2510862f5301Smrg 2511515ec619Smrg _G_rc_lt_options_prep=: 2512515ec619Smrg 25136fc0178dSmrg # Shorthand for --mode=foo, only valid as the first argument 25146fc0178dSmrg case $1 in 25156fc0178dSmrg clean|clea|cle|cl) 25166fc0178dSmrg shift; set dummy --mode clean ${1+"$@"}; shift 25176fc0178dSmrg ;; 25186fc0178dSmrg compile|compil|compi|comp|com|co|c) 25196fc0178dSmrg shift; set dummy --mode compile ${1+"$@"}; shift 25206fc0178dSmrg ;; 25216fc0178dSmrg execute|execut|execu|exec|exe|ex|e) 25226fc0178dSmrg shift; set dummy --mode execute ${1+"$@"}; shift 25236fc0178dSmrg ;; 25246fc0178dSmrg finish|finis|fini|fin|fi|f) 25256fc0178dSmrg shift; set dummy --mode finish ${1+"$@"}; shift 25266fc0178dSmrg ;; 25276fc0178dSmrg install|instal|insta|inst|ins|in|i) 25286fc0178dSmrg shift; set dummy --mode install ${1+"$@"}; shift 25296fc0178dSmrg ;; 25306fc0178dSmrg link|lin|li|l) 25316fc0178dSmrg shift; set dummy --mode link ${1+"$@"}; shift 25326fc0178dSmrg ;; 25336fc0178dSmrg uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) 25346fc0178dSmrg shift; set dummy --mode uninstall ${1+"$@"}; shift 25356fc0178dSmrg ;; 2536515ec619Smrg *) 2537515ec619Smrg _G_rc_lt_options_prep=false 2538515ec619Smrg ;; 25396fc0178dSmrg esac 25406fc0178dSmrg 2541515ec619Smrg if $_G_rc_lt_options_prep; then 2542515ec619Smrg # Pass back the list of options. 2543515ec619Smrg func_quote eval ${1+"$@"} 2544515ec619Smrg libtool_options_prep_result=$func_quote_result 2545515ec619Smrg fi 25466fc0178dSmrg} 25476fc0178dSmrgfunc_add_hook func_options_prep libtool_options_prep 2548862f5301Smrg 2549862f5301Smrg 25506fc0178dSmrg# libtool_parse_options [ARG]... 25516fc0178dSmrg# --------------------------------- 25526fc0178dSmrg# Provide handling for libtool specific options. 25536fc0178dSmrglibtool_parse_options () 2554862f5301Smrg{ 25556fc0178dSmrg $debug_cmd 25567a3b38f7Smrg 2557515ec619Smrg _G_rc_lt_parse_options=false 2558515ec619Smrg 25596fc0178dSmrg # Perform our own loop to consume as many options as possible in 25606fc0178dSmrg # each iteration. 25616fc0178dSmrg while test $# -gt 0; do 2562515ec619Smrg _G_match_lt_parse_options=: 25636fc0178dSmrg _G_opt=$1 25646fc0178dSmrg shift 25656fc0178dSmrg case $_G_opt in 25666fc0178dSmrg --dry-run|--dryrun|-n) 25676fc0178dSmrg opt_dry_run=: 25686fc0178dSmrg ;; 25696fc0178dSmrg 25706fc0178dSmrg --config) func_config ;; 25716fc0178dSmrg 25726fc0178dSmrg --dlopen|-dlopen) 25736fc0178dSmrg opt_dlopen="${opt_dlopen+$opt_dlopen 25746fc0178dSmrg}$1" 25756fc0178dSmrg shift 25766fc0178dSmrg ;; 25776fc0178dSmrg 25786fc0178dSmrg --preserve-dup-deps) 25796fc0178dSmrg opt_preserve_dup_deps=: ;; 25806fc0178dSmrg 25816fc0178dSmrg --features) func_features ;; 25826fc0178dSmrg 25836fc0178dSmrg --finish) set dummy --mode finish ${1+"$@"}; shift ;; 25846fc0178dSmrg 25856fc0178dSmrg --help) opt_help=: ;; 25866fc0178dSmrg 25876fc0178dSmrg --help-all) opt_help=': help-all' ;; 25886fc0178dSmrg 25896fc0178dSmrg --mode) test $# = 0 && func_missing_arg $_G_opt && break 25906fc0178dSmrg opt_mode=$1 25916fc0178dSmrg case $1 in 25926fc0178dSmrg # Valid mode arguments: 25936fc0178dSmrg clean|compile|execute|finish|install|link|relink|uninstall) ;; 25946fc0178dSmrg 25956fc0178dSmrg # Catch anything else as an error 25966fc0178dSmrg *) func_error "invalid argument for $_G_opt" 25976fc0178dSmrg exit_cmd=exit 25986fc0178dSmrg break 25996fc0178dSmrg ;; 26006fc0178dSmrg esac 26016fc0178dSmrg shift 26026fc0178dSmrg ;; 26036fc0178dSmrg 26046fc0178dSmrg --no-silent|--no-quiet) 26056fc0178dSmrg opt_quiet=false 26066fc0178dSmrg func_append preserve_args " $_G_opt" 26076fc0178dSmrg ;; 26086fc0178dSmrg 26096fc0178dSmrg --no-warnings|--no-warning|--no-warn) 26106fc0178dSmrg opt_warning=false 26116fc0178dSmrg func_append preserve_args " $_G_opt" 26126fc0178dSmrg ;; 26136fc0178dSmrg 26146fc0178dSmrg --no-verbose) 26156fc0178dSmrg opt_verbose=false 26166fc0178dSmrg func_append preserve_args " $_G_opt" 26176fc0178dSmrg ;; 26186fc0178dSmrg 26196fc0178dSmrg --silent|--quiet) 26206fc0178dSmrg opt_quiet=: 26216fc0178dSmrg opt_verbose=false 26226fc0178dSmrg func_append preserve_args " $_G_opt" 26236fc0178dSmrg ;; 26246fc0178dSmrg 26256fc0178dSmrg --tag) test $# = 0 && func_missing_arg $_G_opt && break 26266fc0178dSmrg opt_tag=$1 26276fc0178dSmrg func_append preserve_args " $_G_opt $1" 26286fc0178dSmrg func_enable_tag "$1" 26296fc0178dSmrg shift 26306fc0178dSmrg ;; 26316fc0178dSmrg 26326fc0178dSmrg --verbose|-v) opt_quiet=false 26336fc0178dSmrg opt_verbose=: 26346fc0178dSmrg func_append preserve_args " $_G_opt" 26356fc0178dSmrg ;; 26366fc0178dSmrg 2637515ec619Smrg # An option not handled by this hook function: 2638515ec619Smrg *) set dummy "$_G_opt" ${1+"$@"} ; shift 2639515ec619Smrg _G_match_lt_parse_options=false 2640515ec619Smrg break 2641515ec619Smrg ;; 26426fc0178dSmrg esac 2643515ec619Smrg $_G_match_lt_parse_options && _G_rc_lt_parse_options=: 26446fc0178dSmrg done 2645862f5301Smrg 2646515ec619Smrg if $_G_rc_lt_parse_options; then 2647515ec619Smrg # save modified positional parameters for caller 2648515ec619Smrg func_quote eval ${1+"$@"} 2649515ec619Smrg libtool_parse_options_result=$func_quote_result 2650515ec619Smrg fi 26516fc0178dSmrg} 26526fc0178dSmrgfunc_add_hook func_parse_options libtool_parse_options 26537a3b38f7Smrg 2654ff559fabSmrg 26557a3b38f7Smrg 26566fc0178dSmrg# libtool_validate_options [ARG]... 26576fc0178dSmrg# --------------------------------- 26586fc0178dSmrg# Perform any sanity checks on option settings and/or unconsumed 26596fc0178dSmrg# arguments. 26606fc0178dSmrglibtool_validate_options () 26616fc0178dSmrg{ 26626fc0178dSmrg # save first non-option argument 26636fc0178dSmrg if test 0 -lt $#; then 26646fc0178dSmrg nonopt=$1 26656fc0178dSmrg shift 26667a3b38f7Smrg fi 26677a3b38f7Smrg 26686fc0178dSmrg # preserve --debug 26696fc0178dSmrg test : = "$debug_cmd" || func_append preserve_args " --debug" 26707a3b38f7Smrg 26716fc0178dSmrg case $host in 26726fc0178dSmrg # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452 26736fc0178dSmrg # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788 26746fc0178dSmrg *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*) 26756fc0178dSmrg # don't eliminate duplications in $postdeps and $predeps 26766fc0178dSmrg opt_duplicate_compiler_generated_deps=: 26776fc0178dSmrg ;; 26786fc0178dSmrg *) 26796fc0178dSmrg opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps 26806fc0178dSmrg ;; 26816fc0178dSmrg esac 26827a3b38f7Smrg 26836fc0178dSmrg $opt_help || { 26846fc0178dSmrg # Sanity checks first: 26856fc0178dSmrg func_check_version_match 26866fc0178dSmrg 26876fc0178dSmrg test yes != "$build_libtool_libs" \ 26886fc0178dSmrg && test yes != "$build_old_libs" \ 26896fc0178dSmrg && func_fatal_configuration "not configured to build any kind of library" 26906fc0178dSmrg 26916fc0178dSmrg # Darwin sucks 26926fc0178dSmrg eval std_shrext=\"$shrext_cmds\" 26936fc0178dSmrg 26946fc0178dSmrg # Only execute mode is allowed to have -dlopen flags. 26956fc0178dSmrg if test -n "$opt_dlopen" && test execute != "$opt_mode"; then 26966fc0178dSmrg func_error "unrecognized option '-dlopen'" 26976fc0178dSmrg $ECHO "$help" 1>&2 26986fc0178dSmrg exit $EXIT_FAILURE 26996fc0178dSmrg fi 27007a3b38f7Smrg 27016fc0178dSmrg # Change the help message to a mode-specific one. 27026fc0178dSmrg generic_help=$help 27036fc0178dSmrg help="Try '$progname --help --mode=$opt_mode' for more information." 27046fc0178dSmrg } 27057a3b38f7Smrg 27066fc0178dSmrg # Pass back the unparsed argument list 2707515ec619Smrg func_quote eval ${1+"$@"} 2708515ec619Smrg libtool_validate_options_result=$func_quote_result 2709862f5301Smrg} 27106fc0178dSmrgfunc_add_hook func_validate_options libtool_validate_options 27117a3b38f7Smrg 27127a3b38f7Smrg 27136fc0178dSmrg# Process options as early as possible so that --help and --version 27146fc0178dSmrg# can return quickly. 27156fc0178dSmrgfunc_options ${1+"$@"} 27166fc0178dSmrgeval set dummy "$func_options_result"; shift 27176fc0178dSmrg 2718ff559fabSmrg 2719ff559fabSmrg 2720862f5301Smrg## ----------- ## 2721862f5301Smrg## Main. ## 2722862f5301Smrg## ----------- ## 2723ff559fabSmrg 27246fc0178dSmrgmagic='%%%MAGIC variable%%%' 27256fc0178dSmrgmagic_exe='%%%MAGIC EXE variable%%%' 27266fc0178dSmrg 27276fc0178dSmrg# Global variables. 27286fc0178dSmrgextracted_archives= 27296fc0178dSmrgextracted_serial=0 27306fc0178dSmrg 27316fc0178dSmrg# If this variable is set in any of the actions, the command in it 27326fc0178dSmrg# will be execed at the end. This prevents here-documents from being 27336fc0178dSmrg# left over by shells. 27346fc0178dSmrgexec_cmd= 27356fc0178dSmrg 27366fc0178dSmrg 27376fc0178dSmrg# A function that is used when there is no print builtin or printf. 27386fc0178dSmrgfunc_fallback_echo () 27396fc0178dSmrg{ 27406fc0178dSmrg eval 'cat <<_LTECHO_EOF 27416fc0178dSmrg$1 27426fc0178dSmrg_LTECHO_EOF' 27436fc0178dSmrg} 27446fc0178dSmrg 27456fc0178dSmrg# func_generated_by_libtool 27466fc0178dSmrg# True iff stdin has been generated by Libtool. This function is only 27476fc0178dSmrg# a basic sanity check; it will hardly flush out determined imposters. 27486fc0178dSmrgfunc_generated_by_libtool_p () 27496fc0178dSmrg{ 27506fc0178dSmrg $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 27516fc0178dSmrg} 27526fc0178dSmrg 27537a3b38f7Smrg# func_lalib_p file 27546fc0178dSmrg# True iff FILE is a libtool '.la' library or '.lo' object file. 27557a3b38f7Smrg# This function is only a basic sanity check; it will hardly flush out 27567a3b38f7Smrg# determined imposters. 27577a3b38f7Smrgfunc_lalib_p () 27587a3b38f7Smrg{ 27597a3b38f7Smrg test -f "$1" && 27606fc0178dSmrg $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p 27617a3b38f7Smrg} 2762ff559fabSmrg 27637a3b38f7Smrg# func_lalib_unsafe_p file 27646fc0178dSmrg# True iff FILE is a libtool '.la' library or '.lo' object file. 27657a3b38f7Smrg# This function implements the same check as func_lalib_p without 27667a3b38f7Smrg# resorting to external programs. To this end, it redirects stdin and 27677a3b38f7Smrg# closes it afterwards, without saving the original file descriptor. 27687a3b38f7Smrg# As a safety measure, use it only where a negative result would be 27696fc0178dSmrg# fatal anyway. Works if 'file' does not exist. 27707a3b38f7Smrgfunc_lalib_unsafe_p () 27717a3b38f7Smrg{ 27727a3b38f7Smrg lalib_p=no 27737a3b38f7Smrg if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then 27747a3b38f7Smrg for lalib_p_l in 1 2 3 4 27757a3b38f7Smrg do 27767a3b38f7Smrg read lalib_p_line 27776fc0178dSmrg case $lalib_p_line in 27787a3b38f7Smrg \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; 27797a3b38f7Smrg esac 27807a3b38f7Smrg done 27817a3b38f7Smrg exec 0<&5 5<&- 27827a3b38f7Smrg fi 27836fc0178dSmrg test yes = "$lalib_p" 27847a3b38f7Smrg} 2785ff559fabSmrg 27867a3b38f7Smrg# func_ltwrapper_script_p file 27877a3b38f7Smrg# True iff FILE is a libtool wrapper script 27887a3b38f7Smrg# This function is only a basic sanity check; it will hardly flush out 27897a3b38f7Smrg# determined imposters. 27907a3b38f7Smrgfunc_ltwrapper_script_p () 27917a3b38f7Smrg{ 27926fc0178dSmrg test -f "$1" && 27936fc0178dSmrg $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p 27947a3b38f7Smrg} 2795ff559fabSmrg 27967a3b38f7Smrg# func_ltwrapper_executable_p file 27977a3b38f7Smrg# True iff FILE is a libtool wrapper executable 27987a3b38f7Smrg# This function is only a basic sanity check; it will hardly flush out 27997a3b38f7Smrg# determined imposters. 28007a3b38f7Smrgfunc_ltwrapper_executable_p () 28017a3b38f7Smrg{ 28027a3b38f7Smrg func_ltwrapper_exec_suffix= 28037a3b38f7Smrg case $1 in 28047a3b38f7Smrg *.exe) ;; 28057a3b38f7Smrg *) func_ltwrapper_exec_suffix=.exe ;; 28067a3b38f7Smrg esac 28077a3b38f7Smrg $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 28087a3b38f7Smrg} 2809ff559fabSmrg 28107a3b38f7Smrg# func_ltwrapper_scriptname file 28117a3b38f7Smrg# Assumes file is an ltwrapper_executable 28127a3b38f7Smrg# uses $file to determine the appropriate filename for a 28137a3b38f7Smrg# temporary ltwrapper_script. 28147a3b38f7Smrgfunc_ltwrapper_scriptname () 28157a3b38f7Smrg{ 2816862f5301Smrg func_dirname_and_basename "$1" "" "." 2817862f5301Smrg func_stripname '' '.exe' "$func_basename_result" 28186fc0178dSmrg func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper 28197a3b38f7Smrg} 2820ff559fabSmrg 28217a3b38f7Smrg# func_ltwrapper_p file 28227a3b38f7Smrg# True iff FILE is a libtool wrapper script or wrapper executable 28237a3b38f7Smrg# This function is only a basic sanity check; it will hardly flush out 28247a3b38f7Smrg# determined imposters. 28257a3b38f7Smrgfunc_ltwrapper_p () 28267a3b38f7Smrg{ 28277a3b38f7Smrg func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" 28287a3b38f7Smrg} 2829ff559fabSmrg 2830ff559fabSmrg 28317a3b38f7Smrg# func_execute_cmds commands fail_cmd 28327a3b38f7Smrg# Execute tilde-delimited COMMANDS. 28337a3b38f7Smrg# If FAIL_CMD is given, eval that upon failure. 28347a3b38f7Smrg# FAIL_CMD may read-access the current command in variable CMD! 28357a3b38f7Smrgfunc_execute_cmds () 28367a3b38f7Smrg{ 28376fc0178dSmrg $debug_cmd 28386fc0178dSmrg 28397a3b38f7Smrg save_ifs=$IFS; IFS='~' 28407a3b38f7Smrg for cmd in $1; do 28416fc0178dSmrg IFS=$sp$nl 28427a3b38f7Smrg eval cmd=\"$cmd\" 28436fc0178dSmrg IFS=$save_ifs 28447a3b38f7Smrg func_show_eval "$cmd" "${2-:}" 28457a3b38f7Smrg done 28467a3b38f7Smrg IFS=$save_ifs 28477a3b38f7Smrg} 28487a3b38f7Smrg 28497a3b38f7Smrg 28507a3b38f7Smrg# func_source file 28517a3b38f7Smrg# Source FILE, adding directory component if necessary. 28527a3b38f7Smrg# Note that it is not necessary on cygwin/mingw to append a dot to 28537a3b38f7Smrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe 28547a3b38f7Smrg# behavior happens only for exec(3), not for open(2)! Also, sourcing 28556fc0178dSmrg# 'FILE.' does not work on cygwin managed mounts. 28567a3b38f7Smrgfunc_source () 28577a3b38f7Smrg{ 28586fc0178dSmrg $debug_cmd 28596fc0178dSmrg 28607a3b38f7Smrg case $1 in 28617a3b38f7Smrg */* | *\\*) . "$1" ;; 28627a3b38f7Smrg *) . "./$1" ;; 28637a3b38f7Smrg esac 28647a3b38f7Smrg} 28657a3b38f7Smrg 28667a3b38f7Smrg 2867862f5301Smrg# func_resolve_sysroot PATH 2868862f5301Smrg# Replace a leading = in PATH with a sysroot. Store the result into 2869862f5301Smrg# func_resolve_sysroot_result 2870862f5301Smrgfunc_resolve_sysroot () 2871862f5301Smrg{ 2872862f5301Smrg func_resolve_sysroot_result=$1 2873862f5301Smrg case $func_resolve_sysroot_result in 2874862f5301Smrg =*) 2875862f5301Smrg func_stripname '=' '' "$func_resolve_sysroot_result" 2876862f5301Smrg func_resolve_sysroot_result=$lt_sysroot$func_stripname_result 2877862f5301Smrg ;; 2878862f5301Smrg esac 2879862f5301Smrg} 2880862f5301Smrg 2881862f5301Smrg# func_replace_sysroot PATH 2882862f5301Smrg# If PATH begins with the sysroot, replace it with = and 2883862f5301Smrg# store the result into func_replace_sysroot_result. 2884862f5301Smrgfunc_replace_sysroot () 2885862f5301Smrg{ 28866fc0178dSmrg case $lt_sysroot:$1 in 2887862f5301Smrg ?*:"$lt_sysroot"*) 2888862f5301Smrg func_stripname "$lt_sysroot" '' "$1" 28896fc0178dSmrg func_replace_sysroot_result='='$func_stripname_result 2890862f5301Smrg ;; 2891862f5301Smrg *) 2892862f5301Smrg # Including no sysroot. 2893862f5301Smrg func_replace_sysroot_result=$1 2894862f5301Smrg ;; 2895862f5301Smrg esac 2896862f5301Smrg} 2897862f5301Smrg 28987a3b38f7Smrg# func_infer_tag arg 28997a3b38f7Smrg# Infer tagged configuration to use if any are available and 29007a3b38f7Smrg# if one wasn't chosen via the "--tag" command line option. 29017a3b38f7Smrg# Only attempt this if the compiler in the base compile 29027a3b38f7Smrg# command doesn't match the default compiler. 29037a3b38f7Smrg# arg is usually of the form 'gcc ...' 29047a3b38f7Smrgfunc_infer_tag () 29057a3b38f7Smrg{ 29066fc0178dSmrg $debug_cmd 29076fc0178dSmrg 29087a3b38f7Smrg if test -n "$available_tags" && test -z "$tagname"; then 29097a3b38f7Smrg CC_quoted= 29107a3b38f7Smrg for arg in $CC; do 2911862f5301Smrg func_append_quoted CC_quoted "$arg" 29127a3b38f7Smrg done 291344dda7b2Smrg CC_expanded=`func_echo_all $CC` 291444dda7b2Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 29157a3b38f7Smrg case $@ in 29167a3b38f7Smrg # Blanks in the command may have been stripped by the calling shell, 29177a3b38f7Smrg # but not from the CC environment variable when configure was run. 291844dda7b2Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 291944dda7b2Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; 29207a3b38f7Smrg # Blanks at the start of $base_compile will cause this to fail 29217a3b38f7Smrg # if we don't check for them as well. 29227a3b38f7Smrg *) 29237a3b38f7Smrg for z in $available_tags; do 29247a3b38f7Smrg if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then 29257a3b38f7Smrg # Evaluate the configuration. 29266fc0178dSmrg eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" 29277a3b38f7Smrg CC_quoted= 29287a3b38f7Smrg for arg in $CC; do 29297a3b38f7Smrg # Double-quote args containing other shell metacharacters. 2930862f5301Smrg func_append_quoted CC_quoted "$arg" 29317a3b38f7Smrg done 293244dda7b2Smrg CC_expanded=`func_echo_all $CC` 293344dda7b2Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 29347a3b38f7Smrg case "$@ " in 293544dda7b2Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 293644dda7b2Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) 29377a3b38f7Smrg # The compiler in the base compile command matches 29387a3b38f7Smrg # the one in the tagged configuration. 29397a3b38f7Smrg # Assume this is the tagged configuration we want. 29407a3b38f7Smrg tagname=$z 29417a3b38f7Smrg break 29427a3b38f7Smrg ;; 2943ff559fabSmrg esac 29447a3b38f7Smrg fi 29457a3b38f7Smrg done 29467a3b38f7Smrg # If $tagname still isn't set, then no tagged configuration 29477a3b38f7Smrg # was found and let the user know that the "--tag" command 29487a3b38f7Smrg # line option must be used. 29497a3b38f7Smrg if test -z "$tagname"; then 29507a3b38f7Smrg func_echo "unable to infer tagged configuration" 29516fc0178dSmrg func_fatal_error "specify a tag with '--tag'" 29527a3b38f7Smrg# else 29537a3b38f7Smrg# func_verbose "using $tagname tagged configuration" 29547a3b38f7Smrg fi 29557a3b38f7Smrg ;; 29567a3b38f7Smrg esac 29577a3b38f7Smrg fi 29587a3b38f7Smrg} 29597a3b38f7Smrg 29607a3b38f7Smrg 29617a3b38f7Smrg 2962862f5301Smrg# func_write_libtool_object output_name pic_name nonpic_name 2963862f5301Smrg# Create a libtool object file (analogous to a ".la" file), 2964862f5301Smrg# but don't create it if we're doing a dry run. 2965862f5301Smrgfunc_write_libtool_object () 2966862f5301Smrg{ 29676fc0178dSmrg write_libobj=$1 29686fc0178dSmrg if test yes = "$build_libtool_libs"; then 29696fc0178dSmrg write_lobj=\'$2\' 2970862f5301Smrg else 2971862f5301Smrg write_lobj=none 2972862f5301Smrg fi 2973862f5301Smrg 29746fc0178dSmrg if test yes = "$build_old_libs"; then 29756fc0178dSmrg write_oldobj=\'$3\' 2976862f5301Smrg else 2977862f5301Smrg write_oldobj=none 2978862f5301Smrg fi 2979862f5301Smrg 2980862f5301Smrg $opt_dry_run || { 2981862f5301Smrg cat >${write_libobj}T <<EOF 2982862f5301Smrg# $write_libobj - a libtool object file 29836fc0178dSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 2984862f5301Smrg# 2985862f5301Smrg# Please DO NOT delete this file! 2986862f5301Smrg# It is necessary for linking the library. 2987862f5301Smrg 2988862f5301Smrg# Name of the PIC object. 2989862f5301Smrgpic_object=$write_lobj 2990862f5301Smrg 2991862f5301Smrg# Name of the non-PIC object 2992862f5301Smrgnon_pic_object=$write_oldobj 2993862f5301Smrg 2994862f5301SmrgEOF 29956fc0178dSmrg $MV "${write_libobj}T" "$write_libobj" 2996862f5301Smrg } 2997862f5301Smrg} 2998862f5301Smrg 2999862f5301Smrg 3000862f5301Smrg################################################## 3001862f5301Smrg# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS # 3002862f5301Smrg################################################## 3003862f5301Smrg 3004862f5301Smrg# func_convert_core_file_wine_to_w32 ARG 3005862f5301Smrg# Helper function used by file name conversion functions when $build is *nix, 3006862f5301Smrg# and $host is mingw, cygwin, or some other w32 environment. Relies on a 3007862f5301Smrg# correctly configured wine environment available, with the winepath program 3008862f5301Smrg# in $build's $PATH. 3009862f5301Smrg# 3010862f5301Smrg# ARG is the $build file name to be converted to w32 format. 3011862f5301Smrg# Result is available in $func_convert_core_file_wine_to_w32_result, and will 3012862f5301Smrg# be empty on error (or when ARG is empty) 3013862f5301Smrgfunc_convert_core_file_wine_to_w32 () 3014862f5301Smrg{ 30156fc0178dSmrg $debug_cmd 30166fc0178dSmrg 30176fc0178dSmrg func_convert_core_file_wine_to_w32_result=$1 3018862f5301Smrg if test -n "$1"; then 3019862f5301Smrg # Unfortunately, winepath does not exit with a non-zero error code, so we 3020862f5301Smrg # are forced to check the contents of stdout. On the other hand, if the 3021862f5301Smrg # command is not found, the shell will set an exit code of 127 and print 3022862f5301Smrg # *an error message* to stdout. So we must check for both error code of 3023862f5301Smrg # zero AND non-empty stdout, which explains the odd construction: 3024862f5301Smrg func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null` 30256fc0178dSmrg if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then 3026862f5301Smrg func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | 30276fc0178dSmrg $SED -e "$sed_naive_backslashify"` 3028862f5301Smrg else 3029862f5301Smrg func_convert_core_file_wine_to_w32_result= 3030862f5301Smrg fi 3031862f5301Smrg fi 3032862f5301Smrg} 3033862f5301Smrg# end: func_convert_core_file_wine_to_w32 3034862f5301Smrg 3035862f5301Smrg 3036862f5301Smrg# func_convert_core_path_wine_to_w32 ARG 3037862f5301Smrg# Helper function used by path conversion functions when $build is *nix, and 3038862f5301Smrg# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly 3039862f5301Smrg# configured wine environment available, with the winepath program in $build's 3040862f5301Smrg# $PATH. Assumes ARG has no leading or trailing path separator characters. 3041862f5301Smrg# 3042862f5301Smrg# ARG is path to be converted from $build format to win32. 3043862f5301Smrg# Result is available in $func_convert_core_path_wine_to_w32_result. 3044862f5301Smrg# Unconvertible file (directory) names in ARG are skipped; if no directory names 3045862f5301Smrg# are convertible, then the result may be empty. 3046862f5301Smrgfunc_convert_core_path_wine_to_w32 () 3047862f5301Smrg{ 30486fc0178dSmrg $debug_cmd 30496fc0178dSmrg 3050862f5301Smrg # unfortunately, winepath doesn't convert paths, only file names 30516fc0178dSmrg func_convert_core_path_wine_to_w32_result= 3052862f5301Smrg if test -n "$1"; then 3053862f5301Smrg oldIFS=$IFS 3054862f5301Smrg IFS=: 3055862f5301Smrg for func_convert_core_path_wine_to_w32_f in $1; do 3056862f5301Smrg IFS=$oldIFS 3057862f5301Smrg func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" 30586fc0178dSmrg if test -n "$func_convert_core_file_wine_to_w32_result"; then 3059862f5301Smrg if test -z "$func_convert_core_path_wine_to_w32_result"; then 30606fc0178dSmrg func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result 3061862f5301Smrg else 3062862f5301Smrg func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" 3063862f5301Smrg fi 3064862f5301Smrg fi 3065862f5301Smrg done 3066862f5301Smrg IFS=$oldIFS 3067862f5301Smrg fi 3068862f5301Smrg} 3069862f5301Smrg# end: func_convert_core_path_wine_to_w32 3070862f5301Smrg 3071862f5301Smrg 3072862f5301Smrg# func_cygpath ARGS... 3073862f5301Smrg# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when 3074862f5301Smrg# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) 3075862f5301Smrg# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or 3076862f5301Smrg# (2), returns the Cygwin file name or path in func_cygpath_result (input 3077862f5301Smrg# file name or path is assumed to be in w32 format, as previously converted 3078862f5301Smrg# from $build's *nix or MSYS format). In case (3), returns the w32 file name 3079862f5301Smrg# or path in func_cygpath_result (input file name or path is assumed to be in 3080862f5301Smrg# Cygwin format). Returns an empty string on error. 3081862f5301Smrg# 3082862f5301Smrg# ARGS are passed to cygpath, with the last one being the file name or path to 3083862f5301Smrg# be converted. 3084862f5301Smrg# 3085862f5301Smrg# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH 3086862f5301Smrg# environment variable; do not put it in $PATH. 3087862f5301Smrgfunc_cygpath () 3088862f5301Smrg{ 30896fc0178dSmrg $debug_cmd 30906fc0178dSmrg 3091862f5301Smrg if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then 3092862f5301Smrg func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` 3093862f5301Smrg if test "$?" -ne 0; then 3094862f5301Smrg # on failure, ensure result is empty 3095862f5301Smrg func_cygpath_result= 3096862f5301Smrg fi 3097862f5301Smrg else 3098862f5301Smrg func_cygpath_result= 30996fc0178dSmrg func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'" 3100862f5301Smrg fi 3101862f5301Smrg} 3102862f5301Smrg#end: func_cygpath 3103862f5301Smrg 3104862f5301Smrg 3105862f5301Smrg# func_convert_core_msys_to_w32 ARG 3106862f5301Smrg# Convert file name or path ARG from MSYS format to w32 format. Return 3107862f5301Smrg# result in func_convert_core_msys_to_w32_result. 3108862f5301Smrgfunc_convert_core_msys_to_w32 () 3109862f5301Smrg{ 31106fc0178dSmrg $debug_cmd 31116fc0178dSmrg 3112862f5301Smrg # awkward: cmd appends spaces to result 3113862f5301Smrg func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | 31146fc0178dSmrg $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"` 3115862f5301Smrg} 3116862f5301Smrg#end: func_convert_core_msys_to_w32 3117862f5301Smrg 3118862f5301Smrg 3119862f5301Smrg# func_convert_file_check ARG1 ARG2 3120862f5301Smrg# Verify that ARG1 (a file name in $build format) was converted to $host 3121862f5301Smrg# format in ARG2. Otherwise, emit an error message, but continue (resetting 3122862f5301Smrg# func_to_host_file_result to ARG1). 3123862f5301Smrgfunc_convert_file_check () 3124862f5301Smrg{ 31256fc0178dSmrg $debug_cmd 31266fc0178dSmrg 31276fc0178dSmrg if test -z "$2" && test -n "$1"; then 3128862f5301Smrg func_error "Could not determine host file name corresponding to" 31296fc0178dSmrg func_error " '$1'" 3130862f5301Smrg func_error "Continuing, but uninstalled executables may not work." 3131862f5301Smrg # Fallback: 31326fc0178dSmrg func_to_host_file_result=$1 3133862f5301Smrg fi 3134862f5301Smrg} 3135862f5301Smrg# end func_convert_file_check 3136862f5301Smrg 3137862f5301Smrg 3138862f5301Smrg# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH 3139862f5301Smrg# Verify that FROM_PATH (a path in $build format) was converted to $host 3140862f5301Smrg# format in TO_PATH. Otherwise, emit an error message, but continue, resetting 3141862f5301Smrg# func_to_host_file_result to a simplistic fallback value (see below). 3142862f5301Smrgfunc_convert_path_check () 3143862f5301Smrg{ 31446fc0178dSmrg $debug_cmd 31456fc0178dSmrg 3146862f5301Smrg if test -z "$4" && test -n "$3"; then 3147862f5301Smrg func_error "Could not determine the host path corresponding to" 31486fc0178dSmrg func_error " '$3'" 3149862f5301Smrg func_error "Continuing, but uninstalled executables may not work." 3150862f5301Smrg # Fallback. This is a deliberately simplistic "conversion" and 3151862f5301Smrg # should not be "improved". See libtool.info. 3152862f5301Smrg if test "x$1" != "x$2"; then 3153862f5301Smrg lt_replace_pathsep_chars="s|$1|$2|g" 3154862f5301Smrg func_to_host_path_result=`echo "$3" | 3155862f5301Smrg $SED -e "$lt_replace_pathsep_chars"` 3156862f5301Smrg else 31576fc0178dSmrg func_to_host_path_result=$3 3158862f5301Smrg fi 3159862f5301Smrg fi 3160862f5301Smrg} 3161862f5301Smrg# end func_convert_path_check 3162862f5301Smrg 3163862f5301Smrg 3164862f5301Smrg# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG 3165862f5301Smrg# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT 3166862f5301Smrg# and appending REPL if ORIG matches BACKPAT. 3167862f5301Smrgfunc_convert_path_front_back_pathsep () 3168862f5301Smrg{ 31696fc0178dSmrg $debug_cmd 31706fc0178dSmrg 3171862f5301Smrg case $4 in 31726fc0178dSmrg $1 ) func_to_host_path_result=$3$func_to_host_path_result 3173862f5301Smrg ;; 3174862f5301Smrg esac 3175862f5301Smrg case $4 in 3176862f5301Smrg $2 ) func_append func_to_host_path_result "$3" 3177862f5301Smrg ;; 3178862f5301Smrg esac 3179862f5301Smrg} 3180862f5301Smrg# end func_convert_path_front_back_pathsep 3181862f5301Smrg 3182862f5301Smrg 3183862f5301Smrg################################################## 3184862f5301Smrg# $build to $host FILE NAME CONVERSION FUNCTIONS # 3185862f5301Smrg################################################## 31866fc0178dSmrg# invoked via '$to_host_file_cmd ARG' 3187862f5301Smrg# 3188862f5301Smrg# In each case, ARG is the path to be converted from $build to $host format. 3189862f5301Smrg# Result will be available in $func_to_host_file_result. 3190862f5301Smrg 3191862f5301Smrg 3192862f5301Smrg# func_to_host_file ARG 3193862f5301Smrg# Converts the file name ARG from $build format to $host format. Return result 3194862f5301Smrg# in func_to_host_file_result. 3195862f5301Smrgfunc_to_host_file () 3196862f5301Smrg{ 31976fc0178dSmrg $debug_cmd 31986fc0178dSmrg 3199862f5301Smrg $to_host_file_cmd "$1" 3200862f5301Smrg} 3201862f5301Smrg# end func_to_host_file 3202862f5301Smrg 3203862f5301Smrg 3204862f5301Smrg# func_to_tool_file ARG LAZY 3205862f5301Smrg# converts the file name ARG from $build format to toolchain format. Return 3206862f5301Smrg# result in func_to_tool_file_result. If the conversion in use is listed 3207862f5301Smrg# in (the comma separated) LAZY, no conversion takes place. 3208862f5301Smrgfunc_to_tool_file () 3209862f5301Smrg{ 32106fc0178dSmrg $debug_cmd 32116fc0178dSmrg 3212862f5301Smrg case ,$2, in 3213862f5301Smrg *,"$to_tool_file_cmd",*) 3214862f5301Smrg func_to_tool_file_result=$1 3215862f5301Smrg ;; 3216862f5301Smrg *) 3217862f5301Smrg $to_tool_file_cmd "$1" 3218862f5301Smrg func_to_tool_file_result=$func_to_host_file_result 3219862f5301Smrg ;; 3220862f5301Smrg esac 3221862f5301Smrg} 3222862f5301Smrg# end func_to_tool_file 3223862f5301Smrg 3224862f5301Smrg 3225862f5301Smrg# func_convert_file_noop ARG 3226862f5301Smrg# Copy ARG to func_to_host_file_result. 3227862f5301Smrgfunc_convert_file_noop () 3228862f5301Smrg{ 32296fc0178dSmrg func_to_host_file_result=$1 3230862f5301Smrg} 3231862f5301Smrg# end func_convert_file_noop 3232862f5301Smrg 3233862f5301Smrg 3234862f5301Smrg# func_convert_file_msys_to_w32 ARG 3235862f5301Smrg# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic 3236862f5301Smrg# conversion to w32 is not available inside the cwrapper. Returns result in 3237862f5301Smrg# func_to_host_file_result. 3238862f5301Smrgfunc_convert_file_msys_to_w32 () 3239862f5301Smrg{ 32406fc0178dSmrg $debug_cmd 32416fc0178dSmrg 32426fc0178dSmrg func_to_host_file_result=$1 3243862f5301Smrg if test -n "$1"; then 3244862f5301Smrg func_convert_core_msys_to_w32 "$1" 32456fc0178dSmrg func_to_host_file_result=$func_convert_core_msys_to_w32_result 3246862f5301Smrg fi 3247862f5301Smrg func_convert_file_check "$1" "$func_to_host_file_result" 3248862f5301Smrg} 3249862f5301Smrg# end func_convert_file_msys_to_w32 3250862f5301Smrg 3251862f5301Smrg 3252862f5301Smrg# func_convert_file_cygwin_to_w32 ARG 3253862f5301Smrg# Convert file name ARG from Cygwin to w32 format. Returns result in 3254862f5301Smrg# func_to_host_file_result. 3255862f5301Smrgfunc_convert_file_cygwin_to_w32 () 3256862f5301Smrg{ 32576fc0178dSmrg $debug_cmd 32586fc0178dSmrg 32596fc0178dSmrg func_to_host_file_result=$1 3260862f5301Smrg if test -n "$1"; then 3261862f5301Smrg # because $build is cygwin, we call "the" cygpath in $PATH; no need to use 3262862f5301Smrg # LT_CYGPATH in this case. 3263862f5301Smrg func_to_host_file_result=`cygpath -m "$1"` 3264862f5301Smrg fi 3265862f5301Smrg func_convert_file_check "$1" "$func_to_host_file_result" 3266862f5301Smrg} 3267862f5301Smrg# end func_convert_file_cygwin_to_w32 3268862f5301Smrg 3269862f5301Smrg 3270862f5301Smrg# func_convert_file_nix_to_w32 ARG 3271862f5301Smrg# Convert file name ARG from *nix to w32 format. Requires a wine environment 3272862f5301Smrg# and a working winepath. Returns result in func_to_host_file_result. 3273862f5301Smrgfunc_convert_file_nix_to_w32 () 3274862f5301Smrg{ 32756fc0178dSmrg $debug_cmd 32766fc0178dSmrg 32776fc0178dSmrg func_to_host_file_result=$1 3278862f5301Smrg if test -n "$1"; then 3279862f5301Smrg func_convert_core_file_wine_to_w32 "$1" 32806fc0178dSmrg func_to_host_file_result=$func_convert_core_file_wine_to_w32_result 3281862f5301Smrg fi 3282862f5301Smrg func_convert_file_check "$1" "$func_to_host_file_result" 3283862f5301Smrg} 3284862f5301Smrg# end func_convert_file_nix_to_w32 3285862f5301Smrg 3286862f5301Smrg 3287862f5301Smrg# func_convert_file_msys_to_cygwin ARG 3288862f5301Smrg# Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 3289862f5301Smrg# Returns result in func_to_host_file_result. 3290862f5301Smrgfunc_convert_file_msys_to_cygwin () 3291862f5301Smrg{ 32926fc0178dSmrg $debug_cmd 32936fc0178dSmrg 32946fc0178dSmrg func_to_host_file_result=$1 3295862f5301Smrg if test -n "$1"; then 3296862f5301Smrg func_convert_core_msys_to_w32 "$1" 3297862f5301Smrg func_cygpath -u "$func_convert_core_msys_to_w32_result" 32986fc0178dSmrg func_to_host_file_result=$func_cygpath_result 3299862f5301Smrg fi 3300862f5301Smrg func_convert_file_check "$1" "$func_to_host_file_result" 3301862f5301Smrg} 3302862f5301Smrg# end func_convert_file_msys_to_cygwin 3303862f5301Smrg 3304862f5301Smrg 3305862f5301Smrg# func_convert_file_nix_to_cygwin ARG 3306862f5301Smrg# Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed 3307862f5301Smrg# in a wine environment, working winepath, and LT_CYGPATH set. Returns result 3308862f5301Smrg# in func_to_host_file_result. 3309862f5301Smrgfunc_convert_file_nix_to_cygwin () 3310862f5301Smrg{ 33116fc0178dSmrg $debug_cmd 33126fc0178dSmrg 33136fc0178dSmrg func_to_host_file_result=$1 3314862f5301Smrg if test -n "$1"; then 3315862f5301Smrg # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. 3316862f5301Smrg func_convert_core_file_wine_to_w32 "$1" 3317862f5301Smrg func_cygpath -u "$func_convert_core_file_wine_to_w32_result" 33186fc0178dSmrg func_to_host_file_result=$func_cygpath_result 3319862f5301Smrg fi 3320862f5301Smrg func_convert_file_check "$1" "$func_to_host_file_result" 3321862f5301Smrg} 3322862f5301Smrg# end func_convert_file_nix_to_cygwin 3323862f5301Smrg 3324862f5301Smrg 3325862f5301Smrg############################################# 3326862f5301Smrg# $build to $host PATH CONVERSION FUNCTIONS # 3327862f5301Smrg############################################# 33286fc0178dSmrg# invoked via '$to_host_path_cmd ARG' 3329862f5301Smrg# 3330862f5301Smrg# In each case, ARG is the path to be converted from $build to $host format. 3331862f5301Smrg# The result will be available in $func_to_host_path_result. 3332862f5301Smrg# 3333862f5301Smrg# Path separators are also converted from $build format to $host format. If 3334862f5301Smrg# ARG begins or ends with a path separator character, it is preserved (but 3335862f5301Smrg# converted to $host format) on output. 3336862f5301Smrg# 3337862f5301Smrg# All path conversion functions are named using the following convention: 3338862f5301Smrg# file name conversion function : func_convert_file_X_to_Y () 3339862f5301Smrg# path conversion function : func_convert_path_X_to_Y () 3340862f5301Smrg# where, for any given $build/$host combination the 'X_to_Y' value is the 3341862f5301Smrg# same. If conversion functions are added for new $build/$host combinations, 3342862f5301Smrg# the two new functions must follow this pattern, or func_init_to_host_path_cmd 3343862f5301Smrg# will break. 3344862f5301Smrg 3345862f5301Smrg 3346862f5301Smrg# func_init_to_host_path_cmd 3347862f5301Smrg# Ensures that function "pointer" variable $to_host_path_cmd is set to the 3348862f5301Smrg# appropriate value, based on the value of $to_host_file_cmd. 3349862f5301Smrgto_host_path_cmd= 3350862f5301Smrgfunc_init_to_host_path_cmd () 3351862f5301Smrg{ 33526fc0178dSmrg $debug_cmd 33536fc0178dSmrg 3354862f5301Smrg if test -z "$to_host_path_cmd"; then 3355862f5301Smrg func_stripname 'func_convert_file_' '' "$to_host_file_cmd" 33566fc0178dSmrg to_host_path_cmd=func_convert_path_$func_stripname_result 3357862f5301Smrg fi 3358862f5301Smrg} 3359862f5301Smrg 3360862f5301Smrg 3361862f5301Smrg# func_to_host_path ARG 3362862f5301Smrg# Converts the path ARG from $build format to $host format. Return result 3363862f5301Smrg# in func_to_host_path_result. 3364862f5301Smrgfunc_to_host_path () 3365862f5301Smrg{ 33666fc0178dSmrg $debug_cmd 33676fc0178dSmrg 3368862f5301Smrg func_init_to_host_path_cmd 3369862f5301Smrg $to_host_path_cmd "$1" 3370862f5301Smrg} 3371862f5301Smrg# end func_to_host_path 3372862f5301Smrg 3373862f5301Smrg 3374862f5301Smrg# func_convert_path_noop ARG 3375862f5301Smrg# Copy ARG to func_to_host_path_result. 3376862f5301Smrgfunc_convert_path_noop () 3377862f5301Smrg{ 33786fc0178dSmrg func_to_host_path_result=$1 3379862f5301Smrg} 3380862f5301Smrg# end func_convert_path_noop 3381862f5301Smrg 3382862f5301Smrg 3383862f5301Smrg# func_convert_path_msys_to_w32 ARG 3384862f5301Smrg# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic 3385862f5301Smrg# conversion to w32 is not available inside the cwrapper. Returns result in 3386862f5301Smrg# func_to_host_path_result. 3387862f5301Smrgfunc_convert_path_msys_to_w32 () 33887a3b38f7Smrg{ 33896fc0178dSmrg $debug_cmd 33906fc0178dSmrg 33916fc0178dSmrg func_to_host_path_result=$1 3392862f5301Smrg if test -n "$1"; then 3393862f5301Smrg # Remove leading and trailing path separator characters from ARG. MSYS 3394862f5301Smrg # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; 3395862f5301Smrg # and winepath ignores them completely. 3396862f5301Smrg func_stripname : : "$1" 3397862f5301Smrg func_to_host_path_tmp1=$func_stripname_result 3398862f5301Smrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 33996fc0178dSmrg func_to_host_path_result=$func_convert_core_msys_to_w32_result 3400862f5301Smrg func_convert_path_check : ";" \ 3401862f5301Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3402862f5301Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 3403862f5301Smrg fi 3404862f5301Smrg} 3405862f5301Smrg# end func_convert_path_msys_to_w32 34067a3b38f7Smrg 34077a3b38f7Smrg 3408862f5301Smrg# func_convert_path_cygwin_to_w32 ARG 3409862f5301Smrg# Convert path ARG from Cygwin to w32 format. Returns result in 3410862f5301Smrg# func_to_host_file_result. 3411862f5301Smrgfunc_convert_path_cygwin_to_w32 () 3412862f5301Smrg{ 34136fc0178dSmrg $debug_cmd 34146fc0178dSmrg 34156fc0178dSmrg func_to_host_path_result=$1 3416862f5301Smrg if test -n "$1"; then 3417862f5301Smrg # See func_convert_path_msys_to_w32: 3418862f5301Smrg func_stripname : : "$1" 3419862f5301Smrg func_to_host_path_tmp1=$func_stripname_result 3420862f5301Smrg func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` 3421862f5301Smrg func_convert_path_check : ";" \ 3422862f5301Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3423862f5301Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 3424862f5301Smrg fi 3425862f5301Smrg} 3426862f5301Smrg# end func_convert_path_cygwin_to_w32 34277a3b38f7Smrg 34287a3b38f7Smrg 3429862f5301Smrg# func_convert_path_nix_to_w32 ARG 3430862f5301Smrg# Convert path ARG from *nix to w32 format. Requires a wine environment and 3431862f5301Smrg# a working winepath. Returns result in func_to_host_file_result. 3432862f5301Smrgfunc_convert_path_nix_to_w32 () 3433862f5301Smrg{ 34346fc0178dSmrg $debug_cmd 34356fc0178dSmrg 34366fc0178dSmrg func_to_host_path_result=$1 3437862f5301Smrg if test -n "$1"; then 3438862f5301Smrg # See func_convert_path_msys_to_w32: 3439862f5301Smrg func_stripname : : "$1" 3440862f5301Smrg func_to_host_path_tmp1=$func_stripname_result 3441862f5301Smrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 34426fc0178dSmrg func_to_host_path_result=$func_convert_core_path_wine_to_w32_result 3443862f5301Smrg func_convert_path_check : ";" \ 3444862f5301Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3445862f5301Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 3446862f5301Smrg fi 3447862f5301Smrg} 3448862f5301Smrg# end func_convert_path_nix_to_w32 34497a3b38f7Smrg 3450862f5301Smrg 3451862f5301Smrg# func_convert_path_msys_to_cygwin ARG 3452862f5301Smrg# Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 3453862f5301Smrg# Returns result in func_to_host_file_result. 3454862f5301Smrgfunc_convert_path_msys_to_cygwin () 3455862f5301Smrg{ 34566fc0178dSmrg $debug_cmd 34576fc0178dSmrg 34586fc0178dSmrg func_to_host_path_result=$1 3459862f5301Smrg if test -n "$1"; then 3460862f5301Smrg # See func_convert_path_msys_to_w32: 3461862f5301Smrg func_stripname : : "$1" 3462862f5301Smrg func_to_host_path_tmp1=$func_stripname_result 3463862f5301Smrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 3464862f5301Smrg func_cygpath -u -p "$func_convert_core_msys_to_w32_result" 34656fc0178dSmrg func_to_host_path_result=$func_cygpath_result 3466862f5301Smrg func_convert_path_check : : \ 3467862f5301Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3468862f5301Smrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 3469862f5301Smrg fi 3470862f5301Smrg} 3471862f5301Smrg# end func_convert_path_msys_to_cygwin 3472862f5301Smrg 3473862f5301Smrg 3474862f5301Smrg# func_convert_path_nix_to_cygwin ARG 3475862f5301Smrg# Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a 3476862f5301Smrg# a wine environment, working winepath, and LT_CYGPATH set. Returns result in 3477862f5301Smrg# func_to_host_file_result. 3478862f5301Smrgfunc_convert_path_nix_to_cygwin () 3479862f5301Smrg{ 34806fc0178dSmrg $debug_cmd 34816fc0178dSmrg 34826fc0178dSmrg func_to_host_path_result=$1 3483862f5301Smrg if test -n "$1"; then 3484862f5301Smrg # Remove leading and trailing path separator characters from 3485862f5301Smrg # ARG. msys behavior is inconsistent here, cygpath turns them 3486862f5301Smrg # into '.;' and ';.', and winepath ignores them completely. 3487862f5301Smrg func_stripname : : "$1" 3488862f5301Smrg func_to_host_path_tmp1=$func_stripname_result 3489862f5301Smrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 3490862f5301Smrg func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" 34916fc0178dSmrg func_to_host_path_result=$func_cygpath_result 3492862f5301Smrg func_convert_path_check : : \ 3493862f5301Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3494862f5301Smrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 3495862f5301Smrg fi 34967a3b38f7Smrg} 3497862f5301Smrg# end func_convert_path_nix_to_cygwin 3498862f5301Smrg 34997a3b38f7Smrg 35006fc0178dSmrg# func_dll_def_p FILE 35016fc0178dSmrg# True iff FILE is a Windows DLL '.def' file. 35026fc0178dSmrg# Keep in sync with _LT_DLL_DEF_P in libtool.m4 35036fc0178dSmrgfunc_dll_def_p () 35046fc0178dSmrg{ 35056fc0178dSmrg $debug_cmd 35066fc0178dSmrg 35076fc0178dSmrg func_dll_def_p_tmp=`$SED -n \ 35086fc0178dSmrg -e 's/^[ ]*//' \ 35096fc0178dSmrg -e '/^\(;.*\)*$/d' \ 35106fc0178dSmrg -e 's/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p' \ 35116fc0178dSmrg -e q \ 35126fc0178dSmrg "$1"` 35136fc0178dSmrg test DEF = "$func_dll_def_p_tmp" 35146fc0178dSmrg} 35156fc0178dSmrg 35166fc0178dSmrg 35177a3b38f7Smrg# func_mode_compile arg... 35187a3b38f7Smrgfunc_mode_compile () 35197a3b38f7Smrg{ 35206fc0178dSmrg $debug_cmd 35216fc0178dSmrg 35227a3b38f7Smrg # Get the compilation command and the source file. 35237a3b38f7Smrg base_compile= 35246fc0178dSmrg srcfile=$nonopt # always keep a non-empty value in "srcfile" 35257a3b38f7Smrg suppress_opt=yes 35267a3b38f7Smrg suppress_output= 35277a3b38f7Smrg arg_mode=normal 35287a3b38f7Smrg libobj= 35297a3b38f7Smrg later= 35307a3b38f7Smrg pie_flag= 35317a3b38f7Smrg 35327a3b38f7Smrg for arg 35337a3b38f7Smrg do 35347a3b38f7Smrg case $arg_mode in 35357a3b38f7Smrg arg ) 35367a3b38f7Smrg # do not "continue". Instead, add this to base_compile 35376fc0178dSmrg lastarg=$arg 35387a3b38f7Smrg arg_mode=normal 35397a3b38f7Smrg ;; 35407a3b38f7Smrg 35417a3b38f7Smrg target ) 35426fc0178dSmrg libobj=$arg 35437a3b38f7Smrg arg_mode=normal 35447a3b38f7Smrg continue 35457a3b38f7Smrg ;; 35467a3b38f7Smrg 35477a3b38f7Smrg normal ) 35487a3b38f7Smrg # Accept any command-line options. 35497a3b38f7Smrg case $arg in 35507a3b38f7Smrg -o) 35517a3b38f7Smrg test -n "$libobj" && \ 35526fc0178dSmrg func_fatal_error "you cannot specify '-o' more than once" 35537a3b38f7Smrg arg_mode=target 35547a3b38f7Smrg continue 35557a3b38f7Smrg ;; 35567a3b38f7Smrg 35577a3b38f7Smrg -pie | -fpie | -fPIE) 3558862f5301Smrg func_append pie_flag " $arg" 35597a3b38f7Smrg continue 35607a3b38f7Smrg ;; 35617a3b38f7Smrg 35627a3b38f7Smrg -shared | -static | -prefer-pic | -prefer-non-pic) 3563862f5301Smrg func_append later " $arg" 35647a3b38f7Smrg continue 35657a3b38f7Smrg ;; 35667a3b38f7Smrg 35677a3b38f7Smrg -no-suppress) 35687a3b38f7Smrg suppress_opt=no 35697a3b38f7Smrg continue 35707a3b38f7Smrg ;; 35717a3b38f7Smrg 35727a3b38f7Smrg -Xcompiler) 35737a3b38f7Smrg arg_mode=arg # the next one goes into the "base_compile" arg list 35747a3b38f7Smrg continue # The current "srcfile" will either be retained or 35757a3b38f7Smrg ;; # replaced later. I would guess that would be a bug. 35767a3b38f7Smrg 35777a3b38f7Smrg -Wc,*) 35787a3b38f7Smrg func_stripname '-Wc,' '' "$arg" 35797a3b38f7Smrg args=$func_stripname_result 35807a3b38f7Smrg lastarg= 35816fc0178dSmrg save_ifs=$IFS; IFS=, 35827a3b38f7Smrg for arg in $args; do 35836fc0178dSmrg IFS=$save_ifs 3584862f5301Smrg func_append_quoted lastarg "$arg" 3585ff559fabSmrg done 35866fc0178dSmrg IFS=$save_ifs 35877a3b38f7Smrg func_stripname ' ' '' "$lastarg" 35887a3b38f7Smrg lastarg=$func_stripname_result 3589ff559fabSmrg 3590ff559fabSmrg # Add the arguments to base_compile. 3591862f5301Smrg func_append base_compile " $lastarg" 3592ff559fabSmrg continue 3593ff559fabSmrg ;; 3594ff559fabSmrg 35957a3b38f7Smrg *) 3596ff559fabSmrg # Accept the current argument as the source file. 3597ff559fabSmrg # The previous "srcfile" becomes the current argument. 3598ff559fabSmrg # 35996fc0178dSmrg lastarg=$srcfile 36006fc0178dSmrg srcfile=$arg 3601ff559fabSmrg ;; 3602ff559fabSmrg esac # case $arg 3603ff559fabSmrg ;; 3604ff559fabSmrg esac # case $arg_mode 3605ff559fabSmrg 3606ff559fabSmrg # Aesthetically quote the previous argument. 3607862f5301Smrg func_append_quoted base_compile "$lastarg" 3608ff559fabSmrg done # for arg 3609ff559fabSmrg 3610ff559fabSmrg case $arg_mode in 3611ff559fabSmrg arg) 36127a3b38f7Smrg func_fatal_error "you must specify an argument for -Xcompile" 3613ff559fabSmrg ;; 3614ff559fabSmrg target) 36156fc0178dSmrg func_fatal_error "you must specify a target with '-o'" 3616ff559fabSmrg ;; 3617ff559fabSmrg *) 3618ff559fabSmrg # Get the name of the library object. 36197a3b38f7Smrg test -z "$libobj" && { 36207a3b38f7Smrg func_basename "$srcfile" 36216fc0178dSmrg libobj=$func_basename_result 36227a3b38f7Smrg } 3623ff559fabSmrg ;; 3624ff559fabSmrg esac 3625ff559fabSmrg 3626ff559fabSmrg # Recognize several different file suffixes. 3627ff559fabSmrg # If the user specifies -o file.o, it is replaced with file.lo 3628ff559fabSmrg case $libobj in 36297a3b38f7Smrg *.[cCFSifmso] | \ 36307a3b38f7Smrg *.ada | *.adb | *.ads | *.asm | \ 36317a3b38f7Smrg *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ 3632fc544a13Smrg *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup) 36337a3b38f7Smrg func_xform "$libobj" 36347a3b38f7Smrg libobj=$func_xform_result 36357a3b38f7Smrg ;; 3636ff559fabSmrg esac 3637ff559fabSmrg 3638ff559fabSmrg case $libobj in 36397a3b38f7Smrg *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; 3640ff559fabSmrg *) 36416fc0178dSmrg func_fatal_error "cannot determine name of library object from '$libobj'" 3642ff559fabSmrg ;; 3643ff559fabSmrg esac 3644ff559fabSmrg 3645ff559fabSmrg func_infer_tag $base_compile 3646ff559fabSmrg 3647ff559fabSmrg for arg in $later; do 3648ff559fabSmrg case $arg in 36497a3b38f7Smrg -shared) 36506fc0178dSmrg test yes = "$build_libtool_libs" \ 36516fc0178dSmrg || func_fatal_configuration "cannot build a shared library" 36527a3b38f7Smrg build_old_libs=no 36537a3b38f7Smrg continue 36547a3b38f7Smrg ;; 36557a3b38f7Smrg 3656ff559fabSmrg -static) 36577a3b38f7Smrg build_libtool_libs=no 3658ff559fabSmrg build_old_libs=yes 3659ff559fabSmrg continue 3660ff559fabSmrg ;; 3661ff559fabSmrg 3662ff559fabSmrg -prefer-pic) 3663ff559fabSmrg pic_mode=yes 3664ff559fabSmrg continue 3665ff559fabSmrg ;; 3666ff559fabSmrg 3667ff559fabSmrg -prefer-non-pic) 3668ff559fabSmrg pic_mode=no 3669ff559fabSmrg continue 3670ff559fabSmrg ;; 3671ff559fabSmrg esac 3672ff559fabSmrg done 3673ff559fabSmrg 3674515ec619Smrg func_quote_arg pretty "$libobj" 3675515ec619Smrg test "X$libobj" != "X$func_quote_arg_result" \ 36767a3b38f7Smrg && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ 36776fc0178dSmrg && func_warning "libobj name '$libobj' may not contain shell special characters." 36787a3b38f7Smrg func_dirname_and_basename "$obj" "/" "" 36796fc0178dSmrg objname=$func_basename_result 36806fc0178dSmrg xdir=$func_dirname_result 36816fc0178dSmrg lobj=$xdir$objdir/$objname 3682ff559fabSmrg 36837a3b38f7Smrg test -z "$base_compile" && \ 36847a3b38f7Smrg func_fatal_help "you must specify a compilation command" 3685ff559fabSmrg 3686ff559fabSmrg # Delete any leftover library objects. 36876fc0178dSmrg if test yes = "$build_old_libs"; then 3688ff559fabSmrg removelist="$obj $lobj $libobj ${libobj}T" 3689ff559fabSmrg else 3690ff559fabSmrg removelist="$lobj $libobj ${libobj}T" 3691ff559fabSmrg fi 3692ff559fabSmrg 3693ff559fabSmrg # On Cygwin there's no "real" PIC flag so we must build both object types 3694ff559fabSmrg case $host_os in 36957a3b38f7Smrg cygwin* | mingw* | pw32* | os2* | cegcc*) 3696ff559fabSmrg pic_mode=default 3697ff559fabSmrg ;; 3698ff559fabSmrg esac 36996fc0178dSmrg if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then 3700ff559fabSmrg # non-PIC code in shared libraries is not supported 3701ff559fabSmrg pic_mode=default 3702ff559fabSmrg fi 3703ff559fabSmrg 3704ff559fabSmrg # Calculate the filename of the output object if compiler does 3705ff559fabSmrg # not support -o with -c 37066fc0178dSmrg if test no = "$compiler_c_o"; then 37076fc0178dSmrg output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext 37086fc0178dSmrg lockfile=$output_obj.lock 3709ff559fabSmrg else 3710ff559fabSmrg output_obj= 3711ff559fabSmrg need_locks=no 3712ff559fabSmrg lockfile= 3713ff559fabSmrg fi 3714ff559fabSmrg 3715ff559fabSmrg # Lock this critical section if it is needed 3716ff559fabSmrg # We use this script file to make the link, it avoids creating a new file 37176fc0178dSmrg if test yes = "$need_locks"; then 37187a3b38f7Smrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 37197a3b38f7Smrg func_echo "Waiting for $lockfile to be removed" 3720ff559fabSmrg sleep 2 3721ff559fabSmrg done 37226fc0178dSmrg elif test warn = "$need_locks"; then 3723ff559fabSmrg if test -f "$lockfile"; then 37247a3b38f7Smrg $ECHO "\ 3725ff559fabSmrg*** ERROR, $lockfile exists and contains: 3726ff559fabSmrg`cat $lockfile 2>/dev/null` 3727ff559fabSmrg 3728ff559fabSmrgThis indicates that another process is trying to use the same 3729ff559fabSmrgtemporary object file, and libtool could not work around it because 37306fc0178dSmrgyour compiler does not support '-c' and '-o' together. If you 3731ff559fabSmrgrepeat this compilation, it may succeed, by chance, but you had better 3732ff559fabSmrgavoid parallel builds (make -j) in this platform, or get a better 3733ff559fabSmrgcompiler." 3734ff559fabSmrg 37357a3b38f7Smrg $opt_dry_run || $RM $removelist 3736ff559fabSmrg exit $EXIT_FAILURE 3737ff559fabSmrg fi 3738862f5301Smrg func_append removelist " $output_obj" 37397a3b38f7Smrg $ECHO "$srcfile" > "$lockfile" 3740ff559fabSmrg fi 3741ff559fabSmrg 37427a3b38f7Smrg $opt_dry_run || $RM $removelist 3743862f5301Smrg func_append removelist " $lockfile" 37447a3b38f7Smrg trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 37457a3b38f7Smrg 3746862f5301Smrg func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 3747862f5301Smrg srcfile=$func_to_tool_file_result 3748515ec619Smrg func_quote_arg pretty "$srcfile" 3749515ec619Smrg qsrcfile=$func_quote_arg_result 3750ff559fabSmrg 3751ff559fabSmrg # Only build a PIC object if we are building libtool libraries. 37526fc0178dSmrg if test yes = "$build_libtool_libs"; then 3753ff559fabSmrg # Without this assignment, base_compile gets emptied. 3754ff559fabSmrg fbsd_hideous_sh_bug=$base_compile 3755ff559fabSmrg 37566fc0178dSmrg if test no != "$pic_mode"; then 3757ff559fabSmrg command="$base_compile $qsrcfile $pic_flag" 3758ff559fabSmrg else 3759ff559fabSmrg # Don't build PIC code 3760ff559fabSmrg command="$base_compile $qsrcfile" 3761ff559fabSmrg fi 3762ff559fabSmrg 37637a3b38f7Smrg func_mkdir_p "$xdir$objdir" 3764ff559fabSmrg 3765ff559fabSmrg if test -z "$output_obj"; then 3766ff559fabSmrg # Place PIC objects in $objdir 3767862f5301Smrg func_append command " -o $lobj" 3768ff559fabSmrg fi 3769ff559fabSmrg 37707a3b38f7Smrg func_show_eval_locale "$command" \ 37717a3b38f7Smrg 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' 3772ff559fabSmrg 37736fc0178dSmrg if test warn = "$need_locks" && 3774ff559fabSmrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 37757a3b38f7Smrg $ECHO "\ 3776ff559fabSmrg*** ERROR, $lockfile contains: 3777ff559fabSmrg`cat $lockfile 2>/dev/null` 3778ff559fabSmrg 3779ff559fabSmrgbut it should contain: 3780ff559fabSmrg$srcfile 3781ff559fabSmrg 3782ff559fabSmrgThis indicates that another process is trying to use the same 3783ff559fabSmrgtemporary object file, and libtool could not work around it because 37846fc0178dSmrgyour compiler does not support '-c' and '-o' together. If you 3785ff559fabSmrgrepeat this compilation, it may succeed, by chance, but you had better 3786ff559fabSmrgavoid parallel builds (make -j) in this platform, or get a better 3787ff559fabSmrgcompiler." 3788ff559fabSmrg 37897a3b38f7Smrg $opt_dry_run || $RM $removelist 3790ff559fabSmrg exit $EXIT_FAILURE 3791ff559fabSmrg fi 3792ff559fabSmrg 3793ff559fabSmrg # Just move the object if needed, then go on to compile the next one 3794ff559fabSmrg if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then 37957a3b38f7Smrg func_show_eval '$MV "$output_obj" "$lobj"' \ 37967a3b38f7Smrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 3797ff559fabSmrg fi 3798ff559fabSmrg 3799ff559fabSmrg # Allow error messages only from the first compilation. 38006fc0178dSmrg if test yes = "$suppress_opt"; then 38017a3b38f7Smrg suppress_output=' >/dev/null 2>&1' 3802ff559fabSmrg fi 3803ff559fabSmrg fi 3804ff559fabSmrg 3805ff559fabSmrg # Only build a position-dependent object if we build old libraries. 38066fc0178dSmrg if test yes = "$build_old_libs"; then 38076fc0178dSmrg if test yes != "$pic_mode"; then 3808ff559fabSmrg # Don't build PIC code 38097a3b38f7Smrg command="$base_compile $qsrcfile$pie_flag" 3810ff559fabSmrg else 3811ff559fabSmrg command="$base_compile $qsrcfile $pic_flag" 3812ff559fabSmrg fi 38136fc0178dSmrg if test yes = "$compiler_c_o"; then 3814862f5301Smrg func_append command " -o $obj" 3815ff559fabSmrg fi 3816ff559fabSmrg 3817ff559fabSmrg # Suppress compiler output if we already did a PIC compilation. 3818862f5301Smrg func_append command "$suppress_output" 38197a3b38f7Smrg func_show_eval_locale "$command" \ 38207a3b38f7Smrg '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 3821ff559fabSmrg 38226fc0178dSmrg if test warn = "$need_locks" && 3823ff559fabSmrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 38247a3b38f7Smrg $ECHO "\ 3825ff559fabSmrg*** ERROR, $lockfile contains: 3826ff559fabSmrg`cat $lockfile 2>/dev/null` 3827ff559fabSmrg 3828ff559fabSmrgbut it should contain: 3829ff559fabSmrg$srcfile 3830ff559fabSmrg 3831ff559fabSmrgThis indicates that another process is trying to use the same 3832ff559fabSmrgtemporary object file, and libtool could not work around it because 38336fc0178dSmrgyour compiler does not support '-c' and '-o' together. If you 3834ff559fabSmrgrepeat this compilation, it may succeed, by chance, but you had better 3835ff559fabSmrgavoid parallel builds (make -j) in this platform, or get a better 3836ff559fabSmrgcompiler." 3837ff559fabSmrg 38387a3b38f7Smrg $opt_dry_run || $RM $removelist 3839ff559fabSmrg exit $EXIT_FAILURE 3840ff559fabSmrg fi 3841ff559fabSmrg 3842ff559fabSmrg # Just move the object if needed 3843ff559fabSmrg if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then 38447a3b38f7Smrg func_show_eval '$MV "$output_obj" "$obj"' \ 38457a3b38f7Smrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 3846ff559fabSmrg fi 3847ff559fabSmrg fi 3848ff559fabSmrg 38497a3b38f7Smrg $opt_dry_run || { 38507a3b38f7Smrg func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" 3851ff559fabSmrg 38527a3b38f7Smrg # Unlock the critical section if it was locked 38536fc0178dSmrg if test no != "$need_locks"; then 38547a3b38f7Smrg removelist=$lockfile 38557a3b38f7Smrg $RM "$lockfile" 38567a3b38f7Smrg fi 38577a3b38f7Smrg } 3858ff559fabSmrg 3859ff559fabSmrg exit $EXIT_SUCCESS 38607a3b38f7Smrg} 3861ff559fabSmrg 38627a3b38f7Smrg$opt_help || { 38636fc0178dSmrg test compile = "$opt_mode" && func_mode_compile ${1+"$@"} 38647a3b38f7Smrg} 3865ff559fabSmrg 38667a3b38f7Smrgfunc_mode_help () 38677a3b38f7Smrg{ 38687a3b38f7Smrg # We need to display help for each of the modes. 3869862f5301Smrg case $opt_mode in 38707a3b38f7Smrg "") 38717a3b38f7Smrg # Generic help is extracted from the usage comments 38727a3b38f7Smrg # at the start of this file. 38737a3b38f7Smrg func_help 38747a3b38f7Smrg ;; 3875ff559fabSmrg 38767a3b38f7Smrg clean) 38777a3b38f7Smrg $ECHO \ 38787a3b38f7Smrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... 3879ff559fabSmrg 38807a3b38f7SmrgRemove files from the build directory. 3881ff559fabSmrg 38827a3b38f7SmrgRM is the name of the program to use to delete files associated with each FILE 38836fc0178dSmrg(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 38847a3b38f7Smrgto RM. 3885ff559fabSmrg 38867a3b38f7SmrgIf FILE is a libtool library, object or program, all the files associated 38877a3b38f7Smrgwith it are deleted. Otherwise, only FILE itself is deleted using RM." 38887a3b38f7Smrg ;; 3889ff559fabSmrg 38907a3b38f7Smrg compile) 38917a3b38f7Smrg $ECHO \ 38927a3b38f7Smrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE 3893ff559fabSmrg 38947a3b38f7SmrgCompile a source file into a libtool library object. 3895ff559fabSmrg 38967a3b38f7SmrgThis mode accepts the following additional options: 3897ff559fabSmrg 38987a3b38f7Smrg -o OUTPUT-FILE set the output file name to OUTPUT-FILE 38997a3b38f7Smrg -no-suppress do not suppress compiler output for multiple passes 390044dda7b2Smrg -prefer-pic try to build PIC objects only 390144dda7b2Smrg -prefer-non-pic try to build non-PIC objects only 39026fc0178dSmrg -shared do not build a '.o' file suitable for static linking 39036fc0178dSmrg -static only build a '.o' file suitable for static linking 3904515ec619Smrg -Wc,FLAG 3905515ec619Smrg -Xcompiler FLAG pass FLAG directly to the compiler 3906ff559fabSmrg 39076fc0178dSmrgCOMPILE-COMMAND is a command to be used in creating a 'standard' object file 39087a3b38f7Smrgfrom the given SOURCEFILE. 3909ff559fabSmrg 39107a3b38f7SmrgThe output file name is determined by removing the directory component from 39116fc0178dSmrgSOURCEFILE, then substituting the C source code suffix '.c' with the 39126fc0178dSmrglibrary object suffix, '.lo'." 39137a3b38f7Smrg ;; 3914ff559fabSmrg 39157a3b38f7Smrg execute) 39167a3b38f7Smrg $ECHO \ 39177a3b38f7Smrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... 3918ff559fabSmrg 39197a3b38f7SmrgAutomatically set library path, then run a program. 3920ff559fabSmrg 39217a3b38f7SmrgThis mode accepts the following additional options: 3922ff559fabSmrg 39237a3b38f7Smrg -dlopen FILE add the directory containing FILE to the library path 3924ff559fabSmrg 39256fc0178dSmrgThis mode sets the library path environment variable according to '-dlopen' 39267a3b38f7Smrgflags. 3927ff559fabSmrg 39287a3b38f7SmrgIf any of the ARGS are libtool executable wrappers, then they are translated 39297a3b38f7Smrginto their corresponding uninstalled binary, and any of their required library 39307a3b38f7Smrgdirectories are added to the library path. 3931ff559fabSmrg 39327a3b38f7SmrgThen, COMMAND is executed, with ARGS as arguments." 39337a3b38f7Smrg ;; 3934ff559fabSmrg 39357a3b38f7Smrg finish) 39367a3b38f7Smrg $ECHO \ 39377a3b38f7Smrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]... 3938ff559fabSmrg 39397a3b38f7SmrgComplete the installation of libtool libraries. 3940ff559fabSmrg 39417a3b38f7SmrgEach LIBDIR is a directory that contains libtool libraries. 3942ff559fabSmrg 39437a3b38f7SmrgThe commands that this mode executes may require superuser privileges. Use 39446fc0178dSmrgthe '--dry-run' option if you just want to see what would be executed." 39457a3b38f7Smrg ;; 3946ff559fabSmrg 39477a3b38f7Smrg install) 39487a3b38f7Smrg $ECHO \ 39497a3b38f7Smrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... 3950ff559fabSmrg 39517a3b38f7SmrgInstall executables or libraries. 3952ff559fabSmrg 39537a3b38f7SmrgINSTALL-COMMAND is the installation command. The first component should be 39546fc0178dSmrgeither the 'install' or 'cp' program. 3955ff559fabSmrg 39567a3b38f7SmrgThe following components of INSTALL-COMMAND are treated specially: 3957ff559fabSmrg 395844dda7b2Smrg -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation 3959ff559fabSmrg 39607a3b38f7SmrgThe rest of the components are interpreted as arguments to that command (only 39617a3b38f7SmrgBSD-compatible install options are recognized)." 39627a3b38f7Smrg ;; 3963ff559fabSmrg 39647a3b38f7Smrg link) 39657a3b38f7Smrg $ECHO \ 39667a3b38f7Smrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND... 3967ff559fabSmrg 39687a3b38f7SmrgLink object files or libraries together to form another library, or to 39697a3b38f7Smrgcreate an executable program. 3970ff559fabSmrg 39717a3b38f7SmrgLINK-COMMAND is a command using the C compiler that you would use to create 39727a3b38f7Smrga program from several object files. 3973ff559fabSmrg 39747a3b38f7SmrgThe following components of LINK-COMMAND are treated specially: 3975ff559fabSmrg 39767a3b38f7Smrg -all-static do not do any dynamic linking at all 39777a3b38f7Smrg -avoid-version do not add a version suffix if possible 397844dda7b2Smrg -bindir BINDIR specify path to binaries directory (for systems where 397944dda7b2Smrg libraries must be found in the PATH setting at runtime) 39806fc0178dSmrg -dlopen FILE '-dlpreopen' FILE if it cannot be dlopened at runtime 39817a3b38f7Smrg -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols 39827a3b38f7Smrg -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) 39837a3b38f7Smrg -export-symbols SYMFILE 39847a3b38f7Smrg try to export only the symbols listed in SYMFILE 39857a3b38f7Smrg -export-symbols-regex REGEX 39867a3b38f7Smrg try to export only the symbols matching REGEX 39877a3b38f7Smrg -LLIBDIR search LIBDIR for required installed libraries 39887a3b38f7Smrg -lNAME OUTPUT-FILE requires the installed library libNAME 39897a3b38f7Smrg -module build a library that can dlopened 39907a3b38f7Smrg -no-fast-install disable the fast-install mode 39917a3b38f7Smrg -no-install link a not-installable executable 39927a3b38f7Smrg -no-undefined declare that a library does not refer to external symbols 39937a3b38f7Smrg -o OUTPUT-FILE create OUTPUT-FILE from the specified objects 39946fc0178dSmrg -objectlist FILE use a list of object files found in FILE to specify objects 39956fc0178dSmrg -os2dllname NAME force a short DLL name on OS/2 (no effect on other OSes) 39967a3b38f7Smrg -precious-files-regex REGEX 39977a3b38f7Smrg don't remove output files matching REGEX 39987a3b38f7Smrg -release RELEASE specify package release information 39997a3b38f7Smrg -rpath LIBDIR the created library will eventually be installed in LIBDIR 40007a3b38f7Smrg -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries 40017a3b38f7Smrg -shared only do dynamic linking of libtool libraries 40027a3b38f7Smrg -shrext SUFFIX override the standard shared library file extension 40037a3b38f7Smrg -static do not do any dynamic linking of uninstalled libtool libraries 40047a3b38f7Smrg -static-libtool-libs 40057a3b38f7Smrg do not do any dynamic linking of libtool libraries 40067a3b38f7Smrg -version-info CURRENT[:REVISION[:AGE]] 40077a3b38f7Smrg specify library version info [each variable defaults to 0] 40087a3b38f7Smrg -weak LIBNAME declare that the target provides the LIBNAME interface 400944dda7b2Smrg -Wc,FLAG 401044dda7b2Smrg -Xcompiler FLAG pass linker-specific FLAG directly to the compiler 4011515ec619Smrg -Wa,FLAG 4012515ec619Smrg -Xassembler FLAG pass linker-specific FLAG directly to the assembler 401344dda7b2Smrg -Wl,FLAG 401444dda7b2Smrg -Xlinker FLAG pass linker-specific FLAG directly to the linker 401544dda7b2Smrg -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) 4016ff559fabSmrg 40176fc0178dSmrgAll other options (arguments beginning with '-') are ignored. 4018ff559fabSmrg 40196fc0178dSmrgEvery other argument is treated as a filename. Files ending in '.la' are 40207a3b38f7Smrgtreated as uninstalled libtool libraries, other files are standard or library 40217a3b38f7Smrgobject files. 4022ff559fabSmrg 40236fc0178dSmrgIf the OUTPUT-FILE ends in '.la', then a libtool library is created, 40246fc0178dSmrgonly library objects ('.lo' files) may be specified, and '-rpath' is 40257a3b38f7Smrgrequired, except when creating a convenience library. 4026ff559fabSmrg 40276fc0178dSmrgIf OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created 40286fc0178dSmrgusing 'ar' and 'ranlib', or on Windows using 'lib'. 4029ff559fabSmrg 40306fc0178dSmrgIf OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file 40317a3b38f7Smrgis created, otherwise an executable program is created." 4032ff559fabSmrg ;; 4033ff559fabSmrg 40347a3b38f7Smrg uninstall) 40357a3b38f7Smrg $ECHO \ 40367a3b38f7Smrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... 4037ff559fabSmrg 40387a3b38f7SmrgRemove libraries from an installation directory. 4039ff559fabSmrg 40407a3b38f7SmrgRM is the name of the program to use to delete files associated with each FILE 40416fc0178dSmrg(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 40427a3b38f7Smrgto RM. 4043ff559fabSmrg 40447a3b38f7SmrgIf FILE is a libtool library, all the files associated with it are deleted. 40457a3b38f7SmrgOtherwise, only FILE itself is deleted using RM." 40467a3b38f7Smrg ;; 4047ff559fabSmrg 40487a3b38f7Smrg *) 40496fc0178dSmrg func_fatal_help "invalid operation mode '$opt_mode'" 40507a3b38f7Smrg ;; 40517a3b38f7Smrg esac 4052ff559fabSmrg 405344dda7b2Smrg echo 40546fc0178dSmrg $ECHO "Try '$progname --help' for more information about other modes." 40557a3b38f7Smrg} 4056ff559fabSmrg 405744dda7b2Smrg# Now that we've collected a possible --mode arg, show help if necessary 405844dda7b2Smrgif $opt_help; then 40596fc0178dSmrg if test : = "$opt_help"; then 406044dda7b2Smrg func_mode_help 406144dda7b2Smrg else 406244dda7b2Smrg { 406344dda7b2Smrg func_help noexit 4064862f5301Smrg for opt_mode in compile link execute install finish uninstall clean; do 406544dda7b2Smrg func_mode_help 406644dda7b2Smrg done 40676fc0178dSmrg } | $SED -n '1p; 2,$s/^Usage:/ or: /p' 406844dda7b2Smrg { 406944dda7b2Smrg func_help noexit 4070862f5301Smrg for opt_mode in compile link execute install finish uninstall clean; do 407144dda7b2Smrg echo 407244dda7b2Smrg func_mode_help 407344dda7b2Smrg done 407444dda7b2Smrg } | 40756fc0178dSmrg $SED '1d 407644dda7b2Smrg /^When reporting/,/^Report/{ 407744dda7b2Smrg H 407844dda7b2Smrg d 407944dda7b2Smrg } 408044dda7b2Smrg $x 408144dda7b2Smrg /information about other modes/d 408244dda7b2Smrg /more detailed .*MODE/d 408344dda7b2Smrg s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' 408444dda7b2Smrg fi 408544dda7b2Smrg exit $? 408644dda7b2Smrgfi 4087ff559fabSmrg 4088ff559fabSmrg 40897a3b38f7Smrg# func_mode_execute arg... 40907a3b38f7Smrgfunc_mode_execute () 40917a3b38f7Smrg{ 40926fc0178dSmrg $debug_cmd 40936fc0178dSmrg 40947a3b38f7Smrg # The first argument is the command name. 40956fc0178dSmrg cmd=$nonopt 40967a3b38f7Smrg test -z "$cmd" && \ 40977a3b38f7Smrg func_fatal_help "you must specify a COMMAND" 4098ff559fabSmrg 40997a3b38f7Smrg # Handle -dlopen flags immediately. 4100862f5301Smrg for file in $opt_dlopen; do 41017a3b38f7Smrg test -f "$file" \ 41026fc0178dSmrg || func_fatal_help "'$file' is not a file" 4103ff559fabSmrg 41047a3b38f7Smrg dir= 41057a3b38f7Smrg case $file in 41067a3b38f7Smrg *.la) 4107862f5301Smrg func_resolve_sysroot "$file" 4108862f5301Smrg file=$func_resolve_sysroot_result 4109862f5301Smrg 41107a3b38f7Smrg # Check to see that this really is a libtool archive. 41117a3b38f7Smrg func_lalib_unsafe_p "$file" \ 41126fc0178dSmrg || func_fatal_help "'$lib' is not a valid libtool archive" 4113ff559fabSmrg 41147a3b38f7Smrg # Read the libtool library. 41157a3b38f7Smrg dlname= 41167a3b38f7Smrg library_names= 41177a3b38f7Smrg func_source "$file" 4118ff559fabSmrg 41197a3b38f7Smrg # Skip this library if it cannot be dlopened. 41207a3b38f7Smrg if test -z "$dlname"; then 41217a3b38f7Smrg # Warn if it was a shared library. 41227a3b38f7Smrg test -n "$library_names" && \ 41236fc0178dSmrg func_warning "'$file' was not linked with '-export-dynamic'" 41247a3b38f7Smrg continue 41257a3b38f7Smrg fi 4126ff559fabSmrg 41277a3b38f7Smrg func_dirname "$file" "" "." 41286fc0178dSmrg dir=$func_dirname_result 4129ff559fabSmrg 41307a3b38f7Smrg if test -f "$dir/$objdir/$dlname"; then 4131862f5301Smrg func_append dir "/$objdir" 41327a3b38f7Smrg else 41337a3b38f7Smrg if test ! -f "$dir/$dlname"; then 41346fc0178dSmrg func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'" 41357a3b38f7Smrg fi 41367a3b38f7Smrg fi 4137ff559fabSmrg ;; 4138ff559fabSmrg 41397a3b38f7Smrg *.lo) 41407a3b38f7Smrg # Just add the directory containing the .lo file. 41417a3b38f7Smrg func_dirname "$file" "" "." 41426fc0178dSmrg dir=$func_dirname_result 4143ff559fabSmrg ;; 4144ff559fabSmrg 41457a3b38f7Smrg *) 41466fc0178dSmrg func_warning "'-dlopen' is ignored for non-libtool libraries and objects" 4147ff559fabSmrg continue 4148ff559fabSmrg ;; 41497a3b38f7Smrg esac 4150ff559fabSmrg 41517a3b38f7Smrg # Get the absolute pathname. 41527a3b38f7Smrg absdir=`cd "$dir" && pwd` 41536fc0178dSmrg test -n "$absdir" && dir=$absdir 4154ff559fabSmrg 41557a3b38f7Smrg # Now add the directory to shlibpath_var. 41567a3b38f7Smrg if eval "test -z \"\$$shlibpath_var\""; then 41577a3b38f7Smrg eval "$shlibpath_var=\"\$dir\"" 41587a3b38f7Smrg else 41597a3b38f7Smrg eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" 41607a3b38f7Smrg fi 41617a3b38f7Smrg done 4162ff559fabSmrg 41637a3b38f7Smrg # This variable tells wrapper scripts just to set shlibpath_var 41647a3b38f7Smrg # rather than running their programs. 41656fc0178dSmrg libtool_execute_magic=$magic 4166ff559fabSmrg 41677a3b38f7Smrg # Check if any of the arguments is a wrapper script. 41687a3b38f7Smrg args= 41697a3b38f7Smrg for file 41707a3b38f7Smrg do 41717a3b38f7Smrg case $file in 417244dda7b2Smrg -* | *.la | *.lo ) ;; 41737a3b38f7Smrg *) 41747a3b38f7Smrg # Do a test to see if this is really a libtool program. 41757a3b38f7Smrg if func_ltwrapper_script_p "$file"; then 41767a3b38f7Smrg func_source "$file" 41777a3b38f7Smrg # Transform arg to wrapped name. 41786fc0178dSmrg file=$progdir/$program 41797a3b38f7Smrg elif func_ltwrapper_executable_p "$file"; then 41807a3b38f7Smrg func_ltwrapper_scriptname "$file" 41817a3b38f7Smrg func_source "$func_ltwrapper_scriptname_result" 41827a3b38f7Smrg # Transform arg to wrapped name. 41836fc0178dSmrg file=$progdir/$program 41847a3b38f7Smrg fi 41857a3b38f7Smrg ;; 41867a3b38f7Smrg esac 41877a3b38f7Smrg # Quote arguments (to preserve shell metacharacters). 4188862f5301Smrg func_append_quoted args "$file" 41897a3b38f7Smrg done 4190ff559fabSmrg 41916fc0178dSmrg if $opt_dry_run; then 41926fc0178dSmrg # Display what would be done. 41936fc0178dSmrg if test -n "$shlibpath_var"; then 41946fc0178dSmrg eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" 41956fc0178dSmrg echo "export $shlibpath_var" 41966fc0178dSmrg fi 41976fc0178dSmrg $ECHO "$cmd$args" 41986fc0178dSmrg exit $EXIT_SUCCESS 41996fc0178dSmrg else 42007a3b38f7Smrg if test -n "$shlibpath_var"; then 42017a3b38f7Smrg # Export the shlibpath_var. 42027a3b38f7Smrg eval "export $shlibpath_var" 42037a3b38f7Smrg fi 4204ff559fabSmrg 42057a3b38f7Smrg # Restore saved environment variables 42067a3b38f7Smrg for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 42077a3b38f7Smrg do 42087a3b38f7Smrg eval "if test \"\${save_$lt_var+set}\" = set; then 42097a3b38f7Smrg $lt_var=\$save_$lt_var; export $lt_var 42107a3b38f7Smrg else 42117a3b38f7Smrg $lt_unset $lt_var 42127a3b38f7Smrg fi" 42137a3b38f7Smrg done 4214ff559fabSmrg 42157a3b38f7Smrg # Now prepare to actually exec the command. 42166fc0178dSmrg exec_cmd=\$cmd$args 42177a3b38f7Smrg fi 42187a3b38f7Smrg} 4219ff559fabSmrg 42206fc0178dSmrgtest execute = "$opt_mode" && func_mode_execute ${1+"$@"} 4221ff559fabSmrg 4222ff559fabSmrg 42237a3b38f7Smrg# func_mode_finish arg... 42247a3b38f7Smrgfunc_mode_finish () 42257a3b38f7Smrg{ 42266fc0178dSmrg $debug_cmd 42276fc0178dSmrg 4228862f5301Smrg libs= 4229862f5301Smrg libdirs= 42307a3b38f7Smrg admincmds= 4231ff559fabSmrg 4232862f5301Smrg for opt in "$nonopt" ${1+"$@"} 4233862f5301Smrg do 4234862f5301Smrg if test -d "$opt"; then 4235862f5301Smrg func_append libdirs " $opt" 4236862f5301Smrg 4237862f5301Smrg elif test -f "$opt"; then 4238862f5301Smrg if func_lalib_unsafe_p "$opt"; then 4239862f5301Smrg func_append libs " $opt" 4240862f5301Smrg else 42416fc0178dSmrg func_warning "'$opt' is not a valid libtool archive" 4242862f5301Smrg fi 4243862f5301Smrg 4244862f5301Smrg else 42456fc0178dSmrg func_fatal_error "invalid argument '$opt'" 4246862f5301Smrg fi 4247862f5301Smrg done 4248862f5301Smrg 4249862f5301Smrg if test -n "$libs"; then 4250862f5301Smrg if test -n "$lt_sysroot"; then 4251862f5301Smrg sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` 4252862f5301Smrg sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" 4253862f5301Smrg else 4254862f5301Smrg sysroot_cmd= 4255862f5301Smrg fi 4256862f5301Smrg 4257862f5301Smrg # Remove sysroot references 4258862f5301Smrg if $opt_dry_run; then 4259862f5301Smrg for lib in $libs; do 42606fc0178dSmrg echo "removing references to $lt_sysroot and '=' prefixes from $lib" 4261862f5301Smrg done 4262862f5301Smrg else 4263862f5301Smrg tmpdir=`func_mktempdir` 4264862f5301Smrg for lib in $libs; do 42656fc0178dSmrg $SED -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ 4266862f5301Smrg > $tmpdir/tmp-la 4267862f5301Smrg mv -f $tmpdir/tmp-la $lib 4268862f5301Smrg done 4269862f5301Smrg ${RM}r "$tmpdir" 4270862f5301Smrg fi 4271862f5301Smrg fi 4272ff559fabSmrg 4273862f5301Smrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 42747a3b38f7Smrg for libdir in $libdirs; do 42757a3b38f7Smrg if test -n "$finish_cmds"; then 42767a3b38f7Smrg # Do each command in the finish commands. 42777a3b38f7Smrg func_execute_cmds "$finish_cmds" 'admincmds="$admincmds 42787a3b38f7Smrg'"$cmd"'"' 42797a3b38f7Smrg fi 42807a3b38f7Smrg if test -n "$finish_eval"; then 42817a3b38f7Smrg # Do the single finish_eval. 42827a3b38f7Smrg eval cmds=\"$finish_eval\" 4283862f5301Smrg $opt_dry_run || eval "$cmds" || func_append admincmds " 42847a3b38f7Smrg $cmds" 42857a3b38f7Smrg fi 42867a3b38f7Smrg done 42877a3b38f7Smrg fi 4288ff559fabSmrg 42897a3b38f7Smrg # Exit here if they wanted silent mode. 42906fc0178dSmrg $opt_quiet && exit $EXIT_SUCCESS 4291ff559fabSmrg 4292862f5301Smrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 4293862f5301Smrg echo "----------------------------------------------------------------------" 4294862f5301Smrg echo "Libraries have been installed in:" 4295862f5301Smrg for libdir in $libdirs; do 4296862f5301Smrg $ECHO " $libdir" 4297862f5301Smrg done 4298862f5301Smrg echo 4299862f5301Smrg echo "If you ever happen to want to link against installed libraries" 4300862f5301Smrg echo "in a given directory, LIBDIR, you must either use libtool, and" 43016fc0178dSmrg echo "specify the full pathname of the library, or use the '-LLIBDIR'" 4302862f5301Smrg echo "flag during linking and do at least one of the following:" 4303862f5301Smrg if test -n "$shlibpath_var"; then 43046fc0178dSmrg echo " - add LIBDIR to the '$shlibpath_var' environment variable" 4305862f5301Smrg echo " during execution" 4306862f5301Smrg fi 4307862f5301Smrg if test -n "$runpath_var"; then 43086fc0178dSmrg echo " - add LIBDIR to the '$runpath_var' environment variable" 4309862f5301Smrg echo " during linking" 4310862f5301Smrg fi 4311862f5301Smrg if test -n "$hardcode_libdir_flag_spec"; then 4312862f5301Smrg libdir=LIBDIR 4313862f5301Smrg eval flag=\"$hardcode_libdir_flag_spec\" 4314ff559fabSmrg 43156fc0178dSmrg $ECHO " - use the '$flag' linker flag" 4316862f5301Smrg fi 4317862f5301Smrg if test -n "$admincmds"; then 4318862f5301Smrg $ECHO " - have your system administrator run these commands:$admincmds" 4319862f5301Smrg fi 4320862f5301Smrg if test -f /etc/ld.so.conf; then 43216fc0178dSmrg echo " - have your system administrator add LIBDIR to '/etc/ld.so.conf'" 4322862f5301Smrg fi 4323862f5301Smrg echo 4324ff559fabSmrg 4325862f5301Smrg echo "See any operating system documentation about shared libraries for" 4326862f5301Smrg case $host in 4327862f5301Smrg solaris2.[6789]|solaris2.1[0-9]) 4328862f5301Smrg echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" 4329862f5301Smrg echo "pages." 4330862f5301Smrg ;; 4331862f5301Smrg *) 4332862f5301Smrg echo "more information, such as the ld(1) and ld.so(8) manual pages." 4333862f5301Smrg ;; 4334862f5301Smrg esac 4335862f5301Smrg echo "----------------------------------------------------------------------" 4336862f5301Smrg fi 43377a3b38f7Smrg exit $EXIT_SUCCESS 43387a3b38f7Smrg} 4339ff559fabSmrg 43406fc0178dSmrgtest finish = "$opt_mode" && func_mode_finish ${1+"$@"} 4341ff559fabSmrg 4342ff559fabSmrg 43437a3b38f7Smrg# func_mode_install arg... 43447a3b38f7Smrgfunc_mode_install () 43457a3b38f7Smrg{ 43466fc0178dSmrg $debug_cmd 43476fc0178dSmrg 43487a3b38f7Smrg # There may be an optional sh(1) argument at the beginning of 43497a3b38f7Smrg # install_prog (especially on Windows NT). 43506fc0178dSmrg if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" || 43517a3b38f7Smrg # Allow the use of GNU shtool's install command. 43526fc0178dSmrg case $nonopt in *shtool*) :;; *) false;; esac 43536fc0178dSmrg then 43547a3b38f7Smrg # Aesthetically quote it. 4355515ec619Smrg func_quote_arg pretty "$nonopt" 4356515ec619Smrg install_prog="$func_quote_arg_result " 43577a3b38f7Smrg arg=$1 43587a3b38f7Smrg shift 43597a3b38f7Smrg else 43607a3b38f7Smrg install_prog= 43617a3b38f7Smrg arg=$nonopt 43627a3b38f7Smrg fi 4363ff559fabSmrg 43647a3b38f7Smrg # The real first argument should be the name of the installation program. 43657a3b38f7Smrg # Aesthetically quote it. 4366515ec619Smrg func_quote_arg pretty "$arg" 4367515ec619Smrg func_append install_prog "$func_quote_arg_result" 436844dda7b2Smrg install_shared_prog=$install_prog 436944dda7b2Smrg case " $install_prog " in 437044dda7b2Smrg *[\\\ /]cp\ *) install_cp=: ;; 437144dda7b2Smrg *) install_cp=false ;; 437244dda7b2Smrg esac 43737a3b38f7Smrg 43747a3b38f7Smrg # We need to accept at least all the BSD install flags. 43757a3b38f7Smrg dest= 43767a3b38f7Smrg files= 43777a3b38f7Smrg opts= 43787a3b38f7Smrg prev= 43797a3b38f7Smrg install_type= 43806fc0178dSmrg isdir=false 43817a3b38f7Smrg stripme= 438244dda7b2Smrg no_mode=: 43837a3b38f7Smrg for arg 43847a3b38f7Smrg do 438544dda7b2Smrg arg2= 43867a3b38f7Smrg if test -n "$dest"; then 4387862f5301Smrg func_append files " $dest" 43887a3b38f7Smrg dest=$arg 43897a3b38f7Smrg continue 4390ff559fabSmrg fi 4391ff559fabSmrg 43927a3b38f7Smrg case $arg in 43936fc0178dSmrg -d) isdir=: ;; 43947a3b38f7Smrg -f) 439544dda7b2Smrg if $install_cp; then :; else 439644dda7b2Smrg prev=$arg 439744dda7b2Smrg fi 43987a3b38f7Smrg ;; 43997a3b38f7Smrg -g | -m | -o) 44007a3b38f7Smrg prev=$arg 44017a3b38f7Smrg ;; 44027a3b38f7Smrg -s) 44037a3b38f7Smrg stripme=" -s" 44047a3b38f7Smrg continue 44057a3b38f7Smrg ;; 44067a3b38f7Smrg -*) 44077a3b38f7Smrg ;; 44087a3b38f7Smrg *) 44097a3b38f7Smrg # If the previous option needed an argument, then skip it. 44107a3b38f7Smrg if test -n "$prev"; then 44116fc0178dSmrg if test X-m = "X$prev" && test -n "$install_override_mode"; then 441244dda7b2Smrg arg2=$install_override_mode 441344dda7b2Smrg no_mode=false 441444dda7b2Smrg fi 44157a3b38f7Smrg prev= 44167a3b38f7Smrg else 44177a3b38f7Smrg dest=$arg 44187a3b38f7Smrg continue 44197a3b38f7Smrg fi 44207a3b38f7Smrg ;; 44217a3b38f7Smrg esac 4422ff559fabSmrg 44237a3b38f7Smrg # Aesthetically quote the argument. 4424515ec619Smrg func_quote_arg pretty "$arg" 4425515ec619Smrg func_append install_prog " $func_quote_arg_result" 442644dda7b2Smrg if test -n "$arg2"; then 4427515ec619Smrg func_quote_arg pretty "$arg2" 442844dda7b2Smrg fi 4429515ec619Smrg func_append install_shared_prog " $func_quote_arg_result" 44307a3b38f7Smrg done 4431ff559fabSmrg 44327a3b38f7Smrg test -z "$install_prog" && \ 44337a3b38f7Smrg func_fatal_help "you must specify an install program" 4434ff559fabSmrg 44357a3b38f7Smrg test -n "$prev" && \ 44366fc0178dSmrg func_fatal_help "the '$prev' option requires an argument" 4437ff559fabSmrg 443844dda7b2Smrg if test -n "$install_override_mode" && $no_mode; then 443944dda7b2Smrg if $install_cp; then :; else 4440515ec619Smrg func_quote_arg pretty "$install_override_mode" 4441515ec619Smrg func_append install_shared_prog " -m $func_quote_arg_result" 444244dda7b2Smrg fi 444344dda7b2Smrg fi 444444dda7b2Smrg 44457a3b38f7Smrg if test -z "$files"; then 44467a3b38f7Smrg if test -z "$dest"; then 44477a3b38f7Smrg func_fatal_help "no file or destination specified" 44487a3b38f7Smrg else 44497a3b38f7Smrg func_fatal_help "you must specify a destination" 4450ff559fabSmrg fi 4451ff559fabSmrg fi 4452ff559fabSmrg 44537a3b38f7Smrg # Strip any trailing slash from the destination. 44547a3b38f7Smrg func_stripname '' '/' "$dest" 44557a3b38f7Smrg dest=$func_stripname_result 4456ff559fabSmrg 44577a3b38f7Smrg # Check to see that the destination is a directory. 44586fc0178dSmrg test -d "$dest" && isdir=: 44596fc0178dSmrg if $isdir; then 44606fc0178dSmrg destdir=$dest 44617a3b38f7Smrg destname= 44627a3b38f7Smrg else 44637a3b38f7Smrg func_dirname_and_basename "$dest" "" "." 44646fc0178dSmrg destdir=$func_dirname_result 44656fc0178dSmrg destname=$func_basename_result 44667a3b38f7Smrg 44677a3b38f7Smrg # Not a directory, so check to see that there is only one file specified. 44687a3b38f7Smrg set dummy $files; shift 44697a3b38f7Smrg test "$#" -gt 1 && \ 44706fc0178dSmrg func_fatal_help "'$dest' is not a directory" 44717a3b38f7Smrg fi 44727a3b38f7Smrg case $destdir in 44737a3b38f7Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 4474ff559fabSmrg *) 44757a3b38f7Smrg for file in $files; do 44767a3b38f7Smrg case $file in 44777a3b38f7Smrg *.lo) ;; 44787a3b38f7Smrg *) 44796fc0178dSmrg func_fatal_help "'$destdir' must be an absolute directory name" 44807a3b38f7Smrg ;; 44817a3b38f7Smrg esac 44827a3b38f7Smrg done 4483ff559fabSmrg ;; 4484ff559fabSmrg esac 4485ff559fabSmrg 44867a3b38f7Smrg # This variable tells wrapper scripts just to set variables rather 44877a3b38f7Smrg # than running their programs. 44886fc0178dSmrg libtool_install_magic=$magic 4489ff559fabSmrg 44907a3b38f7Smrg staticlibs= 44917a3b38f7Smrg future_libdirs= 44927a3b38f7Smrg current_libdirs= 44937a3b38f7Smrg for file in $files; do 4494ff559fabSmrg 44957a3b38f7Smrg # Do each installation. 44967a3b38f7Smrg case $file in 44977a3b38f7Smrg *.$libext) 44987a3b38f7Smrg # Do the static libraries later. 4499862f5301Smrg func_append staticlibs " $file" 45007a3b38f7Smrg ;; 45017a3b38f7Smrg 45027a3b38f7Smrg *.la) 4503862f5301Smrg func_resolve_sysroot "$file" 4504862f5301Smrg file=$func_resolve_sysroot_result 4505862f5301Smrg 45067a3b38f7Smrg # Check to see that this really is a libtool archive. 45077a3b38f7Smrg func_lalib_unsafe_p "$file" \ 45086fc0178dSmrg || func_fatal_help "'$file' is not a valid libtool archive" 45097a3b38f7Smrg 45107a3b38f7Smrg library_names= 45117a3b38f7Smrg old_library= 45127a3b38f7Smrg relink_command= 45137a3b38f7Smrg func_source "$file" 45147a3b38f7Smrg 45157a3b38f7Smrg # Add the libdir to current_libdirs if it is the destination. 45167a3b38f7Smrg if test "X$destdir" = "X$libdir"; then 45177a3b38f7Smrg case "$current_libdirs " in 45187a3b38f7Smrg *" $libdir "*) ;; 4519862f5301Smrg *) func_append current_libdirs " $libdir" ;; 4520ff559fabSmrg esac 45217a3b38f7Smrg else 45227a3b38f7Smrg # Note the libdir as a future libdir. 45237a3b38f7Smrg case "$future_libdirs " in 45247a3b38f7Smrg *" $libdir "*) ;; 4525862f5301Smrg *) func_append future_libdirs " $libdir" ;; 45267a3b38f7Smrg esac 45277a3b38f7Smrg fi 4528ff559fabSmrg 45297a3b38f7Smrg func_dirname "$file" "/" "" 45306fc0178dSmrg dir=$func_dirname_result 4531862f5301Smrg func_append dir "$objdir" 45327a3b38f7Smrg 45337a3b38f7Smrg if test -n "$relink_command"; then 45347a3b38f7Smrg # Determine the prefix the user has applied to our future dir. 453544dda7b2Smrg inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` 45367a3b38f7Smrg 45377a3b38f7Smrg # Don't allow the user to place us outside of our expected 45387a3b38f7Smrg # location b/c this prevents finding dependent libraries that 45397a3b38f7Smrg # are installed to the same prefix. 45407a3b38f7Smrg # At present, this check doesn't affect windows .dll's that 45417a3b38f7Smrg # are installed into $libdir/../bin (currently, that works fine) 45427a3b38f7Smrg # but it's something to keep an eye on. 45437a3b38f7Smrg test "$inst_prefix_dir" = "$destdir" && \ 45446fc0178dSmrg func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir" 45457a3b38f7Smrg 45467a3b38f7Smrg if test -n "$inst_prefix_dir"; then 45477a3b38f7Smrg # Stick the inst_prefix_dir data into the link command. 454844dda7b2Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` 45497a3b38f7Smrg else 455044dda7b2Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` 45517a3b38f7Smrg fi 45527a3b38f7Smrg 45536fc0178dSmrg func_warning "relinking '$file'" 45547a3b38f7Smrg func_show_eval "$relink_command" \ 45556fc0178dSmrg 'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"' 45567a3b38f7Smrg fi 45577a3b38f7Smrg 45587a3b38f7Smrg # See the names of the shared library. 45597a3b38f7Smrg set dummy $library_names; shift 45607a3b38f7Smrg if test -n "$1"; then 45616fc0178dSmrg realname=$1 45627a3b38f7Smrg shift 45637a3b38f7Smrg 45646fc0178dSmrg srcname=$realname 45656fc0178dSmrg test -n "$relink_command" && srcname=${realname}T 45667a3b38f7Smrg 45677a3b38f7Smrg # Install the shared library and build the symlinks. 456844dda7b2Smrg func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ 45697a3b38f7Smrg 'exit $?' 45706fc0178dSmrg tstripme=$stripme 45717a3b38f7Smrg case $host_os in 45727a3b38f7Smrg cygwin* | mingw* | pw32* | cegcc*) 45737a3b38f7Smrg case $realname in 45747a3b38f7Smrg *.dll.a) 45756fc0178dSmrg tstripme= 45766fc0178dSmrg ;; 45776fc0178dSmrg esac 45786fc0178dSmrg ;; 45796fc0178dSmrg os2*) 45806fc0178dSmrg case $realname in 45816fc0178dSmrg *_dll.a) 45826fc0178dSmrg tstripme= 45837a3b38f7Smrg ;; 45847a3b38f7Smrg esac 4585ff559fabSmrg ;; 4586ff559fabSmrg esac 45877a3b38f7Smrg if test -n "$tstripme" && test -n "$striplib"; then 45887a3b38f7Smrg func_show_eval "$striplib $destdir/$realname" 'exit $?' 4589ff559fabSmrg fi 45907a3b38f7Smrg 45917a3b38f7Smrg if test "$#" -gt 0; then 45927a3b38f7Smrg # Delete the old symlinks, and create new ones. 45936fc0178dSmrg # Try 'ln -sf' first, because the 'ln' binary might depend on 45947a3b38f7Smrg # the symlink we replace! Solaris /bin/ln does not understand -f, 45957a3b38f7Smrg # so we also need to try rm && ln -s. 45967a3b38f7Smrg for linkname 45977a3b38f7Smrg do 45987a3b38f7Smrg test "$linkname" != "$realname" \ 45997a3b38f7Smrg && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" 4600ff559fabSmrg done 4601ff559fabSmrg fi 4602ff559fabSmrg 46037a3b38f7Smrg # Do each command in the postinstall commands. 46046fc0178dSmrg lib=$destdir/$realname 46057a3b38f7Smrg func_execute_cmds "$postinstall_cmds" 'exit $?' 4606ff559fabSmrg fi 4607ff559fabSmrg 46087a3b38f7Smrg # Install the pseudo-library for information purposes. 46097a3b38f7Smrg func_basename "$file" 46106fc0178dSmrg name=$func_basename_result 46116fc0178dSmrg instname=$dir/${name}i 46127a3b38f7Smrg func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' 4613ff559fabSmrg 46147a3b38f7Smrg # Maybe install the static library, too. 4615862f5301Smrg test -n "$old_library" && func_append staticlibs " $dir/$old_library" 46167a3b38f7Smrg ;; 4617ff559fabSmrg 46187a3b38f7Smrg *.lo) 46197a3b38f7Smrg # Install (i.e. copy) a libtool object. 4620ff559fabSmrg 46217a3b38f7Smrg # Figure out destination file name, if it wasn't already specified. 46227a3b38f7Smrg if test -n "$destname"; then 46236fc0178dSmrg destfile=$destdir/$destname 46247a3b38f7Smrg else 46257a3b38f7Smrg func_basename "$file" 46266fc0178dSmrg destfile=$func_basename_result 46276fc0178dSmrg destfile=$destdir/$destfile 46287a3b38f7Smrg fi 46297a3b38f7Smrg 46307a3b38f7Smrg # Deduce the name of the destination old-style object file. 46317a3b38f7Smrg case $destfile in 46327a3b38f7Smrg *.lo) 46337a3b38f7Smrg func_lo2o "$destfile" 46347a3b38f7Smrg staticdest=$func_lo2o_result 46357a3b38f7Smrg ;; 46367a3b38f7Smrg *.$objext) 46376fc0178dSmrg staticdest=$destfile 46387a3b38f7Smrg destfile= 46397a3b38f7Smrg ;; 46407a3b38f7Smrg *) 46416fc0178dSmrg func_fatal_help "cannot copy a libtool object to '$destfile'" 46427a3b38f7Smrg ;; 4643ff559fabSmrg esac 4644ff559fabSmrg 46457a3b38f7Smrg # Install the libtool object if requested. 46467a3b38f7Smrg test -n "$destfile" && \ 46477a3b38f7Smrg func_show_eval "$install_prog $file $destfile" 'exit $?' 46487a3b38f7Smrg 46497a3b38f7Smrg # Install the old object if enabled. 46506fc0178dSmrg if test yes = "$build_old_libs"; then 46517a3b38f7Smrg # Deduce the name of the old-style object file. 46527a3b38f7Smrg func_lo2o "$file" 46537a3b38f7Smrg staticobj=$func_lo2o_result 46547a3b38f7Smrg func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' 4655ff559fabSmrg fi 46567a3b38f7Smrg exit $EXIT_SUCCESS 46577a3b38f7Smrg ;; 4658ff559fabSmrg 46597a3b38f7Smrg *) 46607a3b38f7Smrg # Figure out destination file name, if it wasn't already specified. 46617a3b38f7Smrg if test -n "$destname"; then 46626fc0178dSmrg destfile=$destdir/$destname 46637a3b38f7Smrg else 46647a3b38f7Smrg func_basename "$file" 46656fc0178dSmrg destfile=$func_basename_result 46666fc0178dSmrg destfile=$destdir/$destfile 46677a3b38f7Smrg fi 46687a3b38f7Smrg 46697a3b38f7Smrg # If the file is missing, and there is a .exe on the end, strip it 46707a3b38f7Smrg # because it is most likely a libtool script we actually want to 46717a3b38f7Smrg # install 46726fc0178dSmrg stripped_ext= 46737a3b38f7Smrg case $file in 46747a3b38f7Smrg *.exe) 46757a3b38f7Smrg if test ! -f "$file"; then 46767a3b38f7Smrg func_stripname '' '.exe' "$file" 46777a3b38f7Smrg file=$func_stripname_result 46786fc0178dSmrg stripped_ext=.exe 4679ff559fabSmrg fi 46807a3b38f7Smrg ;; 46817a3b38f7Smrg esac 4682ff559fabSmrg 46837a3b38f7Smrg # Do a test to see if this is really a libtool program. 46847a3b38f7Smrg case $host in 46857a3b38f7Smrg *cygwin* | *mingw*) 46867a3b38f7Smrg if func_ltwrapper_executable_p "$file"; then 46877a3b38f7Smrg func_ltwrapper_scriptname "$file" 46887a3b38f7Smrg wrapper=$func_ltwrapper_scriptname_result 46897a3b38f7Smrg else 46907a3b38f7Smrg func_stripname '' '.exe' "$file" 46917a3b38f7Smrg wrapper=$func_stripname_result 46927a3b38f7Smrg fi 46937a3b38f7Smrg ;; 46947a3b38f7Smrg *) 46957a3b38f7Smrg wrapper=$file 46967a3b38f7Smrg ;; 46977a3b38f7Smrg esac 46987a3b38f7Smrg if func_ltwrapper_script_p "$wrapper"; then 46997a3b38f7Smrg notinst_deplibs= 47007a3b38f7Smrg relink_command= 4701ff559fabSmrg 47027a3b38f7Smrg func_source "$wrapper" 4703ff559fabSmrg 47047a3b38f7Smrg # Check the variables that should have been set. 47057a3b38f7Smrg test -z "$generated_by_libtool_version" && \ 47066fc0178dSmrg func_fatal_error "invalid libtool wrapper script '$wrapper'" 47077a3b38f7Smrg 47086fc0178dSmrg finalize=: 47097a3b38f7Smrg for lib in $notinst_deplibs; do 47107a3b38f7Smrg # Check to see that each library is installed. 47117a3b38f7Smrg libdir= 47127a3b38f7Smrg if test -f "$lib"; then 47137a3b38f7Smrg func_source "$lib" 47147a3b38f7Smrg fi 47156fc0178dSmrg libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'` 47167a3b38f7Smrg if test -n "$libdir" && test ! -f "$libfile"; then 47176fc0178dSmrg func_warning "'$lib' has not been installed in '$libdir'" 47186fc0178dSmrg finalize=false 47197a3b38f7Smrg fi 47207a3b38f7Smrg done 47217a3b38f7Smrg 47227a3b38f7Smrg relink_command= 47237a3b38f7Smrg func_source "$wrapper" 47247a3b38f7Smrg 47257a3b38f7Smrg outputname= 47266fc0178dSmrg if test no = "$fast_install" && test -n "$relink_command"; then 47277a3b38f7Smrg $opt_dry_run || { 47286fc0178dSmrg if $finalize; then 47297a3b38f7Smrg tmpdir=`func_mktempdir` 47307a3b38f7Smrg func_basename "$file$stripped_ext" 47316fc0178dSmrg file=$func_basename_result 47326fc0178dSmrg outputname=$tmpdir/$file 47337a3b38f7Smrg # Replace the output file specification. 473444dda7b2Smrg relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` 47357a3b38f7Smrg 47366fc0178dSmrg $opt_quiet || { 4737515ec619Smrg func_quote_arg expand,pretty "$relink_command" 4738515ec619Smrg eval "func_echo $func_quote_arg_result" 47397a3b38f7Smrg } 47407a3b38f7Smrg if eval "$relink_command"; then : 47417a3b38f7Smrg else 47426fc0178dSmrg func_error "error: relink '$file' with the above command before installing it" 47437a3b38f7Smrg $opt_dry_run || ${RM}r "$tmpdir" 47447a3b38f7Smrg continue 47457a3b38f7Smrg fi 47466fc0178dSmrg file=$outputname 47477a3b38f7Smrg else 47486fc0178dSmrg func_warning "cannot relink '$file'" 47497a3b38f7Smrg fi 47507a3b38f7Smrg } 4751ff559fabSmrg else 47527a3b38f7Smrg # Install the binary that we compiled earlier. 475344dda7b2Smrg file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` 4754ff559fabSmrg fi 47557a3b38f7Smrg fi 4756ff559fabSmrg 47577a3b38f7Smrg # remove .exe since cygwin /usr/bin/install will append another 47587a3b38f7Smrg # one anyway 47597a3b38f7Smrg case $install_prog,$host in 47607a3b38f7Smrg */usr/bin/install*,*cygwin*) 47617a3b38f7Smrg case $file:$destfile in 47627a3b38f7Smrg *.exe:*.exe) 47637a3b38f7Smrg # this is ok 47647a3b38f7Smrg ;; 47657a3b38f7Smrg *.exe:*) 47667a3b38f7Smrg destfile=$destfile.exe 47677a3b38f7Smrg ;; 47687a3b38f7Smrg *:*.exe) 47697a3b38f7Smrg func_stripname '' '.exe' "$destfile" 47707a3b38f7Smrg destfile=$func_stripname_result 47717a3b38f7Smrg ;; 47727a3b38f7Smrg esac 4773ff559fabSmrg ;; 4774ff559fabSmrg esac 47757a3b38f7Smrg func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' 47767a3b38f7Smrg $opt_dry_run || if test -n "$outputname"; then 47777a3b38f7Smrg ${RM}r "$tmpdir" 47787a3b38f7Smrg fi 47797a3b38f7Smrg ;; 47807a3b38f7Smrg esac 47817a3b38f7Smrg done 4782ff559fabSmrg 47837a3b38f7Smrg for file in $staticlibs; do 47847a3b38f7Smrg func_basename "$file" 47856fc0178dSmrg name=$func_basename_result 4786ff559fabSmrg 47877a3b38f7Smrg # Set up the ranlib parameters. 47886fc0178dSmrg oldlib=$destdir/$name 4789fc544a13Smrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 4790fc544a13Smrg tool_oldlib=$func_to_tool_file_result 4791ff559fabSmrg 47927a3b38f7Smrg func_show_eval "$install_prog \$file \$oldlib" 'exit $?' 4793ff559fabSmrg 47947a3b38f7Smrg if test -n "$stripme" && test -n "$old_striplib"; then 4795fc544a13Smrg func_show_eval "$old_striplib $tool_oldlib" 'exit $?' 47967a3b38f7Smrg fi 4797ff559fabSmrg 47987a3b38f7Smrg # Do each command in the postinstall commands. 47997a3b38f7Smrg func_execute_cmds "$old_postinstall_cmds" 'exit $?' 48007a3b38f7Smrg done 4801ff559fabSmrg 48027a3b38f7Smrg test -n "$future_libdirs" && \ 48036fc0178dSmrg func_warning "remember to run '$progname --finish$future_libdirs'" 4804ff559fabSmrg 48057a3b38f7Smrg if test -n "$current_libdirs"; then 48067a3b38f7Smrg # Maybe just do a dry run. 48077a3b38f7Smrg $opt_dry_run && current_libdirs=" -n$current_libdirs" 48086fc0178dSmrg exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs' 48097a3b38f7Smrg else 48107a3b38f7Smrg exit $EXIT_SUCCESS 48117a3b38f7Smrg fi 48127a3b38f7Smrg} 4813ff559fabSmrg 48146fc0178dSmrgtest install = "$opt_mode" && func_mode_install ${1+"$@"} 4815ff559fabSmrg 4816ff559fabSmrg 48177a3b38f7Smrg# func_generate_dlsyms outputname originator pic_p 48187a3b38f7Smrg# Extract symbols from dlprefiles and create ${outputname}S.o with 48197a3b38f7Smrg# a dlpreopen symbol table. 48207a3b38f7Smrgfunc_generate_dlsyms () 48217a3b38f7Smrg{ 48226fc0178dSmrg $debug_cmd 48236fc0178dSmrg 48246fc0178dSmrg my_outputname=$1 48256fc0178dSmrg my_originator=$2 48266fc0178dSmrg my_pic_p=${3-false} 48276fc0178dSmrg my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'` 48287a3b38f7Smrg my_dlsyms= 48297a3b38f7Smrg 48306fc0178dSmrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 48317a3b38f7Smrg if test -n "$NM" && test -n "$global_symbol_pipe"; then 48326fc0178dSmrg my_dlsyms=${my_outputname}S.c 48337a3b38f7Smrg else 48347a3b38f7Smrg func_error "not configured to extract global symbols from dlpreopened files" 48357a3b38f7Smrg fi 48367a3b38f7Smrg fi 4837ff559fabSmrg 48387a3b38f7Smrg if test -n "$my_dlsyms"; then 48397a3b38f7Smrg case $my_dlsyms in 48407a3b38f7Smrg "") ;; 48417a3b38f7Smrg *.c) 48427a3b38f7Smrg # Discover the nlist of each of the dlfiles. 48436fc0178dSmrg nlist=$output_objdir/$my_outputname.nm 48447a3b38f7Smrg 48457a3b38f7Smrg func_show_eval "$RM $nlist ${nlist}S ${nlist}T" 48467a3b38f7Smrg 48477a3b38f7Smrg # Parse the name list into a source file. 48487a3b38f7Smrg func_verbose "creating $output_objdir/$my_dlsyms" 48497a3b38f7Smrg 48507a3b38f7Smrg $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ 48516fc0178dSmrg/* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */ 48526fc0178dSmrg/* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */ 48537a3b38f7Smrg 48547a3b38f7Smrg#ifdef __cplusplus 48557a3b38f7Smrgextern \"C\" { 48567a3b38f7Smrg#endif 48577a3b38f7Smrg 48586fc0178dSmrg#if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) 485944dda7b2Smrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\" 486044dda7b2Smrg#endif 486144dda7b2Smrg 4862862f5301Smrg/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ 48636fc0178dSmrg#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE 48646fc0178dSmrg/* DATA imports from DLLs on WIN32 can't be const, because runtime 4865862f5301Smrg relocations are performed -- see ld's documentation on pseudo-relocs. */ 4866862f5301Smrg# define LT_DLSYM_CONST 48676fc0178dSmrg#elif defined __osf__ 4868862f5301Smrg/* This system does not cope well with relocations in const data. */ 4869862f5301Smrg# define LT_DLSYM_CONST 4870862f5301Smrg#else 4871862f5301Smrg# define LT_DLSYM_CONST const 4872862f5301Smrg#endif 4873862f5301Smrg 48746fc0178dSmrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 48756fc0178dSmrg 48767a3b38f7Smrg/* External symbol declarations for the compiler. */\ 48777a3b38f7Smrg" 48787a3b38f7Smrg 48796fc0178dSmrg if test yes = "$dlself"; then 48806fc0178dSmrg func_verbose "generating symbol list for '$output'" 48817a3b38f7Smrg 48827a3b38f7Smrg $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" 48837a3b38f7Smrg 48847a3b38f7Smrg # Add our own program objects to the symbol list. 488544dda7b2Smrg progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` 48867a3b38f7Smrg for progfile in $progfiles; do 4887862f5301Smrg func_to_tool_file "$progfile" func_convert_file_msys_to_w32 48886fc0178dSmrg func_verbose "extracting global C symbols from '$func_to_tool_file_result'" 4889862f5301Smrg $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" 48907a3b38f7Smrg done 48917a3b38f7Smrg 48927a3b38f7Smrg if test -n "$exclude_expsyms"; then 48937a3b38f7Smrg $opt_dry_run || { 48947a3b38f7Smrg eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' 48957a3b38f7Smrg eval '$MV "$nlist"T "$nlist"' 48967a3b38f7Smrg } 4897ff559fabSmrg fi 4898ff559fabSmrg 48997a3b38f7Smrg if test -n "$export_symbols_regex"; then 49007a3b38f7Smrg $opt_dry_run || { 49017a3b38f7Smrg eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' 49027a3b38f7Smrg eval '$MV "$nlist"T "$nlist"' 49037a3b38f7Smrg } 4904ff559fabSmrg fi 49057a3b38f7Smrg 49067a3b38f7Smrg # Prepare the list of exported symbols 49077a3b38f7Smrg if test -z "$export_symbols"; then 49086fc0178dSmrg export_symbols=$output_objdir/$outputname.exp 49097a3b38f7Smrg $opt_dry_run || { 49107a3b38f7Smrg $RM $export_symbols 49116fc0178dSmrg eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' 49127a3b38f7Smrg case $host in 49137a3b38f7Smrg *cygwin* | *mingw* | *cegcc* ) 49147a3b38f7Smrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 49157a3b38f7Smrg eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' 49167a3b38f7Smrg ;; 4917ff559fabSmrg esac 49187a3b38f7Smrg } 49197a3b38f7Smrg else 49207a3b38f7Smrg $opt_dry_run || { 49216fc0178dSmrg eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' 49227a3b38f7Smrg eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' 49237a3b38f7Smrg eval '$MV "$nlist"T "$nlist"' 49247a3b38f7Smrg case $host in 492544dda7b2Smrg *cygwin* | *mingw* | *cegcc* ) 49267a3b38f7Smrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 49277a3b38f7Smrg eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' 49287a3b38f7Smrg ;; 4929ff559fabSmrg esac 49307a3b38f7Smrg } 4931ff559fabSmrg fi 49327a3b38f7Smrg fi 4933ff559fabSmrg 49347a3b38f7Smrg for dlprefile in $dlprefiles; do 49356fc0178dSmrg func_verbose "extracting global C symbols from '$dlprefile'" 49367a3b38f7Smrg func_basename "$dlprefile" 49376fc0178dSmrg name=$func_basename_result 4938862f5301Smrg case $host in 4939862f5301Smrg *cygwin* | *mingw* | *cegcc* ) 4940862f5301Smrg # if an import library, we need to obtain dlname 4941862f5301Smrg if func_win32_import_lib_p "$dlprefile"; then 4942862f5301Smrg func_tr_sh "$dlprefile" 4943862f5301Smrg eval "curr_lafile=\$libfile_$func_tr_sh_result" 49446fc0178dSmrg dlprefile_dlbasename= 4945862f5301Smrg if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then 4946862f5301Smrg # Use subshell, to avoid clobbering current variable values 4947862f5301Smrg dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` 49486fc0178dSmrg if test -n "$dlprefile_dlname"; then 4949862f5301Smrg func_basename "$dlprefile_dlname" 49506fc0178dSmrg dlprefile_dlbasename=$func_basename_result 4951862f5301Smrg else 4952862f5301Smrg # no lafile. user explicitly requested -dlpreopen <import library>. 4953862f5301Smrg $sharedlib_from_linklib_cmd "$dlprefile" 4954862f5301Smrg dlprefile_dlbasename=$sharedlib_from_linklib_result 4955862f5301Smrg fi 4956862f5301Smrg fi 4957862f5301Smrg $opt_dry_run || { 49586fc0178dSmrg if test -n "$dlprefile_dlbasename"; then 4959862f5301Smrg eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' 4960862f5301Smrg else 4961862f5301Smrg func_warning "Could not compute DLL name from $name" 4962862f5301Smrg eval '$ECHO ": $name " >> "$nlist"' 4963862f5301Smrg fi 4964862f5301Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 4965862f5301Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | 4966862f5301Smrg $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" 4967862f5301Smrg } 4968862f5301Smrg else # not an import lib 4969862f5301Smrg $opt_dry_run || { 4970862f5301Smrg eval '$ECHO ": $name " >> "$nlist"' 4971862f5301Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 4972862f5301Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 4973862f5301Smrg } 4974862f5301Smrg fi 4975862f5301Smrg ;; 4976862f5301Smrg *) 4977862f5301Smrg $opt_dry_run || { 4978862f5301Smrg eval '$ECHO ": $name " >> "$nlist"' 4979862f5301Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 4980862f5301Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 4981862f5301Smrg } 4982862f5301Smrg ;; 4983862f5301Smrg esac 49847a3b38f7Smrg done 4985ff559fabSmrg 49867a3b38f7Smrg $opt_dry_run || { 49877a3b38f7Smrg # Make sure we have at least an empty file. 49887a3b38f7Smrg test -f "$nlist" || : > "$nlist" 4989ff559fabSmrg 49907a3b38f7Smrg if test -n "$exclude_expsyms"; then 49917a3b38f7Smrg $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T 49927a3b38f7Smrg $MV "$nlist"T "$nlist" 4993ff559fabSmrg fi 4994ff559fabSmrg 49957a3b38f7Smrg # Try sorting and uniquifying the output. 49967a3b38f7Smrg if $GREP -v "^: " < "$nlist" | 49977a3b38f7Smrg if sort -k 3 </dev/null >/dev/null 2>&1; then 49987a3b38f7Smrg sort -k 3 4999ff559fabSmrg else 50007a3b38f7Smrg sort +2 50017a3b38f7Smrg fi | 50027a3b38f7Smrg uniq > "$nlist"S; then 50037a3b38f7Smrg : 5004ff559fabSmrg else 50057a3b38f7Smrg $GREP -v "^: " < "$nlist" > "$nlist"S 5006ff559fabSmrg fi 5007ff559fabSmrg 50087a3b38f7Smrg if test -f "$nlist"S; then 50097a3b38f7Smrg eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' 5010ff559fabSmrg else 501144dda7b2Smrg echo '/* NONE */' >> "$output_objdir/$my_dlsyms" 5012ff559fabSmrg fi 5013ff559fabSmrg 50146fc0178dSmrg func_show_eval '$RM "${nlist}I"' 50156fc0178dSmrg if test -n "$global_symbol_to_import"; then 50166fc0178dSmrg eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I' 50176fc0178dSmrg fi 50186fc0178dSmrg 501944dda7b2Smrg echo >> "$output_objdir/$my_dlsyms" "\ 5020ff559fabSmrg 50217a3b38f7Smrg/* The mapping between symbol names and symbols. */ 50227a3b38f7Smrgtypedef struct { 50237a3b38f7Smrg const char *name; 50247a3b38f7Smrg void *address; 50257a3b38f7Smrg} lt_dlsymlist; 5026862f5301Smrgextern LT_DLSYM_CONST lt_dlsymlist 50276fc0178dSmrglt_${my_prefix}_LTX_preloaded_symbols[];\ 50286fc0178dSmrg" 50296fc0178dSmrg 50306fc0178dSmrg if test -s "$nlist"I; then 50316fc0178dSmrg echo >> "$output_objdir/$my_dlsyms" "\ 50326fc0178dSmrgstatic void lt_syminit(void) 50336fc0178dSmrg{ 50346fc0178dSmrg LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols; 50356fc0178dSmrg for (; symbol->name; ++symbol) 50366fc0178dSmrg {" 50376fc0178dSmrg $SED 's/.*/ if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms" 50386fc0178dSmrg echo >> "$output_objdir/$my_dlsyms" "\ 50396fc0178dSmrg } 50406fc0178dSmrg}" 50416fc0178dSmrg fi 50426fc0178dSmrg echo >> "$output_objdir/$my_dlsyms" "\ 5043862f5301SmrgLT_DLSYM_CONST lt_dlsymlist 50447a3b38f7Smrglt_${my_prefix}_LTX_preloaded_symbols[] = 50456fc0178dSmrg{ {\"$my_originator\", (void *) 0}," 50466fc0178dSmrg 50476fc0178dSmrg if test -s "$nlist"I; then 50486fc0178dSmrg echo >> "$output_objdir/$my_dlsyms" "\ 50496fc0178dSmrg {\"@INIT@\", (void *) <_syminit}," 50506fc0178dSmrg fi 50517a3b38f7Smrg 50527a3b38f7Smrg case $need_lib_prefix in 50537a3b38f7Smrg no) 50547a3b38f7Smrg eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" 50557a3b38f7Smrg ;; 50567a3b38f7Smrg *) 50577a3b38f7Smrg eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" 50587a3b38f7Smrg ;; 50597a3b38f7Smrg esac 506044dda7b2Smrg echo >> "$output_objdir/$my_dlsyms" "\ 50617a3b38f7Smrg {0, (void *) 0} 50627a3b38f7Smrg}; 50637a3b38f7Smrg 50647a3b38f7Smrg/* This works around a problem in FreeBSD linker */ 50657a3b38f7Smrg#ifdef FREEBSD_WORKAROUND 50667a3b38f7Smrgstatic const void *lt_preloaded_setup() { 50677a3b38f7Smrg return lt_${my_prefix}_LTX_preloaded_symbols; 50687a3b38f7Smrg} 50697a3b38f7Smrg#endif 50707a3b38f7Smrg 50717a3b38f7Smrg#ifdef __cplusplus 50727a3b38f7Smrg} 50737a3b38f7Smrg#endif\ 50747a3b38f7Smrg" 50757a3b38f7Smrg } # !$opt_dry_run 50767a3b38f7Smrg 50777a3b38f7Smrg pic_flag_for_symtable= 50787a3b38f7Smrg case "$compile_command " in 50797a3b38f7Smrg *" -static "*) ;; 50807a3b38f7Smrg *) 50817a3b38f7Smrg case $host in 50827a3b38f7Smrg # compiling the symbol table file with pic_flag works around 50837a3b38f7Smrg # a FreeBSD bug that causes programs to crash when -lm is 50847a3b38f7Smrg # linked before any other PIC object. But we must not use 50857a3b38f7Smrg # pic_flag when linking with -static. The problem exists in 50867a3b38f7Smrg # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. 5087fc544a13Smrg *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) 50887a3b38f7Smrg pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; 50897a3b38f7Smrg *-*-hpux*) 50907a3b38f7Smrg pic_flag_for_symtable=" $pic_flag" ;; 50917a3b38f7Smrg *) 50926fc0178dSmrg $my_pic_p && pic_flag_for_symtable=" $pic_flag" 50937a3b38f7Smrg ;; 50947a3b38f7Smrg esac 50957a3b38f7Smrg ;; 50967a3b38f7Smrg esac 50977a3b38f7Smrg symtab_cflags= 50987a3b38f7Smrg for arg in $LTCFLAGS; do 50997a3b38f7Smrg case $arg in 51007a3b38f7Smrg -pie | -fpie | -fPIE) ;; 5101862f5301Smrg *) func_append symtab_cflags " $arg" ;; 51027a3b38f7Smrg esac 51037a3b38f7Smrg done 5104ff559fabSmrg 51057a3b38f7Smrg # Now compile the dynamic symbol file. 51067a3b38f7Smrg func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' 5107ff559fabSmrg 51087a3b38f7Smrg # Clean up the generated files. 51096fc0178dSmrg func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"' 51107a3b38f7Smrg 51117a3b38f7Smrg # Transform the symbol file into the correct name. 51126fc0178dSmrg symfileobj=$output_objdir/${my_outputname}S.$objext 51137a3b38f7Smrg case $host in 51147a3b38f7Smrg *cygwin* | *mingw* | *cegcc* ) 51157a3b38f7Smrg if test -f "$output_objdir/$my_outputname.def"; then 511644dda7b2Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 511744dda7b2Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 51187a3b38f7Smrg else 511944dda7b2Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 512044dda7b2Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 51217a3b38f7Smrg fi 51227a3b38f7Smrg ;; 51237a3b38f7Smrg *) 512444dda7b2Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 512544dda7b2Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 5126ff559fabSmrg ;; 5127ff559fabSmrg esac 51287a3b38f7Smrg ;; 51297a3b38f7Smrg *) 51306fc0178dSmrg func_fatal_error "unknown suffix for '$my_dlsyms'" 51317a3b38f7Smrg ;; 51327a3b38f7Smrg esac 51337a3b38f7Smrg else 51347a3b38f7Smrg # We keep going just in case the user didn't refer to 51357a3b38f7Smrg # lt_preloaded_symbols. The linker will fail if global_symbol_pipe 51367a3b38f7Smrg # really was required. 51377a3b38f7Smrg 51387a3b38f7Smrg # Nullify the symbol file. 513944dda7b2Smrg compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` 514044dda7b2Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` 5141ff559fabSmrg fi 51427a3b38f7Smrg} 5143ff559fabSmrg 51446fc0178dSmrg# func_cygming_gnu_implib_p ARG 51456fc0178dSmrg# This predicate returns with zero status (TRUE) if 51466fc0178dSmrg# ARG is a GNU/binutils-style import library. Returns 51476fc0178dSmrg# with nonzero status (FALSE) otherwise. 51486fc0178dSmrgfunc_cygming_gnu_implib_p () 51496fc0178dSmrg{ 51506fc0178dSmrg $debug_cmd 51516fc0178dSmrg 51526fc0178dSmrg func_to_tool_file "$1" func_convert_file_msys_to_w32 51536fc0178dSmrg 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)$'` 51546fc0178dSmrg test -n "$func_cygming_gnu_implib_tmp" 51556fc0178dSmrg} 51566fc0178dSmrg 51576fc0178dSmrg# func_cygming_ms_implib_p ARG 51586fc0178dSmrg# This predicate returns with zero status (TRUE) if 51596fc0178dSmrg# ARG is an MS-style import library. Returns 51606fc0178dSmrg# with nonzero status (FALSE) otherwise. 51616fc0178dSmrgfunc_cygming_ms_implib_p () 51626fc0178dSmrg{ 51636fc0178dSmrg $debug_cmd 51646fc0178dSmrg 51656fc0178dSmrg func_to_tool_file "$1" func_convert_file_msys_to_w32 51666fc0178dSmrg func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` 51676fc0178dSmrg test -n "$func_cygming_ms_implib_tmp" 51686fc0178dSmrg} 51696fc0178dSmrg 51707a3b38f7Smrg# func_win32_libid arg 51717a3b38f7Smrg# return the library type of file 'arg' 51727a3b38f7Smrg# 51737a3b38f7Smrg# Need a lot of goo to handle *both* DLLs and import libs 51747a3b38f7Smrg# Has to be a shell function in order to 'eat' the argument 51757a3b38f7Smrg# that is supplied when $file_magic_command is called. 517644dda7b2Smrg# Despite the name, also deal with 64 bit binaries. 51777a3b38f7Smrgfunc_win32_libid () 51787a3b38f7Smrg{ 51796fc0178dSmrg $debug_cmd 51806fc0178dSmrg 51816fc0178dSmrg win32_libid_type=unknown 51827a3b38f7Smrg win32_fileres=`file -L $1 2>/dev/null` 51837a3b38f7Smrg case $win32_fileres in 51847a3b38f7Smrg *ar\ archive\ import\ library*) # definitely import 51857a3b38f7Smrg win32_libid_type="x86 archive import" 51867a3b38f7Smrg ;; 51877a3b38f7Smrg *ar\ archive*) # could be an import, or static 518844dda7b2Smrg # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. 51897a3b38f7Smrg if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | 519044dda7b2Smrg $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then 51916fc0178dSmrg case $nm_interface in 51926fc0178dSmrg "MS dumpbin") 51936fc0178dSmrg if func_cygming_ms_implib_p "$1" || 51946fc0178dSmrg func_cygming_gnu_implib_p "$1" 51956fc0178dSmrg then 51966fc0178dSmrg win32_nmres=import 51976fc0178dSmrg else 51986fc0178dSmrg win32_nmres= 51996fc0178dSmrg fi 52006fc0178dSmrg ;; 52016fc0178dSmrg *) 52026fc0178dSmrg func_to_tool_file "$1" func_convert_file_msys_to_w32 52036fc0178dSmrg win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | 52046fc0178dSmrg $SED -n -e ' 52057a3b38f7Smrg 1,100{ 52067a3b38f7Smrg / I /{ 52076fc0178dSmrg s|.*|import| 52087a3b38f7Smrg p 52097a3b38f7Smrg q 52107a3b38f7Smrg } 52117a3b38f7Smrg }'` 52126fc0178dSmrg ;; 52136fc0178dSmrg esac 52147a3b38f7Smrg case $win32_nmres in 52157a3b38f7Smrg import*) win32_libid_type="x86 archive import";; 52167a3b38f7Smrg *) win32_libid_type="x86 archive static";; 52177a3b38f7Smrg esac 52187a3b38f7Smrg fi 52197a3b38f7Smrg ;; 52207a3b38f7Smrg *DLL*) 52217a3b38f7Smrg win32_libid_type="x86 DLL" 52227a3b38f7Smrg ;; 52237a3b38f7Smrg *executable*) # but shell scripts are "executable" too... 52247a3b38f7Smrg case $win32_fileres in 52257a3b38f7Smrg *MS\ Windows\ PE\ Intel*) 52267a3b38f7Smrg win32_libid_type="x86 DLL" 52277a3b38f7Smrg ;; 52287a3b38f7Smrg esac 52297a3b38f7Smrg ;; 52307a3b38f7Smrg esac 52317a3b38f7Smrg $ECHO "$win32_libid_type" 52327a3b38f7Smrg} 5233ff559fabSmrg 5234862f5301Smrg# func_cygming_dll_for_implib ARG 5235862f5301Smrg# 5236862f5301Smrg# Platform-specific function to extract the 5237862f5301Smrg# name of the DLL associated with the specified 5238862f5301Smrg# import library ARG. 5239862f5301Smrg# Invoked by eval'ing the libtool variable 5240862f5301Smrg# $sharedlib_from_linklib_cmd 5241862f5301Smrg# Result is available in the variable 5242862f5301Smrg# $sharedlib_from_linklib_result 5243862f5301Smrgfunc_cygming_dll_for_implib () 5244862f5301Smrg{ 52456fc0178dSmrg $debug_cmd 52466fc0178dSmrg 5247862f5301Smrg sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` 5248862f5301Smrg} 5249862f5301Smrg 5250862f5301Smrg# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs 5251862f5301Smrg# 5252862f5301Smrg# The is the core of a fallback implementation of a 5253862f5301Smrg# platform-specific function to extract the name of the 5254862f5301Smrg# DLL associated with the specified import library LIBNAME. 5255862f5301Smrg# 5256862f5301Smrg# SECTION_NAME is either .idata$6 or .idata$7, depending 5257862f5301Smrg# on the platform and compiler that created the implib. 5258862f5301Smrg# 5259862f5301Smrg# Echos the name of the DLL associated with the 5260862f5301Smrg# specified import library. 5261862f5301Smrgfunc_cygming_dll_for_implib_fallback_core () 5262862f5301Smrg{ 52636fc0178dSmrg $debug_cmd 52646fc0178dSmrg 5265862f5301Smrg match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` 5266862f5301Smrg $OBJDUMP -s --section "$1" "$2" 2>/dev/null | 5267862f5301Smrg $SED '/^Contents of section '"$match_literal"':/{ 5268862f5301Smrg # Place marker at beginning of archive member dllname section 5269862f5301Smrg s/.*/====MARK====/ 5270862f5301Smrg p 5271862f5301Smrg d 5272862f5301Smrg } 5273862f5301Smrg # These lines can sometimes be longer than 43 characters, but 5274862f5301Smrg # are always uninteresting 5275862f5301Smrg /:[ ]*file format pe[i]\{,1\}-/d 5276862f5301Smrg /^In archive [^:]*:/d 5277862f5301Smrg # Ensure marker is printed 5278862f5301Smrg /^====MARK====/p 5279862f5301Smrg # Remove all lines with less than 43 characters 5280862f5301Smrg /^.\{43\}/!d 5281862f5301Smrg # From remaining lines, remove first 43 characters 5282862f5301Smrg s/^.\{43\}//' | 5283862f5301Smrg $SED -n ' 5284862f5301Smrg # Join marker and all lines until next marker into a single line 5285862f5301Smrg /^====MARK====/ b para 5286862f5301Smrg H 5287862f5301Smrg $ b para 5288862f5301Smrg b 5289862f5301Smrg :para 5290862f5301Smrg x 5291862f5301Smrg s/\n//g 5292862f5301Smrg # Remove the marker 5293862f5301Smrg s/^====MARK====// 5294862f5301Smrg # Remove trailing dots and whitespace 5295862f5301Smrg s/[\. \t]*$// 5296862f5301Smrg # Print 5297862f5301Smrg /./p' | 5298862f5301Smrg # we now have a list, one entry per line, of the stringified 5299862f5301Smrg # contents of the appropriate section of all members of the 53006fc0178dSmrg # archive that possess that section. Heuristic: eliminate 53016fc0178dSmrg # all those that have a first or second character that is 5302862f5301Smrg # a '.' (that is, objdump's representation of an unprintable 5303862f5301Smrg # character.) This should work for all archives with less than 5304862f5301Smrg # 0x302f exports -- but will fail for DLLs whose name actually 5305862f5301Smrg # begins with a literal '.' or a single character followed by 5306862f5301Smrg # a '.'. 5307862f5301Smrg # 5308862f5301Smrg # Of those that remain, print the first one. 5309862f5301Smrg $SED -e '/^\./d;/^.\./d;q' 5310862f5301Smrg} 5311862f5301Smrg 5312862f5301Smrg# func_cygming_dll_for_implib_fallback ARG 5313862f5301Smrg# Platform-specific function to extract the 5314862f5301Smrg# name of the DLL associated with the specified 5315862f5301Smrg# import library ARG. 5316862f5301Smrg# 5317862f5301Smrg# This fallback implementation is for use when $DLLTOOL 5318862f5301Smrg# does not support the --identify-strict option. 5319862f5301Smrg# Invoked by eval'ing the libtool variable 5320862f5301Smrg# $sharedlib_from_linklib_cmd 5321862f5301Smrg# Result is available in the variable 5322862f5301Smrg# $sharedlib_from_linklib_result 5323862f5301Smrgfunc_cygming_dll_for_implib_fallback () 5324862f5301Smrg{ 53256fc0178dSmrg $debug_cmd 53266fc0178dSmrg 53276fc0178dSmrg if func_cygming_gnu_implib_p "$1"; then 5328862f5301Smrg # binutils import library 5329862f5301Smrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` 53306fc0178dSmrg elif func_cygming_ms_implib_p "$1"; then 5331862f5301Smrg # ms-generated import library 5332862f5301Smrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` 5333862f5301Smrg else 5334862f5301Smrg # unknown 53356fc0178dSmrg sharedlib_from_linklib_result= 5336862f5301Smrg fi 5337862f5301Smrg} 5338ff559fabSmrg 5339ff559fabSmrg 53407a3b38f7Smrg# func_extract_an_archive dir oldlib 53417a3b38f7Smrgfunc_extract_an_archive () 53427a3b38f7Smrg{ 53436fc0178dSmrg $debug_cmd 53446fc0178dSmrg 53456fc0178dSmrg f_ex_an_ar_dir=$1; shift 53466fc0178dSmrg f_ex_an_ar_oldlib=$1 53476fc0178dSmrg if test yes = "$lock_old_archive_extraction"; then 534844dda7b2Smrg lockfile=$f_ex_an_ar_oldlib.lock 534944dda7b2Smrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 535044dda7b2Smrg func_echo "Waiting for $lockfile to be removed" 535144dda7b2Smrg sleep 2 535244dda7b2Smrg done 535344dda7b2Smrg fi 535444dda7b2Smrg func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ 535544dda7b2Smrg 'stat=$?; rm -f "$lockfile"; exit $stat' 53566fc0178dSmrg if test yes = "$lock_old_archive_extraction"; then 535744dda7b2Smrg $opt_dry_run || rm -f "$lockfile" 535844dda7b2Smrg fi 53597a3b38f7Smrg if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then 53607a3b38f7Smrg : 53617a3b38f7Smrg else 53627a3b38f7Smrg func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 53637a3b38f7Smrg fi 53647a3b38f7Smrg} 5365ff559fabSmrg 5366ff559fabSmrg 53677a3b38f7Smrg# func_extract_archives gentop oldlib ... 53687a3b38f7Smrgfunc_extract_archives () 53697a3b38f7Smrg{ 53706fc0178dSmrg $debug_cmd 53716fc0178dSmrg 53726fc0178dSmrg my_gentop=$1; shift 53737a3b38f7Smrg my_oldlibs=${1+"$@"} 53746fc0178dSmrg my_oldobjs= 53756fc0178dSmrg my_xlib= 53766fc0178dSmrg my_xabs= 53776fc0178dSmrg my_xdir= 5378ff559fabSmrg 53797a3b38f7Smrg for my_xlib in $my_oldlibs; do 53807a3b38f7Smrg # Extract the objects. 53817a3b38f7Smrg case $my_xlib in 53826fc0178dSmrg [\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;; 53837a3b38f7Smrg *) my_xabs=`pwd`"/$my_xlib" ;; 53847a3b38f7Smrg esac 53857a3b38f7Smrg func_basename "$my_xlib" 53866fc0178dSmrg my_xlib=$func_basename_result 53877a3b38f7Smrg my_xlib_u=$my_xlib 53887a3b38f7Smrg while :; do 53897a3b38f7Smrg case " $extracted_archives " in 53907a3b38f7Smrg *" $my_xlib_u "*) 53917a3b38f7Smrg func_arith $extracted_serial + 1 53927a3b38f7Smrg extracted_serial=$func_arith_result 53937a3b38f7Smrg my_xlib_u=lt$extracted_serial-$my_xlib ;; 53947a3b38f7Smrg *) break ;; 53957a3b38f7Smrg esac 53967a3b38f7Smrg done 53977a3b38f7Smrg extracted_archives="$extracted_archives $my_xlib_u" 53986fc0178dSmrg my_xdir=$my_gentop/$my_xlib_u 5399ff559fabSmrg 54007a3b38f7Smrg func_mkdir_p "$my_xdir" 5401ff559fabSmrg 54027a3b38f7Smrg case $host in 54037a3b38f7Smrg *-darwin*) 54047a3b38f7Smrg func_verbose "Extracting $my_xabs" 54057a3b38f7Smrg # Do not bother doing anything if just a dry run 54067a3b38f7Smrg $opt_dry_run || { 54077a3b38f7Smrg darwin_orig_dir=`pwd` 54087a3b38f7Smrg cd $my_xdir || exit $? 54097a3b38f7Smrg darwin_archive=$my_xabs 54107a3b38f7Smrg darwin_curdir=`pwd` 54116fc0178dSmrg func_basename "$darwin_archive" 54126fc0178dSmrg darwin_base_archive=$func_basename_result 54137a3b38f7Smrg darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` 54147a3b38f7Smrg if test -n "$darwin_arches"; then 54157a3b38f7Smrg darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` 54167a3b38f7Smrg darwin_arch= 54177a3b38f7Smrg func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" 54186fc0178dSmrg for darwin_arch in $darwin_arches; do 54196fc0178dSmrg func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch" 54206fc0178dSmrg $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive" 54216fc0178dSmrg cd "unfat-$$/$darwin_base_archive-$darwin_arch" 54226fc0178dSmrg func_extract_an_archive "`pwd`" "$darwin_base_archive" 54237a3b38f7Smrg cd "$darwin_curdir" 54246fc0178dSmrg $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" 54257a3b38f7Smrg done # $darwin_arches 54267a3b38f7Smrg ## Okay now we've a bunch of thin objects, gotta fatten them up :) 54276fc0178dSmrg darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$sed_basename" | sort -u` 54287a3b38f7Smrg darwin_file= 54297a3b38f7Smrg darwin_files= 54307a3b38f7Smrg for darwin_file in $darwin_filelist; do 543144dda7b2Smrg darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` 54327a3b38f7Smrg $LIPO -create -output "$darwin_file" $darwin_files 54337a3b38f7Smrg done # $darwin_filelist 54347a3b38f7Smrg $RM -rf unfat-$$ 54357a3b38f7Smrg cd "$darwin_orig_dir" 54367a3b38f7Smrg else 54377a3b38f7Smrg cd $darwin_orig_dir 54387a3b38f7Smrg func_extract_an_archive "$my_xdir" "$my_xabs" 54397a3b38f7Smrg fi # $darwin_arches 54407a3b38f7Smrg } # !$opt_dry_run 54417a3b38f7Smrg ;; 54427a3b38f7Smrg *) 54437a3b38f7Smrg func_extract_an_archive "$my_xdir" "$my_xabs" 54447a3b38f7Smrg ;; 5445ff559fabSmrg esac 544644dda7b2Smrg my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` 54477a3b38f7Smrg done 5448ff559fabSmrg 54496fc0178dSmrg func_extract_archives_result=$my_oldobjs 54507a3b38f7Smrg} 5451ff559fabSmrg 5452ff559fabSmrg 545344dda7b2Smrg# func_emit_wrapper [arg=no] 545444dda7b2Smrg# 545544dda7b2Smrg# Emit a libtool wrapper script on stdout. 545644dda7b2Smrg# Don't directly open a file because we may want to 545744dda7b2Smrg# incorporate the script contents within a cygwin/mingw 545844dda7b2Smrg# wrapper executable. Must ONLY be called from within 545944dda7b2Smrg# func_mode_link because it depends on a number of variables 546044dda7b2Smrg# set therein. 54617a3b38f7Smrg# 546244dda7b2Smrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR 546344dda7b2Smrg# variable will take. If 'yes', then the emitted script 54646fc0178dSmrg# will assume that the directory where it is stored is 546544dda7b2Smrg# the $objdir directory. This is a cygwin/mingw-specific 546644dda7b2Smrg# behavior. 546744dda7b2Smrgfunc_emit_wrapper () 54687a3b38f7Smrg{ 546944dda7b2Smrg func_emit_wrapper_arg1=${1-no} 5470ff559fabSmrg 54717a3b38f7Smrg $ECHO "\ 54727a3b38f7Smrg#! $SHELL 5473ff559fabSmrg 54747a3b38f7Smrg# $output - temporary wrapper script for $objdir/$outputname 54756fc0178dSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 54767a3b38f7Smrg# 54777a3b38f7Smrg# The $output program cannot be directly executed until all the libtool 54787a3b38f7Smrg# libraries that it depends on are installed. 54797a3b38f7Smrg# 54807a3b38f7Smrg# This wrapper script should never be moved out of the build directory. 54817a3b38f7Smrg# If it is, it will not operate correctly. 5482ff559fabSmrg 54837a3b38f7Smrg# Sed substitution that helps us do robust quoting. It backslashifies 54847a3b38f7Smrg# metacharacters that are still active within double-quoted strings. 54857a3b38f7Smrgsed_quote_subst='$sed_quote_subst' 5486ff559fabSmrg 54877a3b38f7Smrg# Be Bourne compatible 54887a3b38f7Smrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then 54897a3b38f7Smrg emulate sh 54907a3b38f7Smrg NULLCMD=: 54917a3b38f7Smrg # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which 54927a3b38f7Smrg # is contrary to our usage. Disable this feature. 54937a3b38f7Smrg alias -g '\${1+\"\$@\"}'='\"\$@\"' 54947a3b38f7Smrg setopt NO_GLOB_SUBST 54957a3b38f7Smrgelse 54967a3b38f7Smrg case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac 54977a3b38f7Smrgfi 54987a3b38f7SmrgBIN_SH=xpg4; export BIN_SH # for Tru64 54997a3b38f7SmrgDUALCASE=1; export DUALCASE # for MKS sh 5500ff559fabSmrg 55017a3b38f7Smrg# The HP-UX ksh and POSIX shell print the target directory to stdout 55027a3b38f7Smrg# if CDPATH is set. 55037a3b38f7Smrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 5504ff559fabSmrg 55057a3b38f7Smrgrelink_command=\"$relink_command\" 5506ff559fabSmrg 55077a3b38f7Smrg# This environment variable determines our operation mode. 55087a3b38f7Smrgif test \"\$libtool_install_magic\" = \"$magic\"; then 55097a3b38f7Smrg # install mode needs the following variables: 55107a3b38f7Smrg generated_by_libtool_version='$macro_version' 55117a3b38f7Smrg notinst_deplibs='$notinst_deplibs' 55127a3b38f7Smrgelse 55137a3b38f7Smrg # When we are sourced in execute mode, \$file and \$ECHO are already set. 55147a3b38f7Smrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 551544dda7b2Smrg file=\"\$0\"" 551644dda7b2Smrg 5517515ec619Smrg func_quote_arg pretty "$ECHO" 5518515ec619Smrg qECHO=$func_quote_arg_result 551944dda7b2Smrg $ECHO "\ 552044dda7b2Smrg 552144dda7b2Smrg# A function that is used when there is no print builtin or printf. 552244dda7b2Smrgfunc_fallback_echo () 552344dda7b2Smrg{ 552444dda7b2Smrg eval 'cat <<_LTECHO_EOF 552544dda7b2Smrg\$1 552644dda7b2Smrg_LTECHO_EOF' 552744dda7b2Smrg} 5528515ec619Smrg ECHO=$qECHO 552944dda7b2Smrg fi 553044dda7b2Smrg 553144dda7b2Smrg# Very basic option parsing. These options are (a) specific to 553244dda7b2Smrg# the libtool wrapper, (b) are identical between the wrapper 55336fc0178dSmrg# /script/ and the wrapper /executable/ that is used only on 553444dda7b2Smrg# windows platforms, and (c) all begin with the string "--lt-" 55356fc0178dSmrg# (application programs are unlikely to have options that match 553644dda7b2Smrg# this pattern). 553744dda7b2Smrg# 553844dda7b2Smrg# There are only two supported options: --lt-debug and 553944dda7b2Smrg# --lt-dump-script. There is, deliberately, no --lt-help. 554044dda7b2Smrg# 554144dda7b2Smrg# The first argument to this parsing function should be the 554244dda7b2Smrg# script's $0 value, followed by "$@". 554344dda7b2Smrglt_option_debug= 554444dda7b2Smrgfunc_parse_lt_options () 554544dda7b2Smrg{ 554644dda7b2Smrg lt_script_arg0=\$0 554744dda7b2Smrg shift 554844dda7b2Smrg for lt_opt 554944dda7b2Smrg do 555044dda7b2Smrg case \"\$lt_opt\" in 555144dda7b2Smrg --lt-debug) lt_option_debug=1 ;; 555244dda7b2Smrg --lt-dump-script) 555344dda7b2Smrg lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` 555444dda7b2Smrg test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. 555544dda7b2Smrg lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` 555644dda7b2Smrg cat \"\$lt_dump_D/\$lt_dump_F\" 555744dda7b2Smrg exit 0 555844dda7b2Smrg ;; 555944dda7b2Smrg --lt-*) 556044dda7b2Smrg \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 556144dda7b2Smrg exit 1 556244dda7b2Smrg ;; 556344dda7b2Smrg esac 556444dda7b2Smrg done 556544dda7b2Smrg 556644dda7b2Smrg # Print the debug banner immediately: 556744dda7b2Smrg if test -n \"\$lt_option_debug\"; then 55686fc0178dSmrg echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2 556944dda7b2Smrg fi 557044dda7b2Smrg} 557144dda7b2Smrg 557244dda7b2Smrg# Used when --lt-debug. Prints its arguments to stdout 557344dda7b2Smrg# (redirection is the responsibility of the caller) 557444dda7b2Smrgfunc_lt_dump_args () 557544dda7b2Smrg{ 557644dda7b2Smrg lt_dump_args_N=1; 557744dda7b2Smrg for lt_arg 557844dda7b2Smrg do 55796fc0178dSmrg \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\" 558044dda7b2Smrg lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` 558144dda7b2Smrg done 558244dda7b2Smrg} 558344dda7b2Smrg 558444dda7b2Smrg# Core function for launching the target application 558544dda7b2Smrgfunc_exec_program_core () 558644dda7b2Smrg{ 55877a3b38f7Smrg" 558844dda7b2Smrg case $host in 558944dda7b2Smrg # Backslashes separate directories on plain windows 559044dda7b2Smrg *-*-mingw | *-*-os2* | *-cegcc*) 559144dda7b2Smrg $ECHO "\ 559244dda7b2Smrg if test -n \"\$lt_option_debug\"; then 55936fc0178dSmrg \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2 559444dda7b2Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 559544dda7b2Smrg fi 559644dda7b2Smrg exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} 559744dda7b2Smrg" 559844dda7b2Smrg ;; 559944dda7b2Smrg 560044dda7b2Smrg *) 560144dda7b2Smrg $ECHO "\ 560244dda7b2Smrg if test -n \"\$lt_option_debug\"; then 56036fc0178dSmrg \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2 560444dda7b2Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 560544dda7b2Smrg fi 560644dda7b2Smrg exec \"\$progdir/\$program\" \${1+\"\$@\"} 560744dda7b2Smrg" 560844dda7b2Smrg ;; 560944dda7b2Smrg esac 561044dda7b2Smrg $ECHO "\ 561144dda7b2Smrg \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 561244dda7b2Smrg exit 1 561344dda7b2Smrg} 561444dda7b2Smrg 561544dda7b2Smrg# A function to encapsulate launching the target application 561644dda7b2Smrg# Strips options in the --lt-* namespace from \$@ and 561744dda7b2Smrg# launches target application with the remaining arguments. 561844dda7b2Smrgfunc_exec_program () 561944dda7b2Smrg{ 5620fc544a13Smrg case \" \$* \" in 5621fc544a13Smrg *\\ --lt-*) 5622fc544a13Smrg for lt_wr_arg 5623fc544a13Smrg do 5624fc544a13Smrg case \$lt_wr_arg in 5625fc544a13Smrg --lt-*) ;; 5626fc544a13Smrg *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; 5627fc544a13Smrg esac 5628fc544a13Smrg shift 5629fc544a13Smrg done ;; 5630fc544a13Smrg esac 563144dda7b2Smrg func_exec_program_core \${1+\"\$@\"} 563244dda7b2Smrg} 563344dda7b2Smrg 563444dda7b2Smrg # Parse options 563544dda7b2Smrg func_parse_lt_options \"\$0\" \${1+\"\$@\"} 5636ff559fabSmrg 56377a3b38f7Smrg # Find the directory that this script lives in. 563844dda7b2Smrg thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` 56397a3b38f7Smrg test \"x\$thisdir\" = \"x\$file\" && thisdir=. 5640ff559fabSmrg 56417a3b38f7Smrg # Follow symbolic links until we get to the real thisdir. 564244dda7b2Smrg file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` 56437a3b38f7Smrg while test -n \"\$file\"; do 564444dda7b2Smrg destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` 5645ff559fabSmrg 56467a3b38f7Smrg # If there was a directory component, then change thisdir. 56477a3b38f7Smrg if test \"x\$destdir\" != \"x\$file\"; then 56487a3b38f7Smrg case \"\$destdir\" in 56497a3b38f7Smrg [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; 56507a3b38f7Smrg *) thisdir=\"\$thisdir/\$destdir\" ;; 56517a3b38f7Smrg esac 56527a3b38f7Smrg fi 5653ff559fabSmrg 565444dda7b2Smrg file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` 565544dda7b2Smrg file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` 56567a3b38f7Smrg done 5657ff559fabSmrg 56587a3b38f7Smrg # Usually 'no', except on cygwin/mingw when embedded into 56597a3b38f7Smrg # the cwrapper. 566044dda7b2Smrg WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 56617a3b38f7Smrg if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then 56627a3b38f7Smrg # special case for '.' 56637a3b38f7Smrg if test \"\$thisdir\" = \".\"; then 56647a3b38f7Smrg thisdir=\`pwd\` 56657a3b38f7Smrg fi 56667a3b38f7Smrg # remove .libs from thisdir 56677a3b38f7Smrg case \"\$thisdir\" in 566844dda7b2Smrg *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; 56697a3b38f7Smrg $objdir ) thisdir=. ;; 56707a3b38f7Smrg esac 56717a3b38f7Smrg fi 5672ff559fabSmrg 56737a3b38f7Smrg # Try to get the absolute directory name. 56747a3b38f7Smrg absdir=\`cd \"\$thisdir\" && pwd\` 56757a3b38f7Smrg test -n \"\$absdir\" && thisdir=\"\$absdir\" 56767a3b38f7Smrg" 5677ff559fabSmrg 56786fc0178dSmrg if test yes = "$fast_install"; then 56797a3b38f7Smrg $ECHO "\ 56807a3b38f7Smrg program=lt-'$outputname'$exeext 56817a3b38f7Smrg progdir=\"\$thisdir/$objdir\" 5682ff559fabSmrg 56837a3b38f7Smrg if test ! -f \"\$progdir/\$program\" || 56846fc0178dSmrg { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\ 56857a3b38f7Smrg test \"X\$file\" != \"X\$progdir/\$program\"; }; then 5686ff559fabSmrg 56877a3b38f7Smrg file=\"\$\$-\$program\" 5688ff559fabSmrg 56897a3b38f7Smrg if test ! -d \"\$progdir\"; then 56907a3b38f7Smrg $MKDIR \"\$progdir\" 56917a3b38f7Smrg else 56927a3b38f7Smrg $RM \"\$progdir/\$file\" 56937a3b38f7Smrg fi" 5694ff559fabSmrg 56957a3b38f7Smrg $ECHO "\ 5696ff559fabSmrg 56977a3b38f7Smrg # relink executable if necessary 56987a3b38f7Smrg if test -n \"\$relink_command\"; then 56997a3b38f7Smrg if relink_command_output=\`eval \$relink_command 2>&1\`; then : 57007a3b38f7Smrg else 57016fc0178dSmrg \$ECHO \"\$relink_command_output\" >&2 57027a3b38f7Smrg $RM \"\$progdir/\$file\" 57037a3b38f7Smrg exit 1 57047a3b38f7Smrg fi 57057a3b38f7Smrg fi 5706ff559fabSmrg 57077a3b38f7Smrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || 57087a3b38f7Smrg { $RM \"\$progdir/\$program\"; 57097a3b38f7Smrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } 57107a3b38f7Smrg $RM \"\$progdir/\$file\" 57117a3b38f7Smrg fi" 57127a3b38f7Smrg else 57137a3b38f7Smrg $ECHO "\ 57147a3b38f7Smrg program='$outputname' 57157a3b38f7Smrg progdir=\"\$thisdir/$objdir\" 57167a3b38f7Smrg" 57177a3b38f7Smrg fi 5718ff559fabSmrg 57197a3b38f7Smrg $ECHO "\ 5720ff559fabSmrg 57217a3b38f7Smrg if test -f \"\$progdir/\$program\"; then" 5722ff559fabSmrg 5723862f5301Smrg # fixup the dll searchpath if we need to. 5724862f5301Smrg # 5725862f5301Smrg # Fix the DLL searchpath if we need to. Do this before prepending 5726862f5301Smrg # to shlibpath, because on Windows, both are PATH and uninstalled 5727862f5301Smrg # libraries must come first. 5728862f5301Smrg if test -n "$dllsearchpath"; then 5729862f5301Smrg $ECHO "\ 5730862f5301Smrg # Add the dll search path components to the executable PATH 5731862f5301Smrg PATH=$dllsearchpath:\$PATH 5732862f5301Smrg" 5733862f5301Smrg fi 5734862f5301Smrg 57357a3b38f7Smrg # Export our shlibpath_var if we have one. 57366fc0178dSmrg if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 57377a3b38f7Smrg $ECHO "\ 57387a3b38f7Smrg # Add our own library path to $shlibpath_var 57397a3b38f7Smrg $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" 5740ff559fabSmrg 57417a3b38f7Smrg # Some systems cannot cope with colon-terminated $shlibpath_var 57427a3b38f7Smrg # The second colon is a workaround for a bug in BeOS R4 sed 574344dda7b2Smrg $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` 5744ff559fabSmrg 57457a3b38f7Smrg export $shlibpath_var 57467a3b38f7Smrg" 5747ff559fabSmrg fi 5748ff559fabSmrg 57497a3b38f7Smrg $ECHO "\ 57507a3b38f7Smrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 57517a3b38f7Smrg # Run the actual program with our arguments. 575244dda7b2Smrg func_exec_program \${1+\"\$@\"} 57537a3b38f7Smrg fi 57547a3b38f7Smrg else 57557a3b38f7Smrg # The program doesn't exist. 57566fc0178dSmrg \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2 57577a3b38f7Smrg \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 575844dda7b2Smrg \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 57597a3b38f7Smrg exit 1 57607a3b38f7Smrg fi 57617a3b38f7Smrgfi\ 57627a3b38f7Smrg" 57637a3b38f7Smrg} 5764ff559fabSmrg 5765ff559fabSmrg 57667a3b38f7Smrg# func_emit_cwrapperexe_src 57677a3b38f7Smrg# emit the source code for a wrapper executable on stdout 57687a3b38f7Smrg# Must ONLY be called from within func_mode_link because 57697a3b38f7Smrg# it depends on a number of variable set therein. 57707a3b38f7Smrgfunc_emit_cwrapperexe_src () 57717a3b38f7Smrg{ 57727a3b38f7Smrg cat <<EOF 5773ff559fabSmrg 57747a3b38f7Smrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname 57756fc0178dSmrg Generated by $PROGRAM (GNU $PACKAGE) $VERSION 5776ff559fabSmrg 57777a3b38f7Smrg The $output program cannot be directly executed until all the libtool 57787a3b38f7Smrg libraries that it depends on are installed. 5779ff559fabSmrg 57807a3b38f7Smrg This wrapper executable should never be moved out of the build directory. 57817a3b38f7Smrg If it is, it will not operate correctly. 57827a3b38f7Smrg*/ 57837a3b38f7SmrgEOF 57847a3b38f7Smrg cat <<"EOF" 578544dda7b2Smrg#ifdef _MSC_VER 578644dda7b2Smrg# define _CRT_SECURE_NO_DEPRECATE 1 578744dda7b2Smrg#endif 57887a3b38f7Smrg#include <stdio.h> 57897a3b38f7Smrg#include <stdlib.h> 57907a3b38f7Smrg#ifdef _MSC_VER 57917a3b38f7Smrg# include <direct.h> 57927a3b38f7Smrg# include <process.h> 57937a3b38f7Smrg# include <io.h> 57947a3b38f7Smrg#else 57957a3b38f7Smrg# include <unistd.h> 57967a3b38f7Smrg# include <stdint.h> 57977a3b38f7Smrg# ifdef __CYGWIN__ 57987a3b38f7Smrg# include <io.h> 57997a3b38f7Smrg# endif 58007a3b38f7Smrg#endif 58017a3b38f7Smrg#include <malloc.h> 58027a3b38f7Smrg#include <stdarg.h> 58037a3b38f7Smrg#include <assert.h> 58047a3b38f7Smrg#include <string.h> 58057a3b38f7Smrg#include <ctype.h> 58067a3b38f7Smrg#include <errno.h> 58077a3b38f7Smrg#include <fcntl.h> 58087a3b38f7Smrg#include <sys/stat.h> 58097a3b38f7Smrg 58106fc0178dSmrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 58116fc0178dSmrg 581244dda7b2Smrg/* declarations of non-ANSI functions */ 58136fc0178dSmrg#if defined __MINGW32__ 581444dda7b2Smrg# ifdef __STRICT_ANSI__ 581544dda7b2Smrgint _putenv (const char *); 581644dda7b2Smrg# endif 58176fc0178dSmrg#elif defined __CYGWIN__ 581844dda7b2Smrg# ifdef __STRICT_ANSI__ 581944dda7b2Smrgchar *realpath (const char *, char *); 582044dda7b2Smrgint putenv (char *); 582144dda7b2Smrgint setenv (const char *, const char *, int); 582244dda7b2Smrg# endif 58236fc0178dSmrg/* #elif defined other_platform || defined ... */ 582444dda7b2Smrg#endif 582544dda7b2Smrg 582644dda7b2Smrg/* portability defines, excluding path handling macros */ 58276fc0178dSmrg#if defined _MSC_VER 582844dda7b2Smrg# define setmode _setmode 582944dda7b2Smrg# define stat _stat 583044dda7b2Smrg# define chmod _chmod 583144dda7b2Smrg# define getcwd _getcwd 583244dda7b2Smrg# define putenv _putenv 583344dda7b2Smrg# define S_IXUSR _S_IEXEC 58346fc0178dSmrg#elif defined __MINGW32__ 583544dda7b2Smrg# define setmode _setmode 583644dda7b2Smrg# define stat _stat 583744dda7b2Smrg# define chmod _chmod 583844dda7b2Smrg# define getcwd _getcwd 583944dda7b2Smrg# define putenv _putenv 58406fc0178dSmrg#elif defined __CYGWIN__ 584144dda7b2Smrg# define HAVE_SETENV 584244dda7b2Smrg# define FOPEN_WB "wb" 58436fc0178dSmrg/* #elif defined other platforms ... */ 584444dda7b2Smrg#endif 584544dda7b2Smrg 58466fc0178dSmrg#if defined PATH_MAX 58477a3b38f7Smrg# define LT_PATHMAX PATH_MAX 58486fc0178dSmrg#elif defined MAXPATHLEN 58497a3b38f7Smrg# define LT_PATHMAX MAXPATHLEN 58507a3b38f7Smrg#else 58517a3b38f7Smrg# define LT_PATHMAX 1024 58527a3b38f7Smrg#endif 58537a3b38f7Smrg 58547a3b38f7Smrg#ifndef S_IXOTH 58557a3b38f7Smrg# define S_IXOTH 0 58567a3b38f7Smrg#endif 58577a3b38f7Smrg#ifndef S_IXGRP 58587a3b38f7Smrg# define S_IXGRP 0 58597a3b38f7Smrg#endif 58607a3b38f7Smrg 586144dda7b2Smrg/* path handling portability macros */ 58627a3b38f7Smrg#ifndef DIR_SEPARATOR 58637a3b38f7Smrg# define DIR_SEPARATOR '/' 58647a3b38f7Smrg# define PATH_SEPARATOR ':' 58657a3b38f7Smrg#endif 58667a3b38f7Smrg 58676fc0178dSmrg#if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \ 58686fc0178dSmrg defined __OS2__ 58697a3b38f7Smrg# define HAVE_DOS_BASED_FILE_SYSTEM 58707a3b38f7Smrg# define FOPEN_WB "wb" 58717a3b38f7Smrg# ifndef DIR_SEPARATOR_2 58727a3b38f7Smrg# define DIR_SEPARATOR_2 '\\' 58737a3b38f7Smrg# endif 58747a3b38f7Smrg# ifndef PATH_SEPARATOR_2 58757a3b38f7Smrg# define PATH_SEPARATOR_2 ';' 58767a3b38f7Smrg# endif 58777a3b38f7Smrg#endif 58787a3b38f7Smrg 58797a3b38f7Smrg#ifndef DIR_SEPARATOR_2 58807a3b38f7Smrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) 58817a3b38f7Smrg#else /* DIR_SEPARATOR_2 */ 58827a3b38f7Smrg# define IS_DIR_SEPARATOR(ch) \ 58837a3b38f7Smrg (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) 58847a3b38f7Smrg#endif /* DIR_SEPARATOR_2 */ 58857a3b38f7Smrg 58867a3b38f7Smrg#ifndef PATH_SEPARATOR_2 58877a3b38f7Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) 58887a3b38f7Smrg#else /* PATH_SEPARATOR_2 */ 58897a3b38f7Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) 58907a3b38f7Smrg#endif /* PATH_SEPARATOR_2 */ 58917a3b38f7Smrg 58927a3b38f7Smrg#ifndef FOPEN_WB 58937a3b38f7Smrg# define FOPEN_WB "w" 58947a3b38f7Smrg#endif 58957a3b38f7Smrg#ifndef _O_BINARY 58967a3b38f7Smrg# define _O_BINARY 0 58977a3b38f7Smrg#endif 58987a3b38f7Smrg 58997a3b38f7Smrg#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) 59007a3b38f7Smrg#define XFREE(stale) do { \ 59016fc0178dSmrg if (stale) { free (stale); stale = 0; } \ 59027a3b38f7Smrg} while (0) 59037a3b38f7Smrg 59046fc0178dSmrg#if defined LT_DEBUGWRAPPER 590544dda7b2Smrgstatic int lt_debug = 1; 59067a3b38f7Smrg#else 590744dda7b2Smrgstatic int lt_debug = 0; 59087a3b38f7Smrg#endif 59097a3b38f7Smrg 591044dda7b2Smrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ 59117a3b38f7Smrg 59127a3b38f7Smrgvoid *xmalloc (size_t num); 59137a3b38f7Smrgchar *xstrdup (const char *string); 59147a3b38f7Smrgconst char *base_name (const char *name); 59157a3b38f7Smrgchar *find_executable (const char *wrapper); 59167a3b38f7Smrgchar *chase_symlinks (const char *pathspec); 59177a3b38f7Smrgint make_executable (const char *path); 59187a3b38f7Smrgint check_executable (const char *path); 59197a3b38f7Smrgchar *strendzap (char *str, const char *pat); 592044dda7b2Smrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...); 592144dda7b2Smrgvoid lt_fatal (const char *file, int line, const char *message, ...); 592244dda7b2Smrgstatic const char *nonnull (const char *s); 592344dda7b2Smrgstatic const char *nonempty (const char *s); 59247a3b38f7Smrgvoid lt_setenv (const char *name, const char *value); 59257a3b38f7Smrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end); 59267a3b38f7Smrgvoid lt_update_exe_path (const char *name, const char *value); 59277a3b38f7Smrgvoid lt_update_lib_path (const char *name, const char *value); 592844dda7b2Smrgchar **prepare_spawn (char **argv); 592944dda7b2Smrgvoid lt_dump_script (FILE *f); 59307a3b38f7SmrgEOF 59317a3b38f7Smrg 59327a3b38f7Smrg cat <<EOF 59336fc0178dSmrg#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5) 59346fc0178dSmrg# define externally_visible volatile 59356fc0178dSmrg#else 59366fc0178dSmrg# define externally_visible __attribute__((externally_visible)) volatile 59376fc0178dSmrg#endif 59386fc0178dSmrgexternally_visible const char * MAGIC_EXE = "$magic_exe"; 59397a3b38f7Smrgconst char * LIB_PATH_VARNAME = "$shlibpath_var"; 59407a3b38f7SmrgEOF 59417a3b38f7Smrg 59426fc0178dSmrg if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 5943862f5301Smrg func_to_host_path "$temp_rpath" 59447a3b38f7Smrg cat <<EOF 5945862f5301Smrgconst char * LIB_PATH_VALUE = "$func_to_host_path_result"; 5946ff559fabSmrgEOF 5947ff559fabSmrg else 59487a3b38f7Smrg cat <<"EOF" 59497a3b38f7Smrgconst char * LIB_PATH_VALUE = ""; 59507a3b38f7SmrgEOF 5951ff559fabSmrg fi 59527a3b38f7Smrg 59537a3b38f7Smrg if test -n "$dllsearchpath"; then 5954862f5301Smrg func_to_host_path "$dllsearchpath:" 59557a3b38f7Smrg cat <<EOF 59567a3b38f7Smrgconst char * EXE_PATH_VARNAME = "PATH"; 5957862f5301Smrgconst char * EXE_PATH_VALUE = "$func_to_host_path_result"; 59587a3b38f7SmrgEOF 5959ff559fabSmrg else 59607a3b38f7Smrg cat <<"EOF" 59617a3b38f7Smrgconst char * EXE_PATH_VARNAME = ""; 59627a3b38f7Smrgconst char * EXE_PATH_VALUE = ""; 59637a3b38f7SmrgEOF 5964ff559fabSmrg fi 59657a3b38f7Smrg 59666fc0178dSmrg if test yes = "$fast_install"; then 59677a3b38f7Smrg cat <<EOF 59687a3b38f7Smrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */ 59697a3b38f7SmrgEOF 5970ff559fabSmrg else 59717a3b38f7Smrg cat <<EOF 59727a3b38f7Smrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */ 59737a3b38f7SmrgEOF 5974ff559fabSmrg fi 5975ff559fabSmrg 5976ff559fabSmrg 59777a3b38f7Smrg cat <<"EOF" 5978ff559fabSmrg 59797a3b38f7Smrg#define LTWRAPPER_OPTION_PREFIX "--lt-" 5980ff559fabSmrg 59817a3b38f7Smrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX; 59827a3b38f7Smrgstatic const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script"; 598344dda7b2Smrgstatic const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug"; 5984ff559fabSmrg 59857a3b38f7Smrgint 59867a3b38f7Smrgmain (int argc, char *argv[]) 59877a3b38f7Smrg{ 59887a3b38f7Smrg char **newargz; 59897a3b38f7Smrg int newargc; 59907a3b38f7Smrg char *tmp_pathspec; 59917a3b38f7Smrg char *actual_cwrapper_path; 59927a3b38f7Smrg char *actual_cwrapper_name; 59937a3b38f7Smrg char *target_name; 59947a3b38f7Smrg char *lt_argv_zero; 59956fc0178dSmrg int rval = 127; 5996ff559fabSmrg 59977a3b38f7Smrg int i; 5998ff559fabSmrg 59997a3b38f7Smrg program_name = (char *) xstrdup (base_name (argv[0])); 60006fc0178dSmrg newargz = XMALLOC (char *, (size_t) argc + 1); 6001ff559fabSmrg 600244dda7b2Smrg /* very simple arg parsing; don't want to rely on getopt 600344dda7b2Smrg * also, copy all non cwrapper options to newargz, except 600444dda7b2Smrg * argz[0], which is handled differently 600544dda7b2Smrg */ 600644dda7b2Smrg newargc=0; 60077a3b38f7Smrg for (i = 1; i < argc; i++) 60087a3b38f7Smrg { 60096fc0178dSmrg if (STREQ (argv[i], dumpscript_opt)) 60107a3b38f7Smrg { 60117a3b38f7SmrgEOF 60126fc0178dSmrg case $host in 60137a3b38f7Smrg *mingw* | *cygwin* ) 60147a3b38f7Smrg # make stdout use "unix" line endings 60157a3b38f7Smrg echo " setmode(1,_O_BINARY);" 60167a3b38f7Smrg ;; 60177a3b38f7Smrg esac 6018ff559fabSmrg 60197a3b38f7Smrg cat <<"EOF" 602044dda7b2Smrg lt_dump_script (stdout); 60217a3b38f7Smrg return 0; 60227a3b38f7Smrg } 60236fc0178dSmrg if (STREQ (argv[i], debug_opt)) 602444dda7b2Smrg { 602544dda7b2Smrg lt_debug = 1; 602644dda7b2Smrg continue; 602744dda7b2Smrg } 60286fc0178dSmrg if (STREQ (argv[i], ltwrapper_option_prefix)) 602944dda7b2Smrg { 603044dda7b2Smrg /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX 603144dda7b2Smrg namespace, but it is not one of the ones we know about and 603244dda7b2Smrg have already dealt with, above (inluding dump-script), then 603344dda7b2Smrg report an error. Otherwise, targets might begin to believe 603444dda7b2Smrg they are allowed to use options in the LTWRAPPER_OPTION_PREFIX 603544dda7b2Smrg namespace. The first time any user complains about this, we'll 603644dda7b2Smrg need to make LTWRAPPER_OPTION_PREFIX a configure-time option 603744dda7b2Smrg or a configure.ac-settable value. 603844dda7b2Smrg */ 603944dda7b2Smrg lt_fatal (__FILE__, __LINE__, 604044dda7b2Smrg "unrecognized %s option: '%s'", 604144dda7b2Smrg ltwrapper_option_prefix, argv[i]); 604244dda7b2Smrg } 604344dda7b2Smrg /* otherwise ... */ 604444dda7b2Smrg newargz[++newargc] = xstrdup (argv[i]); 60457a3b38f7Smrg } 604644dda7b2Smrg newargz[++newargc] = NULL; 604744dda7b2Smrg 604844dda7b2SmrgEOF 604944dda7b2Smrg cat <<EOF 605044dda7b2Smrg /* The GNU banner must be the first non-error debug message */ 60516fc0178dSmrg lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE) $VERSION\n"); 605244dda7b2SmrgEOF 605344dda7b2Smrg cat <<"EOF" 605444dda7b2Smrg lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]); 605544dda7b2Smrg lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name); 6056ff559fabSmrg 60577a3b38f7Smrg tmp_pathspec = find_executable (argv[0]); 60587a3b38f7Smrg if (tmp_pathspec == NULL) 605944dda7b2Smrg lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]); 606044dda7b2Smrg lt_debugprintf (__FILE__, __LINE__, 606144dda7b2Smrg "(main) found exe (before symlink chase) at: %s\n", 606244dda7b2Smrg tmp_pathspec); 60637a3b38f7Smrg 60647a3b38f7Smrg actual_cwrapper_path = chase_symlinks (tmp_pathspec); 606544dda7b2Smrg lt_debugprintf (__FILE__, __LINE__, 606644dda7b2Smrg "(main) found exe (after symlink chase) at: %s\n", 606744dda7b2Smrg actual_cwrapper_path); 60687a3b38f7Smrg XFREE (tmp_pathspec); 60697a3b38f7Smrg 607044dda7b2Smrg actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path)); 60717a3b38f7Smrg strendzap (actual_cwrapper_path, actual_cwrapper_name); 60727a3b38f7Smrg 60737a3b38f7Smrg /* wrapper name transforms */ 60747a3b38f7Smrg strendzap (actual_cwrapper_name, ".exe"); 60757a3b38f7Smrg tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1); 60767a3b38f7Smrg XFREE (actual_cwrapper_name); 60777a3b38f7Smrg actual_cwrapper_name = tmp_pathspec; 60787a3b38f7Smrg tmp_pathspec = 0; 60797a3b38f7Smrg 60807a3b38f7Smrg /* target_name transforms -- use actual target program name; might have lt- prefix */ 60817a3b38f7Smrg target_name = xstrdup (base_name (TARGET_PROGRAM_NAME)); 60827a3b38f7Smrg strendzap (target_name, ".exe"); 60837a3b38f7Smrg tmp_pathspec = lt_extend_str (target_name, ".exe", 1); 60847a3b38f7Smrg XFREE (target_name); 60857a3b38f7Smrg target_name = tmp_pathspec; 60867a3b38f7Smrg tmp_pathspec = 0; 60877a3b38f7Smrg 608844dda7b2Smrg lt_debugprintf (__FILE__, __LINE__, 608944dda7b2Smrg "(main) libtool target name: %s\n", 609044dda7b2Smrg target_name); 60917a3b38f7SmrgEOF 6092ff559fabSmrg 60937a3b38f7Smrg cat <<EOF 60947a3b38f7Smrg newargz[0] = 60957a3b38f7Smrg XMALLOC (char, (strlen (actual_cwrapper_path) + 60967a3b38f7Smrg strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1)); 60977a3b38f7Smrg strcpy (newargz[0], actual_cwrapper_path); 60987a3b38f7Smrg strcat (newargz[0], "$objdir"); 60997a3b38f7Smrg strcat (newargz[0], "/"); 61007a3b38f7SmrgEOF 6101ff559fabSmrg 61027a3b38f7Smrg cat <<"EOF" 61037a3b38f7Smrg /* stop here, and copy so we don't have to do this twice */ 61047a3b38f7Smrg tmp_pathspec = xstrdup (newargz[0]); 6105ff559fabSmrg 61067a3b38f7Smrg /* do NOT want the lt- prefix here, so use actual_cwrapper_name */ 61077a3b38f7Smrg strcat (newargz[0], actual_cwrapper_name); 6108ff559fabSmrg 61097a3b38f7Smrg /* DO want the lt- prefix here if it exists, so use target_name */ 61107a3b38f7Smrg lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1); 61117a3b38f7Smrg XFREE (tmp_pathspec); 61127a3b38f7Smrg tmp_pathspec = NULL; 61137a3b38f7SmrgEOF 6114ff559fabSmrg 61157a3b38f7Smrg case $host_os in 61167a3b38f7Smrg mingw*) 61177a3b38f7Smrg cat <<"EOF" 61187a3b38f7Smrg { 61197a3b38f7Smrg char* p; 61207a3b38f7Smrg while ((p = strchr (newargz[0], '\\')) != NULL) 61217a3b38f7Smrg { 61227a3b38f7Smrg *p = '/'; 61237a3b38f7Smrg } 61247a3b38f7Smrg while ((p = strchr (lt_argv_zero, '\\')) != NULL) 61257a3b38f7Smrg { 61267a3b38f7Smrg *p = '/'; 61277a3b38f7Smrg } 61287a3b38f7Smrg } 61297a3b38f7SmrgEOF 61307a3b38f7Smrg ;; 61317a3b38f7Smrg esac 6132ff559fabSmrg 61337a3b38f7Smrg cat <<"EOF" 61347a3b38f7Smrg XFREE (target_name); 61357a3b38f7Smrg XFREE (actual_cwrapper_path); 61367a3b38f7Smrg XFREE (actual_cwrapper_name); 6137ff559fabSmrg 61387a3b38f7Smrg lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */ 61397a3b38f7Smrg lt_setenv ("DUALCASE", "1"); /* for MSK sh */ 6140862f5301Smrg /* Update the DLL searchpath. EXE_PATH_VALUE ($dllsearchpath) must 6141862f5301Smrg be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath) 6142862f5301Smrg because on Windows, both *_VARNAMEs are PATH but uninstalled 6143862f5301Smrg libraries must come first. */ 61447a3b38f7Smrg lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE); 6145862f5301Smrg lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE); 6146ff559fabSmrg 614744dda7b2Smrg lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n", 614844dda7b2Smrg nonnull (lt_argv_zero)); 61497a3b38f7Smrg for (i = 0; i < newargc; i++) 61507a3b38f7Smrg { 615144dda7b2Smrg lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n", 615244dda7b2Smrg i, nonnull (newargz[i])); 61537a3b38f7Smrg } 6154ff559fabSmrg 61557a3b38f7SmrgEOF 6156ff559fabSmrg 61577a3b38f7Smrg case $host_os in 61587a3b38f7Smrg mingw*) 61597a3b38f7Smrg cat <<"EOF" 61607a3b38f7Smrg /* execv doesn't actually work on mingw as expected on unix */ 616144dda7b2Smrg newargz = prepare_spawn (newargz); 61626fc0178dSmrg rval = (int) _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz); 61637a3b38f7Smrg if (rval == -1) 61647a3b38f7Smrg { 61657a3b38f7Smrg /* failed to start process */ 616644dda7b2Smrg lt_debugprintf (__FILE__, __LINE__, 616744dda7b2Smrg "(main) failed to launch target \"%s\": %s\n", 616844dda7b2Smrg lt_argv_zero, nonnull (strerror (errno))); 61697a3b38f7Smrg return 127; 61707a3b38f7Smrg } 61717a3b38f7Smrg return rval; 61727a3b38f7SmrgEOF 61737a3b38f7Smrg ;; 61747a3b38f7Smrg *) 61757a3b38f7Smrg cat <<"EOF" 61767a3b38f7Smrg execv (lt_argv_zero, newargz); 61777a3b38f7Smrg return rval; /* =127, but avoids unused variable warning */ 61787a3b38f7SmrgEOF 61797a3b38f7Smrg ;; 61807a3b38f7Smrg esac 6181ff559fabSmrg 61827a3b38f7Smrg cat <<"EOF" 61837a3b38f7Smrg} 6184ff559fabSmrg 61857a3b38f7Smrgvoid * 61867a3b38f7Smrgxmalloc (size_t num) 61877a3b38f7Smrg{ 61887a3b38f7Smrg void *p = (void *) malloc (num); 61897a3b38f7Smrg if (!p) 619044dda7b2Smrg lt_fatal (__FILE__, __LINE__, "memory exhausted"); 6191ff559fabSmrg 61927a3b38f7Smrg return p; 61937a3b38f7Smrg} 6194ff559fabSmrg 61957a3b38f7Smrgchar * 61967a3b38f7Smrgxstrdup (const char *string) 61977a3b38f7Smrg{ 61987a3b38f7Smrg return string ? strcpy ((char *) xmalloc (strlen (string) + 1), 61997a3b38f7Smrg string) : NULL; 62007a3b38f7Smrg} 6201ff559fabSmrg 62027a3b38f7Smrgconst char * 62037a3b38f7Smrgbase_name (const char *name) 62047a3b38f7Smrg{ 62057a3b38f7Smrg const char *base; 6206ff559fabSmrg 62076fc0178dSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 62087a3b38f7Smrg /* Skip over the disk name in MSDOS pathnames. */ 62097a3b38f7Smrg if (isalpha ((unsigned char) name[0]) && name[1] == ':') 62107a3b38f7Smrg name += 2; 62117a3b38f7Smrg#endif 6212ff559fabSmrg 62137a3b38f7Smrg for (base = name; *name; name++) 62147a3b38f7Smrg if (IS_DIR_SEPARATOR (*name)) 62157a3b38f7Smrg base = name + 1; 62167a3b38f7Smrg return base; 62177a3b38f7Smrg} 6218ff559fabSmrg 62197a3b38f7Smrgint 62207a3b38f7Smrgcheck_executable (const char *path) 62217a3b38f7Smrg{ 62227a3b38f7Smrg struct stat st; 6223ff559fabSmrg 622444dda7b2Smrg lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n", 622544dda7b2Smrg nonempty (path)); 62267a3b38f7Smrg if ((!path) || (!*path)) 62277a3b38f7Smrg return 0; 6228ff559fabSmrg 62297a3b38f7Smrg if ((stat (path, &st) >= 0) 62307a3b38f7Smrg && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) 62317a3b38f7Smrg return 1; 62327a3b38f7Smrg else 62337a3b38f7Smrg return 0; 62347a3b38f7Smrg} 6235ff559fabSmrg 62367a3b38f7Smrgint 62377a3b38f7Smrgmake_executable (const char *path) 62387a3b38f7Smrg{ 62397a3b38f7Smrg int rval = 0; 62407a3b38f7Smrg struct stat st; 6241ff559fabSmrg 624244dda7b2Smrg lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", 624344dda7b2Smrg nonempty (path)); 62447a3b38f7Smrg if ((!path) || (!*path)) 62457a3b38f7Smrg return 0; 6246ff559fabSmrg 62477a3b38f7Smrg if (stat (path, &st) >= 0) 62487a3b38f7Smrg { 62497a3b38f7Smrg rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); 62507a3b38f7Smrg } 62517a3b38f7Smrg return rval; 62527a3b38f7Smrg} 6253ff559fabSmrg 62547a3b38f7Smrg/* Searches for the full path of the wrapper. Returns 62557a3b38f7Smrg newly allocated full path name if found, NULL otherwise 62567a3b38f7Smrg Does not chase symlinks, even on platforms that support them. 62577a3b38f7Smrg*/ 62587a3b38f7Smrgchar * 62597a3b38f7Smrgfind_executable (const char *wrapper) 62607a3b38f7Smrg{ 62617a3b38f7Smrg int has_slash = 0; 62627a3b38f7Smrg const char *p; 62637a3b38f7Smrg const char *p_next; 62647a3b38f7Smrg /* static buffer for getcwd */ 62657a3b38f7Smrg char tmp[LT_PATHMAX + 1]; 62666fc0178dSmrg size_t tmp_len; 62677a3b38f7Smrg char *concat_name; 6268ff559fabSmrg 626944dda7b2Smrg lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", 627044dda7b2Smrg nonempty (wrapper)); 6271ff559fabSmrg 62727a3b38f7Smrg if ((wrapper == NULL) || (*wrapper == '\0')) 62737a3b38f7Smrg return NULL; 6274ff559fabSmrg 62757a3b38f7Smrg /* Absolute path? */ 62766fc0178dSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 62777a3b38f7Smrg if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') 62787a3b38f7Smrg { 62797a3b38f7Smrg concat_name = xstrdup (wrapper); 62807a3b38f7Smrg if (check_executable (concat_name)) 62817a3b38f7Smrg return concat_name; 62827a3b38f7Smrg XFREE (concat_name); 62837a3b38f7Smrg } 62847a3b38f7Smrg else 62857a3b38f7Smrg { 62867a3b38f7Smrg#endif 62877a3b38f7Smrg if (IS_DIR_SEPARATOR (wrapper[0])) 62887a3b38f7Smrg { 62897a3b38f7Smrg concat_name = xstrdup (wrapper); 62907a3b38f7Smrg if (check_executable (concat_name)) 62917a3b38f7Smrg return concat_name; 62927a3b38f7Smrg XFREE (concat_name); 62937a3b38f7Smrg } 62946fc0178dSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 62957a3b38f7Smrg } 62967a3b38f7Smrg#endif 6297ff559fabSmrg 62987a3b38f7Smrg for (p = wrapper; *p; p++) 62997a3b38f7Smrg if (*p == '/') 63007a3b38f7Smrg { 63017a3b38f7Smrg has_slash = 1; 63027a3b38f7Smrg break; 63037a3b38f7Smrg } 63047a3b38f7Smrg if (!has_slash) 63057a3b38f7Smrg { 63067a3b38f7Smrg /* no slashes; search PATH */ 63077a3b38f7Smrg const char *path = getenv ("PATH"); 63087a3b38f7Smrg if (path != NULL) 63097a3b38f7Smrg { 63107a3b38f7Smrg for (p = path; *p; p = p_next) 63117a3b38f7Smrg { 63127a3b38f7Smrg const char *q; 63137a3b38f7Smrg size_t p_len; 63147a3b38f7Smrg for (q = p; *q; q++) 63157a3b38f7Smrg if (IS_PATH_SEPARATOR (*q)) 63167a3b38f7Smrg break; 63176fc0178dSmrg p_len = (size_t) (q - p); 63187a3b38f7Smrg p_next = (*q == '\0' ? q : q + 1); 63197a3b38f7Smrg if (p_len == 0) 63207a3b38f7Smrg { 63217a3b38f7Smrg /* empty path: current directory */ 63227a3b38f7Smrg if (getcwd (tmp, LT_PATHMAX) == NULL) 632344dda7b2Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 632444dda7b2Smrg nonnull (strerror (errno))); 63257a3b38f7Smrg tmp_len = strlen (tmp); 63267a3b38f7Smrg concat_name = 63277a3b38f7Smrg XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 63287a3b38f7Smrg memcpy (concat_name, tmp, tmp_len); 63297a3b38f7Smrg concat_name[tmp_len] = '/'; 63307a3b38f7Smrg strcpy (concat_name + tmp_len + 1, wrapper); 63317a3b38f7Smrg } 63327a3b38f7Smrg else 63337a3b38f7Smrg { 63347a3b38f7Smrg concat_name = 63357a3b38f7Smrg XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); 63367a3b38f7Smrg memcpy (concat_name, p, p_len); 63377a3b38f7Smrg concat_name[p_len] = '/'; 63387a3b38f7Smrg strcpy (concat_name + p_len + 1, wrapper); 63397a3b38f7Smrg } 63407a3b38f7Smrg if (check_executable (concat_name)) 63417a3b38f7Smrg return concat_name; 63427a3b38f7Smrg XFREE (concat_name); 63437a3b38f7Smrg } 63447a3b38f7Smrg } 63457a3b38f7Smrg /* not found in PATH; assume curdir */ 63467a3b38f7Smrg } 63477a3b38f7Smrg /* Relative path | not found in path: prepend cwd */ 63487a3b38f7Smrg if (getcwd (tmp, LT_PATHMAX) == NULL) 634944dda7b2Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 635044dda7b2Smrg nonnull (strerror (errno))); 63517a3b38f7Smrg tmp_len = strlen (tmp); 63527a3b38f7Smrg concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 63537a3b38f7Smrg memcpy (concat_name, tmp, tmp_len); 63547a3b38f7Smrg concat_name[tmp_len] = '/'; 63557a3b38f7Smrg strcpy (concat_name + tmp_len + 1, wrapper); 6356ff559fabSmrg 63577a3b38f7Smrg if (check_executable (concat_name)) 63587a3b38f7Smrg return concat_name; 63597a3b38f7Smrg XFREE (concat_name); 63607a3b38f7Smrg return NULL; 63617a3b38f7Smrg} 6362ff559fabSmrg 63637a3b38f7Smrgchar * 63647a3b38f7Smrgchase_symlinks (const char *pathspec) 63657a3b38f7Smrg{ 63667a3b38f7Smrg#ifndef S_ISLNK 63677a3b38f7Smrg return xstrdup (pathspec); 63687a3b38f7Smrg#else 63697a3b38f7Smrg char buf[LT_PATHMAX]; 63707a3b38f7Smrg struct stat s; 63717a3b38f7Smrg char *tmp_pathspec = xstrdup (pathspec); 63727a3b38f7Smrg char *p; 63737a3b38f7Smrg int has_symlinks = 0; 63747a3b38f7Smrg while (strlen (tmp_pathspec) && !has_symlinks) 63757a3b38f7Smrg { 637644dda7b2Smrg lt_debugprintf (__FILE__, __LINE__, 637744dda7b2Smrg "checking path component for symlinks: %s\n", 637844dda7b2Smrg tmp_pathspec); 63797a3b38f7Smrg if (lstat (tmp_pathspec, &s) == 0) 63807a3b38f7Smrg { 63817a3b38f7Smrg if (S_ISLNK (s.st_mode) != 0) 63827a3b38f7Smrg { 63837a3b38f7Smrg has_symlinks = 1; 63847a3b38f7Smrg break; 63857a3b38f7Smrg } 6386ff559fabSmrg 63877a3b38f7Smrg /* search backwards for last DIR_SEPARATOR */ 63887a3b38f7Smrg p = tmp_pathspec + strlen (tmp_pathspec) - 1; 63897a3b38f7Smrg while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 63907a3b38f7Smrg p--; 63917a3b38f7Smrg if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 63927a3b38f7Smrg { 63937a3b38f7Smrg /* no more DIR_SEPARATORS left */ 63947a3b38f7Smrg break; 63957a3b38f7Smrg } 63967a3b38f7Smrg *p = '\0'; 63977a3b38f7Smrg } 63987a3b38f7Smrg else 63997a3b38f7Smrg { 640044dda7b2Smrg lt_fatal (__FILE__, __LINE__, 640144dda7b2Smrg "error accessing file \"%s\": %s", 640244dda7b2Smrg tmp_pathspec, nonnull (strerror (errno))); 64037a3b38f7Smrg } 64047a3b38f7Smrg } 64057a3b38f7Smrg XFREE (tmp_pathspec); 6406ff559fabSmrg 64077a3b38f7Smrg if (!has_symlinks) 64087a3b38f7Smrg { 64097a3b38f7Smrg return xstrdup (pathspec); 64107a3b38f7Smrg } 6411ff559fabSmrg 64127a3b38f7Smrg tmp_pathspec = realpath (pathspec, buf); 64137a3b38f7Smrg if (tmp_pathspec == 0) 64147a3b38f7Smrg { 641544dda7b2Smrg lt_fatal (__FILE__, __LINE__, 641644dda7b2Smrg "could not follow symlinks for %s", pathspec); 64177a3b38f7Smrg } 64187a3b38f7Smrg return xstrdup (tmp_pathspec); 64197a3b38f7Smrg#endif 64207a3b38f7Smrg} 6421ff559fabSmrg 64227a3b38f7Smrgchar * 64237a3b38f7Smrgstrendzap (char *str, const char *pat) 64247a3b38f7Smrg{ 64257a3b38f7Smrg size_t len, patlen; 6426ff559fabSmrg 64277a3b38f7Smrg assert (str != NULL); 64287a3b38f7Smrg assert (pat != NULL); 6429ff559fabSmrg 64307a3b38f7Smrg len = strlen (str); 64317a3b38f7Smrg patlen = strlen (pat); 6432ff559fabSmrg 64337a3b38f7Smrg if (patlen <= len) 64347a3b38f7Smrg { 64357a3b38f7Smrg str += len - patlen; 64366fc0178dSmrg if (STREQ (str, pat)) 64377a3b38f7Smrg *str = '\0'; 64387a3b38f7Smrg } 64397a3b38f7Smrg return str; 64407a3b38f7Smrg} 6441ff559fabSmrg 644244dda7b2Smrgvoid 644344dda7b2Smrglt_debugprintf (const char *file, int line, const char *fmt, ...) 644444dda7b2Smrg{ 644544dda7b2Smrg va_list args; 644644dda7b2Smrg if (lt_debug) 644744dda7b2Smrg { 644844dda7b2Smrg (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); 644944dda7b2Smrg va_start (args, fmt); 645044dda7b2Smrg (void) vfprintf (stderr, fmt, args); 645144dda7b2Smrg va_end (args); 645244dda7b2Smrg } 645344dda7b2Smrg} 645444dda7b2Smrg 64557a3b38f7Smrgstatic void 645644dda7b2Smrglt_error_core (int exit_status, const char *file, 645744dda7b2Smrg int line, const char *mode, 64587a3b38f7Smrg const char *message, va_list ap) 64597a3b38f7Smrg{ 646044dda7b2Smrg fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); 64617a3b38f7Smrg vfprintf (stderr, message, ap); 64627a3b38f7Smrg fprintf (stderr, ".\n"); 6463ff559fabSmrg 64647a3b38f7Smrg if (exit_status >= 0) 64657a3b38f7Smrg exit (exit_status); 64667a3b38f7Smrg} 6467ff559fabSmrg 64687a3b38f7Smrgvoid 646944dda7b2Smrglt_fatal (const char *file, int line, const char *message, ...) 64707a3b38f7Smrg{ 64717a3b38f7Smrg va_list ap; 64727a3b38f7Smrg va_start (ap, message); 647344dda7b2Smrg lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); 64747a3b38f7Smrg va_end (ap); 64757a3b38f7Smrg} 6476ff559fabSmrg 647744dda7b2Smrgstatic const char * 647844dda7b2Smrgnonnull (const char *s) 647944dda7b2Smrg{ 648044dda7b2Smrg return s ? s : "(null)"; 648144dda7b2Smrg} 648244dda7b2Smrg 648344dda7b2Smrgstatic const char * 648444dda7b2Smrgnonempty (const char *s) 648544dda7b2Smrg{ 648644dda7b2Smrg return (s && !*s) ? "(empty)" : nonnull (s); 648744dda7b2Smrg} 648844dda7b2Smrg 64897a3b38f7Smrgvoid 64907a3b38f7Smrglt_setenv (const char *name, const char *value) 64917a3b38f7Smrg{ 649244dda7b2Smrg lt_debugprintf (__FILE__, __LINE__, 649344dda7b2Smrg "(lt_setenv) setting '%s' to '%s'\n", 649444dda7b2Smrg nonnull (name), nonnull (value)); 64957a3b38f7Smrg { 64967a3b38f7Smrg#ifdef HAVE_SETENV 64977a3b38f7Smrg /* always make a copy, for consistency with !HAVE_SETENV */ 64987a3b38f7Smrg char *str = xstrdup (value); 64997a3b38f7Smrg setenv (name, str, 1); 65007a3b38f7Smrg#else 65016fc0178dSmrg size_t len = strlen (name) + 1 + strlen (value) + 1; 65027a3b38f7Smrg char *str = XMALLOC (char, len); 65037a3b38f7Smrg sprintf (str, "%s=%s", name, value); 65047a3b38f7Smrg if (putenv (str) != EXIT_SUCCESS) 65057a3b38f7Smrg { 65067a3b38f7Smrg XFREE (str); 65077a3b38f7Smrg } 65087a3b38f7Smrg#endif 65097a3b38f7Smrg } 65107a3b38f7Smrg} 6511ff559fabSmrg 65127a3b38f7Smrgchar * 65137a3b38f7Smrglt_extend_str (const char *orig_value, const char *add, int to_end) 65147a3b38f7Smrg{ 65157a3b38f7Smrg char *new_value; 65167a3b38f7Smrg if (orig_value && *orig_value) 65177a3b38f7Smrg { 65186fc0178dSmrg size_t orig_value_len = strlen (orig_value); 65196fc0178dSmrg size_t add_len = strlen (add); 65207a3b38f7Smrg new_value = XMALLOC (char, add_len + orig_value_len + 1); 65217a3b38f7Smrg if (to_end) 65227a3b38f7Smrg { 65237a3b38f7Smrg strcpy (new_value, orig_value); 65247a3b38f7Smrg strcpy (new_value + orig_value_len, add); 65257a3b38f7Smrg } 65267a3b38f7Smrg else 65277a3b38f7Smrg { 65287a3b38f7Smrg strcpy (new_value, add); 65297a3b38f7Smrg strcpy (new_value + add_len, orig_value); 65307a3b38f7Smrg } 65317a3b38f7Smrg } 65327a3b38f7Smrg else 65337a3b38f7Smrg { 65347a3b38f7Smrg new_value = xstrdup (add); 65357a3b38f7Smrg } 65367a3b38f7Smrg return new_value; 65377a3b38f7Smrg} 6538ff559fabSmrg 65397a3b38f7Smrgvoid 65407a3b38f7Smrglt_update_exe_path (const char *name, const char *value) 65417a3b38f7Smrg{ 654244dda7b2Smrg lt_debugprintf (__FILE__, __LINE__, 654344dda7b2Smrg "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", 654444dda7b2Smrg nonnull (name), nonnull (value)); 6545ff559fabSmrg 65467a3b38f7Smrg if (name && *name && value && *value) 65477a3b38f7Smrg { 65487a3b38f7Smrg char *new_value = lt_extend_str (getenv (name), value, 0); 65497a3b38f7Smrg /* some systems can't cope with a ':'-terminated path #' */ 65506fc0178dSmrg size_t len = strlen (new_value); 65516fc0178dSmrg while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1])) 65527a3b38f7Smrg { 65536fc0178dSmrg new_value[--len] = '\0'; 65547a3b38f7Smrg } 65557a3b38f7Smrg lt_setenv (name, new_value); 65567a3b38f7Smrg XFREE (new_value); 65577a3b38f7Smrg } 65587a3b38f7Smrg} 6559ff559fabSmrg 65607a3b38f7Smrgvoid 65617a3b38f7Smrglt_update_lib_path (const char *name, const char *value) 65627a3b38f7Smrg{ 656344dda7b2Smrg lt_debugprintf (__FILE__, __LINE__, 656444dda7b2Smrg "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", 656544dda7b2Smrg nonnull (name), nonnull (value)); 6566ff559fabSmrg 65677a3b38f7Smrg if (name && *name && value && *value) 65687a3b38f7Smrg { 65697a3b38f7Smrg char *new_value = lt_extend_str (getenv (name), value, 0); 65707a3b38f7Smrg lt_setenv (name, new_value); 65717a3b38f7Smrg XFREE (new_value); 65727a3b38f7Smrg } 65737a3b38f7Smrg} 6574ff559fabSmrg 657544dda7b2SmrgEOF 657644dda7b2Smrg case $host_os in 657744dda7b2Smrg mingw*) 657844dda7b2Smrg cat <<"EOF" 657944dda7b2Smrg 658044dda7b2Smrg/* Prepares an argument vector before calling spawn(). 658144dda7b2Smrg Note that spawn() does not by itself call the command interpreter 658244dda7b2Smrg (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : 658344dda7b2Smrg ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); 658444dda7b2Smrg GetVersionEx(&v); 658544dda7b2Smrg v.dwPlatformId == VER_PLATFORM_WIN32_NT; 658644dda7b2Smrg }) ? "cmd.exe" : "command.com"). 658744dda7b2Smrg Instead it simply concatenates the arguments, separated by ' ', and calls 658844dda7b2Smrg CreateProcess(). We must quote the arguments since Win32 CreateProcess() 658944dda7b2Smrg interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a 659044dda7b2Smrg special way: 659144dda7b2Smrg - Space and tab are interpreted as delimiters. They are not treated as 659244dda7b2Smrg delimiters if they are surrounded by double quotes: "...". 659344dda7b2Smrg - Unescaped double quotes are removed from the input. Their only effect is 659444dda7b2Smrg that within double quotes, space and tab are treated like normal 659544dda7b2Smrg characters. 659644dda7b2Smrg - Backslashes not followed by double quotes are not special. 659744dda7b2Smrg - But 2*n+1 backslashes followed by a double quote become 659844dda7b2Smrg n backslashes followed by a double quote (n >= 0): 659944dda7b2Smrg \" -> " 660044dda7b2Smrg \\\" -> \" 660144dda7b2Smrg \\\\\" -> \\" 660244dda7b2Smrg */ 660344dda7b2Smrg#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" 660444dda7b2Smrg#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" 660544dda7b2Smrgchar ** 660644dda7b2Smrgprepare_spawn (char **argv) 660744dda7b2Smrg{ 660844dda7b2Smrg size_t argc; 660944dda7b2Smrg char **new_argv; 661044dda7b2Smrg size_t i; 661144dda7b2Smrg 661244dda7b2Smrg /* Count number of arguments. */ 661344dda7b2Smrg for (argc = 0; argv[argc] != NULL; argc++) 661444dda7b2Smrg ; 661544dda7b2Smrg 661644dda7b2Smrg /* Allocate new argument vector. */ 661744dda7b2Smrg new_argv = XMALLOC (char *, argc + 1); 661844dda7b2Smrg 661944dda7b2Smrg /* Put quoted arguments into the new argument vector. */ 662044dda7b2Smrg for (i = 0; i < argc; i++) 662144dda7b2Smrg { 662244dda7b2Smrg const char *string = argv[i]; 662344dda7b2Smrg 662444dda7b2Smrg if (string[0] == '\0') 662544dda7b2Smrg new_argv[i] = xstrdup ("\"\""); 662644dda7b2Smrg else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) 662744dda7b2Smrg { 662844dda7b2Smrg int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); 662944dda7b2Smrg size_t length; 663044dda7b2Smrg unsigned int backslashes; 663144dda7b2Smrg const char *s; 663244dda7b2Smrg char *quoted_string; 663344dda7b2Smrg char *p; 663444dda7b2Smrg 663544dda7b2Smrg length = 0; 663644dda7b2Smrg backslashes = 0; 663744dda7b2Smrg if (quote_around) 663844dda7b2Smrg length++; 663944dda7b2Smrg for (s = string; *s != '\0'; s++) 664044dda7b2Smrg { 664144dda7b2Smrg char c = *s; 664244dda7b2Smrg if (c == '"') 664344dda7b2Smrg length += backslashes + 1; 664444dda7b2Smrg length++; 664544dda7b2Smrg if (c == '\\') 664644dda7b2Smrg backslashes++; 664744dda7b2Smrg else 664844dda7b2Smrg backslashes = 0; 664944dda7b2Smrg } 665044dda7b2Smrg if (quote_around) 665144dda7b2Smrg length += backslashes + 1; 665244dda7b2Smrg 665344dda7b2Smrg quoted_string = XMALLOC (char, length + 1); 665444dda7b2Smrg 665544dda7b2Smrg p = quoted_string; 665644dda7b2Smrg backslashes = 0; 665744dda7b2Smrg if (quote_around) 665844dda7b2Smrg *p++ = '"'; 665944dda7b2Smrg for (s = string; *s != '\0'; s++) 666044dda7b2Smrg { 666144dda7b2Smrg char c = *s; 666244dda7b2Smrg if (c == '"') 666344dda7b2Smrg { 666444dda7b2Smrg unsigned int j; 666544dda7b2Smrg for (j = backslashes + 1; j > 0; j--) 666644dda7b2Smrg *p++ = '\\'; 666744dda7b2Smrg } 666844dda7b2Smrg *p++ = c; 666944dda7b2Smrg if (c == '\\') 667044dda7b2Smrg backslashes++; 667144dda7b2Smrg else 667244dda7b2Smrg backslashes = 0; 667344dda7b2Smrg } 667444dda7b2Smrg if (quote_around) 667544dda7b2Smrg { 667644dda7b2Smrg unsigned int j; 667744dda7b2Smrg for (j = backslashes; j > 0; j--) 667844dda7b2Smrg *p++ = '\\'; 667944dda7b2Smrg *p++ = '"'; 668044dda7b2Smrg } 668144dda7b2Smrg *p = '\0'; 668244dda7b2Smrg 668344dda7b2Smrg new_argv[i] = quoted_string; 668444dda7b2Smrg } 668544dda7b2Smrg else 668644dda7b2Smrg new_argv[i] = (char *) string; 668744dda7b2Smrg } 668844dda7b2Smrg new_argv[argc] = NULL; 668944dda7b2Smrg 669044dda7b2Smrg return new_argv; 669144dda7b2Smrg} 669244dda7b2SmrgEOF 669344dda7b2Smrg ;; 669444dda7b2Smrg esac 669544dda7b2Smrg 669644dda7b2Smrg cat <<"EOF" 669744dda7b2Smrgvoid lt_dump_script (FILE* f) 669844dda7b2Smrg{ 669944dda7b2SmrgEOF 670044dda7b2Smrg func_emit_wrapper yes | 6701fc544a13Smrg $SED -n -e ' 6702fc544a13Smrgs/^\(.\{79\}\)\(..*\)/\1\ 6703fc544a13Smrg\2/ 6704fc544a13Smrgh 6705fc544a13Smrgs/\([\\"]\)/\\\1/g 6706fc544a13Smrgs/$/\\n/ 6707fc544a13Smrgs/\([^\n]*\).*/ fputs ("\1", f);/p 6708fc544a13Smrgg 6709fc544a13SmrgD' 671044dda7b2Smrg cat <<"EOF" 671144dda7b2Smrg} 67127a3b38f7SmrgEOF 67137a3b38f7Smrg} 67147a3b38f7Smrg# end: func_emit_cwrapperexe_src 6715ff559fabSmrg 671644dda7b2Smrg# func_win32_import_lib_p ARG 671744dda7b2Smrg# True if ARG is an import lib, as indicated by $file_magic_cmd 671844dda7b2Smrgfunc_win32_import_lib_p () 671944dda7b2Smrg{ 67206fc0178dSmrg $debug_cmd 67216fc0178dSmrg 672244dda7b2Smrg case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in 672344dda7b2Smrg *import*) : ;; 672444dda7b2Smrg *) false ;; 672544dda7b2Smrg esac 672644dda7b2Smrg} 672744dda7b2Smrg 67286fc0178dSmrg# func_suncc_cstd_abi 67296fc0178dSmrg# !!ONLY CALL THIS FOR SUN CC AFTER $compile_command IS FULLY EXPANDED!! 67306fc0178dSmrg# Several compiler flags select an ABI that is incompatible with the 67316fc0178dSmrg# Cstd library. Avoid specifying it if any are in CXXFLAGS. 67326fc0178dSmrgfunc_suncc_cstd_abi () 67336fc0178dSmrg{ 67346fc0178dSmrg $debug_cmd 67356fc0178dSmrg 67366fc0178dSmrg case " $compile_command " in 67376fc0178dSmrg *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*) 67386fc0178dSmrg suncc_use_cstd_abi=no 67396fc0178dSmrg ;; 67406fc0178dSmrg *) 67416fc0178dSmrg suncc_use_cstd_abi=yes 67426fc0178dSmrg ;; 67436fc0178dSmrg esac 67446fc0178dSmrg} 67456fc0178dSmrg 67467a3b38f7Smrg# func_mode_link arg... 67477a3b38f7Smrgfunc_mode_link () 67487a3b38f7Smrg{ 67496fc0178dSmrg $debug_cmd 67506fc0178dSmrg 67517a3b38f7Smrg case $host in 67527a3b38f7Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 67537a3b38f7Smrg # It is impossible to link a dll without this setting, and 67547a3b38f7Smrg # we shouldn't force the makefile maintainer to figure out 67556fc0178dSmrg # what system we are compiling for in order to pass an extra 67567a3b38f7Smrg # flag for every libtool invocation. 67577a3b38f7Smrg # allow_undefined=no 6758ff559fabSmrg 67597a3b38f7Smrg # FIXME: Unfortunately, there are problems with the above when trying 67606fc0178dSmrg # to make a dll that has undefined symbols, in which case not 67617a3b38f7Smrg # even a static library is built. For now, we need to specify 67627a3b38f7Smrg # -no-undefined on the libtool link line when we can be certain 67637a3b38f7Smrg # that all symbols are satisfied, otherwise we get a static library. 67647a3b38f7Smrg allow_undefined=yes 67657a3b38f7Smrg ;; 67667a3b38f7Smrg *) 67677a3b38f7Smrg allow_undefined=yes 67687a3b38f7Smrg ;; 67697a3b38f7Smrg esac 67707a3b38f7Smrg libtool_args=$nonopt 67717a3b38f7Smrg base_compile="$nonopt $@" 67727a3b38f7Smrg compile_command=$nonopt 67737a3b38f7Smrg finalize_command=$nonopt 6774ff559fabSmrg 67757a3b38f7Smrg compile_rpath= 67767a3b38f7Smrg finalize_rpath= 67777a3b38f7Smrg compile_shlibpath= 67787a3b38f7Smrg finalize_shlibpath= 67797a3b38f7Smrg convenience= 67807a3b38f7Smrg old_convenience= 67817a3b38f7Smrg deplibs= 67827a3b38f7Smrg old_deplibs= 67837a3b38f7Smrg compiler_flags= 67847a3b38f7Smrg linker_flags= 67857a3b38f7Smrg dllsearchpath= 67867a3b38f7Smrg lib_search_path=`pwd` 67877a3b38f7Smrg inst_prefix_dir= 67887a3b38f7Smrg new_inherited_linker_flags= 6789ff559fabSmrg 67907a3b38f7Smrg avoid_version=no 679144dda7b2Smrg bindir= 67927a3b38f7Smrg dlfiles= 67937a3b38f7Smrg dlprefiles= 67947a3b38f7Smrg dlself=no 67957a3b38f7Smrg export_dynamic=no 67967a3b38f7Smrg export_symbols= 67977a3b38f7Smrg export_symbols_regex= 67987a3b38f7Smrg generated= 67997a3b38f7Smrg libobjs= 68007a3b38f7Smrg ltlibs= 68017a3b38f7Smrg module=no 68027a3b38f7Smrg no_install=no 68037a3b38f7Smrg objs= 68046fc0178dSmrg os2dllname= 68057a3b38f7Smrg non_pic_objects= 68067a3b38f7Smrg precious_files_regex= 68077a3b38f7Smrg prefer_static_libs=no 68086fc0178dSmrg preload=false 68097a3b38f7Smrg prev= 68107a3b38f7Smrg prevarg= 68117a3b38f7Smrg release= 68127a3b38f7Smrg rpath= 68137a3b38f7Smrg xrpath= 68147a3b38f7Smrg perm_rpath= 68157a3b38f7Smrg temp_rpath= 68167a3b38f7Smrg thread_safe=no 68177a3b38f7Smrg vinfo= 68187a3b38f7Smrg vinfo_number=no 68197a3b38f7Smrg weak_libs= 68206fc0178dSmrg single_module=$wl-single_module 68217a3b38f7Smrg func_infer_tag $base_compile 6822ff559fabSmrg 68237a3b38f7Smrg # We need to know -static, to get the right output filenames. 68247a3b38f7Smrg for arg 68257a3b38f7Smrg do 68267a3b38f7Smrg case $arg in 68277a3b38f7Smrg -shared) 68286fc0178dSmrg test yes != "$build_libtool_libs" \ 68296fc0178dSmrg && func_fatal_configuration "cannot build a shared library" 68307a3b38f7Smrg build_old_libs=no 68317a3b38f7Smrg break 68327a3b38f7Smrg ;; 68337a3b38f7Smrg -all-static | -static | -static-libtool-libs) 68347a3b38f7Smrg case $arg in 68357a3b38f7Smrg -all-static) 68366fc0178dSmrg if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then 68377a3b38f7Smrg func_warning "complete static linking is impossible in this configuration" 6838ff559fabSmrg fi 68397a3b38f7Smrg if test -n "$link_static_flag"; then 68407a3b38f7Smrg dlopen_self=$dlopen_self_static 6841ff559fabSmrg fi 68427a3b38f7Smrg prefer_static_libs=yes 6843ff559fabSmrg ;; 68447a3b38f7Smrg -static) 68457a3b38f7Smrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 68467a3b38f7Smrg dlopen_self=$dlopen_self_static 68477a3b38f7Smrg fi 68487a3b38f7Smrg prefer_static_libs=built 68497a3b38f7Smrg ;; 68507a3b38f7Smrg -static-libtool-libs) 68517a3b38f7Smrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 68527a3b38f7Smrg dlopen_self=$dlopen_self_static 68537a3b38f7Smrg fi 68547a3b38f7Smrg prefer_static_libs=yes 6855ff559fabSmrg ;; 6856ff559fabSmrg esac 68577a3b38f7Smrg build_libtool_libs=no 68587a3b38f7Smrg build_old_libs=yes 68597a3b38f7Smrg break 68607a3b38f7Smrg ;; 68617a3b38f7Smrg esac 68627a3b38f7Smrg done 6863ff559fabSmrg 68647a3b38f7Smrg # See if our shared archives depend on static archives. 68657a3b38f7Smrg test -n "$old_archive_from_new_cmds" && build_old_libs=yes 6866ff559fabSmrg 68677a3b38f7Smrg # Go through the arguments, transforming them on the way. 68687a3b38f7Smrg while test "$#" -gt 0; do 68696fc0178dSmrg arg=$1 68707a3b38f7Smrg shift 6871515ec619Smrg func_quote_arg pretty,unquoted "$arg" 6872515ec619Smrg qarg=$func_quote_arg_unquoted_result 6873515ec619Smrg func_append libtool_args " $func_quote_arg_result" 6874ff559fabSmrg 68757a3b38f7Smrg # If the previous option needs an argument, assign it. 68767a3b38f7Smrg if test -n "$prev"; then 68777a3b38f7Smrg case $prev in 68787a3b38f7Smrg output) 68797a3b38f7Smrg func_append compile_command " @OUTPUT@" 68807a3b38f7Smrg func_append finalize_command " @OUTPUT@" 68817a3b38f7Smrg ;; 68827a3b38f7Smrg esac 6883ff559fabSmrg 68847a3b38f7Smrg case $prev in 688544dda7b2Smrg bindir) 68866fc0178dSmrg bindir=$arg 688744dda7b2Smrg prev= 688844dda7b2Smrg continue 688944dda7b2Smrg ;; 68907a3b38f7Smrg dlfiles|dlprefiles) 68916fc0178dSmrg $preload || { 68927a3b38f7Smrg # Add the symbol object into the linking commands. 68937a3b38f7Smrg func_append compile_command " @SYMFILE@" 68947a3b38f7Smrg func_append finalize_command " @SYMFILE@" 68956fc0178dSmrg preload=: 68966fc0178dSmrg } 68977a3b38f7Smrg case $arg in 68987a3b38f7Smrg *.la | *.lo) ;; # We handle these cases below. 68997a3b38f7Smrg force) 69006fc0178dSmrg if test no = "$dlself"; then 69017a3b38f7Smrg dlself=needless 69027a3b38f7Smrg export_dynamic=yes 69037a3b38f7Smrg fi 69047a3b38f7Smrg prev= 69057a3b38f7Smrg continue 69067a3b38f7Smrg ;; 69077a3b38f7Smrg self) 69086fc0178dSmrg if test dlprefiles = "$prev"; then 69097a3b38f7Smrg dlself=yes 69106fc0178dSmrg elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then 69117a3b38f7Smrg dlself=yes 69127a3b38f7Smrg else 69137a3b38f7Smrg dlself=needless 69147a3b38f7Smrg export_dynamic=yes 69157a3b38f7Smrg fi 69167a3b38f7Smrg prev= 69177a3b38f7Smrg continue 6918ff559fabSmrg ;; 6919ff559fabSmrg *) 69206fc0178dSmrg if test dlfiles = "$prev"; then 6921862f5301Smrg func_append dlfiles " $arg" 69227a3b38f7Smrg else 6923862f5301Smrg func_append dlprefiles " $arg" 69247a3b38f7Smrg fi 69257a3b38f7Smrg prev= 69267a3b38f7Smrg continue 6927ff559fabSmrg ;; 6928ff559fabSmrg esac 69297a3b38f7Smrg ;; 69307a3b38f7Smrg expsyms) 69316fc0178dSmrg export_symbols=$arg 69327a3b38f7Smrg test -f "$arg" \ 69336fc0178dSmrg || func_fatal_error "symbol file '$arg' does not exist" 69347a3b38f7Smrg prev= 69357a3b38f7Smrg continue 69367a3b38f7Smrg ;; 69377a3b38f7Smrg expsyms_regex) 69386fc0178dSmrg export_symbols_regex=$arg 69397a3b38f7Smrg prev= 69407a3b38f7Smrg continue 69417a3b38f7Smrg ;; 69427a3b38f7Smrg framework) 69437a3b38f7Smrg case $host in 69447a3b38f7Smrg *-*-darwin*) 69457a3b38f7Smrg case "$deplibs " in 69467a3b38f7Smrg *" $qarg.ltframework "*) ;; 6947862f5301Smrg *) func_append deplibs " $qarg.ltframework" # this is fixed later 69487a3b38f7Smrg ;; 69497a3b38f7Smrg esac 69507a3b38f7Smrg ;; 69517a3b38f7Smrg esac 69527a3b38f7Smrg prev= 69537a3b38f7Smrg continue 69547a3b38f7Smrg ;; 69557a3b38f7Smrg inst_prefix) 69566fc0178dSmrg inst_prefix_dir=$arg 69576fc0178dSmrg prev= 69586fc0178dSmrg continue 69596fc0178dSmrg ;; 69606fc0178dSmrg mllvm) 69616fc0178dSmrg # Clang does not use LLVM to link, so we can simply discard any 69626fc0178dSmrg # '-mllvm $arg' options when doing the link step. 69637a3b38f7Smrg prev= 69647a3b38f7Smrg continue 69657a3b38f7Smrg ;; 69667a3b38f7Smrg objectlist) 69677a3b38f7Smrg if test -f "$arg"; then 69687a3b38f7Smrg save_arg=$arg 69697a3b38f7Smrg moreargs= 69707a3b38f7Smrg for fil in `cat "$save_arg"` 69717a3b38f7Smrg do 6972862f5301Smrg# func_append moreargs " $fil" 69737a3b38f7Smrg arg=$fil 69747a3b38f7Smrg # A libtool-controlled object. 6975ff559fabSmrg 69767a3b38f7Smrg # Check to see that this really is a libtool object. 69777a3b38f7Smrg if func_lalib_unsafe_p "$arg"; then 69787a3b38f7Smrg pic_object= 69797a3b38f7Smrg non_pic_object= 6980ff559fabSmrg 69817a3b38f7Smrg # Read the .lo file 69827a3b38f7Smrg func_source "$arg" 6983ff559fabSmrg 69847a3b38f7Smrg if test -z "$pic_object" || 69857a3b38f7Smrg test -z "$non_pic_object" || 69866fc0178dSmrg test none = "$pic_object" && 69876fc0178dSmrg test none = "$non_pic_object"; then 69886fc0178dSmrg func_fatal_error "cannot find name of object for '$arg'" 69897a3b38f7Smrg fi 6990ff559fabSmrg 69917a3b38f7Smrg # Extract subdirectory from the argument. 69927a3b38f7Smrg func_dirname "$arg" "/" "" 69936fc0178dSmrg xdir=$func_dirname_result 6994ff559fabSmrg 69956fc0178dSmrg if test none != "$pic_object"; then 69967a3b38f7Smrg # Prepend the subdirectory the object is found in. 69976fc0178dSmrg pic_object=$xdir$pic_object 6998ff559fabSmrg 69996fc0178dSmrg if test dlfiles = "$prev"; then 70006fc0178dSmrg if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 7001862f5301Smrg func_append dlfiles " $pic_object" 70027a3b38f7Smrg prev= 70037a3b38f7Smrg continue 70047a3b38f7Smrg else 70057a3b38f7Smrg # If libtool objects are unsupported, then we need to preload. 70067a3b38f7Smrg prev=dlprefiles 70077a3b38f7Smrg fi 70087a3b38f7Smrg fi 7009ff559fabSmrg 70107a3b38f7Smrg # CHECK ME: I think I busted this. -Ossama 70116fc0178dSmrg if test dlprefiles = "$prev"; then 70127a3b38f7Smrg # Preload the old-style object. 7013862f5301Smrg func_append dlprefiles " $pic_object" 70147a3b38f7Smrg prev= 70157a3b38f7Smrg fi 7016ff559fabSmrg 70177a3b38f7Smrg # A PIC object. 70187a3b38f7Smrg func_append libobjs " $pic_object" 70196fc0178dSmrg arg=$pic_object 70207a3b38f7Smrg fi 7021ff559fabSmrg 70227a3b38f7Smrg # Non-PIC object. 70236fc0178dSmrg if test none != "$non_pic_object"; then 70247a3b38f7Smrg # Prepend the subdirectory the object is found in. 70256fc0178dSmrg non_pic_object=$xdir$non_pic_object 7026ff559fabSmrg 70277a3b38f7Smrg # A standard non-PIC object 70287a3b38f7Smrg func_append non_pic_objects " $non_pic_object" 70296fc0178dSmrg if test -z "$pic_object" || test none = "$pic_object"; then 70306fc0178dSmrg arg=$non_pic_object 70317a3b38f7Smrg fi 70327a3b38f7Smrg else 70337a3b38f7Smrg # If the PIC object exists, use it instead. 70347a3b38f7Smrg # $xdir was prepended to $pic_object above. 70356fc0178dSmrg non_pic_object=$pic_object 70367a3b38f7Smrg func_append non_pic_objects " $non_pic_object" 70377a3b38f7Smrg fi 70387a3b38f7Smrg else 70397a3b38f7Smrg # Only an error if not doing a dry-run. 70407a3b38f7Smrg if $opt_dry_run; then 70417a3b38f7Smrg # Extract subdirectory from the argument. 70427a3b38f7Smrg func_dirname "$arg" "/" "" 70436fc0178dSmrg xdir=$func_dirname_result 70447a3b38f7Smrg 70457a3b38f7Smrg func_lo2o "$arg" 70467a3b38f7Smrg pic_object=$xdir$objdir/$func_lo2o_result 70477a3b38f7Smrg non_pic_object=$xdir$func_lo2o_result 70487a3b38f7Smrg func_append libobjs " $pic_object" 70497a3b38f7Smrg func_append non_pic_objects " $non_pic_object" 70507a3b38f7Smrg else 70516fc0178dSmrg func_fatal_error "'$arg' is not a valid libtool object" 70527a3b38f7Smrg fi 70537a3b38f7Smrg fi 70547a3b38f7Smrg done 70557a3b38f7Smrg else 70566fc0178dSmrg func_fatal_error "link input file '$arg' does not exist" 70577a3b38f7Smrg fi 70587a3b38f7Smrg arg=$save_arg 70597a3b38f7Smrg prev= 70607a3b38f7Smrg continue 70617a3b38f7Smrg ;; 70626fc0178dSmrg os2dllname) 70636fc0178dSmrg os2dllname=$arg 70646fc0178dSmrg prev= 70656fc0178dSmrg continue 70666fc0178dSmrg ;; 70677a3b38f7Smrg precious_regex) 70686fc0178dSmrg precious_files_regex=$arg 70697a3b38f7Smrg prev= 70707a3b38f7Smrg continue 70717a3b38f7Smrg ;; 70727a3b38f7Smrg release) 70736fc0178dSmrg release=-$arg 70747a3b38f7Smrg prev= 70757a3b38f7Smrg continue 70767a3b38f7Smrg ;; 70777a3b38f7Smrg rpath | xrpath) 70787a3b38f7Smrg # We need an absolute path. 70797a3b38f7Smrg case $arg in 70807a3b38f7Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 70817a3b38f7Smrg *) 70827a3b38f7Smrg func_fatal_error "only absolute run-paths are allowed" 70837a3b38f7Smrg ;; 70847a3b38f7Smrg esac 70856fc0178dSmrg if test rpath = "$prev"; then 70867a3b38f7Smrg case "$rpath " in 70877a3b38f7Smrg *" $arg "*) ;; 7088862f5301Smrg *) func_append rpath " $arg" ;; 70897a3b38f7Smrg esac 70907a3b38f7Smrg else 70917a3b38f7Smrg case "$xrpath " in 70927a3b38f7Smrg *" $arg "*) ;; 7093862f5301Smrg *) func_append xrpath " $arg" ;; 70947a3b38f7Smrg esac 70957a3b38f7Smrg fi 70967a3b38f7Smrg prev= 70977a3b38f7Smrg continue 70987a3b38f7Smrg ;; 70997a3b38f7Smrg shrext) 71006fc0178dSmrg shrext_cmds=$arg 71017a3b38f7Smrg prev= 71027a3b38f7Smrg continue 71037a3b38f7Smrg ;; 71047a3b38f7Smrg weak) 7105862f5301Smrg func_append weak_libs " $arg" 71067a3b38f7Smrg prev= 71077a3b38f7Smrg continue 71087a3b38f7Smrg ;; 7109515ec619Smrg xassembler) 7110515ec619Smrg func_append compiler_flags " -Xassembler $qarg" 7111515ec619Smrg prev= 7112515ec619Smrg func_append compile_command " -Xassembler $qarg" 7113515ec619Smrg func_append finalize_command " -Xassembler $qarg" 7114515ec619Smrg continue 7115515ec619Smrg ;; 71167a3b38f7Smrg xcclinker) 7117862f5301Smrg func_append linker_flags " $qarg" 7118862f5301Smrg func_append compiler_flags " $qarg" 71197a3b38f7Smrg prev= 71207a3b38f7Smrg func_append compile_command " $qarg" 71217a3b38f7Smrg func_append finalize_command " $qarg" 71227a3b38f7Smrg continue 71237a3b38f7Smrg ;; 71247a3b38f7Smrg xcompiler) 7125862f5301Smrg func_append compiler_flags " $qarg" 71267a3b38f7Smrg prev= 71277a3b38f7Smrg func_append compile_command " $qarg" 71287a3b38f7Smrg func_append finalize_command " $qarg" 71297a3b38f7Smrg continue 71307a3b38f7Smrg ;; 71317a3b38f7Smrg xlinker) 7132862f5301Smrg func_append linker_flags " $qarg" 7133862f5301Smrg func_append compiler_flags " $wl$qarg" 71347a3b38f7Smrg prev= 71357a3b38f7Smrg func_append compile_command " $wl$qarg" 71367a3b38f7Smrg func_append finalize_command " $wl$qarg" 71377a3b38f7Smrg continue 71387a3b38f7Smrg ;; 71397a3b38f7Smrg *) 71407a3b38f7Smrg eval "$prev=\"\$arg\"" 71417a3b38f7Smrg prev= 71427a3b38f7Smrg continue 71437a3b38f7Smrg ;; 7144ff559fabSmrg esac 71457a3b38f7Smrg fi # test -n "$prev" 7146ff559fabSmrg 71476fc0178dSmrg prevarg=$arg 7148ff559fabSmrg 71497a3b38f7Smrg case $arg in 71507a3b38f7Smrg -all-static) 71517a3b38f7Smrg if test -n "$link_static_flag"; then 71527a3b38f7Smrg # See comment for -static flag below, for more details. 71537a3b38f7Smrg func_append compile_command " $link_static_flag" 71547a3b38f7Smrg func_append finalize_command " $link_static_flag" 71557a3b38f7Smrg fi 71567a3b38f7Smrg continue 71577a3b38f7Smrg ;; 7158ff559fabSmrg 71597a3b38f7Smrg -allow-undefined) 71607a3b38f7Smrg # FIXME: remove this flag sometime in the future. 71616fc0178dSmrg func_fatal_error "'-allow-undefined' must not be used because it is the default" 71627a3b38f7Smrg ;; 7163ff559fabSmrg 71647a3b38f7Smrg -avoid-version) 71657a3b38f7Smrg avoid_version=yes 71667a3b38f7Smrg continue 71677a3b38f7Smrg ;; 7168ff559fabSmrg 716944dda7b2Smrg -bindir) 717044dda7b2Smrg prev=bindir 717144dda7b2Smrg continue 717244dda7b2Smrg ;; 717344dda7b2Smrg 71747a3b38f7Smrg -dlopen) 71757a3b38f7Smrg prev=dlfiles 71767a3b38f7Smrg continue 71777a3b38f7Smrg ;; 7178ff559fabSmrg 71797a3b38f7Smrg -dlpreopen) 71807a3b38f7Smrg prev=dlprefiles 71817a3b38f7Smrg continue 71827a3b38f7Smrg ;; 7183ff559fabSmrg 71847a3b38f7Smrg -export-dynamic) 71857a3b38f7Smrg export_dynamic=yes 71867a3b38f7Smrg continue 71877a3b38f7Smrg ;; 7188ff559fabSmrg 71897a3b38f7Smrg -export-symbols | -export-symbols-regex) 71907a3b38f7Smrg if test -n "$export_symbols" || test -n "$export_symbols_regex"; then 71917a3b38f7Smrg func_fatal_error "more than one -exported-symbols argument is not allowed" 71927a3b38f7Smrg fi 71936fc0178dSmrg if test X-export-symbols = "X$arg"; then 71947a3b38f7Smrg prev=expsyms 71957a3b38f7Smrg else 71967a3b38f7Smrg prev=expsyms_regex 71977a3b38f7Smrg fi 71987a3b38f7Smrg continue 71997a3b38f7Smrg ;; 7200ff559fabSmrg 72017a3b38f7Smrg -framework) 72027a3b38f7Smrg prev=framework 72037a3b38f7Smrg continue 72047a3b38f7Smrg ;; 7205ff559fabSmrg 72067a3b38f7Smrg -inst-prefix-dir) 72077a3b38f7Smrg prev=inst_prefix 72087a3b38f7Smrg continue 72097a3b38f7Smrg ;; 7210ff559fabSmrg 72117a3b38f7Smrg # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* 72127a3b38f7Smrg # so, if we see these flags be careful not to treat them like -L 72137a3b38f7Smrg -L[A-Z][A-Z]*:*) 72147a3b38f7Smrg case $with_gcc/$host in 72157a3b38f7Smrg no/*-*-irix* | /*-*-irix*) 72167a3b38f7Smrg func_append compile_command " $arg" 72177a3b38f7Smrg func_append finalize_command " $arg" 72187a3b38f7Smrg ;; 72197a3b38f7Smrg esac 72207a3b38f7Smrg continue 72217a3b38f7Smrg ;; 7222ff559fabSmrg 72237a3b38f7Smrg -L*) 7224862f5301Smrg func_stripname "-L" '' "$arg" 7225862f5301Smrg if test -z "$func_stripname_result"; then 72267a3b38f7Smrg if test "$#" -gt 0; then 72276fc0178dSmrg func_fatal_error "require no space between '-L' and '$1'" 72287a3b38f7Smrg else 72296fc0178dSmrg func_fatal_error "need path for '-L' option" 72307a3b38f7Smrg fi 72317a3b38f7Smrg fi 7232862f5301Smrg func_resolve_sysroot "$func_stripname_result" 7233862f5301Smrg dir=$func_resolve_sysroot_result 72347a3b38f7Smrg # We need an absolute path. 72357a3b38f7Smrg case $dir in 72367a3b38f7Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 72377a3b38f7Smrg *) 72387a3b38f7Smrg absdir=`cd "$dir" && pwd` 72397a3b38f7Smrg test -z "$absdir" && \ 72406fc0178dSmrg func_fatal_error "cannot determine absolute directory name of '$dir'" 72416fc0178dSmrg dir=$absdir 72427a3b38f7Smrg ;; 72437a3b38f7Smrg esac 72447a3b38f7Smrg case "$deplibs " in 7245862f5301Smrg *" -L$dir "* | *" $arg "*) 7246862f5301Smrg # Will only happen for absolute or sysroot arguments 7247862f5301Smrg ;; 72487a3b38f7Smrg *) 7249862f5301Smrg # Preserve sysroot, but never include relative directories 7250862f5301Smrg case $dir in 7251862f5301Smrg [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; 7252862f5301Smrg *) func_append deplibs " -L$dir" ;; 7253862f5301Smrg esac 7254862f5301Smrg func_append lib_search_path " $dir" 72557a3b38f7Smrg ;; 72567a3b38f7Smrg esac 72577a3b38f7Smrg case $host in 72587a3b38f7Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 725944dda7b2Smrg testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` 72607a3b38f7Smrg case :$dllsearchpath: in 72617a3b38f7Smrg *":$dir:"*) ;; 72627a3b38f7Smrg ::) dllsearchpath=$dir;; 7263862f5301Smrg *) func_append dllsearchpath ":$dir";; 72647a3b38f7Smrg esac 72657a3b38f7Smrg case :$dllsearchpath: in 72667a3b38f7Smrg *":$testbindir:"*) ;; 72677a3b38f7Smrg ::) dllsearchpath=$testbindir;; 7268862f5301Smrg *) func_append dllsearchpath ":$testbindir";; 72697a3b38f7Smrg esac 72707a3b38f7Smrg ;; 72717a3b38f7Smrg esac 72727a3b38f7Smrg continue 72737a3b38f7Smrg ;; 7274ff559fabSmrg 72757a3b38f7Smrg -l*) 72766fc0178dSmrg if test X-lc = "X$arg" || test X-lm = "X$arg"; then 72777a3b38f7Smrg case $host in 727844dda7b2Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) 72797a3b38f7Smrg # These systems don't actually have a C or math library (as such) 72807a3b38f7Smrg continue 72817a3b38f7Smrg ;; 72827a3b38f7Smrg *-*-os2*) 72837a3b38f7Smrg # These systems don't actually have a C library (as such) 72846fc0178dSmrg test X-lc = "X$arg" && continue 72857a3b38f7Smrg ;; 7286515ec619Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig* | *-*-midnightbsd*) 72877a3b38f7Smrg # Do not include libc due to us having libc/libc_r. 72886fc0178dSmrg test X-lc = "X$arg" && continue 72897a3b38f7Smrg ;; 72907a3b38f7Smrg *-*-rhapsody* | *-*-darwin1.[012]) 72917a3b38f7Smrg # Rhapsody C and math libraries are in the System framework 7292862f5301Smrg func_append deplibs " System.ltframework" 72937a3b38f7Smrg continue 72947a3b38f7Smrg ;; 72957a3b38f7Smrg *-*-sco3.2v5* | *-*-sco5v6*) 72967a3b38f7Smrg # Causes problems with __ctype 72976fc0178dSmrg test X-lc = "X$arg" && continue 72987a3b38f7Smrg ;; 72997a3b38f7Smrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 73007a3b38f7Smrg # Compiler inserts libc in the correct place for threads to work 73016fc0178dSmrg test X-lc = "X$arg" && continue 73027a3b38f7Smrg ;; 73037a3b38f7Smrg esac 73046fc0178dSmrg elif test X-lc_r = "X$arg"; then 73057a3b38f7Smrg case $host in 7306515ec619Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig* | *-*-midnightbsd*) 73077a3b38f7Smrg # Do not include libc_r directly, use -pthread flag. 73087a3b38f7Smrg continue 73097a3b38f7Smrg ;; 73107a3b38f7Smrg esac 73117a3b38f7Smrg fi 7312862f5301Smrg func_append deplibs " $arg" 73137a3b38f7Smrg continue 73147a3b38f7Smrg ;; 7315ff559fabSmrg 73166fc0178dSmrg -mllvm) 73176fc0178dSmrg prev=mllvm 73186fc0178dSmrg continue 73196fc0178dSmrg ;; 73206fc0178dSmrg 73217a3b38f7Smrg -module) 73227a3b38f7Smrg module=yes 73237a3b38f7Smrg continue 73247a3b38f7Smrg ;; 7325ff559fabSmrg 73267a3b38f7Smrg # Tru64 UNIX uses -model [arg] to determine the layout of C++ 73277a3b38f7Smrg # classes, name mangling, and exception handling. 73287a3b38f7Smrg # Darwin uses the -arch flag to determine output architecture. 7329862f5301Smrg -model|-arch|-isysroot|--sysroot) 7330862f5301Smrg func_append compiler_flags " $arg" 73317a3b38f7Smrg func_append compile_command " $arg" 73327a3b38f7Smrg func_append finalize_command " $arg" 73337a3b38f7Smrg prev=xcompiler 73347a3b38f7Smrg continue 73357a3b38f7Smrg ;; 7336515ec619Smrg # Solaris ld rejects as of 11.4. Refer to Oracle bug 22985199. 7337515ec619Smrg -pthread) 7338515ec619Smrg case $host in 7339515ec619Smrg *solaris2*) ;; 7340515ec619Smrg *) 7341515ec619Smrg case "$new_inherited_linker_flags " in 7342515ec619Smrg *" $arg "*) ;; 7343515ec619Smrg * ) func_append new_inherited_linker_flags " $arg" ;; 7344515ec619Smrg esac 7345515ec619Smrg ;; 7346515ec619Smrg esac 7347515ec619Smrg continue 7348515ec619Smrg ;; 7349515ec619Smrg -mt|-mthreads|-kthread|-Kthread|-pthreads|--thread-safe \ 7350fc544a13Smrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 7351862f5301Smrg func_append compiler_flags " $arg" 73527a3b38f7Smrg func_append compile_command " $arg" 73537a3b38f7Smrg func_append finalize_command " $arg" 73547a3b38f7Smrg case "$new_inherited_linker_flags " in 73557a3b38f7Smrg *" $arg "*) ;; 7356862f5301Smrg * ) func_append new_inherited_linker_flags " $arg" ;; 73577a3b38f7Smrg esac 73587a3b38f7Smrg continue 73597a3b38f7Smrg ;; 7360ff559fabSmrg 73617a3b38f7Smrg -multi_module) 73626fc0178dSmrg single_module=$wl-multi_module 73637a3b38f7Smrg continue 73647a3b38f7Smrg ;; 7365ff559fabSmrg 73667a3b38f7Smrg -no-fast-install) 73677a3b38f7Smrg fast_install=no 73687a3b38f7Smrg continue 73697a3b38f7Smrg ;; 7370ff559fabSmrg 73717a3b38f7Smrg -no-install) 73727a3b38f7Smrg case $host in 73737a3b38f7Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) 73747a3b38f7Smrg # The PATH hackery in wrapper scripts is required on Windows 73757a3b38f7Smrg # and Darwin in order for the loader to find any dlls it needs. 73766fc0178dSmrg func_warning "'-no-install' is ignored for $host" 73776fc0178dSmrg func_warning "assuming '-no-fast-install' instead" 73787a3b38f7Smrg fast_install=no 73797a3b38f7Smrg ;; 73807a3b38f7Smrg *) no_install=yes ;; 73817a3b38f7Smrg esac 73827a3b38f7Smrg continue 73837a3b38f7Smrg ;; 7384ff559fabSmrg 73857a3b38f7Smrg -no-undefined) 73867a3b38f7Smrg allow_undefined=no 73877a3b38f7Smrg continue 73887a3b38f7Smrg ;; 7389ff559fabSmrg 73907a3b38f7Smrg -objectlist) 73917a3b38f7Smrg prev=objectlist 73927a3b38f7Smrg continue 73937a3b38f7Smrg ;; 7394ff559fabSmrg 73956fc0178dSmrg -os2dllname) 73966fc0178dSmrg prev=os2dllname 73976fc0178dSmrg continue 73986fc0178dSmrg ;; 73996fc0178dSmrg 74007a3b38f7Smrg -o) prev=output ;; 7401ff559fabSmrg 74027a3b38f7Smrg -precious-files-regex) 74037a3b38f7Smrg prev=precious_regex 74047a3b38f7Smrg continue 74057a3b38f7Smrg ;; 7406ff559fabSmrg 74077a3b38f7Smrg -release) 74087a3b38f7Smrg prev=release 74097a3b38f7Smrg continue 74107a3b38f7Smrg ;; 7411ff559fabSmrg 74127a3b38f7Smrg -rpath) 74137a3b38f7Smrg prev=rpath 74147a3b38f7Smrg continue 74157a3b38f7Smrg ;; 7416ff559fabSmrg 74177a3b38f7Smrg -R) 74187a3b38f7Smrg prev=xrpath 74197a3b38f7Smrg continue 74207a3b38f7Smrg ;; 7421ff559fabSmrg 74227a3b38f7Smrg -R*) 74237a3b38f7Smrg func_stripname '-R' '' "$arg" 74247a3b38f7Smrg dir=$func_stripname_result 74257a3b38f7Smrg # We need an absolute path. 74267a3b38f7Smrg case $dir in 74277a3b38f7Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 7428862f5301Smrg =*) 7429862f5301Smrg func_stripname '=' '' "$dir" 7430862f5301Smrg dir=$lt_sysroot$func_stripname_result 7431862f5301Smrg ;; 74327a3b38f7Smrg *) 74337a3b38f7Smrg func_fatal_error "only absolute run-paths are allowed" 74347a3b38f7Smrg ;; 74357a3b38f7Smrg esac 74367a3b38f7Smrg case "$xrpath " in 74377a3b38f7Smrg *" $dir "*) ;; 7438862f5301Smrg *) func_append xrpath " $dir" ;; 74397a3b38f7Smrg esac 74407a3b38f7Smrg continue 74417a3b38f7Smrg ;; 7442ff559fabSmrg 74437a3b38f7Smrg -shared) 74447a3b38f7Smrg # The effects of -shared are defined in a previous loop. 74457a3b38f7Smrg continue 74467a3b38f7Smrg ;; 7447ff559fabSmrg 74487a3b38f7Smrg -shrext) 74497a3b38f7Smrg prev=shrext 74507a3b38f7Smrg continue 74517a3b38f7Smrg ;; 7452ff559fabSmrg 74537a3b38f7Smrg -static | -static-libtool-libs) 74547a3b38f7Smrg # The effects of -static are defined in a previous loop. 74557a3b38f7Smrg # We used to do the same as -all-static on platforms that 74567a3b38f7Smrg # didn't have a PIC flag, but the assumption that the effects 74577a3b38f7Smrg # would be equivalent was wrong. It would break on at least 74587a3b38f7Smrg # Digital Unix and AIX. 74597a3b38f7Smrg continue 74607a3b38f7Smrg ;; 7461ff559fabSmrg 74627a3b38f7Smrg -thread-safe) 74637a3b38f7Smrg thread_safe=yes 74647a3b38f7Smrg continue 74657a3b38f7Smrg ;; 7466ff559fabSmrg 74677a3b38f7Smrg -version-info) 74687a3b38f7Smrg prev=vinfo 74697a3b38f7Smrg continue 74707a3b38f7Smrg ;; 7471ff559fabSmrg 74727a3b38f7Smrg -version-number) 74737a3b38f7Smrg prev=vinfo 74747a3b38f7Smrg vinfo_number=yes 74757a3b38f7Smrg continue 74767a3b38f7Smrg ;; 7477ff559fabSmrg 74787a3b38f7Smrg -weak) 74797a3b38f7Smrg prev=weak 74807a3b38f7Smrg continue 74817a3b38f7Smrg ;; 7482ff559fabSmrg 74837a3b38f7Smrg -Wc,*) 74847a3b38f7Smrg func_stripname '-Wc,' '' "$arg" 74857a3b38f7Smrg args=$func_stripname_result 74867a3b38f7Smrg arg= 74876fc0178dSmrg save_ifs=$IFS; IFS=, 74887a3b38f7Smrg for flag in $args; do 74896fc0178dSmrg IFS=$save_ifs 7490515ec619Smrg func_quote_arg pretty "$flag" 7491515ec619Smrg func_append arg " $func_quote_arg_result" 7492515ec619Smrg func_append compiler_flags " $func_quote_arg_result" 74937a3b38f7Smrg done 74946fc0178dSmrg IFS=$save_ifs 74957a3b38f7Smrg func_stripname ' ' '' "$arg" 74967a3b38f7Smrg arg=$func_stripname_result 74977a3b38f7Smrg ;; 7498ff559fabSmrg 74997a3b38f7Smrg -Wl,*) 75007a3b38f7Smrg func_stripname '-Wl,' '' "$arg" 75017a3b38f7Smrg args=$func_stripname_result 75027a3b38f7Smrg arg= 75036fc0178dSmrg save_ifs=$IFS; IFS=, 75047a3b38f7Smrg for flag in $args; do 75056fc0178dSmrg IFS=$save_ifs 7506515ec619Smrg func_quote_arg pretty "$flag" 7507515ec619Smrg func_append arg " $wl$func_quote_arg_result" 7508515ec619Smrg func_append compiler_flags " $wl$func_quote_arg_result" 7509515ec619Smrg func_append linker_flags " $func_quote_arg_result" 75107a3b38f7Smrg done 75116fc0178dSmrg IFS=$save_ifs 75127a3b38f7Smrg func_stripname ' ' '' "$arg" 75137a3b38f7Smrg arg=$func_stripname_result 75147a3b38f7Smrg ;; 7515ff559fabSmrg 7516515ec619Smrg -Xassembler) 7517515ec619Smrg prev=xassembler 7518515ec619Smrg continue 7519515ec619Smrg ;; 7520515ec619Smrg 75217a3b38f7Smrg -Xcompiler) 75227a3b38f7Smrg prev=xcompiler 75237a3b38f7Smrg continue 75247a3b38f7Smrg ;; 7525ff559fabSmrg 75267a3b38f7Smrg -Xlinker) 75277a3b38f7Smrg prev=xlinker 75287a3b38f7Smrg continue 75297a3b38f7Smrg ;; 7530ff559fabSmrg 75317a3b38f7Smrg -XCClinker) 75327a3b38f7Smrg prev=xcclinker 75337a3b38f7Smrg continue 75347a3b38f7Smrg ;; 7535ff559fabSmrg 75367a3b38f7Smrg # -msg_* for osf cc 75377a3b38f7Smrg -msg_*) 7538515ec619Smrg func_quote_arg pretty "$arg" 7539515ec619Smrg arg=$func_quote_arg_result 75407a3b38f7Smrg ;; 7541ff559fabSmrg 754244dda7b2Smrg # Flags to be passed through unchanged, with rationale: 754344dda7b2Smrg # -64, -mips[0-9] enable 64-bit mode for the SGI compiler 754444dda7b2Smrg # -r[0-9][0-9]* specify processor for the SGI compiler 754544dda7b2Smrg # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler 754644dda7b2Smrg # +DA*, +DD* enable 64-bit mode for the HP compiler 754744dda7b2Smrg # -q* compiler args for the IBM compiler 754844dda7b2Smrg # -m*, -t[45]*, -txscale* architecture-specific flags for GCC 754944dda7b2Smrg # -F/path path to uninstalled frameworks, gcc on darwin 755044dda7b2Smrg # -p, -pg, --coverage, -fprofile-* profiling flags for GCC 75516fc0178dSmrg # -fstack-protector* stack protector flags for GCC 755244dda7b2Smrg # @file GCC response files 755344dda7b2Smrg # -tp=* Portland pgcc target processor selection 7554862f5301Smrg # --sysroot=* for sysroot support 75556fc0178dSmrg # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization 7556515ec619Smrg # -specs=* GCC specs files 75576fc0178dSmrg # -stdlib=* select c++ std lib with clang 7558515ec619Smrg # -fsanitize=* Clang/GCC memory and address sanitizer 7559515ec619Smrg # -fuse-ld=* Linker select flags for GCC 7560515ec619Smrg # -Wa,* Pass flags directly to the assembler 75617a3b38f7Smrg -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ 7562862f5301Smrg -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ 7563515ec619Smrg -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*| \ 7564515ec619Smrg -specs=*|-fsanitize=*|-fuse-ld=*|-Wa,*) 7565515ec619Smrg func_quote_arg pretty "$arg" 7566515ec619Smrg arg=$func_quote_arg_result 75677a3b38f7Smrg func_append compile_command " $arg" 75687a3b38f7Smrg func_append finalize_command " $arg" 7569862f5301Smrg func_append compiler_flags " $arg" 75707a3b38f7Smrg continue 75717a3b38f7Smrg ;; 7572ff559fabSmrg 75736fc0178dSmrg -Z*) 75746fc0178dSmrg if test os2 = "`expr $host : '.*\(os2\)'`"; then 75756fc0178dSmrg # OS/2 uses -Zxxx to specify OS/2-specific options 75766fc0178dSmrg compiler_flags="$compiler_flags $arg" 75776fc0178dSmrg func_append compile_command " $arg" 75786fc0178dSmrg func_append finalize_command " $arg" 75796fc0178dSmrg case $arg in 75806fc0178dSmrg -Zlinker | -Zstack) 75816fc0178dSmrg prev=xcompiler 75826fc0178dSmrg ;; 75836fc0178dSmrg esac 75846fc0178dSmrg continue 75856fc0178dSmrg else 75866fc0178dSmrg # Otherwise treat like 'Some other compiler flag' below 7587515ec619Smrg func_quote_arg pretty "$arg" 7588515ec619Smrg arg=$func_quote_arg_result 75896fc0178dSmrg fi 75906fc0178dSmrg ;; 75916fc0178dSmrg 75927a3b38f7Smrg # Some other compiler flag. 75937a3b38f7Smrg -* | +*) 7594515ec619Smrg func_quote_arg pretty "$arg" 7595515ec619Smrg arg=$func_quote_arg_result 75967a3b38f7Smrg ;; 7597ff559fabSmrg 75987a3b38f7Smrg *.$objext) 75997a3b38f7Smrg # A standard object. 7600862f5301Smrg func_append objs " $arg" 76017a3b38f7Smrg ;; 76027a3b38f7Smrg 76037a3b38f7Smrg *.lo) 76047a3b38f7Smrg # A libtool-controlled object. 76057a3b38f7Smrg 76067a3b38f7Smrg # Check to see that this really is a libtool object. 76077a3b38f7Smrg if func_lalib_unsafe_p "$arg"; then 76087a3b38f7Smrg pic_object= 76097a3b38f7Smrg non_pic_object= 76107a3b38f7Smrg 76117a3b38f7Smrg # Read the .lo file 76127a3b38f7Smrg func_source "$arg" 76137a3b38f7Smrg 76147a3b38f7Smrg if test -z "$pic_object" || 76157a3b38f7Smrg test -z "$non_pic_object" || 76166fc0178dSmrg test none = "$pic_object" && 76176fc0178dSmrg test none = "$non_pic_object"; then 76186fc0178dSmrg func_fatal_error "cannot find name of object for '$arg'" 76197a3b38f7Smrg fi 76207a3b38f7Smrg 76217a3b38f7Smrg # Extract subdirectory from the argument. 76227a3b38f7Smrg func_dirname "$arg" "/" "" 76236fc0178dSmrg xdir=$func_dirname_result 76247a3b38f7Smrg 76256fc0178dSmrg test none = "$pic_object" || { 76267a3b38f7Smrg # Prepend the subdirectory the object is found in. 76276fc0178dSmrg pic_object=$xdir$pic_object 76287a3b38f7Smrg 76296fc0178dSmrg if test dlfiles = "$prev"; then 76306fc0178dSmrg if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 7631862f5301Smrg func_append dlfiles " $pic_object" 76327a3b38f7Smrg prev= 76337a3b38f7Smrg continue 76347a3b38f7Smrg else 76357a3b38f7Smrg # If libtool objects are unsupported, then we need to preload. 76367a3b38f7Smrg prev=dlprefiles 76377a3b38f7Smrg fi 76387a3b38f7Smrg fi 76397a3b38f7Smrg 76407a3b38f7Smrg # CHECK ME: I think I busted this. -Ossama 76416fc0178dSmrg if test dlprefiles = "$prev"; then 76427a3b38f7Smrg # Preload the old-style object. 7643862f5301Smrg func_append dlprefiles " $pic_object" 76447a3b38f7Smrg prev= 76457a3b38f7Smrg fi 76467a3b38f7Smrg 76477a3b38f7Smrg # A PIC object. 76487a3b38f7Smrg func_append libobjs " $pic_object" 76496fc0178dSmrg arg=$pic_object 76506fc0178dSmrg } 76517a3b38f7Smrg 76527a3b38f7Smrg # Non-PIC object. 76536fc0178dSmrg if test none != "$non_pic_object"; then 76547a3b38f7Smrg # Prepend the subdirectory the object is found in. 76556fc0178dSmrg non_pic_object=$xdir$non_pic_object 76567a3b38f7Smrg 76577a3b38f7Smrg # A standard non-PIC object 76587a3b38f7Smrg func_append non_pic_objects " $non_pic_object" 76596fc0178dSmrg if test -z "$pic_object" || test none = "$pic_object"; then 76606fc0178dSmrg arg=$non_pic_object 76617a3b38f7Smrg fi 76627a3b38f7Smrg else 76637a3b38f7Smrg # If the PIC object exists, use it instead. 76647a3b38f7Smrg # $xdir was prepended to $pic_object above. 76656fc0178dSmrg non_pic_object=$pic_object 76667a3b38f7Smrg func_append non_pic_objects " $non_pic_object" 76677a3b38f7Smrg fi 76687a3b38f7Smrg else 76697a3b38f7Smrg # Only an error if not doing a dry-run. 76707a3b38f7Smrg if $opt_dry_run; then 76717a3b38f7Smrg # Extract subdirectory from the argument. 76727a3b38f7Smrg func_dirname "$arg" "/" "" 76736fc0178dSmrg xdir=$func_dirname_result 76747a3b38f7Smrg 76757a3b38f7Smrg func_lo2o "$arg" 76767a3b38f7Smrg pic_object=$xdir$objdir/$func_lo2o_result 76777a3b38f7Smrg non_pic_object=$xdir$func_lo2o_result 76787a3b38f7Smrg func_append libobjs " $pic_object" 76797a3b38f7Smrg func_append non_pic_objects " $non_pic_object" 76807a3b38f7Smrg else 76816fc0178dSmrg func_fatal_error "'$arg' is not a valid libtool object" 76827a3b38f7Smrg fi 76837a3b38f7Smrg fi 76847a3b38f7Smrg ;; 76857a3b38f7Smrg 76867a3b38f7Smrg *.$libext) 76877a3b38f7Smrg # An archive. 7688862f5301Smrg func_append deplibs " $arg" 7689862f5301Smrg func_append old_deplibs " $arg" 76907a3b38f7Smrg continue 76917a3b38f7Smrg ;; 76927a3b38f7Smrg 76937a3b38f7Smrg *.la) 76947a3b38f7Smrg # A libtool-controlled library. 76957a3b38f7Smrg 7696862f5301Smrg func_resolve_sysroot "$arg" 76976fc0178dSmrg if test dlfiles = "$prev"; then 76987a3b38f7Smrg # This library was specified with -dlopen. 7699862f5301Smrg func_append dlfiles " $func_resolve_sysroot_result" 77007a3b38f7Smrg prev= 77016fc0178dSmrg elif test dlprefiles = "$prev"; then 77027a3b38f7Smrg # The library was specified with -dlpreopen. 7703862f5301Smrg func_append dlprefiles " $func_resolve_sysroot_result" 77047a3b38f7Smrg prev= 77057a3b38f7Smrg else 7706862f5301Smrg func_append deplibs " $func_resolve_sysroot_result" 77077a3b38f7Smrg fi 77087a3b38f7Smrg continue 77097a3b38f7Smrg ;; 77107a3b38f7Smrg 77117a3b38f7Smrg # Some other compiler argument. 77127a3b38f7Smrg *) 77137a3b38f7Smrg # Unknown arguments in both finalize_command and compile_command need 77147a3b38f7Smrg # to be aesthetically quoted because they are evaled later. 7715515ec619Smrg func_quote_arg pretty "$arg" 7716515ec619Smrg arg=$func_quote_arg_result 77177a3b38f7Smrg ;; 77187a3b38f7Smrg esac # arg 77197a3b38f7Smrg 77207a3b38f7Smrg # Now actually substitute the argument into the commands. 77217a3b38f7Smrg if test -n "$arg"; then 77227a3b38f7Smrg func_append compile_command " $arg" 77237a3b38f7Smrg func_append finalize_command " $arg" 77247a3b38f7Smrg fi 77257a3b38f7Smrg done # argument parsing loop 77267a3b38f7Smrg 77277a3b38f7Smrg test -n "$prev" && \ 77286fc0178dSmrg func_fatal_help "the '$prevarg' option requires an argument" 77297a3b38f7Smrg 77306fc0178dSmrg if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then 77317a3b38f7Smrg eval arg=\"$export_dynamic_flag_spec\" 77327a3b38f7Smrg func_append compile_command " $arg" 77337a3b38f7Smrg func_append finalize_command " $arg" 77347a3b38f7Smrg fi 77357a3b38f7Smrg 77367a3b38f7Smrg oldlibs= 77377a3b38f7Smrg # calculate the name of the file, without its directory 77387a3b38f7Smrg func_basename "$output" 77396fc0178dSmrg outputname=$func_basename_result 77406fc0178dSmrg libobjs_save=$libobjs 77417a3b38f7Smrg 77427a3b38f7Smrg if test -n "$shlibpath_var"; then 77437a3b38f7Smrg # get the directories listed in $shlibpath_var 77446fc0178dSmrg eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\` 7745ff559fabSmrg else 77467a3b38f7Smrg shlib_search_path= 7747ff559fabSmrg fi 77487a3b38f7Smrg eval sys_lib_search_path=\"$sys_lib_search_path_spec\" 77497a3b38f7Smrg eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" 7750ff559fabSmrg 77516fc0178dSmrg # Definition is injected by LT_CONFIG during libtool generation. 77526fc0178dSmrg func_munge_path_list sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH" 77536fc0178dSmrg 77547a3b38f7Smrg func_dirname "$output" "/" "" 77556fc0178dSmrg output_objdir=$func_dirname_result$objdir 7756862f5301Smrg func_to_tool_file "$output_objdir/" 7757862f5301Smrg tool_output_objdir=$func_to_tool_file_result 77587a3b38f7Smrg # Create the object directory. 77597a3b38f7Smrg func_mkdir_p "$output_objdir" 7760ff559fabSmrg 77617a3b38f7Smrg # Determine the type of output 77627a3b38f7Smrg case $output in 77637a3b38f7Smrg "") 77647a3b38f7Smrg func_fatal_help "you must specify an output file" 77657a3b38f7Smrg ;; 77667a3b38f7Smrg *.$libext) linkmode=oldlib ;; 77677a3b38f7Smrg *.lo | *.$objext) linkmode=obj ;; 77687a3b38f7Smrg *.la) linkmode=lib ;; 77697a3b38f7Smrg *) linkmode=prog ;; # Anything else should be a program. 77707a3b38f7Smrg esac 77717a3b38f7Smrg 77727a3b38f7Smrg specialdeplibs= 77737a3b38f7Smrg 77747a3b38f7Smrg libs= 77757a3b38f7Smrg # Find all interdependent deplibs by searching for libraries 77767a3b38f7Smrg # that are linked more than once (e.g. -la -lb -la) 77777a3b38f7Smrg for deplib in $deplibs; do 77786fc0178dSmrg if $opt_preserve_dup_deps; then 77797a3b38f7Smrg case "$libs " in 7780862f5301Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 77817a3b38f7Smrg esac 77827a3b38f7Smrg fi 7783862f5301Smrg func_append libs " $deplib" 77847a3b38f7Smrg done 77857a3b38f7Smrg 77866fc0178dSmrg if test lib = "$linkmode"; then 77877a3b38f7Smrg libs="$predeps $libs $compiler_lib_search_path $postdeps" 77887a3b38f7Smrg 77897a3b38f7Smrg # Compute libraries that are listed more than once in $predeps 77907a3b38f7Smrg # $postdeps and mark them as special (i.e., whose duplicates are 77917a3b38f7Smrg # not to be eliminated). 77927a3b38f7Smrg pre_post_deps= 77937a3b38f7Smrg if $opt_duplicate_compiler_generated_deps; then 77947a3b38f7Smrg for pre_post_dep in $predeps $postdeps; do 77957a3b38f7Smrg case "$pre_post_deps " in 7796862f5301Smrg *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; 77977a3b38f7Smrg esac 7798862f5301Smrg func_append pre_post_deps " $pre_post_dep" 77997a3b38f7Smrg done 78007a3b38f7Smrg fi 78017a3b38f7Smrg pre_post_deps= 78027a3b38f7Smrg fi 78037a3b38f7Smrg 78047a3b38f7Smrg deplibs= 78057a3b38f7Smrg newdependency_libs= 78067a3b38f7Smrg newlib_search_path= 78077a3b38f7Smrg need_relink=no # whether we're linking any uninstalled libtool libraries 78087a3b38f7Smrg notinst_deplibs= # not-installed libtool libraries 78097a3b38f7Smrg notinst_path= # paths that contain not-installed libtool libraries 78107a3b38f7Smrg 78117a3b38f7Smrg case $linkmode in 78127a3b38f7Smrg lib) 78137a3b38f7Smrg passes="conv dlpreopen link" 78147a3b38f7Smrg for file in $dlfiles $dlprefiles; do 78157a3b38f7Smrg case $file in 78167a3b38f7Smrg *.la) ;; 78177a3b38f7Smrg *) 78186fc0178dSmrg func_fatal_help "libraries can '-dlopen' only libtool libraries: $file" 78197a3b38f7Smrg ;; 78207a3b38f7Smrg esac 78217a3b38f7Smrg done 78227a3b38f7Smrg ;; 78237a3b38f7Smrg prog) 78247a3b38f7Smrg compile_deplibs= 78257a3b38f7Smrg finalize_deplibs= 78266fc0178dSmrg alldeplibs=false 78277a3b38f7Smrg newdlfiles= 78287a3b38f7Smrg newdlprefiles= 78297a3b38f7Smrg passes="conv scan dlopen dlpreopen link" 78307a3b38f7Smrg ;; 78317a3b38f7Smrg *) passes="conv" 78327a3b38f7Smrg ;; 78337a3b38f7Smrg esac 78347a3b38f7Smrg 78357a3b38f7Smrg for pass in $passes; do 78367a3b38f7Smrg # The preopen pass in lib mode reverses $deplibs; put it back here 78377a3b38f7Smrg # so that -L comes before libs that need it for instance... 78386fc0178dSmrg if test lib,link = "$linkmode,$pass"; then 78397a3b38f7Smrg ## FIXME: Find the place where the list is rebuilt in the wrong 78407a3b38f7Smrg ## order, and fix it there properly 78417a3b38f7Smrg tmp_deplibs= 78427a3b38f7Smrg for deplib in $deplibs; do 78437a3b38f7Smrg tmp_deplibs="$deplib $tmp_deplibs" 78447a3b38f7Smrg done 78456fc0178dSmrg deplibs=$tmp_deplibs 78467a3b38f7Smrg fi 78477a3b38f7Smrg 78486fc0178dSmrg if test lib,link = "$linkmode,$pass" || 78496fc0178dSmrg test prog,scan = "$linkmode,$pass"; then 78506fc0178dSmrg libs=$deplibs 78517a3b38f7Smrg deplibs= 78527a3b38f7Smrg fi 78536fc0178dSmrg if test prog = "$linkmode"; then 78547a3b38f7Smrg case $pass in 78556fc0178dSmrg dlopen) libs=$dlfiles ;; 78566fc0178dSmrg dlpreopen) libs=$dlprefiles ;; 78577a3b38f7Smrg link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; 78587a3b38f7Smrg esac 78597a3b38f7Smrg fi 78606fc0178dSmrg if test lib,dlpreopen = "$linkmode,$pass"; then 78617a3b38f7Smrg # Collect and forward deplibs of preopened libtool libs 78627a3b38f7Smrg for lib in $dlprefiles; do 78637a3b38f7Smrg # Ignore non-libtool-libs 78647a3b38f7Smrg dependency_libs= 7865862f5301Smrg func_resolve_sysroot "$lib" 78667a3b38f7Smrg case $lib in 7867862f5301Smrg *.la) func_source "$func_resolve_sysroot_result" ;; 78687a3b38f7Smrg esac 78697a3b38f7Smrg 78707a3b38f7Smrg # Collect preopened libtool deplibs, except any this library 78717a3b38f7Smrg # has declared as weak libs 78727a3b38f7Smrg for deplib in $dependency_libs; do 787344dda7b2Smrg func_basename "$deplib" 787444dda7b2Smrg deplib_base=$func_basename_result 78757a3b38f7Smrg case " $weak_libs " in 78767a3b38f7Smrg *" $deplib_base "*) ;; 7877862f5301Smrg *) func_append deplibs " $deplib" ;; 78787a3b38f7Smrg esac 78797a3b38f7Smrg done 78807a3b38f7Smrg done 78816fc0178dSmrg libs=$dlprefiles 78827a3b38f7Smrg fi 78836fc0178dSmrg if test dlopen = "$pass"; then 78847a3b38f7Smrg # Collect dlpreopened libraries 78856fc0178dSmrg save_deplibs=$deplibs 78867a3b38f7Smrg deplibs= 78877a3b38f7Smrg fi 78887a3b38f7Smrg 78897a3b38f7Smrg for deplib in $libs; do 78907a3b38f7Smrg lib= 78916fc0178dSmrg found=false 78927a3b38f7Smrg case $deplib in 7893fc544a13Smrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 7894fc544a13Smrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 78956fc0178dSmrg if test prog,link = "$linkmode,$pass"; then 78967a3b38f7Smrg compile_deplibs="$deplib $compile_deplibs" 78977a3b38f7Smrg finalize_deplibs="$deplib $finalize_deplibs" 78987a3b38f7Smrg else 7899862f5301Smrg func_append compiler_flags " $deplib" 79006fc0178dSmrg if test lib = "$linkmode"; then 79017a3b38f7Smrg case "$new_inherited_linker_flags " in 79027a3b38f7Smrg *" $deplib "*) ;; 7903862f5301Smrg * ) func_append new_inherited_linker_flags " $deplib" ;; 79047a3b38f7Smrg esac 79057a3b38f7Smrg fi 79067a3b38f7Smrg fi 79077a3b38f7Smrg continue 79087a3b38f7Smrg ;; 79097a3b38f7Smrg -l*) 79106fc0178dSmrg if test lib != "$linkmode" && test prog != "$linkmode"; then 79116fc0178dSmrg func_warning "'-l' is ignored for archives/objects" 79127a3b38f7Smrg continue 79137a3b38f7Smrg fi 79147a3b38f7Smrg func_stripname '-l' '' "$deplib" 79157a3b38f7Smrg name=$func_stripname_result 79166fc0178dSmrg if test lib = "$linkmode"; then 79177a3b38f7Smrg searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" 79187a3b38f7Smrg else 79197a3b38f7Smrg searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" 79207a3b38f7Smrg fi 79217a3b38f7Smrg for searchdir in $searchdirs; do 79227a3b38f7Smrg for search_ext in .la $std_shrext .so .a; do 79237a3b38f7Smrg # Search the libtool library 79246fc0178dSmrg lib=$searchdir/lib$name$search_ext 79257a3b38f7Smrg if test -f "$lib"; then 79266fc0178dSmrg if test .la = "$search_ext"; then 79276fc0178dSmrg found=: 79287a3b38f7Smrg else 79296fc0178dSmrg found=false 79307a3b38f7Smrg fi 79317a3b38f7Smrg break 2 79327a3b38f7Smrg fi 79337a3b38f7Smrg done 79347a3b38f7Smrg done 79356fc0178dSmrg if $found; then 79366fc0178dSmrg # deplib is a libtool library 79377a3b38f7Smrg # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, 79387a3b38f7Smrg # We need to do some special things here, and not later. 79396fc0178dSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 79407a3b38f7Smrg case " $predeps $postdeps " in 79417a3b38f7Smrg *" $deplib "*) 79427a3b38f7Smrg if func_lalib_p "$lib"; then 79437a3b38f7Smrg library_names= 79447a3b38f7Smrg old_library= 79457a3b38f7Smrg func_source "$lib" 79467a3b38f7Smrg for l in $old_library $library_names; do 79476fc0178dSmrg ll=$l 79487a3b38f7Smrg done 79496fc0178dSmrg if test "X$ll" = "X$old_library"; then # only static version available 79506fc0178dSmrg found=false 79517a3b38f7Smrg func_dirname "$lib" "" "." 79526fc0178dSmrg ladir=$func_dirname_result 79537a3b38f7Smrg lib=$ladir/$old_library 79546fc0178dSmrg if test prog,link = "$linkmode,$pass"; then 79557a3b38f7Smrg compile_deplibs="$deplib $compile_deplibs" 79567a3b38f7Smrg finalize_deplibs="$deplib $finalize_deplibs" 79577a3b38f7Smrg else 79587a3b38f7Smrg deplibs="$deplib $deplibs" 79596fc0178dSmrg test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 79607a3b38f7Smrg fi 79617a3b38f7Smrg continue 79627a3b38f7Smrg fi 79637a3b38f7Smrg fi 79647a3b38f7Smrg ;; 79657a3b38f7Smrg *) ;; 79667a3b38f7Smrg esac 79677a3b38f7Smrg fi 79686fc0178dSmrg else 79696fc0178dSmrg # deplib doesn't seem to be a libtool library 79706fc0178dSmrg if test prog,link = "$linkmode,$pass"; then 79716fc0178dSmrg compile_deplibs="$deplib $compile_deplibs" 79726fc0178dSmrg finalize_deplibs="$deplib $finalize_deplibs" 79736fc0178dSmrg else 79746fc0178dSmrg deplibs="$deplib $deplibs" 79756fc0178dSmrg test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 79766fc0178dSmrg fi 79776fc0178dSmrg continue 79787a3b38f7Smrg fi 79797a3b38f7Smrg ;; # -l 79807a3b38f7Smrg *.ltframework) 79816fc0178dSmrg if test prog,link = "$linkmode,$pass"; then 79827a3b38f7Smrg compile_deplibs="$deplib $compile_deplibs" 79837a3b38f7Smrg finalize_deplibs="$deplib $finalize_deplibs" 79847a3b38f7Smrg else 79857a3b38f7Smrg deplibs="$deplib $deplibs" 79866fc0178dSmrg if test lib = "$linkmode"; then 79877a3b38f7Smrg case "$new_inherited_linker_flags " in 79887a3b38f7Smrg *" $deplib "*) ;; 7989862f5301Smrg * ) func_append new_inherited_linker_flags " $deplib" ;; 79907a3b38f7Smrg esac 79917a3b38f7Smrg fi 79927a3b38f7Smrg fi 79937a3b38f7Smrg continue 79947a3b38f7Smrg ;; 79957a3b38f7Smrg -L*) 79967a3b38f7Smrg case $linkmode in 79977a3b38f7Smrg lib) 79987a3b38f7Smrg deplibs="$deplib $deplibs" 79996fc0178dSmrg test conv = "$pass" && continue 80007a3b38f7Smrg newdependency_libs="$deplib $newdependency_libs" 80017a3b38f7Smrg func_stripname '-L' '' "$deplib" 8002862f5301Smrg func_resolve_sysroot "$func_stripname_result" 8003862f5301Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 80047a3b38f7Smrg ;; 80057a3b38f7Smrg prog) 80066fc0178dSmrg if test conv = "$pass"; then 80077a3b38f7Smrg deplibs="$deplib $deplibs" 80087a3b38f7Smrg continue 80097a3b38f7Smrg fi 80106fc0178dSmrg if test scan = "$pass"; then 80117a3b38f7Smrg deplibs="$deplib $deplibs" 80127a3b38f7Smrg else 80137a3b38f7Smrg compile_deplibs="$deplib $compile_deplibs" 80147a3b38f7Smrg finalize_deplibs="$deplib $finalize_deplibs" 80157a3b38f7Smrg fi 80167a3b38f7Smrg func_stripname '-L' '' "$deplib" 8017862f5301Smrg func_resolve_sysroot "$func_stripname_result" 8018862f5301Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 80197a3b38f7Smrg ;; 80207a3b38f7Smrg *) 80216fc0178dSmrg func_warning "'-L' is ignored for archives/objects" 80227a3b38f7Smrg ;; 80237a3b38f7Smrg esac # linkmode 80247a3b38f7Smrg continue 80257a3b38f7Smrg ;; # -L 80267a3b38f7Smrg -R*) 80276fc0178dSmrg if test link = "$pass"; then 80287a3b38f7Smrg func_stripname '-R' '' "$deplib" 8029862f5301Smrg func_resolve_sysroot "$func_stripname_result" 8030862f5301Smrg dir=$func_resolve_sysroot_result 80317a3b38f7Smrg # Make sure the xrpath contains only unique directories. 80327a3b38f7Smrg case "$xrpath " in 80337a3b38f7Smrg *" $dir "*) ;; 8034862f5301Smrg *) func_append xrpath " $dir" ;; 80357a3b38f7Smrg esac 80367a3b38f7Smrg fi 80377a3b38f7Smrg deplibs="$deplib $deplibs" 80387a3b38f7Smrg continue 80397a3b38f7Smrg ;; 8040862f5301Smrg *.la) 8041862f5301Smrg func_resolve_sysroot "$deplib" 8042862f5301Smrg lib=$func_resolve_sysroot_result 8043862f5301Smrg ;; 80447a3b38f7Smrg *.$libext) 80456fc0178dSmrg if test conv = "$pass"; then 80467a3b38f7Smrg deplibs="$deplib $deplibs" 80477a3b38f7Smrg continue 80487a3b38f7Smrg fi 80497a3b38f7Smrg case $linkmode in 80507a3b38f7Smrg lib) 80517a3b38f7Smrg # Linking convenience modules into shared libraries is allowed, 80527a3b38f7Smrg # but linking other static libraries is non-portable. 80537a3b38f7Smrg case " $dlpreconveniencelibs " in 80547a3b38f7Smrg *" $deplib "*) ;; 80557a3b38f7Smrg *) 80566fc0178dSmrg valid_a_lib=false 80577a3b38f7Smrg case $deplibs_check_method in 80587a3b38f7Smrg match_pattern*) 80597a3b38f7Smrg set dummy $deplibs_check_method; shift 80607a3b38f7Smrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 806144dda7b2Smrg if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ 80627a3b38f7Smrg | $EGREP "$match_pattern_regex" > /dev/null; then 80636fc0178dSmrg valid_a_lib=: 80647a3b38f7Smrg fi 80657a3b38f7Smrg ;; 80667a3b38f7Smrg pass_all) 80676fc0178dSmrg valid_a_lib=: 80687a3b38f7Smrg ;; 80697a3b38f7Smrg esac 80706fc0178dSmrg if $valid_a_lib; then 80716fc0178dSmrg echo 80726fc0178dSmrg $ECHO "*** Warning: Linking the shared library $output against the" 80736fc0178dSmrg $ECHO "*** static library $deplib is not portable!" 80746fc0178dSmrg deplibs="$deplib $deplibs" 80756fc0178dSmrg else 807644dda7b2Smrg echo 80777a3b38f7Smrg $ECHO "*** Warning: Trying to link with static lib archive $deplib." 807844dda7b2Smrg echo "*** I have the capability to make that library automatically link in when" 807944dda7b2Smrg echo "*** you link to this library. But I can only do this if you have a" 808044dda7b2Smrg echo "*** shared version of the library, which you do not appear to have" 808144dda7b2Smrg echo "*** because the file extensions .$libext of this argument makes me believe" 808244dda7b2Smrg echo "*** that it is just a static archive that I should not use here." 80837a3b38f7Smrg fi 80847a3b38f7Smrg ;; 80857a3b38f7Smrg esac 80867a3b38f7Smrg continue 80877a3b38f7Smrg ;; 80887a3b38f7Smrg prog) 80896fc0178dSmrg if test link != "$pass"; then 80907a3b38f7Smrg deplibs="$deplib $deplibs" 80917a3b38f7Smrg else 80927a3b38f7Smrg compile_deplibs="$deplib $compile_deplibs" 80937a3b38f7Smrg finalize_deplibs="$deplib $finalize_deplibs" 80947a3b38f7Smrg fi 80957a3b38f7Smrg continue 80967a3b38f7Smrg ;; 80977a3b38f7Smrg esac # linkmode 80987a3b38f7Smrg ;; # *.$libext 80997a3b38f7Smrg *.lo | *.$objext) 81006fc0178dSmrg if test conv = "$pass"; then 81017a3b38f7Smrg deplibs="$deplib $deplibs" 81026fc0178dSmrg elif test prog = "$linkmode"; then 81036fc0178dSmrg if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then 81047a3b38f7Smrg # If there is no dlopen support or we're linking statically, 81057a3b38f7Smrg # we need to preload. 8106862f5301Smrg func_append newdlprefiles " $deplib" 81077a3b38f7Smrg compile_deplibs="$deplib $compile_deplibs" 81087a3b38f7Smrg finalize_deplibs="$deplib $finalize_deplibs" 81097a3b38f7Smrg else 8110862f5301Smrg func_append newdlfiles " $deplib" 81117a3b38f7Smrg fi 81127a3b38f7Smrg fi 81137a3b38f7Smrg continue 81147a3b38f7Smrg ;; 81157a3b38f7Smrg %DEPLIBS%) 81166fc0178dSmrg alldeplibs=: 81177a3b38f7Smrg continue 81187a3b38f7Smrg ;; 81197a3b38f7Smrg esac # case $deplib 81207a3b38f7Smrg 81216fc0178dSmrg $found || test -f "$lib" \ 81226fc0178dSmrg || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'" 81237a3b38f7Smrg 81247a3b38f7Smrg # Check to see that this really is a libtool archive. 81257a3b38f7Smrg func_lalib_unsafe_p "$lib" \ 81266fc0178dSmrg || func_fatal_error "'$lib' is not a valid libtool archive" 81277a3b38f7Smrg 81287a3b38f7Smrg func_dirname "$lib" "" "." 81296fc0178dSmrg ladir=$func_dirname_result 81307a3b38f7Smrg 81317a3b38f7Smrg dlname= 81327a3b38f7Smrg dlopen= 81337a3b38f7Smrg dlpreopen= 81347a3b38f7Smrg libdir= 81357a3b38f7Smrg library_names= 81367a3b38f7Smrg old_library= 81377a3b38f7Smrg inherited_linker_flags= 81387a3b38f7Smrg # If the library was installed with an old release of libtool, 81397a3b38f7Smrg # it will not redefine variables installed, or shouldnotlink 81407a3b38f7Smrg installed=yes 81417a3b38f7Smrg shouldnotlink=no 81427a3b38f7Smrg avoidtemprpath= 81437a3b38f7Smrg 81447a3b38f7Smrg 81457a3b38f7Smrg # Read the .la file 81467a3b38f7Smrg func_source "$lib" 81477a3b38f7Smrg 81487a3b38f7Smrg # Convert "-framework foo" to "foo.ltframework" 81497a3b38f7Smrg if test -n "$inherited_linker_flags"; then 815044dda7b2Smrg tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` 81517a3b38f7Smrg for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do 81527a3b38f7Smrg case " $new_inherited_linker_flags " in 81537a3b38f7Smrg *" $tmp_inherited_linker_flag "*) ;; 8154862f5301Smrg *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; 81557a3b38f7Smrg esac 81567a3b38f7Smrg done 81577a3b38f7Smrg fi 815844dda7b2Smrg dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 81596fc0178dSmrg if test lib,link = "$linkmode,$pass" || 81606fc0178dSmrg test prog,scan = "$linkmode,$pass" || 81616fc0178dSmrg { test prog != "$linkmode" && test lib != "$linkmode"; }; then 8162862f5301Smrg test -n "$dlopen" && func_append dlfiles " $dlopen" 8163862f5301Smrg test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" 81647a3b38f7Smrg fi 81657a3b38f7Smrg 81666fc0178dSmrg if test conv = "$pass"; then 81677a3b38f7Smrg # Only check for convenience libraries 81687a3b38f7Smrg deplibs="$lib $deplibs" 81697a3b38f7Smrg if test -z "$libdir"; then 81707a3b38f7Smrg if test -z "$old_library"; then 81716fc0178dSmrg func_fatal_error "cannot find name of link library for '$lib'" 81727a3b38f7Smrg fi 81737a3b38f7Smrg # It is a libtool convenience library, so add in its objects. 8174862f5301Smrg func_append convenience " $ladir/$objdir/$old_library" 8175862f5301Smrg func_append old_convenience " $ladir/$objdir/$old_library" 81766fc0178dSmrg elif test prog != "$linkmode" && test lib != "$linkmode"; then 81776fc0178dSmrg func_fatal_error "'$lib' is not a convenience library" 81787a3b38f7Smrg fi 81797a3b38f7Smrg tmp_libs= 81807a3b38f7Smrg for deplib in $dependency_libs; do 81817a3b38f7Smrg deplibs="$deplib $deplibs" 81826fc0178dSmrg if $opt_preserve_dup_deps; then 81837a3b38f7Smrg case "$tmp_libs " in 8184862f5301Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 81857a3b38f7Smrg esac 81867a3b38f7Smrg fi 8187862f5301Smrg func_append tmp_libs " $deplib" 81887a3b38f7Smrg done 81897a3b38f7Smrg continue 81907a3b38f7Smrg fi # $pass = conv 81917a3b38f7Smrg 81927a3b38f7Smrg 81937a3b38f7Smrg # Get the name of the library we link against. 81947a3b38f7Smrg linklib= 8195862f5301Smrg if test -n "$old_library" && 81966fc0178dSmrg { test yes = "$prefer_static_libs" || 81976fc0178dSmrg test built,no = "$prefer_static_libs,$installed"; }; then 8198862f5301Smrg linklib=$old_library 8199862f5301Smrg else 8200862f5301Smrg for l in $old_library $library_names; do 82016fc0178dSmrg linklib=$l 8202862f5301Smrg done 8203862f5301Smrg fi 82047a3b38f7Smrg if test -z "$linklib"; then 82056fc0178dSmrg func_fatal_error "cannot find name of link library for '$lib'" 82067a3b38f7Smrg fi 82077a3b38f7Smrg 82087a3b38f7Smrg # This library was specified with -dlopen. 82096fc0178dSmrg if test dlopen = "$pass"; then 82106fc0178dSmrg test -z "$libdir" \ 82116fc0178dSmrg && func_fatal_error "cannot -dlopen a convenience library: '$lib'" 82127a3b38f7Smrg if test -z "$dlname" || 82136fc0178dSmrg test yes != "$dlopen_support" || 82146fc0178dSmrg test no = "$build_libtool_libs" 82156fc0178dSmrg then 82167a3b38f7Smrg # If there is no dlname, no dlopen support or we're linking 82177a3b38f7Smrg # statically, we need to preload. We also need to preload any 82187a3b38f7Smrg # dependent libraries so libltdl's deplib preloader doesn't 82197a3b38f7Smrg # bomb out in the load deplibs phase. 8220862f5301Smrg func_append dlprefiles " $lib $dependency_libs" 82217a3b38f7Smrg else 8222862f5301Smrg func_append newdlfiles " $lib" 82237a3b38f7Smrg fi 82247a3b38f7Smrg continue 82257a3b38f7Smrg fi # $pass = dlopen 82267a3b38f7Smrg 82277a3b38f7Smrg # We need an absolute path. 82287a3b38f7Smrg case $ladir in 82296fc0178dSmrg [\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;; 82307a3b38f7Smrg *) 82317a3b38f7Smrg abs_ladir=`cd "$ladir" && pwd` 82327a3b38f7Smrg if test -z "$abs_ladir"; then 82336fc0178dSmrg func_warning "cannot determine absolute directory name of '$ladir'" 82347a3b38f7Smrg func_warning "passing it literally to the linker, although it might fail" 82356fc0178dSmrg abs_ladir=$ladir 82367a3b38f7Smrg fi 82377a3b38f7Smrg ;; 82387a3b38f7Smrg esac 82397a3b38f7Smrg func_basename "$lib" 82406fc0178dSmrg laname=$func_basename_result 82417a3b38f7Smrg 82427a3b38f7Smrg # Find the relevant object directory and library name. 82436fc0178dSmrg if test yes = "$installed"; then 8244862f5301Smrg if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then 82456fc0178dSmrg func_warning "library '$lib' was moved." 82466fc0178dSmrg dir=$ladir 82476fc0178dSmrg absdir=$abs_ladir 82486fc0178dSmrg libdir=$abs_ladir 82497a3b38f7Smrg else 82506fc0178dSmrg dir=$lt_sysroot$libdir 82516fc0178dSmrg absdir=$lt_sysroot$libdir 82527a3b38f7Smrg fi 82536fc0178dSmrg test yes = "$hardcode_automatic" && avoidtemprpath=yes 82547a3b38f7Smrg else 82557a3b38f7Smrg if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then 82566fc0178dSmrg dir=$ladir 82576fc0178dSmrg absdir=$abs_ladir 82587a3b38f7Smrg # Remove this search path later 8259862f5301Smrg func_append notinst_path " $abs_ladir" 82607a3b38f7Smrg else 82616fc0178dSmrg dir=$ladir/$objdir 82626fc0178dSmrg absdir=$abs_ladir/$objdir 82637a3b38f7Smrg # Remove this search path later 8264862f5301Smrg func_append notinst_path " $abs_ladir" 82657a3b38f7Smrg fi 82667a3b38f7Smrg fi # $installed = yes 82677a3b38f7Smrg func_stripname 'lib' '.la' "$laname" 82687a3b38f7Smrg name=$func_stripname_result 82697a3b38f7Smrg 82707a3b38f7Smrg # This library was specified with -dlpreopen. 82716fc0178dSmrg if test dlpreopen = "$pass"; then 82726fc0178dSmrg if test -z "$libdir" && test prog = "$linkmode"; then 82736fc0178dSmrg func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'" 82747a3b38f7Smrg fi 82756fc0178dSmrg case $host in 8276862f5301Smrg # special handling for platforms with PE-DLLs. 8277862f5301Smrg *cygwin* | *mingw* | *cegcc* ) 8278862f5301Smrg # Linker will automatically link against shared library if both 8279862f5301Smrg # static and shared are present. Therefore, ensure we extract 8280862f5301Smrg # symbols from the import library if a shared library is present 8281862f5301Smrg # (otherwise, the dlopen module name will be incorrect). We do 8282862f5301Smrg # this by putting the import library name into $newdlprefiles. 8283862f5301Smrg # We recover the dlopen module name by 'saving' the la file 8284862f5301Smrg # name in a special purpose variable, and (later) extracting the 8285862f5301Smrg # dlname from the la file. 8286862f5301Smrg if test -n "$dlname"; then 8287862f5301Smrg func_tr_sh "$dir/$linklib" 8288862f5301Smrg eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" 8289862f5301Smrg func_append newdlprefiles " $dir/$linklib" 8290862f5301Smrg else 8291862f5301Smrg func_append newdlprefiles " $dir/$old_library" 8292862f5301Smrg # Keep a list of preopened convenience libraries to check 8293862f5301Smrg # that they are being used correctly in the link pass. 8294862f5301Smrg test -z "$libdir" && \ 8295862f5301Smrg func_append dlpreconveniencelibs " $dir/$old_library" 8296862f5301Smrg fi 8297862f5301Smrg ;; 8298862f5301Smrg * ) 8299862f5301Smrg # Prefer using a static library (so that no silly _DYNAMIC symbols 8300862f5301Smrg # are required to link). 8301862f5301Smrg if test -n "$old_library"; then 8302862f5301Smrg func_append newdlprefiles " $dir/$old_library" 8303862f5301Smrg # Keep a list of preopened convenience libraries to check 8304862f5301Smrg # that they are being used correctly in the link pass. 8305862f5301Smrg test -z "$libdir" && \ 8306862f5301Smrg func_append dlpreconveniencelibs " $dir/$old_library" 8307862f5301Smrg # Otherwise, use the dlname, so that lt_dlopen finds it. 8308862f5301Smrg elif test -n "$dlname"; then 8309862f5301Smrg func_append newdlprefiles " $dir/$dlname" 8310862f5301Smrg else 8311862f5301Smrg func_append newdlprefiles " $dir/$linklib" 8312862f5301Smrg fi 8313862f5301Smrg ;; 8314862f5301Smrg esac 83157a3b38f7Smrg fi # $pass = dlpreopen 83167a3b38f7Smrg 83177a3b38f7Smrg if test -z "$libdir"; then 83187a3b38f7Smrg # Link the convenience library 83196fc0178dSmrg if test lib = "$linkmode"; then 83207a3b38f7Smrg deplibs="$dir/$old_library $deplibs" 83216fc0178dSmrg elif test prog,link = "$linkmode,$pass"; then 83227a3b38f7Smrg compile_deplibs="$dir/$old_library $compile_deplibs" 83237a3b38f7Smrg finalize_deplibs="$dir/$old_library $finalize_deplibs" 83247a3b38f7Smrg else 83257a3b38f7Smrg deplibs="$lib $deplibs" # used for prog,scan pass 83267a3b38f7Smrg fi 83277a3b38f7Smrg continue 83287a3b38f7Smrg fi 83297a3b38f7Smrg 83307a3b38f7Smrg 83316fc0178dSmrg if test prog = "$linkmode" && test link != "$pass"; then 8332862f5301Smrg func_append newlib_search_path " $ladir" 83337a3b38f7Smrg deplibs="$lib $deplibs" 83347a3b38f7Smrg 83356fc0178dSmrg linkalldeplibs=false 83366fc0178dSmrg if test no != "$link_all_deplibs" || test -z "$library_names" || 83376fc0178dSmrg test no = "$build_libtool_libs"; then 83386fc0178dSmrg linkalldeplibs=: 83397a3b38f7Smrg fi 83407a3b38f7Smrg 83417a3b38f7Smrg tmp_libs= 83427a3b38f7Smrg for deplib in $dependency_libs; do 83437a3b38f7Smrg case $deplib in 83447a3b38f7Smrg -L*) func_stripname '-L' '' "$deplib" 8345862f5301Smrg func_resolve_sysroot "$func_stripname_result" 8346862f5301Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 83477a3b38f7Smrg ;; 83487a3b38f7Smrg esac 83497a3b38f7Smrg # Need to link against all dependency_libs? 83506fc0178dSmrg if $linkalldeplibs; then 83517a3b38f7Smrg deplibs="$deplib $deplibs" 83527a3b38f7Smrg else 83537a3b38f7Smrg # Need to hardcode shared library paths 83547a3b38f7Smrg # or/and link against static libraries 83557a3b38f7Smrg newdependency_libs="$deplib $newdependency_libs" 83567a3b38f7Smrg fi 83576fc0178dSmrg if $opt_preserve_dup_deps; then 83587a3b38f7Smrg case "$tmp_libs " in 8359862f5301Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 83607a3b38f7Smrg esac 83617a3b38f7Smrg fi 8362862f5301Smrg func_append tmp_libs " $deplib" 83637a3b38f7Smrg done # for deplib 83647a3b38f7Smrg continue 83657a3b38f7Smrg fi # $linkmode = prog... 83667a3b38f7Smrg 83676fc0178dSmrg if test prog,link = "$linkmode,$pass"; then 83687a3b38f7Smrg if test -n "$library_names" && 83696fc0178dSmrg { { test no = "$prefer_static_libs" || 83706fc0178dSmrg test built,yes = "$prefer_static_libs,$installed"; } || 83717a3b38f7Smrg test -z "$old_library"; }; then 83727a3b38f7Smrg # We need to hardcode the library path 83736fc0178dSmrg if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then 83747a3b38f7Smrg # Make sure the rpath contains only unique directories. 83756fc0178dSmrg case $temp_rpath: in 83767a3b38f7Smrg *"$absdir:"*) ;; 8377862f5301Smrg *) func_append temp_rpath "$absdir:" ;; 83787a3b38f7Smrg esac 83797a3b38f7Smrg fi 83807a3b38f7Smrg 83817a3b38f7Smrg # Hardcode the library path. 83827a3b38f7Smrg # Skip directories that are in the system default run-time 83837a3b38f7Smrg # search path. 83847a3b38f7Smrg case " $sys_lib_dlsearch_path " in 83857a3b38f7Smrg *" $absdir "*) ;; 83867a3b38f7Smrg *) 83877a3b38f7Smrg case "$compile_rpath " in 83887a3b38f7Smrg *" $absdir "*) ;; 8389862f5301Smrg *) func_append compile_rpath " $absdir" ;; 83907a3b38f7Smrg esac 83917a3b38f7Smrg ;; 83927a3b38f7Smrg esac 83937a3b38f7Smrg case " $sys_lib_dlsearch_path " in 83947a3b38f7Smrg *" $libdir "*) ;; 83957a3b38f7Smrg *) 83967a3b38f7Smrg case "$finalize_rpath " in 83977a3b38f7Smrg *" $libdir "*) ;; 8398862f5301Smrg *) func_append finalize_rpath " $libdir" ;; 83997a3b38f7Smrg esac 84007a3b38f7Smrg ;; 84017a3b38f7Smrg esac 84027a3b38f7Smrg fi # $linkmode,$pass = prog,link... 84037a3b38f7Smrg 84046fc0178dSmrg if $alldeplibs && 84056fc0178dSmrg { test pass_all = "$deplibs_check_method" || 84066fc0178dSmrg { test yes = "$build_libtool_libs" && 84077a3b38f7Smrg test -n "$library_names"; }; }; then 84087a3b38f7Smrg # We only need to search for static libraries 84097a3b38f7Smrg continue 84107a3b38f7Smrg fi 84117a3b38f7Smrg fi 84127a3b38f7Smrg 84137a3b38f7Smrg link_static=no # Whether the deplib will be linked statically 84147a3b38f7Smrg use_static_libs=$prefer_static_libs 84156fc0178dSmrg if test built = "$use_static_libs" && test yes = "$installed"; then 84167a3b38f7Smrg use_static_libs=no 84177a3b38f7Smrg fi 84187a3b38f7Smrg if test -n "$library_names" && 84196fc0178dSmrg { test no = "$use_static_libs" || test -z "$old_library"; }; then 84207a3b38f7Smrg case $host in 84216fc0178dSmrg *cygwin* | *mingw* | *cegcc* | *os2*) 84227a3b38f7Smrg # No point in relinking DLLs because paths are not encoded 8423862f5301Smrg func_append notinst_deplibs " $lib" 84247a3b38f7Smrg need_relink=no 84257a3b38f7Smrg ;; 84267a3b38f7Smrg *) 84276fc0178dSmrg if test no = "$installed"; then 8428862f5301Smrg func_append notinst_deplibs " $lib" 84297a3b38f7Smrg need_relink=yes 84307a3b38f7Smrg fi 84317a3b38f7Smrg ;; 84327a3b38f7Smrg esac 84337a3b38f7Smrg # This is a shared library 84347a3b38f7Smrg 84357a3b38f7Smrg # Warn about portability, can't link against -module's on some 84367a3b38f7Smrg # systems (darwin). Don't bleat about dlopened modules though! 84376fc0178dSmrg dlopenmodule= 84387a3b38f7Smrg for dlpremoduletest in $dlprefiles; do 84397a3b38f7Smrg if test "X$dlpremoduletest" = "X$lib"; then 84406fc0178dSmrg dlopenmodule=$dlpremoduletest 84417a3b38f7Smrg break 84427a3b38f7Smrg fi 84437a3b38f7Smrg done 84446fc0178dSmrg if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then 844544dda7b2Smrg echo 84466fc0178dSmrg if test prog = "$linkmode"; then 84477a3b38f7Smrg $ECHO "*** Warning: Linking the executable $output against the loadable module" 84487a3b38f7Smrg else 84497a3b38f7Smrg $ECHO "*** Warning: Linking the shared library $output against the loadable module" 84507a3b38f7Smrg fi 84517a3b38f7Smrg $ECHO "*** $linklib is not portable!" 84527a3b38f7Smrg fi 84536fc0178dSmrg if test lib = "$linkmode" && 84546fc0178dSmrg test yes = "$hardcode_into_libs"; then 84557a3b38f7Smrg # Hardcode the library path. 84567a3b38f7Smrg # Skip directories that are in the system default run-time 84577a3b38f7Smrg # search path. 84587a3b38f7Smrg case " $sys_lib_dlsearch_path " in 84597a3b38f7Smrg *" $absdir "*) ;; 84607a3b38f7Smrg *) 84617a3b38f7Smrg case "$compile_rpath " in 84627a3b38f7Smrg *" $absdir "*) ;; 8463862f5301Smrg *) func_append compile_rpath " $absdir" ;; 84647a3b38f7Smrg esac 84657a3b38f7Smrg ;; 84667a3b38f7Smrg esac 84677a3b38f7Smrg case " $sys_lib_dlsearch_path " in 84687a3b38f7Smrg *" $libdir "*) ;; 84697a3b38f7Smrg *) 84707a3b38f7Smrg case "$finalize_rpath " in 84717a3b38f7Smrg *" $libdir "*) ;; 8472862f5301Smrg *) func_append finalize_rpath " $libdir" ;; 84737a3b38f7Smrg esac 84747a3b38f7Smrg ;; 84757a3b38f7Smrg esac 84767a3b38f7Smrg fi 84777a3b38f7Smrg 84787a3b38f7Smrg if test -n "$old_archive_from_expsyms_cmds"; then 84797a3b38f7Smrg # figure out the soname 84807a3b38f7Smrg set dummy $library_names 84817a3b38f7Smrg shift 84826fc0178dSmrg realname=$1 84837a3b38f7Smrg shift 84847a3b38f7Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 84857a3b38f7Smrg # use dlname if we got it. it's perfectly good, no? 84867a3b38f7Smrg if test -n "$dlname"; then 84876fc0178dSmrg soname=$dlname 84887a3b38f7Smrg elif test -n "$soname_spec"; then 84897a3b38f7Smrg # bleh windows 84907a3b38f7Smrg case $host in 84916fc0178dSmrg *cygwin* | mingw* | *cegcc* | *os2*) 84927a3b38f7Smrg func_arith $current - $age 84937a3b38f7Smrg major=$func_arith_result 84946fc0178dSmrg versuffix=-$major 84957a3b38f7Smrg ;; 84967a3b38f7Smrg esac 84977a3b38f7Smrg eval soname=\"$soname_spec\" 84987a3b38f7Smrg else 84996fc0178dSmrg soname=$realname 85007a3b38f7Smrg fi 85017a3b38f7Smrg 85027a3b38f7Smrg # Make a new name for the extract_expsyms_cmds to use 85036fc0178dSmrg soroot=$soname 85047a3b38f7Smrg func_basename "$soroot" 85056fc0178dSmrg soname=$func_basename_result 85067a3b38f7Smrg func_stripname 'lib' '.dll' "$soname" 85077a3b38f7Smrg newlib=libimp-$func_stripname_result.a 85087a3b38f7Smrg 85097a3b38f7Smrg # If the library has no export list, then create one now 85107a3b38f7Smrg if test -f "$output_objdir/$soname-def"; then : 85117a3b38f7Smrg else 85126fc0178dSmrg func_verbose "extracting exported symbol list from '$soname'" 85137a3b38f7Smrg func_execute_cmds "$extract_expsyms_cmds" 'exit $?' 85147a3b38f7Smrg fi 85157a3b38f7Smrg 85167a3b38f7Smrg # Create $newlib 85177a3b38f7Smrg if test -f "$output_objdir/$newlib"; then :; else 85186fc0178dSmrg func_verbose "generating import library for '$soname'" 85197a3b38f7Smrg func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' 85207a3b38f7Smrg fi 85217a3b38f7Smrg # make sure the library variables are pointing to the new library 85227a3b38f7Smrg dir=$output_objdir 85237a3b38f7Smrg linklib=$newlib 85247a3b38f7Smrg fi # test -n "$old_archive_from_expsyms_cmds" 85257a3b38f7Smrg 85266fc0178dSmrg if test prog = "$linkmode" || test relink != "$opt_mode"; then 85277a3b38f7Smrg add_shlibpath= 85287a3b38f7Smrg add_dir= 85297a3b38f7Smrg add= 85307a3b38f7Smrg lib_linked=yes 85317a3b38f7Smrg case $hardcode_action in 85327a3b38f7Smrg immediate | unsupported) 85336fc0178dSmrg if test no = "$hardcode_direct"; then 85346fc0178dSmrg add=$dir/$linklib 85357a3b38f7Smrg case $host in 85366fc0178dSmrg *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;; 85376fc0178dSmrg *-*-sysv4*uw2*) add_dir=-L$dir ;; 85387a3b38f7Smrg *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ 85396fc0178dSmrg *-*-unixware7*) add_dir=-L$dir ;; 85407a3b38f7Smrg *-*-darwin* ) 85416fc0178dSmrg # if the lib is a (non-dlopened) module then we cannot 85427a3b38f7Smrg # link against it, someone is ignoring the earlier warnings 85437a3b38f7Smrg if /usr/bin/file -L $add 2> /dev/null | 85446fc0178dSmrg $GREP ": [^:]* bundle" >/dev/null; then 85457a3b38f7Smrg if test "X$dlopenmodule" != "X$lib"; then 85467a3b38f7Smrg $ECHO "*** Warning: lib $linklib is a module, not a shared library" 85476fc0178dSmrg if test -z "$old_library"; then 854844dda7b2Smrg echo 854944dda7b2Smrg echo "*** And there doesn't seem to be a static archive available" 855044dda7b2Smrg echo "*** The link will probably fail, sorry" 85517a3b38f7Smrg else 85526fc0178dSmrg add=$dir/$old_library 85537a3b38f7Smrg fi 85547a3b38f7Smrg elif test -n "$old_library"; then 85556fc0178dSmrg add=$dir/$old_library 85567a3b38f7Smrg fi 85577a3b38f7Smrg fi 85587a3b38f7Smrg esac 85596fc0178dSmrg elif test no = "$hardcode_minus_L"; then 85607a3b38f7Smrg case $host in 85616fc0178dSmrg *-*-sunos*) add_shlibpath=$dir ;; 85627a3b38f7Smrg esac 85636fc0178dSmrg add_dir=-L$dir 85646fc0178dSmrg add=-l$name 85656fc0178dSmrg elif test no = "$hardcode_shlibpath_var"; then 85666fc0178dSmrg add_shlibpath=$dir 85676fc0178dSmrg add=-l$name 85687a3b38f7Smrg else 85697a3b38f7Smrg lib_linked=no 85707a3b38f7Smrg fi 85717a3b38f7Smrg ;; 85727a3b38f7Smrg relink) 85736fc0178dSmrg if test yes = "$hardcode_direct" && 85746fc0178dSmrg test no = "$hardcode_direct_absolute"; then 85756fc0178dSmrg add=$dir/$linklib 85766fc0178dSmrg elif test yes = "$hardcode_minus_L"; then 85776fc0178dSmrg add_dir=-L$absdir 85787a3b38f7Smrg # Try looking first in the location we're being installed to. 85797a3b38f7Smrg if test -n "$inst_prefix_dir"; then 85807a3b38f7Smrg case $libdir in 85817a3b38f7Smrg [\\/]*) 8582862f5301Smrg func_append add_dir " -L$inst_prefix_dir$libdir" 85837a3b38f7Smrg ;; 85847a3b38f7Smrg esac 85857a3b38f7Smrg fi 85866fc0178dSmrg add=-l$name 85876fc0178dSmrg elif test yes = "$hardcode_shlibpath_var"; then 85886fc0178dSmrg add_shlibpath=$dir 85896fc0178dSmrg add=-l$name 85907a3b38f7Smrg else 85917a3b38f7Smrg lib_linked=no 85927a3b38f7Smrg fi 85937a3b38f7Smrg ;; 85947a3b38f7Smrg *) lib_linked=no ;; 85957a3b38f7Smrg esac 85967a3b38f7Smrg 85976fc0178dSmrg if test yes != "$lib_linked"; then 85987a3b38f7Smrg func_fatal_configuration "unsupported hardcode properties" 85997a3b38f7Smrg fi 86007a3b38f7Smrg 86017a3b38f7Smrg if test -n "$add_shlibpath"; then 86027a3b38f7Smrg case :$compile_shlibpath: in 86037a3b38f7Smrg *":$add_shlibpath:"*) ;; 8604862f5301Smrg *) func_append compile_shlibpath "$add_shlibpath:" ;; 86057a3b38f7Smrg esac 86067a3b38f7Smrg fi 86076fc0178dSmrg if test prog = "$linkmode"; then 86087a3b38f7Smrg test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" 86097a3b38f7Smrg test -n "$add" && compile_deplibs="$add $compile_deplibs" 86107a3b38f7Smrg else 86117a3b38f7Smrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 86127a3b38f7Smrg test -n "$add" && deplibs="$add $deplibs" 86136fc0178dSmrg if test yes != "$hardcode_direct" && 86146fc0178dSmrg test yes != "$hardcode_minus_L" && 86156fc0178dSmrg test yes = "$hardcode_shlibpath_var"; then 86167a3b38f7Smrg case :$finalize_shlibpath: in 86177a3b38f7Smrg *":$libdir:"*) ;; 8618862f5301Smrg *) func_append finalize_shlibpath "$libdir:" ;; 86197a3b38f7Smrg esac 86207a3b38f7Smrg fi 86217a3b38f7Smrg fi 86227a3b38f7Smrg fi 86237a3b38f7Smrg 86246fc0178dSmrg if test prog = "$linkmode" || test relink = "$opt_mode"; then 86257a3b38f7Smrg add_shlibpath= 86267a3b38f7Smrg add_dir= 86277a3b38f7Smrg add= 86287a3b38f7Smrg # Finalize command for both is simple: just hardcode it. 86296fc0178dSmrg if test yes = "$hardcode_direct" && 86306fc0178dSmrg test no = "$hardcode_direct_absolute"; then 86316fc0178dSmrg add=$libdir/$linklib 86326fc0178dSmrg elif test yes = "$hardcode_minus_L"; then 86336fc0178dSmrg add_dir=-L$libdir 86346fc0178dSmrg add=-l$name 86356fc0178dSmrg elif test yes = "$hardcode_shlibpath_var"; then 86367a3b38f7Smrg case :$finalize_shlibpath: in 86377a3b38f7Smrg *":$libdir:"*) ;; 8638862f5301Smrg *) func_append finalize_shlibpath "$libdir:" ;; 86397a3b38f7Smrg esac 86406fc0178dSmrg add=-l$name 86416fc0178dSmrg elif test yes = "$hardcode_automatic"; then 86427a3b38f7Smrg if test -n "$inst_prefix_dir" && 86436fc0178dSmrg test -f "$inst_prefix_dir$libdir/$linklib"; then 86446fc0178dSmrg add=$inst_prefix_dir$libdir/$linklib 86457a3b38f7Smrg else 86466fc0178dSmrg add=$libdir/$linklib 86477a3b38f7Smrg fi 86487a3b38f7Smrg else 86497a3b38f7Smrg # We cannot seem to hardcode it, guess we'll fake it. 86506fc0178dSmrg add_dir=-L$libdir 86517a3b38f7Smrg # Try looking first in the location we're being installed to. 86527a3b38f7Smrg if test -n "$inst_prefix_dir"; then 86537a3b38f7Smrg case $libdir in 86547a3b38f7Smrg [\\/]*) 8655862f5301Smrg func_append add_dir " -L$inst_prefix_dir$libdir" 86567a3b38f7Smrg ;; 86577a3b38f7Smrg esac 86587a3b38f7Smrg fi 86596fc0178dSmrg add=-l$name 86607a3b38f7Smrg fi 86617a3b38f7Smrg 86626fc0178dSmrg if test prog = "$linkmode"; then 86637a3b38f7Smrg test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" 86647a3b38f7Smrg test -n "$add" && finalize_deplibs="$add $finalize_deplibs" 86657a3b38f7Smrg else 86667a3b38f7Smrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 86677a3b38f7Smrg test -n "$add" && deplibs="$add $deplibs" 86687a3b38f7Smrg fi 86697a3b38f7Smrg fi 86706fc0178dSmrg elif test prog = "$linkmode"; then 86717a3b38f7Smrg # Here we assume that one of hardcode_direct or hardcode_minus_L 86727a3b38f7Smrg # is not unsupported. This is valid on all known static and 86737a3b38f7Smrg # shared platforms. 86746fc0178dSmrg if test unsupported != "$hardcode_direct"; then 86756fc0178dSmrg test -n "$old_library" && linklib=$old_library 86767a3b38f7Smrg compile_deplibs="$dir/$linklib $compile_deplibs" 86777a3b38f7Smrg finalize_deplibs="$dir/$linklib $finalize_deplibs" 86787a3b38f7Smrg else 86797a3b38f7Smrg compile_deplibs="-l$name -L$dir $compile_deplibs" 86807a3b38f7Smrg finalize_deplibs="-l$name -L$dir $finalize_deplibs" 86817a3b38f7Smrg fi 86826fc0178dSmrg elif test yes = "$build_libtool_libs"; then 86837a3b38f7Smrg # Not a shared library 86846fc0178dSmrg if test pass_all != "$deplibs_check_method"; then 86857a3b38f7Smrg # We're trying link a shared library against a static one 86867a3b38f7Smrg # but the system doesn't support it. 86877a3b38f7Smrg 86887a3b38f7Smrg # Just print a warning and add the library to dependency_libs so 86897a3b38f7Smrg # that the program can be linked against the static library. 869044dda7b2Smrg echo 86916fc0178dSmrg $ECHO "*** Warning: This system cannot link to static lib archive $lib." 869244dda7b2Smrg echo "*** I have the capability to make that library automatically link in when" 869344dda7b2Smrg echo "*** you link to this library. But I can only do this if you have a" 869444dda7b2Smrg echo "*** shared version of the library, which you do not appear to have." 86956fc0178dSmrg if test yes = "$module"; then 869644dda7b2Smrg echo "*** But as you try to build a module library, libtool will still create " 869744dda7b2Smrg echo "*** a static module, that should work as long as the dlopening application" 869844dda7b2Smrg echo "*** is linked with the -dlopen flag to resolve symbols at runtime." 86997a3b38f7Smrg if test -z "$global_symbol_pipe"; then 870044dda7b2Smrg echo 870144dda7b2Smrg echo "*** However, this would only work if libtool was able to extract symbol" 87026fc0178dSmrg echo "*** lists from a program, using 'nm' or equivalent, but libtool could" 870344dda7b2Smrg echo "*** not find such a program. So, this module is probably useless." 87046fc0178dSmrg echo "*** 'nm' from GNU binutils and a full rebuild may help." 87057a3b38f7Smrg fi 87066fc0178dSmrg if test no = "$build_old_libs"; then 87077a3b38f7Smrg build_libtool_libs=module 87087a3b38f7Smrg build_old_libs=yes 87097a3b38f7Smrg else 87107a3b38f7Smrg build_libtool_libs=no 87117a3b38f7Smrg fi 87127a3b38f7Smrg fi 87137a3b38f7Smrg else 87147a3b38f7Smrg deplibs="$dir/$old_library $deplibs" 87157a3b38f7Smrg link_static=yes 87167a3b38f7Smrg fi 87177a3b38f7Smrg fi # link shared/static library? 87187a3b38f7Smrg 87196fc0178dSmrg if test lib = "$linkmode"; then 87207a3b38f7Smrg if test -n "$dependency_libs" && 87216fc0178dSmrg { test yes != "$hardcode_into_libs" || 87226fc0178dSmrg test yes = "$build_old_libs" || 87236fc0178dSmrg test yes = "$link_static"; }; then 87247a3b38f7Smrg # Extract -R from dependency_libs 87257a3b38f7Smrg temp_deplibs= 87267a3b38f7Smrg for libdir in $dependency_libs; do 87277a3b38f7Smrg case $libdir in 87287a3b38f7Smrg -R*) func_stripname '-R' '' "$libdir" 87297a3b38f7Smrg temp_xrpath=$func_stripname_result 87307a3b38f7Smrg case " $xrpath " in 87317a3b38f7Smrg *" $temp_xrpath "*) ;; 8732862f5301Smrg *) func_append xrpath " $temp_xrpath";; 87337a3b38f7Smrg esac;; 8734862f5301Smrg *) func_append temp_deplibs " $libdir";; 87357a3b38f7Smrg esac 87367a3b38f7Smrg done 87376fc0178dSmrg dependency_libs=$temp_deplibs 87387a3b38f7Smrg fi 87397a3b38f7Smrg 8740862f5301Smrg func_append newlib_search_path " $absdir" 87417a3b38f7Smrg # Link against this library 87426fc0178dSmrg test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs" 87437a3b38f7Smrg # ... and its dependency_libs 87447a3b38f7Smrg tmp_libs= 87457a3b38f7Smrg for deplib in $dependency_libs; do 87467a3b38f7Smrg newdependency_libs="$deplib $newdependency_libs" 8747862f5301Smrg case $deplib in 8748862f5301Smrg -L*) func_stripname '-L' '' "$deplib" 8749862f5301Smrg func_resolve_sysroot "$func_stripname_result";; 8750862f5301Smrg *) func_resolve_sysroot "$deplib" ;; 8751862f5301Smrg esac 87526fc0178dSmrg if $opt_preserve_dup_deps; then 87537a3b38f7Smrg case "$tmp_libs " in 8754862f5301Smrg *" $func_resolve_sysroot_result "*) 8755862f5301Smrg func_append specialdeplibs " $func_resolve_sysroot_result" ;; 87567a3b38f7Smrg esac 87577a3b38f7Smrg fi 8758862f5301Smrg func_append tmp_libs " $func_resolve_sysroot_result" 87597a3b38f7Smrg done 87607a3b38f7Smrg 87616fc0178dSmrg if test no != "$link_all_deplibs"; then 87627a3b38f7Smrg # Add the search paths of all dependency libraries 87637a3b38f7Smrg for deplib in $dependency_libs; do 876444dda7b2Smrg path= 87657a3b38f7Smrg case $deplib in 87666fc0178dSmrg -L*) path=$deplib ;; 87677a3b38f7Smrg *.la) 8768862f5301Smrg func_resolve_sysroot "$deplib" 8769862f5301Smrg deplib=$func_resolve_sysroot_result 87707a3b38f7Smrg func_dirname "$deplib" "" "." 8771862f5301Smrg dir=$func_dirname_result 87727a3b38f7Smrg # We need an absolute path. 87737a3b38f7Smrg case $dir in 87746fc0178dSmrg [\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;; 87757a3b38f7Smrg *) 87767a3b38f7Smrg absdir=`cd "$dir" && pwd` 87777a3b38f7Smrg if test -z "$absdir"; then 87786fc0178dSmrg func_warning "cannot determine absolute directory name of '$dir'" 87796fc0178dSmrg absdir=$dir 87807a3b38f7Smrg fi 87817a3b38f7Smrg ;; 87827a3b38f7Smrg esac 87837a3b38f7Smrg if $GREP "^installed=no" $deplib > /dev/null; then 87847a3b38f7Smrg case $host in 87857a3b38f7Smrg *-*-darwin*) 87867a3b38f7Smrg depdepl= 87876fc0178dSmrg eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` 87886fc0178dSmrg if test -n "$deplibrary_names"; then 87896fc0178dSmrg for tmp in $deplibrary_names; do 87907a3b38f7Smrg depdepl=$tmp 87917a3b38f7Smrg done 87926fc0178dSmrg if test -f "$absdir/$objdir/$depdepl"; then 87936fc0178dSmrg depdepl=$absdir/$objdir/$depdepl 87946fc0178dSmrg darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 87957a3b38f7Smrg if test -z "$darwin_install_name"; then 87966fc0178dSmrg darwin_install_name=`$OTOOL64 -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 87977a3b38f7Smrg fi 87986fc0178dSmrg func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl" 87996fc0178dSmrg func_append linker_flags " -dylib_file $darwin_install_name:$depdepl" 88007a3b38f7Smrg path= 88017a3b38f7Smrg fi 88027a3b38f7Smrg fi 88037a3b38f7Smrg ;; 88047a3b38f7Smrg *) 88056fc0178dSmrg path=-L$absdir/$objdir 88067a3b38f7Smrg ;; 88077a3b38f7Smrg esac 88087a3b38f7Smrg else 88096fc0178dSmrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` 88107a3b38f7Smrg test -z "$libdir" && \ 88116fc0178dSmrg func_fatal_error "'$deplib' is not a valid libtool archive" 88127a3b38f7Smrg test "$absdir" != "$libdir" && \ 88136fc0178dSmrg func_warning "'$deplib' seems to be moved" 88147a3b38f7Smrg 88156fc0178dSmrg path=-L$absdir 88167a3b38f7Smrg fi 88177a3b38f7Smrg ;; 88187a3b38f7Smrg esac 88197a3b38f7Smrg case " $deplibs " in 88207a3b38f7Smrg *" $path "*) ;; 88217a3b38f7Smrg *) deplibs="$path $deplibs" ;; 88227a3b38f7Smrg esac 88237a3b38f7Smrg done 88247a3b38f7Smrg fi # link_all_deplibs != no 88257a3b38f7Smrg fi # linkmode = lib 88267a3b38f7Smrg done # for deplib in $libs 88276fc0178dSmrg if test link = "$pass"; then 88286fc0178dSmrg if test prog = "$linkmode"; then 88297a3b38f7Smrg compile_deplibs="$new_inherited_linker_flags $compile_deplibs" 88307a3b38f7Smrg finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" 88317a3b38f7Smrg else 883244dda7b2Smrg compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 88337a3b38f7Smrg fi 88347a3b38f7Smrg fi 88356fc0178dSmrg dependency_libs=$newdependency_libs 88366fc0178dSmrg if test dlpreopen = "$pass"; then 88377a3b38f7Smrg # Link the dlpreopened libraries before other libraries 88387a3b38f7Smrg for deplib in $save_deplibs; do 88397a3b38f7Smrg deplibs="$deplib $deplibs" 88407a3b38f7Smrg done 88417a3b38f7Smrg fi 88426fc0178dSmrg if test dlopen != "$pass"; then 88436fc0178dSmrg test conv = "$pass" || { 88447a3b38f7Smrg # Make sure lib_search_path contains only unique directories. 88457a3b38f7Smrg lib_search_path= 88467a3b38f7Smrg for dir in $newlib_search_path; do 88477a3b38f7Smrg case "$lib_search_path " in 88487a3b38f7Smrg *" $dir "*) ;; 8849862f5301Smrg *) func_append lib_search_path " $dir" ;; 88507a3b38f7Smrg esac 88517a3b38f7Smrg done 88527a3b38f7Smrg newlib_search_path= 88536fc0178dSmrg } 88547a3b38f7Smrg 88556fc0178dSmrg if test prog,link = "$linkmode,$pass"; then 88567a3b38f7Smrg vars="compile_deplibs finalize_deplibs" 88576fc0178dSmrg else 88586fc0178dSmrg vars=deplibs 88597a3b38f7Smrg fi 88607a3b38f7Smrg for var in $vars dependency_libs; do 88617a3b38f7Smrg # Add libraries to $var in reverse order 88627a3b38f7Smrg eval tmp_libs=\"\$$var\" 88637a3b38f7Smrg new_libs= 88647a3b38f7Smrg for deplib in $tmp_libs; do 88657a3b38f7Smrg # FIXME: Pedantically, this is the right thing to do, so 88667a3b38f7Smrg # that some nasty dependency loop isn't accidentally 88677a3b38f7Smrg # broken: 88687a3b38f7Smrg #new_libs="$deplib $new_libs" 88697a3b38f7Smrg # Pragmatically, this seems to cause very few problems in 88707a3b38f7Smrg # practice: 88717a3b38f7Smrg case $deplib in 88727a3b38f7Smrg -L*) new_libs="$deplib $new_libs" ;; 88737a3b38f7Smrg -R*) ;; 88747a3b38f7Smrg *) 88757a3b38f7Smrg # And here is the reason: when a library appears more 88767a3b38f7Smrg # than once as an explicit dependence of a library, or 88777a3b38f7Smrg # is implicitly linked in more than once by the 88787a3b38f7Smrg # compiler, it is considered special, and multiple 88797a3b38f7Smrg # occurrences thereof are not removed. Compare this 88807a3b38f7Smrg # with having the same library being listed as a 88817a3b38f7Smrg # dependency of multiple other libraries: in this case, 88827a3b38f7Smrg # we know (pedantically, we assume) the library does not 88837a3b38f7Smrg # need to be listed more than once, so we keep only the 88847a3b38f7Smrg # last copy. This is not always right, but it is rare 88857a3b38f7Smrg # enough that we require users that really mean to play 88867a3b38f7Smrg # such unportable linking tricks to link the library 88877a3b38f7Smrg # using -Wl,-lname, so that libtool does not consider it 88887a3b38f7Smrg # for duplicate removal. 88897a3b38f7Smrg case " $specialdeplibs " in 88907a3b38f7Smrg *" $deplib "*) new_libs="$deplib $new_libs" ;; 88917a3b38f7Smrg *) 88927a3b38f7Smrg case " $new_libs " in 88937a3b38f7Smrg *" $deplib "*) ;; 88947a3b38f7Smrg *) new_libs="$deplib $new_libs" ;; 88957a3b38f7Smrg esac 88967a3b38f7Smrg ;; 88977a3b38f7Smrg esac 88987a3b38f7Smrg ;; 88997a3b38f7Smrg esac 89007a3b38f7Smrg done 89017a3b38f7Smrg tmp_libs= 89027a3b38f7Smrg for deplib in $new_libs; do 89037a3b38f7Smrg case $deplib in 89047a3b38f7Smrg -L*) 89057a3b38f7Smrg case " $tmp_libs " in 89067a3b38f7Smrg *" $deplib "*) ;; 8907862f5301Smrg *) func_append tmp_libs " $deplib" ;; 89087a3b38f7Smrg esac 89097a3b38f7Smrg ;; 8910862f5301Smrg *) func_append tmp_libs " $deplib" ;; 89117a3b38f7Smrg esac 89127a3b38f7Smrg done 89137a3b38f7Smrg eval $var=\"$tmp_libs\" 89147a3b38f7Smrg done # for var 89157a3b38f7Smrg fi 89166fc0178dSmrg 89176fc0178dSmrg # Add Sun CC postdeps if required: 89186fc0178dSmrg test CXX = "$tagname" && { 89196fc0178dSmrg case $host_os in 89206fc0178dSmrg linux*) 8921515ec619Smrg case `$CC -V 2>&1 | $SED 5q` in 89226fc0178dSmrg *Sun\ C*) # Sun C++ 5.9 89236fc0178dSmrg func_suncc_cstd_abi 89246fc0178dSmrg 89256fc0178dSmrg if test no != "$suncc_use_cstd_abi"; then 89266fc0178dSmrg func_append postdeps ' -library=Cstd -library=Crun' 89276fc0178dSmrg fi 89286fc0178dSmrg ;; 89296fc0178dSmrg esac 89306fc0178dSmrg ;; 89316fc0178dSmrg 89326fc0178dSmrg solaris*) 89336fc0178dSmrg func_cc_basename "$CC" 89346fc0178dSmrg case $func_cc_basename_result in 89356fc0178dSmrg CC* | sunCC*) 89366fc0178dSmrg func_suncc_cstd_abi 89376fc0178dSmrg 89386fc0178dSmrg if test no != "$suncc_use_cstd_abi"; then 89396fc0178dSmrg func_append postdeps ' -library=Cstd -library=Crun' 89406fc0178dSmrg fi 89416fc0178dSmrg ;; 89426fc0178dSmrg esac 89436fc0178dSmrg ;; 89446fc0178dSmrg esac 89456fc0178dSmrg } 89466fc0178dSmrg 89477a3b38f7Smrg # Last step: remove runtime libs from dependency_libs 89487a3b38f7Smrg # (they stay in deplibs) 89497a3b38f7Smrg tmp_libs= 89506fc0178dSmrg for i in $dependency_libs; do 89517a3b38f7Smrg case " $predeps $postdeps $compiler_lib_search_path " in 89527a3b38f7Smrg *" $i "*) 89536fc0178dSmrg i= 89547a3b38f7Smrg ;; 89557a3b38f7Smrg esac 89566fc0178dSmrg if test -n "$i"; then 8957862f5301Smrg func_append tmp_libs " $i" 89587a3b38f7Smrg fi 89597a3b38f7Smrg done 89607a3b38f7Smrg dependency_libs=$tmp_libs 89617a3b38f7Smrg done # for pass 89626fc0178dSmrg if test prog = "$linkmode"; then 89636fc0178dSmrg dlfiles=$newdlfiles 89647a3b38f7Smrg fi 89656fc0178dSmrg if test prog = "$linkmode" || test lib = "$linkmode"; then 89666fc0178dSmrg dlprefiles=$newdlprefiles 89677a3b38f7Smrg fi 89687a3b38f7Smrg 89697a3b38f7Smrg case $linkmode in 89707a3b38f7Smrg oldlib) 89716fc0178dSmrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 89726fc0178dSmrg func_warning "'-dlopen' is ignored for archives" 89737a3b38f7Smrg fi 89747a3b38f7Smrg 89757a3b38f7Smrg case " $deplibs" in 89767a3b38f7Smrg *\ -l* | *\ -L*) 89776fc0178dSmrg func_warning "'-l' and '-L' are ignored for archives" ;; 89787a3b38f7Smrg esac 89797a3b38f7Smrg 89807a3b38f7Smrg test -n "$rpath" && \ 89816fc0178dSmrg func_warning "'-rpath' is ignored for archives" 89827a3b38f7Smrg 89837a3b38f7Smrg test -n "$xrpath" && \ 89846fc0178dSmrg func_warning "'-R' is ignored for archives" 89857a3b38f7Smrg 89867a3b38f7Smrg test -n "$vinfo" && \ 89876fc0178dSmrg func_warning "'-version-info/-version-number' is ignored for archives" 89887a3b38f7Smrg 89897a3b38f7Smrg test -n "$release" && \ 89906fc0178dSmrg func_warning "'-release' is ignored for archives" 89917a3b38f7Smrg 89927a3b38f7Smrg test -n "$export_symbols$export_symbols_regex" && \ 89936fc0178dSmrg func_warning "'-export-symbols' is ignored for archives" 89947a3b38f7Smrg 89957a3b38f7Smrg # Now set the variables for building old libraries. 89967a3b38f7Smrg build_libtool_libs=no 89976fc0178dSmrg oldlibs=$output 8998862f5301Smrg func_append objs "$old_deplibs" 89997a3b38f7Smrg ;; 90007a3b38f7Smrg 90017a3b38f7Smrg lib) 90026fc0178dSmrg # Make sure we only generate libraries of the form 'libNAME.la'. 90037a3b38f7Smrg case $outputname in 90047a3b38f7Smrg lib*) 90057a3b38f7Smrg func_stripname 'lib' '.la' "$outputname" 90067a3b38f7Smrg name=$func_stripname_result 90077a3b38f7Smrg eval shared_ext=\"$shrext_cmds\" 90087a3b38f7Smrg eval libname=\"$libname_spec\" 90097a3b38f7Smrg ;; 90107a3b38f7Smrg *) 90116fc0178dSmrg test no = "$module" \ 90126fc0178dSmrg && func_fatal_help "libtool library '$output' must begin with 'lib'" 90137a3b38f7Smrg 90146fc0178dSmrg if test no != "$need_lib_prefix"; then 90157a3b38f7Smrg # Add the "lib" prefix for modules if required 90167a3b38f7Smrg func_stripname '' '.la' "$outputname" 90177a3b38f7Smrg name=$func_stripname_result 90187a3b38f7Smrg eval shared_ext=\"$shrext_cmds\" 90197a3b38f7Smrg eval libname=\"$libname_spec\" 90207a3b38f7Smrg else 90217a3b38f7Smrg func_stripname '' '.la' "$outputname" 90227a3b38f7Smrg libname=$func_stripname_result 90237a3b38f7Smrg fi 90247a3b38f7Smrg ;; 90257a3b38f7Smrg esac 90267a3b38f7Smrg 90277a3b38f7Smrg if test -n "$objs"; then 90286fc0178dSmrg if test pass_all != "$deplibs_check_method"; then 90296fc0178dSmrg func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs" 90307a3b38f7Smrg else 903144dda7b2Smrg echo 90327a3b38f7Smrg $ECHO "*** Warning: Linking the shared library $output against the non-libtool" 90337a3b38f7Smrg $ECHO "*** objects $objs is not portable!" 9034862f5301Smrg func_append libobjs " $objs" 90357a3b38f7Smrg fi 90367a3b38f7Smrg fi 90377a3b38f7Smrg 90386fc0178dSmrg test no = "$dlself" \ 90396fc0178dSmrg || func_warning "'-dlopen self' is ignored for libtool libraries" 90407a3b38f7Smrg 90417a3b38f7Smrg set dummy $rpath 90427a3b38f7Smrg shift 90436fc0178dSmrg test 1 -lt "$#" \ 90446fc0178dSmrg && func_warning "ignoring multiple '-rpath's for a libtool library" 90457a3b38f7Smrg 90466fc0178dSmrg install_libdir=$1 90477a3b38f7Smrg 90487a3b38f7Smrg oldlibs= 90497a3b38f7Smrg if test -z "$rpath"; then 90506fc0178dSmrg if test yes = "$build_libtool_libs"; then 90517a3b38f7Smrg # Building a libtool convenience library. 90526fc0178dSmrg # Some compilers have problems with a '.al' extension so 90537a3b38f7Smrg # convenience libraries should have the same extension an 90547a3b38f7Smrg # archive normally would. 90557a3b38f7Smrg oldlibs="$output_objdir/$libname.$libext $oldlibs" 90567a3b38f7Smrg build_libtool_libs=convenience 90577a3b38f7Smrg build_old_libs=yes 90587a3b38f7Smrg fi 90597a3b38f7Smrg 90607a3b38f7Smrg test -n "$vinfo" && \ 90616fc0178dSmrg func_warning "'-version-info/-version-number' is ignored for convenience libraries" 90627a3b38f7Smrg 90637a3b38f7Smrg test -n "$release" && \ 90646fc0178dSmrg func_warning "'-release' is ignored for convenience libraries" 90657a3b38f7Smrg else 90667a3b38f7Smrg 90677a3b38f7Smrg # Parse the version information argument. 90686fc0178dSmrg save_ifs=$IFS; IFS=: 90697a3b38f7Smrg set dummy $vinfo 0 0 0 90707a3b38f7Smrg shift 90716fc0178dSmrg IFS=$save_ifs 90727a3b38f7Smrg 90737a3b38f7Smrg test -n "$7" && \ 90746fc0178dSmrg func_fatal_help "too many parameters to '-version-info'" 90757a3b38f7Smrg 90767a3b38f7Smrg # convert absolute version numbers to libtool ages 90777a3b38f7Smrg # this retains compatibility with .la files and attempts 90787a3b38f7Smrg # to make the code below a bit more comprehensible 90797a3b38f7Smrg 90807a3b38f7Smrg case $vinfo_number in 90817a3b38f7Smrg yes) 90826fc0178dSmrg number_major=$1 90836fc0178dSmrg number_minor=$2 90846fc0178dSmrg number_revision=$3 90857a3b38f7Smrg # 90867a3b38f7Smrg # There are really only two kinds -- those that 90877a3b38f7Smrg # use the current revision as the major version 90887a3b38f7Smrg # and those that subtract age and use age as 90897a3b38f7Smrg # a minor version. But, then there is irix 90906fc0178dSmrg # that has an extra 1 added just for fun 90917a3b38f7Smrg # 90927a3b38f7Smrg case $version_type in 9093fc544a13Smrg # correct linux to gnu/linux during the next big refactor 9094515ec619Smrg darwin|freebsd-elf|linux|midnightbsd-elf|osf|windows|none) 90957a3b38f7Smrg func_arith $number_major + $number_minor 90967a3b38f7Smrg current=$func_arith_result 90976fc0178dSmrg age=$number_minor 90986fc0178dSmrg revision=$number_revision 90997a3b38f7Smrg ;; 91006fc0178dSmrg freebsd-aout|qnx|sunos) 91016fc0178dSmrg current=$number_major 91026fc0178dSmrg revision=$number_minor 91036fc0178dSmrg age=0 91047a3b38f7Smrg ;; 91057a3b38f7Smrg irix|nonstopux) 91067a3b38f7Smrg func_arith $number_major + $number_minor 91077a3b38f7Smrg current=$func_arith_result 91086fc0178dSmrg age=$number_minor 91096fc0178dSmrg revision=$number_minor 91107a3b38f7Smrg lt_irix_increment=no 91117a3b38f7Smrg ;; 91127a3b38f7Smrg esac 91137a3b38f7Smrg ;; 91147a3b38f7Smrg no) 91156fc0178dSmrg current=$1 91166fc0178dSmrg revision=$2 91176fc0178dSmrg age=$3 91187a3b38f7Smrg ;; 91197a3b38f7Smrg esac 91207a3b38f7Smrg 91217a3b38f7Smrg # Check that each of the things are valid numbers. 91227a3b38f7Smrg case $current in 91237a3b38f7Smrg 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]) ;; 91247a3b38f7Smrg *) 91256fc0178dSmrg func_error "CURRENT '$current' must be a nonnegative integer" 91266fc0178dSmrg func_fatal_error "'$vinfo' is not valid version information" 91277a3b38f7Smrg ;; 91287a3b38f7Smrg esac 91297a3b38f7Smrg 91307a3b38f7Smrg case $revision in 91317a3b38f7Smrg 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]) ;; 91327a3b38f7Smrg *) 91336fc0178dSmrg func_error "REVISION '$revision' must be a nonnegative integer" 91346fc0178dSmrg func_fatal_error "'$vinfo' is not valid version information" 91357a3b38f7Smrg ;; 91367a3b38f7Smrg esac 91377a3b38f7Smrg 91387a3b38f7Smrg case $age in 91397a3b38f7Smrg 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]) ;; 91407a3b38f7Smrg *) 91416fc0178dSmrg func_error "AGE '$age' must be a nonnegative integer" 91426fc0178dSmrg func_fatal_error "'$vinfo' is not valid version information" 91437a3b38f7Smrg ;; 91447a3b38f7Smrg esac 91457a3b38f7Smrg 91467a3b38f7Smrg if test "$age" -gt "$current"; then 91476fc0178dSmrg func_error "AGE '$age' is greater than the current interface number '$current'" 91486fc0178dSmrg func_fatal_error "'$vinfo' is not valid version information" 91497a3b38f7Smrg fi 91507a3b38f7Smrg 91517a3b38f7Smrg # Calculate the version variables. 91527a3b38f7Smrg major= 91537a3b38f7Smrg versuffix= 91547a3b38f7Smrg verstring= 91557a3b38f7Smrg case $version_type in 91567a3b38f7Smrg none) ;; 91577a3b38f7Smrg 91587a3b38f7Smrg darwin) 91597a3b38f7Smrg # Like Linux, but with the current version available in 91607a3b38f7Smrg # verstring for coding it into the library header 91617a3b38f7Smrg func_arith $current - $age 91627a3b38f7Smrg major=.$func_arith_result 91636fc0178dSmrg versuffix=$major.$age.$revision 91647a3b38f7Smrg # Darwin ld doesn't like 0 for these options... 91657a3b38f7Smrg func_arith $current + 1 91667a3b38f7Smrg minor_current=$func_arith_result 91676fc0178dSmrg xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" 91687a3b38f7Smrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 91696fc0178dSmrg # On Darwin other compilers 91706fc0178dSmrg case $CC in 91716fc0178dSmrg nagfor*) 91726fc0178dSmrg verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" 91736fc0178dSmrg ;; 91746fc0178dSmrg *) 91756fc0178dSmrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 91766fc0178dSmrg ;; 91776fc0178dSmrg esac 91787a3b38f7Smrg ;; 91797a3b38f7Smrg 91807a3b38f7Smrg freebsd-aout) 91816fc0178dSmrg major=.$current 91826fc0178dSmrg versuffix=.$current.$revision 91837a3b38f7Smrg ;; 91847a3b38f7Smrg 9185515ec619Smrg freebsd-elf | midnightbsd-elf) 91866fc0178dSmrg func_arith $current - $age 91876fc0178dSmrg major=.$func_arith_result 91886fc0178dSmrg versuffix=$major.$age.$revision 91897a3b38f7Smrg ;; 91907a3b38f7Smrg 91917a3b38f7Smrg irix | nonstopux) 91926fc0178dSmrg if test no = "$lt_irix_increment"; then 91937a3b38f7Smrg func_arith $current - $age 91947a3b38f7Smrg else 91957a3b38f7Smrg func_arith $current - $age + 1 91967a3b38f7Smrg fi 91977a3b38f7Smrg major=$func_arith_result 91987a3b38f7Smrg 91997a3b38f7Smrg case $version_type in 92007a3b38f7Smrg nonstopux) verstring_prefix=nonstopux ;; 92017a3b38f7Smrg *) verstring_prefix=sgi ;; 92027a3b38f7Smrg esac 92036fc0178dSmrg verstring=$verstring_prefix$major.$revision 92047a3b38f7Smrg 92057a3b38f7Smrg # Add in all the interfaces that we are compatible with. 92067a3b38f7Smrg loop=$revision 92076fc0178dSmrg while test 0 -ne "$loop"; do 92087a3b38f7Smrg func_arith $revision - $loop 92097a3b38f7Smrg iface=$func_arith_result 92107a3b38f7Smrg func_arith $loop - 1 92117a3b38f7Smrg loop=$func_arith_result 92126fc0178dSmrg verstring=$verstring_prefix$major.$iface:$verstring 92137a3b38f7Smrg done 92147a3b38f7Smrg 92156fc0178dSmrg # Before this point, $major must not contain '.'. 92167a3b38f7Smrg major=.$major 92176fc0178dSmrg versuffix=$major.$revision 92187a3b38f7Smrg ;; 92197a3b38f7Smrg 9220fc544a13Smrg linux) # correct to gnu/linux during the next big refactor 92217a3b38f7Smrg func_arith $current - $age 92227a3b38f7Smrg major=.$func_arith_result 92236fc0178dSmrg versuffix=$major.$age.$revision 92247a3b38f7Smrg ;; 92257a3b38f7Smrg 92267a3b38f7Smrg osf) 92277a3b38f7Smrg func_arith $current - $age 92287a3b38f7Smrg major=.$func_arith_result 92296fc0178dSmrg versuffix=.$current.$age.$revision 92306fc0178dSmrg verstring=$current.$age.$revision 92317a3b38f7Smrg 92327a3b38f7Smrg # Add in all the interfaces that we are compatible with. 92337a3b38f7Smrg loop=$age 92346fc0178dSmrg while test 0 -ne "$loop"; do 92357a3b38f7Smrg func_arith $current - $loop 92367a3b38f7Smrg iface=$func_arith_result 92377a3b38f7Smrg func_arith $loop - 1 92387a3b38f7Smrg loop=$func_arith_result 92396fc0178dSmrg verstring=$verstring:$iface.0 92407a3b38f7Smrg done 92417a3b38f7Smrg 92427a3b38f7Smrg # Make executables depend on our current version. 92436fc0178dSmrg func_append verstring ":$current.0" 92447a3b38f7Smrg ;; 92457a3b38f7Smrg 92467a3b38f7Smrg qnx) 92476fc0178dSmrg major=.$current 92486fc0178dSmrg versuffix=.$current 92496fc0178dSmrg ;; 92506fc0178dSmrg 92516fc0178dSmrg sco) 92526fc0178dSmrg major=.$current 92536fc0178dSmrg versuffix=.$current 92547a3b38f7Smrg ;; 92557a3b38f7Smrg 92567a3b38f7Smrg sunos) 92576fc0178dSmrg major=.$current 92586fc0178dSmrg versuffix=.$current.$revision 92597a3b38f7Smrg ;; 92607a3b38f7Smrg 92617a3b38f7Smrg windows) 92627a3b38f7Smrg # Use '-' rather than '.', since we only want one 92636fc0178dSmrg # extension on DOS 8.3 file systems. 92647a3b38f7Smrg func_arith $current - $age 92657a3b38f7Smrg major=$func_arith_result 92666fc0178dSmrg versuffix=-$major 92677a3b38f7Smrg ;; 92687a3b38f7Smrg 92697a3b38f7Smrg *) 92706fc0178dSmrg func_fatal_configuration "unknown library version type '$version_type'" 92717a3b38f7Smrg ;; 92727a3b38f7Smrg esac 92737a3b38f7Smrg 92747a3b38f7Smrg # Clear the version info if we defaulted, and they specified a release. 92757a3b38f7Smrg if test -z "$vinfo" && test -n "$release"; then 92767a3b38f7Smrg major= 92777a3b38f7Smrg case $version_type in 92787a3b38f7Smrg darwin) 92797a3b38f7Smrg # we can't check for "0.0" in archive_cmds due to quoting 92807a3b38f7Smrg # problems, so we reset it completely 92817a3b38f7Smrg verstring= 92827a3b38f7Smrg ;; 92837a3b38f7Smrg *) 92846fc0178dSmrg verstring=0.0 92857a3b38f7Smrg ;; 92867a3b38f7Smrg esac 92876fc0178dSmrg if test no = "$need_version"; then 92887a3b38f7Smrg versuffix= 92897a3b38f7Smrg else 92906fc0178dSmrg versuffix=.0.0 92917a3b38f7Smrg fi 92927a3b38f7Smrg fi 92937a3b38f7Smrg 92947a3b38f7Smrg # Remove version info from name if versioning should be avoided 92956fc0178dSmrg if test yes,no = "$avoid_version,$need_version"; then 92967a3b38f7Smrg major= 92977a3b38f7Smrg versuffix= 92986fc0178dSmrg verstring= 92997a3b38f7Smrg fi 93007a3b38f7Smrg 93017a3b38f7Smrg # Check to see if the archive will have undefined symbols. 93026fc0178dSmrg if test yes = "$allow_undefined"; then 93036fc0178dSmrg if test unsupported = "$allow_undefined_flag"; then 93046fc0178dSmrg if test yes = "$build_old_libs"; then 93056fc0178dSmrg func_warning "undefined symbols not allowed in $host shared libraries; building static only" 93066fc0178dSmrg build_libtool_libs=no 93076fc0178dSmrg else 93086fc0178dSmrg func_fatal_error "can't build $host shared library unless -no-undefined is specified" 93096fc0178dSmrg fi 93107a3b38f7Smrg fi 93117a3b38f7Smrg else 93127a3b38f7Smrg # Don't allow undefined symbols. 93136fc0178dSmrg allow_undefined_flag=$no_undefined_flag 93147a3b38f7Smrg fi 93157a3b38f7Smrg 93167a3b38f7Smrg fi 93177a3b38f7Smrg 93186fc0178dSmrg func_generate_dlsyms "$libname" "$libname" : 9319862f5301Smrg func_append libobjs " $symfileobj" 93206fc0178dSmrg test " " = "$libobjs" && libobjs= 93217a3b38f7Smrg 93226fc0178dSmrg if test relink != "$opt_mode"; then 93237a3b38f7Smrg # Remove our outputs, but don't remove object files since they 93247a3b38f7Smrg # may have been created when compiling PIC objects. 93257a3b38f7Smrg removelist= 93267a3b38f7Smrg tempremovelist=`$ECHO "$output_objdir/*"` 93277a3b38f7Smrg for p in $tempremovelist; do 93287a3b38f7Smrg case $p in 93297a3b38f7Smrg *.$objext | *.gcno) 93307a3b38f7Smrg ;; 93316fc0178dSmrg $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/$libname$release.*) 93326fc0178dSmrg if test -n "$precious_files_regex"; then 93337a3b38f7Smrg if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 93347a3b38f7Smrg then 93357a3b38f7Smrg continue 93367a3b38f7Smrg fi 93377a3b38f7Smrg fi 9338862f5301Smrg func_append removelist " $p" 93397a3b38f7Smrg ;; 93407a3b38f7Smrg *) ;; 93417a3b38f7Smrg esac 93427a3b38f7Smrg done 93437a3b38f7Smrg test -n "$removelist" && \ 93447a3b38f7Smrg func_show_eval "${RM}r \$removelist" 93457a3b38f7Smrg fi 93467a3b38f7Smrg 93477a3b38f7Smrg # Now set the variables for building old libraries. 93486fc0178dSmrg if test yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; then 9349862f5301Smrg func_append oldlibs " $output_objdir/$libname.$libext" 93507a3b38f7Smrg 93517a3b38f7Smrg # Transform .lo files to .o files. 93526fc0178dSmrg oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; $lo2o" | $NL2SP` 93537a3b38f7Smrg fi 93547a3b38f7Smrg 93557a3b38f7Smrg # Eliminate all temporary directories. 93567a3b38f7Smrg #for path in $notinst_path; do 935744dda7b2Smrg # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` 935844dda7b2Smrg # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` 935944dda7b2Smrg # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` 93607a3b38f7Smrg #done 93617a3b38f7Smrg 93627a3b38f7Smrg if test -n "$xrpath"; then 93637a3b38f7Smrg # If the user specified any rpath flags, then add them. 93647a3b38f7Smrg temp_xrpath= 93657a3b38f7Smrg for libdir in $xrpath; do 9366862f5301Smrg func_replace_sysroot "$libdir" 9367862f5301Smrg func_append temp_xrpath " -R$func_replace_sysroot_result" 93687a3b38f7Smrg case "$finalize_rpath " in 93697a3b38f7Smrg *" $libdir "*) ;; 9370862f5301Smrg *) func_append finalize_rpath " $libdir" ;; 93717a3b38f7Smrg esac 93727a3b38f7Smrg done 93736fc0178dSmrg if test yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; then 93747a3b38f7Smrg dependency_libs="$temp_xrpath $dependency_libs" 93757a3b38f7Smrg fi 93767a3b38f7Smrg fi 93777a3b38f7Smrg 93787a3b38f7Smrg # Make sure dlfiles contains only unique files that won't be dlpreopened 93796fc0178dSmrg old_dlfiles=$dlfiles 93807a3b38f7Smrg dlfiles= 93817a3b38f7Smrg for lib in $old_dlfiles; do 93827a3b38f7Smrg case " $dlprefiles $dlfiles " in 93837a3b38f7Smrg *" $lib "*) ;; 9384862f5301Smrg *) func_append dlfiles " $lib" ;; 93857a3b38f7Smrg esac 93867a3b38f7Smrg done 93877a3b38f7Smrg 93887a3b38f7Smrg # Make sure dlprefiles contains only unique files 93896fc0178dSmrg old_dlprefiles=$dlprefiles 93907a3b38f7Smrg dlprefiles= 93917a3b38f7Smrg for lib in $old_dlprefiles; do 93927a3b38f7Smrg case "$dlprefiles " in 93937a3b38f7Smrg *" $lib "*) ;; 9394862f5301Smrg *) func_append dlprefiles " $lib" ;; 93957a3b38f7Smrg esac 93967a3b38f7Smrg done 93977a3b38f7Smrg 93986fc0178dSmrg if test yes = "$build_libtool_libs"; then 93997a3b38f7Smrg if test -n "$rpath"; then 94007a3b38f7Smrg case $host in 940144dda7b2Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) 94027a3b38f7Smrg # these systems don't actually have a c library (as such)! 94037a3b38f7Smrg ;; 94047a3b38f7Smrg *-*-rhapsody* | *-*-darwin1.[012]) 94057a3b38f7Smrg # Rhapsody C library is in the System framework 9406862f5301Smrg func_append deplibs " System.ltframework" 94077a3b38f7Smrg ;; 94087a3b38f7Smrg *-*-netbsd*) 94097a3b38f7Smrg # Don't link with libc until the a.out ld.so is fixed. 94107a3b38f7Smrg ;; 9411515ec619Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-midnightbsd*) 94127a3b38f7Smrg # Do not include libc due to us having libc/libc_r. 94137a3b38f7Smrg ;; 94147a3b38f7Smrg *-*-sco3.2v5* | *-*-sco5v6*) 94157a3b38f7Smrg # Causes problems with __ctype 94167a3b38f7Smrg ;; 94177a3b38f7Smrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 94187a3b38f7Smrg # Compiler inserts libc in the correct place for threads to work 94197a3b38f7Smrg ;; 94207a3b38f7Smrg *) 94217a3b38f7Smrg # Add libc to deplibs on all other systems if necessary. 94226fc0178dSmrg if test yes = "$build_libtool_need_lc"; then 9423862f5301Smrg func_append deplibs " -lc" 94247a3b38f7Smrg fi 94257a3b38f7Smrg ;; 94267a3b38f7Smrg esac 94277a3b38f7Smrg fi 94287a3b38f7Smrg 94297a3b38f7Smrg # Transform deplibs into only deplibs that can be linked in shared. 94307a3b38f7Smrg name_save=$name 94317a3b38f7Smrg libname_save=$libname 94327a3b38f7Smrg release_save=$release 94337a3b38f7Smrg versuffix_save=$versuffix 94347a3b38f7Smrg major_save=$major 94357a3b38f7Smrg # I'm not sure if I'm treating the release correctly. I think 94367a3b38f7Smrg # release should show up in the -l (ie -lgmp5) so we don't want to 94377a3b38f7Smrg # add it in twice. Is that correct? 94386fc0178dSmrg release= 94396fc0178dSmrg versuffix= 94406fc0178dSmrg major= 94417a3b38f7Smrg newdeplibs= 94427a3b38f7Smrg droppeddeps=no 94437a3b38f7Smrg case $deplibs_check_method in 94447a3b38f7Smrg pass_all) 94457a3b38f7Smrg # Don't check for shared/static. Everything works. 94467a3b38f7Smrg # This might be a little naive. We might want to check 94477a3b38f7Smrg # whether the library exists or not. But this is on 94487a3b38f7Smrg # osf3 & osf4 and I'm not really sure... Just 94497a3b38f7Smrg # implementing what was already the behavior. 94507a3b38f7Smrg newdeplibs=$deplibs 94517a3b38f7Smrg ;; 94527a3b38f7Smrg test_compile) 94537a3b38f7Smrg # This code stresses the "libraries are programs" paradigm to its 94547a3b38f7Smrg # limits. Maybe even breaks it. We compile a program, linking it 94557a3b38f7Smrg # against the deplibs as a proxy for the library. Then we can check 94567a3b38f7Smrg # whether they linked in statically or dynamically with ldd. 94577a3b38f7Smrg $opt_dry_run || $RM conftest.c 94587a3b38f7Smrg cat > conftest.c <<EOF 94597a3b38f7Smrg int main() { return 0; } 94607a3b38f7SmrgEOF 94617a3b38f7Smrg $opt_dry_run || $RM conftest 94627a3b38f7Smrg if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then 94637a3b38f7Smrg ldd_output=`ldd conftest` 94647a3b38f7Smrg for i in $deplibs; do 94657a3b38f7Smrg case $i in 94667a3b38f7Smrg -l*) 94677a3b38f7Smrg func_stripname -l '' "$i" 94687a3b38f7Smrg name=$func_stripname_result 94696fc0178dSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 94707a3b38f7Smrg case " $predeps $postdeps " in 94717a3b38f7Smrg *" $i "*) 9472862f5301Smrg func_append newdeplibs " $i" 94736fc0178dSmrg i= 94747a3b38f7Smrg ;; 94757a3b38f7Smrg esac 94767a3b38f7Smrg fi 94776fc0178dSmrg if test -n "$i"; then 94787a3b38f7Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 94797a3b38f7Smrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 94807a3b38f7Smrg set dummy $deplib_matches; shift 94817a3b38f7Smrg deplib_match=$1 94826fc0178dSmrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then 9483862f5301Smrg func_append newdeplibs " $i" 94847a3b38f7Smrg else 94857a3b38f7Smrg droppeddeps=yes 948644dda7b2Smrg echo 94877a3b38f7Smrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 948844dda7b2Smrg echo "*** I have the capability to make that library automatically link in when" 948944dda7b2Smrg echo "*** you link to this library. But I can only do this if you have a" 949044dda7b2Smrg echo "*** shared version of the library, which I believe you do not have" 949144dda7b2Smrg echo "*** because a test_compile did reveal that the linker did not use it for" 949244dda7b2Smrg echo "*** its dynamic dependency list that programs get resolved with at runtime." 94937a3b38f7Smrg fi 94947a3b38f7Smrg fi 94957a3b38f7Smrg ;; 94967a3b38f7Smrg *) 9497862f5301Smrg func_append newdeplibs " $i" 94987a3b38f7Smrg ;; 94997a3b38f7Smrg esac 95007a3b38f7Smrg done 95017a3b38f7Smrg else 95027a3b38f7Smrg # Error occurred in the first compile. Let's try to salvage 95037a3b38f7Smrg # the situation: Compile a separate program for each library. 95047a3b38f7Smrg for i in $deplibs; do 95057a3b38f7Smrg case $i in 95067a3b38f7Smrg -l*) 95077a3b38f7Smrg func_stripname -l '' "$i" 95087a3b38f7Smrg name=$func_stripname_result 95097a3b38f7Smrg $opt_dry_run || $RM conftest 95107a3b38f7Smrg if $LTCC $LTCFLAGS -o conftest conftest.c $i; then 95117a3b38f7Smrg ldd_output=`ldd conftest` 95126fc0178dSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 95137a3b38f7Smrg case " $predeps $postdeps " in 95147a3b38f7Smrg *" $i "*) 9515862f5301Smrg func_append newdeplibs " $i" 95166fc0178dSmrg i= 95177a3b38f7Smrg ;; 95187a3b38f7Smrg esac 95197a3b38f7Smrg fi 95206fc0178dSmrg if test -n "$i"; then 95217a3b38f7Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 95227a3b38f7Smrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 95237a3b38f7Smrg set dummy $deplib_matches; shift 95247a3b38f7Smrg deplib_match=$1 95256fc0178dSmrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then 9526862f5301Smrg func_append newdeplibs " $i" 95277a3b38f7Smrg else 95287a3b38f7Smrg droppeddeps=yes 952944dda7b2Smrg echo 95307a3b38f7Smrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 953144dda7b2Smrg echo "*** I have the capability to make that library automatically link in when" 953244dda7b2Smrg echo "*** you link to this library. But I can only do this if you have a" 953344dda7b2Smrg echo "*** shared version of the library, which you do not appear to have" 953444dda7b2Smrg echo "*** because a test_compile did reveal that the linker did not use this one" 953544dda7b2Smrg echo "*** as a dynamic dependency that programs can get resolved with at runtime." 95367a3b38f7Smrg fi 95377a3b38f7Smrg fi 95387a3b38f7Smrg else 95397a3b38f7Smrg droppeddeps=yes 954044dda7b2Smrg echo 95417a3b38f7Smrg $ECHO "*** Warning! Library $i is needed by this library but I was not able to" 954244dda7b2Smrg echo "*** make it link in! You will probably need to install it or some" 954344dda7b2Smrg echo "*** library that it depends on before this library will be fully" 954444dda7b2Smrg echo "*** functional. Installing it before continuing would be even better." 95457a3b38f7Smrg fi 95467a3b38f7Smrg ;; 95477a3b38f7Smrg *) 9548862f5301Smrg func_append newdeplibs " $i" 95497a3b38f7Smrg ;; 95507a3b38f7Smrg esac 95517a3b38f7Smrg done 95527a3b38f7Smrg fi 95537a3b38f7Smrg ;; 95547a3b38f7Smrg file_magic*) 95557a3b38f7Smrg set dummy $deplibs_check_method; shift 95567a3b38f7Smrg file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 95577a3b38f7Smrg for a_deplib in $deplibs; do 95587a3b38f7Smrg case $a_deplib in 95597a3b38f7Smrg -l*) 95607a3b38f7Smrg func_stripname -l '' "$a_deplib" 95617a3b38f7Smrg name=$func_stripname_result 95626fc0178dSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 95637a3b38f7Smrg case " $predeps $postdeps " in 95647a3b38f7Smrg *" $a_deplib "*) 9565862f5301Smrg func_append newdeplibs " $a_deplib" 95666fc0178dSmrg a_deplib= 95677a3b38f7Smrg ;; 95687a3b38f7Smrg esac 95697a3b38f7Smrg fi 95706fc0178dSmrg if test -n "$a_deplib"; then 95717a3b38f7Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 9572862f5301Smrg if test -n "$file_magic_glob"; then 9573862f5301Smrg libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob` 9574862f5301Smrg else 9575862f5301Smrg libnameglob=$libname 9576862f5301Smrg fi 95776fc0178dSmrg test yes = "$want_nocaseglob" && nocaseglob=`shopt -p nocaseglob` 95787a3b38f7Smrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 95796fc0178dSmrg if test yes = "$want_nocaseglob"; then 9580862f5301Smrg shopt -s nocaseglob 9581862f5301Smrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 9582862f5301Smrg $nocaseglob 9583862f5301Smrg else 9584862f5301Smrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 9585862f5301Smrg fi 95867a3b38f7Smrg for potent_lib in $potential_libs; do 95877a3b38f7Smrg # Follow soft links. 95887a3b38f7Smrg if ls -lLd "$potent_lib" 2>/dev/null | 95897a3b38f7Smrg $GREP " -> " >/dev/null; then 95907a3b38f7Smrg continue 95917a3b38f7Smrg fi 95927a3b38f7Smrg # The statement above tries to avoid entering an 95937a3b38f7Smrg # endless loop below, in case of cyclic links. 95947a3b38f7Smrg # We might still enter an endless loop, since a link 95957a3b38f7Smrg # loop can be closed while we follow links, 95967a3b38f7Smrg # but so what? 95976fc0178dSmrg potlib=$potent_lib 95987a3b38f7Smrg while test -h "$potlib" 2>/dev/null; do 95996fc0178dSmrg potliblink=`ls -ld $potlib | $SED 's/.* -> //'` 96007a3b38f7Smrg case $potliblink in 96016fc0178dSmrg [\\/]* | [A-Za-z]:[\\/]*) potlib=$potliblink;; 96026fc0178dSmrg *) potlib=`$ECHO "$potlib" | $SED 's|[^/]*$||'`"$potliblink";; 96037a3b38f7Smrg esac 96047a3b38f7Smrg done 96057a3b38f7Smrg if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | 96067a3b38f7Smrg $SED -e 10q | 96077a3b38f7Smrg $EGREP "$file_magic_regex" > /dev/null; then 9608862f5301Smrg func_append newdeplibs " $a_deplib" 96096fc0178dSmrg a_deplib= 96107a3b38f7Smrg break 2 96117a3b38f7Smrg fi 96127a3b38f7Smrg done 96137a3b38f7Smrg done 96147a3b38f7Smrg fi 96156fc0178dSmrg if test -n "$a_deplib"; then 96167a3b38f7Smrg droppeddeps=yes 961744dda7b2Smrg echo 96187a3b38f7Smrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 961944dda7b2Smrg echo "*** I have the capability to make that library automatically link in when" 962044dda7b2Smrg echo "*** you link to this library. But I can only do this if you have a" 962144dda7b2Smrg echo "*** shared version of the library, which you do not appear to have" 962244dda7b2Smrg echo "*** because I did check the linker path looking for a file starting" 96236fc0178dSmrg if test -z "$potlib"; then 96247a3b38f7Smrg $ECHO "*** with $libname but no candidates were found. (...for file magic test)" 96257a3b38f7Smrg else 96267a3b38f7Smrg $ECHO "*** with $libname and none of the candidates passed a file format test" 96277a3b38f7Smrg $ECHO "*** using a file magic. Last file checked: $potlib" 96287a3b38f7Smrg fi 96297a3b38f7Smrg fi 96307a3b38f7Smrg ;; 96317a3b38f7Smrg *) 96327a3b38f7Smrg # Add a -L argument. 9633862f5301Smrg func_append newdeplibs " $a_deplib" 96347a3b38f7Smrg ;; 96357a3b38f7Smrg esac 96367a3b38f7Smrg done # Gone through all deplibs. 96377a3b38f7Smrg ;; 96387a3b38f7Smrg match_pattern*) 96397a3b38f7Smrg set dummy $deplibs_check_method; shift 96407a3b38f7Smrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 96417a3b38f7Smrg for a_deplib in $deplibs; do 96427a3b38f7Smrg case $a_deplib in 96437a3b38f7Smrg -l*) 96447a3b38f7Smrg func_stripname -l '' "$a_deplib" 96457a3b38f7Smrg name=$func_stripname_result 96466fc0178dSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 96477a3b38f7Smrg case " $predeps $postdeps " in 96487a3b38f7Smrg *" $a_deplib "*) 9649862f5301Smrg func_append newdeplibs " $a_deplib" 96506fc0178dSmrg a_deplib= 96517a3b38f7Smrg ;; 96527a3b38f7Smrg esac 96537a3b38f7Smrg fi 96546fc0178dSmrg if test -n "$a_deplib"; then 96557a3b38f7Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 96567a3b38f7Smrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 96577a3b38f7Smrg potential_libs=`ls $i/$libname[.-]* 2>/dev/null` 96587a3b38f7Smrg for potent_lib in $potential_libs; do 96596fc0178dSmrg potlib=$potent_lib # see symlink-check above in file_magic test 966044dda7b2Smrg if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ 96617a3b38f7Smrg $EGREP "$match_pattern_regex" > /dev/null; then 9662862f5301Smrg func_append newdeplibs " $a_deplib" 96636fc0178dSmrg a_deplib= 96647a3b38f7Smrg break 2 96657a3b38f7Smrg fi 96667a3b38f7Smrg done 96677a3b38f7Smrg done 96687a3b38f7Smrg fi 96696fc0178dSmrg if test -n "$a_deplib"; then 96707a3b38f7Smrg droppeddeps=yes 967144dda7b2Smrg echo 96727a3b38f7Smrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 967344dda7b2Smrg echo "*** I have the capability to make that library automatically link in when" 967444dda7b2Smrg echo "*** you link to this library. But I can only do this if you have a" 967544dda7b2Smrg echo "*** shared version of the library, which you do not appear to have" 967644dda7b2Smrg echo "*** because I did check the linker path looking for a file starting" 96776fc0178dSmrg if test -z "$potlib"; then 96787a3b38f7Smrg $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" 96797a3b38f7Smrg else 96807a3b38f7Smrg $ECHO "*** with $libname and none of the candidates passed a file format test" 96817a3b38f7Smrg $ECHO "*** using a regex pattern. Last file checked: $potlib" 96827a3b38f7Smrg fi 96837a3b38f7Smrg fi 96847a3b38f7Smrg ;; 96857a3b38f7Smrg *) 96867a3b38f7Smrg # Add a -L argument. 9687862f5301Smrg func_append newdeplibs " $a_deplib" 96887a3b38f7Smrg ;; 96897a3b38f7Smrg esac 96907a3b38f7Smrg done # Gone through all deplibs. 96917a3b38f7Smrg ;; 96927a3b38f7Smrg none | unknown | *) 96936fc0178dSmrg newdeplibs= 969444dda7b2Smrg tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` 96956fc0178dSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 96966fc0178dSmrg for i in $predeps $postdeps; do 96977a3b38f7Smrg # can't use Xsed below, because $i might contain '/' 96986fc0178dSmrg tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s|$i||"` 96997a3b38f7Smrg done 97007a3b38f7Smrg fi 970144dda7b2Smrg case $tmp_deplibs in 970244dda7b2Smrg *[!\ \ ]*) 970344dda7b2Smrg echo 97046fc0178dSmrg if test none = "$deplibs_check_method"; then 970544dda7b2Smrg echo "*** Warning: inter-library dependencies are not supported in this platform." 97067a3b38f7Smrg else 970744dda7b2Smrg echo "*** Warning: inter-library dependencies are not known to be supported." 97087a3b38f7Smrg fi 970944dda7b2Smrg echo "*** All declared inter-library dependencies are being dropped." 97107a3b38f7Smrg droppeddeps=yes 971144dda7b2Smrg ;; 971244dda7b2Smrg esac 97137a3b38f7Smrg ;; 97147a3b38f7Smrg esac 97157a3b38f7Smrg versuffix=$versuffix_save 97167a3b38f7Smrg major=$major_save 97177a3b38f7Smrg release=$release_save 97187a3b38f7Smrg libname=$libname_save 97197a3b38f7Smrg name=$name_save 97207a3b38f7Smrg 97217a3b38f7Smrg case $host in 97227a3b38f7Smrg *-*-rhapsody* | *-*-darwin1.[012]) 97237a3b38f7Smrg # On Rhapsody replace the C library with the System framework 972444dda7b2Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` 97257a3b38f7Smrg ;; 97267a3b38f7Smrg esac 97277a3b38f7Smrg 97286fc0178dSmrg if test yes = "$droppeddeps"; then 97296fc0178dSmrg if test yes = "$module"; then 973044dda7b2Smrg echo 973144dda7b2Smrg echo "*** Warning: libtool could not satisfy all declared inter-library" 97327a3b38f7Smrg $ECHO "*** dependencies of module $libname. Therefore, libtool will create" 973344dda7b2Smrg echo "*** a static module, that should work as long as the dlopening" 973444dda7b2Smrg echo "*** application is linked with the -dlopen flag." 97357a3b38f7Smrg if test -z "$global_symbol_pipe"; then 973644dda7b2Smrg echo 973744dda7b2Smrg echo "*** However, this would only work if libtool was able to extract symbol" 97386fc0178dSmrg echo "*** lists from a program, using 'nm' or equivalent, but libtool could" 973944dda7b2Smrg echo "*** not find such a program. So, this module is probably useless." 97406fc0178dSmrg echo "*** 'nm' from GNU binutils and a full rebuild may help." 97417a3b38f7Smrg fi 97426fc0178dSmrg if test no = "$build_old_libs"; then 97436fc0178dSmrg oldlibs=$output_objdir/$libname.$libext 97447a3b38f7Smrg build_libtool_libs=module 97457a3b38f7Smrg build_old_libs=yes 97467a3b38f7Smrg else 97477a3b38f7Smrg build_libtool_libs=no 97487a3b38f7Smrg fi 97497a3b38f7Smrg else 975044dda7b2Smrg echo "*** The inter-library dependencies that have been dropped here will be" 975144dda7b2Smrg echo "*** automatically added whenever a program is linked with this library" 975244dda7b2Smrg echo "*** or is declared to -dlopen it." 97537a3b38f7Smrg 97546fc0178dSmrg if test no = "$allow_undefined"; then 975544dda7b2Smrg echo 975644dda7b2Smrg echo "*** Since this library must not contain undefined symbols," 975744dda7b2Smrg echo "*** because either the platform does not support them or" 975844dda7b2Smrg echo "*** it was explicitly requested with -no-undefined," 975944dda7b2Smrg echo "*** libtool will only create a static version of it." 97606fc0178dSmrg if test no = "$build_old_libs"; then 97616fc0178dSmrg oldlibs=$output_objdir/$libname.$libext 97627a3b38f7Smrg build_libtool_libs=module 97637a3b38f7Smrg build_old_libs=yes 97647a3b38f7Smrg else 97657a3b38f7Smrg build_libtool_libs=no 97667a3b38f7Smrg fi 97677a3b38f7Smrg fi 97687a3b38f7Smrg fi 97697a3b38f7Smrg fi 97707a3b38f7Smrg # Done checking deplibs! 97717a3b38f7Smrg deplibs=$newdeplibs 97727a3b38f7Smrg fi 97737a3b38f7Smrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 97747a3b38f7Smrg case $host in 97757a3b38f7Smrg *-*-darwin*) 977644dda7b2Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 977744dda7b2Smrg new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 977844dda7b2Smrg deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 97797a3b38f7Smrg ;; 97807a3b38f7Smrg esac 97817a3b38f7Smrg 97827a3b38f7Smrg # move library search paths that coincide with paths to not yet 97837a3b38f7Smrg # installed libraries to the beginning of the library search list 97847a3b38f7Smrg new_libs= 97857a3b38f7Smrg for path in $notinst_path; do 97867a3b38f7Smrg case " $new_libs " in 97877a3b38f7Smrg *" -L$path/$objdir "*) ;; 97887a3b38f7Smrg *) 97897a3b38f7Smrg case " $deplibs " in 97907a3b38f7Smrg *" -L$path/$objdir "*) 9791862f5301Smrg func_append new_libs " -L$path/$objdir" ;; 97927a3b38f7Smrg esac 97937a3b38f7Smrg ;; 97947a3b38f7Smrg esac 97957a3b38f7Smrg done 97967a3b38f7Smrg for deplib in $deplibs; do 97977a3b38f7Smrg case $deplib in 97987a3b38f7Smrg -L*) 97997a3b38f7Smrg case " $new_libs " in 98007a3b38f7Smrg *" $deplib "*) ;; 9801862f5301Smrg *) func_append new_libs " $deplib" ;; 98027a3b38f7Smrg esac 98037a3b38f7Smrg ;; 9804862f5301Smrg *) func_append new_libs " $deplib" ;; 98057a3b38f7Smrg esac 98067a3b38f7Smrg done 98076fc0178dSmrg deplibs=$new_libs 98087a3b38f7Smrg 98097a3b38f7Smrg # All the library-specific variables (install_libdir is set above). 98107a3b38f7Smrg library_names= 98117a3b38f7Smrg old_library= 98127a3b38f7Smrg dlname= 98137a3b38f7Smrg 98147a3b38f7Smrg # Test again, we may have decided not to build it any more 98156fc0178dSmrg if test yes = "$build_libtool_libs"; then 98166fc0178dSmrg # Remove $wl instances when linking with ld. 9817fc544a13Smrg # FIXME: should test the right _cmds variable. 9818fc544a13Smrg case $archive_cmds in 9819fc544a13Smrg *\$LD\ *) wl= ;; 9820fc544a13Smrg esac 98216fc0178dSmrg if test yes = "$hardcode_into_libs"; then 98227a3b38f7Smrg # Hardcode the library paths 98237a3b38f7Smrg hardcode_libdirs= 98247a3b38f7Smrg dep_rpath= 98256fc0178dSmrg rpath=$finalize_rpath 98266fc0178dSmrg test relink = "$opt_mode" || rpath=$compile_rpath$rpath 98277a3b38f7Smrg for libdir in $rpath; do 98287a3b38f7Smrg if test -n "$hardcode_libdir_flag_spec"; then 98297a3b38f7Smrg if test -n "$hardcode_libdir_separator"; then 9830862f5301Smrg func_replace_sysroot "$libdir" 9831862f5301Smrg libdir=$func_replace_sysroot_result 98327a3b38f7Smrg if test -z "$hardcode_libdirs"; then 98336fc0178dSmrg hardcode_libdirs=$libdir 98347a3b38f7Smrg else 98357a3b38f7Smrg # Just accumulate the unique libdirs. 98367a3b38f7Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 98377a3b38f7Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 98387a3b38f7Smrg ;; 98397a3b38f7Smrg *) 9840862f5301Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 98417a3b38f7Smrg ;; 98427a3b38f7Smrg esac 98437a3b38f7Smrg fi 98447a3b38f7Smrg else 98457a3b38f7Smrg eval flag=\"$hardcode_libdir_flag_spec\" 9846862f5301Smrg func_append dep_rpath " $flag" 98477a3b38f7Smrg fi 98487a3b38f7Smrg elif test -n "$runpath_var"; then 98497a3b38f7Smrg case "$perm_rpath " in 98507a3b38f7Smrg *" $libdir "*) ;; 9851fc544a13Smrg *) func_append perm_rpath " $libdir" ;; 98527a3b38f7Smrg esac 98537a3b38f7Smrg fi 98547a3b38f7Smrg done 98557a3b38f7Smrg # Substitute the hardcoded libdirs into the rpath. 98567a3b38f7Smrg if test -n "$hardcode_libdir_separator" && 98577a3b38f7Smrg test -n "$hardcode_libdirs"; then 98586fc0178dSmrg libdir=$hardcode_libdirs 9859fc544a13Smrg eval "dep_rpath=\"$hardcode_libdir_flag_spec\"" 98607a3b38f7Smrg fi 98617a3b38f7Smrg if test -n "$runpath_var" && test -n "$perm_rpath"; then 98627a3b38f7Smrg # We should set the runpath_var. 98637a3b38f7Smrg rpath= 98647a3b38f7Smrg for dir in $perm_rpath; do 9865862f5301Smrg func_append rpath "$dir:" 98667a3b38f7Smrg done 98677a3b38f7Smrg eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" 98687a3b38f7Smrg fi 98697a3b38f7Smrg test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" 98707a3b38f7Smrg fi 9871ff559fabSmrg 98726fc0178dSmrg shlibpath=$finalize_shlibpath 98736fc0178dSmrg test relink = "$opt_mode" || shlibpath=$compile_shlibpath$shlibpath 98747a3b38f7Smrg if test -n "$shlibpath"; then 98757a3b38f7Smrg eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" 98767a3b38f7Smrg fi 9877ff559fabSmrg 98787a3b38f7Smrg # Get the real and link names of the library. 98797a3b38f7Smrg eval shared_ext=\"$shrext_cmds\" 98807a3b38f7Smrg eval library_names=\"$library_names_spec\" 98817a3b38f7Smrg set dummy $library_names 98827a3b38f7Smrg shift 98836fc0178dSmrg realname=$1 98847a3b38f7Smrg shift 9885ff559fabSmrg 98867a3b38f7Smrg if test -n "$soname_spec"; then 98877a3b38f7Smrg eval soname=\"$soname_spec\" 98887a3b38f7Smrg else 98896fc0178dSmrg soname=$realname 98907a3b38f7Smrg fi 98917a3b38f7Smrg if test -z "$dlname"; then 98927a3b38f7Smrg dlname=$soname 98937a3b38f7Smrg fi 9894ff559fabSmrg 98956fc0178dSmrg lib=$output_objdir/$realname 98967a3b38f7Smrg linknames= 98977a3b38f7Smrg for link 98987a3b38f7Smrg do 9899862f5301Smrg func_append linknames " $link" 99007a3b38f7Smrg done 9901ff559fabSmrg 99027a3b38f7Smrg # Use standard objects if they are pic 990344dda7b2Smrg test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` 99047a3b38f7Smrg test "X$libobjs" = "X " && libobjs= 9905ff559fabSmrg 99067a3b38f7Smrg delfiles= 99077a3b38f7Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 99087a3b38f7Smrg $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" 99096fc0178dSmrg export_symbols=$output_objdir/$libname.uexp 9910862f5301Smrg func_append delfiles " $export_symbols" 99117a3b38f7Smrg fi 9912ff559fabSmrg 99137a3b38f7Smrg orig_export_symbols= 99147a3b38f7Smrg case $host_os in 99157a3b38f7Smrg cygwin* | mingw* | cegcc*) 99167a3b38f7Smrg if test -n "$export_symbols" && test -z "$export_symbols_regex"; then 99177a3b38f7Smrg # exporting using user supplied symfile 99186fc0178dSmrg func_dll_def_p "$export_symbols" || { 99197a3b38f7Smrg # and it's NOT already a .def file. Must figure out 99207a3b38f7Smrg # which of the given symbols are data symbols and tag 99217a3b38f7Smrg # them as such. So, trigger use of export_symbols_cmds. 99227a3b38f7Smrg # export_symbols gets reassigned inside the "prepare 99237a3b38f7Smrg # the list of exported symbols" if statement, so the 99247a3b38f7Smrg # include_expsyms logic still works. 99256fc0178dSmrg orig_export_symbols=$export_symbols 99267a3b38f7Smrg export_symbols= 99277a3b38f7Smrg always_export_symbols=yes 99286fc0178dSmrg } 99297a3b38f7Smrg fi 99307a3b38f7Smrg ;; 99317a3b38f7Smrg esac 9932ff559fabSmrg 99337a3b38f7Smrg # Prepare the list of exported symbols 99347a3b38f7Smrg if test -z "$export_symbols"; then 99356fc0178dSmrg if test yes = "$always_export_symbols" || test -n "$export_symbols_regex"; then 99366fc0178dSmrg func_verbose "generating symbol list for '$libname.la'" 99376fc0178dSmrg export_symbols=$output_objdir/$libname.exp 99387a3b38f7Smrg $opt_dry_run || $RM $export_symbols 99397a3b38f7Smrg cmds=$export_symbols_cmds 99406fc0178dSmrg save_ifs=$IFS; IFS='~' 9941862f5301Smrg for cmd1 in $cmds; do 99426fc0178dSmrg IFS=$save_ifs 9943862f5301Smrg # Take the normal branch if the nm_file_list_spec branch 9944862f5301Smrg # doesn't work or if tool conversion is not needed. 9945862f5301Smrg case $nm_file_list_spec~$to_tool_file_cmd in 9946862f5301Smrg *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) 9947862f5301Smrg try_normal_branch=yes 9948862f5301Smrg eval cmd=\"$cmd1\" 9949862f5301Smrg func_len " $cmd" 9950862f5301Smrg len=$func_len_result 9951862f5301Smrg ;; 9952862f5301Smrg *) 9953862f5301Smrg try_normal_branch=no 9954862f5301Smrg ;; 9955862f5301Smrg esac 99566fc0178dSmrg if test yes = "$try_normal_branch" \ 9957862f5301Smrg && { test "$len" -lt "$max_cmd_len" \ 9958862f5301Smrg || test "$max_cmd_len" -le -1; } 9959862f5301Smrg then 9960862f5301Smrg func_show_eval "$cmd" 'exit $?' 9961862f5301Smrg skipped_export=false 9962862f5301Smrg elif test -n "$nm_file_list_spec"; then 9963862f5301Smrg func_basename "$output" 9964862f5301Smrg output_la=$func_basename_result 9965862f5301Smrg save_libobjs=$libobjs 9966862f5301Smrg save_output=$output 99676fc0178dSmrg output=$output_objdir/$output_la.nm 9968862f5301Smrg func_to_tool_file "$output" 9969862f5301Smrg libobjs=$nm_file_list_spec$func_to_tool_file_result 9970862f5301Smrg func_append delfiles " $output" 9971862f5301Smrg func_verbose "creating $NM input file list: $output" 9972862f5301Smrg for obj in $save_libobjs; do 9973862f5301Smrg func_to_tool_file "$obj" 9974862f5301Smrg $ECHO "$func_to_tool_file_result" 9975862f5301Smrg done > "$output" 9976862f5301Smrg eval cmd=\"$cmd1\" 99777a3b38f7Smrg func_show_eval "$cmd" 'exit $?' 9978862f5301Smrg output=$save_output 9979862f5301Smrg libobjs=$save_libobjs 99807a3b38f7Smrg skipped_export=false 99817a3b38f7Smrg else 99827a3b38f7Smrg # The command line is too long to execute in one step. 99837a3b38f7Smrg func_verbose "using reloadable object file for export list..." 99847a3b38f7Smrg skipped_export=: 99857a3b38f7Smrg # Break out early, otherwise skipped_export may be 99867a3b38f7Smrg # set to false by a later but shorter cmd. 99877a3b38f7Smrg break 99887a3b38f7Smrg fi 99897a3b38f7Smrg done 99906fc0178dSmrg IFS=$save_ifs 99916fc0178dSmrg if test -n "$export_symbols_regex" && test : != "$skipped_export"; then 99927a3b38f7Smrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 99937a3b38f7Smrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 99947a3b38f7Smrg fi 99957a3b38f7Smrg fi 99967a3b38f7Smrg fi 9997ff559fabSmrg 99987a3b38f7Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 99996fc0178dSmrg tmp_export_symbols=$export_symbols 100006fc0178dSmrg test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols 1000144dda7b2Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 100027a3b38f7Smrg fi 10003ff559fabSmrg 100046fc0178dSmrg if test : != "$skipped_export" && test -n "$orig_export_symbols"; then 100057a3b38f7Smrg # The given exports_symbols file has to be filtered, so filter it. 100066fc0178dSmrg func_verbose "filter symbol list for '$libname.la' to tag DATA exports" 100077a3b38f7Smrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 100086fc0178dSmrg # 's' commands, which not all seds can handle. GNU sed should be fine 100097a3b38f7Smrg # though. Also, the filter scales superlinearly with the number of 100107a3b38f7Smrg # global variables. join(1) would be nice here, but unfortunately 100117a3b38f7Smrg # isn't a blessed tool. 100127a3b38f7Smrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 10013862f5301Smrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 100147a3b38f7Smrg export_symbols=$output_objdir/$libname.def 100157a3b38f7Smrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 10016ff559fabSmrg fi 10017ff559fabSmrg 100187a3b38f7Smrg tmp_deplibs= 100197a3b38f7Smrg for test_deplib in $deplibs; do 100207a3b38f7Smrg case " $convenience " in 100217a3b38f7Smrg *" $test_deplib "*) ;; 100227a3b38f7Smrg *) 10023862f5301Smrg func_append tmp_deplibs " $test_deplib" 100247a3b38f7Smrg ;; 100257a3b38f7Smrg esac 100267a3b38f7Smrg done 100276fc0178dSmrg deplibs=$tmp_deplibs 10028ff559fabSmrg 100297a3b38f7Smrg if test -n "$convenience"; then 100307a3b38f7Smrg if test -n "$whole_archive_flag_spec" && 100316fc0178dSmrg test yes = "$compiler_needs_object" && 100327a3b38f7Smrg test -z "$libobjs"; then 100337a3b38f7Smrg # extract the archives, so we have objects to list. 100347a3b38f7Smrg # TODO: could optimize this to just extract one archive. 100357a3b38f7Smrg whole_archive_flag_spec= 100367a3b38f7Smrg fi 100377a3b38f7Smrg if test -n "$whole_archive_flag_spec"; then 100387a3b38f7Smrg save_libobjs=$libobjs 100397a3b38f7Smrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 100407a3b38f7Smrg test "X$libobjs" = "X " && libobjs= 100417a3b38f7Smrg else 100426fc0178dSmrg gentop=$output_objdir/${outputname}x 10043862f5301Smrg func_append generated " $gentop" 10044ff559fabSmrg 100457a3b38f7Smrg func_extract_archives $gentop $convenience 10046862f5301Smrg func_append libobjs " $func_extract_archives_result" 100477a3b38f7Smrg test "X$libobjs" = "X " && libobjs= 100487a3b38f7Smrg fi 100497a3b38f7Smrg fi 10050ff559fabSmrg 100516fc0178dSmrg if test yes = "$thread_safe" && test -n "$thread_safe_flag_spec"; then 100527a3b38f7Smrg eval flag=\"$thread_safe_flag_spec\" 10053862f5301Smrg func_append linker_flags " $flag" 100547a3b38f7Smrg fi 10055ff559fabSmrg 100567a3b38f7Smrg # Make a backup of the uninstalled library when relinking 100576fc0178dSmrg if test relink = "$opt_mode"; then 100587a3b38f7Smrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? 10059ff559fabSmrg fi 10060ff559fabSmrg 100617a3b38f7Smrg # Do each of the archive commands. 100626fc0178dSmrg if test yes = "$module" && test -n "$module_cmds"; then 100637a3b38f7Smrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 100647a3b38f7Smrg eval test_cmds=\"$module_expsym_cmds\" 100657a3b38f7Smrg cmds=$module_expsym_cmds 100667a3b38f7Smrg else 100677a3b38f7Smrg eval test_cmds=\"$module_cmds\" 100687a3b38f7Smrg cmds=$module_cmds 100697a3b38f7Smrg fi 100707a3b38f7Smrg else 100717a3b38f7Smrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 100727a3b38f7Smrg eval test_cmds=\"$archive_expsym_cmds\" 100737a3b38f7Smrg cmds=$archive_expsym_cmds 100747a3b38f7Smrg else 100757a3b38f7Smrg eval test_cmds=\"$archive_cmds\" 100767a3b38f7Smrg cmds=$archive_cmds 100777a3b38f7Smrg fi 10078ff559fabSmrg fi 10079ff559fabSmrg 100806fc0178dSmrg if test : != "$skipped_export" && 100817a3b38f7Smrg func_len " $test_cmds" && 100827a3b38f7Smrg len=$func_len_result && 100837a3b38f7Smrg test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 100847a3b38f7Smrg : 100857a3b38f7Smrg else 100867a3b38f7Smrg # The command line is too long to link in one step, link piecewise 100877a3b38f7Smrg # or, if using GNU ld and skipped_export is not :, use a linker 100887a3b38f7Smrg # script. 10089ff559fabSmrg 100907a3b38f7Smrg # Save the value of $output and $libobjs because we want to 100917a3b38f7Smrg # use them later. If we have whole_archive_flag_spec, we 100927a3b38f7Smrg # want to use save_libobjs as it was before 100937a3b38f7Smrg # whole_archive_flag_spec was expanded, because we can't 100947a3b38f7Smrg # assume the linker understands whole_archive_flag_spec. 100957a3b38f7Smrg # This may have to be revisited, in case too many 100967a3b38f7Smrg # convenience libraries get linked in and end up exceeding 100977a3b38f7Smrg # the spec. 100987a3b38f7Smrg if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then 100997a3b38f7Smrg save_libobjs=$libobjs 101007a3b38f7Smrg fi 101017a3b38f7Smrg save_output=$output 1010244dda7b2Smrg func_basename "$output" 1010344dda7b2Smrg output_la=$func_basename_result 10104ff559fabSmrg 101057a3b38f7Smrg # Clear the reloadable object creation command queue and 101067a3b38f7Smrg # initialize k to one. 101077a3b38f7Smrg test_cmds= 101087a3b38f7Smrg concat_cmds= 101097a3b38f7Smrg objlist= 101107a3b38f7Smrg last_robj= 101117a3b38f7Smrg k=1 10112ff559fabSmrg 101136fc0178dSmrg if test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then 101146fc0178dSmrg output=$output_objdir/$output_la.lnkscript 101157a3b38f7Smrg func_verbose "creating GNU ld script: $output" 1011644dda7b2Smrg echo 'INPUT (' > $output 101177a3b38f7Smrg for obj in $save_libobjs 101187a3b38f7Smrg do 10119862f5301Smrg func_to_tool_file "$obj" 10120862f5301Smrg $ECHO "$func_to_tool_file_result" >> $output 101217a3b38f7Smrg done 1012244dda7b2Smrg echo ')' >> $output 10123862f5301Smrg func_append delfiles " $output" 10124862f5301Smrg func_to_tool_file "$output" 10125862f5301Smrg output=$func_to_tool_file_result 101266fc0178dSmrg elif test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then 101276fc0178dSmrg output=$output_objdir/$output_la.lnk 101287a3b38f7Smrg func_verbose "creating linker input file list: $output" 101297a3b38f7Smrg : > $output 101307a3b38f7Smrg set x $save_libobjs 101317a3b38f7Smrg shift 101327a3b38f7Smrg firstobj= 101336fc0178dSmrg if test yes = "$compiler_needs_object"; then 101347a3b38f7Smrg firstobj="$1 " 101357a3b38f7Smrg shift 101367a3b38f7Smrg fi 101377a3b38f7Smrg for obj 101387a3b38f7Smrg do 10139862f5301Smrg func_to_tool_file "$obj" 10140862f5301Smrg $ECHO "$func_to_tool_file_result" >> $output 101417a3b38f7Smrg done 10142862f5301Smrg func_append delfiles " $output" 10143862f5301Smrg func_to_tool_file "$output" 10144862f5301Smrg output=$firstobj\"$file_list_spec$func_to_tool_file_result\" 101457a3b38f7Smrg else 101467a3b38f7Smrg if test -n "$save_libobjs"; then 101477a3b38f7Smrg func_verbose "creating reloadable object files..." 101486fc0178dSmrg output=$output_objdir/$output_la-$k.$objext 101497a3b38f7Smrg eval test_cmds=\"$reload_cmds\" 101507a3b38f7Smrg func_len " $test_cmds" 101517a3b38f7Smrg len0=$func_len_result 101527a3b38f7Smrg len=$len0 101537a3b38f7Smrg 101547a3b38f7Smrg # Loop over the list of objects to be linked. 101557a3b38f7Smrg for obj in $save_libobjs 101567a3b38f7Smrg do 101577a3b38f7Smrg func_len " $obj" 101587a3b38f7Smrg func_arith $len + $func_len_result 101597a3b38f7Smrg len=$func_arith_result 101606fc0178dSmrg if test -z "$objlist" || 101617a3b38f7Smrg test "$len" -lt "$max_cmd_len"; then 101627a3b38f7Smrg func_append objlist " $obj" 101637a3b38f7Smrg else 101647a3b38f7Smrg # The command $test_cmds is almost too long, add a 101657a3b38f7Smrg # command to the queue. 101666fc0178dSmrg if test 1 -eq "$k"; then 101677a3b38f7Smrg # The first file doesn't have a previous command to add. 1016844dda7b2Smrg reload_objs=$objlist 1016944dda7b2Smrg eval concat_cmds=\"$reload_cmds\" 101707a3b38f7Smrg else 101717a3b38f7Smrg # All subsequent reloadable object files will link in 101727a3b38f7Smrg # the last one created. 1017344dda7b2Smrg reload_objs="$objlist $last_robj" 1017444dda7b2Smrg eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" 101757a3b38f7Smrg fi 101766fc0178dSmrg last_robj=$output_objdir/$output_la-$k.$objext 101777a3b38f7Smrg func_arith $k + 1 101787a3b38f7Smrg k=$func_arith_result 101796fc0178dSmrg output=$output_objdir/$output_la-$k.$objext 1018044dda7b2Smrg objlist=" $obj" 101817a3b38f7Smrg func_len " $last_robj" 101827a3b38f7Smrg func_arith $len0 + $func_len_result 101837a3b38f7Smrg len=$func_arith_result 101847a3b38f7Smrg fi 101857a3b38f7Smrg done 101867a3b38f7Smrg # Handle the remaining objects by creating one last 101877a3b38f7Smrg # reloadable object file. All subsequent reloadable object 101887a3b38f7Smrg # files will link in the last one created. 101897a3b38f7Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 1019044dda7b2Smrg reload_objs="$objlist $last_robj" 101916fc0178dSmrg eval concat_cmds=\"\$concat_cmds$reload_cmds\" 101927a3b38f7Smrg if test -n "$last_robj"; then 101936fc0178dSmrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 101947a3b38f7Smrg fi 10195862f5301Smrg func_append delfiles " $output" 10196ff559fabSmrg 101977a3b38f7Smrg else 101987a3b38f7Smrg output= 101997a3b38f7Smrg fi 10200ff559fabSmrg 102016fc0178dSmrg ${skipped_export-false} && { 102026fc0178dSmrg func_verbose "generating symbol list for '$libname.la'" 102036fc0178dSmrg export_symbols=$output_objdir/$libname.exp 102047a3b38f7Smrg $opt_dry_run || $RM $export_symbols 102057a3b38f7Smrg libobjs=$output 102067a3b38f7Smrg # Append the command to create the export file. 102077a3b38f7Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 102087a3b38f7Smrg eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" 102097a3b38f7Smrg if test -n "$last_robj"; then 102107a3b38f7Smrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 102117a3b38f7Smrg fi 102126fc0178dSmrg } 10213ff559fabSmrg 102147a3b38f7Smrg test -n "$save_libobjs" && 102157a3b38f7Smrg func_verbose "creating a temporary reloadable object file: $output" 10216ff559fabSmrg 102177a3b38f7Smrg # Loop through the commands generated above and execute them. 102186fc0178dSmrg save_ifs=$IFS; IFS='~' 102197a3b38f7Smrg for cmd in $concat_cmds; do 102206fc0178dSmrg IFS=$save_ifs 102216fc0178dSmrg $opt_quiet || { 10222515ec619Smrg func_quote_arg expand,pretty "$cmd" 10223515ec619Smrg eval "func_echo $func_quote_arg_result" 102247a3b38f7Smrg } 102257a3b38f7Smrg $opt_dry_run || eval "$cmd" || { 102267a3b38f7Smrg lt_exit=$? 102277a3b38f7Smrg 102287a3b38f7Smrg # Restore the uninstalled library and exit 102296fc0178dSmrg if test relink = "$opt_mode"; then 102307a3b38f7Smrg ( cd "$output_objdir" && \ 102317a3b38f7Smrg $RM "${realname}T" && \ 102327a3b38f7Smrg $MV "${realname}U" "$realname" ) 102337a3b38f7Smrg fi 10234ff559fabSmrg 102357a3b38f7Smrg exit $lt_exit 102367a3b38f7Smrg } 102377a3b38f7Smrg done 102386fc0178dSmrg IFS=$save_ifs 102397a3b38f7Smrg 102407a3b38f7Smrg if test -n "$export_symbols_regex" && ${skipped_export-false}; then 102417a3b38f7Smrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 102427a3b38f7Smrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 10243ff559fabSmrg fi 10244ff559fabSmrg fi 10245ff559fabSmrg 102466fc0178dSmrg ${skipped_export-false} && { 102477a3b38f7Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 102486fc0178dSmrg tmp_export_symbols=$export_symbols 102496fc0178dSmrg test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols 1025044dda7b2Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 102517a3b38f7Smrg fi 10252ff559fabSmrg 102537a3b38f7Smrg if test -n "$orig_export_symbols"; then 102547a3b38f7Smrg # The given exports_symbols file has to be filtered, so filter it. 102556fc0178dSmrg func_verbose "filter symbol list for '$libname.la' to tag DATA exports" 102567a3b38f7Smrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 102576fc0178dSmrg # 's' commands, which not all seds can handle. GNU sed should be fine 102587a3b38f7Smrg # though. Also, the filter scales superlinearly with the number of 102597a3b38f7Smrg # global variables. join(1) would be nice here, but unfortunately 102607a3b38f7Smrg # isn't a blessed tool. 102617a3b38f7Smrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 10262862f5301Smrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 102637a3b38f7Smrg export_symbols=$output_objdir/$libname.def 102647a3b38f7Smrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 102657a3b38f7Smrg fi 102666fc0178dSmrg } 10267ff559fabSmrg 102687a3b38f7Smrg libobjs=$output 102697a3b38f7Smrg # Restore the value of output. 102707a3b38f7Smrg output=$save_output 10271ff559fabSmrg 102727a3b38f7Smrg if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then 102737a3b38f7Smrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 102747a3b38f7Smrg test "X$libobjs" = "X " && libobjs= 102757a3b38f7Smrg fi 102767a3b38f7Smrg # Expand the library linking commands again to reset the 102777a3b38f7Smrg # value of $libobjs for piecewise linking. 102787a3b38f7Smrg 102797a3b38f7Smrg # Do each of the archive commands. 102806fc0178dSmrg if test yes = "$module" && test -n "$module_cmds"; then 102817a3b38f7Smrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 102827a3b38f7Smrg cmds=$module_expsym_cmds 10283ff559fabSmrg else 102847a3b38f7Smrg cmds=$module_cmds 10285ff559fabSmrg fi 10286ff559fabSmrg else 102877a3b38f7Smrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 102887a3b38f7Smrg cmds=$archive_expsym_cmds 102897a3b38f7Smrg else 102907a3b38f7Smrg cmds=$archive_cmds 102917a3b38f7Smrg fi 10292ff559fabSmrg fi 10293ff559fabSmrg fi 10294ff559fabSmrg 102957a3b38f7Smrg if test -n "$delfiles"; then 102967a3b38f7Smrg # Append the command to remove temporary files to $cmds. 102977a3b38f7Smrg eval cmds=\"\$cmds~\$RM $delfiles\" 102987a3b38f7Smrg fi 10299ff559fabSmrg 103007a3b38f7Smrg # Add any objects from preloaded convenience libraries 103017a3b38f7Smrg if test -n "$dlprefiles"; then 103026fc0178dSmrg gentop=$output_objdir/${outputname}x 10303862f5301Smrg func_append generated " $gentop" 10304ff559fabSmrg 103057a3b38f7Smrg func_extract_archives $gentop $dlprefiles 10306862f5301Smrg func_append libobjs " $func_extract_archives_result" 103077a3b38f7Smrg test "X$libobjs" = "X " && libobjs= 10308ff559fabSmrg fi 10309ff559fabSmrg 103106fc0178dSmrg save_ifs=$IFS; IFS='~' 103117a3b38f7Smrg for cmd in $cmds; do 103126fc0178dSmrg IFS=$sp$nl 103137a3b38f7Smrg eval cmd=\"$cmd\" 103146fc0178dSmrg IFS=$save_ifs 103156fc0178dSmrg $opt_quiet || { 10316515ec619Smrg func_quote_arg expand,pretty "$cmd" 10317515ec619Smrg eval "func_echo $func_quote_arg_result" 103187a3b38f7Smrg } 103197a3b38f7Smrg $opt_dry_run || eval "$cmd" || { 103207a3b38f7Smrg lt_exit=$? 10321ff559fabSmrg 103227a3b38f7Smrg # Restore the uninstalled library and exit 103236fc0178dSmrg if test relink = "$opt_mode"; then 103247a3b38f7Smrg ( cd "$output_objdir" && \ 103257a3b38f7Smrg $RM "${realname}T" && \ 103267a3b38f7Smrg $MV "${realname}U" "$realname" ) 103277a3b38f7Smrg fi 103287a3b38f7Smrg 103297a3b38f7Smrg exit $lt_exit 103307a3b38f7Smrg } 103317a3b38f7Smrg done 103326fc0178dSmrg IFS=$save_ifs 103337a3b38f7Smrg 103347a3b38f7Smrg # Restore the uninstalled library and exit 103356fc0178dSmrg if test relink = "$opt_mode"; then 103367a3b38f7Smrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? 103377a3b38f7Smrg 103387a3b38f7Smrg if test -n "$convenience"; then 103397a3b38f7Smrg if test -z "$whole_archive_flag_spec"; then 103407a3b38f7Smrg func_show_eval '${RM}r "$gentop"' 10341ff559fabSmrg fi 10342ff559fabSmrg fi 10343ff559fabSmrg 103447a3b38f7Smrg exit $EXIT_SUCCESS 103457a3b38f7Smrg fi 10346ff559fabSmrg 103477a3b38f7Smrg # Create links to the real library. 103487a3b38f7Smrg for linkname in $linknames; do 103497a3b38f7Smrg if test "$realname" != "$linkname"; then 103507a3b38f7Smrg func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' 103517a3b38f7Smrg fi 103527a3b38f7Smrg done 103537a3b38f7Smrg 103547a3b38f7Smrg # If -module or -export-dynamic was specified, set the dlname. 103556fc0178dSmrg if test yes = "$module" || test yes = "$export_dynamic"; then 103567a3b38f7Smrg # On all known operating systems, these are identical. 103576fc0178dSmrg dlname=$soname 103587a3b38f7Smrg fi 103597a3b38f7Smrg fi 103607a3b38f7Smrg ;; 103617a3b38f7Smrg 103627a3b38f7Smrg obj) 103636fc0178dSmrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 103646fc0178dSmrg func_warning "'-dlopen' is ignored for objects" 103657a3b38f7Smrg fi 103667a3b38f7Smrg 103677a3b38f7Smrg case " $deplibs" in 103687a3b38f7Smrg *\ -l* | *\ -L*) 103696fc0178dSmrg func_warning "'-l' and '-L' are ignored for objects" ;; 103707a3b38f7Smrg esac 103717a3b38f7Smrg 103727a3b38f7Smrg test -n "$rpath" && \ 103736fc0178dSmrg func_warning "'-rpath' is ignored for objects" 103747a3b38f7Smrg 103757a3b38f7Smrg test -n "$xrpath" && \ 103766fc0178dSmrg func_warning "'-R' is ignored for objects" 103777a3b38f7Smrg 103787a3b38f7Smrg test -n "$vinfo" && \ 103796fc0178dSmrg func_warning "'-version-info' is ignored for objects" 103807a3b38f7Smrg 103817a3b38f7Smrg test -n "$release" && \ 103826fc0178dSmrg func_warning "'-release' is ignored for objects" 103837a3b38f7Smrg 103847a3b38f7Smrg case $output in 103857a3b38f7Smrg *.lo) 103867a3b38f7Smrg test -n "$objs$old_deplibs" && \ 103876fc0178dSmrg func_fatal_error "cannot build library object '$output' from non-libtool objects" 103887a3b38f7Smrg 103897a3b38f7Smrg libobj=$output 103907a3b38f7Smrg func_lo2o "$libobj" 103917a3b38f7Smrg obj=$func_lo2o_result 103927a3b38f7Smrg ;; 103937a3b38f7Smrg *) 103947a3b38f7Smrg libobj= 103956fc0178dSmrg obj=$output 103967a3b38f7Smrg ;; 103977a3b38f7Smrg esac 103987a3b38f7Smrg 103997a3b38f7Smrg # Delete the old objects. 104007a3b38f7Smrg $opt_dry_run || $RM $obj $libobj 104017a3b38f7Smrg 104027a3b38f7Smrg # Objects from convenience libraries. This assumes 104037a3b38f7Smrg # single-version convenience libraries. Whenever we create 104047a3b38f7Smrg # different ones for PIC/non-PIC, this we'll have to duplicate 104057a3b38f7Smrg # the extraction. 104067a3b38f7Smrg reload_conv_objs= 104077a3b38f7Smrg gentop= 104086fc0178dSmrg # if reload_cmds runs $LD directly, get rid of -Wl from 104096fc0178dSmrg # whole_archive_flag_spec and hope we can get by with turning comma 104106fc0178dSmrg # into space. 104116fc0178dSmrg case $reload_cmds in 104126fc0178dSmrg *\$LD[\ \$]*) wl= ;; 104136fc0178dSmrg esac 104147a3b38f7Smrg if test -n "$convenience"; then 104157a3b38f7Smrg if test -n "$whole_archive_flag_spec"; then 104167a3b38f7Smrg eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" 104176fc0178dSmrg test -n "$wl" || tmp_whole_archive_flags=`$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` 104186fc0178dSmrg reload_conv_objs=$reload_objs\ $tmp_whole_archive_flags 104197a3b38f7Smrg else 104206fc0178dSmrg gentop=$output_objdir/${obj}x 10421862f5301Smrg func_append generated " $gentop" 104227a3b38f7Smrg 104237a3b38f7Smrg func_extract_archives $gentop $convenience 104247a3b38f7Smrg reload_conv_objs="$reload_objs $func_extract_archives_result" 104257a3b38f7Smrg fi 104267a3b38f7Smrg fi 10427ff559fabSmrg 10428862f5301Smrg # If we're not building shared, we need to use non_pic_objs 104296fc0178dSmrg test yes = "$build_libtool_libs" || libobjs=$non_pic_objects 10430862f5301Smrg 104317a3b38f7Smrg # Create the old-style object. 104326fc0178dSmrg reload_objs=$objs$old_deplibs' '`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; /\.lib$/d; $lo2o" | $NL2SP`' '$reload_conv_objs 10433ff559fabSmrg 104346fc0178dSmrg output=$obj 104357a3b38f7Smrg func_execute_cmds "$reload_cmds" 'exit $?' 10436ff559fabSmrg 104377a3b38f7Smrg # Exit if we aren't doing a library object file. 104387a3b38f7Smrg if test -z "$libobj"; then 104397a3b38f7Smrg if test -n "$gentop"; then 104407a3b38f7Smrg func_show_eval '${RM}r "$gentop"' 104417a3b38f7Smrg fi 10442ff559fabSmrg 104437a3b38f7Smrg exit $EXIT_SUCCESS 104447a3b38f7Smrg fi 10445ff559fabSmrg 104466fc0178dSmrg test yes = "$build_libtool_libs" || { 104477a3b38f7Smrg if test -n "$gentop"; then 104487a3b38f7Smrg func_show_eval '${RM}r "$gentop"' 104497a3b38f7Smrg fi 10450ff559fabSmrg 104517a3b38f7Smrg # Create an invalid libtool object if no PIC, so that we don't 104527a3b38f7Smrg # accidentally link it into a program. 104537a3b38f7Smrg # $show "echo timestamp > $libobj" 104547a3b38f7Smrg # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? 104557a3b38f7Smrg exit $EXIT_SUCCESS 104566fc0178dSmrg } 10457ff559fabSmrg 104586fc0178dSmrg if test -n "$pic_flag" || test default != "$pic_mode"; then 104597a3b38f7Smrg # Only do commands if we really have different PIC objects. 104607a3b38f7Smrg reload_objs="$libobjs $reload_conv_objs" 104616fc0178dSmrg output=$libobj 104627a3b38f7Smrg func_execute_cmds "$reload_cmds" 'exit $?' 10463ff559fabSmrg fi 10464ff559fabSmrg 104657a3b38f7Smrg if test -n "$gentop"; then 104667a3b38f7Smrg func_show_eval '${RM}r "$gentop"' 104677a3b38f7Smrg fi 10468ff559fabSmrg 104697a3b38f7Smrg exit $EXIT_SUCCESS 104707a3b38f7Smrg ;; 10471ff559fabSmrg 104727a3b38f7Smrg prog) 104737a3b38f7Smrg case $host in 104747a3b38f7Smrg *cygwin*) func_stripname '' '.exe' "$output" 104757a3b38f7Smrg output=$func_stripname_result.exe;; 10476ff559fabSmrg esac 104777a3b38f7Smrg test -n "$vinfo" && \ 104786fc0178dSmrg func_warning "'-version-info' is ignored for programs" 10479ff559fabSmrg 104807a3b38f7Smrg test -n "$release" && \ 104816fc0178dSmrg func_warning "'-release' is ignored for programs" 10482ff559fabSmrg 104836fc0178dSmrg $preload \ 104846fc0178dSmrg && test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \ 104856fc0178dSmrg && func_warning "'LT_INIT([dlopen])' not used. Assuming no dlopen support." 10486ff559fabSmrg 104877a3b38f7Smrg case $host in 104887a3b38f7Smrg *-*-rhapsody* | *-*-darwin1.[012]) 104897a3b38f7Smrg # On Rhapsody replace the C library is the System framework 1049044dda7b2Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` 1049144dda7b2Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` 10492ff559fabSmrg ;; 10493ff559fabSmrg esac 10494ff559fabSmrg 104957a3b38f7Smrg case $host in 104967a3b38f7Smrg *-*-darwin*) 104977a3b38f7Smrg # Don't allow lazy linking, it breaks C++ global constructors 104987a3b38f7Smrg # But is supposedly fixed on 10.4 or later (yay!). 104996fc0178dSmrg if test CXX = "$tagname"; then 105007a3b38f7Smrg case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 105017a3b38f7Smrg 10.[0123]) 105026fc0178dSmrg func_append compile_command " $wl-bind_at_load" 105036fc0178dSmrg func_append finalize_command " $wl-bind_at_load" 105047a3b38f7Smrg ;; 105057a3b38f7Smrg esac 105067a3b38f7Smrg fi 105077a3b38f7Smrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 1050844dda7b2Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 1050944dda7b2Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 10510ff559fabSmrg ;; 10511ff559fabSmrg esac 10512ff559fabSmrg 10513ff559fabSmrg 105147a3b38f7Smrg # move library search paths that coincide with paths to not yet 105157a3b38f7Smrg # installed libraries to the beginning of the library search list 105167a3b38f7Smrg new_libs= 105177a3b38f7Smrg for path in $notinst_path; do 105187a3b38f7Smrg case " $new_libs " in 105197a3b38f7Smrg *" -L$path/$objdir "*) ;; 10520ff559fabSmrg *) 105217a3b38f7Smrg case " $compile_deplibs " in 105227a3b38f7Smrg *" -L$path/$objdir "*) 10523862f5301Smrg func_append new_libs " -L$path/$objdir" ;; 105247a3b38f7Smrg esac 10525ff559fabSmrg ;; 10526ff559fabSmrg esac 10527ff559fabSmrg done 105287a3b38f7Smrg for deplib in $compile_deplibs; do 105297a3b38f7Smrg case $deplib in 105307a3b38f7Smrg -L*) 105317a3b38f7Smrg case " $new_libs " in 105327a3b38f7Smrg *" $deplib "*) ;; 10533862f5301Smrg *) func_append new_libs " $deplib" ;; 105347a3b38f7Smrg esac 105357a3b38f7Smrg ;; 10536862f5301Smrg *) func_append new_libs " $deplib" ;; 105377a3b38f7Smrg esac 105387a3b38f7Smrg done 105396fc0178dSmrg compile_deplibs=$new_libs 10540ff559fabSmrg 10541ff559fabSmrg 10542862f5301Smrg func_append compile_command " $compile_deplibs" 10543862f5301Smrg func_append finalize_command " $finalize_deplibs" 10544ff559fabSmrg 105457a3b38f7Smrg if test -n "$rpath$xrpath"; then 105467a3b38f7Smrg # If the user specified any rpath flags, then add them. 105477a3b38f7Smrg for libdir in $rpath $xrpath; do 105487a3b38f7Smrg # This is the magic to use -rpath. 105497a3b38f7Smrg case "$finalize_rpath " in 105507a3b38f7Smrg *" $libdir "*) ;; 10551862f5301Smrg *) func_append finalize_rpath " $libdir" ;; 105527a3b38f7Smrg esac 105537a3b38f7Smrg done 105547a3b38f7Smrg fi 10555ff559fabSmrg 105567a3b38f7Smrg # Now hardcode the library paths 105577a3b38f7Smrg rpath= 105587a3b38f7Smrg hardcode_libdirs= 105597a3b38f7Smrg for libdir in $compile_rpath $finalize_rpath; do 105607a3b38f7Smrg if test -n "$hardcode_libdir_flag_spec"; then 105617a3b38f7Smrg if test -n "$hardcode_libdir_separator"; then 105627a3b38f7Smrg if test -z "$hardcode_libdirs"; then 105636fc0178dSmrg hardcode_libdirs=$libdir 105647a3b38f7Smrg else 105657a3b38f7Smrg # Just accumulate the unique libdirs. 105667a3b38f7Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 105677a3b38f7Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 105687a3b38f7Smrg ;; 105697a3b38f7Smrg *) 10570862f5301Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 105717a3b38f7Smrg ;; 105727a3b38f7Smrg esac 105737a3b38f7Smrg fi 105747a3b38f7Smrg else 105757a3b38f7Smrg eval flag=\"$hardcode_libdir_flag_spec\" 10576862f5301Smrg func_append rpath " $flag" 105777a3b38f7Smrg fi 105787a3b38f7Smrg elif test -n "$runpath_var"; then 105797a3b38f7Smrg case "$perm_rpath " in 10580ff559fabSmrg *" $libdir "*) ;; 10581862f5301Smrg *) func_append perm_rpath " $libdir" ;; 10582ff559fabSmrg esac 105837a3b38f7Smrg fi 105847a3b38f7Smrg case $host in 105857a3b38f7Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 105866fc0178dSmrg testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'` 105877a3b38f7Smrg case :$dllsearchpath: in 105887a3b38f7Smrg *":$libdir:"*) ;; 105897a3b38f7Smrg ::) dllsearchpath=$libdir;; 10590862f5301Smrg *) func_append dllsearchpath ":$libdir";; 105917a3b38f7Smrg esac 105927a3b38f7Smrg case :$dllsearchpath: in 105937a3b38f7Smrg *":$testbindir:"*) ;; 105947a3b38f7Smrg ::) dllsearchpath=$testbindir;; 10595862f5301Smrg *) func_append dllsearchpath ":$testbindir";; 105967a3b38f7Smrg esac 105977a3b38f7Smrg ;; 105987a3b38f7Smrg esac 105997a3b38f7Smrg done 106007a3b38f7Smrg # Substitute the hardcoded libdirs into the rpath. 106017a3b38f7Smrg if test -n "$hardcode_libdir_separator" && 106027a3b38f7Smrg test -n "$hardcode_libdirs"; then 106036fc0178dSmrg libdir=$hardcode_libdirs 106047a3b38f7Smrg eval rpath=\" $hardcode_libdir_flag_spec\" 106057a3b38f7Smrg fi 106066fc0178dSmrg compile_rpath=$rpath 106077a3b38f7Smrg 106087a3b38f7Smrg rpath= 106097a3b38f7Smrg hardcode_libdirs= 106107a3b38f7Smrg for libdir in $finalize_rpath; do 106117a3b38f7Smrg if test -n "$hardcode_libdir_flag_spec"; then 106127a3b38f7Smrg if test -n "$hardcode_libdir_separator"; then 106137a3b38f7Smrg if test -z "$hardcode_libdirs"; then 106146fc0178dSmrg hardcode_libdirs=$libdir 106157a3b38f7Smrg else 106167a3b38f7Smrg # Just accumulate the unique libdirs. 106177a3b38f7Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 106187a3b38f7Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 106197a3b38f7Smrg ;; 106207a3b38f7Smrg *) 10621862f5301Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 106227a3b38f7Smrg ;; 106237a3b38f7Smrg esac 106247a3b38f7Smrg fi 106257a3b38f7Smrg else 106267a3b38f7Smrg eval flag=\"$hardcode_libdir_flag_spec\" 10627862f5301Smrg func_append rpath " $flag" 106287a3b38f7Smrg fi 106297a3b38f7Smrg elif test -n "$runpath_var"; then 106307a3b38f7Smrg case "$finalize_perm_rpath " in 10631ff559fabSmrg *" $libdir "*) ;; 10632862f5301Smrg *) func_append finalize_perm_rpath " $libdir" ;; 10633ff559fabSmrg esac 10634ff559fabSmrg fi 106357a3b38f7Smrg done 106367a3b38f7Smrg # Substitute the hardcoded libdirs into the rpath. 106377a3b38f7Smrg if test -n "$hardcode_libdir_separator" && 106387a3b38f7Smrg test -n "$hardcode_libdirs"; then 106396fc0178dSmrg libdir=$hardcode_libdirs 106407a3b38f7Smrg eval rpath=\" $hardcode_libdir_flag_spec\" 106417a3b38f7Smrg fi 106426fc0178dSmrg finalize_rpath=$rpath 10643ff559fabSmrg 106446fc0178dSmrg if test -n "$libobjs" && test yes = "$build_old_libs"; then 106457a3b38f7Smrg # Transform all the library objects into standard objects. 1064644dda7b2Smrg compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 1064744dda7b2Smrg finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 106487a3b38f7Smrg fi 10649ff559fabSmrg 106506fc0178dSmrg func_generate_dlsyms "$outputname" "@PROGRAM@" false 10651ff559fabSmrg 106527a3b38f7Smrg # template prelinking step 106537a3b38f7Smrg if test -n "$prelink_cmds"; then 106547a3b38f7Smrg func_execute_cmds "$prelink_cmds" 'exit $?' 106557a3b38f7Smrg fi 10656ff559fabSmrg 106576fc0178dSmrg wrappers_required=: 106587a3b38f7Smrg case $host in 1065944dda7b2Smrg *cegcc* | *mingw32ce*) 1066044dda7b2Smrg # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. 106616fc0178dSmrg wrappers_required=false 1066244dda7b2Smrg ;; 106637a3b38f7Smrg *cygwin* | *mingw* ) 106646fc0178dSmrg test yes = "$build_libtool_libs" || wrappers_required=false 106657a3b38f7Smrg ;; 106667a3b38f7Smrg *) 106676fc0178dSmrg if test no = "$need_relink" || test yes != "$build_libtool_libs"; then 106686fc0178dSmrg wrappers_required=false 106697a3b38f7Smrg fi 106707a3b38f7Smrg ;; 106717a3b38f7Smrg esac 106726fc0178dSmrg $wrappers_required || { 106737a3b38f7Smrg # Replace the output file specification. 1067444dda7b2Smrg compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 106756fc0178dSmrg link_command=$compile_command$compile_rpath 10676ff559fabSmrg 106777a3b38f7Smrg # We have no uninstalled library dependencies, so finalize right now. 106787a3b38f7Smrg exit_status=0 106797a3b38f7Smrg func_show_eval "$link_command" 'exit_status=$?' 10680ff559fabSmrg 10681862f5301Smrg if test -n "$postlink_cmds"; then 10682862f5301Smrg func_to_tool_file "$output" 10683862f5301Smrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 10684862f5301Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 10685862f5301Smrg fi 10686862f5301Smrg 106877a3b38f7Smrg # Delete the generated files. 106886fc0178dSmrg if test -f "$output_objdir/${outputname}S.$objext"; then 106896fc0178dSmrg func_show_eval '$RM "$output_objdir/${outputname}S.$objext"' 106907a3b38f7Smrg fi 10691ff559fabSmrg 106927a3b38f7Smrg exit $exit_status 106936fc0178dSmrg } 10694ff559fabSmrg 106957a3b38f7Smrg if test -n "$compile_shlibpath$finalize_shlibpath"; then 106967a3b38f7Smrg compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" 106977a3b38f7Smrg fi 106987a3b38f7Smrg if test -n "$finalize_shlibpath"; then 106997a3b38f7Smrg finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" 107007a3b38f7Smrg fi 10701ff559fabSmrg 107027a3b38f7Smrg compile_var= 107037a3b38f7Smrg finalize_var= 107047a3b38f7Smrg if test -n "$runpath_var"; then 107057a3b38f7Smrg if test -n "$perm_rpath"; then 107067a3b38f7Smrg # We should set the runpath_var. 107077a3b38f7Smrg rpath= 107087a3b38f7Smrg for dir in $perm_rpath; do 10709862f5301Smrg func_append rpath "$dir:" 10710ff559fabSmrg done 107117a3b38f7Smrg compile_var="$runpath_var=\"$rpath\$$runpath_var\" " 10712ff559fabSmrg fi 107137a3b38f7Smrg if test -n "$finalize_perm_rpath"; then 107147a3b38f7Smrg # We should set the runpath_var. 107157a3b38f7Smrg rpath= 107167a3b38f7Smrg for dir in $finalize_perm_rpath; do 10717862f5301Smrg func_append rpath "$dir:" 107187a3b38f7Smrg done 107197a3b38f7Smrg finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " 107207a3b38f7Smrg fi 107217a3b38f7Smrg fi 10722ff559fabSmrg 107236fc0178dSmrg if test yes = "$no_install"; then 107247a3b38f7Smrg # We don't need to create a wrapper script. 107256fc0178dSmrg link_command=$compile_var$compile_command$compile_rpath 107267a3b38f7Smrg # Replace the output file specification. 1072744dda7b2Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 107287a3b38f7Smrg # Delete the old output file. 107297a3b38f7Smrg $opt_dry_run || $RM $output 107307a3b38f7Smrg # Link the executable and exit 107317a3b38f7Smrg func_show_eval "$link_command" 'exit $?' 10732862f5301Smrg 10733862f5301Smrg if test -n "$postlink_cmds"; then 10734862f5301Smrg func_to_tool_file "$output" 10735862f5301Smrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 10736862f5301Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 10737862f5301Smrg fi 10738862f5301Smrg 107397a3b38f7Smrg exit $EXIT_SUCCESS 107407a3b38f7Smrg fi 10741ff559fabSmrg 107426fc0178dSmrg case $hardcode_action,$fast_install in 107436fc0178dSmrg relink,*) 107446fc0178dSmrg # Fast installation is not supported 107456fc0178dSmrg link_command=$compile_var$compile_command$compile_rpath 107466fc0178dSmrg relink_command=$finalize_var$finalize_command$finalize_rpath 10747ff559fabSmrg 107486fc0178dSmrg func_warning "this platform does not like uninstalled shared libraries" 107496fc0178dSmrg func_warning "'$output' will be relinked during installation" 107506fc0178dSmrg ;; 107516fc0178dSmrg *,yes) 107526fc0178dSmrg link_command=$finalize_var$compile_command$finalize_rpath 107536fc0178dSmrg relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` 107546fc0178dSmrg ;; 107556fc0178dSmrg *,no) 107566fc0178dSmrg link_command=$compile_var$compile_command$compile_rpath 107576fc0178dSmrg relink_command=$finalize_var$finalize_command$finalize_rpath 107586fc0178dSmrg ;; 107596fc0178dSmrg *,needless) 107606fc0178dSmrg link_command=$finalize_var$compile_command$finalize_rpath 107616fc0178dSmrg relink_command= 107626fc0178dSmrg ;; 107636fc0178dSmrg esac 10764ff559fabSmrg 107657a3b38f7Smrg # Replace the output file specification. 1076644dda7b2Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` 10767ff559fabSmrg 107687a3b38f7Smrg # Delete the old output files. 107697a3b38f7Smrg $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname 10770ff559fabSmrg 107717a3b38f7Smrg func_show_eval "$link_command" 'exit $?' 10772ff559fabSmrg 10773862f5301Smrg if test -n "$postlink_cmds"; then 10774862f5301Smrg func_to_tool_file "$output_objdir/$outputname" 10775862f5301Smrg 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'` 10776862f5301Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 10777862f5301Smrg fi 10778862f5301Smrg 107797a3b38f7Smrg # Now create the wrapper script. 107807a3b38f7Smrg func_verbose "creating $output" 10781ff559fabSmrg 107827a3b38f7Smrg # Quote the relink command for shipping. 107837a3b38f7Smrg if test -n "$relink_command"; then 107847a3b38f7Smrg # Preserve any variables that may affect compiler behavior 107857a3b38f7Smrg for var in $variables_saved_for_relink; do 107867a3b38f7Smrg if eval test -z \"\${$var+set}\"; then 107877a3b38f7Smrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 107887a3b38f7Smrg elif eval var_value=\$$var; test -z "$var_value"; then 107897a3b38f7Smrg relink_command="$var=; export $var; $relink_command" 107907a3b38f7Smrg else 10791515ec619Smrg func_quote_arg pretty "$var_value" 10792515ec619Smrg relink_command="$var=$func_quote_arg_result; export $var; $relink_command" 107937a3b38f7Smrg fi 107947a3b38f7Smrg done 10795515ec619Smrg func_quote eval cd "`pwd`" 10796515ec619Smrg func_quote_arg pretty,unquoted "($func_quote_result; $relink_command)" 10797515ec619Smrg relink_command=$func_quote_arg_unquoted_result 107987a3b38f7Smrg fi 10799ff559fabSmrg 108007a3b38f7Smrg # Only actually do things if not in dry run mode. 108017a3b38f7Smrg $opt_dry_run || { 108027a3b38f7Smrg # win32 will think the script is a binary if it has 108037a3b38f7Smrg # a .exe suffix, so we strip it off here. 108047a3b38f7Smrg case $output in 108057a3b38f7Smrg *.exe) func_stripname '' '.exe' "$output" 108067a3b38f7Smrg output=$func_stripname_result ;; 108077a3b38f7Smrg esac 108087a3b38f7Smrg # test for cygwin because mv fails w/o .exe extensions 10809ff559fabSmrg case $host in 108107a3b38f7Smrg *cygwin*) 108117a3b38f7Smrg exeext=.exe 108127a3b38f7Smrg func_stripname '' '.exe' "$outputname" 108137a3b38f7Smrg outputname=$func_stripname_result ;; 108147a3b38f7Smrg *) exeext= ;; 10815ff559fabSmrg esac 108167a3b38f7Smrg case $host in 108177a3b38f7Smrg *cygwin* | *mingw* ) 108187a3b38f7Smrg func_dirname_and_basename "$output" "" "." 108197a3b38f7Smrg output_name=$func_basename_result 108207a3b38f7Smrg output_path=$func_dirname_result 108216fc0178dSmrg cwrappersource=$output_path/$objdir/lt-$output_name.c 108226fc0178dSmrg cwrapper=$output_path/$output_name.exe 108237a3b38f7Smrg $RM $cwrappersource $cwrapper 108247a3b38f7Smrg trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 108257a3b38f7Smrg 108267a3b38f7Smrg func_emit_cwrapperexe_src > $cwrappersource 108277a3b38f7Smrg 108287a3b38f7Smrg # The wrapper executable is built using the $host compiler, 108297a3b38f7Smrg # because it contains $host paths and files. If cross- 108307a3b38f7Smrg # compiling, it, like the target executable, must be 108317a3b38f7Smrg # executed on the $host or under an emulation environment. 108327a3b38f7Smrg $opt_dry_run || { 108337a3b38f7Smrg $LTCC $LTCFLAGS -o $cwrapper $cwrappersource 108347a3b38f7Smrg $STRIP $cwrapper 108357a3b38f7Smrg } 10836ff559fabSmrg 108377a3b38f7Smrg # Now, create the wrapper script for func_source use: 108387a3b38f7Smrg func_ltwrapper_scriptname $cwrapper 108397a3b38f7Smrg $RM $func_ltwrapper_scriptname_result 108407a3b38f7Smrg trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 108417a3b38f7Smrg $opt_dry_run || { 108427a3b38f7Smrg # note: this script will not be executed, so do not chmod. 108436fc0178dSmrg if test "x$build" = "x$host"; then 108447a3b38f7Smrg $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result 10845ff559fabSmrg else 108467a3b38f7Smrg func_emit_wrapper no > $func_ltwrapper_scriptname_result 10847ff559fabSmrg fi 108487a3b38f7Smrg } 108497a3b38f7Smrg ;; 108507a3b38f7Smrg * ) 108517a3b38f7Smrg $RM $output 108527a3b38f7Smrg trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 10853ff559fabSmrg 108547a3b38f7Smrg func_emit_wrapper no > $output 108557a3b38f7Smrg chmod +x $output 10856ff559fabSmrg ;; 10857ff559fabSmrg esac 108587a3b38f7Smrg } 108597a3b38f7Smrg exit $EXIT_SUCCESS 108607a3b38f7Smrg ;; 108617a3b38f7Smrg esac 10862ff559fabSmrg 108637a3b38f7Smrg # See if we need to build an old-fashioned archive. 108647a3b38f7Smrg for oldlib in $oldlibs; do 10865ff559fabSmrg 108666fc0178dSmrg case $build_libtool_libs in 108676fc0178dSmrg convenience) 108686fc0178dSmrg oldobjs="$libobjs_save $symfileobj" 108696fc0178dSmrg addlibs=$convenience 108707a3b38f7Smrg build_libtool_libs=no 108716fc0178dSmrg ;; 108726fc0178dSmrg module) 108736fc0178dSmrg oldobjs=$libobjs_save 108746fc0178dSmrg addlibs=$old_convenience 108756fc0178dSmrg build_libtool_libs=no 108766fc0178dSmrg ;; 108776fc0178dSmrg *) 108787a3b38f7Smrg oldobjs="$old_deplibs $non_pic_objects" 108796fc0178dSmrg $preload && test -f "$symfileobj" \ 108806fc0178dSmrg && func_append oldobjs " $symfileobj" 108816fc0178dSmrg addlibs=$old_convenience 108826fc0178dSmrg ;; 108836fc0178dSmrg esac 10884ff559fabSmrg 108857a3b38f7Smrg if test -n "$addlibs"; then 108866fc0178dSmrg gentop=$output_objdir/${outputname}x 10887862f5301Smrg func_append generated " $gentop" 10888ff559fabSmrg 108897a3b38f7Smrg func_extract_archives $gentop $addlibs 10890862f5301Smrg func_append oldobjs " $func_extract_archives_result" 108917a3b38f7Smrg fi 10892ff559fabSmrg 108937a3b38f7Smrg # Do each command in the archive commands. 108946fc0178dSmrg if test -n "$old_archive_from_new_cmds" && test yes = "$build_libtool_libs"; then 108957a3b38f7Smrg cmds=$old_archive_from_new_cmds 108967a3b38f7Smrg else 10897ff559fabSmrg 108987a3b38f7Smrg # Add any objects from preloaded convenience libraries 108997a3b38f7Smrg if test -n "$dlprefiles"; then 109006fc0178dSmrg gentop=$output_objdir/${outputname}x 10901862f5301Smrg func_append generated " $gentop" 10902ff559fabSmrg 109037a3b38f7Smrg func_extract_archives $gentop $dlprefiles 10904862f5301Smrg func_append oldobjs " $func_extract_archives_result" 109057a3b38f7Smrg fi 10906ff559fabSmrg 109077a3b38f7Smrg # POSIX demands no paths to be encoded in archives. We have 109087a3b38f7Smrg # to avoid creating archives with duplicate basenames if we 109097a3b38f7Smrg # might have to extract them afterwards, e.g., when creating a 109107a3b38f7Smrg # static archive out of a convenience library, or when linking 109117a3b38f7Smrg # the entirety of a libtool archive into another (currently 109127a3b38f7Smrg # not supported by libtool). 109137a3b38f7Smrg if (for obj in $oldobjs 109147a3b38f7Smrg do 109157a3b38f7Smrg func_basename "$obj" 109167a3b38f7Smrg $ECHO "$func_basename_result" 109177a3b38f7Smrg done | sort | sort -uc >/dev/null 2>&1); then 109187a3b38f7Smrg : 109197a3b38f7Smrg else 1092044dda7b2Smrg echo "copying selected object files to avoid basename conflicts..." 109216fc0178dSmrg gentop=$output_objdir/${outputname}x 10922862f5301Smrg func_append generated " $gentop" 109237a3b38f7Smrg func_mkdir_p "$gentop" 109247a3b38f7Smrg save_oldobjs=$oldobjs 109257a3b38f7Smrg oldobjs= 109267a3b38f7Smrg counter=1 109277a3b38f7Smrg for obj in $save_oldobjs 109287a3b38f7Smrg do 109297a3b38f7Smrg func_basename "$obj" 109306fc0178dSmrg objbase=$func_basename_result 109317a3b38f7Smrg case " $oldobjs " in 109327a3b38f7Smrg " ") oldobjs=$obj ;; 109337a3b38f7Smrg *[\ /]"$objbase "*) 109347a3b38f7Smrg while :; do 109357a3b38f7Smrg # Make sure we don't pick an alternate name that also 109367a3b38f7Smrg # overlaps. 109377a3b38f7Smrg newobj=lt$counter-$objbase 109387a3b38f7Smrg func_arith $counter + 1 109397a3b38f7Smrg counter=$func_arith_result 109407a3b38f7Smrg case " $oldobjs " in 109417a3b38f7Smrg *[\ /]"$newobj "*) ;; 109427a3b38f7Smrg *) if test ! -f "$gentop/$newobj"; then break; fi ;; 109437a3b38f7Smrg esac 109447a3b38f7Smrg done 109457a3b38f7Smrg func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" 10946862f5301Smrg func_append oldobjs " $gentop/$newobj" 109477a3b38f7Smrg ;; 10948862f5301Smrg *) func_append oldobjs " $obj" ;; 109497a3b38f7Smrg esac 10950ff559fabSmrg done 10951ff559fabSmrg fi 10952fc544a13Smrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 10953fc544a13Smrg tool_oldlib=$func_to_tool_file_result 109547a3b38f7Smrg eval cmds=\"$old_archive_cmds\" 10955ff559fabSmrg 109567a3b38f7Smrg func_len " $cmds" 109577a3b38f7Smrg len=$func_len_result 109587a3b38f7Smrg if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 109597a3b38f7Smrg cmds=$old_archive_cmds 10960862f5301Smrg elif test -n "$archiver_list_spec"; then 10961862f5301Smrg func_verbose "using command file archive linking..." 10962862f5301Smrg for obj in $oldobjs 10963862f5301Smrg do 10964862f5301Smrg func_to_tool_file "$obj" 10965862f5301Smrg $ECHO "$func_to_tool_file_result" 10966862f5301Smrg done > $output_objdir/$libname.libcmd 10967862f5301Smrg func_to_tool_file "$output_objdir/$libname.libcmd" 10968862f5301Smrg oldobjs=" $archiver_list_spec$func_to_tool_file_result" 10969862f5301Smrg cmds=$old_archive_cmds 109707a3b38f7Smrg else 109717a3b38f7Smrg # the command line is too long to link in one step, link in parts 109727a3b38f7Smrg func_verbose "using piecewise archive linking..." 109737a3b38f7Smrg save_RANLIB=$RANLIB 109747a3b38f7Smrg RANLIB=: 109757a3b38f7Smrg objlist= 109767a3b38f7Smrg concat_cmds= 109777a3b38f7Smrg save_oldobjs=$oldobjs 109787a3b38f7Smrg oldobjs= 109797a3b38f7Smrg # Is there a better way of finding the last object in the list? 109807a3b38f7Smrg for obj in $save_oldobjs 109817a3b38f7Smrg do 109827a3b38f7Smrg last_oldobj=$obj 109837a3b38f7Smrg done 109847a3b38f7Smrg eval test_cmds=\"$old_archive_cmds\" 109857a3b38f7Smrg func_len " $test_cmds" 109867a3b38f7Smrg len0=$func_len_result 109877a3b38f7Smrg len=$len0 109887a3b38f7Smrg for obj in $save_oldobjs 109897a3b38f7Smrg do 109907a3b38f7Smrg func_len " $obj" 109917a3b38f7Smrg func_arith $len + $func_len_result 109927a3b38f7Smrg len=$func_arith_result 109937a3b38f7Smrg func_append objlist " $obj" 109947a3b38f7Smrg if test "$len" -lt "$max_cmd_len"; then 109957a3b38f7Smrg : 109967a3b38f7Smrg else 109977a3b38f7Smrg # the above command should be used before it gets too long 109987a3b38f7Smrg oldobjs=$objlist 109996fc0178dSmrg if test "$obj" = "$last_oldobj"; then 110007a3b38f7Smrg RANLIB=$save_RANLIB 110017a3b38f7Smrg fi 110027a3b38f7Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 110036fc0178dSmrg eval concat_cmds=\"\$concat_cmds$old_archive_cmds\" 110047a3b38f7Smrg objlist= 110057a3b38f7Smrg len=$len0 110067a3b38f7Smrg fi 110077a3b38f7Smrg done 110087a3b38f7Smrg RANLIB=$save_RANLIB 110097a3b38f7Smrg oldobjs=$objlist 110106fc0178dSmrg if test -z "$oldobjs"; then 110117a3b38f7Smrg eval cmds=\"\$concat_cmds\" 110127a3b38f7Smrg else 110137a3b38f7Smrg eval cmds=\"\$concat_cmds~\$old_archive_cmds\" 110147a3b38f7Smrg fi 110157a3b38f7Smrg fi 110167a3b38f7Smrg fi 110177a3b38f7Smrg func_execute_cmds "$cmds" 'exit $?' 11018ff559fabSmrg done 11019ff559fabSmrg 110207a3b38f7Smrg test -n "$generated" && \ 110217a3b38f7Smrg func_show_eval "${RM}r$generated" 11022ff559fabSmrg 110237a3b38f7Smrg # Now create the libtool archive. 110247a3b38f7Smrg case $output in 110257a3b38f7Smrg *.la) 110267a3b38f7Smrg old_library= 110276fc0178dSmrg test yes = "$build_old_libs" && old_library=$libname.$libext 110287a3b38f7Smrg func_verbose "creating $output" 11029ff559fabSmrg 110307a3b38f7Smrg # Preserve any variables that may affect compiler behavior 110317a3b38f7Smrg for var in $variables_saved_for_relink; do 110327a3b38f7Smrg if eval test -z \"\${$var+set}\"; then 110337a3b38f7Smrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 110347a3b38f7Smrg elif eval var_value=\$$var; test -z "$var_value"; then 110357a3b38f7Smrg relink_command="$var=; export $var; $relink_command" 11036ff559fabSmrg else 11037515ec619Smrg func_quote_arg pretty,unquoted "$var_value" 11038515ec619Smrg relink_command="$var=$func_quote_arg_unquoted_result; export $var; $relink_command" 11039ff559fabSmrg fi 110407a3b38f7Smrg done 110417a3b38f7Smrg # Quote the link command for shipping. 11042515ec619Smrg func_quote eval cd "`pwd`" 11043515ec619Smrg relink_command="($func_quote_result; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" 11044515ec619Smrg func_quote_arg pretty,unquoted "$relink_command" 11045515ec619Smrg relink_command=$func_quote_arg_unquoted_result 110466fc0178dSmrg if test yes = "$hardcode_automatic"; then 110477a3b38f7Smrg relink_command= 110487a3b38f7Smrg fi 11049ff559fabSmrg 110507a3b38f7Smrg # Only create the output if not a dry run. 110517a3b38f7Smrg $opt_dry_run || { 110527a3b38f7Smrg for installed in no yes; do 110536fc0178dSmrg if test yes = "$installed"; then 110547a3b38f7Smrg if test -z "$install_libdir"; then 110557a3b38f7Smrg break 110567a3b38f7Smrg fi 110576fc0178dSmrg output=$output_objdir/${outputname}i 110587a3b38f7Smrg # Replace all uninstalled libtool libraries with the installed ones 110597a3b38f7Smrg newdependency_libs= 110607a3b38f7Smrg for deplib in $dependency_libs; do 110617a3b38f7Smrg case $deplib in 110627a3b38f7Smrg *.la) 110637a3b38f7Smrg func_basename "$deplib" 110646fc0178dSmrg name=$func_basename_result 11065fc544a13Smrg func_resolve_sysroot "$deplib" 110666fc0178dSmrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` 110677a3b38f7Smrg test -z "$libdir" && \ 110686fc0178dSmrg func_fatal_error "'$deplib' is not a valid libtool archive" 11069862f5301Smrg func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" 11070862f5301Smrg ;; 11071862f5301Smrg -L*) 11072862f5301Smrg func_stripname -L '' "$deplib" 11073862f5301Smrg func_replace_sysroot "$func_stripname_result" 11074862f5301Smrg func_append newdependency_libs " -L$func_replace_sysroot_result" 11075862f5301Smrg ;; 11076862f5301Smrg -R*) 11077862f5301Smrg func_stripname -R '' "$deplib" 11078862f5301Smrg func_replace_sysroot "$func_stripname_result" 11079862f5301Smrg func_append newdependency_libs " -R$func_replace_sysroot_result" 110807a3b38f7Smrg ;; 11081862f5301Smrg *) func_append newdependency_libs " $deplib" ;; 110827a3b38f7Smrg esac 110837a3b38f7Smrg done 110846fc0178dSmrg dependency_libs=$newdependency_libs 110857a3b38f7Smrg newdlfiles= 110867a3b38f7Smrg 110877a3b38f7Smrg for lib in $dlfiles; do 110887a3b38f7Smrg case $lib in 110897a3b38f7Smrg *.la) 110907a3b38f7Smrg func_basename "$lib" 110916fc0178dSmrg name=$func_basename_result 110926fc0178dSmrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 110937a3b38f7Smrg test -z "$libdir" && \ 110946fc0178dSmrg func_fatal_error "'$lib' is not a valid libtool archive" 11095862f5301Smrg func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" 110967a3b38f7Smrg ;; 11097862f5301Smrg *) func_append newdlfiles " $lib" ;; 110987a3b38f7Smrg esac 110997a3b38f7Smrg done 111006fc0178dSmrg dlfiles=$newdlfiles 111017a3b38f7Smrg newdlprefiles= 111027a3b38f7Smrg for lib in $dlprefiles; do 111037a3b38f7Smrg case $lib in 111047a3b38f7Smrg *.la) 111057a3b38f7Smrg # Only pass preopened files to the pseudo-archive (for 111067a3b38f7Smrg # eventual linking with the app. that links it) if we 111077a3b38f7Smrg # didn't already link the preopened objects directly into 111087a3b38f7Smrg # the library: 111097a3b38f7Smrg func_basename "$lib" 111106fc0178dSmrg name=$func_basename_result 111116fc0178dSmrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 111127a3b38f7Smrg test -z "$libdir" && \ 111136fc0178dSmrg func_fatal_error "'$lib' is not a valid libtool archive" 11114862f5301Smrg func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" 111157a3b38f7Smrg ;; 111167a3b38f7Smrg esac 111177a3b38f7Smrg done 111186fc0178dSmrg dlprefiles=$newdlprefiles 111197a3b38f7Smrg else 111207a3b38f7Smrg newdlfiles= 111217a3b38f7Smrg for lib in $dlfiles; do 111227a3b38f7Smrg case $lib in 111236fc0178dSmrg [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; 111247a3b38f7Smrg *) abs=`pwd`"/$lib" ;; 111257a3b38f7Smrg esac 11126862f5301Smrg func_append newdlfiles " $abs" 111277a3b38f7Smrg done 111286fc0178dSmrg dlfiles=$newdlfiles 111297a3b38f7Smrg newdlprefiles= 111307a3b38f7Smrg for lib in $dlprefiles; do 111317a3b38f7Smrg case $lib in 111326fc0178dSmrg [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; 111337a3b38f7Smrg *) abs=`pwd`"/$lib" ;; 111347a3b38f7Smrg esac 11135862f5301Smrg func_append newdlprefiles " $abs" 111367a3b38f7Smrg done 111376fc0178dSmrg dlprefiles=$newdlprefiles 111387a3b38f7Smrg fi 111397a3b38f7Smrg $RM $output 111407a3b38f7Smrg # place dlname in correct position for cygwin 1114144dda7b2Smrg # In fact, it would be nice if we could use this code for all target 1114244dda7b2Smrg # systems that can't hard-code library paths into their executables 1114344dda7b2Smrg # and that have no shared library path variable independent of PATH, 1114444dda7b2Smrg # but it turns out we can't easily determine that from inspecting 1114544dda7b2Smrg # libtool variables, so we have to hard-code the OSs to which it 1114644dda7b2Smrg # applies here; at the moment, that means platforms that use the PE 1114744dda7b2Smrg # object format with DLL files. See the long comment at the top of 1114844dda7b2Smrg # tests/bindir.at for full details. 111497a3b38f7Smrg tdlname=$dlname 111507a3b38f7Smrg case $host,$output,$installed,$module,$dlname in 1115144dda7b2Smrg *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) 1115244dda7b2Smrg # If a -bindir argument was supplied, place the dll there. 111536fc0178dSmrg if test -n "$bindir"; then 1115444dda7b2Smrg func_relative_path "$install_libdir" "$bindir" 111556fc0178dSmrg tdlname=$func_relative_path_result/$dlname 1115644dda7b2Smrg else 1115744dda7b2Smrg # Otherwise fall back on heuristic. 1115844dda7b2Smrg tdlname=../bin/$dlname 1115944dda7b2Smrg fi 1116044dda7b2Smrg ;; 111617a3b38f7Smrg esac 111627a3b38f7Smrg $ECHO > $output "\ 111637a3b38f7Smrg# $outputname - a libtool library file 111646fc0178dSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 111657a3b38f7Smrg# 111667a3b38f7Smrg# Please DO NOT delete this file! 111677a3b38f7Smrg# It is necessary for linking the library. 11168ff559fabSmrg 111697a3b38f7Smrg# The name that we can dlopen(3). 111707a3b38f7Smrgdlname='$tdlname' 11171ff559fabSmrg 111727a3b38f7Smrg# Names of this library. 111737a3b38f7Smrglibrary_names='$library_names' 11174ff559fabSmrg 111757a3b38f7Smrg# The name of the static archive. 111767a3b38f7Smrgold_library='$old_library' 11177ff559fabSmrg 111786fc0178dSmrg# Linker flags that cannot go in dependency_libs. 111797a3b38f7Smrginherited_linker_flags='$new_inherited_linker_flags' 11180ff559fabSmrg 111817a3b38f7Smrg# Libraries that this one depends upon. 111827a3b38f7Smrgdependency_libs='$dependency_libs' 11183ff559fabSmrg 111847a3b38f7Smrg# Names of additional weak libraries provided by this library 111857a3b38f7Smrgweak_library_names='$weak_libs' 11186ff559fabSmrg 111877a3b38f7Smrg# Version information for $libname. 111887a3b38f7Smrgcurrent=$current 111897a3b38f7Smrgage=$age 111907a3b38f7Smrgrevision=$revision 11191ff559fabSmrg 111927a3b38f7Smrg# Is this an already installed library? 111937a3b38f7Smrginstalled=$installed 11194ff559fabSmrg 111957a3b38f7Smrg# Should we warn about portability when linking against -modules? 111967a3b38f7Smrgshouldnotlink=$module 11197ff559fabSmrg 111987a3b38f7Smrg# Files to dlopen/dlpreopen 111997a3b38f7Smrgdlopen='$dlfiles' 112007a3b38f7Smrgdlpreopen='$dlprefiles' 11201ff559fabSmrg 112027a3b38f7Smrg# Directory that this library needs to be installed in: 112037a3b38f7Smrglibdir='$install_libdir'" 112046fc0178dSmrg if test no,yes = "$installed,$need_relink"; then 112057a3b38f7Smrg $ECHO >> $output "\ 112067a3b38f7Smrgrelink_command=\"$relink_command\"" 112077a3b38f7Smrg fi 112087a3b38f7Smrg done 112097a3b38f7Smrg } 11210ff559fabSmrg 112117a3b38f7Smrg # Do a symbolic link so that the libtool archive can be found in 112127a3b38f7Smrg # LD_LIBRARY_PATH before the program is installed. 112137a3b38f7Smrg func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' 112147a3b38f7Smrg ;; 112157a3b38f7Smrg esac 112167a3b38f7Smrg exit $EXIT_SUCCESS 112177a3b38f7Smrg} 11218ff559fabSmrg 112196fc0178dSmrgif test link = "$opt_mode" || test relink = "$opt_mode"; then 112206fc0178dSmrg func_mode_link ${1+"$@"} 112216fc0178dSmrgfi 11222ff559fabSmrg 11223ff559fabSmrg 112247a3b38f7Smrg# func_mode_uninstall arg... 112257a3b38f7Smrgfunc_mode_uninstall () 112267a3b38f7Smrg{ 112276fc0178dSmrg $debug_cmd 112286fc0178dSmrg 112296fc0178dSmrg RM=$nonopt 11230ff559fabSmrg files= 112316fc0178dSmrg rmforce=false 11232ff559fabSmrg exit_status=0 11233ff559fabSmrg 11234ff559fabSmrg # This variable tells wrapper scripts just to set variables rather 11235ff559fabSmrg # than running their programs. 112366fc0178dSmrg libtool_install_magic=$magic 11237ff559fabSmrg 11238ff559fabSmrg for arg 11239ff559fabSmrg do 11240ff559fabSmrg case $arg in 112416fc0178dSmrg -f) func_append RM " $arg"; rmforce=: ;; 11242862f5301Smrg -*) func_append RM " $arg" ;; 11243862f5301Smrg *) func_append files " $arg" ;; 11244ff559fabSmrg esac 11245ff559fabSmrg done 11246ff559fabSmrg 112477a3b38f7Smrg test -z "$RM" && \ 112487a3b38f7Smrg func_fatal_help "you must specify an RM program" 11249ff559fabSmrg 11250ff559fabSmrg rmdirs= 11251ff559fabSmrg 11252ff559fabSmrg for file in $files; do 112537a3b38f7Smrg func_dirname "$file" "" "." 112546fc0178dSmrg dir=$func_dirname_result 112556fc0178dSmrg if test . = "$dir"; then 112566fc0178dSmrg odir=$objdir 11257ff559fabSmrg else 112586fc0178dSmrg odir=$dir/$objdir 11259ff559fabSmrg fi 112607a3b38f7Smrg func_basename "$file" 112616fc0178dSmrg name=$func_basename_result 112626fc0178dSmrg test uninstall = "$opt_mode" && odir=$dir 11263ff559fabSmrg 11264862f5301Smrg # Remember odir for removal later, being careful to avoid duplicates 112656fc0178dSmrg if test clean = "$opt_mode"; then 11266ff559fabSmrg case " $rmdirs " in 11267862f5301Smrg *" $odir "*) ;; 11268862f5301Smrg *) func_append rmdirs " $odir" ;; 11269ff559fabSmrg esac 11270ff559fabSmrg fi 11271ff559fabSmrg 11272ff559fabSmrg # Don't error if the file doesn't exist and rm -f was used. 112737a3b38f7Smrg if { test -L "$file"; } >/dev/null 2>&1 || 112747a3b38f7Smrg { test -h "$file"; } >/dev/null 2>&1 || 112757a3b38f7Smrg test -f "$file"; then 11276ff559fabSmrg : 11277ff559fabSmrg elif test -d "$file"; then 11278ff559fabSmrg exit_status=1 11279ff559fabSmrg continue 112806fc0178dSmrg elif $rmforce; then 11281ff559fabSmrg continue 11282ff559fabSmrg fi 11283ff559fabSmrg 112846fc0178dSmrg rmfiles=$file 11285ff559fabSmrg 11286ff559fabSmrg case $name in 11287ff559fabSmrg *.la) 11288ff559fabSmrg # Possibly a libtool archive, so verify it. 112897a3b38f7Smrg if func_lalib_p "$file"; then 112907a3b38f7Smrg func_source $dir/$name 11291ff559fabSmrg 11292ff559fabSmrg # Delete the libtool libraries and symlinks. 11293ff559fabSmrg for n in $library_names; do 11294862f5301Smrg func_append rmfiles " $odir/$n" 11295ff559fabSmrg done 11296862f5301Smrg test -n "$old_library" && func_append rmfiles " $odir/$old_library" 11297ff559fabSmrg 112986fc0178dSmrg case $opt_mode in 11299ff559fabSmrg clean) 11300862f5301Smrg case " $library_names " in 11301ff559fabSmrg *" $dlname "*) ;; 11302862f5301Smrg *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; 11303ff559fabSmrg esac 11304862f5301Smrg test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" 11305ff559fabSmrg ;; 11306ff559fabSmrg uninstall) 11307ff559fabSmrg if test -n "$library_names"; then 11308ff559fabSmrg # Do each command in the postuninstall commands. 113096fc0178dSmrg func_execute_cmds "$postuninstall_cmds" '$rmforce || exit_status=1' 11310ff559fabSmrg fi 11311ff559fabSmrg 11312ff559fabSmrg if test -n "$old_library"; then 11313ff559fabSmrg # Do each command in the old_postuninstall commands. 113146fc0178dSmrg func_execute_cmds "$old_postuninstall_cmds" '$rmforce || exit_status=1' 11315ff559fabSmrg fi 11316ff559fabSmrg # FIXME: should reinstall the best remaining shared library. 11317ff559fabSmrg ;; 11318ff559fabSmrg esac 11319ff559fabSmrg fi 11320ff559fabSmrg ;; 11321ff559fabSmrg 11322ff559fabSmrg *.lo) 11323ff559fabSmrg # Possibly a libtool object, so verify it. 113247a3b38f7Smrg if func_lalib_p "$file"; then 11325ff559fabSmrg 11326ff559fabSmrg # Read the .lo file 113277a3b38f7Smrg func_source $dir/$name 11328ff559fabSmrg 11329ff559fabSmrg # Add PIC object to the list of files to remove. 113306fc0178dSmrg if test -n "$pic_object" && test none != "$pic_object"; then 11331862f5301Smrg func_append rmfiles " $dir/$pic_object" 11332ff559fabSmrg fi 11333ff559fabSmrg 11334ff559fabSmrg # Add non-PIC object to the list of files to remove. 113356fc0178dSmrg if test -n "$non_pic_object" && test none != "$non_pic_object"; then 11336862f5301Smrg func_append rmfiles " $dir/$non_pic_object" 11337ff559fabSmrg fi 11338ff559fabSmrg fi 11339ff559fabSmrg ;; 11340ff559fabSmrg 11341ff559fabSmrg *) 113426fc0178dSmrg if test clean = "$opt_mode"; then 11343ff559fabSmrg noexename=$name 11344ff559fabSmrg case $file in 11345ff559fabSmrg *.exe) 113467a3b38f7Smrg func_stripname '' '.exe' "$file" 113477a3b38f7Smrg file=$func_stripname_result 113487a3b38f7Smrg func_stripname '' '.exe' "$name" 113497a3b38f7Smrg noexename=$func_stripname_result 11350ff559fabSmrg # $file with .exe has already been added to rmfiles, 11351ff559fabSmrg # add $file without .exe 11352862f5301Smrg func_append rmfiles " $file" 11353ff559fabSmrg ;; 11354ff559fabSmrg esac 11355ff559fabSmrg # Do a test to see if this is a libtool program. 113567a3b38f7Smrg if func_ltwrapper_p "$file"; then 113577a3b38f7Smrg if func_ltwrapper_executable_p "$file"; then 113587a3b38f7Smrg func_ltwrapper_scriptname "$file" 113597a3b38f7Smrg relink_command= 113607a3b38f7Smrg func_source $func_ltwrapper_scriptname_result 11361862f5301Smrg func_append rmfiles " $func_ltwrapper_scriptname_result" 113627a3b38f7Smrg else 113637a3b38f7Smrg relink_command= 113647a3b38f7Smrg func_source $dir/$noexename 113657a3b38f7Smrg fi 11366ff559fabSmrg 11367ff559fabSmrg # note $name still contains .exe if it was in $file originally 11368ff559fabSmrg # as does the version of $file that was added into $rmfiles 113696fc0178dSmrg func_append rmfiles " $odir/$name $odir/${name}S.$objext" 113706fc0178dSmrg if test yes = "$fast_install" && test -n "$relink_command"; then 11371862f5301Smrg func_append rmfiles " $odir/lt-$name" 11372ff559fabSmrg fi 113736fc0178dSmrg if test "X$noexename" != "X$name"; then 113746fc0178dSmrg func_append rmfiles " $odir/lt-$noexename.c" 11375ff559fabSmrg fi 11376ff559fabSmrg fi 11377ff559fabSmrg fi 11378ff559fabSmrg ;; 11379ff559fabSmrg esac 113807a3b38f7Smrg func_show_eval "$RM $rmfiles" 'exit_status=1' 11381ff559fabSmrg done 11382ff559fabSmrg 113836fc0178dSmrg # Try to remove the $objdir's in the directories where we deleted files 11384ff559fabSmrg for dir in $rmdirs; do 11385ff559fabSmrg if test -d "$dir"; then 113867a3b38f7Smrg func_show_eval "rmdir $dir >/dev/null 2>&1" 11387ff559fabSmrg fi 11388ff559fabSmrg done 11389ff559fabSmrg 11390ff559fabSmrg exit $exit_status 113917a3b38f7Smrg} 11392ff559fabSmrg 113936fc0178dSmrgif test uninstall = "$opt_mode" || test clean = "$opt_mode"; then 113946fc0178dSmrg func_mode_uninstall ${1+"$@"} 113956fc0178dSmrgfi 11396ff559fabSmrg 11397862f5301Smrgtest -z "$opt_mode" && { 113986fc0178dSmrg help=$generic_help 113997a3b38f7Smrg func_fatal_help "you must specify a MODE" 114007a3b38f7Smrg} 114017a3b38f7Smrg 114027a3b38f7Smrgtest -z "$exec_cmd" && \ 114036fc0178dSmrg func_fatal_help "invalid operation mode '$opt_mode'" 11404ff559fabSmrg 11405ff559fabSmrgif test -n "$exec_cmd"; then 114067a3b38f7Smrg eval exec "$exec_cmd" 11407ff559fabSmrg exit $EXIT_FAILURE 11408ff559fabSmrgfi 11409ff559fabSmrg 114107a3b38f7Smrgexit $exit_status 11411ff559fabSmrg 11412ff559fabSmrg 11413ff559fabSmrg# The TAGs below are defined such that we never get into a situation 114146fc0178dSmrg# where we disable both kinds of libraries. Given conflicting 11415ff559fabSmrg# choices, we go for a static library, that is the most portable, 11416ff559fabSmrg# since we can't tell whether shared libraries were disabled because 11417ff559fabSmrg# the user asked for that or because the platform doesn't support 11418ff559fabSmrg# them. This is particularly important on AIX, because we don't 11419ff559fabSmrg# support having both static and shared libraries enabled at the same 11420ff559fabSmrg# time on that platform, so we default to a shared-only configuration. 11421ff559fabSmrg# If a disable-shared tag is given, we'll fallback to a static-only 11422ff559fabSmrg# configuration. But we'll never go from static-only to shared-only. 11423ff559fabSmrg 11424ff559fabSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared 114257a3b38f7Smrgbuild_libtool_libs=no 114267a3b38f7Smrgbuild_old_libs=yes 11427ff559fabSmrg# ### END LIBTOOL TAG CONFIG: disable-shared 11428ff559fabSmrg 11429ff559fabSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static 114307a3b38f7Smrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` 11431ff559fabSmrg# ### END LIBTOOL TAG CONFIG: disable-static 11432ff559fabSmrg 11433ff559fabSmrg# Local Variables: 11434ff559fabSmrg# mode:shell-script 11435ff559fabSmrg# sh-indentation:2 11436ff559fabSmrg# End: 11437