1efb46889Smrg#! /usr/bin/env sh 22f60eb46Smrg## DO NOT EDIT - This file generated from ./build-aux/ltmain.in 3efb46889Smrg## by inline-source v2019-02-19.15 4c3c9db83Smrg 5efb46889Smrg# libtool (GNU libtool) 2.4.7 62f60eb46Smrg# Provide generalized library-building support services. 7c3c9db83Smrg# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 8c3c9db83Smrg 9efb46889Smrg# Copyright (C) 1996-2019, 2021-2022 Free Software Foundation, Inc. 10c3c9db83Smrg# This is free software; see the source for copying conditions. There is NO 11c3c9db83Smrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12c3c9db83Smrg 13c3c9db83Smrg# GNU Libtool is free software; you can redistribute it and/or modify 14692f60a7Smrg# it under the terms of the GNU General Public License as published by 15692f60a7Smrg# the Free Software Foundation; either version 2 of the License, or 16692f60a7Smrg# (at your option) any later version. 17692f60a7Smrg# 18c3c9db83Smrg# As a special exception to the GNU General Public License, 19c3c9db83Smrg# if you distribute this file as part of a program or library that 20c3c9db83Smrg# is built using GNU Libtool, you may include this file under the 21c3c9db83Smrg# same distribution terms that you use for the rest of that program. 22c3c9db83Smrg# 23c3c9db83Smrg# GNU Libtool is distributed in the hope that it will be useful, but 24692f60a7Smrg# WITHOUT ANY WARRANTY; without even the implied warranty of 25692f60a7Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 26692f60a7Smrg# General Public License for more details. 27692f60a7Smrg# 28692f60a7Smrg# You should have received a copy of the GNU General Public License 292f60eb46Smrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 302e71ea71Smrg 31692f60a7Smrg 323f6d0e1dSmrgPROGRAM=libtool 33692f60a7SmrgPACKAGE=libtool 34efb46889SmrgVERSION=2.4.7 35efb46889Smrgpackage_revision=2.4.7 3654569438Smrg 372f60eb46Smrg 382f60eb46Smrg## ------ ## 392f60eb46Smrg## Usage. ## 402f60eb46Smrg## ------ ## 412f60eb46Smrg 422f60eb46Smrg# Run './libtool --help' for help with using this script from the 432f60eb46Smrg# command line. 442f60eb46Smrg 452f60eb46Smrg 462f60eb46Smrg## ------------------------------- ## 472f60eb46Smrg## User overridable command paths. ## 482f60eb46Smrg## ------------------------------- ## 492f60eb46Smrg 502f60eb46Smrg# After configure completes, it has a better idea of some of the 512f60eb46Smrg# shell tools we need than the defaults used by the functions shared 522f60eb46Smrg# with bootstrap, so set those here where they can still be over- 532f60eb46Smrg# ridden by the user, but otherwise take precedence. 542f60eb46Smrg 552f60eb46Smrg: ${AUTOCONF="autoconf"} 562f60eb46Smrg: ${AUTOMAKE="automake"} 572f60eb46Smrg 582f60eb46Smrg 592f60eb46Smrg## -------------------------- ## 602f60eb46Smrg## Source external libraries. ## 612f60eb46Smrg## -------------------------- ## 622f60eb46Smrg 632f60eb46Smrg# Much of our low-level functionality needs to be sourced from external 642f60eb46Smrg# libraries, which are installed to $pkgauxdir. 652f60eb46Smrg 662f60eb46Smrg# Set a version string for this script. 67efb46889Smrgscriptversion=2019-02-19.15; # UTC 682f60eb46Smrg 692f60eb46Smrg# General shell script boiler plate, and helper functions. 702f60eb46Smrg# Written by Gary V. Vaughan, 2004 712f60eb46Smrg 72efb46889Smrg# This is free software. There is NO warranty; not even for 73efb46889Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 74efb46889Smrg# 75efb46889Smrg# Copyright (C) 2004-2019, 2021 Bootstrap Authors 76efb46889Smrg# 77efb46889Smrg# This file is dual licensed under the terms of the MIT license 78efb46889Smrg# <https://opensource.org/license/MIT>, and GPL version 2 or later 79efb46889Smrg# <http://www.gnu.org/licenses/gpl-2.0.html>. You must apply one of 80efb46889Smrg# these licenses when using or redistributing this software or any of 81efb46889Smrg# the files within it. See the URLs above, or the file `LICENSE` 82efb46889Smrg# included in the Bootstrap distribution for the full license texts. 832f60eb46Smrg 84efb46889Smrg# Please report bugs or propose patches to: 85efb46889Smrg# <https://github.com/gnulib-modules/bootstrap/issues> 862f60eb46Smrg 872f60eb46Smrg 882f60eb46Smrg## ------ ## 892f60eb46Smrg## Usage. ## 902f60eb46Smrg## ------ ## 912f60eb46Smrg 922f60eb46Smrg# Evaluate this file near the top of your script to gain access to 932f60eb46Smrg# the functions and variables defined here: 942f60eb46Smrg# 952f60eb46Smrg# . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh 962f60eb46Smrg# 972f60eb46Smrg# If you need to override any of the default environment variable 982f60eb46Smrg# settings, do that before evaluating this file. 992f60eb46Smrg 1002f60eb46Smrg 1012f60eb46Smrg## -------------------- ## 1022f60eb46Smrg## Shell normalisation. ## 1032f60eb46Smrg## -------------------- ## 1042f60eb46Smrg 1052f60eb46Smrg# Some shells need a little help to be as Bourne compatible as possible. 1062f60eb46Smrg# Before doing anything else, make sure all that help has been provided! 1072f60eb46Smrg 1082f60eb46SmrgDUALCASE=1; export DUALCASE # for MKS sh 1092f60eb46Smrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : 11054569438Smrg emulate sh 11154569438Smrg NULLCMD=: 1122f60eb46Smrg # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which 11354569438Smrg # is contrary to our usage. Disable this feature. 11454569438Smrg alias -g '${1+"$@"}'='"$@"' 115692f60a7Smrg setopt NO_GLOB_SUBST 11654569438Smrgelse 1172f60eb46Smrg case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac 118692f60a7Smrgfi 1193f6d0e1dSmrg 1202f60eb46Smrg# NLS nuisances: We save the old values in case they are required later. 1212f60eb46Smrg_G_user_locale= 1222f60eb46Smrg_G_safe_locale= 1232f60eb46Smrgfor _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 12454569438Smrgdo 1252f60eb46Smrg eval "if test set = \"\${$_G_var+set}\"; then 1262f60eb46Smrg save_$_G_var=\$$_G_var 1272f60eb46Smrg $_G_var=C 1282f60eb46Smrg export $_G_var 1292f60eb46Smrg _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\" 1302f60eb46Smrg _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\" 13154569438Smrg fi" 13254569438Smrgdone 133efb46889Smrg# These NLS vars are set unconditionally (bootstrap issue #24). Unset those 134efb46889Smrg# in case the environment reset is needed later and the $save_* variant is not 135efb46889Smrg# defined (see the code above). 136efb46889SmrgLC_ALL=C 137efb46889SmrgLANGUAGE=C 138efb46889Smrgexport LANGUAGE LC_ALL 139c3c9db83Smrg 1402f60eb46Smrg# Make sure IFS has a sensible default 1412f60eb46Smrgsp=' ' 1422f60eb46Smrgnl=' 1432f60eb46Smrg' 1442f60eb46SmrgIFS="$sp $nl" 1452f60eb46Smrg 1462f60eb46Smrg# There are apparently some retarded systems that use ';' as a PATH separator! 1472f60eb46Smrgif test "${PATH_SEPARATOR+set}" != set; then 1482f60eb46Smrg PATH_SEPARATOR=: 1492f60eb46Smrg (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { 1502f60eb46Smrg (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || 1512f60eb46Smrg PATH_SEPARATOR=';' 1522f60eb46Smrg } 1532f60eb46Smrgfi 154c3c9db83Smrg 155c3c9db83Smrg 156efb46889Smrg# func_unset VAR 157efb46889Smrg# -------------- 158efb46889Smrg# Portably unset VAR. 159efb46889Smrg# In some shells, an 'unset VAR' statement leaves a non-zero return 160efb46889Smrg# status if VAR is already unset, which might be problematic if the 161efb46889Smrg# statement is used at the end of a function (thus poisoning its return 162efb46889Smrg# value) or when 'set -e' is active (causing even a spurious abort of 163efb46889Smrg# the script in this case). 164efb46889Smrgfunc_unset () 165efb46889Smrg{ 166efb46889Smrg { eval $1=; (eval unset $1) >/dev/null 2>&1 && eval unset $1 || : ; } 167efb46889Smrg} 168efb46889Smrg 169efb46889Smrg 170efb46889Smrg# Make sure CDPATH doesn't cause `cd` commands to output the target dir. 171efb46889Smrgfunc_unset CDPATH 172efb46889Smrg 173efb46889Smrg# Make sure ${,E,F}GREP behave sanely. 174efb46889Smrgfunc_unset GREP_OPTIONS 175efb46889Smrg 176c3c9db83Smrg 1772f60eb46Smrg## ------------------------- ## 1782f60eb46Smrg## Locate command utilities. ## 1792f60eb46Smrg## ------------------------- ## 1802f60eb46Smrg 1812f60eb46Smrg 1822f60eb46Smrg# func_executable_p FILE 1832f60eb46Smrg# ---------------------- 1842f60eb46Smrg# Check that FILE is an executable regular file. 1852f60eb46Smrgfunc_executable_p () 1862f60eb46Smrg{ 1872f60eb46Smrg test -f "$1" && test -x "$1" 1882f60eb46Smrg} 1892f60eb46Smrg 1902f60eb46Smrg 1912f60eb46Smrg# func_path_progs PROGS_LIST CHECK_FUNC [PATH] 1922f60eb46Smrg# -------------------------------------------- 1932f60eb46Smrg# Search for either a program that responds to --version with output 1942f60eb46Smrg# containing "GNU", or else returned by CHECK_FUNC otherwise, by 1952f60eb46Smrg# trying all the directories in PATH with each of the elements of 1962f60eb46Smrg# PROGS_LIST. 1972f60eb46Smrg# 1982f60eb46Smrg# CHECK_FUNC should accept the path to a candidate program, and 1992f60eb46Smrg# set $func_check_prog_result if it truncates its output less than 2002f60eb46Smrg# $_G_path_prog_max characters. 2012f60eb46Smrgfunc_path_progs () 2022f60eb46Smrg{ 2032f60eb46Smrg _G_progs_list=$1 2042f60eb46Smrg _G_check_func=$2 2052f60eb46Smrg _G_PATH=${3-"$PATH"} 2062f60eb46Smrg 2072f60eb46Smrg _G_path_prog_max=0 2082f60eb46Smrg _G_path_prog_found=false 2092f60eb46Smrg _G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:} 2102f60eb46Smrg for _G_dir in $_G_PATH; do 2112f60eb46Smrg IFS=$_G_save_IFS 2122f60eb46Smrg test -z "$_G_dir" && _G_dir=. 2132f60eb46Smrg for _G_prog_name in $_G_progs_list; do 2142f60eb46Smrg for _exeext in '' .EXE; do 2152f60eb46Smrg _G_path_prog=$_G_dir/$_G_prog_name$_exeext 2162f60eb46Smrg func_executable_p "$_G_path_prog" || continue 2172f60eb46Smrg case `"$_G_path_prog" --version 2>&1` in 2182f60eb46Smrg *GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;; 2192f60eb46Smrg *) $_G_check_func $_G_path_prog 2202f60eb46Smrg func_path_progs_result=$func_check_prog_result 2212f60eb46Smrg ;; 2222f60eb46Smrg esac 2232f60eb46Smrg $_G_path_prog_found && break 3 2242f60eb46Smrg done 2252f60eb46Smrg done 2262f60eb46Smrg done 2272f60eb46Smrg IFS=$_G_save_IFS 2282f60eb46Smrg test -z "$func_path_progs_result" && { 2292f60eb46Smrg echo "no acceptable sed could be found in \$PATH" >&2 2302f60eb46Smrg exit 1 2312f60eb46Smrg } 2322f60eb46Smrg} 2332f60eb46Smrg 2342f60eb46Smrg 2352f60eb46Smrg# We want to be able to use the functions in this file before configure 2362f60eb46Smrg# has figured out where the best binaries are kept, which means we have 2372f60eb46Smrg# to search for them ourselves - except when the results are already set 2382f60eb46Smrg# where we skip the searches. 2392f60eb46Smrg 2402f60eb46Smrg# Unless the user overrides by setting SED, search the path for either GNU 2412f60eb46Smrg# sed, or the sed that truncates its output the least. 2422f60eb46Smrgtest -z "$SED" && { 2432f60eb46Smrg _G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ 2442f60eb46Smrg for _G_i in 1 2 3 4 5 6 7; do 2452f60eb46Smrg _G_sed_script=$_G_sed_script$nl$_G_sed_script 2462f60eb46Smrg done 2472f60eb46Smrg echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed 2482f60eb46Smrg _G_sed_script= 2492f60eb46Smrg 2502f60eb46Smrg func_check_prog_sed () 2512f60eb46Smrg { 2522f60eb46Smrg _G_path_prog=$1 2532f60eb46Smrg 2542f60eb46Smrg _G_count=0 2552f60eb46Smrg printf 0123456789 >conftest.in 2562f60eb46Smrg while : 2572f60eb46Smrg do 2582f60eb46Smrg cat conftest.in conftest.in >conftest.tmp 2592f60eb46Smrg mv conftest.tmp conftest.in 2602f60eb46Smrg cp conftest.in conftest.nl 2612f60eb46Smrg echo '' >> conftest.nl 2622f60eb46Smrg "$_G_path_prog" -f conftest.sed <conftest.nl >conftest.out 2>/dev/null || break 2632f60eb46Smrg diff conftest.out conftest.nl >/dev/null 2>&1 || break 2642f60eb46Smrg _G_count=`expr $_G_count + 1` 2652f60eb46Smrg if test "$_G_count" -gt "$_G_path_prog_max"; then 2662f60eb46Smrg # Best one so far, save it but keep looking for a better one 2672f60eb46Smrg func_check_prog_result=$_G_path_prog 2682f60eb46Smrg _G_path_prog_max=$_G_count 2692f60eb46Smrg fi 2702f60eb46Smrg # 10*(2^10) chars as input seems more than enough 2712f60eb46Smrg test 10 -lt "$_G_count" && break 2722f60eb46Smrg done 2732f60eb46Smrg rm -f conftest.in conftest.tmp conftest.nl conftest.out 2742f60eb46Smrg } 2752f60eb46Smrg 276efb46889Smrg func_path_progs "sed gsed" func_check_prog_sed "$PATH:/usr/xpg4/bin" 2772f60eb46Smrg rm -f conftest.sed 2782f60eb46Smrg SED=$func_path_progs_result 2792f60eb46Smrg} 2802f60eb46Smrg 2812f60eb46Smrg 2822f60eb46Smrg# Unless the user overrides by setting GREP, search the path for either GNU 2832f60eb46Smrg# grep, or the grep that truncates its output the least. 2842f60eb46Smrgtest -z "$GREP" && { 2852f60eb46Smrg func_check_prog_grep () 2862f60eb46Smrg { 2872f60eb46Smrg _G_path_prog=$1 2882f60eb46Smrg 2892f60eb46Smrg _G_count=0 2902f60eb46Smrg _G_path_prog_max=0 2912f60eb46Smrg printf 0123456789 >conftest.in 2922f60eb46Smrg while : 2932f60eb46Smrg do 2942f60eb46Smrg cat conftest.in conftest.in >conftest.tmp 2952f60eb46Smrg mv conftest.tmp conftest.in 2962f60eb46Smrg cp conftest.in conftest.nl 2972f60eb46Smrg echo 'GREP' >> conftest.nl 2982f60eb46Smrg "$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' <conftest.nl >conftest.out 2>/dev/null || break 2992f60eb46Smrg diff conftest.out conftest.nl >/dev/null 2>&1 || break 3002f60eb46Smrg _G_count=`expr $_G_count + 1` 3012f60eb46Smrg if test "$_G_count" -gt "$_G_path_prog_max"; then 3022f60eb46Smrg # Best one so far, save it but keep looking for a better one 3032f60eb46Smrg func_check_prog_result=$_G_path_prog 3042f60eb46Smrg _G_path_prog_max=$_G_count 3052f60eb46Smrg fi 3062f60eb46Smrg # 10*(2^10) chars as input seems more than enough 3072f60eb46Smrg test 10 -lt "$_G_count" && break 3082f60eb46Smrg done 3092f60eb46Smrg rm -f conftest.in conftest.tmp conftest.nl conftest.out 3102f60eb46Smrg } 3112f60eb46Smrg 312efb46889Smrg func_path_progs "grep ggrep" func_check_prog_grep "$PATH:/usr/xpg4/bin" 3132f60eb46Smrg GREP=$func_path_progs_result 3142f60eb46Smrg} 3152f60eb46Smrg 3162f60eb46Smrg 3172f60eb46Smrg## ------------------------------- ## 3182f60eb46Smrg## User overridable command paths. ## 3192f60eb46Smrg## ------------------------------- ## 3202f60eb46Smrg 3212f60eb46Smrg# All uppercase variable names are used for environment variables. These 3222f60eb46Smrg# variables can be overridden by the user before calling a script that 3232f60eb46Smrg# uses them if a suitable command of that name is not already available 3242f60eb46Smrg# in the command search PATH. 325c3c9db83Smrg 326c3c9db83Smrg: ${CP="cp -f"} 3272f60eb46Smrg: ${ECHO="printf %s\n"} 3282f60eb46Smrg: ${EGREP="$GREP -E"} 3292f60eb46Smrg: ${FGREP="$GREP -F"} 3302f60eb46Smrg: ${LN_S="ln -s"} 331c3c9db83Smrg: ${MAKE="make"} 332c3c9db83Smrg: ${MKDIR="mkdir"} 333c3c9db83Smrg: ${MV="mv -f"} 334c3c9db83Smrg: ${RM="rm -f"} 335c3c9db83Smrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"} 336692f60a7Smrg 337c3c9db83Smrg 3382f60eb46Smrg## -------------------- ## 3392f60eb46Smrg## Useful sed snippets. ## 3402f60eb46Smrg## -------------------- ## 3413f6d0e1dSmrg 3422f60eb46Smrgsed_dirname='s|/[^/]*$||' 3432f60eb46Smrgsed_basename='s|^.*/||' 3443f6d0e1dSmrg 3452f60eb46Smrg# Sed substitution that helps us do robust quoting. It backslashifies 3462f60eb46Smrg# metacharacters that are still active within double-quoted strings. 3472f60eb46Smrgsed_quote_subst='s|\([`"$\\]\)|\\\1|g' 3483f6d0e1dSmrg 3492f60eb46Smrg# Same as above, but do not quote variable references. 3502f60eb46Smrgsed_double_quote_subst='s/\(["`\\]\)/\\\1/g' 3513f6d0e1dSmrg 3522f60eb46Smrg# Sed substitution that turns a string into a regex matching for the 3532f60eb46Smrg# string literally. 3542f60eb46Smrgsed_make_literal_regex='s|[].[^$\\*\/]|\\&|g' 3553f6d0e1dSmrg 3562f60eb46Smrg# Sed substitution that converts a w32 file name or path 3572f60eb46Smrg# that contains forward slashes, into one that contains 3582f60eb46Smrg# (escaped) backslashes. A very naive implementation. 3592f60eb46Smrgsed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' 3602f60eb46Smrg 3612f60eb46Smrg# Re-'\' parameter expansions in output of sed_double_quote_subst that 3622f60eb46Smrg# were '\'-ed in input to the same. If an odd number of '\' preceded a 3632f60eb46Smrg# '$' in input to sed_double_quote_subst, that '$' was protected from 3642f60eb46Smrg# expansion. Since each input '\' is now two '\'s, look for any number 3652f60eb46Smrg# of runs of four '\'s followed by two '\'s and then a '$'. '\' that '$'. 3662f60eb46Smrg_G_bs='\\' 3672f60eb46Smrg_G_bs2='\\\\' 3682f60eb46Smrg_G_bs4='\\\\\\\\' 3692f60eb46Smrg_G_dollar='\$' 3702f60eb46Smrgsed_double_backslash="\ 3712f60eb46Smrg s/$_G_bs4/&\\ 3722f60eb46Smrg/g 3732f60eb46Smrg s/^$_G_bs2$_G_dollar/$_G_bs&/ 3742f60eb46Smrg s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g 3752f60eb46Smrg s/\n//g" 3763f6d0e1dSmrg 377efb46889Smrg# require_check_ifs_backslash 378efb46889Smrg# --------------------------- 379efb46889Smrg# Check if we can use backslash as IFS='\' separator, and set 380efb46889Smrg# $check_ifs_backshlash_broken to ':' or 'false'. 381efb46889Smrgrequire_check_ifs_backslash=func_require_check_ifs_backslash 382efb46889Smrgfunc_require_check_ifs_backslash () 383efb46889Smrg{ 384efb46889Smrg _G_save_IFS=$IFS 385efb46889Smrg IFS='\' 386efb46889Smrg _G_check_ifs_backshlash='a\\b' 387efb46889Smrg for _G_i in $_G_check_ifs_backshlash 388efb46889Smrg do 389efb46889Smrg case $_G_i in 390efb46889Smrg a) 391efb46889Smrg check_ifs_backshlash_broken=false 392efb46889Smrg ;; 393efb46889Smrg '') 394efb46889Smrg break 395efb46889Smrg ;; 396efb46889Smrg *) 397efb46889Smrg check_ifs_backshlash_broken=: 398efb46889Smrg break 399efb46889Smrg ;; 400efb46889Smrg esac 401efb46889Smrg done 402efb46889Smrg IFS=$_G_save_IFS 403efb46889Smrg require_check_ifs_backslash=: 404efb46889Smrg} 405efb46889Smrg 4063f6d0e1dSmrg 4072f60eb46Smrg## ----------------- ## 4082f60eb46Smrg## Global variables. ## 4092f60eb46Smrg## ----------------- ## 4103f6d0e1dSmrg 4112f60eb46Smrg# Except for the global variables explicitly listed below, the following 4122f60eb46Smrg# functions in the '^func_' namespace, and the '^require_' namespace 4132f60eb46Smrg# variables initialised in the 'Resource management' section, sourcing 4142f60eb46Smrg# this file will not pollute your global namespace with anything 4152f60eb46Smrg# else. There's no portable way to scope variables in Bourne shell 4162f60eb46Smrg# though, so actually running these functions will sometimes place 4172f60eb46Smrg# results into a variable named after the function, and often use 4182f60eb46Smrg# temporary variables in the '^_G_' namespace. If you are careful to 4192f60eb46Smrg# avoid using those namespaces casually in your sourcing script, things 4202f60eb46Smrg# should continue to work as you expect. And, of course, you can freely 4212f60eb46Smrg# overwrite any of the functions or variables defined here before 4222f60eb46Smrg# calling anything to customize them. 4233f6d0e1dSmrg 4242f60eb46SmrgEXIT_SUCCESS=0 4252f60eb46SmrgEXIT_FAILURE=1 4262f60eb46SmrgEXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. 4272f60eb46SmrgEXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. 42885ee4c00Smrg 4292f60eb46Smrg# Allow overriding, eg assuming that you follow the convention of 4302f60eb46Smrg# putting '$debug_cmd' at the start of all your functions, you can get 4312f60eb46Smrg# bash to show function call trace with: 4322f60eb46Smrg# 4332f60eb46Smrg# debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name 4342f60eb46Smrgdebug_cmd=${debug_cmd-":"} 4352f60eb46Smrgexit_cmd=: 436c3c9db83Smrg 4372f60eb46Smrg# By convention, finish your script with: 4382f60eb46Smrg# 4392f60eb46Smrg# exit $exit_status 4402f60eb46Smrg# 4412f60eb46Smrg# so that you can set exit_status to non-zero if you want to indicate 4422f60eb46Smrg# something went wrong during execution without actually bailing out at 4432f60eb46Smrg# the point of failure. 4442f60eb46Smrgexit_status=$EXIT_SUCCESS 4453f6d0e1dSmrg 4462f60eb46Smrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh 4472f60eb46Smrg# is ksh but when the shell is invoked as "sh" and the current value of 4482f60eb46Smrg# the _XPG environment variable is not equal to 1 (one), the special 4492f60eb46Smrg# positional parameter $0, within a function call, is the name of the 4502f60eb46Smrg# function. 4512f60eb46Smrgprogpath=$0 452c3c9db83Smrg 4532f60eb46Smrg# The name of this program. 4542f60eb46Smrgprogname=`$ECHO "$progpath" |$SED "$sed_basename"` 455c3c9db83Smrg 4562f60eb46Smrg# Make sure we have an absolute progpath for reexecution: 457c3c9db83Smrgcase $progpath in 458c3c9db83Smrg [\\/]*|[A-Za-z]:\\*) ;; 459c3c9db83Smrg *[\\/]*) 4602f60eb46Smrg progdir=`$ECHO "$progpath" |$SED "$sed_dirname"` 461c3c9db83Smrg progdir=`cd "$progdir" && pwd` 4622f60eb46Smrg progpath=$progdir/$progname 463c3c9db83Smrg ;; 464c3c9db83Smrg *) 4652f60eb46Smrg _G_IFS=$IFS 46695903e71Smrg IFS=${PATH_SEPARATOR-:} 467c3c9db83Smrg for progdir in $PATH; do 4682f60eb46Smrg IFS=$_G_IFS 469c3c9db83Smrg test -x "$progdir/$progname" && break 470c3c9db83Smrg done 4712f60eb46Smrg IFS=$_G_IFS 472c3c9db83Smrg test -n "$progdir" || progdir=`pwd` 4732f60eb46Smrg progpath=$progdir/$progname 474c3c9db83Smrg ;; 475c3c9db83Smrgesac 476c3c9db83Smrg 477c3c9db83Smrg 4782f60eb46Smrg## ----------------- ## 4792f60eb46Smrg## Standard options. ## 4802f60eb46Smrg## ----------------- ## 4813f6d0e1dSmrg 4822f60eb46Smrg# The following options affect the operation of the functions defined 4832f60eb46Smrg# below, and should be set appropriately depending on run-time para- 4842f60eb46Smrg# meters passed on the command line. 485c3c9db83Smrg 486c3c9db83Smrgopt_dry_run=false 487c3c9db83Smrgopt_quiet=false 488c3c9db83Smrgopt_verbose=false 489c3c9db83Smrg 4902f60eb46Smrg# Categories 'all' and 'none' are always available. Append any others 4912f60eb46Smrg# you will pass as the first argument to func_warning from your own 4922f60eb46Smrg# code. 4932f60eb46Smrgwarning_categories= 494c3c9db83Smrg 4952f60eb46Smrg# By default, display warnings according to 'opt_warning_types'. Set 4962f60eb46Smrg# 'warning_func' to ':' to elide all warnings, or func_fatal_error to 4972f60eb46Smrg# treat the next displayed warning as a fatal error. 4982f60eb46Smrgwarning_func=func_warn_and_continue 499c3c9db83Smrg 5002f60eb46Smrg# Set to 'all' to display all warnings, 'none' to suppress all 5012f60eb46Smrg# warnings, or a space delimited list of some subset of 5022f60eb46Smrg# 'warning_categories' to display only the listed warnings. 5032f60eb46Smrgopt_warning_types=all 504c3c9db83Smrg 5053f6d0e1dSmrg 5062f60eb46Smrg## -------------------- ## 5072f60eb46Smrg## Resource management. ## 5082f60eb46Smrg## -------------------- ## 509c3c9db83Smrg 5102f60eb46Smrg# This section contains definitions for functions that each ensure a 5112f60eb46Smrg# particular resource (a file, or a non-empty configuration variable for 5122f60eb46Smrg# example) is available, and if appropriate to extract default values 5132f60eb46Smrg# from pertinent package files. Call them using their associated 5142f60eb46Smrg# 'require_*' variable to ensure that they are executed, at most, once. 5152f60eb46Smrg# 5162f60eb46Smrg# It's entirely deliberate that calling these functions can set 5172f60eb46Smrg# variables that don't obey the namespace limitations obeyed by the rest 5182f60eb46Smrg# of this file, in order that that they be as useful as possible to 5192f60eb46Smrg# callers. 520c3c9db83Smrg 521c3c9db83Smrg 5222f60eb46Smrg# require_term_colors 5232f60eb46Smrg# ------------------- 5242f60eb46Smrg# Allow display of bold text on terminals that support it. 5252f60eb46Smrgrequire_term_colors=func_require_term_colors 5262f60eb46Smrgfunc_require_term_colors () 527c3c9db83Smrg{ 5282f60eb46Smrg $debug_cmd 5292f60eb46Smrg 5302f60eb46Smrg test -t 1 && { 5312f60eb46Smrg # COLORTERM and USE_ANSI_COLORS environment variables take 5322f60eb46Smrg # precedence, because most terminfo databases neglect to describe 5332f60eb46Smrg # whether color sequences are supported. 5342f60eb46Smrg test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"} 5352f60eb46Smrg 5362f60eb46Smrg if test 1 = "$USE_ANSI_COLORS"; then 5372f60eb46Smrg # Standard ANSI escape sequences 5382f60eb46Smrg tc_reset='[0m' 5392f60eb46Smrg tc_bold='[1m'; tc_standout='[7m' 5402f60eb46Smrg tc_red='[31m'; tc_green='[32m' 5412f60eb46Smrg tc_blue='[34m'; tc_cyan='[36m' 5422f60eb46Smrg else 5432f60eb46Smrg # Otherwise trust the terminfo database after all. 5442f60eb46Smrg test -n "`tput sgr0 2>/dev/null`" && { 5452f60eb46Smrg tc_reset=`tput sgr0` 5462f60eb46Smrg test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold` 5472f60eb46Smrg tc_standout=$tc_bold 5482f60eb46Smrg test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso` 5492f60eb46Smrg test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1` 5502f60eb46Smrg test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2` 5512f60eb46Smrg test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4` 5522f60eb46Smrg test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5` 5532f60eb46Smrg } 5542f60eb46Smrg fi 5552f60eb46Smrg } 556c3c9db83Smrg 5572f60eb46Smrg require_term_colors=: 558c3c9db83Smrg} 559c3c9db83Smrg 560c3c9db83Smrg 5612f60eb46Smrg## ----------------- ## 5622f60eb46Smrg## Function library. ## 5632f60eb46Smrg## ----------------- ## 5642f60eb46Smrg 5652f60eb46Smrg# This section contains a variety of useful functions to call in your 5662f60eb46Smrg# scripts. Take note of the portable wrappers for features provided by 5672f60eb46Smrg# some modern shells, which will fall back to slower equivalents on 5682f60eb46Smrg# less featureful shells. 5692f60eb46Smrg 5702f60eb46Smrg 5712f60eb46Smrg# func_append VAR VALUE 5722f60eb46Smrg# --------------------- 5732f60eb46Smrg# Append VALUE onto the existing contents of VAR. 5742f60eb46Smrg 5752f60eb46Smrg # We should try to minimise forks, especially on Windows where they are 5762f60eb46Smrg # unreasonably slow, so skip the feature probes when bash or zsh are 5772f60eb46Smrg # being used: 5782f60eb46Smrg if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then 5792f60eb46Smrg : ${_G_HAVE_ARITH_OP="yes"} 5802f60eb46Smrg : ${_G_HAVE_XSI_OPS="yes"} 5812f60eb46Smrg # The += operator was introduced in bash 3.1 5822f60eb46Smrg case $BASH_VERSION in 5832f60eb46Smrg [12].* | 3.0 | 3.0*) ;; 5842f60eb46Smrg *) 5852f60eb46Smrg : ${_G_HAVE_PLUSEQ_OP="yes"} 5862f60eb46Smrg ;; 5872f60eb46Smrg esac 5882f60eb46Smrg fi 5892f60eb46Smrg 5902f60eb46Smrg # _G_HAVE_PLUSEQ_OP 5912f60eb46Smrg # Can be empty, in which case the shell is probed, "yes" if += is 5922f60eb46Smrg # useable or anything else if it does not work. 5932f60eb46Smrg test -z "$_G_HAVE_PLUSEQ_OP" \ 5942f60eb46Smrg && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \ 5952f60eb46Smrg && _G_HAVE_PLUSEQ_OP=yes 5962f60eb46Smrg 5972f60eb46Smrgif test yes = "$_G_HAVE_PLUSEQ_OP" 5982f60eb46Smrgthen 5992f60eb46Smrg # This is an XSI compatible shell, allowing a faster implementation... 6002f60eb46Smrg eval 'func_append () 6012f60eb46Smrg { 6022f60eb46Smrg $debug_cmd 6032f60eb46Smrg 6042f60eb46Smrg eval "$1+=\$2" 6052f60eb46Smrg }' 6062f60eb46Smrgelse 6072f60eb46Smrg # ...otherwise fall back to using expr, which is often a shell builtin. 6082f60eb46Smrg func_append () 6092f60eb46Smrg { 6102f60eb46Smrg $debug_cmd 6112f60eb46Smrg 6122f60eb46Smrg eval "$1=\$$1\$2" 6132f60eb46Smrg } 6142f60eb46Smrgfi 6152f60eb46Smrg 6162f60eb46Smrg 6172f60eb46Smrg# func_append_quoted VAR VALUE 6182f60eb46Smrg# ---------------------------- 6192f60eb46Smrg# Quote VALUE and append to the end of shell variable VAR, separated 6202f60eb46Smrg# by a space. 6212f60eb46Smrgif test yes = "$_G_HAVE_PLUSEQ_OP"; then 6222f60eb46Smrg eval 'func_append_quoted () 6232f60eb46Smrg { 6242f60eb46Smrg $debug_cmd 6252f60eb46Smrg 626efb46889Smrg func_quote_arg pretty "$2" 627efb46889Smrg eval "$1+=\\ \$func_quote_arg_result" 6282f60eb46Smrg }' 6292f60eb46Smrgelse 6302f60eb46Smrg func_append_quoted () 6312f60eb46Smrg { 6322f60eb46Smrg $debug_cmd 6332f60eb46Smrg 634efb46889Smrg func_quote_arg pretty "$2" 635efb46889Smrg eval "$1=\$$1\\ \$func_quote_arg_result" 6362f60eb46Smrg } 6372f60eb46Smrgfi 6382f60eb46Smrg 6392f60eb46Smrg 6402f60eb46Smrg# func_append_uniq VAR VALUE 6412f60eb46Smrg# -------------------------- 6422f60eb46Smrg# Append unique VALUE onto the existing contents of VAR, assuming 6432f60eb46Smrg# entries are delimited by the first character of VALUE. For example: 6442f60eb46Smrg# 6452f60eb46Smrg# func_append_uniq options " --another-option option-argument" 6462f60eb46Smrg# 6472f60eb46Smrg# will only append to $options if " --another-option option-argument " 6482f60eb46Smrg# is not already present somewhere in $options already (note spaces at 6492f60eb46Smrg# each end implied by leading space in second argument). 6502f60eb46Smrgfunc_append_uniq () 6512f60eb46Smrg{ 6522f60eb46Smrg $debug_cmd 6532f60eb46Smrg 6542f60eb46Smrg eval _G_current_value='`$ECHO $'$1'`' 6552f60eb46Smrg _G_delim=`expr "$2" : '\(.\)'` 6562f60eb46Smrg 6572f60eb46Smrg case $_G_delim$_G_current_value$_G_delim in 6582f60eb46Smrg *"$2$_G_delim"*) ;; 6592f60eb46Smrg *) func_append "$@" ;; 6602f60eb46Smrg esac 6612f60eb46Smrg} 6622f60eb46Smrg 6632f60eb46Smrg 6642f60eb46Smrg# func_arith TERM... 6652f60eb46Smrg# ------------------ 6662f60eb46Smrg# Set func_arith_result to the result of evaluating TERMs. 6672f60eb46Smrg test -z "$_G_HAVE_ARITH_OP" \ 6682f60eb46Smrg && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \ 6692f60eb46Smrg && _G_HAVE_ARITH_OP=yes 6702f60eb46Smrg 6712f60eb46Smrgif test yes = "$_G_HAVE_ARITH_OP"; then 6722f60eb46Smrg eval 'func_arith () 6732f60eb46Smrg { 6742f60eb46Smrg $debug_cmd 6752f60eb46Smrg 6762f60eb46Smrg func_arith_result=$(( $* )) 6772f60eb46Smrg }' 6782f60eb46Smrgelse 6792f60eb46Smrg func_arith () 6802f60eb46Smrg { 6812f60eb46Smrg $debug_cmd 6822f60eb46Smrg 6832f60eb46Smrg func_arith_result=`expr "$@"` 6842f60eb46Smrg } 6852f60eb46Smrgfi 6862f60eb46Smrg 6872f60eb46Smrg 6882f60eb46Smrg# func_basename FILE 6892f60eb46Smrg# ------------------ 6902f60eb46Smrg# Set func_basename_result to FILE with everything up to and including 6912f60eb46Smrg# the last / stripped. 6922f60eb46Smrgif test yes = "$_G_HAVE_XSI_OPS"; then 6932f60eb46Smrg # If this shell supports suffix pattern removal, then use it to avoid 6942f60eb46Smrg # forking. Hide the definitions single quotes in case the shell chokes 6952f60eb46Smrg # on unsupported syntax... 6962f60eb46Smrg _b='func_basename_result=${1##*/}' 6972f60eb46Smrg _d='case $1 in 6982f60eb46Smrg */*) func_dirname_result=${1%/*}$2 ;; 6992f60eb46Smrg * ) func_dirname_result=$3 ;; 7002f60eb46Smrg esac' 7012f60eb46Smrg 7022f60eb46Smrgelse 7032f60eb46Smrg # ...otherwise fall back to using sed. 7042f60eb46Smrg _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`' 7052f60eb46Smrg _d='func_dirname_result=`$ECHO "$1" |$SED "$sed_dirname"` 7062f60eb46Smrg if test "X$func_dirname_result" = "X$1"; then 7072f60eb46Smrg func_dirname_result=$3 7082f60eb46Smrg else 7092f60eb46Smrg func_append func_dirname_result "$2" 7102f60eb46Smrg fi' 7112f60eb46Smrgfi 7122f60eb46Smrg 7132f60eb46Smrgeval 'func_basename () 7142f60eb46Smrg{ 7152f60eb46Smrg $debug_cmd 7162f60eb46Smrg 7172f60eb46Smrg '"$_b"' 7182f60eb46Smrg}' 7192f60eb46Smrg 7202f60eb46Smrg 7212f60eb46Smrg# func_dirname FILE APPEND NONDIR_REPLACEMENT 7222f60eb46Smrg# ------------------------------------------- 7232f60eb46Smrg# Compute the dirname of FILE. If nonempty, add APPEND to the result, 7242f60eb46Smrg# otherwise set result to NONDIR_REPLACEMENT. 7252f60eb46Smrgeval 'func_dirname () 7262f60eb46Smrg{ 7272f60eb46Smrg $debug_cmd 7282f60eb46Smrg 7292f60eb46Smrg '"$_d"' 7302f60eb46Smrg}' 7312f60eb46Smrg 7322f60eb46Smrg 7332f60eb46Smrg# func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT 7342f60eb46Smrg# -------------------------------------------------------- 7352f60eb46Smrg# Perform func_basename and func_dirname in a single function 7362f60eb46Smrg# call: 7372f60eb46Smrg# dirname: Compute the dirname of FILE. If nonempty, 7382f60eb46Smrg# add APPEND to the result, otherwise set result 7392f60eb46Smrg# to NONDIR_REPLACEMENT. 7402f60eb46Smrg# value returned in "$func_dirname_result" 7412f60eb46Smrg# basename: Compute filename of FILE. 7422f60eb46Smrg# value retuned in "$func_basename_result" 7432f60eb46Smrg# For efficiency, we do not delegate to the functions above but instead 7442f60eb46Smrg# duplicate the functionality here. 7452f60eb46Smrgeval 'func_dirname_and_basename () 7462f60eb46Smrg{ 7472f60eb46Smrg $debug_cmd 7482f60eb46Smrg 7492f60eb46Smrg '"$_b"' 7502f60eb46Smrg '"$_d"' 7512f60eb46Smrg}' 7522f60eb46Smrg 7532f60eb46Smrg 7542f60eb46Smrg# func_echo ARG... 7552f60eb46Smrg# ---------------- 7562f60eb46Smrg# Echo program name prefixed message. 7572f60eb46Smrgfunc_echo () 7582f60eb46Smrg{ 7592f60eb46Smrg $debug_cmd 7602f60eb46Smrg 7612f60eb46Smrg _G_message=$* 7622f60eb46Smrg 7632f60eb46Smrg func_echo_IFS=$IFS 7642f60eb46Smrg IFS=$nl 7652f60eb46Smrg for _G_line in $_G_message; do 7662f60eb46Smrg IFS=$func_echo_IFS 7672f60eb46Smrg $ECHO "$progname: $_G_line" 7682f60eb46Smrg done 7692f60eb46Smrg IFS=$func_echo_IFS 7702f60eb46Smrg} 7712f60eb46Smrg 7722f60eb46Smrg 7732f60eb46Smrg# func_echo_all ARG... 7742f60eb46Smrg# -------------------- 7752f60eb46Smrg# Invoke $ECHO with all args, space-separated. 7762f60eb46Smrgfunc_echo_all () 7772f60eb46Smrg{ 7782f60eb46Smrg $ECHO "$*" 7792f60eb46Smrg} 7802f60eb46Smrg 7812f60eb46Smrg 7822f60eb46Smrg# func_echo_infix_1 INFIX ARG... 7832f60eb46Smrg# ------------------------------ 7842f60eb46Smrg# Echo program name, followed by INFIX on the first line, with any 7852f60eb46Smrg# additional lines not showing INFIX. 7862f60eb46Smrgfunc_echo_infix_1 () 7872f60eb46Smrg{ 7882f60eb46Smrg $debug_cmd 7892f60eb46Smrg 7902f60eb46Smrg $require_term_colors 7912f60eb46Smrg 7922f60eb46Smrg _G_infix=$1; shift 7932f60eb46Smrg _G_indent=$_G_infix 7942f60eb46Smrg _G_prefix="$progname: $_G_infix: " 7952f60eb46Smrg _G_message=$* 7962f60eb46Smrg 7972f60eb46Smrg # Strip color escape sequences before counting printable length 7982f60eb46Smrg for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan" 7992f60eb46Smrg do 8002f60eb46Smrg test -n "$_G_tc" && { 8012f60eb46Smrg _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"` 8022f60eb46Smrg _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"` 8032f60eb46Smrg } 8042f60eb46Smrg done 8052f60eb46Smrg _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`" " ## exclude from sc_prohibit_nested_quotes 8062f60eb46Smrg 8072f60eb46Smrg func_echo_infix_1_IFS=$IFS 8082f60eb46Smrg IFS=$nl 8092f60eb46Smrg for _G_line in $_G_message; do 8102f60eb46Smrg IFS=$func_echo_infix_1_IFS 8112f60eb46Smrg $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2 8122f60eb46Smrg _G_prefix=$_G_indent 8132f60eb46Smrg done 8142f60eb46Smrg IFS=$func_echo_infix_1_IFS 8152f60eb46Smrg} 8162f60eb46Smrg 8172f60eb46Smrg 8182f60eb46Smrg# func_error ARG... 8192f60eb46Smrg# ----------------- 8202f60eb46Smrg# Echo program name prefixed message to standard error. 8212f60eb46Smrgfunc_error () 8222f60eb46Smrg{ 8232f60eb46Smrg $debug_cmd 8242f60eb46Smrg 8252f60eb46Smrg $require_term_colors 8262f60eb46Smrg 8272f60eb46Smrg func_echo_infix_1 " $tc_standout${tc_red}error$tc_reset" "$*" >&2 8282f60eb46Smrg} 8292f60eb46Smrg 8302f60eb46Smrg 8312f60eb46Smrg# func_fatal_error ARG... 8322f60eb46Smrg# ----------------------- 8332f60eb46Smrg# Echo program name prefixed message to standard error, and exit. 8342f60eb46Smrgfunc_fatal_error () 8352f60eb46Smrg{ 8362f60eb46Smrg $debug_cmd 8372f60eb46Smrg 8382f60eb46Smrg func_error "$*" 8392f60eb46Smrg exit $EXIT_FAILURE 8402f60eb46Smrg} 8412f60eb46Smrg 8422f60eb46Smrg 8432f60eb46Smrg# func_grep EXPRESSION FILENAME 8442f60eb46Smrg# ----------------------------- 845c3c9db83Smrg# Check whether EXPRESSION matches any line of FILENAME, without output. 846c3c9db83Smrgfunc_grep () 847c3c9db83Smrg{ 8482f60eb46Smrg $debug_cmd 8492f60eb46Smrg 850c3c9db83Smrg $GREP "$1" "$2" >/dev/null 2>&1 851c3c9db83Smrg} 852c3c9db83Smrg 853c3c9db83Smrg 8542f60eb46Smrg# func_len STRING 8552f60eb46Smrg# --------------- 8562f60eb46Smrg# Set func_len_result to the length of STRING. STRING may not 8572f60eb46Smrg# start with a hyphen. 8582f60eb46Smrg test -z "$_G_HAVE_XSI_OPS" \ 8592f60eb46Smrg && (eval 'x=a/b/c; 8602f60eb46Smrg test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ 8612f60eb46Smrg && _G_HAVE_XSI_OPS=yes 8622f60eb46Smrg 8632f60eb46Smrgif test yes = "$_G_HAVE_XSI_OPS"; then 8642f60eb46Smrg eval 'func_len () 8652f60eb46Smrg { 8662f60eb46Smrg $debug_cmd 8672f60eb46Smrg 8682f60eb46Smrg func_len_result=${#1} 8692f60eb46Smrg }' 8702f60eb46Smrgelse 8712f60eb46Smrg func_len () 8722f60eb46Smrg { 8732f60eb46Smrg $debug_cmd 8742f60eb46Smrg 8752f60eb46Smrg func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len` 8762f60eb46Smrg } 8772f60eb46Smrgfi 8782f60eb46Smrg 8792f60eb46Smrg 8802f60eb46Smrg# func_mkdir_p DIRECTORY-PATH 8812f60eb46Smrg# --------------------------- 882c3c9db83Smrg# Make sure the entire path to DIRECTORY-PATH is available. 883c3c9db83Smrgfunc_mkdir_p () 884c3c9db83Smrg{ 8852f60eb46Smrg $debug_cmd 886c3c9db83Smrg 8872f60eb46Smrg _G_directory_path=$1 8882f60eb46Smrg _G_dir_list= 889c3c9db83Smrg 8902f60eb46Smrg if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then 8912f60eb46Smrg 8922f60eb46Smrg # Protect directory names starting with '-' 8932f60eb46Smrg case $_G_directory_path in 8942f60eb46Smrg -*) _G_directory_path=./$_G_directory_path ;; 895c3c9db83Smrg esac 896c3c9db83Smrg 897c3c9db83Smrg # While some portion of DIR does not yet exist... 8982f60eb46Smrg while test ! -d "$_G_directory_path"; do 899c3c9db83Smrg # ...make a list in topmost first order. Use a colon delimited 900c3c9db83Smrg # list incase some portion of path contains whitespace. 9012f60eb46Smrg _G_dir_list=$_G_directory_path:$_G_dir_list 902c3c9db83Smrg 903c3c9db83Smrg # If the last portion added has no slash in it, the list is done 9042f60eb46Smrg case $_G_directory_path in */*) ;; *) break ;; esac 905c3c9db83Smrg 906c3c9db83Smrg # ...otherwise throw away the child directory and loop 9072f60eb46Smrg _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"` 908c3c9db83Smrg done 9092f60eb46Smrg _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'` 910c3c9db83Smrg 9112f60eb46Smrg func_mkdir_p_IFS=$IFS; IFS=: 9122f60eb46Smrg for _G_dir in $_G_dir_list; do 9132f60eb46Smrg IFS=$func_mkdir_p_IFS 9142f60eb46Smrg # mkdir can fail with a 'File exist' error if two processes 915c3c9db83Smrg # try to create one of the directories concurrently. Don't 916c3c9db83Smrg # stop in that case! 9172f60eb46Smrg $MKDIR "$_G_dir" 2>/dev/null || : 918c3c9db83Smrg done 9192f60eb46Smrg IFS=$func_mkdir_p_IFS 920c3c9db83Smrg 921c3c9db83Smrg # Bail out if we (or some other process) failed to create a directory. 9222f60eb46Smrg test -d "$_G_directory_path" || \ 9232f60eb46Smrg func_fatal_error "Failed to create '$1'" 924c3c9db83Smrg fi 925c3c9db83Smrg} 926692f60a7Smrg 927692f60a7Smrg 9282f60eb46Smrg# func_mktempdir [BASENAME] 9292f60eb46Smrg# ------------------------- 930692f60a7Smrg# Make a temporary directory that won't clash with other running 931692f60a7Smrg# libtool processes, and avoids race conditions if possible. If 9322f60eb46Smrg# given, BASENAME is the basename for that directory. 933692f60a7Smrgfunc_mktempdir () 934692f60a7Smrg{ 9352f60eb46Smrg $debug_cmd 9362f60eb46Smrg 9372f60eb46Smrg _G_template=${TMPDIR-/tmp}/${1-$progname} 938692f60a7Smrg 9392f60eb46Smrg if test : = "$opt_dry_run"; then 940692f60a7Smrg # Return a directory name, but don't create it in dry-run mode 9412f60eb46Smrg _G_tmpdir=$_G_template-$$ 942692f60a7Smrg else 943692f60a7Smrg 944692f60a7Smrg # If mktemp works, use that first and foremost 9452f60eb46Smrg _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null` 946692f60a7Smrg 9472f60eb46Smrg if test ! -d "$_G_tmpdir"; then 948c3c9db83Smrg # Failing that, at least try and use $RANDOM to avoid a race 9492f60eb46Smrg _G_tmpdir=$_G_template-${RANDOM-0}$$ 950692f60a7Smrg 9512f60eb46Smrg func_mktempdir_umask=`umask` 952c3c9db83Smrg umask 0077 9532f60eb46Smrg $MKDIR "$_G_tmpdir" 9542f60eb46Smrg umask $func_mktempdir_umask 955692f60a7Smrg fi 956692f60a7Smrg 957692f60a7Smrg # If we're not in dry-run mode, bomb out on failure 9582f60eb46Smrg test -d "$_G_tmpdir" || \ 9592f60eb46Smrg func_fatal_error "cannot create temporary directory '$_G_tmpdir'" 9602f60eb46Smrg fi 9612f60eb46Smrg 9622f60eb46Smrg $ECHO "$_G_tmpdir" 9632f60eb46Smrg} 9642f60eb46Smrg 9652f60eb46Smrg 9662f60eb46Smrg# func_normal_abspath PATH 9672f60eb46Smrg# ------------------------ 9682f60eb46Smrg# Remove doubled-up and trailing slashes, "." path components, 9692f60eb46Smrg# and cancel out any ".." path components in PATH after making 9702f60eb46Smrg# it an absolute path. 9712f60eb46Smrgfunc_normal_abspath () 9722f60eb46Smrg{ 9732f60eb46Smrg $debug_cmd 9742f60eb46Smrg 9752f60eb46Smrg # These SED scripts presuppose an absolute path with a trailing slash. 9762f60eb46Smrg _G_pathcar='s|^/\([^/]*\).*$|\1|' 9772f60eb46Smrg _G_pathcdr='s|^/[^/]*||' 9782f60eb46Smrg _G_removedotparts=':dotsl 9792f60eb46Smrg s|/\./|/|g 9802f60eb46Smrg t dotsl 9812f60eb46Smrg s|/\.$|/|' 9822f60eb46Smrg _G_collapseslashes='s|/\{1,\}|/|g' 9832f60eb46Smrg _G_finalslash='s|/*$|/|' 9842f60eb46Smrg 9852f60eb46Smrg # Start from root dir and reassemble the path. 9862f60eb46Smrg func_normal_abspath_result= 9872f60eb46Smrg func_normal_abspath_tpath=$1 9882f60eb46Smrg func_normal_abspath_altnamespace= 9892f60eb46Smrg case $func_normal_abspath_tpath in 9902f60eb46Smrg "") 9912f60eb46Smrg # Empty path, that just means $cwd. 9922f60eb46Smrg func_stripname '' '/' "`pwd`" 9932f60eb46Smrg func_normal_abspath_result=$func_stripname_result 9942f60eb46Smrg return 9952f60eb46Smrg ;; 9962f60eb46Smrg # The next three entries are used to spot a run of precisely 9972f60eb46Smrg # two leading slashes without using negated character classes; 9982f60eb46Smrg # we take advantage of case's first-match behaviour. 9992f60eb46Smrg ///*) 10002f60eb46Smrg # Unusual form of absolute path, do nothing. 10012f60eb46Smrg ;; 10022f60eb46Smrg //*) 10032f60eb46Smrg # Not necessarily an ordinary path; POSIX reserves leading '//' 10042f60eb46Smrg # and for example Cygwin uses it to access remote file shares 10052f60eb46Smrg # over CIFS/SMB, so we conserve a leading double slash if found. 10062f60eb46Smrg func_normal_abspath_altnamespace=/ 10072f60eb46Smrg ;; 10082f60eb46Smrg /*) 10092f60eb46Smrg # Absolute path, do nothing. 10102f60eb46Smrg ;; 10112f60eb46Smrg *) 10122f60eb46Smrg # Relative path, prepend $cwd. 10132f60eb46Smrg func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath 10142f60eb46Smrg ;; 10152f60eb46Smrg esac 10162f60eb46Smrg 10172f60eb46Smrg # Cancel out all the simple stuff to save iterations. We also want 10182f60eb46Smrg # the path to end with a slash for ease of parsing, so make sure 10192f60eb46Smrg # there is one (and only one) here. 10202f60eb46Smrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 10212f60eb46Smrg -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"` 10222f60eb46Smrg while :; do 10232f60eb46Smrg # Processed it all yet? 10242f60eb46Smrg if test / = "$func_normal_abspath_tpath"; then 10252f60eb46Smrg # If we ascended to the root using ".." the result may be empty now. 10262f60eb46Smrg if test -z "$func_normal_abspath_result"; then 10272f60eb46Smrg func_normal_abspath_result=/ 10282f60eb46Smrg fi 10292f60eb46Smrg break 10302f60eb46Smrg fi 10312f60eb46Smrg func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ 10322f60eb46Smrg -e "$_G_pathcar"` 10332f60eb46Smrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 10342f60eb46Smrg -e "$_G_pathcdr"` 10352f60eb46Smrg # Figure out what to do with it 10362f60eb46Smrg case $func_normal_abspath_tcomponent in 10372f60eb46Smrg "") 10382f60eb46Smrg # Trailing empty path component, ignore it. 10392f60eb46Smrg ;; 10402f60eb46Smrg ..) 10412f60eb46Smrg # Parent dir; strip last assembled component from result. 10422f60eb46Smrg func_dirname "$func_normal_abspath_result" 10432f60eb46Smrg func_normal_abspath_result=$func_dirname_result 10442f60eb46Smrg ;; 10452f60eb46Smrg *) 10462f60eb46Smrg # Actual path component, append it. 10472f60eb46Smrg func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent" 10482f60eb46Smrg ;; 10492f60eb46Smrg esac 10502f60eb46Smrg done 10512f60eb46Smrg # Restore leading double-slash if one was found on entry. 10522f60eb46Smrg func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result 10532f60eb46Smrg} 10542f60eb46Smrg 10552f60eb46Smrg 10562f60eb46Smrg# func_notquiet ARG... 10572f60eb46Smrg# -------------------- 10582f60eb46Smrg# Echo program name prefixed message only when not in quiet mode. 10592f60eb46Smrgfunc_notquiet () 10602f60eb46Smrg{ 10612f60eb46Smrg $debug_cmd 10622f60eb46Smrg 10632f60eb46Smrg $opt_quiet || func_echo ${1+"$@"} 10642f60eb46Smrg 10652f60eb46Smrg # A bug in bash halts the script if the last line of a function 10662f60eb46Smrg # fails when set -e is in force, so we need another command to 10672f60eb46Smrg # work around that: 10682f60eb46Smrg : 10692f60eb46Smrg} 10702f60eb46Smrg 10712f60eb46Smrg 10722f60eb46Smrg# func_relative_path SRCDIR DSTDIR 10732f60eb46Smrg# -------------------------------- 10742f60eb46Smrg# Set func_relative_path_result to the relative path from SRCDIR to DSTDIR. 10752f60eb46Smrgfunc_relative_path () 10762f60eb46Smrg{ 10772f60eb46Smrg $debug_cmd 10782f60eb46Smrg 10792f60eb46Smrg func_relative_path_result= 10802f60eb46Smrg func_normal_abspath "$1" 10812f60eb46Smrg func_relative_path_tlibdir=$func_normal_abspath_result 10822f60eb46Smrg func_normal_abspath "$2" 10832f60eb46Smrg func_relative_path_tbindir=$func_normal_abspath_result 10842f60eb46Smrg 10852f60eb46Smrg # Ascend the tree starting from libdir 10862f60eb46Smrg while :; do 10872f60eb46Smrg # check if we have found a prefix of bindir 10882f60eb46Smrg case $func_relative_path_tbindir in 10892f60eb46Smrg $func_relative_path_tlibdir) 10902f60eb46Smrg # found an exact match 10912f60eb46Smrg func_relative_path_tcancelled= 10922f60eb46Smrg break 10932f60eb46Smrg ;; 10942f60eb46Smrg $func_relative_path_tlibdir*) 10952f60eb46Smrg # found a matching prefix 10962f60eb46Smrg func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" 10972f60eb46Smrg func_relative_path_tcancelled=$func_stripname_result 10982f60eb46Smrg if test -z "$func_relative_path_result"; then 10992f60eb46Smrg func_relative_path_result=. 11002f60eb46Smrg fi 11012f60eb46Smrg break 11022f60eb46Smrg ;; 11032f60eb46Smrg *) 11042f60eb46Smrg func_dirname $func_relative_path_tlibdir 11052f60eb46Smrg func_relative_path_tlibdir=$func_dirname_result 11062f60eb46Smrg if test -z "$func_relative_path_tlibdir"; then 11072f60eb46Smrg # Have to descend all the way to the root! 11082f60eb46Smrg func_relative_path_result=../$func_relative_path_result 11092f60eb46Smrg func_relative_path_tcancelled=$func_relative_path_tbindir 11102f60eb46Smrg break 11112f60eb46Smrg fi 11122f60eb46Smrg func_relative_path_result=../$func_relative_path_result 11132f60eb46Smrg ;; 11142f60eb46Smrg esac 11152f60eb46Smrg done 11162f60eb46Smrg 11172f60eb46Smrg # Now calculate path; take care to avoid doubling-up slashes. 11182f60eb46Smrg func_stripname '' '/' "$func_relative_path_result" 11192f60eb46Smrg func_relative_path_result=$func_stripname_result 11202f60eb46Smrg func_stripname '/' '/' "$func_relative_path_tcancelled" 11212f60eb46Smrg if test -n "$func_stripname_result"; then 11222f60eb46Smrg func_append func_relative_path_result "/$func_stripname_result" 11232f60eb46Smrg fi 11242f60eb46Smrg 11252f60eb46Smrg # Normalisation. If bindir is libdir, return '.' else relative path. 11262f60eb46Smrg if test -n "$func_relative_path_result"; then 11272f60eb46Smrg func_stripname './' '' "$func_relative_path_result" 11282f60eb46Smrg func_relative_path_result=$func_stripname_result 1129692f60a7Smrg fi 1130692f60a7Smrg 11312f60eb46Smrg test -n "$func_relative_path_result" || func_relative_path_result=. 11322f60eb46Smrg 11332f60eb46Smrg : 11342f60eb46Smrg} 11352f60eb46Smrg 11362f60eb46Smrg 1137efb46889Smrg# func_quote_portable EVAL ARG 1138efb46889Smrg# ---------------------------- 1139efb46889Smrg# Internal function to portably implement func_quote_arg. Note that we still 1140efb46889Smrg# keep attention to performance here so we as much as possible try to avoid 1141efb46889Smrg# calling sed binary (so far O(N) complexity as long as func_append is O(1)). 1142efb46889Smrgfunc_quote_portable () 11432f60eb46Smrg{ 11442f60eb46Smrg $debug_cmd 11452f60eb46Smrg 1146efb46889Smrg $require_check_ifs_backslash 1147efb46889Smrg 1148efb46889Smrg func_quote_portable_result=$2 1149efb46889Smrg 1150efb46889Smrg # one-time-loop (easy break) 1151efb46889Smrg while true 1152efb46889Smrg do 1153efb46889Smrg if $1; then 1154efb46889Smrg func_quote_portable_result=`$ECHO "$2" | $SED \ 1155efb46889Smrg -e "$sed_double_quote_subst" -e "$sed_double_backslash"` 1156efb46889Smrg break 11572f60eb46Smrg fi 11582f60eb46Smrg 1159efb46889Smrg # Quote for eval. 1160efb46889Smrg case $func_quote_portable_result in 1161efb46889Smrg *[\\\`\"\$]*) 1162efb46889Smrg # Fallback to sed for $func_check_bs_ifs_broken=:, or when the string 1163efb46889Smrg # contains the shell wildcard characters. 1164efb46889Smrg case $check_ifs_backshlash_broken$func_quote_portable_result in 1165efb46889Smrg :*|*[\[\*\?]*) 1166efb46889Smrg func_quote_portable_result=`$ECHO "$func_quote_portable_result" \ 1167efb46889Smrg | $SED "$sed_quote_subst"` 1168efb46889Smrg break 1169efb46889Smrg ;; 1170efb46889Smrg esac 1171efb46889Smrg 1172efb46889Smrg func_quote_portable_old_IFS=$IFS 1173efb46889Smrg for _G_char in '\' '`' '"' '$' 1174efb46889Smrg do 1175efb46889Smrg # STATE($1) PREV($2) SEPARATOR($3) 1176efb46889Smrg set start "" "" 1177efb46889Smrg func_quote_portable_result=dummy"$_G_char$func_quote_portable_result$_G_char"dummy 1178efb46889Smrg IFS=$_G_char 1179efb46889Smrg for _G_part in $func_quote_portable_result 1180efb46889Smrg do 1181efb46889Smrg case $1 in 1182efb46889Smrg quote) 1183efb46889Smrg func_append func_quote_portable_result "$3$2" 1184efb46889Smrg set quote "$_G_part" "\\$_G_char" 1185efb46889Smrg ;; 1186efb46889Smrg start) 1187efb46889Smrg set first "" "" 1188efb46889Smrg func_quote_portable_result= 1189efb46889Smrg ;; 1190efb46889Smrg first) 1191efb46889Smrg set quote "$_G_part" "" 1192efb46889Smrg ;; 1193efb46889Smrg esac 1194efb46889Smrg done 1195efb46889Smrg done 1196efb46889Smrg IFS=$func_quote_portable_old_IFS 11972f60eb46Smrg ;; 1198efb46889Smrg *) ;; 11992f60eb46Smrg esac 1200efb46889Smrg break 12012f60eb46Smrg done 1202efb46889Smrg 1203efb46889Smrg func_quote_portable_unquoted_result=$func_quote_portable_result 1204efb46889Smrg case $func_quote_portable_result in 1205efb46889Smrg # double-quote args containing shell metacharacters to delay 1206efb46889Smrg # word splitting, command substitution and variable expansion 1207efb46889Smrg # for a subsequent eval. 1208efb46889Smrg # many bourne shells cannot handle close brackets correctly 1209efb46889Smrg # in scan sets, so we specify it separately. 1210efb46889Smrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 1211efb46889Smrg func_quote_portable_result=\"$func_quote_portable_result\" 1212efb46889Smrg ;; 1213efb46889Smrg esac 12142f60eb46Smrg} 12152f60eb46Smrg 12162f60eb46Smrg 1217efb46889Smrg# func_quotefast_eval ARG 1218efb46889Smrg# ----------------------- 1219efb46889Smrg# Quote one ARG (internal). This is equivalent to 'func_quote_arg eval ARG', 1220efb46889Smrg# but optimized for speed. Result is stored in $func_quotefast_eval. 1221efb46889Smrgif test xyes = `(x=; printf -v x %q yes; echo x"$x") 2>/dev/null`; then 1222efb46889Smrg printf -v _GL_test_printf_tilde %q '~' 1223efb46889Smrg if test '\~' = "$_GL_test_printf_tilde"; then 1224efb46889Smrg func_quotefast_eval () 1225efb46889Smrg { 1226efb46889Smrg printf -v func_quotefast_eval_result %q "$1" 1227efb46889Smrg } 1228efb46889Smrg else 1229efb46889Smrg # Broken older Bash implementations. Make those faster too if possible. 1230efb46889Smrg func_quotefast_eval () 1231efb46889Smrg { 1232efb46889Smrg case $1 in 1233efb46889Smrg '~'*) 1234efb46889Smrg func_quote_portable false "$1" 1235efb46889Smrg func_quotefast_eval_result=$func_quote_portable_result 1236efb46889Smrg ;; 1237efb46889Smrg *) 1238efb46889Smrg printf -v func_quotefast_eval_result %q "$1" 1239efb46889Smrg ;; 1240efb46889Smrg esac 1241efb46889Smrg } 1242efb46889Smrg fi 1243efb46889Smrgelse 1244efb46889Smrg func_quotefast_eval () 1245efb46889Smrg { 1246efb46889Smrg func_quote_portable false "$1" 1247efb46889Smrg func_quotefast_eval_result=$func_quote_portable_result 1248efb46889Smrg } 1249efb46889Smrgfi 12502f60eb46Smrg 1251efb46889Smrg 1252efb46889Smrg# func_quote_arg MODEs ARG 1253efb46889Smrg# ------------------------ 1254efb46889Smrg# Quote one ARG to be evaled later. MODEs argument may contain zero or more 1255efb46889Smrg# specifiers listed below separated by ',' character. This function returns two 1256efb46889Smrg# values: 1257efb46889Smrg# i) func_quote_arg_result 1258efb46889Smrg# double-quoted (when needed), suitable for a subsequent eval 1259efb46889Smrg# ii) func_quote_arg_unquoted_result 1260efb46889Smrg# has all characters that are still active within double 1261efb46889Smrg# quotes backslashified. Available only if 'unquoted' is specified. 1262efb46889Smrg# 1263efb46889Smrg# Available modes: 1264efb46889Smrg# ---------------- 1265efb46889Smrg# 'eval' (default) 1266efb46889Smrg# - escape shell special characters 1267efb46889Smrg# 'expand' 1268efb46889Smrg# - the same as 'eval'; but do not quote variable references 1269efb46889Smrg# 'pretty' 1270efb46889Smrg# - request aesthetic output, i.e. '"a b"' instead of 'a\ b'. This might 1271efb46889Smrg# be used later in func_quote to get output like: 'echo "a b"' instead 1272efb46889Smrg# of 'echo a\ b'. This is slower than default on some shells. 1273efb46889Smrg# 'unquoted' 1274efb46889Smrg# - produce also $func_quote_arg_unquoted_result which does not contain 1275efb46889Smrg# wrapping double-quotes. 1276efb46889Smrg# 1277efb46889Smrg# Examples for 'func_quote_arg pretty,unquoted string': 1278efb46889Smrg# 1279efb46889Smrg# string | *_result | *_unquoted_result 1280efb46889Smrg# ------------+-----------------------+------------------- 1281efb46889Smrg# " | \" | \" 1282efb46889Smrg# a b | "a b" | a b 1283efb46889Smrg# "a b" | "\"a b\"" | \"a b\" 1284efb46889Smrg# * | "*" | * 1285efb46889Smrg# z="${x-$y}" | "z=\"\${x-\$y}\"" | z=\"\${x-\$y}\" 1286efb46889Smrg# 1287efb46889Smrg# Examples for 'func_quote_arg pretty,unquoted,expand string': 1288efb46889Smrg# 1289efb46889Smrg# string | *_result | *_unquoted_result 1290efb46889Smrg# --------------+---------------------+-------------------- 1291efb46889Smrg# z="${x-$y}" | "z=\"${x-$y}\"" | z=\"${x-$y}\" 1292efb46889Smrgfunc_quote_arg () 1293efb46889Smrg{ 1294efb46889Smrg _G_quote_expand=false 1295efb46889Smrg case ,$1, in 1296efb46889Smrg *,expand,*) 1297efb46889Smrg _G_quote_expand=: 1298efb46889Smrg ;; 12992f60eb46Smrg esac 13002f60eb46Smrg 1301efb46889Smrg case ,$1, in 1302efb46889Smrg *,pretty,*|*,expand,*|*,unquoted,*) 1303efb46889Smrg func_quote_portable $_G_quote_expand "$2" 1304efb46889Smrg func_quote_arg_result=$func_quote_portable_result 1305efb46889Smrg func_quote_arg_unquoted_result=$func_quote_portable_unquoted_result 1306efb46889Smrg ;; 1307efb46889Smrg *) 1308efb46889Smrg # Faster quote-for-eval for some shells. 1309efb46889Smrg func_quotefast_eval "$2" 1310efb46889Smrg func_quote_arg_result=$func_quotefast_eval_result 13112f60eb46Smrg ;; 13122f60eb46Smrg esac 1313efb46889Smrg} 1314efb46889Smrg 13152f60eb46Smrg 1316efb46889Smrg# func_quote MODEs ARGs... 1317efb46889Smrg# ------------------------ 1318efb46889Smrg# Quote all ARGs to be evaled later and join them into single command. See 1319efb46889Smrg# func_quote_arg's description for more info. 1320efb46889Smrgfunc_quote () 1321efb46889Smrg{ 1322efb46889Smrg $debug_cmd 1323efb46889Smrg _G_func_quote_mode=$1 ; shift 1324efb46889Smrg func_quote_result= 1325efb46889Smrg while test 0 -lt $#; do 1326efb46889Smrg func_quote_arg "$_G_func_quote_mode" "$1" 1327efb46889Smrg if test -n "$func_quote_result"; then 1328efb46889Smrg func_append func_quote_result " $func_quote_arg_result" 1329efb46889Smrg else 1330efb46889Smrg func_append func_quote_result "$func_quote_arg_result" 1331efb46889Smrg fi 1332efb46889Smrg shift 1333efb46889Smrg done 13342f60eb46Smrg} 13352f60eb46Smrg 13362f60eb46Smrg 13372f60eb46Smrg# func_stripname PREFIX SUFFIX NAME 13382f60eb46Smrg# --------------------------------- 13392f60eb46Smrg# strip PREFIX and SUFFIX from NAME, and store in func_stripname_result. 13402f60eb46Smrg# PREFIX and SUFFIX must not contain globbing or regex special 13412f60eb46Smrg# characters, hashes, percent signs, but SUFFIX may contain a leading 13422f60eb46Smrg# dot (in which case that matches only a dot). 13432f60eb46Smrgif test yes = "$_G_HAVE_XSI_OPS"; then 13442f60eb46Smrg eval 'func_stripname () 13452f60eb46Smrg { 13462f60eb46Smrg $debug_cmd 13472f60eb46Smrg 13482f60eb46Smrg # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are 13492f60eb46Smrg # positional parameters, so assign one to ordinary variable first. 13502f60eb46Smrg func_stripname_result=$3 13512f60eb46Smrg func_stripname_result=${func_stripname_result#"$1"} 13522f60eb46Smrg func_stripname_result=${func_stripname_result%"$2"} 13532f60eb46Smrg }' 13542f60eb46Smrgelse 13552f60eb46Smrg func_stripname () 13562f60eb46Smrg { 13572f60eb46Smrg $debug_cmd 13582f60eb46Smrg 13592f60eb46Smrg case $2 in 13602f60eb46Smrg .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;; 13612f60eb46Smrg *) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;; 13622f60eb46Smrg esac 13632f60eb46Smrg } 13642f60eb46Smrgfi 13652f60eb46Smrg 13662f60eb46Smrg 13672f60eb46Smrg# func_show_eval CMD [FAIL_EXP] 13682f60eb46Smrg# ----------------------------- 13692f60eb46Smrg# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is 13702f60eb46Smrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 13712f60eb46Smrg# is given, then evaluate it. 13722f60eb46Smrgfunc_show_eval () 13732f60eb46Smrg{ 13742f60eb46Smrg $debug_cmd 13752f60eb46Smrg 13762f60eb46Smrg _G_cmd=$1 13772f60eb46Smrg _G_fail_exp=${2-':'} 13782f60eb46Smrg 1379efb46889Smrg func_quote_arg pretty,expand "$_G_cmd" 1380efb46889Smrg eval "func_notquiet $func_quote_arg_result" 13812f60eb46Smrg 13822f60eb46Smrg $opt_dry_run || { 13832f60eb46Smrg eval "$_G_cmd" 13842f60eb46Smrg _G_status=$? 13852f60eb46Smrg if test 0 -ne "$_G_status"; then 13862f60eb46Smrg eval "(exit $_G_status); $_G_fail_exp" 13872f60eb46Smrg fi 13882f60eb46Smrg } 13892f60eb46Smrg} 13902f60eb46Smrg 13912f60eb46Smrg 13922f60eb46Smrg# func_show_eval_locale CMD [FAIL_EXP] 13932f60eb46Smrg# ------------------------------------ 13942f60eb46Smrg# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is 13952f60eb46Smrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 13962f60eb46Smrg# is given, then evaluate it. Use the saved locale for evaluation. 13972f60eb46Smrgfunc_show_eval_locale () 13982f60eb46Smrg{ 13992f60eb46Smrg $debug_cmd 14002f60eb46Smrg 14012f60eb46Smrg _G_cmd=$1 14022f60eb46Smrg _G_fail_exp=${2-':'} 14032f60eb46Smrg 14042f60eb46Smrg $opt_quiet || { 1405efb46889Smrg func_quote_arg expand,pretty "$_G_cmd" 1406efb46889Smrg eval "func_echo $func_quote_arg_result" 14072f60eb46Smrg } 14082f60eb46Smrg 14092f60eb46Smrg $opt_dry_run || { 14102f60eb46Smrg eval "$_G_user_locale 14112f60eb46Smrg $_G_cmd" 14122f60eb46Smrg _G_status=$? 14132f60eb46Smrg eval "$_G_safe_locale" 14142f60eb46Smrg if test 0 -ne "$_G_status"; then 14152f60eb46Smrg eval "(exit $_G_status); $_G_fail_exp" 14162f60eb46Smrg fi 14172f60eb46Smrg } 14182f60eb46Smrg} 14192f60eb46Smrg 14202f60eb46Smrg 14212f60eb46Smrg# func_tr_sh 14222f60eb46Smrg# ---------- 14232f60eb46Smrg# Turn $1 into a string suitable for a shell variable name. 14242f60eb46Smrg# Result is stored in $func_tr_sh_result. All characters 14252f60eb46Smrg# not in the set a-zA-Z0-9_ are replaced with '_'. Further, 14262f60eb46Smrg# if $1 begins with a digit, a '_' is prepended as well. 14272f60eb46Smrgfunc_tr_sh () 14282f60eb46Smrg{ 14292f60eb46Smrg $debug_cmd 14302f60eb46Smrg 14312f60eb46Smrg case $1 in 14322f60eb46Smrg [0-9]* | *[!a-zA-Z0-9_]*) 14332f60eb46Smrg func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'` 14342f60eb46Smrg ;; 14352f60eb46Smrg * ) 14362f60eb46Smrg func_tr_sh_result=$1 14372f60eb46Smrg ;; 14382f60eb46Smrg esac 14392f60eb46Smrg} 14402f60eb46Smrg 14412f60eb46Smrg 14422f60eb46Smrg# func_verbose ARG... 14432f60eb46Smrg# ------------------- 14442f60eb46Smrg# Echo program name prefixed message in verbose mode only. 14452f60eb46Smrgfunc_verbose () 14462f60eb46Smrg{ 14472f60eb46Smrg $debug_cmd 14482f60eb46Smrg 14492f60eb46Smrg $opt_verbose && func_echo "$*" 14502f60eb46Smrg 14512f60eb46Smrg : 14522f60eb46Smrg} 14532f60eb46Smrg 14542f60eb46Smrg 14552f60eb46Smrg# func_warn_and_continue ARG... 14562f60eb46Smrg# ----------------------------- 14572f60eb46Smrg# Echo program name prefixed warning message to standard error. 14582f60eb46Smrgfunc_warn_and_continue () 14592f60eb46Smrg{ 14602f60eb46Smrg $debug_cmd 14612f60eb46Smrg 14622f60eb46Smrg $require_term_colors 14632f60eb46Smrg 14642f60eb46Smrg func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2 14652f60eb46Smrg} 14662f60eb46Smrg 14672f60eb46Smrg 14682f60eb46Smrg# func_warning CATEGORY ARG... 14692f60eb46Smrg# ---------------------------- 14702f60eb46Smrg# Echo program name prefixed warning message to standard error. Warning 14712f60eb46Smrg# messages can be filtered according to CATEGORY, where this function 14722f60eb46Smrg# elides messages where CATEGORY is not listed in the global variable 14732f60eb46Smrg# 'opt_warning_types'. 14742f60eb46Smrgfunc_warning () 14752f60eb46Smrg{ 14762f60eb46Smrg $debug_cmd 14772f60eb46Smrg 14782f60eb46Smrg # CATEGORY must be in the warning_categories list! 14792f60eb46Smrg case " $warning_categories " in 14802f60eb46Smrg *" $1 "*) ;; 14812f60eb46Smrg *) func_internal_error "invalid warning category '$1'" ;; 14822f60eb46Smrg esac 14832f60eb46Smrg 14842f60eb46Smrg _G_category=$1 14852f60eb46Smrg shift 14862f60eb46Smrg 14872f60eb46Smrg case " $opt_warning_types " in 14882f60eb46Smrg *" $_G_category "*) $warning_func ${1+"$@"} ;; 14892f60eb46Smrg esac 14902f60eb46Smrg} 14912f60eb46Smrg 14922f60eb46Smrg 14932f60eb46Smrg# func_sort_ver VER1 VER2 14942f60eb46Smrg# ----------------------- 14952f60eb46Smrg# 'sort -V' is not generally available. 14962f60eb46Smrg# Note this deviates from the version comparison in automake 14972f60eb46Smrg# in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a 14982f60eb46Smrg# but this should suffice as we won't be specifying old 14992f60eb46Smrg# version formats or redundant trailing .0 in bootstrap.conf. 15002f60eb46Smrg# If we did want full compatibility then we should probably 15012f60eb46Smrg# use m4_version_compare from autoconf. 15022f60eb46Smrgfunc_sort_ver () 15032f60eb46Smrg{ 15042f60eb46Smrg $debug_cmd 15052f60eb46Smrg 15062f60eb46Smrg printf '%s\n%s\n' "$1" "$2" \ 15072f60eb46Smrg | 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 15082f60eb46Smrg} 15092f60eb46Smrg 15102f60eb46Smrg# func_lt_ver PREV CURR 15112f60eb46Smrg# --------------------- 15122f60eb46Smrg# Return true if PREV and CURR are in the correct order according to 15132f60eb46Smrg# func_sort_ver, otherwise false. Use it like this: 15142f60eb46Smrg# 15152f60eb46Smrg# func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..." 15162f60eb46Smrgfunc_lt_ver () 15172f60eb46Smrg{ 15182f60eb46Smrg $debug_cmd 15192f60eb46Smrg 15202f60eb46Smrg test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q` 15212f60eb46Smrg} 15222f60eb46Smrg 15232f60eb46Smrg 15242f60eb46Smrg# Local variables: 15252f60eb46Smrg# mode: shell-script 15262f60eb46Smrg# sh-indentation: 2 15272f60eb46Smrg# eval: (add-hook 'before-save-hook 'time-stamp) 15282f60eb46Smrg# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" 15292f60eb46Smrg# time-stamp-time-zone: "UTC" 15302f60eb46Smrg# End: 15312f60eb46Smrg#! /bin/sh 15322f60eb46Smrg 15332f60eb46Smrg# A portable, pluggable option parser for Bourne shell. 15342f60eb46Smrg# Written by Gary V. Vaughan, 2010 15352f60eb46Smrg 1536efb46889Smrg# This is free software. There is NO warranty; not even for 1537efb46889Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 1538efb46889Smrg# 1539efb46889Smrg# Copyright (C) 2010-2019, 2021 Bootstrap Authors 1540efb46889Smrg# 1541efb46889Smrg# This file is dual licensed under the terms of the MIT license 1542efb46889Smrg# <https://opensource.org/license/MIT>, and GPL version 2 or later 1543efb46889Smrg# <http://www.gnu.org/licenses/gpl-2.0.html>. You must apply one of 1544efb46889Smrg# these licenses when using or redistributing this software or any of 1545efb46889Smrg# the files within it. See the URLs above, or the file `LICENSE` 1546efb46889Smrg# included in the Bootstrap distribution for the full license texts. 15472f60eb46Smrg 1548efb46889Smrg# Please report bugs or propose patches to: 1549efb46889Smrg# <https://github.com/gnulib-modules/bootstrap/issues> 15502f60eb46Smrg 1551efb46889Smrg# Set a version string for this script. 1552efb46889Smrgscriptversion=2019-02-19.15; # UTC 15532f60eb46Smrg 15542f60eb46Smrg 15552f60eb46Smrg## ------ ## 15562f60eb46Smrg## Usage. ## 15572f60eb46Smrg## ------ ## 15582f60eb46Smrg 15592f60eb46Smrg# This file is a library for parsing options in your shell scripts along 15602f60eb46Smrg# with assorted other useful supporting features that you can make use 15612f60eb46Smrg# of too. 15622f60eb46Smrg# 15632f60eb46Smrg# For the simplest scripts you might need only: 15642f60eb46Smrg# 15652f60eb46Smrg# #!/bin/sh 15662f60eb46Smrg# . relative/path/to/funclib.sh 15672f60eb46Smrg# . relative/path/to/options-parser 15682f60eb46Smrg# scriptversion=1.0 15692f60eb46Smrg# func_options ${1+"$@"} 15702f60eb46Smrg# eval set dummy "$func_options_result"; shift 15712f60eb46Smrg# ...rest of your script... 15722f60eb46Smrg# 15732f60eb46Smrg# In order for the '--version' option to work, you will need to have a 15742f60eb46Smrg# suitably formatted comment like the one at the top of this file 1575efb46889Smrg# starting with '# Written by ' and ending with '# Copyright'. 15762f60eb46Smrg# 15772f60eb46Smrg# For '-h' and '--help' to work, you will also need a one line 15782f60eb46Smrg# description of your script's purpose in a comment directly above the 15792f60eb46Smrg# '# Written by ' line, like the one at the top of this file. 15802f60eb46Smrg# 15812f60eb46Smrg# The default options also support '--debug', which will turn on shell 15822f60eb46Smrg# execution tracing (see the comment above debug_cmd below for another 15832f60eb46Smrg# use), and '--verbose' and the func_verbose function to allow your script 15842f60eb46Smrg# to display verbose messages only when your user has specified 15852f60eb46Smrg# '--verbose'. 15862f60eb46Smrg# 1587efb46889Smrg# After sourcing this file, you can plug in processing for additional 15882f60eb46Smrg# options by amending the variables from the 'Configuration' section 15892f60eb46Smrg# below, and following the instructions in the 'Option parsing' 15902f60eb46Smrg# section further down. 15912f60eb46Smrg 15922f60eb46Smrg## -------------- ## 15932f60eb46Smrg## Configuration. ## 15942f60eb46Smrg## -------------- ## 15952f60eb46Smrg 15962f60eb46Smrg# You should override these variables in your script after sourcing this 15972f60eb46Smrg# file so that they reflect the customisations you have added to the 15982f60eb46Smrg# option parser. 15992f60eb46Smrg 16002f60eb46Smrg# The usage line for option parsing errors and the start of '-h' and 16012f60eb46Smrg# '--help' output messages. You can embed shell variables for delayed 16022f60eb46Smrg# expansion at the time the message is displayed, but you will need to 16032f60eb46Smrg# quote other shell meta-characters carefully to prevent them being 16042f60eb46Smrg# expanded when the contents are evaled. 16052f60eb46Smrgusage='$progpath [OPTION]...' 16062f60eb46Smrg 16072f60eb46Smrg# Short help message in response to '-h' and '--help'. Add to this or 16082f60eb46Smrg# override it after sourcing this library to reflect the full set of 16092f60eb46Smrg# options your script accepts. 16102f60eb46Smrgusage_message="\ 16112f60eb46Smrg --debug enable verbose shell tracing 16122f60eb46Smrg -W, --warnings=CATEGORY 16132f60eb46Smrg report the warnings falling in CATEGORY [all] 16142f60eb46Smrg -v, --verbose verbosely report processing 16152f60eb46Smrg --version print version information and exit 16162f60eb46Smrg -h, --help print short or long help message and exit 16172f60eb46Smrg" 16182f60eb46Smrg 16192f60eb46Smrg# Additional text appended to 'usage_message' in response to '--help'. 16202f60eb46Smrglong_help_message=" 16212f60eb46SmrgWarning categories include: 16222f60eb46Smrg 'all' show all warnings 16232f60eb46Smrg 'none' turn off all the warnings 16242f60eb46Smrg 'error' warnings are treated as fatal errors" 16252f60eb46Smrg 16262f60eb46Smrg# Help message printed before fatal option parsing errors. 16272f60eb46Smrgfatal_help="Try '\$progname --help' for more information." 16282f60eb46Smrg 16292f60eb46Smrg 16302f60eb46Smrg 16312f60eb46Smrg## ------------------------- ## 16322f60eb46Smrg## Hook function management. ## 16332f60eb46Smrg## ------------------------- ## 16342f60eb46Smrg 16352f60eb46Smrg# This section contains functions for adding, removing, and running hooks 1636efb46889Smrg# in the main code. A hook is just a list of function names that can be 1637efb46889Smrg# run in order later on. 16382f60eb46Smrg 16392f60eb46Smrg# func_hookable FUNC_NAME 16402f60eb46Smrg# ----------------------- 16412f60eb46Smrg# Declare that FUNC_NAME will run hooks added with 16422f60eb46Smrg# 'func_add_hook FUNC_NAME ...'. 16432f60eb46Smrgfunc_hookable () 16442f60eb46Smrg{ 16452f60eb46Smrg $debug_cmd 16462f60eb46Smrg 16472f60eb46Smrg func_append hookable_fns " $1" 16482f60eb46Smrg} 16492f60eb46Smrg 16502f60eb46Smrg 16512f60eb46Smrg# func_add_hook FUNC_NAME HOOK_FUNC 16522f60eb46Smrg# --------------------------------- 16532f60eb46Smrg# Request that FUNC_NAME call HOOK_FUNC before it returns. FUNC_NAME must 16542f60eb46Smrg# first have been declared "hookable" by a call to 'func_hookable'. 16552f60eb46Smrgfunc_add_hook () 16562f60eb46Smrg{ 16572f60eb46Smrg $debug_cmd 16582f60eb46Smrg 16592f60eb46Smrg case " $hookable_fns " in 16602f60eb46Smrg *" $1 "*) ;; 16612f60eb46Smrg *) func_fatal_error "'$1' does not accept hook functions." ;; 16622f60eb46Smrg esac 16632f60eb46Smrg 16642f60eb46Smrg eval func_append ${1}_hooks '" $2"' 16652f60eb46Smrg} 16662f60eb46Smrg 16672f60eb46Smrg 16682f60eb46Smrg# func_remove_hook FUNC_NAME HOOK_FUNC 16692f60eb46Smrg# ------------------------------------ 1670efb46889Smrg# Remove HOOK_FUNC from the list of hook functions to be called by 1671efb46889Smrg# FUNC_NAME. 16722f60eb46Smrgfunc_remove_hook () 16732f60eb46Smrg{ 16742f60eb46Smrg $debug_cmd 16752f60eb46Smrg 16762f60eb46Smrg eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`' 16772f60eb46Smrg} 16782f60eb46Smrg 16792f60eb46Smrg 1680efb46889Smrg# func_propagate_result FUNC_NAME_A FUNC_NAME_B 1681efb46889Smrg# --------------------------------------------- 1682efb46889Smrg# If the *_result variable of FUNC_NAME_A _is set_, assign its value to 1683efb46889Smrg# *_result variable of FUNC_NAME_B. 1684efb46889Smrgfunc_propagate_result () 1685efb46889Smrg{ 1686efb46889Smrg $debug_cmd 1687efb46889Smrg 1688efb46889Smrg func_propagate_result_result=: 1689efb46889Smrg if eval "test \"\${${1}_result+set}\" = set" 1690efb46889Smrg then 1691efb46889Smrg eval "${2}_result=\$${1}_result" 1692efb46889Smrg else 1693efb46889Smrg func_propagate_result_result=false 1694efb46889Smrg fi 1695efb46889Smrg} 1696efb46889Smrg 1697efb46889Smrg 16982f60eb46Smrg# func_run_hooks FUNC_NAME [ARG]... 16992f60eb46Smrg# --------------------------------- 17002f60eb46Smrg# Run all hook functions registered to FUNC_NAME. 1701efb46889Smrg# It's assumed that the list of hook functions contains nothing more 17022f60eb46Smrg# than a whitespace-delimited list of legal shell function names, and 17032f60eb46Smrg# no effort is wasted trying to catch shell meta-characters or preserve 17042f60eb46Smrg# whitespace. 17052f60eb46Smrgfunc_run_hooks () 17062f60eb46Smrg{ 17072f60eb46Smrg $debug_cmd 17082f60eb46Smrg 17092f60eb46Smrg case " $hookable_fns " in 17102f60eb46Smrg *" $1 "*) ;; 1711efb46889Smrg *) func_fatal_error "'$1' does not support hook functions." ;; 17122f60eb46Smrg esac 17132f60eb46Smrg 17142f60eb46Smrg eval _G_hook_fns=\$$1_hooks; shift 17152f60eb46Smrg 17162f60eb46Smrg for _G_hook in $_G_hook_fns; do 1717efb46889Smrg func_unset "${_G_hook}_result" 1718efb46889Smrg eval $_G_hook '${1+"$@"}' 1719efb46889Smrg func_propagate_result $_G_hook func_run_hooks 1720efb46889Smrg if $func_propagate_result_result; then 1721efb46889Smrg eval set dummy "$func_run_hooks_result"; shift 1722efb46889Smrg fi 17232f60eb46Smrg done 17242f60eb46Smrg} 17252f60eb46Smrg 17262f60eb46Smrg 17272f60eb46Smrg 17282f60eb46Smrg## --------------- ## 17292f60eb46Smrg## Option parsing. ## 17302f60eb46Smrg## --------------- ## 17312f60eb46Smrg 17322f60eb46Smrg# In order to add your own option parsing hooks, you must accept the 1733efb46889Smrg# full positional parameter list from your hook function. You may remove 1734efb46889Smrg# or edit any options that you action, and then pass back the remaining 1735efb46889Smrg# unprocessed options in '<hooked_function_name>_result', escaped 1736efb46889Smrg# suitably for 'eval'. 1737efb46889Smrg# 1738efb46889Smrg# The '<hooked_function_name>_result' variable is automatically unset 1739efb46889Smrg# before your hook gets called; for best performance, only set the 1740efb46889Smrg# *_result variable when necessary (i.e. don't call the 'func_quote' 1741efb46889Smrg# function unnecessarily because it can be an expensive operation on some 1742efb46889Smrg# machines). 1743efb46889Smrg# 1744efb46889Smrg# Like this: 17452f60eb46Smrg# 17462f60eb46Smrg# my_options_prep () 17472f60eb46Smrg# { 17482f60eb46Smrg# $debug_cmd 17492f60eb46Smrg# 17502f60eb46Smrg# # Extend the existing usage message. 17512f60eb46Smrg# usage_message=$usage_message' 17522f60eb46Smrg# -s, --silent don'\''t print informational messages 17532f60eb46Smrg# ' 1754efb46889Smrg# # No change in '$@' (ignored completely by this hook). Leave 1755efb46889Smrg# # my_options_prep_result variable intact. 17562f60eb46Smrg# } 17572f60eb46Smrg# func_add_hook func_options_prep my_options_prep 17582f60eb46Smrg# 17592f60eb46Smrg# 17602f60eb46Smrg# my_silent_option () 17612f60eb46Smrg# { 17622f60eb46Smrg# $debug_cmd 17632f60eb46Smrg# 1764efb46889Smrg# args_changed=false 1765efb46889Smrg# 1766efb46889Smrg# # Note that, for efficiency, we parse as many options as we can 17672f60eb46Smrg# # recognise in a loop before passing the remainder back to the 17682f60eb46Smrg# # caller on the first unrecognised argument we encounter. 17692f60eb46Smrg# while test $# -gt 0; do 17702f60eb46Smrg# opt=$1; shift 17712f60eb46Smrg# case $opt in 1772efb46889Smrg# --silent|-s) opt_silent=: 1773efb46889Smrg# args_changed=: 1774efb46889Smrg# ;; 17752f60eb46Smrg# # Separate non-argument short options: 17762f60eb46Smrg# -s*) func_split_short_opt "$_G_opt" 17772f60eb46Smrg# set dummy "$func_split_short_opt_name" \ 17782f60eb46Smrg# "-$func_split_short_opt_arg" ${1+"$@"} 17792f60eb46Smrg# shift 1780efb46889Smrg# args_changed=: 17812f60eb46Smrg# ;; 1782efb46889Smrg# *) # Make sure the first unrecognised option "$_G_opt" 1783efb46889Smrg# # is added back to "$@" in case we need it later, 1784efb46889Smrg# # if $args_changed was set to 'true'. 1785efb46889Smrg# set dummy "$_G_opt" ${1+"$@"}; shift; break ;; 17862f60eb46Smrg# esac 17872f60eb46Smrg# done 17882f60eb46Smrg# 1789efb46889Smrg# # Only call 'func_quote' here if we processed at least one argument. 1790efb46889Smrg# if $args_changed; then 1791efb46889Smrg# func_quote eval ${1+"$@"} 1792efb46889Smrg# my_silent_option_result=$func_quote_result 1793efb46889Smrg# fi 17942f60eb46Smrg# } 17952f60eb46Smrg# func_add_hook func_parse_options my_silent_option 17962f60eb46Smrg# 17972f60eb46Smrg# 17982f60eb46Smrg# my_option_validation () 17992f60eb46Smrg# { 18002f60eb46Smrg# $debug_cmd 18012f60eb46Smrg# 18022f60eb46Smrg# $opt_silent && $opt_verbose && func_fatal_help "\ 18032f60eb46Smrg# '--silent' and '--verbose' options are mutually exclusive." 18042f60eb46Smrg# } 18052f60eb46Smrg# func_add_hook func_validate_options my_option_validation 18062f60eb46Smrg# 1807efb46889Smrg# You'll also need to manually amend $usage_message to reflect the extra 18082f60eb46Smrg# options you parse. It's preferable to append if you can, so that 18092f60eb46Smrg# multiple option parsing hooks can be added safely. 18102f60eb46Smrg 18112f60eb46Smrg 1812efb46889Smrg# func_options_finish [ARG]... 1813efb46889Smrg# ---------------------------- 1814efb46889Smrg# Finishing the option parse loop (call 'func_options' hooks ATM). 1815efb46889Smrgfunc_options_finish () 1816efb46889Smrg{ 1817efb46889Smrg $debug_cmd 1818efb46889Smrg 1819efb46889Smrg func_run_hooks func_options ${1+"$@"} 1820efb46889Smrg func_propagate_result func_run_hooks func_options_finish 1821efb46889Smrg} 1822efb46889Smrg 1823efb46889Smrg 18242f60eb46Smrg# func_options [ARG]... 18252f60eb46Smrg# --------------------- 18262f60eb46Smrg# All the functions called inside func_options are hookable. See the 18272f60eb46Smrg# individual implementations for details. 18282f60eb46Smrgfunc_hookable func_options 18292f60eb46Smrgfunc_options () 18302f60eb46Smrg{ 18312f60eb46Smrg $debug_cmd 18322f60eb46Smrg 1833efb46889Smrg _G_options_quoted=false 18342f60eb46Smrg 1835efb46889Smrg for my_func in options_prep parse_options validate_options options_finish 1836efb46889Smrg do 1837efb46889Smrg func_unset func_${my_func}_result 1838efb46889Smrg func_unset func_run_hooks_result 1839efb46889Smrg eval func_$my_func '${1+"$@"}' 1840efb46889Smrg func_propagate_result func_$my_func func_options 1841efb46889Smrg if $func_propagate_result_result; then 1842efb46889Smrg eval set dummy "$func_options_result"; shift 1843efb46889Smrg _G_options_quoted=: 1844efb46889Smrg fi 1845efb46889Smrg done 18462f60eb46Smrg 1847efb46889Smrg $_G_options_quoted || { 1848efb46889Smrg # As we (func_options) are top-level options-parser function and 1849efb46889Smrg # nobody quoted "$@" for us yet, we need to do it explicitly for 1850efb46889Smrg # caller. 1851efb46889Smrg func_quote eval ${1+"$@"} 1852efb46889Smrg func_options_result=$func_quote_result 1853efb46889Smrg } 1854692f60a7Smrg} 1855692f60a7Smrg 1856692f60a7Smrg 18572f60eb46Smrg# func_options_prep [ARG]... 18582f60eb46Smrg# -------------------------- 18592f60eb46Smrg# All initialisations required before starting the option parse loop. 18602f60eb46Smrg# Note that when calling hook functions, we pass through the list of 18612f60eb46Smrg# positional parameters. If a hook function modifies that list, and 1862efb46889Smrg# needs to propagate that back to rest of this script, then the complete 1863efb46889Smrg# modified list must be put in 'func_run_hooks_result' before returning. 18642f60eb46Smrgfunc_hookable func_options_prep 18652f60eb46Smrgfunc_options_prep () 1866692f60a7Smrg{ 18672f60eb46Smrg $debug_cmd 1868c3c9db83Smrg 18692f60eb46Smrg # Option defaults: 18702f60eb46Smrg opt_verbose=false 18712f60eb46Smrg opt_warning_types= 18722f60eb46Smrg 18732f60eb46Smrg func_run_hooks func_options_prep ${1+"$@"} 1874efb46889Smrg func_propagate_result func_run_hooks func_options_prep 1875692f60a7Smrg} 1876692f60a7Smrg 1877692f60a7Smrg 18782f60eb46Smrg# func_parse_options [ARG]... 18792f60eb46Smrg# --------------------------- 18802f60eb46Smrg# The main option parsing loop. 18812f60eb46Smrgfunc_hookable func_parse_options 18822f60eb46Smrgfunc_parse_options () 1883692f60a7Smrg{ 18842f60eb46Smrg $debug_cmd 1885c3c9db83Smrg 1886efb46889Smrg _G_parse_options_requote=false 18872f60eb46Smrg # this just eases exit handling 18882f60eb46Smrg while test $# -gt 0; do 18892f60eb46Smrg # Defer to hook functions for initial option parsing, so they 18902f60eb46Smrg # get priority in the event of reusing an option name. 18912f60eb46Smrg func_run_hooks func_parse_options ${1+"$@"} 1892efb46889Smrg func_propagate_result func_run_hooks func_parse_options 1893efb46889Smrg if $func_propagate_result_result; then 1894efb46889Smrg eval set dummy "$func_parse_options_result"; shift 1895efb46889Smrg # Even though we may have changed "$@", we passed the "$@" array 1896efb46889Smrg # down into the hook and it quoted it for us (because we are in 1897efb46889Smrg # this if-branch). No need to quote it again. 1898efb46889Smrg _G_parse_options_requote=false 1899efb46889Smrg fi 1900692f60a7Smrg 19012f60eb46Smrg # Break out of the loop if we already parsed every option. 19022f60eb46Smrg test $# -gt 0 || break 190385ee4c00Smrg 1904efb46889Smrg # We expect that one of the options parsed in this function matches 1905efb46889Smrg # and thus we remove _G_opt from "$@" and need to re-quote. 1906efb46889Smrg _G_match_parse_options=: 19072f60eb46Smrg _G_opt=$1 19082f60eb46Smrg shift 19092f60eb46Smrg case $_G_opt in 19102f60eb46Smrg --debug|-x) debug_cmd='set -x' 1911efb46889Smrg func_echo "enabling shell trace mode" >&2 19122f60eb46Smrg $debug_cmd 19132f60eb46Smrg ;; 19142f60eb46Smrg 19152f60eb46Smrg --no-warnings|--no-warning|--no-warn) 19162f60eb46Smrg set dummy --warnings none ${1+"$@"} 19172f60eb46Smrg shift 19182f60eb46Smrg ;; 1919c3c9db83Smrg 19202f60eb46Smrg --warnings|--warning|-W) 1921efb46889Smrg if test $# = 0 && func_missing_arg $_G_opt; then 1922efb46889Smrg _G_parse_options_requote=: 1923efb46889Smrg break 1924efb46889Smrg fi 19252f60eb46Smrg case " $warning_categories $1" in 19262f60eb46Smrg *" $1 "*) 19272f60eb46Smrg # trailing space prevents matching last $1 above 19282f60eb46Smrg func_append_uniq opt_warning_types " $1" 19292f60eb46Smrg ;; 19302f60eb46Smrg *all) 19312f60eb46Smrg opt_warning_types=$warning_categories 19322f60eb46Smrg ;; 19332f60eb46Smrg *none) 19342f60eb46Smrg opt_warning_types=none 19352f60eb46Smrg warning_func=: 19362f60eb46Smrg ;; 19372f60eb46Smrg *error) 19382f60eb46Smrg opt_warning_types=$warning_categories 19392f60eb46Smrg warning_func=func_fatal_error 19402f60eb46Smrg ;; 19412f60eb46Smrg *) 19422f60eb46Smrg func_fatal_error \ 19432f60eb46Smrg "unsupported warning category: '$1'" 19442f60eb46Smrg ;; 19452f60eb46Smrg esac 19462f60eb46Smrg shift 19472f60eb46Smrg ;; 19482f60eb46Smrg 19492f60eb46Smrg --verbose|-v) opt_verbose=: ;; 19502f60eb46Smrg --version) func_version ;; 19512f60eb46Smrg -\?|-h) func_usage ;; 19522f60eb46Smrg --help) func_help ;; 19532f60eb46Smrg 19542f60eb46Smrg # Separate optargs to long options (plugins may need this): 19552f60eb46Smrg --*=*) func_split_equals "$_G_opt" 19562f60eb46Smrg set dummy "$func_split_equals_lhs" \ 19572f60eb46Smrg "$func_split_equals_rhs" ${1+"$@"} 19582f60eb46Smrg shift 19592f60eb46Smrg ;; 19602f60eb46Smrg 19612f60eb46Smrg # Separate optargs to short options: 19622f60eb46Smrg -W*) 19632f60eb46Smrg func_split_short_opt "$_G_opt" 19642f60eb46Smrg set dummy "$func_split_short_opt_name" \ 19652f60eb46Smrg "$func_split_short_opt_arg" ${1+"$@"} 19662f60eb46Smrg shift 19672f60eb46Smrg ;; 19682f60eb46Smrg 19692f60eb46Smrg # Separate non-argument short options: 19702f60eb46Smrg -\?*|-h*|-v*|-x*) 19712f60eb46Smrg func_split_short_opt "$_G_opt" 19722f60eb46Smrg set dummy "$func_split_short_opt_name" \ 19732f60eb46Smrg "-$func_split_short_opt_arg" ${1+"$@"} 19742f60eb46Smrg shift 19752f60eb46Smrg ;; 19762f60eb46Smrg 1977efb46889Smrg --) _G_parse_options_requote=: ; break ;; 19782f60eb46Smrg -*) func_fatal_help "unrecognised option: '$_G_opt'" ;; 1979efb46889Smrg *) set dummy "$_G_opt" ${1+"$@"}; shift 1980efb46889Smrg _G_match_parse_options=false 1981efb46889Smrg break 1982efb46889Smrg ;; 19832f60eb46Smrg esac 1984efb46889Smrg 1985efb46889Smrg if $_G_match_parse_options; then 1986efb46889Smrg _G_parse_options_requote=: 1987efb46889Smrg fi 19882f60eb46Smrg done 19892f60eb46Smrg 1990efb46889Smrg if $_G_parse_options_requote; then 1991efb46889Smrg # save modified positional parameters for caller 1992efb46889Smrg func_quote eval ${1+"$@"} 1993efb46889Smrg func_parse_options_result=$func_quote_result 1994efb46889Smrg fi 1995692f60a7Smrg} 1996692f60a7Smrg 1997c3c9db83Smrg 19982f60eb46Smrg# func_validate_options [ARG]... 19992f60eb46Smrg# ------------------------------ 20002f60eb46Smrg# Perform any sanity checks on option settings and/or unconsumed 20012f60eb46Smrg# arguments. 20022f60eb46Smrgfunc_hookable func_validate_options 20032f60eb46Smrgfunc_validate_options () 2004692f60a7Smrg{ 20052f60eb46Smrg $debug_cmd 2006c3c9db83Smrg 20072f60eb46Smrg # Display all warnings if -W was not given. 20082f60eb46Smrg test -n "$opt_warning_types" || opt_warning_types=" $warning_categories" 2009c3c9db83Smrg 20102f60eb46Smrg func_run_hooks func_validate_options ${1+"$@"} 2011efb46889Smrg func_propagate_result func_run_hooks func_validate_options 2012692f60a7Smrg 20132f60eb46Smrg # Bail if the options were screwed! 20142f60eb46Smrg $exit_cmd $EXIT_FAILURE 20153f6d0e1dSmrg} 2016c3c9db83Smrg 2017c3c9db83Smrg 20183f6d0e1dSmrg 20192f60eb46Smrg## ----------------- ## 20202f60eb46Smrg## Helper functions. ## 20212f60eb46Smrg## ----------------- ## 2022c3c9db83Smrg 20232f60eb46Smrg# This section contains the helper functions used by the rest of the 20242f60eb46Smrg# hookable option parser framework in ascii-betical order. 20252f60eb46Smrg 20262f60eb46Smrg 20272f60eb46Smrg# func_fatal_help ARG... 20282f60eb46Smrg# ---------------------- 20292f60eb46Smrg# Echo program name prefixed message to standard error, followed by 20302f60eb46Smrg# a help hint, and exit. 20312f60eb46Smrgfunc_fatal_help () 2032c3c9db83Smrg{ 20332f60eb46Smrg $debug_cmd 20343f6d0e1dSmrg 20352f60eb46Smrg eval \$ECHO \""Usage: $usage"\" 20362f60eb46Smrg eval \$ECHO \""$fatal_help"\" 20372f60eb46Smrg func_error ${1+"$@"} 20382f60eb46Smrg exit $EXIT_FAILURE 2039c3c9db83Smrg} 2040c3c9db83Smrg 20412f60eb46Smrg 20422f60eb46Smrg# func_help 20432f60eb46Smrg# --------- 20442f60eb46Smrg# Echo long help message to standard output and exit. 2045c3c9db83Smrgfunc_help () 2046c3c9db83Smrg{ 20472f60eb46Smrg $debug_cmd 20482f60eb46Smrg 20492f60eb46Smrg func_usage_message 20502f60eb46Smrg $ECHO "$long_help_message" 20512f60eb46Smrg exit 0 2052c3c9db83Smrg} 2053c3c9db83Smrg 20542f60eb46Smrg 20552f60eb46Smrg# func_missing_arg ARGNAME 20562f60eb46Smrg# ------------------------ 2057c3c9db83Smrg# Echo program name prefixed message to standard error and set global 2058c3c9db83Smrg# exit_cmd. 2059c3c9db83Smrgfunc_missing_arg () 2060c3c9db83Smrg{ 20612f60eb46Smrg $debug_cmd 20623f6d0e1dSmrg 20632f60eb46Smrg func_error "Missing argument for '$1'." 2064c3c9db83Smrg exit_cmd=exit 2065692f60a7Smrg} 2066692f60a7Smrg 206785ee4c00Smrg 20682f60eb46Smrg# func_split_equals STRING 20692f60eb46Smrg# ------------------------ 2070efb46889Smrg# Set func_split_equals_lhs and func_split_equals_rhs shell variables 2071efb46889Smrg# after splitting STRING at the '=' sign. 20722f60eb46Smrgtest -z "$_G_HAVE_XSI_OPS" \ 20732f60eb46Smrg && (eval 'x=a/b/c; 20742f60eb46Smrg test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ 20752f60eb46Smrg && _G_HAVE_XSI_OPS=yes 20762f60eb46Smrg 20772f60eb46Smrgif test yes = "$_G_HAVE_XSI_OPS" 20782f60eb46Smrgthen 20792f60eb46Smrg # This is an XSI compatible shell, allowing a faster implementation... 20802f60eb46Smrg eval 'func_split_equals () 20812f60eb46Smrg { 20822f60eb46Smrg $debug_cmd 20832f60eb46Smrg 20842f60eb46Smrg func_split_equals_lhs=${1%%=*} 20852f60eb46Smrg func_split_equals_rhs=${1#*=} 2086efb46889Smrg if test "x$func_split_equals_lhs" = "x$1"; then 2087efb46889Smrg func_split_equals_rhs= 2088efb46889Smrg fi 20892f60eb46Smrg }' 20902f60eb46Smrgelse 20912f60eb46Smrg # ...otherwise fall back to using expr, which is often a shell builtin. 20922f60eb46Smrg func_split_equals () 20932f60eb46Smrg { 20942f60eb46Smrg $debug_cmd 20952f60eb46Smrg 20962f60eb46Smrg func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'` 20972f60eb46Smrg func_split_equals_rhs= 2098efb46889Smrg test "x$func_split_equals_lhs=" = "x$1" \ 20992f60eb46Smrg || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'` 21002f60eb46Smrg } 21012f60eb46Smrgfi #func_split_equals 21022f60eb46Smrg 21032f60eb46Smrg 21042f60eb46Smrg# func_split_short_opt SHORTOPT 21052f60eb46Smrg# ----------------------------- 21063f6d0e1dSmrg# Set func_split_short_opt_name and func_split_short_opt_arg shell 21073f6d0e1dSmrg# variables after splitting SHORTOPT after the 2nd character. 21082f60eb46Smrgif test yes = "$_G_HAVE_XSI_OPS" 21092f60eb46Smrgthen 21102f60eb46Smrg # This is an XSI compatible shell, allowing a faster implementation... 21112f60eb46Smrg eval 'func_split_short_opt () 21122f60eb46Smrg { 21132f60eb46Smrg $debug_cmd 21142f60eb46Smrg 21152f60eb46Smrg func_split_short_opt_arg=${1#??} 21162f60eb46Smrg func_split_short_opt_name=${1%"$func_split_short_opt_arg"} 21172f60eb46Smrg }' 21182f60eb46Smrgelse 21192f60eb46Smrg # ...otherwise fall back to using expr, which is often a shell builtin. 21202f60eb46Smrg func_split_short_opt () 21212f60eb46Smrg { 21222f60eb46Smrg $debug_cmd 21232f60eb46Smrg 2124efb46889Smrg func_split_short_opt_name=`expr "x$1" : 'x\(-.\)'` 21252f60eb46Smrg func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'` 21262f60eb46Smrg } 21272f60eb46Smrgfi #func_split_short_opt 21282f60eb46Smrg 21292f60eb46Smrg 21302f60eb46Smrg# func_usage 21312f60eb46Smrg# ---------- 21322f60eb46Smrg# Echo short help message to standard output and exit. 21332f60eb46Smrgfunc_usage () 21343f6d0e1dSmrg{ 21352f60eb46Smrg $debug_cmd 213685ee4c00Smrg 21372f60eb46Smrg func_usage_message 21382f60eb46Smrg $ECHO "Run '$progname --help |${PAGER-more}' for full usage" 21392f60eb46Smrg exit 0 21402f60eb46Smrg} 21413f6d0e1dSmrg 21423f6d0e1dSmrg 21432f60eb46Smrg# func_usage_message 21442f60eb46Smrg# ------------------ 21452f60eb46Smrg# Echo short help message to standard output. 21462f60eb46Smrgfunc_usage_message () 21473f6d0e1dSmrg{ 21482f60eb46Smrg $debug_cmd 21493f6d0e1dSmrg 21502f60eb46Smrg eval \$ECHO \""Usage: $usage"\" 21512f60eb46Smrg echo 21522f60eb46Smrg $SED -n 's|^# || 21532f60eb46Smrg /^Written by/{ 21542f60eb46Smrg x;p;x 21552f60eb46Smrg } 21562f60eb46Smrg h 21572f60eb46Smrg /^Written by/q' < "$progpath" 21582f60eb46Smrg echo 21592f60eb46Smrg eval \$ECHO \""$usage_message"\" 21602f60eb46Smrg} 21613f6d0e1dSmrg 2162c3c9db83Smrg 21632f60eb46Smrg# func_version 21642f60eb46Smrg# ------------ 21652f60eb46Smrg# Echo version message to standard output and exit. 2166efb46889Smrg# The version message is extracted from the calling file's header 2167efb46889Smrg# comments, with leading '# ' stripped: 2168efb46889Smrg# 1. First display the progname and version 2169efb46889Smrg# 2. Followed by the header comment line matching /^# Written by / 2170efb46889Smrg# 3. Then a blank line followed by the first following line matching 2171efb46889Smrg# /^# Copyright / 2172efb46889Smrg# 4. Immediately followed by any lines between the previous matches, 2173efb46889Smrg# except lines preceding the intervening completely blank line. 2174efb46889Smrg# For example, see the header comments of this file. 21752f60eb46Smrgfunc_version () 21762f60eb46Smrg{ 21772f60eb46Smrg $debug_cmd 2178c3c9db83Smrg 21792f60eb46Smrg printf '%s\n' "$progname $scriptversion" 21802f60eb46Smrg $SED -n ' 2181efb46889Smrg /^# Written by /!b 2182efb46889Smrg s|^# ||; p; n 2183efb46889Smrg 2184efb46889Smrg :fwd2blnk 2185efb46889Smrg /./ { 2186efb46889Smrg n 2187efb46889Smrg b fwd2blnk 21882f60eb46Smrg } 2189efb46889Smrg p; n 2190efb46889Smrg 2191efb46889Smrg :holdwrnt 2192efb46889Smrg s|^# || 2193efb46889Smrg s|^# *$|| 2194efb46889Smrg /^Copyright /!{ 2195efb46889Smrg /./H 2196efb46889Smrg n 2197efb46889Smrg b holdwrnt 21982f60eb46Smrg } 2199efb46889Smrg 2200efb46889Smrg s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2| 2201efb46889Smrg G 2202efb46889Smrg s|\(\n\)\n*|\1|g 2203efb46889Smrg p; q' < "$progpath" 2204c3c9db83Smrg 22052f60eb46Smrg exit $? 22062f60eb46Smrg} 2207692f60a7Smrg 2208692f60a7Smrg 22092f60eb46Smrg# Local variables: 22102f60eb46Smrg# mode: shell-script 22112f60eb46Smrg# sh-indentation: 2 22122f60eb46Smrg# eval: (add-hook 'before-save-hook 'time-stamp) 2213efb46889Smrg# time-stamp-pattern: "30/scriptversion=%:y-%02m-%02d.%02H; # UTC" 22142f60eb46Smrg# time-stamp-time-zone: "UTC" 22152f60eb46Smrg# End: 2216692f60a7Smrg 22172f60eb46Smrg# Set a version string. 2218efb46889Smrgscriptversion='(GNU libtool) 2.4.7' 221985ee4c00Smrg 2220c3c9db83Smrg 22212f60eb46Smrg# func_echo ARG... 22222f60eb46Smrg# ---------------- 22232f60eb46Smrg# Libtool also displays the current mode in messages, so override 22242f60eb46Smrg# funclib.sh func_echo with this custom definition. 22252f60eb46Smrgfunc_echo () 22263f6d0e1dSmrg{ 22272f60eb46Smrg $debug_cmd 22283f6d0e1dSmrg 22292f60eb46Smrg _G_message=$* 22303f6d0e1dSmrg 22312f60eb46Smrg func_echo_IFS=$IFS 22322f60eb46Smrg IFS=$nl 22332f60eb46Smrg for _G_line in $_G_message; do 22342f60eb46Smrg IFS=$func_echo_IFS 22352f60eb46Smrg $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line" 22362f60eb46Smrg done 22372f60eb46Smrg IFS=$func_echo_IFS 22382f60eb46Smrg} 22393f6d0e1dSmrg 22402f60eb46Smrg 22412f60eb46Smrg# func_warning ARG... 22422f60eb46Smrg# ------------------- 22432f60eb46Smrg# Libtool warnings are not categorized, so override funclib.sh 22442f60eb46Smrg# func_warning with this simpler definition. 22452f60eb46Smrgfunc_warning () 22463f6d0e1dSmrg{ 22472f60eb46Smrg $debug_cmd 22483f6d0e1dSmrg 22492f60eb46Smrg $warning_func ${1+"$@"} 22502f60eb46Smrg} 22513f6d0e1dSmrg 22523f6d0e1dSmrg 22532f60eb46Smrg## ---------------- ## 22542f60eb46Smrg## Options parsing. ## 22552f60eb46Smrg## ---------------- ## 22562f60eb46Smrg 22572f60eb46Smrg# Hook in the functions to make sure our own options are parsed during 22582f60eb46Smrg# the option parsing loop. 22592f60eb46Smrg 22602f60eb46Smrgusage='$progpath [OPTION]... [MODE-ARG]...' 22612f60eb46Smrg 22622f60eb46Smrg# Short help message in response to '-h'. 22632f60eb46Smrgusage_message="Options: 22642f60eb46Smrg --config show all configuration variables 22652f60eb46Smrg --debug enable verbose shell tracing 22662f60eb46Smrg -n, --dry-run display commands without modifying any files 22672f60eb46Smrg --features display basic configuration information and exit 22682f60eb46Smrg --mode=MODE use operation mode MODE 22692f60eb46Smrg --no-warnings equivalent to '-Wnone' 22702f60eb46Smrg --preserve-dup-deps don't remove duplicate dependency libraries 22712f60eb46Smrg --quiet, --silent don't print informational messages 22722f60eb46Smrg --tag=TAG use configuration variables from tag TAG 22732f60eb46Smrg -v, --verbose print more informational messages than default 22742f60eb46Smrg --version print version information 22752f60eb46Smrg -W, --warnings=CATEGORY report the warnings falling in CATEGORY [all] 22762f60eb46Smrg -h, --help, --help-all print short, long, or detailed help message 22772f60eb46Smrg" 22783f6d0e1dSmrg 22792f60eb46Smrg# Additional text appended to 'usage_message' in response to '--help'. 22802f60eb46Smrgfunc_help () 22813f6d0e1dSmrg{ 22822f60eb46Smrg $debug_cmd 22832f60eb46Smrg 22842f60eb46Smrg func_usage_message 22852f60eb46Smrg $ECHO "$long_help_message 22862f60eb46Smrg 22872f60eb46SmrgMODE must be one of the following: 22882f60eb46Smrg 22892f60eb46Smrg clean remove files from the build directory 22902f60eb46Smrg compile compile a source file into a libtool object 22912f60eb46Smrg execute automatically set library path, then run a program 22922f60eb46Smrg finish complete the installation of libtool libraries 22932f60eb46Smrg install install libraries or executables 22942f60eb46Smrg link create a library or an executable 22952f60eb46Smrg uninstall remove libraries from an installed directory 22962f60eb46Smrg 22972f60eb46SmrgMODE-ARGS vary depending on the MODE. When passed as first option, 22982f60eb46Smrg'--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that. 22992f60eb46SmrgTry '$progname --help --mode=MODE' for a more detailed description of MODE. 23002f60eb46Smrg 23012f60eb46SmrgWhen reporting a bug, please describe a test case to reproduce it and 23022f60eb46Smrginclude the following information: 23032f60eb46Smrg 23042f60eb46Smrg host-triplet: $host 23052f60eb46Smrg shell: $SHELL 23062f60eb46Smrg compiler: $LTCC 23072f60eb46Smrg compiler flags: $LTCFLAGS 23082f60eb46Smrg linker: $LD (gnu? $with_gnu_ld) 2309efb46889Smrg version: $progname (GNU libtool) 2.4.7 23102f60eb46Smrg automake: `($AUTOMAKE --version) 2>/dev/null |$SED 1q` 23112f60eb46Smrg autoconf: `($AUTOCONF --version) 2>/dev/null |$SED 1q` 23122f60eb46Smrg 23132f60eb46SmrgReport bugs to <bug-libtool@gnu.org>. 2314efb46889SmrgGNU libtool home page: <http://www.gnu.org/software/libtool/>. 23152f60eb46SmrgGeneral help using GNU software: <http://www.gnu.org/gethelp/>." 23162f60eb46Smrg exit 0 23172f60eb46Smrg} 23183f6d0e1dSmrg 23193f6d0e1dSmrg 23202f60eb46Smrg# func_lo2o OBJECT-NAME 23212f60eb46Smrg# --------------------- 23222f60eb46Smrg# Transform OBJECT-NAME from a '.lo' suffix to the platform specific 23232f60eb46Smrg# object suffix. 23242f60eb46Smrg 23252f60eb46Smrglo2o=s/\\.lo\$/.$objext/ 23262f60eb46Smrgo2lo=s/\\.$objext\$/.lo/ 23272f60eb46Smrg 23282f60eb46Smrgif test yes = "$_G_HAVE_XSI_OPS"; then 23292f60eb46Smrg eval 'func_lo2o () 23302f60eb46Smrg { 23312f60eb46Smrg case $1 in 23322f60eb46Smrg *.lo) func_lo2o_result=${1%.lo}.$objext ;; 23332f60eb46Smrg * ) func_lo2o_result=$1 ;; 23342f60eb46Smrg esac 23352f60eb46Smrg }' 23362f60eb46Smrg 23372f60eb46Smrg # func_xform LIBOBJ-OR-SOURCE 23382f60eb46Smrg # --------------------------- 23392f60eb46Smrg # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise) 23402f60eb46Smrg # suffix to a '.lo' libtool-object suffix. 23412f60eb46Smrg eval 'func_xform () 23422f60eb46Smrg { 23432f60eb46Smrg func_xform_result=${1%.*}.lo 23442f60eb46Smrg }' 23452f60eb46Smrgelse 23462f60eb46Smrg # ...otherwise fall back to using sed. 23472f60eb46Smrg func_lo2o () 23482f60eb46Smrg { 23492f60eb46Smrg func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"` 23502f60eb46Smrg } 23512f60eb46Smrg 23522f60eb46Smrg func_xform () 23532f60eb46Smrg { 23542f60eb46Smrg func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'` 23552f60eb46Smrg } 23562f60eb46Smrgfi 23573f6d0e1dSmrg 23583f6d0e1dSmrg 23592f60eb46Smrg# func_fatal_configuration ARG... 23602f60eb46Smrg# ------------------------------- 2361c3c9db83Smrg# Echo program name prefixed message to standard error, followed by 2362c3c9db83Smrg# a configuration failure hint, and exit. 2363c3c9db83Smrgfunc_fatal_configuration () 2364c3c9db83Smrg{ 2365efb46889Smrg func_fatal_error ${1+"$@"} \ 23662f60eb46Smrg "See the $PACKAGE documentation for more information." \ 23672f60eb46Smrg "Fatal configuration error." 2368c3c9db83Smrg} 236954569438Smrg 237085ee4c00Smrg 2371c3c9db83Smrg# func_config 23722f60eb46Smrg# ----------- 2373c3c9db83Smrg# Display the configuration for all the tags in this script. 2374c3c9db83Smrgfunc_config () 2375c3c9db83Smrg{ 2376c3c9db83Smrg re_begincf='^# ### BEGIN LIBTOOL' 2377c3c9db83Smrg re_endcf='^# ### END LIBTOOL' 2378c3c9db83Smrg 2379c3c9db83Smrg # Default configuration. 2380c3c9db83Smrg $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" 2381692f60a7Smrg 2382692f60a7Smrg # Now print the configurations for the tags. 2383692f60a7Smrg for tagname in $taglist; do 2384c3c9db83Smrg $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" 2385692f60a7Smrg done 23862e71ea71Smrg 2387c3c9db83Smrg exit $? 2388c3c9db83Smrg} 23892e71ea71Smrg 23902f60eb46Smrg 2391c3c9db83Smrg# func_features 23922f60eb46Smrg# ------------- 2393c3c9db83Smrg# Display the features supported by this script. 2394c3c9db83Smrgfunc_features () 2395c3c9db83Smrg{ 23963f6d0e1dSmrg echo "host: $host" 23972f60eb46Smrg if test yes = "$build_libtool_libs"; then 23983f6d0e1dSmrg echo "enable shared libraries" 2399692f60a7Smrg else 24003f6d0e1dSmrg echo "disable shared libraries" 2401692f60a7Smrg fi 24022f60eb46Smrg if test yes = "$build_old_libs"; then 24033f6d0e1dSmrg echo "enable static libraries" 2404692f60a7Smrg else 24053f6d0e1dSmrg echo "disable static libraries" 2406692f60a7Smrg fi 2407c3c9db83Smrg 2408692f60a7Smrg exit $? 2409c3c9db83Smrg} 2410692f60a7Smrg 24112f60eb46Smrg 24122f60eb46Smrg# func_enable_tag TAGNAME 24132f60eb46Smrg# ----------------------- 2414c3c9db83Smrg# Verify that TAGNAME is valid, and either flag an error and exit, or 2415c3c9db83Smrg# enable the TAGNAME tag. We also add TAGNAME to the global $taglist 2416c3c9db83Smrg# variable here. 2417c3c9db83Smrgfunc_enable_tag () 2418c3c9db83Smrg{ 24192f60eb46Smrg # Global variable: 24202f60eb46Smrg tagname=$1 2421692f60a7Smrg 24222f60eb46Smrg re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" 24232f60eb46Smrg re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" 24242f60eb46Smrg sed_extractcf=/$re_begincf/,/$re_endcf/p 242585ee4c00Smrg 24262f60eb46Smrg # Validate tagname. 24272f60eb46Smrg case $tagname in 24282f60eb46Smrg *[!-_A-Za-z0-9,/]*) 24292f60eb46Smrg func_fatal_error "invalid tag name: $tagname" 24302f60eb46Smrg ;; 24312f60eb46Smrg esac 2432692f60a7Smrg 24332f60eb46Smrg # Don't test for the "default" C tag, as we know it's 24342f60eb46Smrg # there but not specially marked. 24352f60eb46Smrg case $tagname in 24362f60eb46Smrg CC) ;; 2437c3c9db83Smrg *) 24382f60eb46Smrg if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then 24392f60eb46Smrg taglist="$taglist $tagname" 24402f60eb46Smrg 24412f60eb46Smrg # Evaluate the configuration. Be careful to quote the path 24422f60eb46Smrg # and the sed script, to avoid splitting on whitespace, but 24432f60eb46Smrg # also don't use non-portable quotes within backquotes within 24442f60eb46Smrg # quotes we have to do it in 2 steps: 24452f60eb46Smrg extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` 24462f60eb46Smrg eval "$extractedcf" 24472f60eb46Smrg else 24482f60eb46Smrg func_error "ignoring unknown tag $tagname" 24492f60eb46Smrg fi 24502f60eb46Smrg ;; 24512f60eb46Smrg esac 2452c3c9db83Smrg} 2453c3c9db83Smrg 24542f60eb46Smrg 24553f6d0e1dSmrg# func_check_version_match 24562f60eb46Smrg# ------------------------ 24573f6d0e1dSmrg# Ensure that we are using m4 macros, and libtool script from the same 24583f6d0e1dSmrg# release of libtool. 24593f6d0e1dSmrgfunc_check_version_match () 2460c3c9db83Smrg{ 24612f60eb46Smrg if test "$package_revision" != "$macro_revision"; then 24622f60eb46Smrg if test "$VERSION" != "$macro_version"; then 24632f60eb46Smrg if test -z "$macro_version"; then 24642f60eb46Smrg cat >&2 <<_LT_EOF 24653f6d0e1dSmrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 24663f6d0e1dSmrg$progname: definition of this LT_INIT comes from an older release. 24673f6d0e1dSmrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 24683f6d0e1dSmrg$progname: and run autoconf again. 24693f6d0e1dSmrg_LT_EOF 24702f60eb46Smrg else 24712f60eb46Smrg cat >&2 <<_LT_EOF 24723f6d0e1dSmrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 24733f6d0e1dSmrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version. 24743f6d0e1dSmrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 24753f6d0e1dSmrg$progname: and run autoconf again. 24763f6d0e1dSmrg_LT_EOF 24772f60eb46Smrg fi 24782f60eb46Smrg else 24792f60eb46Smrg cat >&2 <<_LT_EOF 24803f6d0e1dSmrg$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, 24813f6d0e1dSmrg$progname: but the definition of this LT_INIT comes from revision $macro_revision. 24823f6d0e1dSmrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision 24833f6d0e1dSmrg$progname: of $PACKAGE $VERSION and run autoconf again. 24843f6d0e1dSmrg_LT_EOF 24852f60eb46Smrg fi 24863f6d0e1dSmrg 24872f60eb46Smrg exit $EXIT_MISMATCH 24882f60eb46Smrg fi 24893f6d0e1dSmrg} 24903f6d0e1dSmrg 24913f6d0e1dSmrg 24922f60eb46Smrg# libtool_options_prep [ARG]... 24932f60eb46Smrg# ----------------------------- 24942f60eb46Smrg# Preparation for options parsed by libtool. 24952f60eb46Smrglibtool_options_prep () 24962f60eb46Smrg{ 24972f60eb46Smrg $debug_mode 24983f6d0e1dSmrg 24992f60eb46Smrg # Option defaults: 25002f60eb46Smrg opt_config=false 25012f60eb46Smrg opt_dlopen= 25022f60eb46Smrg opt_dry_run=false 25032f60eb46Smrg opt_help=false 25042f60eb46Smrg opt_mode= 25052f60eb46Smrg opt_preserve_dup_deps=false 25062f60eb46Smrg opt_quiet=false 25073f6d0e1dSmrg 25082f60eb46Smrg nonopt= 25092f60eb46Smrg preserve_args= 25103f6d0e1dSmrg 2511efb46889Smrg _G_rc_lt_options_prep=: 2512efb46889Smrg 25132f60eb46Smrg # Shorthand for --mode=foo, only valid as the first argument 25142f60eb46Smrg case $1 in 25152f60eb46Smrg clean|clea|cle|cl) 25162f60eb46Smrg shift; set dummy --mode clean ${1+"$@"}; shift 25172f60eb46Smrg ;; 25182f60eb46Smrg compile|compil|compi|comp|com|co|c) 25192f60eb46Smrg shift; set dummy --mode compile ${1+"$@"}; shift 25202f60eb46Smrg ;; 25212f60eb46Smrg execute|execut|execu|exec|exe|ex|e) 25222f60eb46Smrg shift; set dummy --mode execute ${1+"$@"}; shift 25232f60eb46Smrg ;; 25242f60eb46Smrg finish|finis|fini|fin|fi|f) 25252f60eb46Smrg shift; set dummy --mode finish ${1+"$@"}; shift 25262f60eb46Smrg ;; 25272f60eb46Smrg install|instal|insta|inst|ins|in|i) 25282f60eb46Smrg shift; set dummy --mode install ${1+"$@"}; shift 25292f60eb46Smrg ;; 25302f60eb46Smrg link|lin|li|l) 25312f60eb46Smrg shift; set dummy --mode link ${1+"$@"}; shift 25322f60eb46Smrg ;; 25332f60eb46Smrg uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) 25342f60eb46Smrg shift; set dummy --mode uninstall ${1+"$@"}; shift 25352f60eb46Smrg ;; 2536efb46889Smrg *) 2537efb46889Smrg _G_rc_lt_options_prep=false 2538efb46889Smrg ;; 25392f60eb46Smrg esac 25402f60eb46Smrg 2541efb46889Smrg if $_G_rc_lt_options_prep; then 2542efb46889Smrg # Pass back the list of options. 2543efb46889Smrg func_quote eval ${1+"$@"} 2544efb46889Smrg libtool_options_prep_result=$func_quote_result 2545efb46889Smrg fi 25462f60eb46Smrg} 25472f60eb46Smrgfunc_add_hook func_options_prep libtool_options_prep 25482e71ea71Smrg 2549692f60a7Smrg 25502f60eb46Smrg# libtool_parse_options [ARG]... 25512f60eb46Smrg# --------------------------------- 25522f60eb46Smrg# Provide handling for libtool specific options. 25532f60eb46Smrglibtool_parse_options () 25543f6d0e1dSmrg{ 25552f60eb46Smrg $debug_cmd 2556c3c9db83Smrg 2557efb46889Smrg _G_rc_lt_parse_options=false 2558efb46889Smrg 25592f60eb46Smrg # Perform our own loop to consume as many options as possible in 25602f60eb46Smrg # each iteration. 25612f60eb46Smrg while test $# -gt 0; do 2562efb46889Smrg _G_match_lt_parse_options=: 25632f60eb46Smrg _G_opt=$1 25642f60eb46Smrg shift 25652f60eb46Smrg case $_G_opt in 25662f60eb46Smrg --dry-run|--dryrun|-n) 25672f60eb46Smrg opt_dry_run=: 25682f60eb46Smrg ;; 25692f60eb46Smrg 25702f60eb46Smrg --config) func_config ;; 25712f60eb46Smrg 25722f60eb46Smrg --dlopen|-dlopen) 25732f60eb46Smrg opt_dlopen="${opt_dlopen+$opt_dlopen 25742f60eb46Smrg}$1" 25752f60eb46Smrg shift 25762f60eb46Smrg ;; 25772f60eb46Smrg 25782f60eb46Smrg --preserve-dup-deps) 25792f60eb46Smrg opt_preserve_dup_deps=: ;; 25802f60eb46Smrg 25812f60eb46Smrg --features) func_features ;; 25822f60eb46Smrg 25832f60eb46Smrg --finish) set dummy --mode finish ${1+"$@"}; shift ;; 25842f60eb46Smrg 25852f60eb46Smrg --help) opt_help=: ;; 25862f60eb46Smrg 25872f60eb46Smrg --help-all) opt_help=': help-all' ;; 25882f60eb46Smrg 25892f60eb46Smrg --mode) test $# = 0 && func_missing_arg $_G_opt && break 25902f60eb46Smrg opt_mode=$1 25912f60eb46Smrg case $1 in 25922f60eb46Smrg # Valid mode arguments: 25932f60eb46Smrg clean|compile|execute|finish|install|link|relink|uninstall) ;; 25942f60eb46Smrg 25952f60eb46Smrg # Catch anything else as an error 25962f60eb46Smrg *) func_error "invalid argument for $_G_opt" 25972f60eb46Smrg exit_cmd=exit 25982f60eb46Smrg break 25992f60eb46Smrg ;; 26002f60eb46Smrg esac 26012f60eb46Smrg shift 26022f60eb46Smrg ;; 26032f60eb46Smrg 26042f60eb46Smrg --no-silent|--no-quiet) 26052f60eb46Smrg opt_quiet=false 26062f60eb46Smrg func_append preserve_args " $_G_opt" 26072f60eb46Smrg ;; 26082f60eb46Smrg 26092f60eb46Smrg --no-warnings|--no-warning|--no-warn) 26102f60eb46Smrg opt_warning=false 26112f60eb46Smrg func_append preserve_args " $_G_opt" 26122f60eb46Smrg ;; 26132f60eb46Smrg 26142f60eb46Smrg --no-verbose) 26152f60eb46Smrg opt_verbose=false 26162f60eb46Smrg func_append preserve_args " $_G_opt" 26172f60eb46Smrg ;; 26182f60eb46Smrg 26192f60eb46Smrg --silent|--quiet) 26202f60eb46Smrg opt_quiet=: 26212f60eb46Smrg opt_verbose=false 26222f60eb46Smrg func_append preserve_args " $_G_opt" 26232f60eb46Smrg ;; 26242f60eb46Smrg 26252f60eb46Smrg --tag) test $# = 0 && func_missing_arg $_G_opt && break 26262f60eb46Smrg opt_tag=$1 26272f60eb46Smrg func_append preserve_args " $_G_opt $1" 26282f60eb46Smrg func_enable_tag "$1" 26292f60eb46Smrg shift 26302f60eb46Smrg ;; 26312f60eb46Smrg 26322f60eb46Smrg --verbose|-v) opt_quiet=false 26332f60eb46Smrg opt_verbose=: 26342f60eb46Smrg func_append preserve_args " $_G_opt" 26352f60eb46Smrg ;; 26362f60eb46Smrg 2637efb46889Smrg # An option not handled by this hook function: 2638efb46889Smrg *) set dummy "$_G_opt" ${1+"$@"} ; shift 2639efb46889Smrg _G_match_lt_parse_options=false 2640efb46889Smrg break 2641efb46889Smrg ;; 26422f60eb46Smrg esac 2643efb46889Smrg $_G_match_lt_parse_options && _G_rc_lt_parse_options=: 26442f60eb46Smrg done 26453f6d0e1dSmrg 2646efb46889Smrg if $_G_rc_lt_parse_options; then 2647efb46889Smrg # save modified positional parameters for caller 2648efb46889Smrg func_quote eval ${1+"$@"} 2649efb46889Smrg libtool_parse_options_result=$func_quote_result 2650efb46889Smrg fi 26512f60eb46Smrg} 26522f60eb46Smrgfunc_add_hook func_parse_options libtool_parse_options 2653c3c9db83Smrg 265485ee4c00Smrg 2655c3c9db83Smrg 26562f60eb46Smrg# libtool_validate_options [ARG]... 26572f60eb46Smrg# --------------------------------- 26582f60eb46Smrg# Perform any sanity checks on option settings and/or unconsumed 26592f60eb46Smrg# arguments. 26602f60eb46Smrglibtool_validate_options () 26612f60eb46Smrg{ 26622f60eb46Smrg # save first non-option argument 26632f60eb46Smrg if test 0 -lt $#; then 26642f60eb46Smrg nonopt=$1 26652f60eb46Smrg shift 2666c3c9db83Smrg fi 2667c3c9db83Smrg 26682f60eb46Smrg # preserve --debug 26692f60eb46Smrg test : = "$debug_cmd" || func_append preserve_args " --debug" 2670c3c9db83Smrg 26712f60eb46Smrg case $host in 26722f60eb46Smrg # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452 26732f60eb46Smrg # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788 26742f60eb46Smrg *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*) 26752f60eb46Smrg # don't eliminate duplications in $postdeps and $predeps 26762f60eb46Smrg opt_duplicate_compiler_generated_deps=: 26772f60eb46Smrg ;; 26782f60eb46Smrg *) 26792f60eb46Smrg opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps 26802f60eb46Smrg ;; 26812f60eb46Smrg esac 2682692f60a7Smrg 26832f60eb46Smrg $opt_help || { 26842f60eb46Smrg # Sanity checks first: 26852f60eb46Smrg func_check_version_match 26862f60eb46Smrg 26872f60eb46Smrg test yes != "$build_libtool_libs" \ 26882f60eb46Smrg && test yes != "$build_old_libs" \ 26892f60eb46Smrg && func_fatal_configuration "not configured to build any kind of library" 26902f60eb46Smrg 26912f60eb46Smrg # Darwin sucks 26922f60eb46Smrg eval std_shrext=\"$shrext_cmds\" 26932f60eb46Smrg 26942f60eb46Smrg # Only execute mode is allowed to have -dlopen flags. 26952f60eb46Smrg if test -n "$opt_dlopen" && test execute != "$opt_mode"; then 26962f60eb46Smrg func_error "unrecognized option '-dlopen'" 26972f60eb46Smrg $ECHO "$help" 1>&2 26982f60eb46Smrg exit $EXIT_FAILURE 26992f60eb46Smrg fi 2700c3c9db83Smrg 27012f60eb46Smrg # Change the help message to a mode-specific one. 27022f60eb46Smrg generic_help=$help 27032f60eb46Smrg help="Try '$progname --help --mode=$opt_mode' for more information." 27042f60eb46Smrg } 2705c3c9db83Smrg 27062f60eb46Smrg # Pass back the unparsed argument list 2707efb46889Smrg func_quote eval ${1+"$@"} 2708efb46889Smrg libtool_validate_options_result=$func_quote_result 27093f6d0e1dSmrg} 27102f60eb46Smrgfunc_add_hook func_validate_options libtool_validate_options 2711c3c9db83Smrg 2712c3c9db83Smrg 27132f60eb46Smrg# Process options as early as possible so that --help and --version 27142f60eb46Smrg# can return quickly. 27152f60eb46Smrgfunc_options ${1+"$@"} 27162f60eb46Smrgeval set dummy "$func_options_result"; shift 27172f60eb46Smrg 2718692f60a7Smrg 2719692f60a7Smrg 27203f6d0e1dSmrg## ----------- ## 27213f6d0e1dSmrg## Main. ## 27223f6d0e1dSmrg## ----------- ## 2723692f60a7Smrg 27242f60eb46Smrgmagic='%%%MAGIC variable%%%' 27252f60eb46Smrgmagic_exe='%%%MAGIC EXE variable%%%' 27262f60eb46Smrg 27272f60eb46Smrg# Global variables. 27282f60eb46Smrgextracted_archives= 27292f60eb46Smrgextracted_serial=0 27302f60eb46Smrg 27312f60eb46Smrg# If this variable is set in any of the actions, the command in it 27322f60eb46Smrg# will be execed at the end. This prevents here-documents from being 27332f60eb46Smrg# left over by shells. 27342f60eb46Smrgexec_cmd= 27352f60eb46Smrg 27362f60eb46Smrg 27372f60eb46Smrg# A function that is used when there is no print builtin or printf. 27382f60eb46Smrgfunc_fallback_echo () 27392f60eb46Smrg{ 27402f60eb46Smrg eval 'cat <<_LTECHO_EOF 27412f60eb46Smrg$1 27422f60eb46Smrg_LTECHO_EOF' 27432f60eb46Smrg} 27442f60eb46Smrg 27452f60eb46Smrg# func_generated_by_libtool 27462f60eb46Smrg# True iff stdin has been generated by Libtool. This function is only 27472f60eb46Smrg# a basic sanity check; it will hardly flush out determined imposters. 27482f60eb46Smrgfunc_generated_by_libtool_p () 27492f60eb46Smrg{ 27502f60eb46Smrg $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 27512f60eb46Smrg} 27522f60eb46Smrg 2753c3c9db83Smrg# func_lalib_p file 27542f60eb46Smrg# True iff FILE is a libtool '.la' library or '.lo' object file. 2755c3c9db83Smrg# This function is only a basic sanity check; it will hardly flush out 2756c3c9db83Smrg# determined imposters. 2757c3c9db83Smrgfunc_lalib_p () 2758c3c9db83Smrg{ 2759c3c9db83Smrg test -f "$1" && 27602f60eb46Smrg $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p 2761c3c9db83Smrg} 2762692f60a7Smrg 2763c3c9db83Smrg# func_lalib_unsafe_p file 27642f60eb46Smrg# True iff FILE is a libtool '.la' library or '.lo' object file. 2765c3c9db83Smrg# This function implements the same check as func_lalib_p without 2766c3c9db83Smrg# resorting to external programs. To this end, it redirects stdin and 2767c3c9db83Smrg# closes it afterwards, without saving the original file descriptor. 2768c3c9db83Smrg# As a safety measure, use it only where a negative result would be 27692f60eb46Smrg# fatal anyway. Works if 'file' does not exist. 2770c3c9db83Smrgfunc_lalib_unsafe_p () 2771c3c9db83Smrg{ 2772c3c9db83Smrg lalib_p=no 2773c3c9db83Smrg if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then 2774c3c9db83Smrg for lalib_p_l in 1 2 3 4 2775c3c9db83Smrg do 2776c3c9db83Smrg read lalib_p_line 27772f60eb46Smrg case $lalib_p_line in 2778c3c9db83Smrg \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; 2779c3c9db83Smrg esac 2780c3c9db83Smrg done 2781c3c9db83Smrg exec 0<&5 5<&- 2782c3c9db83Smrg fi 27832f60eb46Smrg test yes = "$lalib_p" 2784c3c9db83Smrg} 2785692f60a7Smrg 2786c3c9db83Smrg# func_ltwrapper_script_p file 2787c3c9db83Smrg# True iff FILE is a libtool wrapper script 2788c3c9db83Smrg# This function is only a basic sanity check; it will hardly flush out 2789c3c9db83Smrg# determined imposters. 2790c3c9db83Smrgfunc_ltwrapper_script_p () 2791c3c9db83Smrg{ 27922f60eb46Smrg test -f "$1" && 27932f60eb46Smrg $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p 2794c3c9db83Smrg} 2795692f60a7Smrg 2796c3c9db83Smrg# func_ltwrapper_executable_p file 2797c3c9db83Smrg# True iff FILE is a libtool wrapper executable 2798c3c9db83Smrg# This function is only a basic sanity check; it will hardly flush out 2799c3c9db83Smrg# determined imposters. 2800c3c9db83Smrgfunc_ltwrapper_executable_p () 2801c3c9db83Smrg{ 2802c3c9db83Smrg func_ltwrapper_exec_suffix= 2803c3c9db83Smrg case $1 in 2804c3c9db83Smrg *.exe) ;; 2805c3c9db83Smrg *) func_ltwrapper_exec_suffix=.exe ;; 2806c3c9db83Smrg esac 2807c3c9db83Smrg $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 2808c3c9db83Smrg} 280985ee4c00Smrg 2810c3c9db83Smrg# func_ltwrapper_scriptname file 2811c3c9db83Smrg# Assumes file is an ltwrapper_executable 2812c3c9db83Smrg# uses $file to determine the appropriate filename for a 2813c3c9db83Smrg# temporary ltwrapper_script. 2814c3c9db83Smrgfunc_ltwrapper_scriptname () 2815c3c9db83Smrg{ 28163f6d0e1dSmrg func_dirname_and_basename "$1" "" "." 28173f6d0e1dSmrg func_stripname '' '.exe' "$func_basename_result" 28182f60eb46Smrg func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper 2819c3c9db83Smrg} 2820c3c9db83Smrg 2821c3c9db83Smrg# func_ltwrapper_p file 2822c3c9db83Smrg# True iff FILE is a libtool wrapper script or wrapper executable 2823c3c9db83Smrg# This function is only a basic sanity check; it will hardly flush out 2824c3c9db83Smrg# determined imposters. 2825c3c9db83Smrgfunc_ltwrapper_p () 2826c3c9db83Smrg{ 2827c3c9db83Smrg func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" 2828c3c9db83Smrg} 2829c3c9db83Smrg 2830c3c9db83Smrg 2831c3c9db83Smrg# func_execute_cmds commands fail_cmd 2832c3c9db83Smrg# Execute tilde-delimited COMMANDS. 2833c3c9db83Smrg# If FAIL_CMD is given, eval that upon failure. 2834c3c9db83Smrg# FAIL_CMD may read-access the current command in variable CMD! 2835c3c9db83Smrgfunc_execute_cmds () 2836c3c9db83Smrg{ 28372f60eb46Smrg $debug_cmd 28382f60eb46Smrg 2839c3c9db83Smrg save_ifs=$IFS; IFS='~' 2840c3c9db83Smrg for cmd in $1; do 28412f60eb46Smrg IFS=$sp$nl 2842c3c9db83Smrg eval cmd=\"$cmd\" 28432f60eb46Smrg IFS=$save_ifs 2844c3c9db83Smrg func_show_eval "$cmd" "${2-:}" 2845c3c9db83Smrg done 2846c3c9db83Smrg IFS=$save_ifs 2847c3c9db83Smrg} 2848c3c9db83Smrg 2849c3c9db83Smrg 2850c3c9db83Smrg# func_source file 2851c3c9db83Smrg# Source FILE, adding directory component if necessary. 2852c3c9db83Smrg# Note that it is not necessary on cygwin/mingw to append a dot to 2853c3c9db83Smrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe 2854c3c9db83Smrg# behavior happens only for exec(3), not for open(2)! Also, sourcing 28552f60eb46Smrg# 'FILE.' does not work on cygwin managed mounts. 2856c3c9db83Smrgfunc_source () 2857c3c9db83Smrg{ 28582f60eb46Smrg $debug_cmd 28592f60eb46Smrg 2860c3c9db83Smrg case $1 in 2861c3c9db83Smrg */* | *\\*) . "$1" ;; 2862c3c9db83Smrg *) . "./$1" ;; 2863c3c9db83Smrg esac 2864c3c9db83Smrg} 2865c3c9db83Smrg 2866c3c9db83Smrg 28673f6d0e1dSmrg# func_resolve_sysroot PATH 28683f6d0e1dSmrg# Replace a leading = in PATH with a sysroot. Store the result into 28693f6d0e1dSmrg# func_resolve_sysroot_result 28703f6d0e1dSmrgfunc_resolve_sysroot () 28713f6d0e1dSmrg{ 28723f6d0e1dSmrg func_resolve_sysroot_result=$1 28733f6d0e1dSmrg case $func_resolve_sysroot_result in 28743f6d0e1dSmrg =*) 28753f6d0e1dSmrg func_stripname '=' '' "$func_resolve_sysroot_result" 28763f6d0e1dSmrg func_resolve_sysroot_result=$lt_sysroot$func_stripname_result 28773f6d0e1dSmrg ;; 28783f6d0e1dSmrg esac 28793f6d0e1dSmrg} 28803f6d0e1dSmrg 28813f6d0e1dSmrg# func_replace_sysroot PATH 28823f6d0e1dSmrg# If PATH begins with the sysroot, replace it with = and 28833f6d0e1dSmrg# store the result into func_replace_sysroot_result. 28843f6d0e1dSmrgfunc_replace_sysroot () 28853f6d0e1dSmrg{ 28862f60eb46Smrg case $lt_sysroot:$1 in 28873f6d0e1dSmrg ?*:"$lt_sysroot"*) 28883f6d0e1dSmrg func_stripname "$lt_sysroot" '' "$1" 28892f60eb46Smrg func_replace_sysroot_result='='$func_stripname_result 28903f6d0e1dSmrg ;; 28913f6d0e1dSmrg *) 28923f6d0e1dSmrg # Including no sysroot. 28933f6d0e1dSmrg func_replace_sysroot_result=$1 28943f6d0e1dSmrg ;; 28953f6d0e1dSmrg esac 28963f6d0e1dSmrg} 28973f6d0e1dSmrg 2898c3c9db83Smrg# func_infer_tag arg 2899c3c9db83Smrg# Infer tagged configuration to use if any are available and 2900c3c9db83Smrg# if one wasn't chosen via the "--tag" command line option. 2901c3c9db83Smrg# Only attempt this if the compiler in the base compile 2902c3c9db83Smrg# command doesn't match the default compiler. 2903c3c9db83Smrg# arg is usually of the form 'gcc ...' 2904c3c9db83Smrgfunc_infer_tag () 2905c3c9db83Smrg{ 29062f60eb46Smrg $debug_cmd 29072f60eb46Smrg 2908c3c9db83Smrg if test -n "$available_tags" && test -z "$tagname"; then 2909c3c9db83Smrg CC_quoted= 2910c3c9db83Smrg for arg in $CC; do 29113f6d0e1dSmrg func_append_quoted CC_quoted "$arg" 2912c3c9db83Smrg done 29133f6d0e1dSmrg CC_expanded=`func_echo_all $CC` 29143f6d0e1dSmrg CC_quoted_expanded=`func_echo_all $CC_quoted` 2915c3c9db83Smrg case $@ in 2916c3c9db83Smrg # Blanks in the command may have been stripped by the calling shell, 2917c3c9db83Smrg # but not from the CC environment variable when configure was run. 29183f6d0e1dSmrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 29193f6d0e1dSmrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; 2920c3c9db83Smrg # Blanks at the start of $base_compile will cause this to fail 2921c3c9db83Smrg # if we don't check for them as well. 2922c3c9db83Smrg *) 2923c3c9db83Smrg for z in $available_tags; do 2924c3c9db83Smrg if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then 2925c3c9db83Smrg # Evaluate the configuration. 29262f60eb46Smrg eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" 2927c3c9db83Smrg CC_quoted= 2928c3c9db83Smrg for arg in $CC; do 2929c3c9db83Smrg # Double-quote args containing other shell metacharacters. 29303f6d0e1dSmrg func_append_quoted CC_quoted "$arg" 2931c3c9db83Smrg done 29323f6d0e1dSmrg CC_expanded=`func_echo_all $CC` 29333f6d0e1dSmrg CC_quoted_expanded=`func_echo_all $CC_quoted` 2934c3c9db83Smrg case "$@ " in 29353f6d0e1dSmrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 29363f6d0e1dSmrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) 2937c3c9db83Smrg # The compiler in the base compile command matches 2938c3c9db83Smrg # the one in the tagged configuration. 2939c3c9db83Smrg # Assume this is the tagged configuration we want. 2940c3c9db83Smrg tagname=$z 2941c3c9db83Smrg break 2942c3c9db83Smrg ;; 2943c3c9db83Smrg esac 2944c3c9db83Smrg fi 2945c3c9db83Smrg done 2946c3c9db83Smrg # If $tagname still isn't set, then no tagged configuration 2947c3c9db83Smrg # was found and let the user know that the "--tag" command 2948c3c9db83Smrg # line option must be used. 2949c3c9db83Smrg if test -z "$tagname"; then 2950c3c9db83Smrg func_echo "unable to infer tagged configuration" 29512f60eb46Smrg func_fatal_error "specify a tag with '--tag'" 2952c3c9db83Smrg# else 2953c3c9db83Smrg# func_verbose "using $tagname tagged configuration" 2954c3c9db83Smrg fi 2955c3c9db83Smrg ;; 2956c3c9db83Smrg esac 2957c3c9db83Smrg fi 2958c3c9db83Smrg} 2959c3c9db83Smrg 2960c3c9db83Smrg 2961c3c9db83Smrg 2962c3c9db83Smrg# func_write_libtool_object output_name pic_name nonpic_name 2963c3c9db83Smrg# Create a libtool object file (analogous to a ".la" file), 2964c3c9db83Smrg# but don't create it if we're doing a dry run. 2965c3c9db83Smrgfunc_write_libtool_object () 2966c3c9db83Smrg{ 29672f60eb46Smrg write_libobj=$1 29682f60eb46Smrg if test yes = "$build_libtool_libs"; then 29692f60eb46Smrg write_lobj=\'$2\' 2970c3c9db83Smrg else 2971c3c9db83Smrg write_lobj=none 2972c3c9db83Smrg fi 2973c3c9db83Smrg 29742f60eb46Smrg if test yes = "$build_old_libs"; then 29752f60eb46Smrg write_oldobj=\'$3\' 2976c3c9db83Smrg else 2977c3c9db83Smrg write_oldobj=none 2978c3c9db83Smrg fi 2979c3c9db83Smrg 2980c3c9db83Smrg $opt_dry_run || { 2981c3c9db83Smrg cat >${write_libobj}T <<EOF 2982c3c9db83Smrg# $write_libobj - a libtool object file 29832f60eb46Smrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 2984c3c9db83Smrg# 2985c3c9db83Smrg# Please DO NOT delete this file! 2986c3c9db83Smrg# It is necessary for linking the library. 2987c3c9db83Smrg 2988c3c9db83Smrg# Name of the PIC object. 2989c3c9db83Smrgpic_object=$write_lobj 2990c3c9db83Smrg 2991c3c9db83Smrg# Name of the non-PIC object 2992c3c9db83Smrgnon_pic_object=$write_oldobj 2993c3c9db83Smrg 2994c3c9db83SmrgEOF 29952f60eb46Smrg $MV "${write_libobj}T" "$write_libobj" 2996c3c9db83Smrg } 2997c3c9db83Smrg} 2998c3c9db83Smrg 29993f6d0e1dSmrg 30003f6d0e1dSmrg################################################## 30013f6d0e1dSmrg# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS # 30023f6d0e1dSmrg################################################## 30033f6d0e1dSmrg 30043f6d0e1dSmrg# func_convert_core_file_wine_to_w32 ARG 30053f6d0e1dSmrg# Helper function used by file name conversion functions when $build is *nix, 30063f6d0e1dSmrg# and $host is mingw, cygwin, or some other w32 environment. Relies on a 30073f6d0e1dSmrg# correctly configured wine environment available, with the winepath program 30083f6d0e1dSmrg# in $build's $PATH. 30093f6d0e1dSmrg# 30103f6d0e1dSmrg# ARG is the $build file name to be converted to w32 format. 30113f6d0e1dSmrg# Result is available in $func_convert_core_file_wine_to_w32_result, and will 30123f6d0e1dSmrg# be empty on error (or when ARG is empty) 30133f6d0e1dSmrgfunc_convert_core_file_wine_to_w32 () 30143f6d0e1dSmrg{ 30152f60eb46Smrg $debug_cmd 30162f60eb46Smrg 30172f60eb46Smrg func_convert_core_file_wine_to_w32_result=$1 30183f6d0e1dSmrg if test -n "$1"; then 30193f6d0e1dSmrg # Unfortunately, winepath does not exit with a non-zero error code, so we 30203f6d0e1dSmrg # are forced to check the contents of stdout. On the other hand, if the 30213f6d0e1dSmrg # command is not found, the shell will set an exit code of 127 and print 30223f6d0e1dSmrg # *an error message* to stdout. So we must check for both error code of 30233f6d0e1dSmrg # zero AND non-empty stdout, which explains the odd construction: 30243f6d0e1dSmrg func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null` 30252f60eb46Smrg if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then 30263f6d0e1dSmrg func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | 30272f60eb46Smrg $SED -e "$sed_naive_backslashify"` 30283f6d0e1dSmrg else 30293f6d0e1dSmrg func_convert_core_file_wine_to_w32_result= 30303f6d0e1dSmrg fi 30313f6d0e1dSmrg fi 30323f6d0e1dSmrg} 30333f6d0e1dSmrg# end: func_convert_core_file_wine_to_w32 30343f6d0e1dSmrg 30353f6d0e1dSmrg 30363f6d0e1dSmrg# func_convert_core_path_wine_to_w32 ARG 30373f6d0e1dSmrg# Helper function used by path conversion functions when $build is *nix, and 30383f6d0e1dSmrg# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly 30393f6d0e1dSmrg# configured wine environment available, with the winepath program in $build's 30403f6d0e1dSmrg# $PATH. Assumes ARG has no leading or trailing path separator characters. 30413f6d0e1dSmrg# 30423f6d0e1dSmrg# ARG is path to be converted from $build format to win32. 30433f6d0e1dSmrg# Result is available in $func_convert_core_path_wine_to_w32_result. 30443f6d0e1dSmrg# Unconvertible file (directory) names in ARG are skipped; if no directory names 30453f6d0e1dSmrg# are convertible, then the result may be empty. 30463f6d0e1dSmrgfunc_convert_core_path_wine_to_w32 () 30473f6d0e1dSmrg{ 30482f60eb46Smrg $debug_cmd 30492f60eb46Smrg 30503f6d0e1dSmrg # unfortunately, winepath doesn't convert paths, only file names 30512f60eb46Smrg func_convert_core_path_wine_to_w32_result= 30523f6d0e1dSmrg if test -n "$1"; then 30533f6d0e1dSmrg oldIFS=$IFS 30543f6d0e1dSmrg IFS=: 30553f6d0e1dSmrg for func_convert_core_path_wine_to_w32_f in $1; do 30563f6d0e1dSmrg IFS=$oldIFS 30573f6d0e1dSmrg func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" 30582f60eb46Smrg if test -n "$func_convert_core_file_wine_to_w32_result"; then 30593f6d0e1dSmrg if test -z "$func_convert_core_path_wine_to_w32_result"; then 30602f60eb46Smrg func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result 30613f6d0e1dSmrg else 30623f6d0e1dSmrg func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" 30633f6d0e1dSmrg fi 30643f6d0e1dSmrg fi 30653f6d0e1dSmrg done 30663f6d0e1dSmrg IFS=$oldIFS 30673f6d0e1dSmrg fi 30683f6d0e1dSmrg} 30693f6d0e1dSmrg# end: func_convert_core_path_wine_to_w32 30703f6d0e1dSmrg 30713f6d0e1dSmrg 30723f6d0e1dSmrg# func_cygpath ARGS... 30733f6d0e1dSmrg# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when 30743f6d0e1dSmrg# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) 30753f6d0e1dSmrg# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or 30763f6d0e1dSmrg# (2), returns the Cygwin file name or path in func_cygpath_result (input 30773f6d0e1dSmrg# file name or path is assumed to be in w32 format, as previously converted 30783f6d0e1dSmrg# from $build's *nix or MSYS format). In case (3), returns the w32 file name 30793f6d0e1dSmrg# or path in func_cygpath_result (input file name or path is assumed to be in 30803f6d0e1dSmrg# Cygwin format). Returns an empty string on error. 30813f6d0e1dSmrg# 30823f6d0e1dSmrg# ARGS are passed to cygpath, with the last one being the file name or path to 30833f6d0e1dSmrg# be converted. 30843f6d0e1dSmrg# 30853f6d0e1dSmrg# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH 30863f6d0e1dSmrg# environment variable; do not put it in $PATH. 30873f6d0e1dSmrgfunc_cygpath () 30883f6d0e1dSmrg{ 30892f60eb46Smrg $debug_cmd 30902f60eb46Smrg 30913f6d0e1dSmrg if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then 30923f6d0e1dSmrg func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` 30933f6d0e1dSmrg if test "$?" -ne 0; then 30943f6d0e1dSmrg # on failure, ensure result is empty 30953f6d0e1dSmrg func_cygpath_result= 30963f6d0e1dSmrg fi 30973f6d0e1dSmrg else 30983f6d0e1dSmrg func_cygpath_result= 30992f60eb46Smrg func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'" 31003f6d0e1dSmrg fi 31013f6d0e1dSmrg} 31023f6d0e1dSmrg#end: func_cygpath 31033f6d0e1dSmrg 31043f6d0e1dSmrg 31053f6d0e1dSmrg# func_convert_core_msys_to_w32 ARG 31063f6d0e1dSmrg# Convert file name or path ARG from MSYS format to w32 format. Return 31073f6d0e1dSmrg# result in func_convert_core_msys_to_w32_result. 31083f6d0e1dSmrgfunc_convert_core_msys_to_w32 () 31093f6d0e1dSmrg{ 31102f60eb46Smrg $debug_cmd 31112f60eb46Smrg 31123f6d0e1dSmrg # awkward: cmd appends spaces to result 31133f6d0e1dSmrg func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | 31142f60eb46Smrg $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"` 31153f6d0e1dSmrg} 31163f6d0e1dSmrg#end: func_convert_core_msys_to_w32 31173f6d0e1dSmrg 31183f6d0e1dSmrg 31193f6d0e1dSmrg# func_convert_file_check ARG1 ARG2 31203f6d0e1dSmrg# Verify that ARG1 (a file name in $build format) was converted to $host 31213f6d0e1dSmrg# format in ARG2. Otherwise, emit an error message, but continue (resetting 31223f6d0e1dSmrg# func_to_host_file_result to ARG1). 31233f6d0e1dSmrgfunc_convert_file_check () 31243f6d0e1dSmrg{ 31252f60eb46Smrg $debug_cmd 31262f60eb46Smrg 31272f60eb46Smrg if test -z "$2" && test -n "$1"; then 31283f6d0e1dSmrg func_error "Could not determine host file name corresponding to" 31292f60eb46Smrg func_error " '$1'" 31303f6d0e1dSmrg func_error "Continuing, but uninstalled executables may not work." 31313f6d0e1dSmrg # Fallback: 31322f60eb46Smrg func_to_host_file_result=$1 31333f6d0e1dSmrg fi 31343f6d0e1dSmrg} 31353f6d0e1dSmrg# end func_convert_file_check 31363f6d0e1dSmrg 31373f6d0e1dSmrg 31383f6d0e1dSmrg# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH 31393f6d0e1dSmrg# Verify that FROM_PATH (a path in $build format) was converted to $host 31403f6d0e1dSmrg# format in TO_PATH. Otherwise, emit an error message, but continue, resetting 31413f6d0e1dSmrg# func_to_host_file_result to a simplistic fallback value (see below). 31423f6d0e1dSmrgfunc_convert_path_check () 31433f6d0e1dSmrg{ 31442f60eb46Smrg $debug_cmd 31452f60eb46Smrg 31463f6d0e1dSmrg if test -z "$4" && test -n "$3"; then 31473f6d0e1dSmrg func_error "Could not determine the host path corresponding to" 31482f60eb46Smrg func_error " '$3'" 31493f6d0e1dSmrg func_error "Continuing, but uninstalled executables may not work." 31503f6d0e1dSmrg # Fallback. This is a deliberately simplistic "conversion" and 31513f6d0e1dSmrg # should not be "improved". See libtool.info. 31523f6d0e1dSmrg if test "x$1" != "x$2"; then 31533f6d0e1dSmrg lt_replace_pathsep_chars="s|$1|$2|g" 31543f6d0e1dSmrg func_to_host_path_result=`echo "$3" | 31553f6d0e1dSmrg $SED -e "$lt_replace_pathsep_chars"` 31563f6d0e1dSmrg else 31572f60eb46Smrg func_to_host_path_result=$3 31583f6d0e1dSmrg fi 31593f6d0e1dSmrg fi 31603f6d0e1dSmrg} 31613f6d0e1dSmrg# end func_convert_path_check 31623f6d0e1dSmrg 31633f6d0e1dSmrg 31643f6d0e1dSmrg# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG 31653f6d0e1dSmrg# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT 31663f6d0e1dSmrg# and appending REPL if ORIG matches BACKPAT. 31673f6d0e1dSmrgfunc_convert_path_front_back_pathsep () 31683f6d0e1dSmrg{ 31692f60eb46Smrg $debug_cmd 31702f60eb46Smrg 31713f6d0e1dSmrg case $4 in 31722f60eb46Smrg $1 ) func_to_host_path_result=$3$func_to_host_path_result 31733f6d0e1dSmrg ;; 31743f6d0e1dSmrg esac 31753f6d0e1dSmrg case $4 in 31763f6d0e1dSmrg $2 ) func_append func_to_host_path_result "$3" 31773f6d0e1dSmrg ;; 31783f6d0e1dSmrg esac 31793f6d0e1dSmrg} 31803f6d0e1dSmrg# end func_convert_path_front_back_pathsep 31813f6d0e1dSmrg 31823f6d0e1dSmrg 31833f6d0e1dSmrg################################################## 31843f6d0e1dSmrg# $build to $host FILE NAME CONVERSION FUNCTIONS # 31853f6d0e1dSmrg################################################## 31862f60eb46Smrg# invoked via '$to_host_file_cmd ARG' 31873f6d0e1dSmrg# 31883f6d0e1dSmrg# In each case, ARG is the path to be converted from $build to $host format. 31893f6d0e1dSmrg# Result will be available in $func_to_host_file_result. 31903f6d0e1dSmrg 31913f6d0e1dSmrg 31923f6d0e1dSmrg# func_to_host_file ARG 31933f6d0e1dSmrg# Converts the file name ARG from $build format to $host format. Return result 31943f6d0e1dSmrg# in func_to_host_file_result. 31953f6d0e1dSmrgfunc_to_host_file () 31963f6d0e1dSmrg{ 31972f60eb46Smrg $debug_cmd 31982f60eb46Smrg 31993f6d0e1dSmrg $to_host_file_cmd "$1" 32003f6d0e1dSmrg} 32013f6d0e1dSmrg# end func_to_host_file 32023f6d0e1dSmrg 32033f6d0e1dSmrg 32043f6d0e1dSmrg# func_to_tool_file ARG LAZY 32053f6d0e1dSmrg# converts the file name ARG from $build format to toolchain format. Return 32063f6d0e1dSmrg# result in func_to_tool_file_result. If the conversion in use is listed 32073f6d0e1dSmrg# in (the comma separated) LAZY, no conversion takes place. 32083f6d0e1dSmrgfunc_to_tool_file () 32093f6d0e1dSmrg{ 32102f60eb46Smrg $debug_cmd 32112f60eb46Smrg 32123f6d0e1dSmrg case ,$2, in 32133f6d0e1dSmrg *,"$to_tool_file_cmd",*) 32143f6d0e1dSmrg func_to_tool_file_result=$1 32153f6d0e1dSmrg ;; 32163f6d0e1dSmrg *) 32173f6d0e1dSmrg $to_tool_file_cmd "$1" 32183f6d0e1dSmrg func_to_tool_file_result=$func_to_host_file_result 32193f6d0e1dSmrg ;; 32203f6d0e1dSmrg esac 32213f6d0e1dSmrg} 32223f6d0e1dSmrg# end func_to_tool_file 32233f6d0e1dSmrg 32243f6d0e1dSmrg 32253f6d0e1dSmrg# func_convert_file_noop ARG 32263f6d0e1dSmrg# Copy ARG to func_to_host_file_result. 32273f6d0e1dSmrgfunc_convert_file_noop () 32283f6d0e1dSmrg{ 32292f60eb46Smrg func_to_host_file_result=$1 32303f6d0e1dSmrg} 32313f6d0e1dSmrg# end func_convert_file_noop 32323f6d0e1dSmrg 32333f6d0e1dSmrg 32343f6d0e1dSmrg# func_convert_file_msys_to_w32 ARG 32353f6d0e1dSmrg# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic 32363f6d0e1dSmrg# conversion to w32 is not available inside the cwrapper. Returns result in 32373f6d0e1dSmrg# func_to_host_file_result. 32383f6d0e1dSmrgfunc_convert_file_msys_to_w32 () 32393f6d0e1dSmrg{ 32402f60eb46Smrg $debug_cmd 32412f60eb46Smrg 32422f60eb46Smrg func_to_host_file_result=$1 32433f6d0e1dSmrg if test -n "$1"; then 32443f6d0e1dSmrg func_convert_core_msys_to_w32 "$1" 32452f60eb46Smrg func_to_host_file_result=$func_convert_core_msys_to_w32_result 32463f6d0e1dSmrg fi 32473f6d0e1dSmrg func_convert_file_check "$1" "$func_to_host_file_result" 32483f6d0e1dSmrg} 32493f6d0e1dSmrg# end func_convert_file_msys_to_w32 32503f6d0e1dSmrg 32513f6d0e1dSmrg 32523f6d0e1dSmrg# func_convert_file_cygwin_to_w32 ARG 32533f6d0e1dSmrg# Convert file name ARG from Cygwin to w32 format. Returns result in 32543f6d0e1dSmrg# func_to_host_file_result. 32553f6d0e1dSmrgfunc_convert_file_cygwin_to_w32 () 32563f6d0e1dSmrg{ 32572f60eb46Smrg $debug_cmd 32582f60eb46Smrg 32592f60eb46Smrg func_to_host_file_result=$1 32603f6d0e1dSmrg if test -n "$1"; then 32613f6d0e1dSmrg # because $build is cygwin, we call "the" cygpath in $PATH; no need to use 32623f6d0e1dSmrg # LT_CYGPATH in this case. 32633f6d0e1dSmrg func_to_host_file_result=`cygpath -m "$1"` 32643f6d0e1dSmrg fi 32653f6d0e1dSmrg func_convert_file_check "$1" "$func_to_host_file_result" 32663f6d0e1dSmrg} 32673f6d0e1dSmrg# end func_convert_file_cygwin_to_w32 32683f6d0e1dSmrg 32693f6d0e1dSmrg 32703f6d0e1dSmrg# func_convert_file_nix_to_w32 ARG 32713f6d0e1dSmrg# Convert file name ARG from *nix to w32 format. Requires a wine environment 32723f6d0e1dSmrg# and a working winepath. Returns result in func_to_host_file_result. 32733f6d0e1dSmrgfunc_convert_file_nix_to_w32 () 32743f6d0e1dSmrg{ 32752f60eb46Smrg $debug_cmd 32762f60eb46Smrg 32772f60eb46Smrg func_to_host_file_result=$1 32783f6d0e1dSmrg if test -n "$1"; then 32793f6d0e1dSmrg func_convert_core_file_wine_to_w32 "$1" 32802f60eb46Smrg func_to_host_file_result=$func_convert_core_file_wine_to_w32_result 32813f6d0e1dSmrg fi 32823f6d0e1dSmrg func_convert_file_check "$1" "$func_to_host_file_result" 32833f6d0e1dSmrg} 32843f6d0e1dSmrg# end func_convert_file_nix_to_w32 32853f6d0e1dSmrg 32863f6d0e1dSmrg 32873f6d0e1dSmrg# func_convert_file_msys_to_cygwin ARG 32883f6d0e1dSmrg# Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 32893f6d0e1dSmrg# Returns result in func_to_host_file_result. 32903f6d0e1dSmrgfunc_convert_file_msys_to_cygwin () 32913f6d0e1dSmrg{ 32922f60eb46Smrg $debug_cmd 32932f60eb46Smrg 32942f60eb46Smrg func_to_host_file_result=$1 32953f6d0e1dSmrg if test -n "$1"; then 32963f6d0e1dSmrg func_convert_core_msys_to_w32 "$1" 32973f6d0e1dSmrg func_cygpath -u "$func_convert_core_msys_to_w32_result" 32982f60eb46Smrg func_to_host_file_result=$func_cygpath_result 32993f6d0e1dSmrg fi 33003f6d0e1dSmrg func_convert_file_check "$1" "$func_to_host_file_result" 33013f6d0e1dSmrg} 33023f6d0e1dSmrg# end func_convert_file_msys_to_cygwin 33033f6d0e1dSmrg 33043f6d0e1dSmrg 33053f6d0e1dSmrg# func_convert_file_nix_to_cygwin ARG 33063f6d0e1dSmrg# Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed 33073f6d0e1dSmrg# in a wine environment, working winepath, and LT_CYGPATH set. Returns result 33083f6d0e1dSmrg# in func_to_host_file_result. 33093f6d0e1dSmrgfunc_convert_file_nix_to_cygwin () 33103f6d0e1dSmrg{ 33112f60eb46Smrg $debug_cmd 33122f60eb46Smrg 33132f60eb46Smrg func_to_host_file_result=$1 33143f6d0e1dSmrg if test -n "$1"; then 33153f6d0e1dSmrg # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. 33163f6d0e1dSmrg func_convert_core_file_wine_to_w32 "$1" 33173f6d0e1dSmrg func_cygpath -u "$func_convert_core_file_wine_to_w32_result" 33182f60eb46Smrg func_to_host_file_result=$func_cygpath_result 33193f6d0e1dSmrg fi 33203f6d0e1dSmrg func_convert_file_check "$1" "$func_to_host_file_result" 33213f6d0e1dSmrg} 33223f6d0e1dSmrg# end func_convert_file_nix_to_cygwin 33233f6d0e1dSmrg 33243f6d0e1dSmrg 33253f6d0e1dSmrg############################################# 33263f6d0e1dSmrg# $build to $host PATH CONVERSION FUNCTIONS # 33273f6d0e1dSmrg############################################# 33282f60eb46Smrg# invoked via '$to_host_path_cmd ARG' 33293f6d0e1dSmrg# 33303f6d0e1dSmrg# In each case, ARG is the path to be converted from $build to $host format. 33313f6d0e1dSmrg# The result will be available in $func_to_host_path_result. 33323f6d0e1dSmrg# 33333f6d0e1dSmrg# Path separators are also converted from $build format to $host format. If 33343f6d0e1dSmrg# ARG begins or ends with a path separator character, it is preserved (but 33353f6d0e1dSmrg# converted to $host format) on output. 33363f6d0e1dSmrg# 33373f6d0e1dSmrg# All path conversion functions are named using the following convention: 33383f6d0e1dSmrg# file name conversion function : func_convert_file_X_to_Y () 33393f6d0e1dSmrg# path conversion function : func_convert_path_X_to_Y () 33403f6d0e1dSmrg# where, for any given $build/$host combination the 'X_to_Y' value is the 33413f6d0e1dSmrg# same. If conversion functions are added for new $build/$host combinations, 33423f6d0e1dSmrg# the two new functions must follow this pattern, or func_init_to_host_path_cmd 33433f6d0e1dSmrg# will break. 33443f6d0e1dSmrg 33453f6d0e1dSmrg 33463f6d0e1dSmrg# func_init_to_host_path_cmd 33473f6d0e1dSmrg# Ensures that function "pointer" variable $to_host_path_cmd is set to the 33483f6d0e1dSmrg# appropriate value, based on the value of $to_host_file_cmd. 33493f6d0e1dSmrgto_host_path_cmd= 33503f6d0e1dSmrgfunc_init_to_host_path_cmd () 33513f6d0e1dSmrg{ 33522f60eb46Smrg $debug_cmd 33532f60eb46Smrg 33543f6d0e1dSmrg if test -z "$to_host_path_cmd"; then 33553f6d0e1dSmrg func_stripname 'func_convert_file_' '' "$to_host_file_cmd" 33562f60eb46Smrg to_host_path_cmd=func_convert_path_$func_stripname_result 33573f6d0e1dSmrg fi 33583f6d0e1dSmrg} 33593f6d0e1dSmrg 33603f6d0e1dSmrg 33613f6d0e1dSmrg# func_to_host_path ARG 33623f6d0e1dSmrg# Converts the path ARG from $build format to $host format. Return result 33633f6d0e1dSmrg# in func_to_host_path_result. 33643f6d0e1dSmrgfunc_to_host_path () 33653f6d0e1dSmrg{ 33662f60eb46Smrg $debug_cmd 33672f60eb46Smrg 33683f6d0e1dSmrg func_init_to_host_path_cmd 33693f6d0e1dSmrg $to_host_path_cmd "$1" 33703f6d0e1dSmrg} 33713f6d0e1dSmrg# end func_to_host_path 33723f6d0e1dSmrg 33733f6d0e1dSmrg 33743f6d0e1dSmrg# func_convert_path_noop ARG 33753f6d0e1dSmrg# Copy ARG to func_to_host_path_result. 33763f6d0e1dSmrgfunc_convert_path_noop () 33773f6d0e1dSmrg{ 33782f60eb46Smrg func_to_host_path_result=$1 33793f6d0e1dSmrg} 33803f6d0e1dSmrg# end func_convert_path_noop 33813f6d0e1dSmrg 33823f6d0e1dSmrg 33833f6d0e1dSmrg# func_convert_path_msys_to_w32 ARG 33843f6d0e1dSmrg# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic 33853f6d0e1dSmrg# conversion to w32 is not available inside the cwrapper. Returns result in 33863f6d0e1dSmrg# func_to_host_path_result. 33873f6d0e1dSmrgfunc_convert_path_msys_to_w32 () 33883f6d0e1dSmrg{ 33892f60eb46Smrg $debug_cmd 33902f60eb46Smrg 33912f60eb46Smrg func_to_host_path_result=$1 33923f6d0e1dSmrg if test -n "$1"; then 33933f6d0e1dSmrg # Remove leading and trailing path separator characters from ARG. MSYS 33943f6d0e1dSmrg # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; 33953f6d0e1dSmrg # and winepath ignores them completely. 33963f6d0e1dSmrg func_stripname : : "$1" 33973f6d0e1dSmrg func_to_host_path_tmp1=$func_stripname_result 33983f6d0e1dSmrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 33992f60eb46Smrg func_to_host_path_result=$func_convert_core_msys_to_w32_result 34003f6d0e1dSmrg func_convert_path_check : ";" \ 34013f6d0e1dSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 34023f6d0e1dSmrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 34033f6d0e1dSmrg fi 34043f6d0e1dSmrg} 34053f6d0e1dSmrg# end func_convert_path_msys_to_w32 34063f6d0e1dSmrg 34073f6d0e1dSmrg 34083f6d0e1dSmrg# func_convert_path_cygwin_to_w32 ARG 34093f6d0e1dSmrg# Convert path ARG from Cygwin to w32 format. Returns result in 34103f6d0e1dSmrg# func_to_host_file_result. 34113f6d0e1dSmrgfunc_convert_path_cygwin_to_w32 () 34123f6d0e1dSmrg{ 34132f60eb46Smrg $debug_cmd 34142f60eb46Smrg 34152f60eb46Smrg func_to_host_path_result=$1 34163f6d0e1dSmrg if test -n "$1"; then 34173f6d0e1dSmrg # See func_convert_path_msys_to_w32: 34183f6d0e1dSmrg func_stripname : : "$1" 34193f6d0e1dSmrg func_to_host_path_tmp1=$func_stripname_result 34203f6d0e1dSmrg func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` 34213f6d0e1dSmrg func_convert_path_check : ";" \ 34223f6d0e1dSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 34233f6d0e1dSmrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 34243f6d0e1dSmrg fi 34253f6d0e1dSmrg} 34263f6d0e1dSmrg# end func_convert_path_cygwin_to_w32 34273f6d0e1dSmrg 34283f6d0e1dSmrg 34293f6d0e1dSmrg# func_convert_path_nix_to_w32 ARG 34303f6d0e1dSmrg# Convert path ARG from *nix to w32 format. Requires a wine environment and 34313f6d0e1dSmrg# a working winepath. Returns result in func_to_host_file_result. 34323f6d0e1dSmrgfunc_convert_path_nix_to_w32 () 34333f6d0e1dSmrg{ 34342f60eb46Smrg $debug_cmd 34352f60eb46Smrg 34362f60eb46Smrg func_to_host_path_result=$1 34373f6d0e1dSmrg if test -n "$1"; then 34383f6d0e1dSmrg # See func_convert_path_msys_to_w32: 34393f6d0e1dSmrg func_stripname : : "$1" 34403f6d0e1dSmrg func_to_host_path_tmp1=$func_stripname_result 34413f6d0e1dSmrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 34422f60eb46Smrg func_to_host_path_result=$func_convert_core_path_wine_to_w32_result 34433f6d0e1dSmrg func_convert_path_check : ";" \ 34443f6d0e1dSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 34453f6d0e1dSmrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 34463f6d0e1dSmrg fi 34473f6d0e1dSmrg} 34483f6d0e1dSmrg# end func_convert_path_nix_to_w32 34493f6d0e1dSmrg 34503f6d0e1dSmrg 34513f6d0e1dSmrg# func_convert_path_msys_to_cygwin ARG 34523f6d0e1dSmrg# Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 34533f6d0e1dSmrg# Returns result in func_to_host_file_result. 34543f6d0e1dSmrgfunc_convert_path_msys_to_cygwin () 34553f6d0e1dSmrg{ 34562f60eb46Smrg $debug_cmd 34572f60eb46Smrg 34582f60eb46Smrg func_to_host_path_result=$1 34593f6d0e1dSmrg if test -n "$1"; then 34603f6d0e1dSmrg # See func_convert_path_msys_to_w32: 34613f6d0e1dSmrg func_stripname : : "$1" 34623f6d0e1dSmrg func_to_host_path_tmp1=$func_stripname_result 34633f6d0e1dSmrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 34643f6d0e1dSmrg func_cygpath -u -p "$func_convert_core_msys_to_w32_result" 34652f60eb46Smrg func_to_host_path_result=$func_cygpath_result 34663f6d0e1dSmrg func_convert_path_check : : \ 34673f6d0e1dSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 34683f6d0e1dSmrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 34693f6d0e1dSmrg fi 34703f6d0e1dSmrg} 34713f6d0e1dSmrg# end func_convert_path_msys_to_cygwin 34723f6d0e1dSmrg 34733f6d0e1dSmrg 34743f6d0e1dSmrg# func_convert_path_nix_to_cygwin ARG 34753f6d0e1dSmrg# Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a 34763f6d0e1dSmrg# a wine environment, working winepath, and LT_CYGPATH set. Returns result in 34773f6d0e1dSmrg# func_to_host_file_result. 34783f6d0e1dSmrgfunc_convert_path_nix_to_cygwin () 34793f6d0e1dSmrg{ 34802f60eb46Smrg $debug_cmd 34812f60eb46Smrg 34822f60eb46Smrg func_to_host_path_result=$1 34833f6d0e1dSmrg if test -n "$1"; then 34843f6d0e1dSmrg # Remove leading and trailing path separator characters from 34853f6d0e1dSmrg # ARG. msys behavior is inconsistent here, cygpath turns them 34863f6d0e1dSmrg # into '.;' and ';.', and winepath ignores them completely. 34873f6d0e1dSmrg func_stripname : : "$1" 34883f6d0e1dSmrg func_to_host_path_tmp1=$func_stripname_result 34893f6d0e1dSmrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 34903f6d0e1dSmrg func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" 34912f60eb46Smrg func_to_host_path_result=$func_cygpath_result 34923f6d0e1dSmrg func_convert_path_check : : \ 34933f6d0e1dSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 34943f6d0e1dSmrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 34953f6d0e1dSmrg fi 34963f6d0e1dSmrg} 34973f6d0e1dSmrg# end func_convert_path_nix_to_cygwin 34983f6d0e1dSmrg 34993f6d0e1dSmrg 35002f60eb46Smrg# func_dll_def_p FILE 35012f60eb46Smrg# True iff FILE is a Windows DLL '.def' file. 35022f60eb46Smrg# Keep in sync with _LT_DLL_DEF_P in libtool.m4 35032f60eb46Smrgfunc_dll_def_p () 35042f60eb46Smrg{ 35052f60eb46Smrg $debug_cmd 35062f60eb46Smrg 35072f60eb46Smrg func_dll_def_p_tmp=`$SED -n \ 35082f60eb46Smrg -e 's/^[ ]*//' \ 35092f60eb46Smrg -e '/^\(;.*\)*$/d' \ 35102f60eb46Smrg -e 's/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p' \ 35112f60eb46Smrg -e q \ 35122f60eb46Smrg "$1"` 35132f60eb46Smrg test DEF = "$func_dll_def_p_tmp" 35142f60eb46Smrg} 35152f60eb46Smrg 35162f60eb46Smrg 3517c3c9db83Smrg# func_mode_compile arg... 3518c3c9db83Smrgfunc_mode_compile () 3519c3c9db83Smrg{ 35202f60eb46Smrg $debug_cmd 35212f60eb46Smrg 3522c3c9db83Smrg # Get the compilation command and the source file. 3523c3c9db83Smrg base_compile= 35242f60eb46Smrg srcfile=$nonopt # always keep a non-empty value in "srcfile" 3525c3c9db83Smrg suppress_opt=yes 3526c3c9db83Smrg suppress_output= 3527c3c9db83Smrg arg_mode=normal 3528c3c9db83Smrg libobj= 3529c3c9db83Smrg later= 3530c3c9db83Smrg pie_flag= 3531c3c9db83Smrg 3532c3c9db83Smrg for arg 3533c3c9db83Smrg do 3534c3c9db83Smrg case $arg_mode in 3535c3c9db83Smrg arg ) 3536c3c9db83Smrg # do not "continue". Instead, add this to base_compile 35372f60eb46Smrg lastarg=$arg 3538c3c9db83Smrg arg_mode=normal 3539c3c9db83Smrg ;; 3540c3c9db83Smrg 3541c3c9db83Smrg target ) 35422f60eb46Smrg libobj=$arg 3543c3c9db83Smrg arg_mode=normal 3544c3c9db83Smrg continue 3545c3c9db83Smrg ;; 3546c3c9db83Smrg 3547c3c9db83Smrg normal ) 3548c3c9db83Smrg # Accept any command-line options. 3549c3c9db83Smrg case $arg in 3550c3c9db83Smrg -o) 3551c3c9db83Smrg test -n "$libobj" && \ 35522f60eb46Smrg func_fatal_error "you cannot specify '-o' more than once" 3553c3c9db83Smrg arg_mode=target 3554c3c9db83Smrg continue 3555c3c9db83Smrg ;; 3556c3c9db83Smrg 3557c3c9db83Smrg -pie | -fpie | -fPIE) 35583f6d0e1dSmrg func_append pie_flag " $arg" 3559c3c9db83Smrg continue 3560c3c9db83Smrg ;; 3561c3c9db83Smrg 3562c3c9db83Smrg -shared | -static | -prefer-pic | -prefer-non-pic) 35633f6d0e1dSmrg func_append later " $arg" 3564c3c9db83Smrg continue 3565c3c9db83Smrg ;; 3566c3c9db83Smrg 3567c3c9db83Smrg -no-suppress) 3568692f60a7Smrg suppress_opt=no 3569692f60a7Smrg continue 3570692f60a7Smrg ;; 3571692f60a7Smrg 3572692f60a7Smrg -Xcompiler) 3573692f60a7Smrg arg_mode=arg # the next one goes into the "base_compile" arg list 3574692f60a7Smrg continue # The current "srcfile" will either be retained or 3575692f60a7Smrg ;; # replaced later. I would guess that would be a bug. 3576692f60a7Smrg 3577692f60a7Smrg -Wc,*) 3578c3c9db83Smrg func_stripname '-Wc,' '' "$arg" 3579c3c9db83Smrg args=$func_stripname_result 3580692f60a7Smrg lastarg= 35812f60eb46Smrg save_ifs=$IFS; IFS=, 3582c3c9db83Smrg for arg in $args; do 35832f60eb46Smrg IFS=$save_ifs 35843f6d0e1dSmrg func_append_quoted lastarg "$arg" 3585692f60a7Smrg done 35862f60eb46Smrg IFS=$save_ifs 3587c3c9db83Smrg func_stripname ' ' '' "$lastarg" 3588c3c9db83Smrg lastarg=$func_stripname_result 3589692f60a7Smrg 3590692f60a7Smrg # Add the arguments to base_compile. 35913f6d0e1dSmrg func_append base_compile " $lastarg" 3592692f60a7Smrg continue 3593692f60a7Smrg ;; 3594692f60a7Smrg 3595c3c9db83Smrg *) 3596692f60a7Smrg # Accept the current argument as the source file. 3597692f60a7Smrg # The previous "srcfile" becomes the current argument. 3598692f60a7Smrg # 35992f60eb46Smrg lastarg=$srcfile 36002f60eb46Smrg srcfile=$arg 3601692f60a7Smrg ;; 3602692f60a7Smrg esac # case $arg 3603692f60a7Smrg ;; 3604692f60a7Smrg esac # case $arg_mode 3605692f60a7Smrg 3606692f60a7Smrg # Aesthetically quote the previous argument. 36073f6d0e1dSmrg func_append_quoted base_compile "$lastarg" 3608692f60a7Smrg done # for arg 3609692f60a7Smrg 3610692f60a7Smrg case $arg_mode in 3611692f60a7Smrg arg) 3612c3c9db83Smrg func_fatal_error "you must specify an argument for -Xcompile" 3613692f60a7Smrg ;; 3614692f60a7Smrg target) 36152f60eb46Smrg func_fatal_error "you must specify a target with '-o'" 3616692f60a7Smrg ;; 3617692f60a7Smrg *) 3618692f60a7Smrg # Get the name of the library object. 3619c3c9db83Smrg test -z "$libobj" && { 3620c3c9db83Smrg func_basename "$srcfile" 36212f60eb46Smrg libobj=$func_basename_result 3622c3c9db83Smrg } 3623692f60a7Smrg ;; 3624692f60a7Smrg esac 3625692f60a7Smrg 3626692f60a7Smrg # Recognize several different file suffixes. 3627692f60a7Smrg # If the user specifies -o file.o, it is replaced with file.lo 3628692f60a7Smrg case $libobj in 3629c3c9db83Smrg *.[cCFSifmso] | \ 3630c3c9db83Smrg *.ada | *.adb | *.ads | *.asm | \ 3631c3c9db83Smrg *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ 363295903e71Smrg *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup) 3633c3c9db83Smrg func_xform "$libobj" 3634c3c9db83Smrg libobj=$func_xform_result 3635c3c9db83Smrg ;; 3636692f60a7Smrg esac 3637692f60a7Smrg 3638692f60a7Smrg case $libobj in 3639c3c9db83Smrg *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; 3640692f60a7Smrg *) 36412f60eb46Smrg func_fatal_error "cannot determine name of library object from '$libobj'" 3642692f60a7Smrg ;; 3643692f60a7Smrg esac 3644692f60a7Smrg 3645692f60a7Smrg func_infer_tag $base_compile 3646692f60a7Smrg 3647692f60a7Smrg for arg in $later; do 3648692f60a7Smrg case $arg in 3649c3c9db83Smrg -shared) 36502f60eb46Smrg test yes = "$build_libtool_libs" \ 36512f60eb46Smrg || func_fatal_configuration "cannot build a shared library" 3652c3c9db83Smrg build_old_libs=no 3653c3c9db83Smrg continue 3654c3c9db83Smrg ;; 3655c3c9db83Smrg 3656692f60a7Smrg -static) 3657c3c9db83Smrg build_libtool_libs=no 3658692f60a7Smrg build_old_libs=yes 3659692f60a7Smrg continue 3660692f60a7Smrg ;; 3661692f60a7Smrg 3662692f60a7Smrg -prefer-pic) 3663692f60a7Smrg pic_mode=yes 3664692f60a7Smrg continue 3665692f60a7Smrg ;; 3666692f60a7Smrg 3667692f60a7Smrg -prefer-non-pic) 3668692f60a7Smrg pic_mode=no 3669692f60a7Smrg continue 3670692f60a7Smrg ;; 3671692f60a7Smrg esac 3672692f60a7Smrg done 3673692f60a7Smrg 3674efb46889Smrg func_quote_arg pretty "$libobj" 3675efb46889Smrg test "X$libobj" != "X$func_quote_arg_result" \ 3676c3c9db83Smrg && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ 36772f60eb46Smrg && func_warning "libobj name '$libobj' may not contain shell special characters." 3678c3c9db83Smrg func_dirname_and_basename "$obj" "/" "" 36792f60eb46Smrg objname=$func_basename_result 36802f60eb46Smrg xdir=$func_dirname_result 36812f60eb46Smrg lobj=$xdir$objdir/$objname 3682692f60a7Smrg 3683c3c9db83Smrg test -z "$base_compile" && \ 3684c3c9db83Smrg func_fatal_help "you must specify a compilation command" 3685692f60a7Smrg 3686692f60a7Smrg # Delete any leftover library objects. 36872f60eb46Smrg if test yes = "$build_old_libs"; then 3688692f60a7Smrg removelist="$obj $lobj $libobj ${libobj}T" 3689692f60a7Smrg else 3690692f60a7Smrg removelist="$lobj $libobj ${libobj}T" 3691692f60a7Smrg fi 3692692f60a7Smrg 3693692f60a7Smrg # On Cygwin there's no "real" PIC flag so we must build both object types 3694692f60a7Smrg case $host_os in 3695c3c9db83Smrg cygwin* | mingw* | pw32* | os2* | cegcc*) 3696692f60a7Smrg pic_mode=default 3697692f60a7Smrg ;; 3698692f60a7Smrg esac 36992f60eb46Smrg if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then 3700692f60a7Smrg # non-PIC code in shared libraries is not supported 3701692f60a7Smrg pic_mode=default 3702692f60a7Smrg fi 3703692f60a7Smrg 3704692f60a7Smrg # Calculate the filename of the output object if compiler does 3705692f60a7Smrg # not support -o with -c 37062f60eb46Smrg if test no = "$compiler_c_o"; then 37072f60eb46Smrg output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext 37082f60eb46Smrg lockfile=$output_obj.lock 3709692f60a7Smrg else 3710692f60a7Smrg output_obj= 3711692f60a7Smrg need_locks=no 3712692f60a7Smrg lockfile= 3713692f60a7Smrg fi 3714692f60a7Smrg 3715692f60a7Smrg # Lock this critical section if it is needed 3716692f60a7Smrg # We use this script file to make the link, it avoids creating a new file 37172f60eb46Smrg if test yes = "$need_locks"; then 3718c3c9db83Smrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 3719c3c9db83Smrg func_echo "Waiting for $lockfile to be removed" 3720692f60a7Smrg sleep 2 3721692f60a7Smrg done 37222f60eb46Smrg elif test warn = "$need_locks"; then 3723692f60a7Smrg if test -f "$lockfile"; then 3724c3c9db83Smrg $ECHO "\ 3725692f60a7Smrg*** ERROR, $lockfile exists and contains: 3726692f60a7Smrg`cat $lockfile 2>/dev/null` 3727692f60a7Smrg 3728692f60a7SmrgThis indicates that another process is trying to use the same 3729692f60a7Smrgtemporary object file, and libtool could not work around it because 37302f60eb46Smrgyour compiler does not support '-c' and '-o' together. If you 3731692f60a7Smrgrepeat this compilation, it may succeed, by chance, but you had better 3732692f60a7Smrgavoid parallel builds (make -j) in this platform, or get a better 3733692f60a7Smrgcompiler." 3734692f60a7Smrg 3735c3c9db83Smrg $opt_dry_run || $RM $removelist 3736692f60a7Smrg exit $EXIT_FAILURE 3737692f60a7Smrg fi 37383f6d0e1dSmrg func_append removelist " $output_obj" 3739c3c9db83Smrg $ECHO "$srcfile" > "$lockfile" 3740692f60a7Smrg fi 3741692f60a7Smrg 3742c3c9db83Smrg $opt_dry_run || $RM $removelist 37433f6d0e1dSmrg func_append removelist " $lockfile" 3744c3c9db83Smrg trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 3745c3c9db83Smrg 37463f6d0e1dSmrg func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 37473f6d0e1dSmrg srcfile=$func_to_tool_file_result 3748efb46889Smrg func_quote_arg pretty "$srcfile" 3749efb46889Smrg qsrcfile=$func_quote_arg_result 3750692f60a7Smrg 3751692f60a7Smrg # Only build a PIC object if we are building libtool libraries. 37522f60eb46Smrg if test yes = "$build_libtool_libs"; then 3753692f60a7Smrg # Without this assignment, base_compile gets emptied. 3754692f60a7Smrg fbsd_hideous_sh_bug=$base_compile 3755692f60a7Smrg 37562f60eb46Smrg if test no != "$pic_mode"; then 3757692f60a7Smrg command="$base_compile $qsrcfile $pic_flag" 3758692f60a7Smrg else 3759692f60a7Smrg # Don't build PIC code 3760692f60a7Smrg command="$base_compile $qsrcfile" 3761692f60a7Smrg fi 3762692f60a7Smrg 3763c3c9db83Smrg func_mkdir_p "$xdir$objdir" 3764692f60a7Smrg 3765692f60a7Smrg if test -z "$output_obj"; then 3766692f60a7Smrg # Place PIC objects in $objdir 37673f6d0e1dSmrg func_append command " -o $lobj" 3768692f60a7Smrg fi 3769692f60a7Smrg 3770c3c9db83Smrg func_show_eval_locale "$command" \ 3771c3c9db83Smrg 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' 3772692f60a7Smrg 37732f60eb46Smrg if test warn = "$need_locks" && 3774692f60a7Smrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 3775c3c9db83Smrg $ECHO "\ 3776692f60a7Smrg*** ERROR, $lockfile contains: 3777692f60a7Smrg`cat $lockfile 2>/dev/null` 3778692f60a7Smrg 3779692f60a7Smrgbut it should contain: 3780692f60a7Smrg$srcfile 3781692f60a7Smrg 3782692f60a7SmrgThis indicates that another process is trying to use the same 3783692f60a7Smrgtemporary object file, and libtool could not work around it because 37842f60eb46Smrgyour compiler does not support '-c' and '-o' together. If you 3785692f60a7Smrgrepeat this compilation, it may succeed, by chance, but you had better 3786692f60a7Smrgavoid parallel builds (make -j) in this platform, or get a better 3787692f60a7Smrgcompiler." 3788692f60a7Smrg 3789c3c9db83Smrg $opt_dry_run || $RM $removelist 3790692f60a7Smrg exit $EXIT_FAILURE 3791692f60a7Smrg fi 3792692f60a7Smrg 3793692f60a7Smrg # Just move the object if needed, then go on to compile the next one 3794692f60a7Smrg if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then 3795c3c9db83Smrg func_show_eval '$MV "$output_obj" "$lobj"' \ 3796c3c9db83Smrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 3797692f60a7Smrg fi 3798692f60a7Smrg 3799692f60a7Smrg # Allow error messages only from the first compilation. 38002f60eb46Smrg if test yes = "$suppress_opt"; then 3801c3c9db83Smrg suppress_output=' >/dev/null 2>&1' 3802692f60a7Smrg fi 3803692f60a7Smrg fi 3804692f60a7Smrg 3805692f60a7Smrg # Only build a position-dependent object if we build old libraries. 38062f60eb46Smrg if test yes = "$build_old_libs"; then 38072f60eb46Smrg if test yes != "$pic_mode"; then 3808692f60a7Smrg # Don't build PIC code 3809c3c9db83Smrg command="$base_compile $qsrcfile$pie_flag" 3810692f60a7Smrg else 3811692f60a7Smrg command="$base_compile $qsrcfile $pic_flag" 3812692f60a7Smrg fi 38132f60eb46Smrg if test yes = "$compiler_c_o"; then 38143f6d0e1dSmrg func_append command " -o $obj" 3815692f60a7Smrg fi 3816692f60a7Smrg 3817692f60a7Smrg # Suppress compiler output if we already did a PIC compilation. 38183f6d0e1dSmrg func_append command "$suppress_output" 3819c3c9db83Smrg func_show_eval_locale "$command" \ 3820c3c9db83Smrg '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 3821692f60a7Smrg 38222f60eb46Smrg if test warn = "$need_locks" && 3823692f60a7Smrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 3824c3c9db83Smrg $ECHO "\ 3825692f60a7Smrg*** ERROR, $lockfile contains: 3826692f60a7Smrg`cat $lockfile 2>/dev/null` 3827692f60a7Smrg 3828692f60a7Smrgbut it should contain: 3829692f60a7Smrg$srcfile 3830692f60a7Smrg 3831692f60a7SmrgThis indicates that another process is trying to use the same 3832692f60a7Smrgtemporary object file, and libtool could not work around it because 38332f60eb46Smrgyour compiler does not support '-c' and '-o' together. If you 3834692f60a7Smrgrepeat this compilation, it may succeed, by chance, but you had better 3835692f60a7Smrgavoid parallel builds (make -j) in this platform, or get a better 3836692f60a7Smrgcompiler." 3837692f60a7Smrg 3838c3c9db83Smrg $opt_dry_run || $RM $removelist 3839692f60a7Smrg exit $EXIT_FAILURE 3840692f60a7Smrg fi 3841692f60a7Smrg 3842692f60a7Smrg # Just move the object if needed 3843692f60a7Smrg if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then 3844c3c9db83Smrg func_show_eval '$MV "$output_obj" "$obj"' \ 3845c3c9db83Smrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 3846692f60a7Smrg fi 3847692f60a7Smrg fi 3848692f60a7Smrg 3849c3c9db83Smrg $opt_dry_run || { 3850c3c9db83Smrg func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" 3851692f60a7Smrg 3852c3c9db83Smrg # Unlock the critical section if it was locked 38532f60eb46Smrg if test no != "$need_locks"; then 3854c3c9db83Smrg removelist=$lockfile 3855c3c9db83Smrg $RM "$lockfile" 3856c3c9db83Smrg fi 3857c3c9db83Smrg } 3858692f60a7Smrg 3859692f60a7Smrg exit $EXIT_SUCCESS 3860c3c9db83Smrg} 3861692f60a7Smrg 3862c3c9db83Smrg$opt_help || { 38632f60eb46Smrg test compile = "$opt_mode" && func_mode_compile ${1+"$@"} 3864c3c9db83Smrg} 3865692f60a7Smrg 3866c3c9db83Smrgfunc_mode_help () 3867c3c9db83Smrg{ 3868c3c9db83Smrg # We need to display help for each of the modes. 38693f6d0e1dSmrg case $opt_mode in 3870c3c9db83Smrg "") 3871c3c9db83Smrg # Generic help is extracted from the usage comments 3872c3c9db83Smrg # at the start of this file. 3873c3c9db83Smrg func_help 3874c3c9db83Smrg ;; 3875692f60a7Smrg 3876c3c9db83Smrg clean) 3877c3c9db83Smrg $ECHO \ 3878c3c9db83Smrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... 3879692f60a7Smrg 3880c3c9db83SmrgRemove files from the build directory. 3881692f60a7Smrg 3882c3c9db83SmrgRM is the name of the program to use to delete files associated with each FILE 38832f60eb46Smrg(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 3884c3c9db83Smrgto RM. 3885692f60a7Smrg 3886c3c9db83SmrgIf FILE is a libtool library, object or program, all the files associated 3887c3c9db83Smrgwith it are deleted. Otherwise, only FILE itself is deleted using RM." 3888c3c9db83Smrg ;; 3889692f60a7Smrg 3890c3c9db83Smrg compile) 3891c3c9db83Smrg $ECHO \ 3892c3c9db83Smrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE 3893692f60a7Smrg 3894c3c9db83SmrgCompile a source file into a libtool library object. 3895692f60a7Smrg 3896c3c9db83SmrgThis mode accepts the following additional options: 3897692f60a7Smrg 3898c3c9db83Smrg -o OUTPUT-FILE set the output file name to OUTPUT-FILE 3899c3c9db83Smrg -no-suppress do not suppress compiler output for multiple passes 39003f6d0e1dSmrg -prefer-pic try to build PIC objects only 39013f6d0e1dSmrg -prefer-non-pic try to build non-PIC objects only 39022f60eb46Smrg -shared do not build a '.o' file suitable for static linking 39032f60eb46Smrg -static only build a '.o' file suitable for static linking 3904efb46889Smrg -Wc,FLAG 3905efb46889Smrg -Xcompiler FLAG pass FLAG directly to the compiler 3906692f60a7Smrg 39072f60eb46SmrgCOMPILE-COMMAND is a command to be used in creating a 'standard' object file 3908c3c9db83Smrgfrom the given SOURCEFILE. 3909692f60a7Smrg 3910c3c9db83SmrgThe output file name is determined by removing the directory component from 39112f60eb46SmrgSOURCEFILE, then substituting the C source code suffix '.c' with the 39122f60eb46Smrglibrary object suffix, '.lo'." 3913c3c9db83Smrg ;; 3914692f60a7Smrg 3915c3c9db83Smrg execute) 3916c3c9db83Smrg $ECHO \ 3917c3c9db83Smrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... 3918692f60a7Smrg 3919c3c9db83SmrgAutomatically set library path, then run a program. 3920692f60a7Smrg 3921c3c9db83SmrgThis mode accepts the following additional options: 3922692f60a7Smrg 3923c3c9db83Smrg -dlopen FILE add the directory containing FILE to the library path 3924692f60a7Smrg 39252f60eb46SmrgThis mode sets the library path environment variable according to '-dlopen' 3926c3c9db83Smrgflags. 3927692f60a7Smrg 3928c3c9db83SmrgIf any of the ARGS are libtool executable wrappers, then they are translated 3929c3c9db83Smrginto their corresponding uninstalled binary, and any of their required library 3930c3c9db83Smrgdirectories are added to the library path. 3931692f60a7Smrg 3932c3c9db83SmrgThen, COMMAND is executed, with ARGS as arguments." 3933c3c9db83Smrg ;; 3934692f60a7Smrg 3935c3c9db83Smrg finish) 3936c3c9db83Smrg $ECHO \ 3937c3c9db83Smrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]... 3938692f60a7Smrg 3939c3c9db83SmrgComplete the installation of libtool libraries. 3940692f60a7Smrg 3941c3c9db83SmrgEach LIBDIR is a directory that contains libtool libraries. 3942692f60a7Smrg 3943c3c9db83SmrgThe commands that this mode executes may require superuser privileges. Use 39442f60eb46Smrgthe '--dry-run' option if you just want to see what would be executed." 3945c3c9db83Smrg ;; 3946692f60a7Smrg 3947c3c9db83Smrg install) 3948c3c9db83Smrg $ECHO \ 3949c3c9db83Smrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... 3950692f60a7Smrg 3951c3c9db83SmrgInstall executables or libraries. 3952692f60a7Smrg 3953c3c9db83SmrgINSTALL-COMMAND is the installation command. The first component should be 39542f60eb46Smrgeither the 'install' or 'cp' program. 3955692f60a7Smrg 3956c3c9db83SmrgThe following components of INSTALL-COMMAND are treated specially: 3957692f60a7Smrg 39583f6d0e1dSmrg -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation 3959692f60a7Smrg 3960c3c9db83SmrgThe rest of the components are interpreted as arguments to that command (only 3961c3c9db83SmrgBSD-compatible install options are recognized)." 3962c3c9db83Smrg ;; 3963692f60a7Smrg 3964c3c9db83Smrg link) 3965c3c9db83Smrg $ECHO \ 3966c3c9db83Smrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND... 3967692f60a7Smrg 3968c3c9db83SmrgLink object files or libraries together to form another library, or to 3969c3c9db83Smrgcreate an executable program. 3970692f60a7Smrg 3971c3c9db83SmrgLINK-COMMAND is a command using the C compiler that you would use to create 3972c3c9db83Smrga program from several object files. 3973692f60a7Smrg 3974c3c9db83SmrgThe following components of LINK-COMMAND are treated specially: 3975692f60a7Smrg 3976c3c9db83Smrg -all-static do not do any dynamic linking at all 3977c3c9db83Smrg -avoid-version do not add a version suffix if possible 39783f6d0e1dSmrg -bindir BINDIR specify path to binaries directory (for systems where 39793f6d0e1dSmrg libraries must be found in the PATH setting at runtime) 39802f60eb46Smrg -dlopen FILE '-dlpreopen' FILE if it cannot be dlopened at runtime 3981c3c9db83Smrg -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols 3982c3c9db83Smrg -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) 3983c3c9db83Smrg -export-symbols SYMFILE 3984c3c9db83Smrg try to export only the symbols listed in SYMFILE 3985c3c9db83Smrg -export-symbols-regex REGEX 3986c3c9db83Smrg try to export only the symbols matching REGEX 3987c3c9db83Smrg -LLIBDIR search LIBDIR for required installed libraries 3988c3c9db83Smrg -lNAME OUTPUT-FILE requires the installed library libNAME 3989c3c9db83Smrg -module build a library that can dlopened 3990c3c9db83Smrg -no-fast-install disable the fast-install mode 3991c3c9db83Smrg -no-install link a not-installable executable 3992c3c9db83Smrg -no-undefined declare that a library does not refer to external symbols 3993c3c9db83Smrg -o OUTPUT-FILE create OUTPUT-FILE from the specified objects 39942f60eb46Smrg -objectlist FILE use a list of object files found in FILE to specify objects 39952f60eb46Smrg -os2dllname NAME force a short DLL name on OS/2 (no effect on other OSes) 3996c3c9db83Smrg -precious-files-regex REGEX 3997c3c9db83Smrg don't remove output files matching REGEX 3998c3c9db83Smrg -release RELEASE specify package release information 3999c3c9db83Smrg -rpath LIBDIR the created library will eventually be installed in LIBDIR 4000c3c9db83Smrg -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries 4001c3c9db83Smrg -shared only do dynamic linking of libtool libraries 4002c3c9db83Smrg -shrext SUFFIX override the standard shared library file extension 4003c3c9db83Smrg -static do not do any dynamic linking of uninstalled libtool libraries 4004c3c9db83Smrg -static-libtool-libs 4005c3c9db83Smrg do not do any dynamic linking of libtool libraries 4006c3c9db83Smrg -version-info CURRENT[:REVISION[:AGE]] 4007c3c9db83Smrg specify library version info [each variable defaults to 0] 4008c3c9db83Smrg -weak LIBNAME declare that the target provides the LIBNAME interface 40093f6d0e1dSmrg -Wc,FLAG 40103f6d0e1dSmrg -Xcompiler FLAG pass linker-specific FLAG directly to the compiler 4011efb46889Smrg -Wa,FLAG 4012efb46889Smrg -Xassembler FLAG pass linker-specific FLAG directly to the assembler 40133f6d0e1dSmrg -Wl,FLAG 40143f6d0e1dSmrg -Xlinker FLAG pass linker-specific FLAG directly to the linker 40153f6d0e1dSmrg -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) 4016692f60a7Smrg 40172f60eb46SmrgAll other options (arguments beginning with '-') are ignored. 4018692f60a7Smrg 40192f60eb46SmrgEvery other argument is treated as a filename. Files ending in '.la' are 4020c3c9db83Smrgtreated as uninstalled libtool libraries, other files are standard or library 4021c3c9db83Smrgobject files. 4022692f60a7Smrg 40232f60eb46SmrgIf the OUTPUT-FILE ends in '.la', then a libtool library is created, 40242f60eb46Smrgonly library objects ('.lo' files) may be specified, and '-rpath' is 4025c3c9db83Smrgrequired, except when creating a convenience library. 4026692f60a7Smrg 40272f60eb46SmrgIf OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created 40282f60eb46Smrgusing 'ar' and 'ranlib', or on Windows using 'lib'. 4029692f60a7Smrg 40302f60eb46SmrgIf OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file 4031c3c9db83Smrgis created, otherwise an executable program is created." 40322e71ea71Smrg ;; 4033692f60a7Smrg 4034c3c9db83Smrg uninstall) 4035c3c9db83Smrg $ECHO \ 4036c3c9db83Smrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... 4037692f60a7Smrg 4038c3c9db83SmrgRemove libraries from an installation directory. 4039692f60a7Smrg 4040c3c9db83SmrgRM is the name of the program to use to delete files associated with each FILE 40412f60eb46Smrg(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 4042c3c9db83Smrgto RM. 404385ee4c00Smrg 4044c3c9db83SmrgIf FILE is a libtool library, all the files associated with it are deleted. 4045c3c9db83SmrgOtherwise, only FILE itself is deleted using RM." 4046c3c9db83Smrg ;; 404785ee4c00Smrg 4048c3c9db83Smrg *) 40492f60eb46Smrg func_fatal_help "invalid operation mode '$opt_mode'" 4050c3c9db83Smrg ;; 4051c3c9db83Smrg esac 405285ee4c00Smrg 40533f6d0e1dSmrg echo 40542f60eb46Smrg $ECHO "Try '$progname --help' for more information about other modes." 4055c3c9db83Smrg} 405685ee4c00Smrg 40573f6d0e1dSmrg# Now that we've collected a possible --mode arg, show help if necessary 40583f6d0e1dSmrgif $opt_help; then 40592f60eb46Smrg if test : = "$opt_help"; then 40603f6d0e1dSmrg func_mode_help 40613f6d0e1dSmrg else 40623f6d0e1dSmrg { 40633f6d0e1dSmrg func_help noexit 40643f6d0e1dSmrg for opt_mode in compile link execute install finish uninstall clean; do 40653f6d0e1dSmrg func_mode_help 40663f6d0e1dSmrg done 40672f60eb46Smrg } | $SED -n '1p; 2,$s/^Usage:/ or: /p' 40683f6d0e1dSmrg { 40693f6d0e1dSmrg func_help noexit 40703f6d0e1dSmrg for opt_mode in compile link execute install finish uninstall clean; do 40713f6d0e1dSmrg echo 40723f6d0e1dSmrg func_mode_help 40733f6d0e1dSmrg done 40743f6d0e1dSmrg } | 40752f60eb46Smrg $SED '1d 40763f6d0e1dSmrg /^When reporting/,/^Report/{ 40773f6d0e1dSmrg H 40783f6d0e1dSmrg d 40793f6d0e1dSmrg } 40803f6d0e1dSmrg $x 40813f6d0e1dSmrg /information about other modes/d 40823f6d0e1dSmrg /more detailed .*MODE/d 40833f6d0e1dSmrg s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' 40843f6d0e1dSmrg fi 40853f6d0e1dSmrg exit $? 40863f6d0e1dSmrgfi 408785ee4c00Smrg 408885ee4c00Smrg 4089c3c9db83Smrg# func_mode_execute arg... 4090c3c9db83Smrgfunc_mode_execute () 4091c3c9db83Smrg{ 40922f60eb46Smrg $debug_cmd 40932f60eb46Smrg 4094c3c9db83Smrg # The first argument is the command name. 40952f60eb46Smrg cmd=$nonopt 4096c3c9db83Smrg test -z "$cmd" && \ 4097c3c9db83Smrg func_fatal_help "you must specify a COMMAND" 40982e71ea71Smrg 4099c3c9db83Smrg # Handle -dlopen flags immediately. 41003f6d0e1dSmrg for file in $opt_dlopen; do 4101c3c9db83Smrg test -f "$file" \ 41022f60eb46Smrg || func_fatal_help "'$file' is not a file" 41032e71ea71Smrg 4104c3c9db83Smrg dir= 4105c3c9db83Smrg case $file in 4106c3c9db83Smrg *.la) 41073f6d0e1dSmrg func_resolve_sysroot "$file" 41083f6d0e1dSmrg file=$func_resolve_sysroot_result 41093f6d0e1dSmrg 4110c3c9db83Smrg # Check to see that this really is a libtool archive. 4111c3c9db83Smrg func_lalib_unsafe_p "$file" \ 41122f60eb46Smrg || func_fatal_help "'$lib' is not a valid libtool archive" 41132e71ea71Smrg 4114c3c9db83Smrg # Read the libtool library. 4115c3c9db83Smrg dlname= 4116c3c9db83Smrg library_names= 4117c3c9db83Smrg func_source "$file" 4118692f60a7Smrg 4119c3c9db83Smrg # Skip this library if it cannot be dlopened. 4120c3c9db83Smrg if test -z "$dlname"; then 4121c3c9db83Smrg # Warn if it was a shared library. 4122c3c9db83Smrg test -n "$library_names" && \ 41232f60eb46Smrg func_warning "'$file' was not linked with '-export-dynamic'" 4124c3c9db83Smrg continue 4125c3c9db83Smrg fi 4126692f60a7Smrg 4127c3c9db83Smrg func_dirname "$file" "" "." 41282f60eb46Smrg dir=$func_dirname_result 4129692f60a7Smrg 4130c3c9db83Smrg if test -f "$dir/$objdir/$dlname"; then 41313f6d0e1dSmrg func_append dir "/$objdir" 4132c3c9db83Smrg else 4133c3c9db83Smrg if test ! -f "$dir/$dlname"; then 41342f60eb46Smrg func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'" 4135c3c9db83Smrg fi 4136c3c9db83Smrg fi 41372e71ea71Smrg ;; 4138692f60a7Smrg 4139c3c9db83Smrg *.lo) 4140c3c9db83Smrg # Just add the directory containing the .lo file. 4141c3c9db83Smrg func_dirname "$file" "" "." 41422f60eb46Smrg dir=$func_dirname_result 41432e71ea71Smrg ;; 4144692f60a7Smrg 4145c3c9db83Smrg *) 41462f60eb46Smrg func_warning "'-dlopen' is ignored for non-libtool libraries and objects" 41472e71ea71Smrg continue 41482e71ea71Smrg ;; 4149c3c9db83Smrg esac 4150692f60a7Smrg 4151c3c9db83Smrg # Get the absolute pathname. 4152c3c9db83Smrg absdir=`cd "$dir" && pwd` 41532f60eb46Smrg test -n "$absdir" && dir=$absdir 415485ee4c00Smrg 4155c3c9db83Smrg # Now add the directory to shlibpath_var. 4156c3c9db83Smrg if eval "test -z \"\$$shlibpath_var\""; then 4157c3c9db83Smrg eval "$shlibpath_var=\"\$dir\"" 4158c3c9db83Smrg else 4159c3c9db83Smrg eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" 4160c3c9db83Smrg fi 4161c3c9db83Smrg done 416285ee4c00Smrg 4163c3c9db83Smrg # This variable tells wrapper scripts just to set shlibpath_var 4164c3c9db83Smrg # rather than running their programs. 41652f60eb46Smrg libtool_execute_magic=$magic 416685ee4c00Smrg 4167c3c9db83Smrg # Check if any of the arguments is a wrapper script. 4168c3c9db83Smrg args= 4169c3c9db83Smrg for file 4170c3c9db83Smrg do 4171c3c9db83Smrg case $file in 41723f6d0e1dSmrg -* | *.la | *.lo ) ;; 4173c3c9db83Smrg *) 4174c3c9db83Smrg # Do a test to see if this is really a libtool program. 4175c3c9db83Smrg if func_ltwrapper_script_p "$file"; then 4176c3c9db83Smrg func_source "$file" 4177c3c9db83Smrg # Transform arg to wrapped name. 41782f60eb46Smrg file=$progdir/$program 4179c3c9db83Smrg elif func_ltwrapper_executable_p "$file"; then 4180c3c9db83Smrg func_ltwrapper_scriptname "$file" 4181c3c9db83Smrg func_source "$func_ltwrapper_scriptname_result" 4182c3c9db83Smrg # Transform arg to wrapped name. 41832f60eb46Smrg file=$progdir/$program 4184c3c9db83Smrg fi 4185c3c9db83Smrg ;; 4186c3c9db83Smrg esac 4187c3c9db83Smrg # Quote arguments (to preserve shell metacharacters). 41883f6d0e1dSmrg func_append_quoted args "$file" 4189c3c9db83Smrg done 419085ee4c00Smrg 41912f60eb46Smrg if $opt_dry_run; then 41922f60eb46Smrg # Display what would be done. 41932f60eb46Smrg if test -n "$shlibpath_var"; then 41942f60eb46Smrg eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" 41952f60eb46Smrg echo "export $shlibpath_var" 41962f60eb46Smrg fi 41972f60eb46Smrg $ECHO "$cmd$args" 41982f60eb46Smrg exit $EXIT_SUCCESS 41992f60eb46Smrg else 4200c3c9db83Smrg if test -n "$shlibpath_var"; then 4201c3c9db83Smrg # Export the shlibpath_var. 4202c3c9db83Smrg eval "export $shlibpath_var" 4203c3c9db83Smrg fi 420485ee4c00Smrg 4205c3c9db83Smrg # Restore saved environment variables 4206c3c9db83Smrg for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 4207c3c9db83Smrg do 4208c3c9db83Smrg eval "if test \"\${save_$lt_var+set}\" = set; then 4209c3c9db83Smrg $lt_var=\$save_$lt_var; export $lt_var 42102e71ea71Smrg else 4211c3c9db83Smrg $lt_unset $lt_var 4212c3c9db83Smrg fi" 4213c3c9db83Smrg done 421485ee4c00Smrg 4215c3c9db83Smrg # Now prepare to actually exec the command. 42162f60eb46Smrg exec_cmd=\$cmd$args 4217c3c9db83Smrg fi 4218c3c9db83Smrg} 421985ee4c00Smrg 42202f60eb46Smrgtest execute = "$opt_mode" && func_mode_execute ${1+"$@"} 422185ee4c00Smrg 42222e71ea71Smrg 4223c3c9db83Smrg# func_mode_finish arg... 4224c3c9db83Smrgfunc_mode_finish () 4225c3c9db83Smrg{ 42262f60eb46Smrg $debug_cmd 42272f60eb46Smrg 42283f6d0e1dSmrg libs= 42293f6d0e1dSmrg libdirs= 4230c3c9db83Smrg admincmds= 4231692f60a7Smrg 42323f6d0e1dSmrg for opt in "$nonopt" ${1+"$@"} 42333f6d0e1dSmrg do 42343f6d0e1dSmrg if test -d "$opt"; then 42353f6d0e1dSmrg func_append libdirs " $opt" 42363f6d0e1dSmrg 42373f6d0e1dSmrg elif test -f "$opt"; then 42383f6d0e1dSmrg if func_lalib_unsafe_p "$opt"; then 42393f6d0e1dSmrg func_append libs " $opt" 42403f6d0e1dSmrg else 42412f60eb46Smrg func_warning "'$opt' is not a valid libtool archive" 42423f6d0e1dSmrg fi 42433f6d0e1dSmrg 42443f6d0e1dSmrg else 42452f60eb46Smrg func_fatal_error "invalid argument '$opt'" 42463f6d0e1dSmrg fi 42473f6d0e1dSmrg done 42483f6d0e1dSmrg 42493f6d0e1dSmrg if test -n "$libs"; then 42503f6d0e1dSmrg if test -n "$lt_sysroot"; then 42513f6d0e1dSmrg sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` 42523f6d0e1dSmrg sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" 42533f6d0e1dSmrg else 42543f6d0e1dSmrg sysroot_cmd= 42553f6d0e1dSmrg fi 42563f6d0e1dSmrg 42573f6d0e1dSmrg # Remove sysroot references 42583f6d0e1dSmrg if $opt_dry_run; then 42593f6d0e1dSmrg for lib in $libs; do 42602f60eb46Smrg echo "removing references to $lt_sysroot and '=' prefixes from $lib" 42613f6d0e1dSmrg done 42623f6d0e1dSmrg else 42633f6d0e1dSmrg tmpdir=`func_mktempdir` 42643f6d0e1dSmrg for lib in $libs; do 42652f60eb46Smrg $SED -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ 42663f6d0e1dSmrg > $tmpdir/tmp-la 42673f6d0e1dSmrg mv -f $tmpdir/tmp-la $lib 42683f6d0e1dSmrg done 42693f6d0e1dSmrg ${RM}r "$tmpdir" 42703f6d0e1dSmrg fi 42713f6d0e1dSmrg fi 4272692f60a7Smrg 42733f6d0e1dSmrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 4274c3c9db83Smrg for libdir in $libdirs; do 4275c3c9db83Smrg if test -n "$finish_cmds"; then 4276c3c9db83Smrg # Do each command in the finish commands. 4277c3c9db83Smrg func_execute_cmds "$finish_cmds" 'admincmds="$admincmds 4278c3c9db83Smrg'"$cmd"'"' 42792e71ea71Smrg fi 4280c3c9db83Smrg if test -n "$finish_eval"; then 4281c3c9db83Smrg # Do the single finish_eval. 4282c3c9db83Smrg eval cmds=\"$finish_eval\" 42833f6d0e1dSmrg $opt_dry_run || eval "$cmds" || func_append admincmds " 4284c3c9db83Smrg $cmds" 4285c3c9db83Smrg fi 4286c3c9db83Smrg done 4287c3c9db83Smrg fi 4288692f60a7Smrg 4289c3c9db83Smrg # Exit here if they wanted silent mode. 42902f60eb46Smrg $opt_quiet && exit $EXIT_SUCCESS 4291692f60a7Smrg 42923f6d0e1dSmrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 42933f6d0e1dSmrg echo "----------------------------------------------------------------------" 42943f6d0e1dSmrg echo "Libraries have been installed in:" 42953f6d0e1dSmrg for libdir in $libdirs; do 42963f6d0e1dSmrg $ECHO " $libdir" 42973f6d0e1dSmrg done 42983f6d0e1dSmrg echo 42993f6d0e1dSmrg echo "If you ever happen to want to link against installed libraries" 43003f6d0e1dSmrg echo "in a given directory, LIBDIR, you must either use libtool, and" 43012f60eb46Smrg echo "specify the full pathname of the library, or use the '-LLIBDIR'" 43023f6d0e1dSmrg echo "flag during linking and do at least one of the following:" 43033f6d0e1dSmrg if test -n "$shlibpath_var"; then 43042f60eb46Smrg echo " - add LIBDIR to the '$shlibpath_var' environment variable" 43053f6d0e1dSmrg echo " during execution" 43063f6d0e1dSmrg fi 43073f6d0e1dSmrg if test -n "$runpath_var"; then 43082f60eb46Smrg echo " - add LIBDIR to the '$runpath_var' environment variable" 43093f6d0e1dSmrg echo " during linking" 43103f6d0e1dSmrg fi 43113f6d0e1dSmrg if test -n "$hardcode_libdir_flag_spec"; then 43123f6d0e1dSmrg libdir=LIBDIR 43133f6d0e1dSmrg eval flag=\"$hardcode_libdir_flag_spec\" 4314c3c9db83Smrg 43152f60eb46Smrg $ECHO " - use the '$flag' linker flag" 43163f6d0e1dSmrg fi 43173f6d0e1dSmrg if test -n "$admincmds"; then 43183f6d0e1dSmrg $ECHO " - have your system administrator run these commands:$admincmds" 43193f6d0e1dSmrg fi 43203f6d0e1dSmrg if test -f /etc/ld.so.conf; then 43212f60eb46Smrg echo " - have your system administrator add LIBDIR to '/etc/ld.so.conf'" 43223f6d0e1dSmrg fi 43233f6d0e1dSmrg echo 4324c3c9db83Smrg 43253f6d0e1dSmrg echo "See any operating system documentation about shared libraries for" 43263f6d0e1dSmrg case $host in 43273f6d0e1dSmrg solaris2.[6789]|solaris2.1[0-9]) 43283f6d0e1dSmrg echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" 43293f6d0e1dSmrg echo "pages." 43303f6d0e1dSmrg ;; 43313f6d0e1dSmrg *) 43323f6d0e1dSmrg echo "more information, such as the ld(1) and ld.so(8) manual pages." 43333f6d0e1dSmrg ;; 43343f6d0e1dSmrg esac 43353f6d0e1dSmrg echo "----------------------------------------------------------------------" 43363f6d0e1dSmrg fi 4337c3c9db83Smrg exit $EXIT_SUCCESS 4338c3c9db83Smrg} 4339c3c9db83Smrg 43402f60eb46Smrgtest finish = "$opt_mode" && func_mode_finish ${1+"$@"} 4341c3c9db83Smrg 4342c3c9db83Smrg 4343c3c9db83Smrg# func_mode_install arg... 4344c3c9db83Smrgfunc_mode_install () 4345c3c9db83Smrg{ 43462f60eb46Smrg $debug_cmd 43472f60eb46Smrg 4348c3c9db83Smrg # There may be an optional sh(1) argument at the beginning of 4349c3c9db83Smrg # install_prog (especially on Windows NT). 43502f60eb46Smrg if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" || 4351c3c9db83Smrg # Allow the use of GNU shtool's install command. 43522f60eb46Smrg case $nonopt in *shtool*) :;; *) false;; esac 43532f60eb46Smrg then 4354c3c9db83Smrg # Aesthetically quote it. 4355efb46889Smrg func_quote_arg pretty "$nonopt" 4356efb46889Smrg install_prog="$func_quote_arg_result " 4357c3c9db83Smrg arg=$1 4358c3c9db83Smrg shift 4359c3c9db83Smrg else 4360c3c9db83Smrg install_prog= 4361c3c9db83Smrg arg=$nonopt 4362c3c9db83Smrg fi 4363c3c9db83Smrg 4364c3c9db83Smrg # The real first argument should be the name of the installation program. 4365c3c9db83Smrg # Aesthetically quote it. 4366efb46889Smrg func_quote_arg pretty "$arg" 4367efb46889Smrg func_append install_prog "$func_quote_arg_result" 43683f6d0e1dSmrg install_shared_prog=$install_prog 43693f6d0e1dSmrg case " $install_prog " in 43703f6d0e1dSmrg *[\\\ /]cp\ *) install_cp=: ;; 43713f6d0e1dSmrg *) install_cp=false ;; 43723f6d0e1dSmrg esac 4373c3c9db83Smrg 4374c3c9db83Smrg # We need to accept at least all the BSD install flags. 4375c3c9db83Smrg dest= 4376c3c9db83Smrg files= 4377c3c9db83Smrg opts= 4378c3c9db83Smrg prev= 4379c3c9db83Smrg install_type= 43802f60eb46Smrg isdir=false 4381c3c9db83Smrg stripme= 43823f6d0e1dSmrg no_mode=: 4383c3c9db83Smrg for arg 4384c3c9db83Smrg do 43853f6d0e1dSmrg arg2= 4386c3c9db83Smrg if test -n "$dest"; then 43873f6d0e1dSmrg func_append files " $dest" 4388c3c9db83Smrg dest=$arg 4389c3c9db83Smrg continue 4390c3c9db83Smrg fi 4391c3c9db83Smrg 4392c3c9db83Smrg case $arg in 43932f60eb46Smrg -d) isdir=: ;; 4394c3c9db83Smrg -f) 43953f6d0e1dSmrg if $install_cp; then :; else 43963f6d0e1dSmrg prev=$arg 43973f6d0e1dSmrg fi 4398c3c9db83Smrg ;; 4399c3c9db83Smrg -g | -m | -o) 4400c3c9db83Smrg prev=$arg 4401c3c9db83Smrg ;; 4402c3c9db83Smrg -s) 4403c3c9db83Smrg stripme=" -s" 4404c3c9db83Smrg continue 4405c3c9db83Smrg ;; 4406c3c9db83Smrg -*) 4407c3c9db83Smrg ;; 4408c3c9db83Smrg *) 4409c3c9db83Smrg # If the previous option needed an argument, then skip it. 4410c3c9db83Smrg if test -n "$prev"; then 44112f60eb46Smrg if test X-m = "X$prev" && test -n "$install_override_mode"; then 44123f6d0e1dSmrg arg2=$install_override_mode 44133f6d0e1dSmrg no_mode=false 44143f6d0e1dSmrg fi 44152e71ea71Smrg prev= 441685ee4c00Smrg else 4417c3c9db83Smrg dest=$arg 4418c3c9db83Smrg continue 4419692f60a7Smrg fi 44202e71ea71Smrg ;; 4421c3c9db83Smrg esac 4422692f60a7Smrg 4423c3c9db83Smrg # Aesthetically quote the argument. 4424efb46889Smrg func_quote_arg pretty "$arg" 4425efb46889Smrg func_append install_prog " $func_quote_arg_result" 44263f6d0e1dSmrg if test -n "$arg2"; then 4427efb46889Smrg func_quote_arg pretty "$arg2" 44283f6d0e1dSmrg fi 4429efb46889Smrg func_append install_shared_prog " $func_quote_arg_result" 4430c3c9db83Smrg done 4431692f60a7Smrg 4432c3c9db83Smrg test -z "$install_prog" && \ 4433c3c9db83Smrg func_fatal_help "you must specify an install program" 4434692f60a7Smrg 4435c3c9db83Smrg test -n "$prev" && \ 44362f60eb46Smrg func_fatal_help "the '$prev' option requires an argument" 443785ee4c00Smrg 44383f6d0e1dSmrg if test -n "$install_override_mode" && $no_mode; then 44393f6d0e1dSmrg if $install_cp; then :; else 4440efb46889Smrg func_quote_arg pretty "$install_override_mode" 4441efb46889Smrg func_append install_shared_prog " -m $func_quote_arg_result" 44423f6d0e1dSmrg fi 44433f6d0e1dSmrg fi 44443f6d0e1dSmrg 4445c3c9db83Smrg if test -z "$files"; then 4446c3c9db83Smrg if test -z "$dest"; then 4447c3c9db83Smrg func_fatal_help "no file or destination specified" 4448c3c9db83Smrg else 4449c3c9db83Smrg func_fatal_help "you must specify a destination" 4450c3c9db83Smrg fi 44512e71ea71Smrg fi 445285ee4c00Smrg 4453c3c9db83Smrg # Strip any trailing slash from the destination. 4454c3c9db83Smrg func_stripname '' '/' "$dest" 4455c3c9db83Smrg dest=$func_stripname_result 445685ee4c00Smrg 4457c3c9db83Smrg # Check to see that the destination is a directory. 44582f60eb46Smrg test -d "$dest" && isdir=: 44592f60eb46Smrg if $isdir; then 44602f60eb46Smrg destdir=$dest 4461c3c9db83Smrg destname= 44622e71ea71Smrg else 4463c3c9db83Smrg func_dirname_and_basename "$dest" "" "." 44642f60eb46Smrg destdir=$func_dirname_result 44652f60eb46Smrg destname=$func_basename_result 446685ee4c00Smrg 4467c3c9db83Smrg # Not a directory, so check to see that there is only one file specified. 4468c3c9db83Smrg set dummy $files; shift 4469c3c9db83Smrg test "$#" -gt 1 && \ 44702f60eb46Smrg func_fatal_help "'$dest' is not a directory" 447185ee4c00Smrg fi 4472c3c9db83Smrg case $destdir in 4473c3c9db83Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 44742e71ea71Smrg *) 4475c3c9db83Smrg for file in $files; do 4476c3c9db83Smrg case $file in 4477c3c9db83Smrg *.lo) ;; 4478c3c9db83Smrg *) 44792f60eb46Smrg func_fatal_help "'$destdir' must be an absolute directory name" 4480c3c9db83Smrg ;; 4481c3c9db83Smrg esac 4482c3c9db83Smrg done 44832e71ea71Smrg ;; 44842e71ea71Smrg esac 4485692f60a7Smrg 4486c3c9db83Smrg # This variable tells wrapper scripts just to set variables rather 4487c3c9db83Smrg # than running their programs. 44882f60eb46Smrg libtool_install_magic=$magic 4489692f60a7Smrg 4490c3c9db83Smrg staticlibs= 4491c3c9db83Smrg future_libdirs= 4492c3c9db83Smrg current_libdirs= 4493c3c9db83Smrg for file in $files; do 4494692f60a7Smrg 4495c3c9db83Smrg # Do each installation. 4496c3c9db83Smrg case $file in 4497c3c9db83Smrg *.$libext) 4498c3c9db83Smrg # Do the static libraries later. 44993f6d0e1dSmrg func_append staticlibs " $file" 4500c3c9db83Smrg ;; 4501c3c9db83Smrg 4502c3c9db83Smrg *.la) 45033f6d0e1dSmrg func_resolve_sysroot "$file" 45043f6d0e1dSmrg file=$func_resolve_sysroot_result 45053f6d0e1dSmrg 4506c3c9db83Smrg # Check to see that this really is a libtool archive. 4507c3c9db83Smrg func_lalib_unsafe_p "$file" \ 45082f60eb46Smrg || func_fatal_help "'$file' is not a valid libtool archive" 4509c3c9db83Smrg 4510c3c9db83Smrg library_names= 4511c3c9db83Smrg old_library= 4512c3c9db83Smrg relink_command= 4513c3c9db83Smrg func_source "$file" 4514c3c9db83Smrg 4515c3c9db83Smrg # Add the libdir to current_libdirs if it is the destination. 4516c3c9db83Smrg if test "X$destdir" = "X$libdir"; then 4517c3c9db83Smrg case "$current_libdirs " in 4518c3c9db83Smrg *" $libdir "*) ;; 45193f6d0e1dSmrg *) func_append current_libdirs " $libdir" ;; 452085ee4c00Smrg esac 4521c3c9db83Smrg else 4522c3c9db83Smrg # Note the libdir as a future libdir. 4523c3c9db83Smrg case "$future_libdirs " in 4524c3c9db83Smrg *" $libdir "*) ;; 45253f6d0e1dSmrg *) func_append future_libdirs " $libdir" ;; 4526c3c9db83Smrg esac 4527c3c9db83Smrg fi 452885ee4c00Smrg 4529c3c9db83Smrg func_dirname "$file" "/" "" 45302f60eb46Smrg dir=$func_dirname_result 45313f6d0e1dSmrg func_append dir "$objdir" 4532c3c9db83Smrg 4533c3c9db83Smrg if test -n "$relink_command"; then 4534c3c9db83Smrg # Determine the prefix the user has applied to our future dir. 45353f6d0e1dSmrg inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` 4536c3c9db83Smrg 4537c3c9db83Smrg # Don't allow the user to place us outside of our expected 4538c3c9db83Smrg # location b/c this prevents finding dependent libraries that 4539c3c9db83Smrg # are installed to the same prefix. 4540c3c9db83Smrg # At present, this check doesn't affect windows .dll's that 4541c3c9db83Smrg # are installed into $libdir/../bin (currently, that works fine) 4542c3c9db83Smrg # but it's something to keep an eye on. 4543c3c9db83Smrg test "$inst_prefix_dir" = "$destdir" && \ 45442f60eb46Smrg func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir" 4545c3c9db83Smrg 4546c3c9db83Smrg if test -n "$inst_prefix_dir"; then 4547c3c9db83Smrg # Stick the inst_prefix_dir data into the link command. 45483f6d0e1dSmrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` 4549c3c9db83Smrg else 45503f6d0e1dSmrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` 4551c3c9db83Smrg fi 4552c3c9db83Smrg 45532f60eb46Smrg func_warning "relinking '$file'" 4554c3c9db83Smrg func_show_eval "$relink_command" \ 45552f60eb46Smrg 'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"' 4556c3c9db83Smrg fi 4557c3c9db83Smrg 4558c3c9db83Smrg # See the names of the shared library. 4559c3c9db83Smrg set dummy $library_names; shift 4560c3c9db83Smrg if test -n "$1"; then 45612f60eb46Smrg realname=$1 4562c3c9db83Smrg shift 4563c3c9db83Smrg 45642f60eb46Smrg srcname=$realname 45652f60eb46Smrg test -n "$relink_command" && srcname=${realname}T 4566c3c9db83Smrg 4567c3c9db83Smrg # Install the shared library and build the symlinks. 45683f6d0e1dSmrg func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ 4569c3c9db83Smrg 'exit $?' 45702f60eb46Smrg tstripme=$stripme 4571c3c9db83Smrg case $host_os in 4572c3c9db83Smrg cygwin* | mingw* | pw32* | cegcc*) 4573c3c9db83Smrg case $realname in 4574c3c9db83Smrg *.dll.a) 45752f60eb46Smrg tstripme= 45762f60eb46Smrg ;; 45772f60eb46Smrg esac 45782f60eb46Smrg ;; 45792f60eb46Smrg os2*) 45802f60eb46Smrg case $realname in 45812f60eb46Smrg *_dll.a) 45822f60eb46Smrg tstripme= 4583c3c9db83Smrg ;; 4584c3c9db83Smrg esac 458585ee4c00Smrg ;; 458685ee4c00Smrg esac 4587c3c9db83Smrg if test -n "$tstripme" && test -n "$striplib"; then 4588c3c9db83Smrg func_show_eval "$striplib $destdir/$realname" 'exit $?' 45892e71ea71Smrg fi 4590c3c9db83Smrg 4591c3c9db83Smrg if test "$#" -gt 0; then 4592c3c9db83Smrg # Delete the old symlinks, and create new ones. 45932f60eb46Smrg # Try 'ln -sf' first, because the 'ln' binary might depend on 4594c3c9db83Smrg # the symlink we replace! Solaris /bin/ln does not understand -f, 4595c3c9db83Smrg # so we also need to try rm && ln -s. 4596c3c9db83Smrg for linkname 4597c3c9db83Smrg do 4598c3c9db83Smrg test "$linkname" != "$realname" \ 4599c3c9db83Smrg && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" 46002e71ea71Smrg done 46012e71ea71Smrg fi 4602692f60a7Smrg 4603c3c9db83Smrg # Do each command in the postinstall commands. 46042f60eb46Smrg lib=$destdir/$realname 4605c3c9db83Smrg func_execute_cmds "$postinstall_cmds" 'exit $?' 46062e71ea71Smrg fi 4607692f60a7Smrg 4608c3c9db83Smrg # Install the pseudo-library for information purposes. 4609c3c9db83Smrg func_basename "$file" 46102f60eb46Smrg name=$func_basename_result 46112f60eb46Smrg instname=$dir/${name}i 4612c3c9db83Smrg func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' 4613692f60a7Smrg 4614c3c9db83Smrg # Maybe install the static library, too. 46153f6d0e1dSmrg test -n "$old_library" && func_append staticlibs " $dir/$old_library" 4616c3c9db83Smrg ;; 4617692f60a7Smrg 4618c3c9db83Smrg *.lo) 4619c3c9db83Smrg # Install (i.e. copy) a libtool object. 4620692f60a7Smrg 4621c3c9db83Smrg # Figure out destination file name, if it wasn't already specified. 4622c3c9db83Smrg if test -n "$destname"; then 46232f60eb46Smrg destfile=$destdir/$destname 4624c3c9db83Smrg else 4625c3c9db83Smrg func_basename "$file" 46262f60eb46Smrg destfile=$func_basename_result 46272f60eb46Smrg destfile=$destdir/$destfile 46282e71ea71Smrg fi 4629692f60a7Smrg 4630c3c9db83Smrg # Deduce the name of the destination old-style object file. 4631c3c9db83Smrg case $destfile in 4632c3c9db83Smrg *.lo) 4633c3c9db83Smrg func_lo2o "$destfile" 4634c3c9db83Smrg staticdest=$func_lo2o_result 4635c3c9db83Smrg ;; 4636c3c9db83Smrg *.$objext) 46372f60eb46Smrg staticdest=$destfile 4638c3c9db83Smrg destfile= 4639c3c9db83Smrg ;; 4640c3c9db83Smrg *) 46412f60eb46Smrg func_fatal_help "cannot copy a libtool object to '$destfile'" 4642c3c9db83Smrg ;; 4643c3c9db83Smrg esac 4644692f60a7Smrg 4645c3c9db83Smrg # Install the libtool object if requested. 4646c3c9db83Smrg test -n "$destfile" && \ 4647c3c9db83Smrg func_show_eval "$install_prog $file $destfile" 'exit $?' 4648692f60a7Smrg 4649c3c9db83Smrg # Install the old object if enabled. 46502f60eb46Smrg if test yes = "$build_old_libs"; then 4651c3c9db83Smrg # Deduce the name of the old-style object file. 4652c3c9db83Smrg func_lo2o "$file" 4653c3c9db83Smrg staticobj=$func_lo2o_result 4654c3c9db83Smrg func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' 4655692f60a7Smrg fi 4656c3c9db83Smrg exit $EXIT_SUCCESS 4657c3c9db83Smrg ;; 4658692f60a7Smrg 4659c3c9db83Smrg *) 4660c3c9db83Smrg # Figure out destination file name, if it wasn't already specified. 4661c3c9db83Smrg if test -n "$destname"; then 46622f60eb46Smrg destfile=$destdir/$destname 4663c3c9db83Smrg else 4664c3c9db83Smrg func_basename "$file" 46652f60eb46Smrg destfile=$func_basename_result 46662f60eb46Smrg destfile=$destdir/$destfile 4667c3c9db83Smrg fi 4668692f60a7Smrg 4669c3c9db83Smrg # If the file is missing, and there is a .exe on the end, strip it 4670c3c9db83Smrg # because it is most likely a libtool script we actually want to 4671c3c9db83Smrg # install 46722f60eb46Smrg stripped_ext= 4673c3c9db83Smrg case $file in 4674c3c9db83Smrg *.exe) 4675c3c9db83Smrg if test ! -f "$file"; then 4676c3c9db83Smrg func_stripname '' '.exe' "$file" 4677c3c9db83Smrg file=$func_stripname_result 46782f60eb46Smrg stripped_ext=.exe 4679c3c9db83Smrg fi 4680c3c9db83Smrg ;; 4681c3c9db83Smrg esac 4682c3c9db83Smrg 4683c3c9db83Smrg # Do a test to see if this is really a libtool program. 4684c3c9db83Smrg case $host in 4685c3c9db83Smrg *cygwin* | *mingw*) 4686c3c9db83Smrg if func_ltwrapper_executable_p "$file"; then 4687c3c9db83Smrg func_ltwrapper_scriptname "$file" 4688c3c9db83Smrg wrapper=$func_ltwrapper_scriptname_result 4689c3c9db83Smrg else 4690c3c9db83Smrg func_stripname '' '.exe' "$file" 4691c3c9db83Smrg wrapper=$func_stripname_result 4692c3c9db83Smrg fi 4693c3c9db83Smrg ;; 46942e71ea71Smrg *) 4695c3c9db83Smrg wrapper=$file 4696c3c9db83Smrg ;; 4697c3c9db83Smrg esac 4698c3c9db83Smrg if func_ltwrapper_script_p "$wrapper"; then 4699c3c9db83Smrg notinst_deplibs= 4700c3c9db83Smrg relink_command= 4701c3c9db83Smrg 4702c3c9db83Smrg func_source "$wrapper" 4703c3c9db83Smrg 4704c3c9db83Smrg # Check the variables that should have been set. 4705c3c9db83Smrg test -z "$generated_by_libtool_version" && \ 47062f60eb46Smrg func_fatal_error "invalid libtool wrapper script '$wrapper'" 4707c3c9db83Smrg 47082f60eb46Smrg finalize=: 4709c3c9db83Smrg for lib in $notinst_deplibs; do 4710c3c9db83Smrg # Check to see that each library is installed. 4711c3c9db83Smrg libdir= 4712c3c9db83Smrg if test -f "$lib"; then 4713c3c9db83Smrg func_source "$lib" 4714c3c9db83Smrg fi 47152f60eb46Smrg libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'` 4716c3c9db83Smrg if test -n "$libdir" && test ! -f "$libfile"; then 47172f60eb46Smrg func_warning "'$lib' has not been installed in '$libdir'" 47182f60eb46Smrg finalize=false 4719c3c9db83Smrg fi 4720c3c9db83Smrg done 4721c3c9db83Smrg 4722c3c9db83Smrg relink_command= 4723c3c9db83Smrg func_source "$wrapper" 4724c3c9db83Smrg 4725c3c9db83Smrg outputname= 47262f60eb46Smrg if test no = "$fast_install" && test -n "$relink_command"; then 4727c3c9db83Smrg $opt_dry_run || { 47282f60eb46Smrg if $finalize; then 4729c3c9db83Smrg tmpdir=`func_mktempdir` 4730c3c9db83Smrg func_basename "$file$stripped_ext" 47312f60eb46Smrg file=$func_basename_result 47322f60eb46Smrg outputname=$tmpdir/$file 4733c3c9db83Smrg # Replace the output file specification. 47343f6d0e1dSmrg relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` 4735c3c9db83Smrg 47362f60eb46Smrg $opt_quiet || { 4737efb46889Smrg func_quote_arg expand,pretty "$relink_command" 4738efb46889Smrg eval "func_echo $func_quote_arg_result" 4739c3c9db83Smrg } 4740c3c9db83Smrg if eval "$relink_command"; then : 4741c3c9db83Smrg else 47422f60eb46Smrg func_error "error: relink '$file' with the above command before installing it" 4743c3c9db83Smrg $opt_dry_run || ${RM}r "$tmpdir" 4744c3c9db83Smrg continue 4745c3c9db83Smrg fi 47462f60eb46Smrg file=$outputname 4747c3c9db83Smrg else 47482f60eb46Smrg func_warning "cannot relink '$file'" 4749c3c9db83Smrg fi 4750c3c9db83Smrg } 4751c3c9db83Smrg else 4752c3c9db83Smrg # Install the binary that we compiled earlier. 47533f6d0e1dSmrg file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` 47542e71ea71Smrg fi 4755c3c9db83Smrg fi 4756c3c9db83Smrg 4757c3c9db83Smrg # remove .exe since cygwin /usr/bin/install will append another 4758c3c9db83Smrg # one anyway 4759c3c9db83Smrg case $install_prog,$host in 4760c3c9db83Smrg */usr/bin/install*,*cygwin*) 4761c3c9db83Smrg case $file:$destfile in 4762c3c9db83Smrg *.exe:*.exe) 4763c3c9db83Smrg # this is ok 4764c3c9db83Smrg ;; 4765c3c9db83Smrg *.exe:*) 4766c3c9db83Smrg destfile=$destfile.exe 4767c3c9db83Smrg ;; 4768c3c9db83Smrg *:*.exe) 4769c3c9db83Smrg func_stripname '' '.exe' "$destfile" 4770c3c9db83Smrg destfile=$func_stripname_result 4771c3c9db83Smrg ;; 4772c3c9db83Smrg esac 47732e71ea71Smrg ;; 47742e71ea71Smrg esac 4775c3c9db83Smrg func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' 4776c3c9db83Smrg $opt_dry_run || if test -n "$outputname"; then 4777c3c9db83Smrg ${RM}r "$tmpdir" 4778c3c9db83Smrg fi 4779c3c9db83Smrg ;; 4780c3c9db83Smrg esac 4781c3c9db83Smrg done 4782692f60a7Smrg 4783c3c9db83Smrg for file in $staticlibs; do 4784c3c9db83Smrg func_basename "$file" 47852f60eb46Smrg name=$func_basename_result 4786c3c9db83Smrg 4787c3c9db83Smrg # Set up the ranlib parameters. 47882f60eb46Smrg oldlib=$destdir/$name 478995903e71Smrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 479095903e71Smrg tool_oldlib=$func_to_tool_file_result 4791c3c9db83Smrg 4792c3c9db83Smrg func_show_eval "$install_prog \$file \$oldlib" 'exit $?' 4793c3c9db83Smrg 4794c3c9db83Smrg if test -n "$stripme" && test -n "$old_striplib"; then 479595903e71Smrg func_show_eval "$old_striplib $tool_oldlib" 'exit $?' 4796c3c9db83Smrg fi 4797c3c9db83Smrg 4798c3c9db83Smrg # Do each command in the postinstall commands. 4799c3c9db83Smrg func_execute_cmds "$old_postinstall_cmds" 'exit $?' 4800c3c9db83Smrg done 4801c3c9db83Smrg 4802c3c9db83Smrg test -n "$future_libdirs" && \ 48032f60eb46Smrg func_warning "remember to run '$progname --finish$future_libdirs'" 4804c3c9db83Smrg 4805c3c9db83Smrg if test -n "$current_libdirs"; then 4806c3c9db83Smrg # Maybe just do a dry run. 4807c3c9db83Smrg $opt_dry_run && current_libdirs=" -n$current_libdirs" 48082f60eb46Smrg exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs' 4809c3c9db83Smrg else 4810c3c9db83Smrg exit $EXIT_SUCCESS 4811c3c9db83Smrg fi 4812c3c9db83Smrg} 4813c3c9db83Smrg 48142f60eb46Smrgtest install = "$opt_mode" && func_mode_install ${1+"$@"} 4815c3c9db83Smrg 4816c3c9db83Smrg 4817c3c9db83Smrg# func_generate_dlsyms outputname originator pic_p 4818c3c9db83Smrg# Extract symbols from dlprefiles and create ${outputname}S.o with 4819c3c9db83Smrg# a dlpreopen symbol table. 4820c3c9db83Smrgfunc_generate_dlsyms () 4821c3c9db83Smrg{ 48222f60eb46Smrg $debug_cmd 48232f60eb46Smrg 48242f60eb46Smrg my_outputname=$1 48252f60eb46Smrg my_originator=$2 48262f60eb46Smrg my_pic_p=${3-false} 48272f60eb46Smrg my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'` 4828c3c9db83Smrg my_dlsyms= 4829c3c9db83Smrg 48302f60eb46Smrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 4831c3c9db83Smrg if test -n "$NM" && test -n "$global_symbol_pipe"; then 48322f60eb46Smrg my_dlsyms=${my_outputname}S.c 4833c3c9db83Smrg else 4834c3c9db83Smrg func_error "not configured to extract global symbols from dlpreopened files" 4835c3c9db83Smrg fi 4836c3c9db83Smrg fi 4837c3c9db83Smrg 4838c3c9db83Smrg if test -n "$my_dlsyms"; then 4839c3c9db83Smrg case $my_dlsyms in 4840c3c9db83Smrg "") ;; 4841c3c9db83Smrg *.c) 4842c3c9db83Smrg # Discover the nlist of each of the dlfiles. 48432f60eb46Smrg nlist=$output_objdir/$my_outputname.nm 4844c3c9db83Smrg 4845c3c9db83Smrg func_show_eval "$RM $nlist ${nlist}S ${nlist}T" 4846c3c9db83Smrg 4847c3c9db83Smrg # Parse the name list into a source file. 4848c3c9db83Smrg func_verbose "creating $output_objdir/$my_dlsyms" 4849c3c9db83Smrg 4850c3c9db83Smrg $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ 48512f60eb46Smrg/* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */ 48522f60eb46Smrg/* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */ 4853c3c9db83Smrg 4854c3c9db83Smrg#ifdef __cplusplus 4855c3c9db83Smrgextern \"C\" { 4856c3c9db83Smrg#endif 4857c3c9db83Smrg 48582f60eb46Smrg#if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) 48593f6d0e1dSmrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\" 48603f6d0e1dSmrg#endif 48613f6d0e1dSmrg 48623f6d0e1dSmrg/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ 48632f60eb46Smrg#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE 48642f60eb46Smrg/* DATA imports from DLLs on WIN32 can't be const, because runtime 48653f6d0e1dSmrg relocations are performed -- see ld's documentation on pseudo-relocs. */ 48663f6d0e1dSmrg# define LT_DLSYM_CONST 48672f60eb46Smrg#elif defined __osf__ 48683f6d0e1dSmrg/* This system does not cope well with relocations in const data. */ 48693f6d0e1dSmrg# define LT_DLSYM_CONST 48703f6d0e1dSmrg#else 48713f6d0e1dSmrg# define LT_DLSYM_CONST const 48723f6d0e1dSmrg#endif 48733f6d0e1dSmrg 48742f60eb46Smrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 48752f60eb46Smrg 4876c3c9db83Smrg/* External symbol declarations for the compiler. */\ 4877c3c9db83Smrg" 4878c3c9db83Smrg 48792f60eb46Smrg if test yes = "$dlself"; then 48802f60eb46Smrg func_verbose "generating symbol list for '$output'" 4881c3c9db83Smrg 4882c3c9db83Smrg $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" 4883c3c9db83Smrg 4884c3c9db83Smrg # Add our own program objects to the symbol list. 48853f6d0e1dSmrg progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` 4886c3c9db83Smrg for progfile in $progfiles; do 48873f6d0e1dSmrg func_to_tool_file "$progfile" func_convert_file_msys_to_w32 48882f60eb46Smrg func_verbose "extracting global C symbols from '$func_to_tool_file_result'" 48893f6d0e1dSmrg $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" 4890c3c9db83Smrg done 4891c3c9db83Smrg 4892c3c9db83Smrg if test -n "$exclude_expsyms"; then 4893c3c9db83Smrg $opt_dry_run || { 4894c3c9db83Smrg eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' 4895c3c9db83Smrg eval '$MV "$nlist"T "$nlist"' 4896c3c9db83Smrg } 48972e71ea71Smrg fi 4898c3c9db83Smrg 4899c3c9db83Smrg if test -n "$export_symbols_regex"; then 4900c3c9db83Smrg $opt_dry_run || { 4901c3c9db83Smrg eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' 4902c3c9db83Smrg eval '$MV "$nlist"T "$nlist"' 4903c3c9db83Smrg } 4904c3c9db83Smrg fi 4905c3c9db83Smrg 4906c3c9db83Smrg # Prepare the list of exported symbols 4907c3c9db83Smrg if test -z "$export_symbols"; then 49082f60eb46Smrg export_symbols=$output_objdir/$outputname.exp 4909c3c9db83Smrg $opt_dry_run || { 4910c3c9db83Smrg $RM $export_symbols 49112f60eb46Smrg eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' 4912c3c9db83Smrg case $host in 4913c3c9db83Smrg *cygwin* | *mingw* | *cegcc* ) 4914c3c9db83Smrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 4915c3c9db83Smrg eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' 4916c3c9db83Smrg ;; 4917c3c9db83Smrg esac 4918c3c9db83Smrg } 49192e71ea71Smrg else 4920c3c9db83Smrg $opt_dry_run || { 49212f60eb46Smrg eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' 4922c3c9db83Smrg eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' 4923c3c9db83Smrg eval '$MV "$nlist"T "$nlist"' 4924c3c9db83Smrg case $host in 49253f6d0e1dSmrg *cygwin* | *mingw* | *cegcc* ) 4926c3c9db83Smrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 4927c3c9db83Smrg eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' 4928c3c9db83Smrg ;; 4929c3c9db83Smrg esac 4930c3c9db83Smrg } 49312e71ea71Smrg fi 4932c3c9db83Smrg fi 4933692f60a7Smrg 4934c3c9db83Smrg for dlprefile in $dlprefiles; do 49352f60eb46Smrg func_verbose "extracting global C symbols from '$dlprefile'" 4936c3c9db83Smrg func_basename "$dlprefile" 49372f60eb46Smrg name=$func_basename_result 49383f6d0e1dSmrg case $host in 49393f6d0e1dSmrg *cygwin* | *mingw* | *cegcc* ) 49403f6d0e1dSmrg # if an import library, we need to obtain dlname 49413f6d0e1dSmrg if func_win32_import_lib_p "$dlprefile"; then 49423f6d0e1dSmrg func_tr_sh "$dlprefile" 49433f6d0e1dSmrg eval "curr_lafile=\$libfile_$func_tr_sh_result" 49442f60eb46Smrg dlprefile_dlbasename= 49453f6d0e1dSmrg if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then 49463f6d0e1dSmrg # Use subshell, to avoid clobbering current variable values 49473f6d0e1dSmrg dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` 49482f60eb46Smrg if test -n "$dlprefile_dlname"; then 49493f6d0e1dSmrg func_basename "$dlprefile_dlname" 49502f60eb46Smrg dlprefile_dlbasename=$func_basename_result 49513f6d0e1dSmrg else 49523f6d0e1dSmrg # no lafile. user explicitly requested -dlpreopen <import library>. 49533f6d0e1dSmrg $sharedlib_from_linklib_cmd "$dlprefile" 49543f6d0e1dSmrg dlprefile_dlbasename=$sharedlib_from_linklib_result 49553f6d0e1dSmrg fi 49563f6d0e1dSmrg fi 49573f6d0e1dSmrg $opt_dry_run || { 49582f60eb46Smrg if test -n "$dlprefile_dlbasename"; then 49593f6d0e1dSmrg eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' 49603f6d0e1dSmrg else 49613f6d0e1dSmrg func_warning "Could not compute DLL name from $name" 49623f6d0e1dSmrg eval '$ECHO ": $name " >> "$nlist"' 49633f6d0e1dSmrg fi 49643f6d0e1dSmrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 49653f6d0e1dSmrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | 49663f6d0e1dSmrg $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" 49673f6d0e1dSmrg } 49683f6d0e1dSmrg else # not an import lib 49693f6d0e1dSmrg $opt_dry_run || { 49703f6d0e1dSmrg eval '$ECHO ": $name " >> "$nlist"' 49713f6d0e1dSmrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 49723f6d0e1dSmrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 49733f6d0e1dSmrg } 49743f6d0e1dSmrg fi 49753f6d0e1dSmrg ;; 49763f6d0e1dSmrg *) 49773f6d0e1dSmrg $opt_dry_run || { 49783f6d0e1dSmrg eval '$ECHO ": $name " >> "$nlist"' 49793f6d0e1dSmrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 49803f6d0e1dSmrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 49813f6d0e1dSmrg } 49823f6d0e1dSmrg ;; 49833f6d0e1dSmrg esac 4984c3c9db83Smrg done 4985c3c9db83Smrg 4986c3c9db83Smrg $opt_dry_run || { 4987c3c9db83Smrg # Make sure we have at least an empty file. 4988c3c9db83Smrg test -f "$nlist" || : > "$nlist" 4989c3c9db83Smrg 4990c3c9db83Smrg if test -n "$exclude_expsyms"; then 4991c3c9db83Smrg $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T 4992c3c9db83Smrg $MV "$nlist"T "$nlist" 49932e71ea71Smrg fi 4994c3c9db83Smrg 4995c3c9db83Smrg # Try sorting and uniquifying the output. 4996c3c9db83Smrg if $GREP -v "^: " < "$nlist" | 4997c3c9db83Smrg if sort -k 3 </dev/null >/dev/null 2>&1; then 4998c3c9db83Smrg sort -k 3 4999c3c9db83Smrg else 5000c3c9db83Smrg sort +2 5001c3c9db83Smrg fi | 5002c3c9db83Smrg uniq > "$nlist"S; then 5003c3c9db83Smrg : 50042e71ea71Smrg else 5005c3c9db83Smrg $GREP -v "^: " < "$nlist" > "$nlist"S 50062e71ea71Smrg fi 5007692f60a7Smrg 5008c3c9db83Smrg if test -f "$nlist"S; then 5009c3c9db83Smrg eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' 50102e71ea71Smrg else 50113f6d0e1dSmrg echo '/* NONE */' >> "$output_objdir/$my_dlsyms" 50122e71ea71Smrg fi 5013692f60a7Smrg 50142f60eb46Smrg func_show_eval '$RM "${nlist}I"' 50152f60eb46Smrg if test -n "$global_symbol_to_import"; then 50162f60eb46Smrg eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I' 50172f60eb46Smrg fi 50182f60eb46Smrg 50193f6d0e1dSmrg echo >> "$output_objdir/$my_dlsyms" "\ 5020692f60a7Smrg 5021c3c9db83Smrg/* The mapping between symbol names and symbols. */ 5022c3c9db83Smrgtypedef struct { 5023c3c9db83Smrg const char *name; 5024c3c9db83Smrg void *address; 5025c3c9db83Smrg} lt_dlsymlist; 50263f6d0e1dSmrgextern LT_DLSYM_CONST lt_dlsymlist 50272f60eb46Smrglt_${my_prefix}_LTX_preloaded_symbols[];\ 50282f60eb46Smrg" 50292f60eb46Smrg 50302f60eb46Smrg if test -s "$nlist"I; then 50312f60eb46Smrg echo >> "$output_objdir/$my_dlsyms" "\ 50322f60eb46Smrgstatic void lt_syminit(void) 50332f60eb46Smrg{ 50342f60eb46Smrg LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols; 50352f60eb46Smrg for (; symbol->name; ++symbol) 50362f60eb46Smrg {" 50372f60eb46Smrg $SED 's/.*/ if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms" 50382f60eb46Smrg echo >> "$output_objdir/$my_dlsyms" "\ 50392f60eb46Smrg } 50402f60eb46Smrg}" 50412f60eb46Smrg fi 50422f60eb46Smrg echo >> "$output_objdir/$my_dlsyms" "\ 50433f6d0e1dSmrgLT_DLSYM_CONST lt_dlsymlist 5044c3c9db83Smrglt_${my_prefix}_LTX_preloaded_symbols[] = 50452f60eb46Smrg{ {\"$my_originator\", (void *) 0}," 50462f60eb46Smrg 50472f60eb46Smrg if test -s "$nlist"I; then 50482f60eb46Smrg echo >> "$output_objdir/$my_dlsyms" "\ 50492f60eb46Smrg {\"@INIT@\", (void *) <_syminit}," 50502f60eb46Smrg fi 5051692f60a7Smrg 5052c3c9db83Smrg case $need_lib_prefix in 5053c3c9db83Smrg no) 5054c3c9db83Smrg eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" 5055c3c9db83Smrg ;; 5056c3c9db83Smrg *) 5057c3c9db83Smrg eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" 5058c3c9db83Smrg ;; 5059c3c9db83Smrg esac 50603f6d0e1dSmrg echo >> "$output_objdir/$my_dlsyms" "\ 5061c3c9db83Smrg {0, (void *) 0} 5062c3c9db83Smrg}; 5063692f60a7Smrg 5064c3c9db83Smrg/* This works around a problem in FreeBSD linker */ 5065c3c9db83Smrg#ifdef FREEBSD_WORKAROUND 5066c3c9db83Smrgstatic const void *lt_preloaded_setup() { 5067c3c9db83Smrg return lt_${my_prefix}_LTX_preloaded_symbols; 5068c3c9db83Smrg} 5069c3c9db83Smrg#endif 5070c3c9db83Smrg 5071c3c9db83Smrg#ifdef __cplusplus 5072c3c9db83Smrg} 5073c3c9db83Smrg#endif\ 5074c3c9db83Smrg" 5075c3c9db83Smrg } # !$opt_dry_run 5076c3c9db83Smrg 5077c3c9db83Smrg pic_flag_for_symtable= 5078c3c9db83Smrg case "$compile_command " in 5079c3c9db83Smrg *" -static "*) ;; 5080c3c9db83Smrg *) 5081c3c9db83Smrg case $host in 5082c3c9db83Smrg # compiling the symbol table file with pic_flag works around 5083c3c9db83Smrg # a FreeBSD bug that causes programs to crash when -lm is 5084c3c9db83Smrg # linked before any other PIC object. But we must not use 5085c3c9db83Smrg # pic_flag when linking with -static. The problem exists in 5086c3c9db83Smrg # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. 508795903e71Smrg *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) 5088c3c9db83Smrg pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; 5089c3c9db83Smrg *-*-hpux*) 5090c3c9db83Smrg pic_flag_for_symtable=" $pic_flag" ;; 5091c3c9db83Smrg *) 50922f60eb46Smrg $my_pic_p && pic_flag_for_symtable=" $pic_flag" 5093c3c9db83Smrg ;; 5094c3c9db83Smrg esac 5095c3c9db83Smrg ;; 5096c3c9db83Smrg esac 5097c3c9db83Smrg symtab_cflags= 5098c3c9db83Smrg for arg in $LTCFLAGS; do 5099c3c9db83Smrg case $arg in 5100c3c9db83Smrg -pie | -fpie | -fPIE) ;; 51013f6d0e1dSmrg *) func_append symtab_cflags " $arg" ;; 5102c3c9db83Smrg esac 5103c3c9db83Smrg done 5104692f60a7Smrg 5105c3c9db83Smrg # Now compile the dynamic symbol file. 5106c3c9db83Smrg func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' 510785ee4c00Smrg 5108c3c9db83Smrg # Clean up the generated files. 51092f60eb46Smrg func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"' 5110692f60a7Smrg 5111c3c9db83Smrg # Transform the symbol file into the correct name. 51122f60eb46Smrg symfileobj=$output_objdir/${my_outputname}S.$objext 5113c3c9db83Smrg case $host in 5114c3c9db83Smrg *cygwin* | *mingw* | *cegcc* ) 5115c3c9db83Smrg if test -f "$output_objdir/$my_outputname.def"; then 51163f6d0e1dSmrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 51173f6d0e1dSmrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 5118c3c9db83Smrg else 51193f6d0e1dSmrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 51203f6d0e1dSmrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 51212e71ea71Smrg fi 5122c3c9db83Smrg ;; 5123c3c9db83Smrg *) 51243f6d0e1dSmrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 51253f6d0e1dSmrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 5126c3c9db83Smrg ;; 5127c3c9db83Smrg esac 5128c3c9db83Smrg ;; 5129c3c9db83Smrg *) 51302f60eb46Smrg func_fatal_error "unknown suffix for '$my_dlsyms'" 5131c3c9db83Smrg ;; 5132c3c9db83Smrg esac 5133c3c9db83Smrg else 5134c3c9db83Smrg # We keep going just in case the user didn't refer to 5135c3c9db83Smrg # lt_preloaded_symbols. The linker will fail if global_symbol_pipe 5136c3c9db83Smrg # really was required. 5137692f60a7Smrg 5138c3c9db83Smrg # Nullify the symbol file. 51393f6d0e1dSmrg compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` 51403f6d0e1dSmrg finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` 5141c3c9db83Smrg fi 5142c3c9db83Smrg} 514385ee4c00Smrg 51442f60eb46Smrg# func_cygming_gnu_implib_p ARG 51452f60eb46Smrg# This predicate returns with zero status (TRUE) if 51462f60eb46Smrg# ARG is a GNU/binutils-style import library. Returns 51472f60eb46Smrg# with nonzero status (FALSE) otherwise. 51482f60eb46Smrgfunc_cygming_gnu_implib_p () 51492f60eb46Smrg{ 51502f60eb46Smrg $debug_cmd 51512f60eb46Smrg 51522f60eb46Smrg func_to_tool_file "$1" func_convert_file_msys_to_w32 51532f60eb46Smrg 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)$'` 51542f60eb46Smrg test -n "$func_cygming_gnu_implib_tmp" 51552f60eb46Smrg} 51562f60eb46Smrg 51572f60eb46Smrg# func_cygming_ms_implib_p ARG 51582f60eb46Smrg# This predicate returns with zero status (TRUE) if 51592f60eb46Smrg# ARG is an MS-style import library. Returns 51602f60eb46Smrg# with nonzero status (FALSE) otherwise. 51612f60eb46Smrgfunc_cygming_ms_implib_p () 51622f60eb46Smrg{ 51632f60eb46Smrg $debug_cmd 51642f60eb46Smrg 51652f60eb46Smrg func_to_tool_file "$1" func_convert_file_msys_to_w32 51662f60eb46Smrg func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` 51672f60eb46Smrg test -n "$func_cygming_ms_implib_tmp" 51682f60eb46Smrg} 51692f60eb46Smrg 5170c3c9db83Smrg# func_win32_libid arg 5171c3c9db83Smrg# return the library type of file 'arg' 5172c3c9db83Smrg# 5173c3c9db83Smrg# Need a lot of goo to handle *both* DLLs and import libs 5174c3c9db83Smrg# Has to be a shell function in order to 'eat' the argument 5175c3c9db83Smrg# that is supplied when $file_magic_command is called. 51763f6d0e1dSmrg# Despite the name, also deal with 64 bit binaries. 5177c3c9db83Smrgfunc_win32_libid () 5178c3c9db83Smrg{ 51792f60eb46Smrg $debug_cmd 51802f60eb46Smrg 51812f60eb46Smrg win32_libid_type=unknown 5182c3c9db83Smrg win32_fileres=`file -L $1 2>/dev/null` 5183c3c9db83Smrg case $win32_fileres in 5184c3c9db83Smrg *ar\ archive\ import\ library*) # definitely import 5185c3c9db83Smrg win32_libid_type="x86 archive import" 5186c3c9db83Smrg ;; 5187c3c9db83Smrg *ar\ archive*) # could be an import, or static 51883f6d0e1dSmrg # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. 5189c3c9db83Smrg if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | 51903f6d0e1dSmrg $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then 51912f60eb46Smrg case $nm_interface in 51922f60eb46Smrg "MS dumpbin") 51932f60eb46Smrg if func_cygming_ms_implib_p "$1" || 51942f60eb46Smrg func_cygming_gnu_implib_p "$1" 51952f60eb46Smrg then 51962f60eb46Smrg win32_nmres=import 51972f60eb46Smrg else 51982f60eb46Smrg win32_nmres= 51992f60eb46Smrg fi 52002f60eb46Smrg ;; 52012f60eb46Smrg *) 52022f60eb46Smrg func_to_tool_file "$1" func_convert_file_msys_to_w32 52032f60eb46Smrg win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | 52042f60eb46Smrg $SED -n -e ' 5205c3c9db83Smrg 1,100{ 5206c3c9db83Smrg / I /{ 52072f60eb46Smrg s|.*|import| 5208c3c9db83Smrg p 5209c3c9db83Smrg q 5210c3c9db83Smrg } 5211c3c9db83Smrg }'` 52122f60eb46Smrg ;; 52132f60eb46Smrg esac 5214c3c9db83Smrg case $win32_nmres in 5215c3c9db83Smrg import*) win32_libid_type="x86 archive import";; 5216c3c9db83Smrg *) win32_libid_type="x86 archive static";; 5217c3c9db83Smrg esac 5218c3c9db83Smrg fi 5219c3c9db83Smrg ;; 5220c3c9db83Smrg *DLL*) 5221c3c9db83Smrg win32_libid_type="x86 DLL" 5222c3c9db83Smrg ;; 5223c3c9db83Smrg *executable*) # but shell scripts are "executable" too... 5224c3c9db83Smrg case $win32_fileres in 5225c3c9db83Smrg *MS\ Windows\ PE\ Intel*) 5226c3c9db83Smrg win32_libid_type="x86 DLL" 5227c3c9db83Smrg ;; 5228c3c9db83Smrg esac 5229c3c9db83Smrg ;; 5230c3c9db83Smrg esac 5231c3c9db83Smrg $ECHO "$win32_libid_type" 5232c3c9db83Smrg} 523385ee4c00Smrg 52343f6d0e1dSmrg# func_cygming_dll_for_implib ARG 52353f6d0e1dSmrg# 52363f6d0e1dSmrg# Platform-specific function to extract the 52373f6d0e1dSmrg# name of the DLL associated with the specified 52383f6d0e1dSmrg# import library ARG. 52393f6d0e1dSmrg# Invoked by eval'ing the libtool variable 52403f6d0e1dSmrg# $sharedlib_from_linklib_cmd 52413f6d0e1dSmrg# Result is available in the variable 52423f6d0e1dSmrg# $sharedlib_from_linklib_result 52433f6d0e1dSmrgfunc_cygming_dll_for_implib () 52443f6d0e1dSmrg{ 52452f60eb46Smrg $debug_cmd 52462f60eb46Smrg 52473f6d0e1dSmrg sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` 52483f6d0e1dSmrg} 52493f6d0e1dSmrg 52503f6d0e1dSmrg# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs 52513f6d0e1dSmrg# 52523f6d0e1dSmrg# The is the core of a fallback implementation of a 52533f6d0e1dSmrg# platform-specific function to extract the name of the 52543f6d0e1dSmrg# DLL associated with the specified import library LIBNAME. 52553f6d0e1dSmrg# 52563f6d0e1dSmrg# SECTION_NAME is either .idata$6 or .idata$7, depending 52573f6d0e1dSmrg# on the platform and compiler that created the implib. 52583f6d0e1dSmrg# 52593f6d0e1dSmrg# Echos the name of the DLL associated with the 52603f6d0e1dSmrg# specified import library. 52613f6d0e1dSmrgfunc_cygming_dll_for_implib_fallback_core () 52623f6d0e1dSmrg{ 52632f60eb46Smrg $debug_cmd 52642f60eb46Smrg 52653f6d0e1dSmrg match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` 52663f6d0e1dSmrg $OBJDUMP -s --section "$1" "$2" 2>/dev/null | 52673f6d0e1dSmrg $SED '/^Contents of section '"$match_literal"':/{ 52683f6d0e1dSmrg # Place marker at beginning of archive member dllname section 52693f6d0e1dSmrg s/.*/====MARK====/ 52703f6d0e1dSmrg p 52713f6d0e1dSmrg d 52723f6d0e1dSmrg } 52733f6d0e1dSmrg # These lines can sometimes be longer than 43 characters, but 52743f6d0e1dSmrg # are always uninteresting 52753f6d0e1dSmrg /:[ ]*file format pe[i]\{,1\}-/d 52763f6d0e1dSmrg /^In archive [^:]*:/d 52773f6d0e1dSmrg # Ensure marker is printed 52783f6d0e1dSmrg /^====MARK====/p 52793f6d0e1dSmrg # Remove all lines with less than 43 characters 52803f6d0e1dSmrg /^.\{43\}/!d 52813f6d0e1dSmrg # From remaining lines, remove first 43 characters 52823f6d0e1dSmrg s/^.\{43\}//' | 52833f6d0e1dSmrg $SED -n ' 52843f6d0e1dSmrg # Join marker and all lines until next marker into a single line 52853f6d0e1dSmrg /^====MARK====/ b para 52863f6d0e1dSmrg H 52873f6d0e1dSmrg $ b para 52883f6d0e1dSmrg b 52893f6d0e1dSmrg :para 52903f6d0e1dSmrg x 52913f6d0e1dSmrg s/\n//g 52923f6d0e1dSmrg # Remove the marker 52933f6d0e1dSmrg s/^====MARK====// 52943f6d0e1dSmrg # Remove trailing dots and whitespace 52953f6d0e1dSmrg s/[\. \t]*$// 52963f6d0e1dSmrg # Print 52973f6d0e1dSmrg /./p' | 52983f6d0e1dSmrg # we now have a list, one entry per line, of the stringified 52993f6d0e1dSmrg # contents of the appropriate section of all members of the 53002f60eb46Smrg # archive that possess that section. Heuristic: eliminate 53012f60eb46Smrg # all those that have a first or second character that is 53023f6d0e1dSmrg # a '.' (that is, objdump's representation of an unprintable 53033f6d0e1dSmrg # character.) This should work for all archives with less than 53043f6d0e1dSmrg # 0x302f exports -- but will fail for DLLs whose name actually 53053f6d0e1dSmrg # begins with a literal '.' or a single character followed by 53063f6d0e1dSmrg # a '.'. 53073f6d0e1dSmrg # 53083f6d0e1dSmrg # Of those that remain, print the first one. 53093f6d0e1dSmrg $SED -e '/^\./d;/^.\./d;q' 53103f6d0e1dSmrg} 53113f6d0e1dSmrg 53123f6d0e1dSmrg# func_cygming_dll_for_implib_fallback ARG 53133f6d0e1dSmrg# Platform-specific function to extract the 53143f6d0e1dSmrg# name of the DLL associated with the specified 53153f6d0e1dSmrg# import library ARG. 53163f6d0e1dSmrg# 53173f6d0e1dSmrg# This fallback implementation is for use when $DLLTOOL 53183f6d0e1dSmrg# does not support the --identify-strict option. 53193f6d0e1dSmrg# Invoked by eval'ing the libtool variable 53203f6d0e1dSmrg# $sharedlib_from_linklib_cmd 53213f6d0e1dSmrg# Result is available in the variable 53223f6d0e1dSmrg# $sharedlib_from_linklib_result 53233f6d0e1dSmrgfunc_cygming_dll_for_implib_fallback () 53243f6d0e1dSmrg{ 53252f60eb46Smrg $debug_cmd 53262f60eb46Smrg 53272f60eb46Smrg if func_cygming_gnu_implib_p "$1"; then 53283f6d0e1dSmrg # binutils import library 53293f6d0e1dSmrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` 53302f60eb46Smrg elif func_cygming_ms_implib_p "$1"; then 53313f6d0e1dSmrg # ms-generated import library 53323f6d0e1dSmrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` 53333f6d0e1dSmrg else 53343f6d0e1dSmrg # unknown 53352f60eb46Smrg sharedlib_from_linklib_result= 53363f6d0e1dSmrg fi 53373f6d0e1dSmrg} 533885ee4c00Smrg 533985ee4c00Smrg 5340c3c9db83Smrg# func_extract_an_archive dir oldlib 5341c3c9db83Smrgfunc_extract_an_archive () 5342c3c9db83Smrg{ 53432f60eb46Smrg $debug_cmd 53442f60eb46Smrg 53452f60eb46Smrg f_ex_an_ar_dir=$1; shift 53462f60eb46Smrg f_ex_an_ar_oldlib=$1 53472f60eb46Smrg if test yes = "$lock_old_archive_extraction"; then 53483f6d0e1dSmrg lockfile=$f_ex_an_ar_oldlib.lock 53493f6d0e1dSmrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 53503f6d0e1dSmrg func_echo "Waiting for $lockfile to be removed" 53513f6d0e1dSmrg sleep 2 53523f6d0e1dSmrg done 53533f6d0e1dSmrg fi 53543f6d0e1dSmrg func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ 53553f6d0e1dSmrg 'stat=$?; rm -f "$lockfile"; exit $stat' 53562f60eb46Smrg if test yes = "$lock_old_archive_extraction"; then 53573f6d0e1dSmrg $opt_dry_run || rm -f "$lockfile" 53583f6d0e1dSmrg fi 5359c3c9db83Smrg if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then 5360c3c9db83Smrg : 5361c3c9db83Smrg else 5362c3c9db83Smrg func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 5363c3c9db83Smrg fi 5364c3c9db83Smrg} 5365692f60a7Smrg 5366692f60a7Smrg 5367c3c9db83Smrg# func_extract_archives gentop oldlib ... 5368c3c9db83Smrgfunc_extract_archives () 5369c3c9db83Smrg{ 53702f60eb46Smrg $debug_cmd 53712f60eb46Smrg 53722f60eb46Smrg my_gentop=$1; shift 5373c3c9db83Smrg my_oldlibs=${1+"$@"} 53742f60eb46Smrg my_oldobjs= 53752f60eb46Smrg my_xlib= 53762f60eb46Smrg my_xabs= 53772f60eb46Smrg my_xdir= 5378692f60a7Smrg 5379c3c9db83Smrg for my_xlib in $my_oldlibs; do 5380c3c9db83Smrg # Extract the objects. 5381c3c9db83Smrg case $my_xlib in 53822f60eb46Smrg [\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;; 5383c3c9db83Smrg *) my_xabs=`pwd`"/$my_xlib" ;; 5384c3c9db83Smrg esac 5385c3c9db83Smrg func_basename "$my_xlib" 53862f60eb46Smrg my_xlib=$func_basename_result 5387c3c9db83Smrg my_xlib_u=$my_xlib 5388c3c9db83Smrg while :; do 5389c3c9db83Smrg case " $extracted_archives " in 5390c3c9db83Smrg *" $my_xlib_u "*) 5391c3c9db83Smrg func_arith $extracted_serial + 1 5392c3c9db83Smrg extracted_serial=$func_arith_result 5393c3c9db83Smrg my_xlib_u=lt$extracted_serial-$my_xlib ;; 5394c3c9db83Smrg *) break ;; 5395c3c9db83Smrg esac 5396c3c9db83Smrg done 5397c3c9db83Smrg extracted_archives="$extracted_archives $my_xlib_u" 53982f60eb46Smrg my_xdir=$my_gentop/$my_xlib_u 5399692f60a7Smrg 5400c3c9db83Smrg func_mkdir_p "$my_xdir" 540185ee4c00Smrg 5402c3c9db83Smrg case $host in 5403c3c9db83Smrg *-darwin*) 5404c3c9db83Smrg func_verbose "Extracting $my_xabs" 5405c3c9db83Smrg # Do not bother doing anything if just a dry run 5406c3c9db83Smrg $opt_dry_run || { 5407c3c9db83Smrg darwin_orig_dir=`pwd` 5408c3c9db83Smrg cd $my_xdir || exit $? 5409c3c9db83Smrg darwin_archive=$my_xabs 5410c3c9db83Smrg darwin_curdir=`pwd` 54112f60eb46Smrg func_basename "$darwin_archive" 54122f60eb46Smrg darwin_base_archive=$func_basename_result 5413c3c9db83Smrg darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` 5414c3c9db83Smrg if test -n "$darwin_arches"; then 5415c3c9db83Smrg darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` 5416c3c9db83Smrg darwin_arch= 5417c3c9db83Smrg func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" 54182f60eb46Smrg for darwin_arch in $darwin_arches; do 54192f60eb46Smrg func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch" 54202f60eb46Smrg $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive" 54212f60eb46Smrg cd "unfat-$$/$darwin_base_archive-$darwin_arch" 54222f60eb46Smrg func_extract_an_archive "`pwd`" "$darwin_base_archive" 5423c3c9db83Smrg cd "$darwin_curdir" 54242f60eb46Smrg $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" 5425c3c9db83Smrg done # $darwin_arches 5426c3c9db83Smrg ## Okay now we've a bunch of thin objects, gotta fatten them up :) 54272f60eb46Smrg darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$sed_basename" | sort -u` 5428c3c9db83Smrg darwin_file= 5429c3c9db83Smrg darwin_files= 5430c3c9db83Smrg for darwin_file in $darwin_filelist; do 54313f6d0e1dSmrg darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` 5432c3c9db83Smrg $LIPO -create -output "$darwin_file" $darwin_files 5433c3c9db83Smrg done # $darwin_filelist 5434c3c9db83Smrg $RM -rf unfat-$$ 5435c3c9db83Smrg cd "$darwin_orig_dir" 54362e71ea71Smrg else 5437c3c9db83Smrg cd $darwin_orig_dir 5438c3c9db83Smrg func_extract_an_archive "$my_xdir" "$my_xabs" 5439c3c9db83Smrg fi # $darwin_arches 5440c3c9db83Smrg } # !$opt_dry_run 5441c3c9db83Smrg ;; 5442c3c9db83Smrg *) 5443c3c9db83Smrg func_extract_an_archive "$my_xdir" "$my_xabs" 5444c3c9db83Smrg ;; 5445c3c9db83Smrg esac 54463f6d0e1dSmrg my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` 5447c3c9db83Smrg done 5448692f60a7Smrg 54492f60eb46Smrg func_extract_archives_result=$my_oldobjs 5450c3c9db83Smrg} 5451692f60a7Smrg 5452692f60a7Smrg 54533f6d0e1dSmrg# func_emit_wrapper [arg=no] 54543f6d0e1dSmrg# 54553f6d0e1dSmrg# Emit a libtool wrapper script on stdout. 54563f6d0e1dSmrg# Don't directly open a file because we may want to 54573f6d0e1dSmrg# incorporate the script contents within a cygwin/mingw 54583f6d0e1dSmrg# wrapper executable. Must ONLY be called from within 54593f6d0e1dSmrg# func_mode_link because it depends on a number of variables 54603f6d0e1dSmrg# set therein. 5461c3c9db83Smrg# 54623f6d0e1dSmrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR 54633f6d0e1dSmrg# variable will take. If 'yes', then the emitted script 54642f60eb46Smrg# will assume that the directory where it is stored is 54653f6d0e1dSmrg# the $objdir directory. This is a cygwin/mingw-specific 54663f6d0e1dSmrg# behavior. 54673f6d0e1dSmrgfunc_emit_wrapper () 5468c3c9db83Smrg{ 54693f6d0e1dSmrg func_emit_wrapper_arg1=${1-no} 54702e71ea71Smrg 5471c3c9db83Smrg $ECHO "\ 5472c3c9db83Smrg#! $SHELL 5473692f60a7Smrg 5474c3c9db83Smrg# $output - temporary wrapper script for $objdir/$outputname 54752f60eb46Smrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 5476c3c9db83Smrg# 5477c3c9db83Smrg# The $output program cannot be directly executed until all the libtool 5478c3c9db83Smrg# libraries that it depends on are installed. 5479c3c9db83Smrg# 5480c3c9db83Smrg# This wrapper script should never be moved out of the build directory. 5481c3c9db83Smrg# If it is, it will not operate correctly. 5482692f60a7Smrg 5483c3c9db83Smrg# Sed substitution that helps us do robust quoting. It backslashifies 5484c3c9db83Smrg# metacharacters that are still active within double-quoted strings. 5485c3c9db83Smrgsed_quote_subst='$sed_quote_subst' 5486692f60a7Smrg 5487c3c9db83Smrg# Be Bourne compatible 5488c3c9db83Smrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then 5489c3c9db83Smrg emulate sh 5490c3c9db83Smrg NULLCMD=: 5491c3c9db83Smrg # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which 5492c3c9db83Smrg # is contrary to our usage. Disable this feature. 5493c3c9db83Smrg alias -g '\${1+\"\$@\"}'='\"\$@\"' 5494c3c9db83Smrg setopt NO_GLOB_SUBST 5495c3c9db83Smrgelse 5496c3c9db83Smrg case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac 5497c3c9db83Smrgfi 5498c3c9db83SmrgBIN_SH=xpg4; export BIN_SH # for Tru64 5499c3c9db83SmrgDUALCASE=1; export DUALCASE # for MKS sh 5500692f60a7Smrg 5501c3c9db83Smrg# The HP-UX ksh and POSIX shell print the target directory to stdout 5502c3c9db83Smrg# if CDPATH is set. 5503c3c9db83Smrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 5504692f60a7Smrg 5505c3c9db83Smrgrelink_command=\"$relink_command\" 5506692f60a7Smrg 5507c3c9db83Smrg# This environment variable determines our operation mode. 5508c3c9db83Smrgif test \"\$libtool_install_magic\" = \"$magic\"; then 5509c3c9db83Smrg # install mode needs the following variables: 5510c3c9db83Smrg generated_by_libtool_version='$macro_version' 5511c3c9db83Smrg notinst_deplibs='$notinst_deplibs' 5512c3c9db83Smrgelse 5513c3c9db83Smrg # When we are sourced in execute mode, \$file and \$ECHO are already set. 5514c3c9db83Smrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 55153f6d0e1dSmrg file=\"\$0\"" 55163f6d0e1dSmrg 5517efb46889Smrg func_quote_arg pretty "$ECHO" 5518efb46889Smrg qECHO=$func_quote_arg_result 55193f6d0e1dSmrg $ECHO "\ 55203f6d0e1dSmrg 55213f6d0e1dSmrg# A function that is used when there is no print builtin or printf. 55223f6d0e1dSmrgfunc_fallback_echo () 55233f6d0e1dSmrg{ 55243f6d0e1dSmrg eval 'cat <<_LTECHO_EOF 55253f6d0e1dSmrg\$1 55263f6d0e1dSmrg_LTECHO_EOF' 55273f6d0e1dSmrg} 5528efb46889Smrg ECHO=$qECHO 55293f6d0e1dSmrg fi 55303f6d0e1dSmrg 55313f6d0e1dSmrg# Very basic option parsing. These options are (a) specific to 55323f6d0e1dSmrg# the libtool wrapper, (b) are identical between the wrapper 55332f60eb46Smrg# /script/ and the wrapper /executable/ that is used only on 55343f6d0e1dSmrg# windows platforms, and (c) all begin with the string "--lt-" 55352f60eb46Smrg# (application programs are unlikely to have options that match 55363f6d0e1dSmrg# this pattern). 55373f6d0e1dSmrg# 55383f6d0e1dSmrg# There are only two supported options: --lt-debug and 55393f6d0e1dSmrg# --lt-dump-script. There is, deliberately, no --lt-help. 55403f6d0e1dSmrg# 55413f6d0e1dSmrg# The first argument to this parsing function should be the 55423f6d0e1dSmrg# script's $0 value, followed by "$@". 55433f6d0e1dSmrglt_option_debug= 55443f6d0e1dSmrgfunc_parse_lt_options () 55453f6d0e1dSmrg{ 55463f6d0e1dSmrg lt_script_arg0=\$0 55473f6d0e1dSmrg shift 55483f6d0e1dSmrg for lt_opt 55493f6d0e1dSmrg do 55503f6d0e1dSmrg case \"\$lt_opt\" in 55513f6d0e1dSmrg --lt-debug) lt_option_debug=1 ;; 55523f6d0e1dSmrg --lt-dump-script) 55533f6d0e1dSmrg lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` 55543f6d0e1dSmrg test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. 55553f6d0e1dSmrg lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` 55563f6d0e1dSmrg cat \"\$lt_dump_D/\$lt_dump_F\" 55573f6d0e1dSmrg exit 0 55583f6d0e1dSmrg ;; 55593f6d0e1dSmrg --lt-*) 55603f6d0e1dSmrg \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 55613f6d0e1dSmrg exit 1 55623f6d0e1dSmrg ;; 55633f6d0e1dSmrg esac 55643f6d0e1dSmrg done 55653f6d0e1dSmrg 55663f6d0e1dSmrg # Print the debug banner immediately: 55673f6d0e1dSmrg if test -n \"\$lt_option_debug\"; then 55682f60eb46Smrg echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2 55693f6d0e1dSmrg fi 55703f6d0e1dSmrg} 55713f6d0e1dSmrg 55723f6d0e1dSmrg# Used when --lt-debug. Prints its arguments to stdout 55733f6d0e1dSmrg# (redirection is the responsibility of the caller) 55743f6d0e1dSmrgfunc_lt_dump_args () 55753f6d0e1dSmrg{ 55763f6d0e1dSmrg lt_dump_args_N=1; 55773f6d0e1dSmrg for lt_arg 55783f6d0e1dSmrg do 55792f60eb46Smrg \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\" 55803f6d0e1dSmrg lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` 55813f6d0e1dSmrg done 55823f6d0e1dSmrg} 55833f6d0e1dSmrg 55843f6d0e1dSmrg# Core function for launching the target application 55853f6d0e1dSmrgfunc_exec_program_core () 55863f6d0e1dSmrg{ 5587c3c9db83Smrg" 55883f6d0e1dSmrg case $host in 55893f6d0e1dSmrg # Backslashes separate directories on plain windows 55903f6d0e1dSmrg *-*-mingw | *-*-os2* | *-cegcc*) 55913f6d0e1dSmrg $ECHO "\ 55923f6d0e1dSmrg if test -n \"\$lt_option_debug\"; then 55932f60eb46Smrg \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2 55943f6d0e1dSmrg func_lt_dump_args \${1+\"\$@\"} 1>&2 55953f6d0e1dSmrg fi 55963f6d0e1dSmrg exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} 55973f6d0e1dSmrg" 55983f6d0e1dSmrg ;; 55993f6d0e1dSmrg 56003f6d0e1dSmrg *) 56013f6d0e1dSmrg $ECHO "\ 56023f6d0e1dSmrg if test -n \"\$lt_option_debug\"; then 56032f60eb46Smrg \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2 56043f6d0e1dSmrg func_lt_dump_args \${1+\"\$@\"} 1>&2 56053f6d0e1dSmrg fi 56063f6d0e1dSmrg exec \"\$progdir/\$program\" \${1+\"\$@\"} 56073f6d0e1dSmrg" 56083f6d0e1dSmrg ;; 56093f6d0e1dSmrg esac 56103f6d0e1dSmrg $ECHO "\ 56113f6d0e1dSmrg \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 56123f6d0e1dSmrg exit 1 56133f6d0e1dSmrg} 56143f6d0e1dSmrg 56153f6d0e1dSmrg# A function to encapsulate launching the target application 56163f6d0e1dSmrg# Strips options in the --lt-* namespace from \$@ and 56173f6d0e1dSmrg# launches target application with the remaining arguments. 56183f6d0e1dSmrgfunc_exec_program () 56193f6d0e1dSmrg{ 562095903e71Smrg case \" \$* \" in 562195903e71Smrg *\\ --lt-*) 562295903e71Smrg for lt_wr_arg 562395903e71Smrg do 562495903e71Smrg case \$lt_wr_arg in 562595903e71Smrg --lt-*) ;; 562695903e71Smrg *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; 562795903e71Smrg esac 562895903e71Smrg shift 562995903e71Smrg done ;; 563095903e71Smrg esac 56313f6d0e1dSmrg func_exec_program_core \${1+\"\$@\"} 56323f6d0e1dSmrg} 56333f6d0e1dSmrg 56343f6d0e1dSmrg # Parse options 56353f6d0e1dSmrg func_parse_lt_options \"\$0\" \${1+\"\$@\"} 5636692f60a7Smrg 5637c3c9db83Smrg # Find the directory that this script lives in. 56383f6d0e1dSmrg thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` 5639c3c9db83Smrg test \"x\$thisdir\" = \"x\$file\" && thisdir=. 5640692f60a7Smrg 5641c3c9db83Smrg # Follow symbolic links until we get to the real thisdir. 56423f6d0e1dSmrg file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` 5643c3c9db83Smrg while test -n \"\$file\"; do 56443f6d0e1dSmrg destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` 5645692f60a7Smrg 5646c3c9db83Smrg # If there was a directory component, then change thisdir. 5647c3c9db83Smrg if test \"x\$destdir\" != \"x\$file\"; then 5648c3c9db83Smrg case \"\$destdir\" in 5649c3c9db83Smrg [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; 5650c3c9db83Smrg *) thisdir=\"\$thisdir/\$destdir\" ;; 56512e71ea71Smrg esac 5652c3c9db83Smrg fi 5653692f60a7Smrg 56543f6d0e1dSmrg file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` 56553f6d0e1dSmrg file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` 5656c3c9db83Smrg done 5657692f60a7Smrg 5658c3c9db83Smrg # Usually 'no', except on cygwin/mingw when embedded into 5659c3c9db83Smrg # the cwrapper. 56603f6d0e1dSmrg WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 5661c3c9db83Smrg if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then 5662c3c9db83Smrg # special case for '.' 5663c3c9db83Smrg if test \"\$thisdir\" = \".\"; then 5664c3c9db83Smrg thisdir=\`pwd\` 5665c3c9db83Smrg fi 5666c3c9db83Smrg # remove .libs from thisdir 5667c3c9db83Smrg case \"\$thisdir\" in 56683f6d0e1dSmrg *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; 5669c3c9db83Smrg $objdir ) thisdir=. ;; 5670c3c9db83Smrg esac 5671c3c9db83Smrg fi 5672c3c9db83Smrg 5673c3c9db83Smrg # Try to get the absolute directory name. 5674c3c9db83Smrg absdir=\`cd \"\$thisdir\" && pwd\` 5675c3c9db83Smrg test -n \"\$absdir\" && thisdir=\"\$absdir\" 5676c3c9db83Smrg" 5677c3c9db83Smrg 56782f60eb46Smrg if test yes = "$fast_install"; then 5679c3c9db83Smrg $ECHO "\ 5680c3c9db83Smrg program=lt-'$outputname'$exeext 5681c3c9db83Smrg progdir=\"\$thisdir/$objdir\" 5682c3c9db83Smrg 5683c3c9db83Smrg if test ! -f \"\$progdir/\$program\" || 56842f60eb46Smrg { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\ 5685c3c9db83Smrg test \"X\$file\" != \"X\$progdir/\$program\"; }; then 5686c3c9db83Smrg 5687c3c9db83Smrg file=\"\$\$-\$program\" 5688c3c9db83Smrg 5689c3c9db83Smrg if test ! -d \"\$progdir\"; then 5690c3c9db83Smrg $MKDIR \"\$progdir\" 5691c3c9db83Smrg else 5692c3c9db83Smrg $RM \"\$progdir/\$file\" 5693c3c9db83Smrg fi" 5694c3c9db83Smrg 5695c3c9db83Smrg $ECHO "\ 5696c3c9db83Smrg 5697c3c9db83Smrg # relink executable if necessary 5698c3c9db83Smrg if test -n \"\$relink_command\"; then 5699c3c9db83Smrg if relink_command_output=\`eval \$relink_command 2>&1\`; then : 5700c3c9db83Smrg else 57012f60eb46Smrg \$ECHO \"\$relink_command_output\" >&2 5702c3c9db83Smrg $RM \"\$progdir/\$file\" 5703c3c9db83Smrg exit 1 57042e71ea71Smrg fi 5705c3c9db83Smrg fi 5706692f60a7Smrg 5707c3c9db83Smrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || 5708c3c9db83Smrg { $RM \"\$progdir/\$program\"; 5709c3c9db83Smrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } 5710c3c9db83Smrg $RM \"\$progdir/\$file\" 5711c3c9db83Smrg fi" 5712c3c9db83Smrg else 5713c3c9db83Smrg $ECHO "\ 5714c3c9db83Smrg program='$outputname' 5715c3c9db83Smrg progdir=\"\$thisdir/$objdir\" 5716c3c9db83Smrg" 57172e71ea71Smrg fi 5718692f60a7Smrg 5719c3c9db83Smrg $ECHO "\ 5720692f60a7Smrg 5721c3c9db83Smrg if test -f \"\$progdir/\$program\"; then" 5722692f60a7Smrg 57233f6d0e1dSmrg # fixup the dll searchpath if we need to. 57243f6d0e1dSmrg # 57253f6d0e1dSmrg # Fix the DLL searchpath if we need to. Do this before prepending 57263f6d0e1dSmrg # to shlibpath, because on Windows, both are PATH and uninstalled 57273f6d0e1dSmrg # libraries must come first. 57283f6d0e1dSmrg if test -n "$dllsearchpath"; then 57293f6d0e1dSmrg $ECHO "\ 57303f6d0e1dSmrg # Add the dll search path components to the executable PATH 57313f6d0e1dSmrg PATH=$dllsearchpath:\$PATH 57323f6d0e1dSmrg" 57333f6d0e1dSmrg fi 57343f6d0e1dSmrg 5735c3c9db83Smrg # Export our shlibpath_var if we have one. 57362f60eb46Smrg if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 5737c3c9db83Smrg $ECHO "\ 5738c3c9db83Smrg # Add our own library path to $shlibpath_var 5739c3c9db83Smrg $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" 5740c3c9db83Smrg 5741c3c9db83Smrg # Some systems cannot cope with colon-terminated $shlibpath_var 5742c3c9db83Smrg # The second colon is a workaround for a bug in BeOS R4 sed 57433f6d0e1dSmrg $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` 5744692f60a7Smrg 5745c3c9db83Smrg export $shlibpath_var 5746c3c9db83Smrg" 57472e71ea71Smrg fi 5748692f60a7Smrg 5749c3c9db83Smrg $ECHO "\ 5750c3c9db83Smrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 5751c3c9db83Smrg # Run the actual program with our arguments. 57523f6d0e1dSmrg func_exec_program \${1+\"\$@\"} 5753c3c9db83Smrg fi 5754c3c9db83Smrg else 5755c3c9db83Smrg # The program doesn't exist. 57562f60eb46Smrg \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2 5757c3c9db83Smrg \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 57583f6d0e1dSmrg \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 5759c3c9db83Smrg exit 1 5760c3c9db83Smrg fi 5761c3c9db83Smrgfi\ 5762c3c9db83Smrg" 5763c3c9db83Smrg} 5764692f60a7Smrg 576585ee4c00Smrg 5766c3c9db83Smrg# func_emit_cwrapperexe_src 5767c3c9db83Smrg# emit the source code for a wrapper executable on stdout 5768c3c9db83Smrg# Must ONLY be called from within func_mode_link because 5769c3c9db83Smrg# it depends on a number of variable set therein. 5770c3c9db83Smrgfunc_emit_cwrapperexe_src () 5771c3c9db83Smrg{ 5772c3c9db83Smrg cat <<EOF 5773692f60a7Smrg 5774c3c9db83Smrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname 57752f60eb46Smrg Generated by $PROGRAM (GNU $PACKAGE) $VERSION 5776692f60a7Smrg 5777c3c9db83Smrg The $output program cannot be directly executed until all the libtool 5778c3c9db83Smrg libraries that it depends on are installed. 5779692f60a7Smrg 5780c3c9db83Smrg This wrapper executable should never be moved out of the build directory. 5781c3c9db83Smrg If it is, it will not operate correctly. 5782c3c9db83Smrg*/ 5783c3c9db83SmrgEOF 5784c3c9db83Smrg cat <<"EOF" 57853f6d0e1dSmrg#ifdef _MSC_VER 57863f6d0e1dSmrg# define _CRT_SECURE_NO_DEPRECATE 1 57873f6d0e1dSmrg#endif 5788c3c9db83Smrg#include <stdio.h> 5789c3c9db83Smrg#include <stdlib.h> 5790c3c9db83Smrg#ifdef _MSC_VER 5791c3c9db83Smrg# include <direct.h> 5792c3c9db83Smrg# include <process.h> 5793c3c9db83Smrg# include <io.h> 5794c3c9db83Smrg#else 5795c3c9db83Smrg# include <unistd.h> 5796c3c9db83Smrg# include <stdint.h> 5797c3c9db83Smrg# ifdef __CYGWIN__ 5798c3c9db83Smrg# include <io.h> 5799c3c9db83Smrg# endif 5800c3c9db83Smrg#endif 5801c3c9db83Smrg#include <malloc.h> 5802c3c9db83Smrg#include <stdarg.h> 5803c3c9db83Smrg#include <assert.h> 5804c3c9db83Smrg#include <string.h> 5805c3c9db83Smrg#include <ctype.h> 5806c3c9db83Smrg#include <errno.h> 5807c3c9db83Smrg#include <fcntl.h> 5808c3c9db83Smrg#include <sys/stat.h> 5809692f60a7Smrg 58102f60eb46Smrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 58112f60eb46Smrg 58123f6d0e1dSmrg/* declarations of non-ANSI functions */ 58132f60eb46Smrg#if defined __MINGW32__ 58143f6d0e1dSmrg# ifdef __STRICT_ANSI__ 58153f6d0e1dSmrgint _putenv (const char *); 58163f6d0e1dSmrg# endif 58172f60eb46Smrg#elif defined __CYGWIN__ 58183f6d0e1dSmrg# ifdef __STRICT_ANSI__ 58193f6d0e1dSmrgchar *realpath (const char *, char *); 58203f6d0e1dSmrgint putenv (char *); 58213f6d0e1dSmrgint setenv (const char *, const char *, int); 58223f6d0e1dSmrg# endif 58232f60eb46Smrg/* #elif defined other_platform || defined ... */ 58243f6d0e1dSmrg#endif 58253f6d0e1dSmrg 58263f6d0e1dSmrg/* portability defines, excluding path handling macros */ 58272f60eb46Smrg#if defined _MSC_VER 58283f6d0e1dSmrg# define setmode _setmode 58293f6d0e1dSmrg# define stat _stat 58303f6d0e1dSmrg# define chmod _chmod 58313f6d0e1dSmrg# define getcwd _getcwd 58323f6d0e1dSmrg# define putenv _putenv 58333f6d0e1dSmrg# define S_IXUSR _S_IEXEC 58342f60eb46Smrg#elif defined __MINGW32__ 58353f6d0e1dSmrg# define setmode _setmode 58363f6d0e1dSmrg# define stat _stat 58373f6d0e1dSmrg# define chmod _chmod 58383f6d0e1dSmrg# define getcwd _getcwd 58393f6d0e1dSmrg# define putenv _putenv 58402f60eb46Smrg#elif defined __CYGWIN__ 58413f6d0e1dSmrg# define HAVE_SETENV 58423f6d0e1dSmrg# define FOPEN_WB "wb" 58432f60eb46Smrg/* #elif defined other platforms ... */ 58443f6d0e1dSmrg#endif 58453f6d0e1dSmrg 58462f60eb46Smrg#if defined PATH_MAX 5847c3c9db83Smrg# define LT_PATHMAX PATH_MAX 58482f60eb46Smrg#elif defined MAXPATHLEN 5849c3c9db83Smrg# define LT_PATHMAX MAXPATHLEN 5850c3c9db83Smrg#else 5851c3c9db83Smrg# define LT_PATHMAX 1024 5852c3c9db83Smrg#endif 5853692f60a7Smrg 5854c3c9db83Smrg#ifndef S_IXOTH 5855c3c9db83Smrg# define S_IXOTH 0 5856c3c9db83Smrg#endif 5857c3c9db83Smrg#ifndef S_IXGRP 5858c3c9db83Smrg# define S_IXGRP 0 5859c3c9db83Smrg#endif 5860692f60a7Smrg 58613f6d0e1dSmrg/* path handling portability macros */ 5862c3c9db83Smrg#ifndef DIR_SEPARATOR 5863c3c9db83Smrg# define DIR_SEPARATOR '/' 5864c3c9db83Smrg# define PATH_SEPARATOR ':' 5865c3c9db83Smrg#endif 5866692f60a7Smrg 58672f60eb46Smrg#if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \ 58682f60eb46Smrg defined __OS2__ 5869c3c9db83Smrg# define HAVE_DOS_BASED_FILE_SYSTEM 5870c3c9db83Smrg# define FOPEN_WB "wb" 5871c3c9db83Smrg# ifndef DIR_SEPARATOR_2 5872c3c9db83Smrg# define DIR_SEPARATOR_2 '\\' 5873c3c9db83Smrg# endif 5874c3c9db83Smrg# ifndef PATH_SEPARATOR_2 5875c3c9db83Smrg# define PATH_SEPARATOR_2 ';' 5876c3c9db83Smrg# endif 5877c3c9db83Smrg#endif 5878692f60a7Smrg 5879c3c9db83Smrg#ifndef DIR_SEPARATOR_2 5880c3c9db83Smrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) 5881c3c9db83Smrg#else /* DIR_SEPARATOR_2 */ 5882c3c9db83Smrg# define IS_DIR_SEPARATOR(ch) \ 5883c3c9db83Smrg (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) 5884c3c9db83Smrg#endif /* DIR_SEPARATOR_2 */ 5885692f60a7Smrg 5886c3c9db83Smrg#ifndef PATH_SEPARATOR_2 5887c3c9db83Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) 5888c3c9db83Smrg#else /* PATH_SEPARATOR_2 */ 5889c3c9db83Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) 5890c3c9db83Smrg#endif /* PATH_SEPARATOR_2 */ 5891692f60a7Smrg 5892c3c9db83Smrg#ifndef FOPEN_WB 5893c3c9db83Smrg# define FOPEN_WB "w" 5894c3c9db83Smrg#endif 5895c3c9db83Smrg#ifndef _O_BINARY 5896c3c9db83Smrg# define _O_BINARY 0 5897c3c9db83Smrg#endif 5898692f60a7Smrg 5899c3c9db83Smrg#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) 5900c3c9db83Smrg#define XFREE(stale) do { \ 59012f60eb46Smrg if (stale) { free (stale); stale = 0; } \ 5902c3c9db83Smrg} while (0) 5903692f60a7Smrg 59042f60eb46Smrg#if defined LT_DEBUGWRAPPER 59053f6d0e1dSmrgstatic int lt_debug = 1; 5906c3c9db83Smrg#else 59073f6d0e1dSmrgstatic int lt_debug = 0; 5908c3c9db83Smrg#endif 5909692f60a7Smrg 59103f6d0e1dSmrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ 5911692f60a7Smrg 5912c3c9db83Smrgvoid *xmalloc (size_t num); 5913c3c9db83Smrgchar *xstrdup (const char *string); 5914c3c9db83Smrgconst char *base_name (const char *name); 5915c3c9db83Smrgchar *find_executable (const char *wrapper); 5916c3c9db83Smrgchar *chase_symlinks (const char *pathspec); 5917c3c9db83Smrgint make_executable (const char *path); 5918c3c9db83Smrgint check_executable (const char *path); 5919c3c9db83Smrgchar *strendzap (char *str, const char *pat); 59203f6d0e1dSmrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...); 59213f6d0e1dSmrgvoid lt_fatal (const char *file, int line, const char *message, ...); 59223f6d0e1dSmrgstatic const char *nonnull (const char *s); 59233f6d0e1dSmrgstatic const char *nonempty (const char *s); 5924c3c9db83Smrgvoid lt_setenv (const char *name, const char *value); 5925c3c9db83Smrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end); 5926c3c9db83Smrgvoid lt_update_exe_path (const char *name, const char *value); 5927c3c9db83Smrgvoid lt_update_lib_path (const char *name, const char *value); 59283f6d0e1dSmrgchar **prepare_spawn (char **argv); 59293f6d0e1dSmrgvoid lt_dump_script (FILE *f); 5930c3c9db83SmrgEOF 5931c3c9db83Smrg 5932c3c9db83Smrg cat <<EOF 59332f60eb46Smrg#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5) 59342f60eb46Smrg# define externally_visible volatile 59352f60eb46Smrg#else 59362f60eb46Smrg# define externally_visible __attribute__((externally_visible)) volatile 59372f60eb46Smrg#endif 59382f60eb46Smrgexternally_visible const char * MAGIC_EXE = "$magic_exe"; 5939c3c9db83Smrgconst char * LIB_PATH_VARNAME = "$shlibpath_var"; 5940c3c9db83SmrgEOF 5941692f60a7Smrg 59422f60eb46Smrg if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 59433f6d0e1dSmrg func_to_host_path "$temp_rpath" 5944c3c9db83Smrg cat <<EOF 59453f6d0e1dSmrgconst char * LIB_PATH_VALUE = "$func_to_host_path_result"; 5946c3c9db83SmrgEOF 5947c3c9db83Smrg else 5948c3c9db83Smrg cat <<"EOF" 5949c3c9db83Smrgconst char * LIB_PATH_VALUE = ""; 5950c3c9db83SmrgEOF 59512e71ea71Smrg fi 5952692f60a7Smrg 5953c3c9db83Smrg if test -n "$dllsearchpath"; then 59543f6d0e1dSmrg func_to_host_path "$dllsearchpath:" 5955c3c9db83Smrg cat <<EOF 5956c3c9db83Smrgconst char * EXE_PATH_VARNAME = "PATH"; 59573f6d0e1dSmrgconst char * EXE_PATH_VALUE = "$func_to_host_path_result"; 59582e71ea71SmrgEOF 59592e71ea71Smrg else 5960c3c9db83Smrg cat <<"EOF" 5961c3c9db83Smrgconst char * EXE_PATH_VARNAME = ""; 5962c3c9db83Smrgconst char * EXE_PATH_VALUE = ""; 5963c3c9db83SmrgEOF 59642e71ea71Smrg fi 5965c3c9db83Smrg 59662f60eb46Smrg if test yes = "$fast_install"; then 5967c3c9db83Smrg cat <<EOF 5968c3c9db83Smrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */ 5969c3c9db83SmrgEOF 59702e71ea71Smrg else 5971c3c9db83Smrg cat <<EOF 5972c3c9db83Smrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */ 5973c3c9db83SmrgEOF 59742e71ea71Smrg fi 5975692f60a7Smrg 5976692f60a7Smrg 5977c3c9db83Smrg cat <<"EOF" 5978692f60a7Smrg 5979c3c9db83Smrg#define LTWRAPPER_OPTION_PREFIX "--lt-" 5980692f60a7Smrg 5981c3c9db83Smrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX; 5982c3c9db83Smrgstatic const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script"; 59833f6d0e1dSmrgstatic const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug"; 5984692f60a7Smrg 5985c3c9db83Smrgint 5986c3c9db83Smrgmain (int argc, char *argv[]) 5987c3c9db83Smrg{ 5988c3c9db83Smrg char **newargz; 5989c3c9db83Smrg int newargc; 5990c3c9db83Smrg char *tmp_pathspec; 5991c3c9db83Smrg char *actual_cwrapper_path; 5992c3c9db83Smrg char *actual_cwrapper_name; 5993c3c9db83Smrg char *target_name; 5994c3c9db83Smrg char *lt_argv_zero; 59952f60eb46Smrg int rval = 127; 5996692f60a7Smrg 5997c3c9db83Smrg int i; 5998692f60a7Smrg 5999c3c9db83Smrg program_name = (char *) xstrdup (base_name (argv[0])); 60002f60eb46Smrg newargz = XMALLOC (char *, (size_t) argc + 1); 6001692f60a7Smrg 60023f6d0e1dSmrg /* very simple arg parsing; don't want to rely on getopt 60033f6d0e1dSmrg * also, copy all non cwrapper options to newargz, except 60043f6d0e1dSmrg * argz[0], which is handled differently 60053f6d0e1dSmrg */ 60063f6d0e1dSmrg newargc=0; 6007c3c9db83Smrg for (i = 1; i < argc; i++) 6008c3c9db83Smrg { 60092f60eb46Smrg if (STREQ (argv[i], dumpscript_opt)) 6010c3c9db83Smrg { 6011c3c9db83SmrgEOF 60122f60eb46Smrg case $host in 6013c3c9db83Smrg *mingw* | *cygwin* ) 6014c3c9db83Smrg # make stdout use "unix" line endings 6015c3c9db83Smrg echo " setmode(1,_O_BINARY);" 6016c3c9db83Smrg ;; 6017c3c9db83Smrg esac 6018692f60a7Smrg 6019c3c9db83Smrg cat <<"EOF" 60203f6d0e1dSmrg lt_dump_script (stdout); 6021c3c9db83Smrg return 0; 6022c3c9db83Smrg } 60232f60eb46Smrg if (STREQ (argv[i], debug_opt)) 60243f6d0e1dSmrg { 60253f6d0e1dSmrg lt_debug = 1; 60263f6d0e1dSmrg continue; 60273f6d0e1dSmrg } 60282f60eb46Smrg if (STREQ (argv[i], ltwrapper_option_prefix)) 60293f6d0e1dSmrg { 60303f6d0e1dSmrg /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX 60313f6d0e1dSmrg namespace, but it is not one of the ones we know about and 60323f6d0e1dSmrg have already dealt with, above (inluding dump-script), then 60333f6d0e1dSmrg report an error. Otherwise, targets might begin to believe 60343f6d0e1dSmrg they are allowed to use options in the LTWRAPPER_OPTION_PREFIX 60353f6d0e1dSmrg namespace. The first time any user complains about this, we'll 60363f6d0e1dSmrg need to make LTWRAPPER_OPTION_PREFIX a configure-time option 60373f6d0e1dSmrg or a configure.ac-settable value. 60383f6d0e1dSmrg */ 60393f6d0e1dSmrg lt_fatal (__FILE__, __LINE__, 60403f6d0e1dSmrg "unrecognized %s option: '%s'", 60413f6d0e1dSmrg ltwrapper_option_prefix, argv[i]); 60423f6d0e1dSmrg } 60433f6d0e1dSmrg /* otherwise ... */ 60443f6d0e1dSmrg newargz[++newargc] = xstrdup (argv[i]); 6045c3c9db83Smrg } 60463f6d0e1dSmrg newargz[++newargc] = NULL; 60473f6d0e1dSmrg 60483f6d0e1dSmrgEOF 60493f6d0e1dSmrg cat <<EOF 60503f6d0e1dSmrg /* The GNU banner must be the first non-error debug message */ 60512f60eb46Smrg lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE) $VERSION\n"); 60523f6d0e1dSmrgEOF 60533f6d0e1dSmrg cat <<"EOF" 60543f6d0e1dSmrg lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]); 60553f6d0e1dSmrg lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name); 6056692f60a7Smrg 6057c3c9db83Smrg tmp_pathspec = find_executable (argv[0]); 6058c3c9db83Smrg if (tmp_pathspec == NULL) 60593f6d0e1dSmrg lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]); 60603f6d0e1dSmrg lt_debugprintf (__FILE__, __LINE__, 60613f6d0e1dSmrg "(main) found exe (before symlink chase) at: %s\n", 60623f6d0e1dSmrg tmp_pathspec); 6063c3c9db83Smrg 6064c3c9db83Smrg actual_cwrapper_path = chase_symlinks (tmp_pathspec); 60653f6d0e1dSmrg lt_debugprintf (__FILE__, __LINE__, 60663f6d0e1dSmrg "(main) found exe (after symlink chase) at: %s\n", 60673f6d0e1dSmrg actual_cwrapper_path); 6068c3c9db83Smrg XFREE (tmp_pathspec); 6069c3c9db83Smrg 60703f6d0e1dSmrg actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path)); 6071c3c9db83Smrg strendzap (actual_cwrapper_path, actual_cwrapper_name); 6072c3c9db83Smrg 6073c3c9db83Smrg /* wrapper name transforms */ 6074c3c9db83Smrg strendzap (actual_cwrapper_name, ".exe"); 6075c3c9db83Smrg tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1); 6076c3c9db83Smrg XFREE (actual_cwrapper_name); 6077c3c9db83Smrg actual_cwrapper_name = tmp_pathspec; 6078c3c9db83Smrg tmp_pathspec = 0; 6079c3c9db83Smrg 6080c3c9db83Smrg /* target_name transforms -- use actual target program name; might have lt- prefix */ 6081c3c9db83Smrg target_name = xstrdup (base_name (TARGET_PROGRAM_NAME)); 6082c3c9db83Smrg strendzap (target_name, ".exe"); 6083c3c9db83Smrg tmp_pathspec = lt_extend_str (target_name, ".exe", 1); 6084c3c9db83Smrg XFREE (target_name); 6085c3c9db83Smrg target_name = tmp_pathspec; 6086c3c9db83Smrg tmp_pathspec = 0; 6087c3c9db83Smrg 60883f6d0e1dSmrg lt_debugprintf (__FILE__, __LINE__, 60893f6d0e1dSmrg "(main) libtool target name: %s\n", 60903f6d0e1dSmrg target_name); 6091c3c9db83SmrgEOF 6092692f60a7Smrg 6093c3c9db83Smrg cat <<EOF 6094c3c9db83Smrg newargz[0] = 6095c3c9db83Smrg XMALLOC (char, (strlen (actual_cwrapper_path) + 6096c3c9db83Smrg strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1)); 6097c3c9db83Smrg strcpy (newargz[0], actual_cwrapper_path); 6098c3c9db83Smrg strcat (newargz[0], "$objdir"); 6099c3c9db83Smrg strcat (newargz[0], "/"); 6100c3c9db83SmrgEOF 6101692f60a7Smrg 6102c3c9db83Smrg cat <<"EOF" 6103c3c9db83Smrg /* stop here, and copy so we don't have to do this twice */ 6104c3c9db83Smrg tmp_pathspec = xstrdup (newargz[0]); 6105692f60a7Smrg 6106c3c9db83Smrg /* do NOT want the lt- prefix here, so use actual_cwrapper_name */ 6107c3c9db83Smrg strcat (newargz[0], actual_cwrapper_name); 6108692f60a7Smrg 6109c3c9db83Smrg /* DO want the lt- prefix here if it exists, so use target_name */ 6110c3c9db83Smrg lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1); 6111c3c9db83Smrg XFREE (tmp_pathspec); 6112c3c9db83Smrg tmp_pathspec = NULL; 6113c3c9db83SmrgEOF 6114692f60a7Smrg 6115c3c9db83Smrg case $host_os in 6116c3c9db83Smrg mingw*) 6117c3c9db83Smrg cat <<"EOF" 6118c3c9db83Smrg { 6119c3c9db83Smrg char* p; 6120c3c9db83Smrg while ((p = strchr (newargz[0], '\\')) != NULL) 6121c3c9db83Smrg { 6122c3c9db83Smrg *p = '/'; 6123c3c9db83Smrg } 6124c3c9db83Smrg while ((p = strchr (lt_argv_zero, '\\')) != NULL) 6125c3c9db83Smrg { 6126c3c9db83Smrg *p = '/'; 6127c3c9db83Smrg } 6128c3c9db83Smrg } 6129c3c9db83SmrgEOF 6130c3c9db83Smrg ;; 6131c3c9db83Smrg esac 6132692f60a7Smrg 6133c3c9db83Smrg cat <<"EOF" 6134c3c9db83Smrg XFREE (target_name); 6135c3c9db83Smrg XFREE (actual_cwrapper_path); 6136c3c9db83Smrg XFREE (actual_cwrapper_name); 6137692f60a7Smrg 6138c3c9db83Smrg lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */ 6139c3c9db83Smrg lt_setenv ("DUALCASE", "1"); /* for MSK sh */ 61403f6d0e1dSmrg /* Update the DLL searchpath. EXE_PATH_VALUE ($dllsearchpath) must 61413f6d0e1dSmrg be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath) 61423f6d0e1dSmrg because on Windows, both *_VARNAMEs are PATH but uninstalled 61433f6d0e1dSmrg libraries must come first. */ 6144c3c9db83Smrg lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE); 61453f6d0e1dSmrg lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE); 6146692f60a7Smrg 61473f6d0e1dSmrg lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n", 61483f6d0e1dSmrg nonnull (lt_argv_zero)); 6149c3c9db83Smrg for (i = 0; i < newargc; i++) 6150c3c9db83Smrg { 61513f6d0e1dSmrg lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n", 61523f6d0e1dSmrg i, nonnull (newargz[i])); 6153c3c9db83Smrg } 6154692f60a7Smrg 6155c3c9db83SmrgEOF 6156692f60a7Smrg 6157c3c9db83Smrg case $host_os in 6158c3c9db83Smrg mingw*) 6159c3c9db83Smrg cat <<"EOF" 6160c3c9db83Smrg /* execv doesn't actually work on mingw as expected on unix */ 61613f6d0e1dSmrg newargz = prepare_spawn (newargz); 61622f60eb46Smrg rval = (int) _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz); 6163c3c9db83Smrg if (rval == -1) 6164c3c9db83Smrg { 6165c3c9db83Smrg /* failed to start process */ 61663f6d0e1dSmrg lt_debugprintf (__FILE__, __LINE__, 61673f6d0e1dSmrg "(main) failed to launch target \"%s\": %s\n", 61683f6d0e1dSmrg lt_argv_zero, nonnull (strerror (errno))); 6169c3c9db83Smrg return 127; 6170c3c9db83Smrg } 6171c3c9db83Smrg return rval; 6172c3c9db83SmrgEOF 6173c3c9db83Smrg ;; 6174c3c9db83Smrg *) 6175c3c9db83Smrg cat <<"EOF" 6176c3c9db83Smrg execv (lt_argv_zero, newargz); 6177c3c9db83Smrg return rval; /* =127, but avoids unused variable warning */ 6178c3c9db83SmrgEOF 6179c3c9db83Smrg ;; 6180c3c9db83Smrg esac 6181692f60a7Smrg 6182c3c9db83Smrg cat <<"EOF" 6183c3c9db83Smrg} 6184692f60a7Smrg 6185c3c9db83Smrgvoid * 6186c3c9db83Smrgxmalloc (size_t num) 6187c3c9db83Smrg{ 6188c3c9db83Smrg void *p = (void *) malloc (num); 6189c3c9db83Smrg if (!p) 61903f6d0e1dSmrg lt_fatal (__FILE__, __LINE__, "memory exhausted"); 6191692f60a7Smrg 6192c3c9db83Smrg return p; 6193c3c9db83Smrg} 6194692f60a7Smrg 6195c3c9db83Smrgchar * 6196c3c9db83Smrgxstrdup (const char *string) 6197c3c9db83Smrg{ 6198c3c9db83Smrg return string ? strcpy ((char *) xmalloc (strlen (string) + 1), 6199c3c9db83Smrg string) : NULL; 6200c3c9db83Smrg} 6201692f60a7Smrg 6202c3c9db83Smrgconst char * 6203c3c9db83Smrgbase_name (const char *name) 6204c3c9db83Smrg{ 6205c3c9db83Smrg const char *base; 62062e71ea71Smrg 62072f60eb46Smrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 6208c3c9db83Smrg /* Skip over the disk name in MSDOS pathnames. */ 6209c3c9db83Smrg if (isalpha ((unsigned char) name[0]) && name[1] == ':') 6210c3c9db83Smrg name += 2; 6211c3c9db83Smrg#endif 62122e71ea71Smrg 6213c3c9db83Smrg for (base = name; *name; name++) 6214c3c9db83Smrg if (IS_DIR_SEPARATOR (*name)) 6215c3c9db83Smrg base = name + 1; 6216c3c9db83Smrg return base; 6217c3c9db83Smrg} 62182e71ea71Smrg 6219c3c9db83Smrgint 6220c3c9db83Smrgcheck_executable (const char *path) 6221c3c9db83Smrg{ 6222c3c9db83Smrg struct stat st; 62232e71ea71Smrg 62243f6d0e1dSmrg lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n", 62253f6d0e1dSmrg nonempty (path)); 6226c3c9db83Smrg if ((!path) || (!*path)) 6227c3c9db83Smrg return 0; 62282e71ea71Smrg 6229c3c9db83Smrg if ((stat (path, &st) >= 0) 6230c3c9db83Smrg && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) 6231c3c9db83Smrg return 1; 6232c3c9db83Smrg else 6233c3c9db83Smrg return 0; 6234c3c9db83Smrg} 6235692f60a7Smrg 6236c3c9db83Smrgint 6237c3c9db83Smrgmake_executable (const char *path) 6238c3c9db83Smrg{ 6239c3c9db83Smrg int rval = 0; 6240c3c9db83Smrg struct stat st; 6241692f60a7Smrg 62423f6d0e1dSmrg lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", 62433f6d0e1dSmrg nonempty (path)); 6244c3c9db83Smrg if ((!path) || (!*path)) 6245c3c9db83Smrg return 0; 624685ee4c00Smrg 6247c3c9db83Smrg if (stat (path, &st) >= 0) 6248c3c9db83Smrg { 6249c3c9db83Smrg rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); 6250c3c9db83Smrg } 6251c3c9db83Smrg return rval; 6252c3c9db83Smrg} 62532e71ea71Smrg 6254c3c9db83Smrg/* Searches for the full path of the wrapper. Returns 6255c3c9db83Smrg newly allocated full path name if found, NULL otherwise 6256c3c9db83Smrg Does not chase symlinks, even on platforms that support them. 6257c3c9db83Smrg*/ 6258c3c9db83Smrgchar * 6259c3c9db83Smrgfind_executable (const char *wrapper) 6260c3c9db83Smrg{ 6261c3c9db83Smrg int has_slash = 0; 6262c3c9db83Smrg const char *p; 6263c3c9db83Smrg const char *p_next; 6264c3c9db83Smrg /* static buffer for getcwd */ 6265c3c9db83Smrg char tmp[LT_PATHMAX + 1]; 62662f60eb46Smrg size_t tmp_len; 6267c3c9db83Smrg char *concat_name; 62682e71ea71Smrg 62693f6d0e1dSmrg lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", 62703f6d0e1dSmrg nonempty (wrapper)); 62712e71ea71Smrg 6272c3c9db83Smrg if ((wrapper == NULL) || (*wrapper == '\0')) 6273c3c9db83Smrg return NULL; 62742e71ea71Smrg 6275c3c9db83Smrg /* Absolute path? */ 62762f60eb46Smrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 6277c3c9db83Smrg if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') 6278c3c9db83Smrg { 6279c3c9db83Smrg concat_name = xstrdup (wrapper); 6280c3c9db83Smrg if (check_executable (concat_name)) 6281c3c9db83Smrg return concat_name; 6282c3c9db83Smrg XFREE (concat_name); 6283c3c9db83Smrg } 6284c3c9db83Smrg else 6285c3c9db83Smrg { 6286c3c9db83Smrg#endif 6287c3c9db83Smrg if (IS_DIR_SEPARATOR (wrapper[0])) 6288c3c9db83Smrg { 6289c3c9db83Smrg concat_name = xstrdup (wrapper); 6290c3c9db83Smrg if (check_executable (concat_name)) 6291c3c9db83Smrg return concat_name; 6292c3c9db83Smrg XFREE (concat_name); 6293c3c9db83Smrg } 62942f60eb46Smrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 6295c3c9db83Smrg } 6296c3c9db83Smrg#endif 6297692f60a7Smrg 6298c3c9db83Smrg for (p = wrapper; *p; p++) 6299c3c9db83Smrg if (*p == '/') 6300c3c9db83Smrg { 6301c3c9db83Smrg has_slash = 1; 6302c3c9db83Smrg break; 6303c3c9db83Smrg } 6304c3c9db83Smrg if (!has_slash) 6305c3c9db83Smrg { 6306c3c9db83Smrg /* no slashes; search PATH */ 6307c3c9db83Smrg const char *path = getenv ("PATH"); 6308c3c9db83Smrg if (path != NULL) 6309c3c9db83Smrg { 6310c3c9db83Smrg for (p = path; *p; p = p_next) 6311c3c9db83Smrg { 6312c3c9db83Smrg const char *q; 6313c3c9db83Smrg size_t p_len; 6314c3c9db83Smrg for (q = p; *q; q++) 6315c3c9db83Smrg if (IS_PATH_SEPARATOR (*q)) 6316c3c9db83Smrg break; 63172f60eb46Smrg p_len = (size_t) (q - p); 6318c3c9db83Smrg p_next = (*q == '\0' ? q : q + 1); 6319c3c9db83Smrg if (p_len == 0) 6320c3c9db83Smrg { 6321c3c9db83Smrg /* empty path: current directory */ 6322c3c9db83Smrg if (getcwd (tmp, LT_PATHMAX) == NULL) 63233f6d0e1dSmrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 63243f6d0e1dSmrg nonnull (strerror (errno))); 6325c3c9db83Smrg tmp_len = strlen (tmp); 6326c3c9db83Smrg concat_name = 6327c3c9db83Smrg XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 6328c3c9db83Smrg memcpy (concat_name, tmp, tmp_len); 6329c3c9db83Smrg concat_name[tmp_len] = '/'; 6330c3c9db83Smrg strcpy (concat_name + tmp_len + 1, wrapper); 6331c3c9db83Smrg } 6332c3c9db83Smrg else 6333c3c9db83Smrg { 6334c3c9db83Smrg concat_name = 6335c3c9db83Smrg XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); 6336c3c9db83Smrg memcpy (concat_name, p, p_len); 6337c3c9db83Smrg concat_name[p_len] = '/'; 6338c3c9db83Smrg strcpy (concat_name + p_len + 1, wrapper); 6339c3c9db83Smrg } 6340c3c9db83Smrg if (check_executable (concat_name)) 6341c3c9db83Smrg return concat_name; 6342c3c9db83Smrg XFREE (concat_name); 6343c3c9db83Smrg } 6344c3c9db83Smrg } 6345c3c9db83Smrg /* not found in PATH; assume curdir */ 6346c3c9db83Smrg } 6347c3c9db83Smrg /* Relative path | not found in path: prepend cwd */ 6348c3c9db83Smrg if (getcwd (tmp, LT_PATHMAX) == NULL) 63493f6d0e1dSmrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 63503f6d0e1dSmrg nonnull (strerror (errno))); 6351c3c9db83Smrg tmp_len = strlen (tmp); 6352c3c9db83Smrg concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 6353c3c9db83Smrg memcpy (concat_name, tmp, tmp_len); 6354c3c9db83Smrg concat_name[tmp_len] = '/'; 6355c3c9db83Smrg strcpy (concat_name + tmp_len + 1, wrapper); 6356692f60a7Smrg 6357c3c9db83Smrg if (check_executable (concat_name)) 6358c3c9db83Smrg return concat_name; 6359c3c9db83Smrg XFREE (concat_name); 6360c3c9db83Smrg return NULL; 6361c3c9db83Smrg} 6362692f60a7Smrg 6363c3c9db83Smrgchar * 6364c3c9db83Smrgchase_symlinks (const char *pathspec) 6365c3c9db83Smrg{ 6366c3c9db83Smrg#ifndef S_ISLNK 6367c3c9db83Smrg return xstrdup (pathspec); 6368c3c9db83Smrg#else 6369c3c9db83Smrg char buf[LT_PATHMAX]; 6370c3c9db83Smrg struct stat s; 6371c3c9db83Smrg char *tmp_pathspec = xstrdup (pathspec); 6372c3c9db83Smrg char *p; 6373c3c9db83Smrg int has_symlinks = 0; 6374c3c9db83Smrg while (strlen (tmp_pathspec) && !has_symlinks) 6375c3c9db83Smrg { 63763f6d0e1dSmrg lt_debugprintf (__FILE__, __LINE__, 63773f6d0e1dSmrg "checking path component for symlinks: %s\n", 63783f6d0e1dSmrg tmp_pathspec); 6379c3c9db83Smrg if (lstat (tmp_pathspec, &s) == 0) 6380c3c9db83Smrg { 6381c3c9db83Smrg if (S_ISLNK (s.st_mode) != 0) 6382c3c9db83Smrg { 6383c3c9db83Smrg has_symlinks = 1; 6384c3c9db83Smrg break; 6385c3c9db83Smrg } 6386692f60a7Smrg 6387c3c9db83Smrg /* search backwards for last DIR_SEPARATOR */ 6388c3c9db83Smrg p = tmp_pathspec + strlen (tmp_pathspec) - 1; 6389c3c9db83Smrg while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 6390c3c9db83Smrg p--; 6391c3c9db83Smrg if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 6392c3c9db83Smrg { 6393c3c9db83Smrg /* no more DIR_SEPARATORS left */ 6394c3c9db83Smrg break; 6395c3c9db83Smrg } 6396c3c9db83Smrg *p = '\0'; 6397c3c9db83Smrg } 6398c3c9db83Smrg else 6399c3c9db83Smrg { 64003f6d0e1dSmrg lt_fatal (__FILE__, __LINE__, 64013f6d0e1dSmrg "error accessing file \"%s\": %s", 64023f6d0e1dSmrg tmp_pathspec, nonnull (strerror (errno))); 6403c3c9db83Smrg } 6404c3c9db83Smrg } 6405c3c9db83Smrg XFREE (tmp_pathspec); 6406692f60a7Smrg 6407c3c9db83Smrg if (!has_symlinks) 6408c3c9db83Smrg { 6409c3c9db83Smrg return xstrdup (pathspec); 6410c3c9db83Smrg } 6411692f60a7Smrg 6412c3c9db83Smrg tmp_pathspec = realpath (pathspec, buf); 6413c3c9db83Smrg if (tmp_pathspec == 0) 6414c3c9db83Smrg { 64153f6d0e1dSmrg lt_fatal (__FILE__, __LINE__, 64163f6d0e1dSmrg "could not follow symlinks for %s", pathspec); 6417c3c9db83Smrg } 6418c3c9db83Smrg return xstrdup (tmp_pathspec); 6419c3c9db83Smrg#endif 6420c3c9db83Smrg} 6421692f60a7Smrg 6422c3c9db83Smrgchar * 6423c3c9db83Smrgstrendzap (char *str, const char *pat) 6424c3c9db83Smrg{ 6425c3c9db83Smrg size_t len, patlen; 6426692f60a7Smrg 6427c3c9db83Smrg assert (str != NULL); 6428c3c9db83Smrg assert (pat != NULL); 6429692f60a7Smrg 6430c3c9db83Smrg len = strlen (str); 6431c3c9db83Smrg patlen = strlen (pat); 6432692f60a7Smrg 6433c3c9db83Smrg if (patlen <= len) 6434c3c9db83Smrg { 6435c3c9db83Smrg str += len - patlen; 64362f60eb46Smrg if (STREQ (str, pat)) 6437c3c9db83Smrg *str = '\0'; 6438c3c9db83Smrg } 6439c3c9db83Smrg return str; 6440c3c9db83Smrg} 6441692f60a7Smrg 64423f6d0e1dSmrgvoid 64433f6d0e1dSmrglt_debugprintf (const char *file, int line, const char *fmt, ...) 64443f6d0e1dSmrg{ 64453f6d0e1dSmrg va_list args; 64463f6d0e1dSmrg if (lt_debug) 64473f6d0e1dSmrg { 64483f6d0e1dSmrg (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); 64493f6d0e1dSmrg va_start (args, fmt); 64503f6d0e1dSmrg (void) vfprintf (stderr, fmt, args); 64513f6d0e1dSmrg va_end (args); 64523f6d0e1dSmrg } 64533f6d0e1dSmrg} 64543f6d0e1dSmrg 6455c3c9db83Smrgstatic void 64563f6d0e1dSmrglt_error_core (int exit_status, const char *file, 64573f6d0e1dSmrg int line, const char *mode, 6458c3c9db83Smrg const char *message, va_list ap) 6459c3c9db83Smrg{ 64603f6d0e1dSmrg fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); 6461c3c9db83Smrg vfprintf (stderr, message, ap); 6462c3c9db83Smrg fprintf (stderr, ".\n"); 6463692f60a7Smrg 6464c3c9db83Smrg if (exit_status >= 0) 6465c3c9db83Smrg exit (exit_status); 6466c3c9db83Smrg} 6467692f60a7Smrg 6468c3c9db83Smrgvoid 64693f6d0e1dSmrglt_fatal (const char *file, int line, const char *message, ...) 6470c3c9db83Smrg{ 6471c3c9db83Smrg va_list ap; 6472c3c9db83Smrg va_start (ap, message); 64733f6d0e1dSmrg lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); 6474c3c9db83Smrg va_end (ap); 6475c3c9db83Smrg} 6476692f60a7Smrg 64773f6d0e1dSmrgstatic const char * 64783f6d0e1dSmrgnonnull (const char *s) 64793f6d0e1dSmrg{ 64803f6d0e1dSmrg return s ? s : "(null)"; 64813f6d0e1dSmrg} 64823f6d0e1dSmrg 64833f6d0e1dSmrgstatic const char * 64843f6d0e1dSmrgnonempty (const char *s) 64853f6d0e1dSmrg{ 64863f6d0e1dSmrg return (s && !*s) ? "(empty)" : nonnull (s); 64873f6d0e1dSmrg} 64883f6d0e1dSmrg 6489c3c9db83Smrgvoid 6490c3c9db83Smrglt_setenv (const char *name, const char *value) 6491c3c9db83Smrg{ 64923f6d0e1dSmrg lt_debugprintf (__FILE__, __LINE__, 64933f6d0e1dSmrg "(lt_setenv) setting '%s' to '%s'\n", 64943f6d0e1dSmrg nonnull (name), nonnull (value)); 6495c3c9db83Smrg { 6496c3c9db83Smrg#ifdef HAVE_SETENV 6497c3c9db83Smrg /* always make a copy, for consistency with !HAVE_SETENV */ 6498c3c9db83Smrg char *str = xstrdup (value); 6499c3c9db83Smrg setenv (name, str, 1); 6500c3c9db83Smrg#else 65012f60eb46Smrg size_t len = strlen (name) + 1 + strlen (value) + 1; 6502c3c9db83Smrg char *str = XMALLOC (char, len); 6503c3c9db83Smrg sprintf (str, "%s=%s", name, value); 6504c3c9db83Smrg if (putenv (str) != EXIT_SUCCESS) 6505c3c9db83Smrg { 6506c3c9db83Smrg XFREE (str); 6507c3c9db83Smrg } 6508c3c9db83Smrg#endif 6509c3c9db83Smrg } 6510c3c9db83Smrg} 6511692f60a7Smrg 6512c3c9db83Smrgchar * 6513c3c9db83Smrglt_extend_str (const char *orig_value, const char *add, int to_end) 6514c3c9db83Smrg{ 6515c3c9db83Smrg char *new_value; 6516c3c9db83Smrg if (orig_value && *orig_value) 6517c3c9db83Smrg { 65182f60eb46Smrg size_t orig_value_len = strlen (orig_value); 65192f60eb46Smrg size_t add_len = strlen (add); 6520c3c9db83Smrg new_value = XMALLOC (char, add_len + orig_value_len + 1); 6521c3c9db83Smrg if (to_end) 6522c3c9db83Smrg { 6523c3c9db83Smrg strcpy (new_value, orig_value); 6524c3c9db83Smrg strcpy (new_value + orig_value_len, add); 6525c3c9db83Smrg } 6526c3c9db83Smrg else 6527c3c9db83Smrg { 6528c3c9db83Smrg strcpy (new_value, add); 6529c3c9db83Smrg strcpy (new_value + add_len, orig_value); 6530c3c9db83Smrg } 6531c3c9db83Smrg } 6532c3c9db83Smrg else 6533c3c9db83Smrg { 6534c3c9db83Smrg new_value = xstrdup (add); 6535c3c9db83Smrg } 6536c3c9db83Smrg return new_value; 6537c3c9db83Smrg} 6538692f60a7Smrg 6539c3c9db83Smrgvoid 6540c3c9db83Smrglt_update_exe_path (const char *name, const char *value) 6541c3c9db83Smrg{ 65423f6d0e1dSmrg lt_debugprintf (__FILE__, __LINE__, 65433f6d0e1dSmrg "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", 65443f6d0e1dSmrg nonnull (name), nonnull (value)); 6545692f60a7Smrg 6546c3c9db83Smrg if (name && *name && value && *value) 6547c3c9db83Smrg { 6548c3c9db83Smrg char *new_value = lt_extend_str (getenv (name), value, 0); 6549c3c9db83Smrg /* some systems can't cope with a ':'-terminated path #' */ 65502f60eb46Smrg size_t len = strlen (new_value); 65512f60eb46Smrg while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1])) 6552c3c9db83Smrg { 65532f60eb46Smrg new_value[--len] = '\0'; 6554c3c9db83Smrg } 6555c3c9db83Smrg lt_setenv (name, new_value); 6556c3c9db83Smrg XFREE (new_value); 6557c3c9db83Smrg } 6558c3c9db83Smrg} 6559692f60a7Smrg 6560c3c9db83Smrgvoid 6561c3c9db83Smrglt_update_lib_path (const char *name, const char *value) 6562c3c9db83Smrg{ 65633f6d0e1dSmrg lt_debugprintf (__FILE__, __LINE__, 65643f6d0e1dSmrg "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", 65653f6d0e1dSmrg nonnull (name), nonnull (value)); 6566692f60a7Smrg 6567c3c9db83Smrg if (name && *name && value && *value) 6568c3c9db83Smrg { 6569c3c9db83Smrg char *new_value = lt_extend_str (getenv (name), value, 0); 6570c3c9db83Smrg lt_setenv (name, new_value); 6571c3c9db83Smrg XFREE (new_value); 6572c3c9db83Smrg } 6573c3c9db83Smrg} 6574692f60a7Smrg 65753f6d0e1dSmrgEOF 65763f6d0e1dSmrg case $host_os in 65773f6d0e1dSmrg mingw*) 65783f6d0e1dSmrg cat <<"EOF" 65793f6d0e1dSmrg 65803f6d0e1dSmrg/* Prepares an argument vector before calling spawn(). 65813f6d0e1dSmrg Note that spawn() does not by itself call the command interpreter 65823f6d0e1dSmrg (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : 65833f6d0e1dSmrg ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); 65843f6d0e1dSmrg GetVersionEx(&v); 65853f6d0e1dSmrg v.dwPlatformId == VER_PLATFORM_WIN32_NT; 65863f6d0e1dSmrg }) ? "cmd.exe" : "command.com"). 65873f6d0e1dSmrg Instead it simply concatenates the arguments, separated by ' ', and calls 65883f6d0e1dSmrg CreateProcess(). We must quote the arguments since Win32 CreateProcess() 65893f6d0e1dSmrg interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a 65903f6d0e1dSmrg special way: 65913f6d0e1dSmrg - Space and tab are interpreted as delimiters. They are not treated as 65923f6d0e1dSmrg delimiters if they are surrounded by double quotes: "...". 65933f6d0e1dSmrg - Unescaped double quotes are removed from the input. Their only effect is 65943f6d0e1dSmrg that within double quotes, space and tab are treated like normal 65953f6d0e1dSmrg characters. 65963f6d0e1dSmrg - Backslashes not followed by double quotes are not special. 65973f6d0e1dSmrg - But 2*n+1 backslashes followed by a double quote become 65983f6d0e1dSmrg n backslashes followed by a double quote (n >= 0): 65993f6d0e1dSmrg \" -> " 66003f6d0e1dSmrg \\\" -> \" 66013f6d0e1dSmrg \\\\\" -> \\" 66023f6d0e1dSmrg */ 66033f6d0e1dSmrg#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" 66043f6d0e1dSmrg#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" 66053f6d0e1dSmrgchar ** 66063f6d0e1dSmrgprepare_spawn (char **argv) 66073f6d0e1dSmrg{ 66083f6d0e1dSmrg size_t argc; 66093f6d0e1dSmrg char **new_argv; 66103f6d0e1dSmrg size_t i; 66113f6d0e1dSmrg 66123f6d0e1dSmrg /* Count number of arguments. */ 66133f6d0e1dSmrg for (argc = 0; argv[argc] != NULL; argc++) 66143f6d0e1dSmrg ; 66153f6d0e1dSmrg 66163f6d0e1dSmrg /* Allocate new argument vector. */ 66173f6d0e1dSmrg new_argv = XMALLOC (char *, argc + 1); 66183f6d0e1dSmrg 66193f6d0e1dSmrg /* Put quoted arguments into the new argument vector. */ 66203f6d0e1dSmrg for (i = 0; i < argc; i++) 66213f6d0e1dSmrg { 66223f6d0e1dSmrg const char *string = argv[i]; 66233f6d0e1dSmrg 66243f6d0e1dSmrg if (string[0] == '\0') 66253f6d0e1dSmrg new_argv[i] = xstrdup ("\"\""); 66263f6d0e1dSmrg else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) 66273f6d0e1dSmrg { 66283f6d0e1dSmrg int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); 66293f6d0e1dSmrg size_t length; 66303f6d0e1dSmrg unsigned int backslashes; 66313f6d0e1dSmrg const char *s; 66323f6d0e1dSmrg char *quoted_string; 66333f6d0e1dSmrg char *p; 66343f6d0e1dSmrg 66353f6d0e1dSmrg length = 0; 66363f6d0e1dSmrg backslashes = 0; 66373f6d0e1dSmrg if (quote_around) 66383f6d0e1dSmrg length++; 66393f6d0e1dSmrg for (s = string; *s != '\0'; s++) 66403f6d0e1dSmrg { 66413f6d0e1dSmrg char c = *s; 66423f6d0e1dSmrg if (c == '"') 66433f6d0e1dSmrg length += backslashes + 1; 66443f6d0e1dSmrg length++; 66453f6d0e1dSmrg if (c == '\\') 66463f6d0e1dSmrg backslashes++; 66473f6d0e1dSmrg else 66483f6d0e1dSmrg backslashes = 0; 66493f6d0e1dSmrg } 66503f6d0e1dSmrg if (quote_around) 66513f6d0e1dSmrg length += backslashes + 1; 66523f6d0e1dSmrg 66533f6d0e1dSmrg quoted_string = XMALLOC (char, length + 1); 66543f6d0e1dSmrg 66553f6d0e1dSmrg p = quoted_string; 66563f6d0e1dSmrg backslashes = 0; 66573f6d0e1dSmrg if (quote_around) 66583f6d0e1dSmrg *p++ = '"'; 66593f6d0e1dSmrg for (s = string; *s != '\0'; s++) 66603f6d0e1dSmrg { 66613f6d0e1dSmrg char c = *s; 66623f6d0e1dSmrg if (c == '"') 66633f6d0e1dSmrg { 66643f6d0e1dSmrg unsigned int j; 66653f6d0e1dSmrg for (j = backslashes + 1; j > 0; j--) 66663f6d0e1dSmrg *p++ = '\\'; 66673f6d0e1dSmrg } 66683f6d0e1dSmrg *p++ = c; 66693f6d0e1dSmrg if (c == '\\') 66703f6d0e1dSmrg backslashes++; 66713f6d0e1dSmrg else 66723f6d0e1dSmrg backslashes = 0; 66733f6d0e1dSmrg } 66743f6d0e1dSmrg if (quote_around) 66753f6d0e1dSmrg { 66763f6d0e1dSmrg unsigned int j; 66773f6d0e1dSmrg for (j = backslashes; j > 0; j--) 66783f6d0e1dSmrg *p++ = '\\'; 66793f6d0e1dSmrg *p++ = '"'; 66803f6d0e1dSmrg } 66813f6d0e1dSmrg *p = '\0'; 66823f6d0e1dSmrg 66833f6d0e1dSmrg new_argv[i] = quoted_string; 66843f6d0e1dSmrg } 66853f6d0e1dSmrg else 66863f6d0e1dSmrg new_argv[i] = (char *) string; 66873f6d0e1dSmrg } 66883f6d0e1dSmrg new_argv[argc] = NULL; 66893f6d0e1dSmrg 66903f6d0e1dSmrg return new_argv; 66913f6d0e1dSmrg} 66923f6d0e1dSmrgEOF 66933f6d0e1dSmrg ;; 66943f6d0e1dSmrg esac 6695692f60a7Smrg 66963f6d0e1dSmrg cat <<"EOF" 66973f6d0e1dSmrgvoid lt_dump_script (FILE* f) 66983f6d0e1dSmrg{ 66993f6d0e1dSmrgEOF 67003f6d0e1dSmrg func_emit_wrapper yes | 670195903e71Smrg $SED -n -e ' 670295903e71Smrgs/^\(.\{79\}\)\(..*\)/\1\ 670395903e71Smrg\2/ 670495903e71Smrgh 670595903e71Smrgs/\([\\"]\)/\\\1/g 670695903e71Smrgs/$/\\n/ 670795903e71Smrgs/\([^\n]*\).*/ fputs ("\1", f);/p 670895903e71Smrgg 670995903e71SmrgD' 67103f6d0e1dSmrg cat <<"EOF" 67113f6d0e1dSmrg} 6712c3c9db83SmrgEOF 6713c3c9db83Smrg} 6714c3c9db83Smrg# end: func_emit_cwrapperexe_src 6715692f60a7Smrg 67163f6d0e1dSmrg# func_win32_import_lib_p ARG 67173f6d0e1dSmrg# True if ARG is an import lib, as indicated by $file_magic_cmd 67183f6d0e1dSmrgfunc_win32_import_lib_p () 67193f6d0e1dSmrg{ 67202f60eb46Smrg $debug_cmd 67212f60eb46Smrg 67223f6d0e1dSmrg case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in 67233f6d0e1dSmrg *import*) : ;; 67243f6d0e1dSmrg *) false ;; 67253f6d0e1dSmrg esac 67263f6d0e1dSmrg} 67273f6d0e1dSmrg 67282f60eb46Smrg# func_suncc_cstd_abi 67292f60eb46Smrg# !!ONLY CALL THIS FOR SUN CC AFTER $compile_command IS FULLY EXPANDED!! 67302f60eb46Smrg# Several compiler flags select an ABI that is incompatible with the 67312f60eb46Smrg# Cstd library. Avoid specifying it if any are in CXXFLAGS. 67322f60eb46Smrgfunc_suncc_cstd_abi () 67332f60eb46Smrg{ 67342f60eb46Smrg $debug_cmd 67352f60eb46Smrg 67362f60eb46Smrg case " $compile_command " in 67372f60eb46Smrg *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*) 67382f60eb46Smrg suncc_use_cstd_abi=no 67392f60eb46Smrg ;; 67402f60eb46Smrg *) 67412f60eb46Smrg suncc_use_cstd_abi=yes 67422f60eb46Smrg ;; 67432f60eb46Smrg esac 67442f60eb46Smrg} 67452f60eb46Smrg 6746c3c9db83Smrg# func_mode_link arg... 6747c3c9db83Smrgfunc_mode_link () 6748c3c9db83Smrg{ 67492f60eb46Smrg $debug_cmd 67502f60eb46Smrg 6751c3c9db83Smrg case $host in 6752c3c9db83Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 6753c3c9db83Smrg # It is impossible to link a dll without this setting, and 6754c3c9db83Smrg # we shouldn't force the makefile maintainer to figure out 67552f60eb46Smrg # what system we are compiling for in order to pass an extra 6756c3c9db83Smrg # flag for every libtool invocation. 6757c3c9db83Smrg # allow_undefined=no 6758692f60a7Smrg 6759c3c9db83Smrg # FIXME: Unfortunately, there are problems with the above when trying 67602f60eb46Smrg # to make a dll that has undefined symbols, in which case not 6761c3c9db83Smrg # even a static library is built. For now, we need to specify 6762c3c9db83Smrg # -no-undefined on the libtool link line when we can be certain 6763c3c9db83Smrg # that all symbols are satisfied, otherwise we get a static library. 6764c3c9db83Smrg allow_undefined=yes 6765c3c9db83Smrg ;; 6766c3c9db83Smrg *) 6767c3c9db83Smrg allow_undefined=yes 6768c3c9db83Smrg ;; 6769c3c9db83Smrg esac 6770c3c9db83Smrg libtool_args=$nonopt 6771c3c9db83Smrg base_compile="$nonopt $@" 6772c3c9db83Smrg compile_command=$nonopt 6773c3c9db83Smrg finalize_command=$nonopt 6774692f60a7Smrg 6775c3c9db83Smrg compile_rpath= 6776c3c9db83Smrg finalize_rpath= 6777c3c9db83Smrg compile_shlibpath= 6778c3c9db83Smrg finalize_shlibpath= 6779c3c9db83Smrg convenience= 6780c3c9db83Smrg old_convenience= 6781c3c9db83Smrg deplibs= 6782c3c9db83Smrg old_deplibs= 6783c3c9db83Smrg compiler_flags= 6784c3c9db83Smrg linker_flags= 6785c3c9db83Smrg dllsearchpath= 6786c3c9db83Smrg lib_search_path=`pwd` 6787c3c9db83Smrg inst_prefix_dir= 6788c3c9db83Smrg new_inherited_linker_flags= 6789692f60a7Smrg 6790c3c9db83Smrg avoid_version=no 67913f6d0e1dSmrg bindir= 6792c3c9db83Smrg dlfiles= 6793c3c9db83Smrg dlprefiles= 6794c3c9db83Smrg dlself=no 6795c3c9db83Smrg export_dynamic=no 6796c3c9db83Smrg export_symbols= 6797c3c9db83Smrg export_symbols_regex= 6798c3c9db83Smrg generated= 6799c3c9db83Smrg libobjs= 6800c3c9db83Smrg ltlibs= 6801c3c9db83Smrg module=no 6802c3c9db83Smrg no_install=no 6803c3c9db83Smrg objs= 68042f60eb46Smrg os2dllname= 6805c3c9db83Smrg non_pic_objects= 6806c3c9db83Smrg precious_files_regex= 6807c3c9db83Smrg prefer_static_libs=no 68082f60eb46Smrg preload=false 6809c3c9db83Smrg prev= 6810c3c9db83Smrg prevarg= 6811c3c9db83Smrg release= 6812c3c9db83Smrg rpath= 6813c3c9db83Smrg xrpath= 6814c3c9db83Smrg perm_rpath= 6815c3c9db83Smrg temp_rpath= 6816c3c9db83Smrg thread_safe=no 6817c3c9db83Smrg vinfo= 6818c3c9db83Smrg vinfo_number=no 6819c3c9db83Smrg weak_libs= 68202f60eb46Smrg single_module=$wl-single_module 6821c3c9db83Smrg func_infer_tag $base_compile 6822c3c9db83Smrg 6823c3c9db83Smrg # We need to know -static, to get the right output filenames. 6824c3c9db83Smrg for arg 6825c3c9db83Smrg do 6826c3c9db83Smrg case $arg in 6827c3c9db83Smrg -shared) 68282f60eb46Smrg test yes != "$build_libtool_libs" \ 68292f60eb46Smrg && func_fatal_configuration "cannot build a shared library" 6830c3c9db83Smrg build_old_libs=no 6831c3c9db83Smrg break 6832c3c9db83Smrg ;; 6833c3c9db83Smrg -all-static | -static | -static-libtool-libs) 6834c3c9db83Smrg case $arg in 6835c3c9db83Smrg -all-static) 68362f60eb46Smrg if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then 6837c3c9db83Smrg func_warning "complete static linking is impossible in this configuration" 6838c3c9db83Smrg fi 6839c3c9db83Smrg if test -n "$link_static_flag"; then 6840c3c9db83Smrg dlopen_self=$dlopen_self_static 6841c3c9db83Smrg fi 6842c3c9db83Smrg prefer_static_libs=yes 6843c3c9db83Smrg ;; 6844c3c9db83Smrg -static) 6845c3c9db83Smrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 6846c3c9db83Smrg dlopen_self=$dlopen_self_static 6847c3c9db83Smrg fi 6848c3c9db83Smrg prefer_static_libs=built 6849c3c9db83Smrg ;; 6850c3c9db83Smrg -static-libtool-libs) 6851c3c9db83Smrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 6852c3c9db83Smrg dlopen_self=$dlopen_self_static 68532e71ea71Smrg fi 6854c3c9db83Smrg prefer_static_libs=yes 6855c3c9db83Smrg ;; 6856c3c9db83Smrg esac 6857c3c9db83Smrg build_libtool_libs=no 6858c3c9db83Smrg build_old_libs=yes 6859c3c9db83Smrg break 6860c3c9db83Smrg ;; 6861c3c9db83Smrg esac 6862c3c9db83Smrg done 6863692f60a7Smrg 6864c3c9db83Smrg # See if our shared archives depend on static archives. 6865c3c9db83Smrg test -n "$old_archive_from_new_cmds" && build_old_libs=yes 6866692f60a7Smrg 6867c3c9db83Smrg # Go through the arguments, transforming them on the way. 6868c3c9db83Smrg while test "$#" -gt 0; do 68692f60eb46Smrg arg=$1 6870c3c9db83Smrg shift 6871efb46889Smrg func_quote_arg pretty,unquoted "$arg" 6872efb46889Smrg qarg=$func_quote_arg_unquoted_result 6873efb46889Smrg func_append libtool_args " $func_quote_arg_result" 6874692f60a7Smrg 6875c3c9db83Smrg # If the previous option needs an argument, assign it. 6876c3c9db83Smrg if test -n "$prev"; then 6877c3c9db83Smrg case $prev in 6878c3c9db83Smrg output) 6879c3c9db83Smrg func_append compile_command " @OUTPUT@" 6880c3c9db83Smrg func_append finalize_command " @OUTPUT@" 6881c3c9db83Smrg ;; 6882c3c9db83Smrg esac 6883692f60a7Smrg 6884c3c9db83Smrg case $prev in 68853f6d0e1dSmrg bindir) 68862f60eb46Smrg bindir=$arg 68873f6d0e1dSmrg prev= 68883f6d0e1dSmrg continue 68893f6d0e1dSmrg ;; 6890c3c9db83Smrg dlfiles|dlprefiles) 68912f60eb46Smrg $preload || { 6892c3c9db83Smrg # Add the symbol object into the linking commands. 6893c3c9db83Smrg func_append compile_command " @SYMFILE@" 6894c3c9db83Smrg func_append finalize_command " @SYMFILE@" 68952f60eb46Smrg preload=: 68962f60eb46Smrg } 6897c3c9db83Smrg case $arg in 6898c3c9db83Smrg *.la | *.lo) ;; # We handle these cases below. 6899c3c9db83Smrg force) 69002f60eb46Smrg if test no = "$dlself"; then 6901c3c9db83Smrg dlself=needless 6902c3c9db83Smrg export_dynamic=yes 6903c3c9db83Smrg fi 6904c3c9db83Smrg prev= 6905c3c9db83Smrg continue 6906c3c9db83Smrg ;; 6907c3c9db83Smrg self) 69082f60eb46Smrg if test dlprefiles = "$prev"; then 6909c3c9db83Smrg dlself=yes 69102f60eb46Smrg elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then 6911c3c9db83Smrg dlself=yes 69122e71ea71Smrg else 6913c3c9db83Smrg dlself=needless 6914c3c9db83Smrg export_dynamic=yes 69152e71ea71Smrg fi 6916c3c9db83Smrg prev= 6917c3c9db83Smrg continue 6918c3c9db83Smrg ;; 6919c3c9db83Smrg *) 69202f60eb46Smrg if test dlfiles = "$prev"; then 69213f6d0e1dSmrg func_append dlfiles " $arg" 69222e71ea71Smrg else 69233f6d0e1dSmrg func_append dlprefiles " $arg" 69242e71ea71Smrg fi 6925c3c9db83Smrg prev= 6926c3c9db83Smrg continue 6927c3c9db83Smrg ;; 6928c3c9db83Smrg esac 6929c3c9db83Smrg ;; 6930c3c9db83Smrg expsyms) 69312f60eb46Smrg export_symbols=$arg 6932c3c9db83Smrg test -f "$arg" \ 69332f60eb46Smrg || func_fatal_error "symbol file '$arg' does not exist" 6934c3c9db83Smrg prev= 6935c3c9db83Smrg continue 6936c3c9db83Smrg ;; 6937c3c9db83Smrg expsyms_regex) 69382f60eb46Smrg export_symbols_regex=$arg 6939c3c9db83Smrg prev= 6940c3c9db83Smrg continue 6941c3c9db83Smrg ;; 6942c3c9db83Smrg framework) 69432e71ea71Smrg case $host in 6944c3c9db83Smrg *-*-darwin*) 6945c3c9db83Smrg case "$deplibs " in 6946c3c9db83Smrg *" $qarg.ltframework "*) ;; 69473f6d0e1dSmrg *) func_append deplibs " $qarg.ltframework" # this is fixed later 6948c3c9db83Smrg ;; 6949c3c9db83Smrg esac 6950c3c9db83Smrg ;; 69512e71ea71Smrg esac 6952c3c9db83Smrg prev= 6953c3c9db83Smrg continue 69542e71ea71Smrg ;; 6955c3c9db83Smrg inst_prefix) 69562f60eb46Smrg inst_prefix_dir=$arg 69572f60eb46Smrg prev= 69582f60eb46Smrg continue 69592f60eb46Smrg ;; 69602f60eb46Smrg mllvm) 69612f60eb46Smrg # Clang does not use LLVM to link, so we can simply discard any 69622f60eb46Smrg # '-mllvm $arg' options when doing the link step. 6963c3c9db83Smrg prev= 6964c3c9db83Smrg continue 69652e71ea71Smrg ;; 6966c3c9db83Smrg objectlist) 6967c3c9db83Smrg if test -f "$arg"; then 6968c3c9db83Smrg save_arg=$arg 6969c3c9db83Smrg moreargs= 6970c3c9db83Smrg for fil in `cat "$save_arg"` 6971c3c9db83Smrg do 69723f6d0e1dSmrg# func_append moreargs " $fil" 6973c3c9db83Smrg arg=$fil 6974c3c9db83Smrg # A libtool-controlled object. 6975692f60a7Smrg 6976c3c9db83Smrg # Check to see that this really is a libtool object. 6977c3c9db83Smrg if func_lalib_unsafe_p "$arg"; then 6978c3c9db83Smrg pic_object= 6979c3c9db83Smrg non_pic_object= 698085ee4c00Smrg 6981c3c9db83Smrg # Read the .lo file 6982c3c9db83Smrg func_source "$arg" 698385ee4c00Smrg 6984c3c9db83Smrg if test -z "$pic_object" || 6985c3c9db83Smrg test -z "$non_pic_object" || 69862f60eb46Smrg test none = "$pic_object" && 69872f60eb46Smrg test none = "$non_pic_object"; then 69882f60eb46Smrg func_fatal_error "cannot find name of object for '$arg'" 6989c3c9db83Smrg fi 699085ee4c00Smrg 6991c3c9db83Smrg # Extract subdirectory from the argument. 6992c3c9db83Smrg func_dirname "$arg" "/" "" 69932f60eb46Smrg xdir=$func_dirname_result 699485ee4c00Smrg 69952f60eb46Smrg if test none != "$pic_object"; then 6996c3c9db83Smrg # Prepend the subdirectory the object is found in. 69972f60eb46Smrg pic_object=$xdir$pic_object 699885ee4c00Smrg 69992f60eb46Smrg if test dlfiles = "$prev"; then 70002f60eb46Smrg if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 70013f6d0e1dSmrg func_append dlfiles " $pic_object" 7002c3c9db83Smrg prev= 7003c3c9db83Smrg continue 7004c3c9db83Smrg else 7005c3c9db83Smrg # If libtool objects are unsupported, then we need to preload. 7006c3c9db83Smrg prev=dlprefiles 7007c3c9db83Smrg fi 7008c3c9db83Smrg fi 700985ee4c00Smrg 7010c3c9db83Smrg # CHECK ME: I think I busted this. -Ossama 70112f60eb46Smrg if test dlprefiles = "$prev"; then 7012c3c9db83Smrg # Preload the old-style object. 70133f6d0e1dSmrg func_append dlprefiles " $pic_object" 7014c3c9db83Smrg prev= 7015c3c9db83Smrg fi 701685ee4c00Smrg 7017c3c9db83Smrg # A PIC object. 7018c3c9db83Smrg func_append libobjs " $pic_object" 70192f60eb46Smrg arg=$pic_object 7020c3c9db83Smrg fi 702185ee4c00Smrg 7022c3c9db83Smrg # Non-PIC object. 70232f60eb46Smrg if test none != "$non_pic_object"; then 7024c3c9db83Smrg # Prepend the subdirectory the object is found in. 70252f60eb46Smrg non_pic_object=$xdir$non_pic_object 702685ee4c00Smrg 7027c3c9db83Smrg # A standard non-PIC object 7028c3c9db83Smrg func_append non_pic_objects " $non_pic_object" 70292f60eb46Smrg if test -z "$pic_object" || test none = "$pic_object"; then 70302f60eb46Smrg arg=$non_pic_object 7031c3c9db83Smrg fi 7032c3c9db83Smrg else 7033c3c9db83Smrg # If the PIC object exists, use it instead. 7034c3c9db83Smrg # $xdir was prepended to $pic_object above. 70352f60eb46Smrg non_pic_object=$pic_object 7036c3c9db83Smrg func_append non_pic_objects " $non_pic_object" 7037c3c9db83Smrg fi 7038c3c9db83Smrg else 7039c3c9db83Smrg # Only an error if not doing a dry-run. 7040c3c9db83Smrg if $opt_dry_run; then 7041c3c9db83Smrg # Extract subdirectory from the argument. 7042c3c9db83Smrg func_dirname "$arg" "/" "" 70432f60eb46Smrg xdir=$func_dirname_result 7044c3c9db83Smrg 7045c3c9db83Smrg func_lo2o "$arg" 7046c3c9db83Smrg pic_object=$xdir$objdir/$func_lo2o_result 7047c3c9db83Smrg non_pic_object=$xdir$func_lo2o_result 7048c3c9db83Smrg func_append libobjs " $pic_object" 7049c3c9db83Smrg func_append non_pic_objects " $non_pic_object" 7050c3c9db83Smrg else 70512f60eb46Smrg func_fatal_error "'$arg' is not a valid libtool object" 7052c3c9db83Smrg fi 7053c3c9db83Smrg fi 7054c3c9db83Smrg done 70552e71ea71Smrg else 70562f60eb46Smrg func_fatal_error "link input file '$arg' does not exist" 70572e71ea71Smrg fi 7058c3c9db83Smrg arg=$save_arg 7059c3c9db83Smrg prev= 7060c3c9db83Smrg continue 7061c3c9db83Smrg ;; 70622f60eb46Smrg os2dllname) 70632f60eb46Smrg os2dllname=$arg 70642f60eb46Smrg prev= 70652f60eb46Smrg continue 70662f60eb46Smrg ;; 7067c3c9db83Smrg precious_regex) 70682f60eb46Smrg precious_files_regex=$arg 7069c3c9db83Smrg prev= 7070c3c9db83Smrg continue 7071c3c9db83Smrg ;; 7072c3c9db83Smrg release) 70732f60eb46Smrg release=-$arg 7074c3c9db83Smrg prev= 7075c3c9db83Smrg continue 7076c3c9db83Smrg ;; 7077c3c9db83Smrg rpath | xrpath) 7078c3c9db83Smrg # We need an absolute path. 7079c3c9db83Smrg case $arg in 7080c3c9db83Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 7081c3c9db83Smrg *) 7082c3c9db83Smrg func_fatal_error "only absolute run-paths are allowed" 7083c3c9db83Smrg ;; 7084c3c9db83Smrg esac 70852f60eb46Smrg if test rpath = "$prev"; then 7086c3c9db83Smrg case "$rpath " in 7087c3c9db83Smrg *" $arg "*) ;; 70883f6d0e1dSmrg *) func_append rpath " $arg" ;; 7089c3c9db83Smrg esac 70902e71ea71Smrg else 7091c3c9db83Smrg case "$xrpath " in 7092c3c9db83Smrg *" $arg "*) ;; 70933f6d0e1dSmrg *) func_append xrpath " $arg" ;; 7094c3c9db83Smrg esac 70952e71ea71Smrg fi 7096c3c9db83Smrg prev= 7097c3c9db83Smrg continue 7098c3c9db83Smrg ;; 7099c3c9db83Smrg shrext) 71002f60eb46Smrg shrext_cmds=$arg 7101c3c9db83Smrg prev= 7102c3c9db83Smrg continue 7103c3c9db83Smrg ;; 7104c3c9db83Smrg weak) 71053f6d0e1dSmrg func_append weak_libs " $arg" 7106c3c9db83Smrg prev= 7107c3c9db83Smrg continue 7108c3c9db83Smrg ;; 7109efb46889Smrg xassembler) 7110efb46889Smrg func_append compiler_flags " -Xassembler $qarg" 7111efb46889Smrg prev= 7112efb46889Smrg func_append compile_command " -Xassembler $qarg" 7113efb46889Smrg func_append finalize_command " -Xassembler $qarg" 7114efb46889Smrg continue 7115efb46889Smrg ;; 7116c3c9db83Smrg xcclinker) 71173f6d0e1dSmrg func_append linker_flags " $qarg" 71183f6d0e1dSmrg func_append compiler_flags " $qarg" 7119c3c9db83Smrg prev= 7120c3c9db83Smrg func_append compile_command " $qarg" 7121c3c9db83Smrg func_append finalize_command " $qarg" 7122c3c9db83Smrg continue 7123c3c9db83Smrg ;; 7124c3c9db83Smrg xcompiler) 71253f6d0e1dSmrg func_append compiler_flags " $qarg" 7126c3c9db83Smrg prev= 7127c3c9db83Smrg func_append compile_command " $qarg" 7128c3c9db83Smrg func_append finalize_command " $qarg" 7129c3c9db83Smrg continue 7130c3c9db83Smrg ;; 7131c3c9db83Smrg xlinker) 71323f6d0e1dSmrg func_append linker_flags " $qarg" 71333f6d0e1dSmrg func_append compiler_flags " $wl$qarg" 7134c3c9db83Smrg prev= 7135c3c9db83Smrg func_append compile_command " $wl$qarg" 7136c3c9db83Smrg func_append finalize_command " $wl$qarg" 7137c3c9db83Smrg continue 7138c3c9db83Smrg ;; 7139c3c9db83Smrg *) 7140c3c9db83Smrg eval "$prev=\"\$arg\"" 7141c3c9db83Smrg prev= 7142c3c9db83Smrg continue 7143c3c9db83Smrg ;; 714485ee4c00Smrg esac 7145c3c9db83Smrg fi # test -n "$prev" 714685ee4c00Smrg 71472f60eb46Smrg prevarg=$arg 714885ee4c00Smrg 7149c3c9db83Smrg case $arg in 7150c3c9db83Smrg -all-static) 7151c3c9db83Smrg if test -n "$link_static_flag"; then 7152c3c9db83Smrg # See comment for -static flag below, for more details. 7153c3c9db83Smrg func_append compile_command " $link_static_flag" 7154c3c9db83Smrg func_append finalize_command " $link_static_flag" 7155c3c9db83Smrg fi 7156c3c9db83Smrg continue 7157c3c9db83Smrg ;; 715885ee4c00Smrg 7159c3c9db83Smrg -allow-undefined) 7160c3c9db83Smrg # FIXME: remove this flag sometime in the future. 71612f60eb46Smrg func_fatal_error "'-allow-undefined' must not be used because it is the default" 7162c3c9db83Smrg ;; 716385ee4c00Smrg 7164c3c9db83Smrg -avoid-version) 7165c3c9db83Smrg avoid_version=yes 7166c3c9db83Smrg continue 7167c3c9db83Smrg ;; 716885ee4c00Smrg 71693f6d0e1dSmrg -bindir) 71703f6d0e1dSmrg prev=bindir 71713f6d0e1dSmrg continue 71723f6d0e1dSmrg ;; 71733f6d0e1dSmrg 7174c3c9db83Smrg -dlopen) 7175c3c9db83Smrg prev=dlfiles 7176c3c9db83Smrg continue 7177c3c9db83Smrg ;; 717885ee4c00Smrg 7179c3c9db83Smrg -dlpreopen) 7180c3c9db83Smrg prev=dlprefiles 7181c3c9db83Smrg continue 7182c3c9db83Smrg ;; 718385ee4c00Smrg 7184c3c9db83Smrg -export-dynamic) 7185c3c9db83Smrg export_dynamic=yes 7186c3c9db83Smrg continue 7187c3c9db83Smrg ;; 718885ee4c00Smrg 7189c3c9db83Smrg -export-symbols | -export-symbols-regex) 7190c3c9db83Smrg if test -n "$export_symbols" || test -n "$export_symbols_regex"; then 7191c3c9db83Smrg func_fatal_error "more than one -exported-symbols argument is not allowed" 7192c3c9db83Smrg fi 71932f60eb46Smrg if test X-export-symbols = "X$arg"; then 7194c3c9db83Smrg prev=expsyms 7195c3c9db83Smrg else 7196c3c9db83Smrg prev=expsyms_regex 7197c3c9db83Smrg fi 7198c3c9db83Smrg continue 7199c3c9db83Smrg ;; 720085ee4c00Smrg 7201c3c9db83Smrg -framework) 7202c3c9db83Smrg prev=framework 7203c3c9db83Smrg continue 7204c3c9db83Smrg ;; 720585ee4c00Smrg 7206c3c9db83Smrg -inst-prefix-dir) 7207c3c9db83Smrg prev=inst_prefix 7208c3c9db83Smrg continue 7209c3c9db83Smrg ;; 721085ee4c00Smrg 7211c3c9db83Smrg # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* 7212c3c9db83Smrg # so, if we see these flags be careful not to treat them like -L 7213c3c9db83Smrg -L[A-Z][A-Z]*:*) 7214c3c9db83Smrg case $with_gcc/$host in 7215c3c9db83Smrg no/*-*-irix* | /*-*-irix*) 7216c3c9db83Smrg func_append compile_command " $arg" 7217c3c9db83Smrg func_append finalize_command " $arg" 7218c3c9db83Smrg ;; 7219c3c9db83Smrg esac 7220c3c9db83Smrg continue 7221c3c9db83Smrg ;; 722285ee4c00Smrg 7223c3c9db83Smrg -L*) 72243f6d0e1dSmrg func_stripname "-L" '' "$arg" 72253f6d0e1dSmrg if test -z "$func_stripname_result"; then 7226c3c9db83Smrg if test "$#" -gt 0; then 72272f60eb46Smrg func_fatal_error "require no space between '-L' and '$1'" 7228c3c9db83Smrg else 72292f60eb46Smrg func_fatal_error "need path for '-L' option" 7230c3c9db83Smrg fi 7231c3c9db83Smrg fi 72323f6d0e1dSmrg func_resolve_sysroot "$func_stripname_result" 72333f6d0e1dSmrg dir=$func_resolve_sysroot_result 7234c3c9db83Smrg # We need an absolute path. 7235c3c9db83Smrg case $dir in 7236c3c9db83Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 7237c3c9db83Smrg *) 7238c3c9db83Smrg absdir=`cd "$dir" && pwd` 7239c3c9db83Smrg test -z "$absdir" && \ 72402f60eb46Smrg func_fatal_error "cannot determine absolute directory name of '$dir'" 72412f60eb46Smrg dir=$absdir 7242c3c9db83Smrg ;; 7243c3c9db83Smrg esac 7244c3c9db83Smrg case "$deplibs " in 72453f6d0e1dSmrg *" -L$dir "* | *" $arg "*) 72463f6d0e1dSmrg # Will only happen for absolute or sysroot arguments 72473f6d0e1dSmrg ;; 7248c3c9db83Smrg *) 72493f6d0e1dSmrg # Preserve sysroot, but never include relative directories 72503f6d0e1dSmrg case $dir in 72513f6d0e1dSmrg [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; 72523f6d0e1dSmrg *) func_append deplibs " -L$dir" ;; 72533f6d0e1dSmrg esac 72543f6d0e1dSmrg func_append lib_search_path " $dir" 7255c3c9db83Smrg ;; 7256c3c9db83Smrg esac 7257c3c9db83Smrg case $host in 7258c3c9db83Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 72593f6d0e1dSmrg testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` 7260c3c9db83Smrg case :$dllsearchpath: in 7261c3c9db83Smrg *":$dir:"*) ;; 7262c3c9db83Smrg ::) dllsearchpath=$dir;; 72633f6d0e1dSmrg *) func_append dllsearchpath ":$dir";; 7264c3c9db83Smrg esac 7265c3c9db83Smrg case :$dllsearchpath: in 7266c3c9db83Smrg *":$testbindir:"*) ;; 7267c3c9db83Smrg ::) dllsearchpath=$testbindir;; 72683f6d0e1dSmrg *) func_append dllsearchpath ":$testbindir";; 7269c3c9db83Smrg esac 7270c3c9db83Smrg ;; 7271c3c9db83Smrg esac 7272c3c9db83Smrg continue 7273c3c9db83Smrg ;; 727485ee4c00Smrg 7275c3c9db83Smrg -l*) 72762f60eb46Smrg if test X-lc = "X$arg" || test X-lm = "X$arg"; then 7277c3c9db83Smrg case $host in 72783f6d0e1dSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) 7279c3c9db83Smrg # These systems don't actually have a C or math library (as such) 7280c3c9db83Smrg continue 7281c3c9db83Smrg ;; 7282c3c9db83Smrg *-*-os2*) 7283c3c9db83Smrg # These systems don't actually have a C library (as such) 72842f60eb46Smrg test X-lc = "X$arg" && continue 7285c3c9db83Smrg ;; 7286efb46889Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig* | *-*-midnightbsd*) 7287c3c9db83Smrg # Do not include libc due to us having libc/libc_r. 72882f60eb46Smrg test X-lc = "X$arg" && continue 7289c3c9db83Smrg ;; 7290c3c9db83Smrg *-*-rhapsody* | *-*-darwin1.[012]) 7291c3c9db83Smrg # Rhapsody C and math libraries are in the System framework 72923f6d0e1dSmrg func_append deplibs " System.ltframework" 7293c3c9db83Smrg continue 7294c3c9db83Smrg ;; 7295c3c9db83Smrg *-*-sco3.2v5* | *-*-sco5v6*) 7296c3c9db83Smrg # Causes problems with __ctype 72972f60eb46Smrg test X-lc = "X$arg" && continue 7298c3c9db83Smrg ;; 7299c3c9db83Smrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 7300c3c9db83Smrg # Compiler inserts libc in the correct place for threads to work 73012f60eb46Smrg test X-lc = "X$arg" && continue 7302c3c9db83Smrg ;; 7303c3c9db83Smrg esac 73042f60eb46Smrg elif test X-lc_r = "X$arg"; then 7305c3c9db83Smrg case $host in 7306efb46889Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig* | *-*-midnightbsd*) 7307c3c9db83Smrg # Do not include libc_r directly, use -pthread flag. 7308c3c9db83Smrg continue 7309c3c9db83Smrg ;; 7310c3c9db83Smrg esac 7311c3c9db83Smrg fi 73123f6d0e1dSmrg func_append deplibs " $arg" 7313c3c9db83Smrg continue 7314c3c9db83Smrg ;; 731585ee4c00Smrg 73162f60eb46Smrg -mllvm) 73172f60eb46Smrg prev=mllvm 73182f60eb46Smrg continue 73192f60eb46Smrg ;; 73202f60eb46Smrg 7321c3c9db83Smrg -module) 7322c3c9db83Smrg module=yes 7323c3c9db83Smrg continue 7324c3c9db83Smrg ;; 732585ee4c00Smrg 7326c3c9db83Smrg # Tru64 UNIX uses -model [arg] to determine the layout of C++ 7327c3c9db83Smrg # classes, name mangling, and exception handling. 7328c3c9db83Smrg # Darwin uses the -arch flag to determine output architecture. 73293f6d0e1dSmrg -model|-arch|-isysroot|--sysroot) 73303f6d0e1dSmrg func_append compiler_flags " $arg" 7331c3c9db83Smrg func_append compile_command " $arg" 7332c3c9db83Smrg func_append finalize_command " $arg" 7333c3c9db83Smrg prev=xcompiler 7334c3c9db83Smrg continue 7335c3c9db83Smrg ;; 7336efb46889Smrg # Solaris ld rejects as of 11.4. Refer to Oracle bug 22985199. 7337efb46889Smrg -pthread) 7338efb46889Smrg case $host in 7339efb46889Smrg *solaris2*) ;; 7340efb46889Smrg *) 7341efb46889Smrg case "$new_inherited_linker_flags " in 7342efb46889Smrg *" $arg "*) ;; 7343efb46889Smrg * ) func_append new_inherited_linker_flags " $arg" ;; 7344efb46889Smrg esac 7345efb46889Smrg ;; 7346efb46889Smrg esac 7347efb46889Smrg continue 7348efb46889Smrg ;; 7349efb46889Smrg -mt|-mthreads|-kthread|-Kthread|-pthreads|--thread-safe \ 735095903e71Smrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 73513f6d0e1dSmrg func_append compiler_flags " $arg" 7352c3c9db83Smrg func_append compile_command " $arg" 7353c3c9db83Smrg func_append finalize_command " $arg" 7354c3c9db83Smrg case "$new_inherited_linker_flags " in 7355c3c9db83Smrg *" $arg "*) ;; 73563f6d0e1dSmrg * ) func_append new_inherited_linker_flags " $arg" ;; 7357c3c9db83Smrg esac 7358c3c9db83Smrg continue 7359c3c9db83Smrg ;; 736085ee4c00Smrg 7361c3c9db83Smrg -multi_module) 73622f60eb46Smrg single_module=$wl-multi_module 7363c3c9db83Smrg continue 7364c3c9db83Smrg ;; 736585ee4c00Smrg 7366c3c9db83Smrg -no-fast-install) 7367c3c9db83Smrg fast_install=no 7368c3c9db83Smrg continue 7369c3c9db83Smrg ;; 737085ee4c00Smrg 7371c3c9db83Smrg -no-install) 7372c3c9db83Smrg case $host in 7373c3c9db83Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) 7374c3c9db83Smrg # The PATH hackery in wrapper scripts is required on Windows 7375c3c9db83Smrg # and Darwin in order for the loader to find any dlls it needs. 73762f60eb46Smrg func_warning "'-no-install' is ignored for $host" 73772f60eb46Smrg func_warning "assuming '-no-fast-install' instead" 7378c3c9db83Smrg fast_install=no 7379c3c9db83Smrg ;; 7380c3c9db83Smrg *) no_install=yes ;; 7381c3c9db83Smrg esac 7382c3c9db83Smrg continue 7383c3c9db83Smrg ;; 738485ee4c00Smrg 7385c3c9db83Smrg -no-undefined) 7386c3c9db83Smrg allow_undefined=no 7387c3c9db83Smrg continue 7388c3c9db83Smrg ;; 738985ee4c00Smrg 7390c3c9db83Smrg -objectlist) 7391c3c9db83Smrg prev=objectlist 7392c3c9db83Smrg continue 7393c3c9db83Smrg ;; 739485ee4c00Smrg 73952f60eb46Smrg -os2dllname) 73962f60eb46Smrg prev=os2dllname 73972f60eb46Smrg continue 73982f60eb46Smrg ;; 73992f60eb46Smrg 7400c3c9db83Smrg -o) prev=output ;; 740185ee4c00Smrg 7402c3c9db83Smrg -precious-files-regex) 7403c3c9db83Smrg prev=precious_regex 7404c3c9db83Smrg continue 7405c3c9db83Smrg ;; 740685ee4c00Smrg 7407c3c9db83Smrg -release) 7408c3c9db83Smrg prev=release 7409c3c9db83Smrg continue 7410c3c9db83Smrg ;; 741185ee4c00Smrg 7412c3c9db83Smrg -rpath) 7413c3c9db83Smrg prev=rpath 7414c3c9db83Smrg continue 7415c3c9db83Smrg ;; 741685ee4c00Smrg 7417c3c9db83Smrg -R) 7418c3c9db83Smrg prev=xrpath 7419c3c9db83Smrg continue 7420c3c9db83Smrg ;; 742185ee4c00Smrg 7422c3c9db83Smrg -R*) 7423c3c9db83Smrg func_stripname '-R' '' "$arg" 7424c3c9db83Smrg dir=$func_stripname_result 7425c3c9db83Smrg # We need an absolute path. 7426c3c9db83Smrg case $dir in 7427c3c9db83Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 74283f6d0e1dSmrg =*) 74293f6d0e1dSmrg func_stripname '=' '' "$dir" 74303f6d0e1dSmrg dir=$lt_sysroot$func_stripname_result 74313f6d0e1dSmrg ;; 7432c3c9db83Smrg *) 7433c3c9db83Smrg func_fatal_error "only absolute run-paths are allowed" 7434c3c9db83Smrg ;; 7435c3c9db83Smrg esac 7436c3c9db83Smrg case "$xrpath " in 7437c3c9db83Smrg *" $dir "*) ;; 74383f6d0e1dSmrg *) func_append xrpath " $dir" ;; 7439c3c9db83Smrg esac 7440c3c9db83Smrg continue 7441c3c9db83Smrg ;; 744285ee4c00Smrg 7443c3c9db83Smrg -shared) 7444c3c9db83Smrg # The effects of -shared are defined in a previous loop. 7445c3c9db83Smrg continue 7446c3c9db83Smrg ;; 744785ee4c00Smrg 7448c3c9db83Smrg -shrext) 7449c3c9db83Smrg prev=shrext 7450c3c9db83Smrg continue 7451c3c9db83Smrg ;; 745285ee4c00Smrg 7453c3c9db83Smrg -static | -static-libtool-libs) 7454c3c9db83Smrg # The effects of -static are defined in a previous loop. 7455c3c9db83Smrg # We used to do the same as -all-static on platforms that 7456c3c9db83Smrg # didn't have a PIC flag, but the assumption that the effects 7457c3c9db83Smrg # would be equivalent was wrong. It would break on at least 7458c3c9db83Smrg # Digital Unix and AIX. 7459c3c9db83Smrg continue 7460c3c9db83Smrg ;; 746185ee4c00Smrg 7462c3c9db83Smrg -thread-safe) 7463c3c9db83Smrg thread_safe=yes 7464c3c9db83Smrg continue 7465c3c9db83Smrg ;; 746685ee4c00Smrg 7467c3c9db83Smrg -version-info) 7468c3c9db83Smrg prev=vinfo 7469c3c9db83Smrg continue 7470c3c9db83Smrg ;; 747185ee4c00Smrg 7472c3c9db83Smrg -version-number) 7473c3c9db83Smrg prev=vinfo 7474c3c9db83Smrg vinfo_number=yes 7475c3c9db83Smrg continue 7476c3c9db83Smrg ;; 747785ee4c00Smrg 7478c3c9db83Smrg -weak) 7479c3c9db83Smrg prev=weak 7480c3c9db83Smrg continue 7481c3c9db83Smrg ;; 7482692f60a7Smrg 7483c3c9db83Smrg -Wc,*) 7484c3c9db83Smrg func_stripname '-Wc,' '' "$arg" 7485c3c9db83Smrg args=$func_stripname_result 7486c3c9db83Smrg arg= 74872f60eb46Smrg save_ifs=$IFS; IFS=, 7488c3c9db83Smrg for flag in $args; do 74892f60eb46Smrg IFS=$save_ifs 7490efb46889Smrg func_quote_arg pretty "$flag" 7491efb46889Smrg func_append arg " $func_quote_arg_result" 7492efb46889Smrg func_append compiler_flags " $func_quote_arg_result" 7493c3c9db83Smrg done 74942f60eb46Smrg IFS=$save_ifs 7495c3c9db83Smrg func_stripname ' ' '' "$arg" 7496c3c9db83Smrg arg=$func_stripname_result 7497c3c9db83Smrg ;; 74982e71ea71Smrg 7499c3c9db83Smrg -Wl,*) 7500c3c9db83Smrg func_stripname '-Wl,' '' "$arg" 7501c3c9db83Smrg args=$func_stripname_result 7502c3c9db83Smrg arg= 75032f60eb46Smrg save_ifs=$IFS; IFS=, 7504c3c9db83Smrg for flag in $args; do 75052f60eb46Smrg IFS=$save_ifs 7506efb46889Smrg func_quote_arg pretty "$flag" 7507efb46889Smrg func_append arg " $wl$func_quote_arg_result" 7508efb46889Smrg func_append compiler_flags " $wl$func_quote_arg_result" 7509efb46889Smrg func_append linker_flags " $func_quote_arg_result" 7510c3c9db83Smrg done 75112f60eb46Smrg IFS=$save_ifs 7512c3c9db83Smrg func_stripname ' ' '' "$arg" 7513c3c9db83Smrg arg=$func_stripname_result 7514c3c9db83Smrg ;; 75152e71ea71Smrg 7516efb46889Smrg -Xassembler) 7517efb46889Smrg prev=xassembler 7518efb46889Smrg continue 7519efb46889Smrg ;; 7520efb46889Smrg 7521c3c9db83Smrg -Xcompiler) 7522c3c9db83Smrg prev=xcompiler 7523c3c9db83Smrg continue 7524c3c9db83Smrg ;; 75252e71ea71Smrg 7526c3c9db83Smrg -Xlinker) 7527c3c9db83Smrg prev=xlinker 7528c3c9db83Smrg continue 7529c3c9db83Smrg ;; 75302e71ea71Smrg 7531c3c9db83Smrg -XCClinker) 7532c3c9db83Smrg prev=xcclinker 7533c3c9db83Smrg continue 7534c3c9db83Smrg ;; 75352e71ea71Smrg 7536c3c9db83Smrg # -msg_* for osf cc 7537c3c9db83Smrg -msg_*) 7538efb46889Smrg func_quote_arg pretty "$arg" 7539efb46889Smrg arg=$func_quote_arg_result 7540c3c9db83Smrg ;; 75412e71ea71Smrg 75423f6d0e1dSmrg # Flags to be passed through unchanged, with rationale: 75433f6d0e1dSmrg # -64, -mips[0-9] enable 64-bit mode for the SGI compiler 75443f6d0e1dSmrg # -r[0-9][0-9]* specify processor for the SGI compiler 75453f6d0e1dSmrg # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler 75463f6d0e1dSmrg # +DA*, +DD* enable 64-bit mode for the HP compiler 75473f6d0e1dSmrg # -q* compiler args for the IBM compiler 75483f6d0e1dSmrg # -m*, -t[45]*, -txscale* architecture-specific flags for GCC 75493f6d0e1dSmrg # -F/path path to uninstalled frameworks, gcc on darwin 75503f6d0e1dSmrg # -p, -pg, --coverage, -fprofile-* profiling flags for GCC 75512f60eb46Smrg # -fstack-protector* stack protector flags for GCC 75523f6d0e1dSmrg # @file GCC response files 75533f6d0e1dSmrg # -tp=* Portland pgcc target processor selection 75543f6d0e1dSmrg # --sysroot=* for sysroot support 75552f60eb46Smrg # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization 75562f60eb46Smrg # -specs=* GCC specs files 75572f60eb46Smrg # -stdlib=* select c++ std lib with clang 75582f60eb46Smrg # -fsanitize=* Clang/GCC memory and address sanitizer 7559efb46889Smrg # -fuse-ld=* Linker select flags for GCC 7560efb46889Smrg # -Wa,* Pass flags directly to the assembler 7561c3c9db83Smrg -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ 75623f6d0e1dSmrg -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ 75632f60eb46Smrg -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*| \ 7564efb46889Smrg -specs=*|-fsanitize=*|-fuse-ld=*|-Wa,*) 7565efb46889Smrg func_quote_arg pretty "$arg" 7566efb46889Smrg arg=$func_quote_arg_result 7567c3c9db83Smrg func_append compile_command " $arg" 7568c3c9db83Smrg func_append finalize_command " $arg" 75693f6d0e1dSmrg func_append compiler_flags " $arg" 7570c3c9db83Smrg continue 7571c3c9db83Smrg ;; 75722e71ea71Smrg 75732f60eb46Smrg -Z*) 75742f60eb46Smrg if test os2 = "`expr $host : '.*\(os2\)'`"; then 75752f60eb46Smrg # OS/2 uses -Zxxx to specify OS/2-specific options 75762f60eb46Smrg compiler_flags="$compiler_flags $arg" 75772f60eb46Smrg func_append compile_command " $arg" 75782f60eb46Smrg func_append finalize_command " $arg" 75792f60eb46Smrg case $arg in 75802f60eb46Smrg -Zlinker | -Zstack) 75812f60eb46Smrg prev=xcompiler 75822f60eb46Smrg ;; 75832f60eb46Smrg esac 75842f60eb46Smrg continue 75852f60eb46Smrg else 75862f60eb46Smrg # Otherwise treat like 'Some other compiler flag' below 7587efb46889Smrg func_quote_arg pretty "$arg" 7588efb46889Smrg arg=$func_quote_arg_result 75892f60eb46Smrg fi 75902f60eb46Smrg ;; 75912f60eb46Smrg 7592c3c9db83Smrg # Some other compiler flag. 7593c3c9db83Smrg -* | +*) 7594efb46889Smrg func_quote_arg pretty "$arg" 7595efb46889Smrg arg=$func_quote_arg_result 7596c3c9db83Smrg ;; 75972e71ea71Smrg 7598c3c9db83Smrg *.$objext) 7599c3c9db83Smrg # A standard object. 76003f6d0e1dSmrg func_append objs " $arg" 7601c3c9db83Smrg ;; 76022e71ea71Smrg 7603c3c9db83Smrg *.lo) 7604c3c9db83Smrg # A libtool-controlled object. 76052e71ea71Smrg 7606c3c9db83Smrg # Check to see that this really is a libtool object. 7607c3c9db83Smrg if func_lalib_unsafe_p "$arg"; then 7608c3c9db83Smrg pic_object= 7609c3c9db83Smrg non_pic_object= 76102e71ea71Smrg 7611c3c9db83Smrg # Read the .lo file 7612c3c9db83Smrg func_source "$arg" 76132e71ea71Smrg 7614c3c9db83Smrg if test -z "$pic_object" || 7615c3c9db83Smrg test -z "$non_pic_object" || 76162f60eb46Smrg test none = "$pic_object" && 76172f60eb46Smrg test none = "$non_pic_object"; then 76182f60eb46Smrg func_fatal_error "cannot find name of object for '$arg'" 7619c3c9db83Smrg fi 76202e71ea71Smrg 7621c3c9db83Smrg # Extract subdirectory from the argument. 7622c3c9db83Smrg func_dirname "$arg" "/" "" 76232f60eb46Smrg xdir=$func_dirname_result 76242e71ea71Smrg 76252f60eb46Smrg test none = "$pic_object" || { 7626c3c9db83Smrg # Prepend the subdirectory the object is found in. 76272f60eb46Smrg pic_object=$xdir$pic_object 76282e71ea71Smrg 76292f60eb46Smrg if test dlfiles = "$prev"; then 76302f60eb46Smrg if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 76313f6d0e1dSmrg func_append dlfiles " $pic_object" 7632c3c9db83Smrg prev= 7633c3c9db83Smrg continue 7634c3c9db83Smrg else 7635c3c9db83Smrg # If libtool objects are unsupported, then we need to preload. 7636c3c9db83Smrg prev=dlprefiles 7637c3c9db83Smrg fi 7638c3c9db83Smrg fi 76392e71ea71Smrg 7640c3c9db83Smrg # CHECK ME: I think I busted this. -Ossama 76412f60eb46Smrg if test dlprefiles = "$prev"; then 7642c3c9db83Smrg # Preload the old-style object. 76433f6d0e1dSmrg func_append dlprefiles " $pic_object" 7644c3c9db83Smrg prev= 7645c3c9db83Smrg fi 7646692f60a7Smrg 7647c3c9db83Smrg # A PIC object. 7648c3c9db83Smrg func_append libobjs " $pic_object" 76492f60eb46Smrg arg=$pic_object 76502f60eb46Smrg } 7651692f60a7Smrg 7652c3c9db83Smrg # Non-PIC object. 76532f60eb46Smrg if test none != "$non_pic_object"; then 7654c3c9db83Smrg # Prepend the subdirectory the object is found in. 76552f60eb46Smrg non_pic_object=$xdir$non_pic_object 7656692f60a7Smrg 7657c3c9db83Smrg # A standard non-PIC object 7658c3c9db83Smrg func_append non_pic_objects " $non_pic_object" 76592f60eb46Smrg if test -z "$pic_object" || test none = "$pic_object"; then 76602f60eb46Smrg arg=$non_pic_object 7661c3c9db83Smrg fi 7662c3c9db83Smrg else 7663c3c9db83Smrg # If the PIC object exists, use it instead. 7664c3c9db83Smrg # $xdir was prepended to $pic_object above. 76652f60eb46Smrg non_pic_object=$pic_object 7666c3c9db83Smrg func_append non_pic_objects " $non_pic_object" 7667c3c9db83Smrg fi 7668c3c9db83Smrg else 7669c3c9db83Smrg # Only an error if not doing a dry-run. 7670c3c9db83Smrg if $opt_dry_run; then 7671c3c9db83Smrg # Extract subdirectory from the argument. 7672c3c9db83Smrg func_dirname "$arg" "/" "" 76732f60eb46Smrg xdir=$func_dirname_result 7674c3c9db83Smrg 7675c3c9db83Smrg func_lo2o "$arg" 7676c3c9db83Smrg pic_object=$xdir$objdir/$func_lo2o_result 7677c3c9db83Smrg non_pic_object=$xdir$func_lo2o_result 7678c3c9db83Smrg func_append libobjs " $pic_object" 7679c3c9db83Smrg func_append non_pic_objects " $non_pic_object" 7680c3c9db83Smrg else 76812f60eb46Smrg func_fatal_error "'$arg' is not a valid libtool object" 7682c3c9db83Smrg fi 7683c3c9db83Smrg fi 7684c3c9db83Smrg ;; 7685692f60a7Smrg 7686c3c9db83Smrg *.$libext) 7687c3c9db83Smrg # An archive. 76883f6d0e1dSmrg func_append deplibs " $arg" 76893f6d0e1dSmrg func_append old_deplibs " $arg" 7690c3c9db83Smrg continue 7691c3c9db83Smrg ;; 7692c3c9db83Smrg 7693c3c9db83Smrg *.la) 7694c3c9db83Smrg # A libtool-controlled library. 7695c3c9db83Smrg 76963f6d0e1dSmrg func_resolve_sysroot "$arg" 76972f60eb46Smrg if test dlfiles = "$prev"; then 7698c3c9db83Smrg # This library was specified with -dlopen. 76993f6d0e1dSmrg func_append dlfiles " $func_resolve_sysroot_result" 7700c3c9db83Smrg prev= 77012f60eb46Smrg elif test dlprefiles = "$prev"; then 7702c3c9db83Smrg # The library was specified with -dlpreopen. 77033f6d0e1dSmrg func_append dlprefiles " $func_resolve_sysroot_result" 7704c3c9db83Smrg prev= 7705c3c9db83Smrg else 77063f6d0e1dSmrg func_append deplibs " $func_resolve_sysroot_result" 7707c3c9db83Smrg fi 7708c3c9db83Smrg continue 7709c3c9db83Smrg ;; 7710c3c9db83Smrg 7711c3c9db83Smrg # Some other compiler argument. 7712c3c9db83Smrg *) 7713c3c9db83Smrg # Unknown arguments in both finalize_command and compile_command need 7714c3c9db83Smrg # to be aesthetically quoted because they are evaled later. 7715efb46889Smrg func_quote_arg pretty "$arg" 7716efb46889Smrg arg=$func_quote_arg_result 7717c3c9db83Smrg ;; 7718c3c9db83Smrg esac # arg 7719c3c9db83Smrg 7720c3c9db83Smrg # Now actually substitute the argument into the commands. 7721c3c9db83Smrg if test -n "$arg"; then 7722c3c9db83Smrg func_append compile_command " $arg" 7723c3c9db83Smrg func_append finalize_command " $arg" 7724c3c9db83Smrg fi 7725c3c9db83Smrg done # argument parsing loop 7726c3c9db83Smrg 7727c3c9db83Smrg test -n "$prev" && \ 77282f60eb46Smrg func_fatal_help "the '$prevarg' option requires an argument" 7729c3c9db83Smrg 77302f60eb46Smrg if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then 7731c3c9db83Smrg eval arg=\"$export_dynamic_flag_spec\" 7732c3c9db83Smrg func_append compile_command " $arg" 7733c3c9db83Smrg func_append finalize_command " $arg" 7734c3c9db83Smrg fi 7735c3c9db83Smrg 7736c3c9db83Smrg oldlibs= 7737c3c9db83Smrg # calculate the name of the file, without its directory 7738c3c9db83Smrg func_basename "$output" 77392f60eb46Smrg outputname=$func_basename_result 77402f60eb46Smrg libobjs_save=$libobjs 7741c3c9db83Smrg 7742c3c9db83Smrg if test -n "$shlibpath_var"; then 7743c3c9db83Smrg # get the directories listed in $shlibpath_var 77442f60eb46Smrg eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\` 7745c3c9db83Smrg else 7746c3c9db83Smrg shlib_search_path= 7747c3c9db83Smrg fi 7748c3c9db83Smrg eval sys_lib_search_path=\"$sys_lib_search_path_spec\" 7749c3c9db83Smrg eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" 7750c3c9db83Smrg 77512f60eb46Smrg # Definition is injected by LT_CONFIG during libtool generation. 77522f60eb46Smrg func_munge_path_list sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH" 77532f60eb46Smrg 7754c3c9db83Smrg func_dirname "$output" "/" "" 77552f60eb46Smrg output_objdir=$func_dirname_result$objdir 77563f6d0e1dSmrg func_to_tool_file "$output_objdir/" 77573f6d0e1dSmrg tool_output_objdir=$func_to_tool_file_result 7758c3c9db83Smrg # Create the object directory. 7759c3c9db83Smrg func_mkdir_p "$output_objdir" 7760c3c9db83Smrg 7761c3c9db83Smrg # Determine the type of output 7762c3c9db83Smrg case $output in 7763c3c9db83Smrg "") 7764c3c9db83Smrg func_fatal_help "you must specify an output file" 7765c3c9db83Smrg ;; 7766c3c9db83Smrg *.$libext) linkmode=oldlib ;; 7767c3c9db83Smrg *.lo | *.$objext) linkmode=obj ;; 7768c3c9db83Smrg *.la) linkmode=lib ;; 7769c3c9db83Smrg *) linkmode=prog ;; # Anything else should be a program. 7770c3c9db83Smrg esac 7771c3c9db83Smrg 7772c3c9db83Smrg specialdeplibs= 7773c3c9db83Smrg 7774c3c9db83Smrg libs= 7775c3c9db83Smrg # Find all interdependent deplibs by searching for libraries 7776c3c9db83Smrg # that are linked more than once (e.g. -la -lb -la) 7777c3c9db83Smrg for deplib in $deplibs; do 77782f60eb46Smrg if $opt_preserve_dup_deps; then 7779c3c9db83Smrg case "$libs " in 77803f6d0e1dSmrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 7781c3c9db83Smrg esac 7782c3c9db83Smrg fi 77833f6d0e1dSmrg func_append libs " $deplib" 7784c3c9db83Smrg done 7785c3c9db83Smrg 77862f60eb46Smrg if test lib = "$linkmode"; then 7787c3c9db83Smrg libs="$predeps $libs $compiler_lib_search_path $postdeps" 7788c3c9db83Smrg 7789c3c9db83Smrg # Compute libraries that are listed more than once in $predeps 7790c3c9db83Smrg # $postdeps and mark them as special (i.e., whose duplicates are 7791c3c9db83Smrg # not to be eliminated). 7792c3c9db83Smrg pre_post_deps= 7793c3c9db83Smrg if $opt_duplicate_compiler_generated_deps; then 7794c3c9db83Smrg for pre_post_dep in $predeps $postdeps; do 7795c3c9db83Smrg case "$pre_post_deps " in 77963f6d0e1dSmrg *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; 7797c3c9db83Smrg esac 77983f6d0e1dSmrg func_append pre_post_deps " $pre_post_dep" 7799c3c9db83Smrg done 7800c3c9db83Smrg fi 7801c3c9db83Smrg pre_post_deps= 7802c3c9db83Smrg fi 7803c3c9db83Smrg 7804c3c9db83Smrg deplibs= 7805c3c9db83Smrg newdependency_libs= 7806c3c9db83Smrg newlib_search_path= 7807c3c9db83Smrg need_relink=no # whether we're linking any uninstalled libtool libraries 7808c3c9db83Smrg notinst_deplibs= # not-installed libtool libraries 7809c3c9db83Smrg notinst_path= # paths that contain not-installed libtool libraries 7810c3c9db83Smrg 7811c3c9db83Smrg case $linkmode in 7812c3c9db83Smrg lib) 7813c3c9db83Smrg passes="conv dlpreopen link" 7814c3c9db83Smrg for file in $dlfiles $dlprefiles; do 7815c3c9db83Smrg case $file in 7816c3c9db83Smrg *.la) ;; 7817c3c9db83Smrg *) 78182f60eb46Smrg func_fatal_help "libraries can '-dlopen' only libtool libraries: $file" 7819c3c9db83Smrg ;; 7820c3c9db83Smrg esac 7821c3c9db83Smrg done 7822c3c9db83Smrg ;; 7823c3c9db83Smrg prog) 7824c3c9db83Smrg compile_deplibs= 7825c3c9db83Smrg finalize_deplibs= 78262f60eb46Smrg alldeplibs=false 7827c3c9db83Smrg newdlfiles= 7828c3c9db83Smrg newdlprefiles= 7829c3c9db83Smrg passes="conv scan dlopen dlpreopen link" 7830c3c9db83Smrg ;; 7831c3c9db83Smrg *) passes="conv" 7832c3c9db83Smrg ;; 7833c3c9db83Smrg esac 7834c3c9db83Smrg 7835c3c9db83Smrg for pass in $passes; do 7836c3c9db83Smrg # The preopen pass in lib mode reverses $deplibs; put it back here 7837c3c9db83Smrg # so that -L comes before libs that need it for instance... 78382f60eb46Smrg if test lib,link = "$linkmode,$pass"; then 7839c3c9db83Smrg ## FIXME: Find the place where the list is rebuilt in the wrong 7840c3c9db83Smrg ## order, and fix it there properly 7841c3c9db83Smrg tmp_deplibs= 7842c3c9db83Smrg for deplib in $deplibs; do 7843c3c9db83Smrg tmp_deplibs="$deplib $tmp_deplibs" 7844c3c9db83Smrg done 78452f60eb46Smrg deplibs=$tmp_deplibs 7846c3c9db83Smrg fi 7847c3c9db83Smrg 78482f60eb46Smrg if test lib,link = "$linkmode,$pass" || 78492f60eb46Smrg test prog,scan = "$linkmode,$pass"; then 78502f60eb46Smrg libs=$deplibs 7851c3c9db83Smrg deplibs= 7852c3c9db83Smrg fi 78532f60eb46Smrg if test prog = "$linkmode"; then 7854c3c9db83Smrg case $pass in 78552f60eb46Smrg dlopen) libs=$dlfiles ;; 78562f60eb46Smrg dlpreopen) libs=$dlprefiles ;; 7857efb46889Smrg link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; 7858c3c9db83Smrg esac 7859c3c9db83Smrg fi 78602f60eb46Smrg if test lib,dlpreopen = "$linkmode,$pass"; then 7861c3c9db83Smrg # Collect and forward deplibs of preopened libtool libs 7862c3c9db83Smrg for lib in $dlprefiles; do 7863c3c9db83Smrg # Ignore non-libtool-libs 7864c3c9db83Smrg dependency_libs= 78653f6d0e1dSmrg func_resolve_sysroot "$lib" 7866c3c9db83Smrg case $lib in 78673f6d0e1dSmrg *.la) func_source "$func_resolve_sysroot_result" ;; 7868c3c9db83Smrg esac 7869c3c9db83Smrg 7870c3c9db83Smrg # Collect preopened libtool deplibs, except any this library 7871c3c9db83Smrg # has declared as weak libs 7872c3c9db83Smrg for deplib in $dependency_libs; do 78733f6d0e1dSmrg func_basename "$deplib" 78743f6d0e1dSmrg deplib_base=$func_basename_result 7875c3c9db83Smrg case " $weak_libs " in 7876c3c9db83Smrg *" $deplib_base "*) ;; 78773f6d0e1dSmrg *) func_append deplibs " $deplib" ;; 7878c3c9db83Smrg esac 7879c3c9db83Smrg done 7880c3c9db83Smrg done 78812f60eb46Smrg libs=$dlprefiles 7882c3c9db83Smrg fi 78832f60eb46Smrg if test dlopen = "$pass"; then 7884c3c9db83Smrg # Collect dlpreopened libraries 78852f60eb46Smrg save_deplibs=$deplibs 7886c3c9db83Smrg deplibs= 7887c3c9db83Smrg fi 7888c3c9db83Smrg 7889c3c9db83Smrg for deplib in $libs; do 7890c3c9db83Smrg lib= 78912f60eb46Smrg found=false 7892c3c9db83Smrg case $deplib in 789395903e71Smrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 789495903e71Smrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 78952f60eb46Smrg if test prog,link = "$linkmode,$pass"; then 7896c3c9db83Smrg compile_deplibs="$deplib $compile_deplibs" 7897c3c9db83Smrg finalize_deplibs="$deplib $finalize_deplibs" 7898c3c9db83Smrg else 78993f6d0e1dSmrg func_append compiler_flags " $deplib" 79002f60eb46Smrg if test lib = "$linkmode"; then 7901c3c9db83Smrg case "$new_inherited_linker_flags " in 7902c3c9db83Smrg *" $deplib "*) ;; 79033f6d0e1dSmrg * ) func_append new_inherited_linker_flags " $deplib" ;; 7904c3c9db83Smrg esac 7905c3c9db83Smrg fi 7906c3c9db83Smrg fi 7907c3c9db83Smrg continue 7908c3c9db83Smrg ;; 7909c3c9db83Smrg -l*) 79102f60eb46Smrg if test lib != "$linkmode" && test prog != "$linkmode"; then 79112f60eb46Smrg func_warning "'-l' is ignored for archives/objects" 7912c3c9db83Smrg continue 7913c3c9db83Smrg fi 7914c3c9db83Smrg func_stripname '-l' '' "$deplib" 7915c3c9db83Smrg name=$func_stripname_result 79162f60eb46Smrg if test lib = "$linkmode"; then 7917c3c9db83Smrg searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" 7918c3c9db83Smrg else 7919c3c9db83Smrg searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" 7920c3c9db83Smrg fi 7921c3c9db83Smrg for searchdir in $searchdirs; do 7922c3c9db83Smrg for search_ext in .la $std_shrext .so .a; do 7923c3c9db83Smrg # Search the libtool library 79242f60eb46Smrg lib=$searchdir/lib$name$search_ext 7925c3c9db83Smrg if test -f "$lib"; then 79262f60eb46Smrg if test .la = "$search_ext"; then 79272f60eb46Smrg found=: 7928c3c9db83Smrg else 79292f60eb46Smrg found=false 7930c3c9db83Smrg fi 7931c3c9db83Smrg break 2 7932c3c9db83Smrg fi 7933c3c9db83Smrg done 7934c3c9db83Smrg done 79352f60eb46Smrg if $found; then 79362f60eb46Smrg # deplib is a libtool library 7937c3c9db83Smrg # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, 7938c3c9db83Smrg # We need to do some special things here, and not later. 79392f60eb46Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 7940c3c9db83Smrg case " $predeps $postdeps " in 7941c3c9db83Smrg *" $deplib "*) 7942c3c9db83Smrg if func_lalib_p "$lib"; then 7943c3c9db83Smrg library_names= 7944c3c9db83Smrg old_library= 7945c3c9db83Smrg func_source "$lib" 7946c3c9db83Smrg for l in $old_library $library_names; do 79472f60eb46Smrg ll=$l 7948c3c9db83Smrg done 79492f60eb46Smrg if test "X$ll" = "X$old_library"; then # only static version available 79502f60eb46Smrg found=false 7951c3c9db83Smrg func_dirname "$lib" "" "." 79522f60eb46Smrg ladir=$func_dirname_result 7953c3c9db83Smrg lib=$ladir/$old_library 79542f60eb46Smrg if test prog,link = "$linkmode,$pass"; then 7955c3c9db83Smrg compile_deplibs="$deplib $compile_deplibs" 7956c3c9db83Smrg finalize_deplibs="$deplib $finalize_deplibs" 7957c3c9db83Smrg else 7958c3c9db83Smrg deplibs="$deplib $deplibs" 79592f60eb46Smrg test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 7960c3c9db83Smrg fi 7961c3c9db83Smrg continue 7962c3c9db83Smrg fi 7963c3c9db83Smrg fi 7964c3c9db83Smrg ;; 7965c3c9db83Smrg *) ;; 7966c3c9db83Smrg esac 7967c3c9db83Smrg fi 79682f60eb46Smrg else 79692f60eb46Smrg # deplib doesn't seem to be a libtool library 79702f60eb46Smrg if test prog,link = "$linkmode,$pass"; then 79712f60eb46Smrg compile_deplibs="$deplib $compile_deplibs" 79722f60eb46Smrg finalize_deplibs="$deplib $finalize_deplibs" 79732f60eb46Smrg else 79742f60eb46Smrg deplibs="$deplib $deplibs" 79752f60eb46Smrg test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 79762f60eb46Smrg fi 79772f60eb46Smrg continue 7978c3c9db83Smrg fi 7979c3c9db83Smrg ;; # -l 7980c3c9db83Smrg *.ltframework) 79812f60eb46Smrg if test prog,link = "$linkmode,$pass"; then 7982c3c9db83Smrg compile_deplibs="$deplib $compile_deplibs" 7983c3c9db83Smrg finalize_deplibs="$deplib $finalize_deplibs" 7984c3c9db83Smrg else 7985c3c9db83Smrg deplibs="$deplib $deplibs" 79862f60eb46Smrg if test lib = "$linkmode"; then 7987c3c9db83Smrg case "$new_inherited_linker_flags " in 7988c3c9db83Smrg *" $deplib "*) ;; 79893f6d0e1dSmrg * ) func_append new_inherited_linker_flags " $deplib" ;; 7990c3c9db83Smrg esac 7991c3c9db83Smrg fi 7992c3c9db83Smrg fi 7993c3c9db83Smrg continue 7994c3c9db83Smrg ;; 7995c3c9db83Smrg -L*) 7996c3c9db83Smrg case $linkmode in 7997c3c9db83Smrg lib) 7998c3c9db83Smrg deplibs="$deplib $deplibs" 79992f60eb46Smrg test conv = "$pass" && continue 8000c3c9db83Smrg newdependency_libs="$deplib $newdependency_libs" 8001c3c9db83Smrg func_stripname '-L' '' "$deplib" 80023f6d0e1dSmrg func_resolve_sysroot "$func_stripname_result" 80033f6d0e1dSmrg func_append newlib_search_path " $func_resolve_sysroot_result" 8004c3c9db83Smrg ;; 8005c3c9db83Smrg prog) 80062f60eb46Smrg if test conv = "$pass"; then 8007c3c9db83Smrg deplibs="$deplib $deplibs" 8008c3c9db83Smrg continue 8009c3c9db83Smrg fi 80102f60eb46Smrg if test scan = "$pass"; then 8011c3c9db83Smrg deplibs="$deplib $deplibs" 8012c3c9db83Smrg else 8013c3c9db83Smrg compile_deplibs="$deplib $compile_deplibs" 8014c3c9db83Smrg finalize_deplibs="$deplib $finalize_deplibs" 8015c3c9db83Smrg fi 8016c3c9db83Smrg func_stripname '-L' '' "$deplib" 80173f6d0e1dSmrg func_resolve_sysroot "$func_stripname_result" 80183f6d0e1dSmrg func_append newlib_search_path " $func_resolve_sysroot_result" 8019c3c9db83Smrg ;; 8020c3c9db83Smrg *) 80212f60eb46Smrg func_warning "'-L' is ignored for archives/objects" 8022c3c9db83Smrg ;; 8023c3c9db83Smrg esac # linkmode 8024c3c9db83Smrg continue 8025c3c9db83Smrg ;; # -L 8026c3c9db83Smrg -R*) 80272f60eb46Smrg if test link = "$pass"; then 8028c3c9db83Smrg func_stripname '-R' '' "$deplib" 80293f6d0e1dSmrg func_resolve_sysroot "$func_stripname_result" 80303f6d0e1dSmrg dir=$func_resolve_sysroot_result 8031c3c9db83Smrg # Make sure the xrpath contains only unique directories. 8032c3c9db83Smrg case "$xrpath " in 8033c3c9db83Smrg *" $dir "*) ;; 80343f6d0e1dSmrg *) func_append xrpath " $dir" ;; 8035c3c9db83Smrg esac 8036c3c9db83Smrg fi 8037c3c9db83Smrg deplibs="$deplib $deplibs" 8038c3c9db83Smrg continue 8039c3c9db83Smrg ;; 80403f6d0e1dSmrg *.la) 80413f6d0e1dSmrg func_resolve_sysroot "$deplib" 80423f6d0e1dSmrg lib=$func_resolve_sysroot_result 80433f6d0e1dSmrg ;; 8044c3c9db83Smrg *.$libext) 80452f60eb46Smrg if test conv = "$pass"; then 8046c3c9db83Smrg deplibs="$deplib $deplibs" 8047c3c9db83Smrg continue 8048c3c9db83Smrg fi 8049c3c9db83Smrg case $linkmode in 8050c3c9db83Smrg lib) 8051c3c9db83Smrg # Linking convenience modules into shared libraries is allowed, 8052c3c9db83Smrg # but linking other static libraries is non-portable. 8053c3c9db83Smrg case " $dlpreconveniencelibs " in 8054c3c9db83Smrg *" $deplib "*) ;; 8055c3c9db83Smrg *) 80562f60eb46Smrg valid_a_lib=false 8057c3c9db83Smrg case $deplibs_check_method in 8058c3c9db83Smrg match_pattern*) 8059c3c9db83Smrg set dummy $deplibs_check_method; shift 8060c3c9db83Smrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 80613f6d0e1dSmrg if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ 8062c3c9db83Smrg | $EGREP "$match_pattern_regex" > /dev/null; then 80632f60eb46Smrg valid_a_lib=: 8064c3c9db83Smrg fi 8065c3c9db83Smrg ;; 8066c3c9db83Smrg pass_all) 80672f60eb46Smrg valid_a_lib=: 8068c3c9db83Smrg ;; 8069c3c9db83Smrg esac 80702f60eb46Smrg if $valid_a_lib; then 80712f60eb46Smrg echo 80722f60eb46Smrg $ECHO "*** Warning: Linking the shared library $output against the" 80732f60eb46Smrg $ECHO "*** static library $deplib is not portable!" 80742f60eb46Smrg deplibs="$deplib $deplibs" 80752f60eb46Smrg else 80763f6d0e1dSmrg echo 8077c3c9db83Smrg $ECHO "*** Warning: Trying to link with static lib archive $deplib." 80783f6d0e1dSmrg echo "*** I have the capability to make that library automatically link in when" 80793f6d0e1dSmrg echo "*** you link to this library. But I can only do this if you have a" 80803f6d0e1dSmrg echo "*** shared version of the library, which you do not appear to have" 80813f6d0e1dSmrg echo "*** because the file extensions .$libext of this argument makes me believe" 80823f6d0e1dSmrg echo "*** that it is just a static archive that I should not use here." 8083c3c9db83Smrg fi 8084c3c9db83Smrg ;; 8085c3c9db83Smrg esac 8086c3c9db83Smrg continue 8087c3c9db83Smrg ;; 8088c3c9db83Smrg prog) 80892f60eb46Smrg if test link != "$pass"; then 8090c3c9db83Smrg deplibs="$deplib $deplibs" 8091c3c9db83Smrg else 8092c3c9db83Smrg compile_deplibs="$deplib $compile_deplibs" 8093c3c9db83Smrg finalize_deplibs="$deplib $finalize_deplibs" 8094c3c9db83Smrg fi 8095c3c9db83Smrg continue 8096c3c9db83Smrg ;; 8097c3c9db83Smrg esac # linkmode 8098c3c9db83Smrg ;; # *.$libext 8099c3c9db83Smrg *.lo | *.$objext) 81002f60eb46Smrg if test conv = "$pass"; then 8101c3c9db83Smrg deplibs="$deplib $deplibs" 81022f60eb46Smrg elif test prog = "$linkmode"; then 81032f60eb46Smrg if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then 8104c3c9db83Smrg # If there is no dlopen support or we're linking statically, 8105c3c9db83Smrg # we need to preload. 81063f6d0e1dSmrg func_append newdlprefiles " $deplib" 8107c3c9db83Smrg compile_deplibs="$deplib $compile_deplibs" 8108c3c9db83Smrg finalize_deplibs="$deplib $finalize_deplibs" 8109c3c9db83Smrg else 81103f6d0e1dSmrg func_append newdlfiles " $deplib" 8111c3c9db83Smrg fi 8112c3c9db83Smrg fi 8113c3c9db83Smrg continue 8114c3c9db83Smrg ;; 8115c3c9db83Smrg %DEPLIBS%) 81162f60eb46Smrg alldeplibs=: 8117c3c9db83Smrg continue 8118c3c9db83Smrg ;; 8119c3c9db83Smrg esac # case $deplib 8120c3c9db83Smrg 81212f60eb46Smrg $found || test -f "$lib" \ 81222f60eb46Smrg || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'" 8123c3c9db83Smrg 8124c3c9db83Smrg # Check to see that this really is a libtool archive. 8125c3c9db83Smrg func_lalib_unsafe_p "$lib" \ 81262f60eb46Smrg || func_fatal_error "'$lib' is not a valid libtool archive" 8127c3c9db83Smrg 8128c3c9db83Smrg func_dirname "$lib" "" "." 81292f60eb46Smrg ladir=$func_dirname_result 8130c3c9db83Smrg 8131c3c9db83Smrg dlname= 8132c3c9db83Smrg dlopen= 8133c3c9db83Smrg dlpreopen= 8134c3c9db83Smrg libdir= 8135c3c9db83Smrg library_names= 8136c3c9db83Smrg old_library= 8137c3c9db83Smrg inherited_linker_flags= 8138c3c9db83Smrg # If the library was installed with an old release of libtool, 8139c3c9db83Smrg # it will not redefine variables installed, or shouldnotlink 8140c3c9db83Smrg installed=yes 8141c3c9db83Smrg shouldnotlink=no 8142c3c9db83Smrg avoidtemprpath= 8143c3c9db83Smrg 8144c3c9db83Smrg 8145c3c9db83Smrg # Read the .la file 8146c3c9db83Smrg func_source "$lib" 8147c3c9db83Smrg 8148c3c9db83Smrg # Convert "-framework foo" to "foo.ltframework" 8149c3c9db83Smrg if test -n "$inherited_linker_flags"; then 81503f6d0e1dSmrg tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` 8151c3c9db83Smrg for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do 8152c3c9db83Smrg case " $new_inherited_linker_flags " in 8153c3c9db83Smrg *" $tmp_inherited_linker_flag "*) ;; 81543f6d0e1dSmrg *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; 8155c3c9db83Smrg esac 8156c3c9db83Smrg done 8157c3c9db83Smrg fi 81583f6d0e1dSmrg dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 81592f60eb46Smrg if test lib,link = "$linkmode,$pass" || 81602f60eb46Smrg test prog,scan = "$linkmode,$pass" || 81612f60eb46Smrg { test prog != "$linkmode" && test lib != "$linkmode"; }; then 81623f6d0e1dSmrg test -n "$dlopen" && func_append dlfiles " $dlopen" 81633f6d0e1dSmrg test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" 8164c3c9db83Smrg fi 8165c3c9db83Smrg 81662f60eb46Smrg if test conv = "$pass"; then 8167c3c9db83Smrg # Only check for convenience libraries 8168c3c9db83Smrg deplibs="$lib $deplibs" 8169c3c9db83Smrg if test -z "$libdir"; then 8170c3c9db83Smrg if test -z "$old_library"; then 81712f60eb46Smrg func_fatal_error "cannot find name of link library for '$lib'" 8172c3c9db83Smrg fi 8173c3c9db83Smrg # It is a libtool convenience library, so add in its objects. 81743f6d0e1dSmrg func_append convenience " $ladir/$objdir/$old_library" 81753f6d0e1dSmrg func_append old_convenience " $ladir/$objdir/$old_library" 81762f60eb46Smrg elif test prog != "$linkmode" && test lib != "$linkmode"; then 81772f60eb46Smrg func_fatal_error "'$lib' is not a convenience library" 8178c3c9db83Smrg fi 8179efb46889Smrg tmp_libs= 8180efb46889Smrg for deplib in $dependency_libs; do 8181efb46889Smrg deplibs="$deplib $deplibs" 8182efb46889Smrg if $opt_preserve_dup_deps; then 8183efb46889Smrg case "$tmp_libs " in 8184efb46889Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 8185efb46889Smrg esac 8186efb46889Smrg fi 8187efb46889Smrg func_append tmp_libs " $deplib" 8188efb46889Smrg done 8189c3c9db83Smrg continue 8190c3c9db83Smrg fi # $pass = conv 8191c3c9db83Smrg 8192c3c9db83Smrg 8193c3c9db83Smrg # Get the name of the library we link against. 8194c3c9db83Smrg linklib= 81953f6d0e1dSmrg if test -n "$old_library" && 81962f60eb46Smrg { test yes = "$prefer_static_libs" || 81972f60eb46Smrg test built,no = "$prefer_static_libs,$installed"; }; then 81983f6d0e1dSmrg linklib=$old_library 81993f6d0e1dSmrg else 82003f6d0e1dSmrg for l in $old_library $library_names; do 82012f60eb46Smrg linklib=$l 82023f6d0e1dSmrg done 82033f6d0e1dSmrg fi 8204c3c9db83Smrg if test -z "$linklib"; then 82052f60eb46Smrg func_fatal_error "cannot find name of link library for '$lib'" 8206c3c9db83Smrg fi 8207c3c9db83Smrg 8208c3c9db83Smrg # This library was specified with -dlopen. 82092f60eb46Smrg if test dlopen = "$pass"; then 82102f60eb46Smrg test -z "$libdir" \ 82112f60eb46Smrg && func_fatal_error "cannot -dlopen a convenience library: '$lib'" 8212c3c9db83Smrg if test -z "$dlname" || 82132f60eb46Smrg test yes != "$dlopen_support" || 82142f60eb46Smrg test no = "$build_libtool_libs" 82152f60eb46Smrg then 8216c3c9db83Smrg # If there is no dlname, no dlopen support or we're linking 8217c3c9db83Smrg # statically, we need to preload. We also need to preload any 8218c3c9db83Smrg # dependent libraries so libltdl's deplib preloader doesn't 8219c3c9db83Smrg # bomb out in the load deplibs phase. 82203f6d0e1dSmrg func_append dlprefiles " $lib $dependency_libs" 8221c3c9db83Smrg else 82223f6d0e1dSmrg func_append newdlfiles " $lib" 8223c3c9db83Smrg fi 8224c3c9db83Smrg continue 8225c3c9db83Smrg fi # $pass = dlopen 8226c3c9db83Smrg 8227c3c9db83Smrg # We need an absolute path. 8228c3c9db83Smrg case $ladir in 82292f60eb46Smrg [\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;; 8230c3c9db83Smrg *) 8231c3c9db83Smrg abs_ladir=`cd "$ladir" && pwd` 8232c3c9db83Smrg if test -z "$abs_ladir"; then 82332f60eb46Smrg func_warning "cannot determine absolute directory name of '$ladir'" 8234c3c9db83Smrg func_warning "passing it literally to the linker, although it might fail" 82352f60eb46Smrg abs_ladir=$ladir 8236c3c9db83Smrg fi 8237c3c9db83Smrg ;; 8238c3c9db83Smrg esac 8239c3c9db83Smrg func_basename "$lib" 82402f60eb46Smrg laname=$func_basename_result 8241c3c9db83Smrg 8242c3c9db83Smrg # Find the relevant object directory and library name. 82432f60eb46Smrg if test yes = "$installed"; then 82443f6d0e1dSmrg if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then 82452f60eb46Smrg func_warning "library '$lib' was moved." 82462f60eb46Smrg dir=$ladir 82472f60eb46Smrg absdir=$abs_ladir 82482f60eb46Smrg libdir=$abs_ladir 8249c3c9db83Smrg else 82502f60eb46Smrg dir=$lt_sysroot$libdir 82512f60eb46Smrg absdir=$lt_sysroot$libdir 8252c3c9db83Smrg fi 82532f60eb46Smrg test yes = "$hardcode_automatic" && avoidtemprpath=yes 8254c3c9db83Smrg else 8255c3c9db83Smrg if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then 82562f60eb46Smrg dir=$ladir 82572f60eb46Smrg absdir=$abs_ladir 8258c3c9db83Smrg # Remove this search path later 82593f6d0e1dSmrg func_append notinst_path " $abs_ladir" 8260c3c9db83Smrg else 82612f60eb46Smrg dir=$ladir/$objdir 82622f60eb46Smrg absdir=$abs_ladir/$objdir 8263c3c9db83Smrg # Remove this search path later 82643f6d0e1dSmrg func_append notinst_path " $abs_ladir" 8265c3c9db83Smrg fi 8266c3c9db83Smrg fi # $installed = yes 8267c3c9db83Smrg func_stripname 'lib' '.la' "$laname" 8268c3c9db83Smrg name=$func_stripname_result 8269c3c9db83Smrg 8270c3c9db83Smrg # This library was specified with -dlpreopen. 82712f60eb46Smrg if test dlpreopen = "$pass"; then 82722f60eb46Smrg if test -z "$libdir" && test prog = "$linkmode"; then 82732f60eb46Smrg func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'" 8274c3c9db83Smrg fi 82752f60eb46Smrg case $host in 82763f6d0e1dSmrg # special handling for platforms with PE-DLLs. 82773f6d0e1dSmrg *cygwin* | *mingw* | *cegcc* ) 82783f6d0e1dSmrg # Linker will automatically link against shared library if both 82793f6d0e1dSmrg # static and shared are present. Therefore, ensure we extract 82803f6d0e1dSmrg # symbols from the import library if a shared library is present 82813f6d0e1dSmrg # (otherwise, the dlopen module name will be incorrect). We do 82823f6d0e1dSmrg # this by putting the import library name into $newdlprefiles. 82833f6d0e1dSmrg # We recover the dlopen module name by 'saving' the la file 82843f6d0e1dSmrg # name in a special purpose variable, and (later) extracting the 82853f6d0e1dSmrg # dlname from the la file. 82863f6d0e1dSmrg if test -n "$dlname"; then 82873f6d0e1dSmrg func_tr_sh "$dir/$linklib" 82883f6d0e1dSmrg eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" 82893f6d0e1dSmrg func_append newdlprefiles " $dir/$linklib" 82903f6d0e1dSmrg else 82913f6d0e1dSmrg func_append newdlprefiles " $dir/$old_library" 82923f6d0e1dSmrg # Keep a list of preopened convenience libraries to check 82933f6d0e1dSmrg # that they are being used correctly in the link pass. 82943f6d0e1dSmrg test -z "$libdir" && \ 82953f6d0e1dSmrg func_append dlpreconveniencelibs " $dir/$old_library" 82963f6d0e1dSmrg fi 82973f6d0e1dSmrg ;; 82983f6d0e1dSmrg * ) 82993f6d0e1dSmrg # Prefer using a static library (so that no silly _DYNAMIC symbols 83003f6d0e1dSmrg # are required to link). 83013f6d0e1dSmrg if test -n "$old_library"; then 83023f6d0e1dSmrg func_append newdlprefiles " $dir/$old_library" 83033f6d0e1dSmrg # Keep a list of preopened convenience libraries to check 83043f6d0e1dSmrg # that they are being used correctly in the link pass. 83053f6d0e1dSmrg test -z "$libdir" && \ 83063f6d0e1dSmrg func_append dlpreconveniencelibs " $dir/$old_library" 83073f6d0e1dSmrg # Otherwise, use the dlname, so that lt_dlopen finds it. 83083f6d0e1dSmrg elif test -n "$dlname"; then 83093f6d0e1dSmrg func_append newdlprefiles " $dir/$dlname" 83103f6d0e1dSmrg else 83113f6d0e1dSmrg func_append newdlprefiles " $dir/$linklib" 83123f6d0e1dSmrg fi 83133f6d0e1dSmrg ;; 83143f6d0e1dSmrg esac 8315c3c9db83Smrg fi # $pass = dlpreopen 8316c3c9db83Smrg 8317c3c9db83Smrg if test -z "$libdir"; then 8318c3c9db83Smrg # Link the convenience library 83192f60eb46Smrg if test lib = "$linkmode"; then 8320c3c9db83Smrg deplibs="$dir/$old_library $deplibs" 83212f60eb46Smrg elif test prog,link = "$linkmode,$pass"; then 8322c3c9db83Smrg compile_deplibs="$dir/$old_library $compile_deplibs" 8323c3c9db83Smrg finalize_deplibs="$dir/$old_library $finalize_deplibs" 8324c3c9db83Smrg else 8325c3c9db83Smrg deplibs="$lib $deplibs" # used for prog,scan pass 8326c3c9db83Smrg fi 8327c3c9db83Smrg continue 8328c3c9db83Smrg fi 8329c3c9db83Smrg 8330c3c9db83Smrg 83312f60eb46Smrg if test prog = "$linkmode" && test link != "$pass"; then 83323f6d0e1dSmrg func_append newlib_search_path " $ladir" 8333c3c9db83Smrg deplibs="$lib $deplibs" 8334c3c9db83Smrg 83352f60eb46Smrg linkalldeplibs=false 83362f60eb46Smrg if test no != "$link_all_deplibs" || test -z "$library_names" || 83372f60eb46Smrg test no = "$build_libtool_libs"; then 83382f60eb46Smrg linkalldeplibs=: 8339c3c9db83Smrg fi 8340c3c9db83Smrg 8341c3c9db83Smrg tmp_libs= 8342c3c9db83Smrg for deplib in $dependency_libs; do 8343c3c9db83Smrg case $deplib in 8344c3c9db83Smrg -L*) func_stripname '-L' '' "$deplib" 83453f6d0e1dSmrg func_resolve_sysroot "$func_stripname_result" 83463f6d0e1dSmrg func_append newlib_search_path " $func_resolve_sysroot_result" 8347c3c9db83Smrg ;; 8348c3c9db83Smrg esac 8349c3c9db83Smrg # Need to link against all dependency_libs? 83502f60eb46Smrg if $linkalldeplibs; then 8351c3c9db83Smrg deplibs="$deplib $deplibs" 8352c3c9db83Smrg else 8353c3c9db83Smrg # Need to hardcode shared library paths 8354c3c9db83Smrg # or/and link against static libraries 8355c3c9db83Smrg newdependency_libs="$deplib $newdependency_libs" 8356c3c9db83Smrg fi 83572f60eb46Smrg if $opt_preserve_dup_deps; then 8358c3c9db83Smrg case "$tmp_libs " in 83593f6d0e1dSmrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 8360c3c9db83Smrg esac 8361c3c9db83Smrg fi 83623f6d0e1dSmrg func_append tmp_libs " $deplib" 8363c3c9db83Smrg done # for deplib 8364c3c9db83Smrg continue 8365c3c9db83Smrg fi # $linkmode = prog... 8366c3c9db83Smrg 83672f60eb46Smrg if test prog,link = "$linkmode,$pass"; then 8368c3c9db83Smrg if test -n "$library_names" && 83692f60eb46Smrg { { test no = "$prefer_static_libs" || 83702f60eb46Smrg test built,yes = "$prefer_static_libs,$installed"; } || 8371c3c9db83Smrg test -z "$old_library"; }; then 8372c3c9db83Smrg # We need to hardcode the library path 83732f60eb46Smrg if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then 8374c3c9db83Smrg # Make sure the rpath contains only unique directories. 83752f60eb46Smrg case $temp_rpath: in 8376c3c9db83Smrg *"$absdir:"*) ;; 83773f6d0e1dSmrg *) func_append temp_rpath "$absdir:" ;; 8378c3c9db83Smrg esac 8379c3c9db83Smrg fi 8380c3c9db83Smrg 8381c3c9db83Smrg # Hardcode the library path. 8382c3c9db83Smrg # Skip directories that are in the system default run-time 8383c3c9db83Smrg # search path. 8384c3c9db83Smrg case " $sys_lib_dlsearch_path " in 8385c3c9db83Smrg *" $absdir "*) ;; 8386c3c9db83Smrg *) 8387c3c9db83Smrg case "$compile_rpath " in 8388c3c9db83Smrg *" $absdir "*) ;; 83893f6d0e1dSmrg *) func_append compile_rpath " $absdir" ;; 8390c3c9db83Smrg esac 8391c3c9db83Smrg ;; 8392c3c9db83Smrg esac 8393c3c9db83Smrg case " $sys_lib_dlsearch_path " in 8394c3c9db83Smrg *" $libdir "*) ;; 8395c3c9db83Smrg *) 8396c3c9db83Smrg case "$finalize_rpath " in 8397c3c9db83Smrg *" $libdir "*) ;; 83983f6d0e1dSmrg *) func_append finalize_rpath " $libdir" ;; 8399c3c9db83Smrg esac 8400c3c9db83Smrg ;; 8401c3c9db83Smrg esac 8402c3c9db83Smrg fi # $linkmode,$pass = prog,link... 8403c3c9db83Smrg 84042f60eb46Smrg if $alldeplibs && 84052f60eb46Smrg { test pass_all = "$deplibs_check_method" || 84062f60eb46Smrg { test yes = "$build_libtool_libs" && 8407c3c9db83Smrg test -n "$library_names"; }; }; then 8408c3c9db83Smrg # We only need to search for static libraries 8409c3c9db83Smrg continue 8410c3c9db83Smrg fi 8411c3c9db83Smrg fi 8412c3c9db83Smrg 8413c3c9db83Smrg link_static=no # Whether the deplib will be linked statically 8414c3c9db83Smrg use_static_libs=$prefer_static_libs 84152f60eb46Smrg if test built = "$use_static_libs" && test yes = "$installed"; then 8416c3c9db83Smrg use_static_libs=no 8417c3c9db83Smrg fi 8418c3c9db83Smrg if test -n "$library_names" && 84192f60eb46Smrg { test no = "$use_static_libs" || test -z "$old_library"; }; then 8420c3c9db83Smrg case $host in 84212f60eb46Smrg *cygwin* | *mingw* | *cegcc* | *os2*) 8422c3c9db83Smrg # No point in relinking DLLs because paths are not encoded 84233f6d0e1dSmrg func_append notinst_deplibs " $lib" 8424c3c9db83Smrg need_relink=no 8425c3c9db83Smrg ;; 8426c3c9db83Smrg *) 84272f60eb46Smrg if test no = "$installed"; then 84283f6d0e1dSmrg func_append notinst_deplibs " $lib" 8429c3c9db83Smrg need_relink=yes 8430c3c9db83Smrg fi 8431c3c9db83Smrg ;; 8432c3c9db83Smrg esac 8433c3c9db83Smrg # This is a shared library 8434c3c9db83Smrg 8435c3c9db83Smrg # Warn about portability, can't link against -module's on some 8436c3c9db83Smrg # systems (darwin). Don't bleat about dlopened modules though! 84372f60eb46Smrg dlopenmodule= 8438c3c9db83Smrg for dlpremoduletest in $dlprefiles; do 8439c3c9db83Smrg if test "X$dlpremoduletest" = "X$lib"; then 84402f60eb46Smrg dlopenmodule=$dlpremoduletest 8441c3c9db83Smrg break 8442c3c9db83Smrg fi 8443c3c9db83Smrg done 84442f60eb46Smrg if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then 84453f6d0e1dSmrg echo 84462f60eb46Smrg if test prog = "$linkmode"; then 8447c3c9db83Smrg $ECHO "*** Warning: Linking the executable $output against the loadable module" 8448c3c9db83Smrg else 8449c3c9db83Smrg $ECHO "*** Warning: Linking the shared library $output against the loadable module" 8450c3c9db83Smrg fi 8451c3c9db83Smrg $ECHO "*** $linklib is not portable!" 8452c3c9db83Smrg fi 84532f60eb46Smrg if test lib = "$linkmode" && 84542f60eb46Smrg test yes = "$hardcode_into_libs"; then 8455c3c9db83Smrg # Hardcode the library path. 8456c3c9db83Smrg # Skip directories that are in the system default run-time 8457c3c9db83Smrg # search path. 8458c3c9db83Smrg case " $sys_lib_dlsearch_path " in 8459c3c9db83Smrg *" $absdir "*) ;; 8460c3c9db83Smrg *) 8461c3c9db83Smrg case "$compile_rpath " in 8462c3c9db83Smrg *" $absdir "*) ;; 84633f6d0e1dSmrg *) func_append compile_rpath " $absdir" ;; 8464c3c9db83Smrg esac 8465c3c9db83Smrg ;; 8466c3c9db83Smrg esac 8467c3c9db83Smrg case " $sys_lib_dlsearch_path " in 8468c3c9db83Smrg *" $libdir "*) ;; 8469c3c9db83Smrg *) 8470c3c9db83Smrg case "$finalize_rpath " in 8471c3c9db83Smrg *" $libdir "*) ;; 84723f6d0e1dSmrg *) func_append finalize_rpath " $libdir" ;; 8473c3c9db83Smrg esac 8474c3c9db83Smrg ;; 8475c3c9db83Smrg esac 8476c3c9db83Smrg fi 8477c3c9db83Smrg 8478c3c9db83Smrg if test -n "$old_archive_from_expsyms_cmds"; then 8479c3c9db83Smrg # figure out the soname 8480c3c9db83Smrg set dummy $library_names 8481c3c9db83Smrg shift 84822f60eb46Smrg realname=$1 8483c3c9db83Smrg shift 8484c3c9db83Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 8485c3c9db83Smrg # use dlname if we got it. it's perfectly good, no? 8486c3c9db83Smrg if test -n "$dlname"; then 84872f60eb46Smrg soname=$dlname 8488c3c9db83Smrg elif test -n "$soname_spec"; then 8489c3c9db83Smrg # bleh windows 8490c3c9db83Smrg case $host in 84912f60eb46Smrg *cygwin* | mingw* | *cegcc* | *os2*) 8492c3c9db83Smrg func_arith $current - $age 8493c3c9db83Smrg major=$func_arith_result 84942f60eb46Smrg versuffix=-$major 8495c3c9db83Smrg ;; 8496c3c9db83Smrg esac 8497c3c9db83Smrg eval soname=\"$soname_spec\" 8498c3c9db83Smrg else 84992f60eb46Smrg soname=$realname 8500c3c9db83Smrg fi 8501c3c9db83Smrg 8502c3c9db83Smrg # Make a new name for the extract_expsyms_cmds to use 85032f60eb46Smrg soroot=$soname 8504c3c9db83Smrg func_basename "$soroot" 85052f60eb46Smrg soname=$func_basename_result 8506c3c9db83Smrg func_stripname 'lib' '.dll' "$soname" 8507c3c9db83Smrg newlib=libimp-$func_stripname_result.a 8508c3c9db83Smrg 8509c3c9db83Smrg # If the library has no export list, then create one now 8510c3c9db83Smrg if test -f "$output_objdir/$soname-def"; then : 8511c3c9db83Smrg else 85122f60eb46Smrg func_verbose "extracting exported symbol list from '$soname'" 8513c3c9db83Smrg func_execute_cmds "$extract_expsyms_cmds" 'exit $?' 8514c3c9db83Smrg fi 8515c3c9db83Smrg 8516c3c9db83Smrg # Create $newlib 8517c3c9db83Smrg if test -f "$output_objdir/$newlib"; then :; else 85182f60eb46Smrg func_verbose "generating import library for '$soname'" 8519c3c9db83Smrg func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' 8520c3c9db83Smrg fi 8521c3c9db83Smrg # make sure the library variables are pointing to the new library 8522c3c9db83Smrg dir=$output_objdir 8523c3c9db83Smrg linklib=$newlib 8524c3c9db83Smrg fi # test -n "$old_archive_from_expsyms_cmds" 8525c3c9db83Smrg 85262f60eb46Smrg if test prog = "$linkmode" || test relink != "$opt_mode"; then 8527c3c9db83Smrg add_shlibpath= 8528c3c9db83Smrg add_dir= 8529c3c9db83Smrg add= 8530c3c9db83Smrg lib_linked=yes 8531c3c9db83Smrg case $hardcode_action in 8532c3c9db83Smrg immediate | unsupported) 85332f60eb46Smrg if test no = "$hardcode_direct"; then 85342f60eb46Smrg add=$dir/$linklib 8535c3c9db83Smrg case $host in 85362f60eb46Smrg *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;; 85372f60eb46Smrg *-*-sysv4*uw2*) add_dir=-L$dir ;; 8538c3c9db83Smrg *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ 85392f60eb46Smrg *-*-unixware7*) add_dir=-L$dir ;; 8540c3c9db83Smrg *-*-darwin* ) 85412f60eb46Smrg # if the lib is a (non-dlopened) module then we cannot 8542c3c9db83Smrg # link against it, someone is ignoring the earlier warnings 8543c3c9db83Smrg if /usr/bin/file -L $add 2> /dev/null | 85442f60eb46Smrg $GREP ": [^:]* bundle" >/dev/null; then 8545c3c9db83Smrg if test "X$dlopenmodule" != "X$lib"; then 8546c3c9db83Smrg $ECHO "*** Warning: lib $linklib is a module, not a shared library" 85472f60eb46Smrg if test -z "$old_library"; then 85483f6d0e1dSmrg echo 85493f6d0e1dSmrg echo "*** And there doesn't seem to be a static archive available" 85503f6d0e1dSmrg echo "*** The link will probably fail, sorry" 8551c3c9db83Smrg else 85522f60eb46Smrg add=$dir/$old_library 8553c3c9db83Smrg fi 8554c3c9db83Smrg elif test -n "$old_library"; then 85552f60eb46Smrg add=$dir/$old_library 8556c3c9db83Smrg fi 8557c3c9db83Smrg fi 8558c3c9db83Smrg esac 85592f60eb46Smrg elif test no = "$hardcode_minus_L"; then 8560c3c9db83Smrg case $host in 85612f60eb46Smrg *-*-sunos*) add_shlibpath=$dir ;; 8562c3c9db83Smrg esac 85632f60eb46Smrg add_dir=-L$dir 85642f60eb46Smrg add=-l$name 85652f60eb46Smrg elif test no = "$hardcode_shlibpath_var"; then 85662f60eb46Smrg add_shlibpath=$dir 85672f60eb46Smrg add=-l$name 8568c3c9db83Smrg else 8569c3c9db83Smrg lib_linked=no 8570c3c9db83Smrg fi 8571c3c9db83Smrg ;; 8572c3c9db83Smrg relink) 85732f60eb46Smrg if test yes = "$hardcode_direct" && 85742f60eb46Smrg test no = "$hardcode_direct_absolute"; then 85752f60eb46Smrg add=$dir/$linklib 85762f60eb46Smrg elif test yes = "$hardcode_minus_L"; then 85772f60eb46Smrg add_dir=-L$absdir 8578c3c9db83Smrg # Try looking first in the location we're being installed to. 8579c3c9db83Smrg if test -n "$inst_prefix_dir"; then 8580c3c9db83Smrg case $libdir in 8581c3c9db83Smrg [\\/]*) 85823f6d0e1dSmrg func_append add_dir " -L$inst_prefix_dir$libdir" 8583c3c9db83Smrg ;; 8584c3c9db83Smrg esac 8585c3c9db83Smrg fi 85862f60eb46Smrg add=-l$name 85872f60eb46Smrg elif test yes = "$hardcode_shlibpath_var"; then 85882f60eb46Smrg add_shlibpath=$dir 85892f60eb46Smrg add=-l$name 8590c3c9db83Smrg else 8591c3c9db83Smrg lib_linked=no 8592c3c9db83Smrg fi 8593c3c9db83Smrg ;; 8594c3c9db83Smrg *) lib_linked=no ;; 8595c3c9db83Smrg esac 8596c3c9db83Smrg 85972f60eb46Smrg if test yes != "$lib_linked"; then 8598c3c9db83Smrg func_fatal_configuration "unsupported hardcode properties" 8599c3c9db83Smrg fi 8600c3c9db83Smrg 8601c3c9db83Smrg if test -n "$add_shlibpath"; then 8602c3c9db83Smrg case :$compile_shlibpath: in 8603c3c9db83Smrg *":$add_shlibpath:"*) ;; 86043f6d0e1dSmrg *) func_append compile_shlibpath "$add_shlibpath:" ;; 8605c3c9db83Smrg esac 8606c3c9db83Smrg fi 86072f60eb46Smrg if test prog = "$linkmode"; then 8608c3c9db83Smrg test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" 8609c3c9db83Smrg test -n "$add" && compile_deplibs="$add $compile_deplibs" 8610c3c9db83Smrg else 8611c3c9db83Smrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 8612c3c9db83Smrg test -n "$add" && deplibs="$add $deplibs" 86132f60eb46Smrg if test yes != "$hardcode_direct" && 86142f60eb46Smrg test yes != "$hardcode_minus_L" && 86152f60eb46Smrg test yes = "$hardcode_shlibpath_var"; then 8616c3c9db83Smrg case :$finalize_shlibpath: in 8617c3c9db83Smrg *":$libdir:"*) ;; 86183f6d0e1dSmrg *) func_append finalize_shlibpath "$libdir:" ;; 8619c3c9db83Smrg esac 8620c3c9db83Smrg fi 8621c3c9db83Smrg fi 8622c3c9db83Smrg fi 8623c3c9db83Smrg 86242f60eb46Smrg if test prog = "$linkmode" || test relink = "$opt_mode"; then 8625c3c9db83Smrg add_shlibpath= 8626c3c9db83Smrg add_dir= 8627c3c9db83Smrg add= 8628c3c9db83Smrg # Finalize command for both is simple: just hardcode it. 86292f60eb46Smrg if test yes = "$hardcode_direct" && 86302f60eb46Smrg test no = "$hardcode_direct_absolute"; then 86312f60eb46Smrg add=$libdir/$linklib 86322f60eb46Smrg elif test yes = "$hardcode_minus_L"; then 86332f60eb46Smrg add_dir=-L$libdir 86342f60eb46Smrg add=-l$name 86352f60eb46Smrg elif test yes = "$hardcode_shlibpath_var"; then 8636c3c9db83Smrg case :$finalize_shlibpath: in 8637c3c9db83Smrg *":$libdir:"*) ;; 86383f6d0e1dSmrg *) func_append finalize_shlibpath "$libdir:" ;; 8639c3c9db83Smrg esac 86402f60eb46Smrg add=-l$name 86412f60eb46Smrg elif test yes = "$hardcode_automatic"; then 8642c3c9db83Smrg if test -n "$inst_prefix_dir" && 86432f60eb46Smrg test -f "$inst_prefix_dir$libdir/$linklib"; then 86442f60eb46Smrg add=$inst_prefix_dir$libdir/$linklib 8645c3c9db83Smrg else 86462f60eb46Smrg add=$libdir/$linklib 8647c3c9db83Smrg fi 8648c3c9db83Smrg else 8649c3c9db83Smrg # We cannot seem to hardcode it, guess we'll fake it. 86502f60eb46Smrg add_dir=-L$libdir 8651c3c9db83Smrg # Try looking first in the location we're being installed to. 8652c3c9db83Smrg if test -n "$inst_prefix_dir"; then 8653c3c9db83Smrg case $libdir in 8654c3c9db83Smrg [\\/]*) 86553f6d0e1dSmrg func_append add_dir " -L$inst_prefix_dir$libdir" 8656c3c9db83Smrg ;; 8657c3c9db83Smrg esac 8658c3c9db83Smrg fi 86592f60eb46Smrg add=-l$name 8660c3c9db83Smrg fi 8661c3c9db83Smrg 86622f60eb46Smrg if test prog = "$linkmode"; then 8663c3c9db83Smrg test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" 8664c3c9db83Smrg test -n "$add" && finalize_deplibs="$add $finalize_deplibs" 8665c3c9db83Smrg else 8666c3c9db83Smrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 8667c3c9db83Smrg test -n "$add" && deplibs="$add $deplibs" 8668c3c9db83Smrg fi 8669c3c9db83Smrg fi 86702f60eb46Smrg elif test prog = "$linkmode"; then 8671c3c9db83Smrg # Here we assume that one of hardcode_direct or hardcode_minus_L 8672c3c9db83Smrg # is not unsupported. This is valid on all known static and 8673c3c9db83Smrg # shared platforms. 86742f60eb46Smrg if test unsupported != "$hardcode_direct"; then 86752f60eb46Smrg test -n "$old_library" && linklib=$old_library 8676c3c9db83Smrg compile_deplibs="$dir/$linklib $compile_deplibs" 8677c3c9db83Smrg finalize_deplibs="$dir/$linklib $finalize_deplibs" 8678c3c9db83Smrg else 8679c3c9db83Smrg compile_deplibs="-l$name -L$dir $compile_deplibs" 8680c3c9db83Smrg finalize_deplibs="-l$name -L$dir $finalize_deplibs" 8681c3c9db83Smrg fi 86822f60eb46Smrg elif test yes = "$build_libtool_libs"; then 8683c3c9db83Smrg # Not a shared library 86842f60eb46Smrg if test pass_all != "$deplibs_check_method"; then 8685c3c9db83Smrg # We're trying link a shared library against a static one 8686c3c9db83Smrg # but the system doesn't support it. 8687c3c9db83Smrg 8688c3c9db83Smrg # Just print a warning and add the library to dependency_libs so 8689c3c9db83Smrg # that the program can be linked against the static library. 86903f6d0e1dSmrg echo 86912f60eb46Smrg $ECHO "*** Warning: This system cannot link to static lib archive $lib." 86923f6d0e1dSmrg echo "*** I have the capability to make that library automatically link in when" 86933f6d0e1dSmrg echo "*** you link to this library. But I can only do this if you have a" 86943f6d0e1dSmrg echo "*** shared version of the library, which you do not appear to have." 86952f60eb46Smrg if test yes = "$module"; then 86963f6d0e1dSmrg echo "*** But as you try to build a module library, libtool will still create " 86973f6d0e1dSmrg echo "*** a static module, that should work as long as the dlopening application" 86983f6d0e1dSmrg echo "*** is linked with the -dlopen flag to resolve symbols at runtime." 8699c3c9db83Smrg if test -z "$global_symbol_pipe"; then 87003f6d0e1dSmrg echo 87013f6d0e1dSmrg echo "*** However, this would only work if libtool was able to extract symbol" 87022f60eb46Smrg echo "*** lists from a program, using 'nm' or equivalent, but libtool could" 87033f6d0e1dSmrg echo "*** not find such a program. So, this module is probably useless." 87042f60eb46Smrg echo "*** 'nm' from GNU binutils and a full rebuild may help." 8705c3c9db83Smrg fi 87062f60eb46Smrg if test no = "$build_old_libs"; then 8707c3c9db83Smrg build_libtool_libs=module 8708c3c9db83Smrg build_old_libs=yes 8709c3c9db83Smrg else 8710c3c9db83Smrg build_libtool_libs=no 8711c3c9db83Smrg fi 8712c3c9db83Smrg fi 8713c3c9db83Smrg else 8714c3c9db83Smrg deplibs="$dir/$old_library $deplibs" 8715c3c9db83Smrg link_static=yes 8716c3c9db83Smrg fi 8717c3c9db83Smrg fi # link shared/static library? 8718c3c9db83Smrg 87192f60eb46Smrg if test lib = "$linkmode"; then 8720c3c9db83Smrg if test -n "$dependency_libs" && 87212f60eb46Smrg { test yes != "$hardcode_into_libs" || 87222f60eb46Smrg test yes = "$build_old_libs" || 87232f60eb46Smrg test yes = "$link_static"; }; then 8724c3c9db83Smrg # Extract -R from dependency_libs 8725c3c9db83Smrg temp_deplibs= 8726c3c9db83Smrg for libdir in $dependency_libs; do 8727c3c9db83Smrg case $libdir in 8728c3c9db83Smrg -R*) func_stripname '-R' '' "$libdir" 8729c3c9db83Smrg temp_xrpath=$func_stripname_result 8730c3c9db83Smrg case " $xrpath " in 8731c3c9db83Smrg *" $temp_xrpath "*) ;; 87323f6d0e1dSmrg *) func_append xrpath " $temp_xrpath";; 8733c3c9db83Smrg esac;; 87343f6d0e1dSmrg *) func_append temp_deplibs " $libdir";; 8735c3c9db83Smrg esac 8736c3c9db83Smrg done 87372f60eb46Smrg dependency_libs=$temp_deplibs 8738c3c9db83Smrg fi 8739c3c9db83Smrg 87403f6d0e1dSmrg func_append newlib_search_path " $absdir" 8741c3c9db83Smrg # Link against this library 87422f60eb46Smrg test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs" 8743c3c9db83Smrg # ... and its dependency_libs 8744c3c9db83Smrg tmp_libs= 8745c3c9db83Smrg for deplib in $dependency_libs; do 8746c3c9db83Smrg newdependency_libs="$deplib $newdependency_libs" 87473f6d0e1dSmrg case $deplib in 87483f6d0e1dSmrg -L*) func_stripname '-L' '' "$deplib" 87493f6d0e1dSmrg func_resolve_sysroot "$func_stripname_result";; 87503f6d0e1dSmrg *) func_resolve_sysroot "$deplib" ;; 87513f6d0e1dSmrg esac 87522f60eb46Smrg if $opt_preserve_dup_deps; then 8753c3c9db83Smrg case "$tmp_libs " in 87543f6d0e1dSmrg *" $func_resolve_sysroot_result "*) 87553f6d0e1dSmrg func_append specialdeplibs " $func_resolve_sysroot_result" ;; 8756c3c9db83Smrg esac 8757c3c9db83Smrg fi 87583f6d0e1dSmrg func_append tmp_libs " $func_resolve_sysroot_result" 8759c3c9db83Smrg done 8760c3c9db83Smrg 87612f60eb46Smrg if test no != "$link_all_deplibs"; then 8762c3c9db83Smrg # Add the search paths of all dependency libraries 8763c3c9db83Smrg for deplib in $dependency_libs; do 87643f6d0e1dSmrg path= 8765c3c9db83Smrg case $deplib in 87662f60eb46Smrg -L*) path=$deplib ;; 8767c3c9db83Smrg *.la) 87683f6d0e1dSmrg func_resolve_sysroot "$deplib" 87693f6d0e1dSmrg deplib=$func_resolve_sysroot_result 8770c3c9db83Smrg func_dirname "$deplib" "" "." 87713f6d0e1dSmrg dir=$func_dirname_result 8772c3c9db83Smrg # We need an absolute path. 8773c3c9db83Smrg case $dir in 87742f60eb46Smrg [\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;; 8775c3c9db83Smrg *) 8776c3c9db83Smrg absdir=`cd "$dir" && pwd` 8777c3c9db83Smrg if test -z "$absdir"; then 87782f60eb46Smrg func_warning "cannot determine absolute directory name of '$dir'" 87792f60eb46Smrg absdir=$dir 8780c3c9db83Smrg fi 8781c3c9db83Smrg ;; 8782c3c9db83Smrg esac 8783c3c9db83Smrg if $GREP "^installed=no" $deplib > /dev/null; then 8784c3c9db83Smrg case $host in 8785c3c9db83Smrg *-*-darwin*) 8786c3c9db83Smrg depdepl= 87872f60eb46Smrg eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` 87882f60eb46Smrg if test -n "$deplibrary_names"; then 87892f60eb46Smrg for tmp in $deplibrary_names; do 8790c3c9db83Smrg depdepl=$tmp 8791c3c9db83Smrg done 87922f60eb46Smrg if test -f "$absdir/$objdir/$depdepl"; then 87932f60eb46Smrg depdepl=$absdir/$objdir/$depdepl 87942f60eb46Smrg darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 8795c3c9db83Smrg if test -z "$darwin_install_name"; then 87962f60eb46Smrg darwin_install_name=`$OTOOL64 -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 8797c3c9db83Smrg fi 87982f60eb46Smrg func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl" 87992f60eb46Smrg func_append linker_flags " -dylib_file $darwin_install_name:$depdepl" 8800c3c9db83Smrg path= 8801c3c9db83Smrg fi 8802c3c9db83Smrg fi 8803c3c9db83Smrg ;; 8804c3c9db83Smrg *) 88052f60eb46Smrg path=-L$absdir/$objdir 8806c3c9db83Smrg ;; 8807c3c9db83Smrg esac 8808c3c9db83Smrg else 88092f60eb46Smrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` 8810c3c9db83Smrg test -z "$libdir" && \ 88112f60eb46Smrg func_fatal_error "'$deplib' is not a valid libtool archive" 8812c3c9db83Smrg test "$absdir" != "$libdir" && \ 88132f60eb46Smrg func_warning "'$deplib' seems to be moved" 8814c3c9db83Smrg 88152f60eb46Smrg path=-L$absdir 8816c3c9db83Smrg fi 8817c3c9db83Smrg ;; 8818c3c9db83Smrg esac 8819c3c9db83Smrg case " $deplibs " in 8820c3c9db83Smrg *" $path "*) ;; 8821c3c9db83Smrg *) deplibs="$path $deplibs" ;; 8822c3c9db83Smrg esac 8823c3c9db83Smrg done 8824c3c9db83Smrg fi # link_all_deplibs != no 8825c3c9db83Smrg fi # linkmode = lib 8826c3c9db83Smrg done # for deplib in $libs 88272f60eb46Smrg if test link = "$pass"; then 88282f60eb46Smrg if test prog = "$linkmode"; then 8829c3c9db83Smrg compile_deplibs="$new_inherited_linker_flags $compile_deplibs" 8830c3c9db83Smrg finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" 8831c3c9db83Smrg else 88323f6d0e1dSmrg compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 8833c3c9db83Smrg fi 8834c3c9db83Smrg fi 88352f60eb46Smrg dependency_libs=$newdependency_libs 88362f60eb46Smrg if test dlpreopen = "$pass"; then 8837c3c9db83Smrg # Link the dlpreopened libraries before other libraries 8838c3c9db83Smrg for deplib in $save_deplibs; do 8839c3c9db83Smrg deplibs="$deplib $deplibs" 8840c3c9db83Smrg done 8841c3c9db83Smrg fi 88422f60eb46Smrg if test dlopen != "$pass"; then 88432f60eb46Smrg test conv = "$pass" || { 8844c3c9db83Smrg # Make sure lib_search_path contains only unique directories. 8845c3c9db83Smrg lib_search_path= 8846c3c9db83Smrg for dir in $newlib_search_path; do 8847c3c9db83Smrg case "$lib_search_path " in 8848c3c9db83Smrg *" $dir "*) ;; 88493f6d0e1dSmrg *) func_append lib_search_path " $dir" ;; 8850c3c9db83Smrg esac 8851c3c9db83Smrg done 8852c3c9db83Smrg newlib_search_path= 88532f60eb46Smrg } 8854c3c9db83Smrg 88552f60eb46Smrg if test prog,link = "$linkmode,$pass"; then 8856c3c9db83Smrg vars="compile_deplibs finalize_deplibs" 88572f60eb46Smrg else 88582f60eb46Smrg vars=deplibs 8859c3c9db83Smrg fi 8860c3c9db83Smrg for var in $vars dependency_libs; do 8861c3c9db83Smrg # Add libraries to $var in reverse order 8862c3c9db83Smrg eval tmp_libs=\"\$$var\" 8863c3c9db83Smrg new_libs= 8864c3c9db83Smrg for deplib in $tmp_libs; do 8865c3c9db83Smrg # FIXME: Pedantically, this is the right thing to do, so 8866c3c9db83Smrg # that some nasty dependency loop isn't accidentally 8867c3c9db83Smrg # broken: 8868c3c9db83Smrg #new_libs="$deplib $new_libs" 8869c3c9db83Smrg # Pragmatically, this seems to cause very few problems in 8870c3c9db83Smrg # practice: 8871c3c9db83Smrg case $deplib in 8872c3c9db83Smrg -L*) new_libs="$deplib $new_libs" ;; 8873c3c9db83Smrg -R*) ;; 8874c3c9db83Smrg *) 8875c3c9db83Smrg # And here is the reason: when a library appears more 8876c3c9db83Smrg # than once as an explicit dependence of a library, or 8877c3c9db83Smrg # is implicitly linked in more than once by the 8878c3c9db83Smrg # compiler, it is considered special, and multiple 8879c3c9db83Smrg # occurrences thereof are not removed. Compare this 8880c3c9db83Smrg # with having the same library being listed as a 8881c3c9db83Smrg # dependency of multiple other libraries: in this case, 8882c3c9db83Smrg # we know (pedantically, we assume) the library does not 8883c3c9db83Smrg # need to be listed more than once, so we keep only the 8884c3c9db83Smrg # last copy. This is not always right, but it is rare 8885c3c9db83Smrg # enough that we require users that really mean to play 8886c3c9db83Smrg # such unportable linking tricks to link the library 8887c3c9db83Smrg # using -Wl,-lname, so that libtool does not consider it 8888c3c9db83Smrg # for duplicate removal. 8889c3c9db83Smrg case " $specialdeplibs " in 8890c3c9db83Smrg *" $deplib "*) new_libs="$deplib $new_libs" ;; 8891c3c9db83Smrg *) 8892c3c9db83Smrg case " $new_libs " in 8893c3c9db83Smrg *" $deplib "*) ;; 8894c3c9db83Smrg *) new_libs="$deplib $new_libs" ;; 8895c3c9db83Smrg esac 8896c3c9db83Smrg ;; 8897c3c9db83Smrg esac 8898c3c9db83Smrg ;; 8899c3c9db83Smrg esac 8900c3c9db83Smrg done 8901c3c9db83Smrg tmp_libs= 8902c3c9db83Smrg for deplib in $new_libs; do 8903c3c9db83Smrg case $deplib in 8904c3c9db83Smrg -L*) 8905c3c9db83Smrg case " $tmp_libs " in 8906c3c9db83Smrg *" $deplib "*) ;; 89073f6d0e1dSmrg *) func_append tmp_libs " $deplib" ;; 8908c3c9db83Smrg esac 8909c3c9db83Smrg ;; 89103f6d0e1dSmrg *) func_append tmp_libs " $deplib" ;; 8911c3c9db83Smrg esac 8912c3c9db83Smrg done 8913c3c9db83Smrg eval $var=\"$tmp_libs\" 8914c3c9db83Smrg done # for var 8915c3c9db83Smrg fi 89162f60eb46Smrg 89172f60eb46Smrg # Add Sun CC postdeps if required: 89182f60eb46Smrg test CXX = "$tagname" && { 89192f60eb46Smrg case $host_os in 89202f60eb46Smrg linux*) 8921efb46889Smrg case `$CC -V 2>&1 | $SED 5q` in 89222f60eb46Smrg *Sun\ C*) # Sun C++ 5.9 89232f60eb46Smrg func_suncc_cstd_abi 89242f60eb46Smrg 89252f60eb46Smrg if test no != "$suncc_use_cstd_abi"; then 89262f60eb46Smrg func_append postdeps ' -library=Cstd -library=Crun' 89272f60eb46Smrg fi 89282f60eb46Smrg ;; 89292f60eb46Smrg esac 89302f60eb46Smrg ;; 89312f60eb46Smrg 89322f60eb46Smrg solaris*) 89332f60eb46Smrg func_cc_basename "$CC" 89342f60eb46Smrg case $func_cc_basename_result in 89352f60eb46Smrg CC* | sunCC*) 89362f60eb46Smrg func_suncc_cstd_abi 89372f60eb46Smrg 89382f60eb46Smrg if test no != "$suncc_use_cstd_abi"; then 89392f60eb46Smrg func_append postdeps ' -library=Cstd -library=Crun' 89402f60eb46Smrg fi 89412f60eb46Smrg ;; 89422f60eb46Smrg esac 89432f60eb46Smrg ;; 89442f60eb46Smrg esac 89452f60eb46Smrg } 89462f60eb46Smrg 8947c3c9db83Smrg # Last step: remove runtime libs from dependency_libs 8948c3c9db83Smrg # (they stay in deplibs) 8949c3c9db83Smrg tmp_libs= 89502f60eb46Smrg for i in $dependency_libs; do 8951c3c9db83Smrg case " $predeps $postdeps $compiler_lib_search_path " in 8952c3c9db83Smrg *" $i "*) 89532f60eb46Smrg i= 8954c3c9db83Smrg ;; 8955c3c9db83Smrg esac 89562f60eb46Smrg if test -n "$i"; then 89573f6d0e1dSmrg func_append tmp_libs " $i" 8958c3c9db83Smrg fi 8959c3c9db83Smrg done 8960c3c9db83Smrg dependency_libs=$tmp_libs 8961c3c9db83Smrg done # for pass 89622f60eb46Smrg if test prog = "$linkmode"; then 89632f60eb46Smrg dlfiles=$newdlfiles 8964c3c9db83Smrg fi 89652f60eb46Smrg if test prog = "$linkmode" || test lib = "$linkmode"; then 89662f60eb46Smrg dlprefiles=$newdlprefiles 8967c3c9db83Smrg fi 8968c3c9db83Smrg 8969c3c9db83Smrg case $linkmode in 8970c3c9db83Smrg oldlib) 89712f60eb46Smrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 89722f60eb46Smrg func_warning "'-dlopen' is ignored for archives" 8973c3c9db83Smrg fi 8974c3c9db83Smrg 8975c3c9db83Smrg case " $deplibs" in 8976c3c9db83Smrg *\ -l* | *\ -L*) 89772f60eb46Smrg func_warning "'-l' and '-L' are ignored for archives" ;; 8978c3c9db83Smrg esac 8979c3c9db83Smrg 8980c3c9db83Smrg test -n "$rpath" && \ 89812f60eb46Smrg func_warning "'-rpath' is ignored for archives" 8982c3c9db83Smrg 8983c3c9db83Smrg test -n "$xrpath" && \ 89842f60eb46Smrg func_warning "'-R' is ignored for archives" 8985c3c9db83Smrg 8986c3c9db83Smrg test -n "$vinfo" && \ 89872f60eb46Smrg func_warning "'-version-info/-version-number' is ignored for archives" 8988c3c9db83Smrg 8989c3c9db83Smrg test -n "$release" && \ 89902f60eb46Smrg func_warning "'-release' is ignored for archives" 8991c3c9db83Smrg 8992c3c9db83Smrg test -n "$export_symbols$export_symbols_regex" && \ 89932f60eb46Smrg func_warning "'-export-symbols' is ignored for archives" 8994c3c9db83Smrg 8995c3c9db83Smrg # Now set the variables for building old libraries. 8996c3c9db83Smrg build_libtool_libs=no 89972f60eb46Smrg oldlibs=$output 89983f6d0e1dSmrg func_append objs "$old_deplibs" 8999c3c9db83Smrg ;; 9000c3c9db83Smrg 9001c3c9db83Smrg lib) 90022f60eb46Smrg # Make sure we only generate libraries of the form 'libNAME.la'. 9003c3c9db83Smrg case $outputname in 9004c3c9db83Smrg lib*) 9005c3c9db83Smrg func_stripname 'lib' '.la' "$outputname" 9006c3c9db83Smrg name=$func_stripname_result 9007c3c9db83Smrg eval shared_ext=\"$shrext_cmds\" 9008c3c9db83Smrg eval libname=\"$libname_spec\" 9009c3c9db83Smrg ;; 9010c3c9db83Smrg *) 90112f60eb46Smrg test no = "$module" \ 90122f60eb46Smrg && func_fatal_help "libtool library '$output' must begin with 'lib'" 9013c3c9db83Smrg 90142f60eb46Smrg if test no != "$need_lib_prefix"; then 9015c3c9db83Smrg # Add the "lib" prefix for modules if required 9016c3c9db83Smrg func_stripname '' '.la' "$outputname" 9017c3c9db83Smrg name=$func_stripname_result 9018c3c9db83Smrg eval shared_ext=\"$shrext_cmds\" 9019c3c9db83Smrg eval libname=\"$libname_spec\" 9020c3c9db83Smrg else 9021c3c9db83Smrg func_stripname '' '.la' "$outputname" 9022c3c9db83Smrg libname=$func_stripname_result 9023c3c9db83Smrg fi 9024c3c9db83Smrg ;; 9025c3c9db83Smrg esac 9026c3c9db83Smrg 9027c3c9db83Smrg if test -n "$objs"; then 90282f60eb46Smrg if test pass_all != "$deplibs_check_method"; then 90292f60eb46Smrg func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs" 9030c3c9db83Smrg else 90313f6d0e1dSmrg echo 9032c3c9db83Smrg $ECHO "*** Warning: Linking the shared library $output against the non-libtool" 9033c3c9db83Smrg $ECHO "*** objects $objs is not portable!" 90343f6d0e1dSmrg func_append libobjs " $objs" 9035c3c9db83Smrg fi 9036c3c9db83Smrg fi 9037c3c9db83Smrg 90382f60eb46Smrg test no = "$dlself" \ 90392f60eb46Smrg || func_warning "'-dlopen self' is ignored for libtool libraries" 9040c3c9db83Smrg 9041c3c9db83Smrg set dummy $rpath 9042c3c9db83Smrg shift 90432f60eb46Smrg test 1 -lt "$#" \ 90442f60eb46Smrg && func_warning "ignoring multiple '-rpath's for a libtool library" 9045c3c9db83Smrg 90462f60eb46Smrg install_libdir=$1 9047c3c9db83Smrg 9048c3c9db83Smrg oldlibs= 9049c3c9db83Smrg if test -z "$rpath"; then 90502f60eb46Smrg if test yes = "$build_libtool_libs"; then 9051c3c9db83Smrg # Building a libtool convenience library. 90522f60eb46Smrg # Some compilers have problems with a '.al' extension so 9053c3c9db83Smrg # convenience libraries should have the same extension an 9054c3c9db83Smrg # archive normally would. 9055c3c9db83Smrg oldlibs="$output_objdir/$libname.$libext $oldlibs" 9056c3c9db83Smrg build_libtool_libs=convenience 9057c3c9db83Smrg build_old_libs=yes 9058c3c9db83Smrg fi 9059c3c9db83Smrg 9060c3c9db83Smrg test -n "$vinfo" && \ 90612f60eb46Smrg func_warning "'-version-info/-version-number' is ignored for convenience libraries" 9062c3c9db83Smrg 9063c3c9db83Smrg test -n "$release" && \ 90642f60eb46Smrg func_warning "'-release' is ignored for convenience libraries" 9065c3c9db83Smrg else 9066c3c9db83Smrg 9067c3c9db83Smrg # Parse the version information argument. 90682f60eb46Smrg save_ifs=$IFS; IFS=: 9069c3c9db83Smrg set dummy $vinfo 0 0 0 9070c3c9db83Smrg shift 90712f60eb46Smrg IFS=$save_ifs 9072c3c9db83Smrg 9073c3c9db83Smrg test -n "$7" && \ 90742f60eb46Smrg func_fatal_help "too many parameters to '-version-info'" 9075c3c9db83Smrg 9076c3c9db83Smrg # convert absolute version numbers to libtool ages 9077c3c9db83Smrg # this retains compatibility with .la files and attempts 9078c3c9db83Smrg # to make the code below a bit more comprehensible 9079c3c9db83Smrg 9080c3c9db83Smrg case $vinfo_number in 9081c3c9db83Smrg yes) 90822f60eb46Smrg number_major=$1 90832f60eb46Smrg number_minor=$2 90842f60eb46Smrg number_revision=$3 9085c3c9db83Smrg # 9086c3c9db83Smrg # There are really only two kinds -- those that 9087c3c9db83Smrg # use the current revision as the major version 9088c3c9db83Smrg # and those that subtract age and use age as 9089c3c9db83Smrg # a minor version. But, then there is irix 90902f60eb46Smrg # that has an extra 1 added just for fun 9091c3c9db83Smrg # 9092c3c9db83Smrg case $version_type in 909395903e71Smrg # correct linux to gnu/linux during the next big refactor 9094efb46889Smrg darwin|freebsd-elf|linux|midnightbsd-elf|osf|windows|none) 9095c3c9db83Smrg func_arith $number_major + $number_minor 9096c3c9db83Smrg current=$func_arith_result 90972f60eb46Smrg age=$number_minor 90982f60eb46Smrg revision=$number_revision 9099c3c9db83Smrg ;; 91002f60eb46Smrg freebsd-aout|qnx|sunos) 91012f60eb46Smrg current=$number_major 91022f60eb46Smrg revision=$number_minor 91032f60eb46Smrg age=0 9104c3c9db83Smrg ;; 9105c3c9db83Smrg irix|nonstopux) 9106c3c9db83Smrg func_arith $number_major + $number_minor 9107c3c9db83Smrg current=$func_arith_result 91082f60eb46Smrg age=$number_minor 91092f60eb46Smrg revision=$number_minor 9110c3c9db83Smrg lt_irix_increment=no 9111c3c9db83Smrg ;; 9112c3c9db83Smrg esac 9113c3c9db83Smrg ;; 9114c3c9db83Smrg no) 91152f60eb46Smrg current=$1 91162f60eb46Smrg revision=$2 91172f60eb46Smrg age=$3 9118c3c9db83Smrg ;; 9119c3c9db83Smrg esac 9120c3c9db83Smrg 9121c3c9db83Smrg # Check that each of the things are valid numbers. 9122c3c9db83Smrg case $current in 9123c3c9db83Smrg 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]) ;; 9124c3c9db83Smrg *) 91252f60eb46Smrg func_error "CURRENT '$current' must be a nonnegative integer" 91262f60eb46Smrg func_fatal_error "'$vinfo' is not valid version information" 9127c3c9db83Smrg ;; 9128c3c9db83Smrg esac 9129c3c9db83Smrg 9130c3c9db83Smrg case $revision in 9131c3c9db83Smrg 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]) ;; 9132c3c9db83Smrg *) 91332f60eb46Smrg func_error "REVISION '$revision' must be a nonnegative integer" 91342f60eb46Smrg func_fatal_error "'$vinfo' is not valid version information" 9135c3c9db83Smrg ;; 9136c3c9db83Smrg esac 9137c3c9db83Smrg 9138c3c9db83Smrg case $age in 9139c3c9db83Smrg 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]) ;; 9140c3c9db83Smrg *) 91412f60eb46Smrg func_error "AGE '$age' must be a nonnegative integer" 91422f60eb46Smrg func_fatal_error "'$vinfo' is not valid version information" 9143c3c9db83Smrg ;; 9144c3c9db83Smrg esac 9145c3c9db83Smrg 9146c3c9db83Smrg if test "$age" -gt "$current"; then 91472f60eb46Smrg func_error "AGE '$age' is greater than the current interface number '$current'" 91482f60eb46Smrg func_fatal_error "'$vinfo' is not valid version information" 9149c3c9db83Smrg fi 9150c3c9db83Smrg 9151c3c9db83Smrg # Calculate the version variables. 9152c3c9db83Smrg major= 9153c3c9db83Smrg versuffix= 9154c3c9db83Smrg verstring= 9155c3c9db83Smrg case $version_type in 9156c3c9db83Smrg none) ;; 9157c3c9db83Smrg 9158c3c9db83Smrg darwin) 9159c3c9db83Smrg # Like Linux, but with the current version available in 9160c3c9db83Smrg # verstring for coding it into the library header 9161c3c9db83Smrg func_arith $current - $age 9162c3c9db83Smrg major=.$func_arith_result 91632f60eb46Smrg versuffix=$major.$age.$revision 9164c3c9db83Smrg # Darwin ld doesn't like 0 for these options... 9165c3c9db83Smrg func_arith $current + 1 9166c3c9db83Smrg minor_current=$func_arith_result 91672f60eb46Smrg xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" 9168c3c9db83Smrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 91692f60eb46Smrg # On Darwin other compilers 91702f60eb46Smrg case $CC in 91712f60eb46Smrg nagfor*) 91722f60eb46Smrg verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" 91732f60eb46Smrg ;; 91742f60eb46Smrg *) 91752f60eb46Smrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 91762f60eb46Smrg ;; 91772f60eb46Smrg esac 9178c3c9db83Smrg ;; 9179c3c9db83Smrg 9180c3c9db83Smrg freebsd-aout) 91812f60eb46Smrg major=.$current 91822f60eb46Smrg versuffix=.$current.$revision 9183c3c9db83Smrg ;; 9184c3c9db83Smrg 9185efb46889Smrg freebsd-elf | midnightbsd-elf) 91862f60eb46Smrg func_arith $current - $age 91872f60eb46Smrg major=.$func_arith_result 91882f60eb46Smrg versuffix=$major.$age.$revision 9189c3c9db83Smrg ;; 9190c3c9db83Smrg 9191c3c9db83Smrg irix | nonstopux) 91922f60eb46Smrg if test no = "$lt_irix_increment"; then 9193c3c9db83Smrg func_arith $current - $age 9194c3c9db83Smrg else 9195c3c9db83Smrg func_arith $current - $age + 1 9196c3c9db83Smrg fi 9197c3c9db83Smrg major=$func_arith_result 9198c3c9db83Smrg 9199c3c9db83Smrg case $version_type in 9200c3c9db83Smrg nonstopux) verstring_prefix=nonstopux ;; 9201c3c9db83Smrg *) verstring_prefix=sgi ;; 9202c3c9db83Smrg esac 92032f60eb46Smrg verstring=$verstring_prefix$major.$revision 9204c3c9db83Smrg 9205c3c9db83Smrg # Add in all the interfaces that we are compatible with. 9206c3c9db83Smrg loop=$revision 92072f60eb46Smrg while test 0 -ne "$loop"; do 9208c3c9db83Smrg func_arith $revision - $loop 9209c3c9db83Smrg iface=$func_arith_result 9210c3c9db83Smrg func_arith $loop - 1 9211c3c9db83Smrg loop=$func_arith_result 92122f60eb46Smrg verstring=$verstring_prefix$major.$iface:$verstring 9213c3c9db83Smrg done 9214c3c9db83Smrg 92152f60eb46Smrg # Before this point, $major must not contain '.'. 9216c3c9db83Smrg major=.$major 92172f60eb46Smrg versuffix=$major.$revision 9218c3c9db83Smrg ;; 9219c3c9db83Smrg 922095903e71Smrg linux) # correct to gnu/linux during the next big refactor 9221c3c9db83Smrg func_arith $current - $age 9222c3c9db83Smrg major=.$func_arith_result 92232f60eb46Smrg versuffix=$major.$age.$revision 9224c3c9db83Smrg ;; 9225c3c9db83Smrg 9226c3c9db83Smrg osf) 9227c3c9db83Smrg func_arith $current - $age 9228c3c9db83Smrg major=.$func_arith_result 92292f60eb46Smrg versuffix=.$current.$age.$revision 92302f60eb46Smrg verstring=$current.$age.$revision 9231c3c9db83Smrg 9232c3c9db83Smrg # Add in all the interfaces that we are compatible with. 9233c3c9db83Smrg loop=$age 92342f60eb46Smrg while test 0 -ne "$loop"; do 9235c3c9db83Smrg func_arith $current - $loop 9236c3c9db83Smrg iface=$func_arith_result 9237c3c9db83Smrg func_arith $loop - 1 9238c3c9db83Smrg loop=$func_arith_result 92392f60eb46Smrg verstring=$verstring:$iface.0 9240c3c9db83Smrg done 9241c3c9db83Smrg 9242c3c9db83Smrg # Make executables depend on our current version. 92432f60eb46Smrg func_append verstring ":$current.0" 9244c3c9db83Smrg ;; 9245c3c9db83Smrg 9246c3c9db83Smrg qnx) 92472f60eb46Smrg major=.$current 92482f60eb46Smrg versuffix=.$current 92492f60eb46Smrg ;; 92502f60eb46Smrg 92512f60eb46Smrg sco) 92522f60eb46Smrg major=.$current 92532f60eb46Smrg versuffix=.$current 9254c3c9db83Smrg ;; 9255c3c9db83Smrg 9256c3c9db83Smrg sunos) 92572f60eb46Smrg major=.$current 92582f60eb46Smrg versuffix=.$current.$revision 9259c3c9db83Smrg ;; 9260c3c9db83Smrg 9261c3c9db83Smrg windows) 9262c3c9db83Smrg # Use '-' rather than '.', since we only want one 92632f60eb46Smrg # extension on DOS 8.3 file systems. 9264c3c9db83Smrg func_arith $current - $age 9265c3c9db83Smrg major=$func_arith_result 92662f60eb46Smrg versuffix=-$major 9267c3c9db83Smrg ;; 9268c3c9db83Smrg 9269c3c9db83Smrg *) 92702f60eb46Smrg func_fatal_configuration "unknown library version type '$version_type'" 9271c3c9db83Smrg ;; 9272c3c9db83Smrg esac 9273c3c9db83Smrg 9274c3c9db83Smrg # Clear the version info if we defaulted, and they specified a release. 9275c3c9db83Smrg if test -z "$vinfo" && test -n "$release"; then 9276c3c9db83Smrg major= 9277c3c9db83Smrg case $version_type in 9278c3c9db83Smrg darwin) 9279c3c9db83Smrg # we can't check for "0.0" in archive_cmds due to quoting 9280c3c9db83Smrg # problems, so we reset it completely 9281c3c9db83Smrg verstring= 9282c3c9db83Smrg ;; 9283c3c9db83Smrg *) 92842f60eb46Smrg verstring=0.0 9285c3c9db83Smrg ;; 9286c3c9db83Smrg esac 92872f60eb46Smrg if test no = "$need_version"; then 9288c3c9db83Smrg versuffix= 9289c3c9db83Smrg else 92902f60eb46Smrg versuffix=.0.0 9291c3c9db83Smrg fi 9292c3c9db83Smrg fi 9293c3c9db83Smrg 9294c3c9db83Smrg # Remove version info from name if versioning should be avoided 92952f60eb46Smrg if test yes,no = "$avoid_version,$need_version"; then 9296c3c9db83Smrg major= 9297c3c9db83Smrg versuffix= 92982f60eb46Smrg verstring= 9299c3c9db83Smrg fi 9300c3c9db83Smrg 9301c3c9db83Smrg # Check to see if the archive will have undefined symbols. 93022f60eb46Smrg if test yes = "$allow_undefined"; then 93032f60eb46Smrg if test unsupported = "$allow_undefined_flag"; then 93042f60eb46Smrg if test yes = "$build_old_libs"; then 93052f60eb46Smrg func_warning "undefined symbols not allowed in $host shared libraries; building static only" 93062f60eb46Smrg build_libtool_libs=no 93072f60eb46Smrg else 93082f60eb46Smrg func_fatal_error "can't build $host shared library unless -no-undefined is specified" 93092f60eb46Smrg fi 9310c3c9db83Smrg fi 9311c3c9db83Smrg else 9312c3c9db83Smrg # Don't allow undefined symbols. 93132f60eb46Smrg allow_undefined_flag=$no_undefined_flag 9314c3c9db83Smrg fi 9315c3c9db83Smrg 9316c3c9db83Smrg fi 9317c3c9db83Smrg 93182f60eb46Smrg func_generate_dlsyms "$libname" "$libname" : 93193f6d0e1dSmrg func_append libobjs " $symfileobj" 93202f60eb46Smrg test " " = "$libobjs" && libobjs= 9321c3c9db83Smrg 93222f60eb46Smrg if test relink != "$opt_mode"; then 9323c3c9db83Smrg # Remove our outputs, but don't remove object files since they 9324c3c9db83Smrg # may have been created when compiling PIC objects. 9325c3c9db83Smrg removelist= 9326c3c9db83Smrg tempremovelist=`$ECHO "$output_objdir/*"` 9327c3c9db83Smrg for p in $tempremovelist; do 9328c3c9db83Smrg case $p in 9329c3c9db83Smrg *.$objext | *.gcno) 9330c3c9db83Smrg ;; 93312f60eb46Smrg $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/$libname$release.*) 93322f60eb46Smrg if test -n "$precious_files_regex"; then 9333c3c9db83Smrg if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 9334c3c9db83Smrg then 9335c3c9db83Smrg continue 9336c3c9db83Smrg fi 9337c3c9db83Smrg fi 93383f6d0e1dSmrg func_append removelist " $p" 9339c3c9db83Smrg ;; 9340c3c9db83Smrg *) ;; 9341c3c9db83Smrg esac 9342c3c9db83Smrg done 9343c3c9db83Smrg test -n "$removelist" && \ 9344c3c9db83Smrg func_show_eval "${RM}r \$removelist" 9345c3c9db83Smrg fi 9346c3c9db83Smrg 9347c3c9db83Smrg # Now set the variables for building old libraries. 93482f60eb46Smrg if test yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; then 93493f6d0e1dSmrg func_append oldlibs " $output_objdir/$libname.$libext" 9350c3c9db83Smrg 9351c3c9db83Smrg # Transform .lo files to .o files. 93522f60eb46Smrg oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; $lo2o" | $NL2SP` 9353c3c9db83Smrg fi 9354c3c9db83Smrg 9355c3c9db83Smrg # Eliminate all temporary directories. 9356c3c9db83Smrg #for path in $notinst_path; do 93573f6d0e1dSmrg # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` 93583f6d0e1dSmrg # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` 93593f6d0e1dSmrg # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` 9360c3c9db83Smrg #done 9361c3c9db83Smrg 9362c3c9db83Smrg if test -n "$xrpath"; then 9363c3c9db83Smrg # If the user specified any rpath flags, then add them. 9364c3c9db83Smrg temp_xrpath= 9365c3c9db83Smrg for libdir in $xrpath; do 93663f6d0e1dSmrg func_replace_sysroot "$libdir" 93673f6d0e1dSmrg func_append temp_xrpath " -R$func_replace_sysroot_result" 9368c3c9db83Smrg case "$finalize_rpath " in 9369c3c9db83Smrg *" $libdir "*) ;; 93703f6d0e1dSmrg *) func_append finalize_rpath " $libdir" ;; 9371c3c9db83Smrg esac 9372c3c9db83Smrg done 93732f60eb46Smrg if test yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; then 9374c3c9db83Smrg dependency_libs="$temp_xrpath $dependency_libs" 9375c3c9db83Smrg fi 9376c3c9db83Smrg fi 9377c3c9db83Smrg 9378c3c9db83Smrg # Make sure dlfiles contains only unique files that won't be dlpreopened 93792f60eb46Smrg old_dlfiles=$dlfiles 9380c3c9db83Smrg dlfiles= 9381c3c9db83Smrg for lib in $old_dlfiles; do 9382c3c9db83Smrg case " $dlprefiles $dlfiles " in 9383c3c9db83Smrg *" $lib "*) ;; 93843f6d0e1dSmrg *) func_append dlfiles " $lib" ;; 9385c3c9db83Smrg esac 9386c3c9db83Smrg done 9387c3c9db83Smrg 9388c3c9db83Smrg # Make sure dlprefiles contains only unique files 93892f60eb46Smrg old_dlprefiles=$dlprefiles 9390c3c9db83Smrg dlprefiles= 9391c3c9db83Smrg for lib in $old_dlprefiles; do 9392c3c9db83Smrg case "$dlprefiles " in 9393c3c9db83Smrg *" $lib "*) ;; 93943f6d0e1dSmrg *) func_append dlprefiles " $lib" ;; 9395c3c9db83Smrg esac 9396c3c9db83Smrg done 9397c3c9db83Smrg 93982f60eb46Smrg if test yes = "$build_libtool_libs"; then 9399c3c9db83Smrg if test -n "$rpath"; then 9400c3c9db83Smrg case $host in 94013f6d0e1dSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) 9402c3c9db83Smrg # these systems don't actually have a c library (as such)! 9403c3c9db83Smrg ;; 9404c3c9db83Smrg *-*-rhapsody* | *-*-darwin1.[012]) 9405c3c9db83Smrg # Rhapsody C library is in the System framework 94063f6d0e1dSmrg func_append deplibs " System.ltframework" 9407c3c9db83Smrg ;; 9408c3c9db83Smrg *-*-netbsd*) 9409c3c9db83Smrg # Don't link with libc until the a.out ld.so is fixed. 9410c3c9db83Smrg ;; 9411efb46889Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-midnightbsd*) 9412c3c9db83Smrg # Do not include libc due to us having libc/libc_r. 9413c3c9db83Smrg ;; 9414c3c9db83Smrg *-*-sco3.2v5* | *-*-sco5v6*) 9415c3c9db83Smrg # Causes problems with __ctype 9416c3c9db83Smrg ;; 9417c3c9db83Smrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 9418c3c9db83Smrg # Compiler inserts libc in the correct place for threads to work 9419c3c9db83Smrg ;; 9420c3c9db83Smrg *) 9421c3c9db83Smrg # Add libc to deplibs on all other systems if necessary. 94222f60eb46Smrg if test yes = "$build_libtool_need_lc"; then 94233f6d0e1dSmrg func_append deplibs " -lc" 9424c3c9db83Smrg fi 9425c3c9db83Smrg ;; 9426c3c9db83Smrg esac 9427c3c9db83Smrg fi 9428c3c9db83Smrg 9429c3c9db83Smrg # Transform deplibs into only deplibs that can be linked in shared. 9430c3c9db83Smrg name_save=$name 9431c3c9db83Smrg libname_save=$libname 9432c3c9db83Smrg release_save=$release 9433c3c9db83Smrg versuffix_save=$versuffix 9434c3c9db83Smrg major_save=$major 9435c3c9db83Smrg # I'm not sure if I'm treating the release correctly. I think 9436c3c9db83Smrg # release should show up in the -l (ie -lgmp5) so we don't want to 9437c3c9db83Smrg # add it in twice. Is that correct? 94382f60eb46Smrg release= 94392f60eb46Smrg versuffix= 94402f60eb46Smrg major= 9441c3c9db83Smrg newdeplibs= 9442c3c9db83Smrg droppeddeps=no 9443c3c9db83Smrg case $deplibs_check_method in 9444c3c9db83Smrg pass_all) 9445c3c9db83Smrg # Don't check for shared/static. Everything works. 9446c3c9db83Smrg # This might be a little naive. We might want to check 9447c3c9db83Smrg # whether the library exists or not. But this is on 9448c3c9db83Smrg # osf3 & osf4 and I'm not really sure... Just 9449c3c9db83Smrg # implementing what was already the behavior. 9450c3c9db83Smrg newdeplibs=$deplibs 9451c3c9db83Smrg ;; 9452c3c9db83Smrg test_compile) 9453c3c9db83Smrg # This code stresses the "libraries are programs" paradigm to its 9454c3c9db83Smrg # limits. Maybe even breaks it. We compile a program, linking it 9455c3c9db83Smrg # against the deplibs as a proxy for the library. Then we can check 9456c3c9db83Smrg # whether they linked in statically or dynamically with ldd. 9457c3c9db83Smrg $opt_dry_run || $RM conftest.c 9458c3c9db83Smrg cat > conftest.c <<EOF 9459c3c9db83Smrg int main() { return 0; } 9460c3c9db83SmrgEOF 9461c3c9db83Smrg $opt_dry_run || $RM conftest 9462c3c9db83Smrg if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then 9463c3c9db83Smrg ldd_output=`ldd conftest` 9464c3c9db83Smrg for i in $deplibs; do 9465c3c9db83Smrg case $i in 9466c3c9db83Smrg -l*) 9467c3c9db83Smrg func_stripname -l '' "$i" 9468c3c9db83Smrg name=$func_stripname_result 94692f60eb46Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9470c3c9db83Smrg case " $predeps $postdeps " in 9471c3c9db83Smrg *" $i "*) 94723f6d0e1dSmrg func_append newdeplibs " $i" 94732f60eb46Smrg i= 9474c3c9db83Smrg ;; 9475c3c9db83Smrg esac 9476c3c9db83Smrg fi 94772f60eb46Smrg if test -n "$i"; then 9478c3c9db83Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 9479c3c9db83Smrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 9480c3c9db83Smrg set dummy $deplib_matches; shift 9481c3c9db83Smrg deplib_match=$1 94822f60eb46Smrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then 94833f6d0e1dSmrg func_append newdeplibs " $i" 9484c3c9db83Smrg else 9485c3c9db83Smrg droppeddeps=yes 94863f6d0e1dSmrg echo 9487c3c9db83Smrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 94883f6d0e1dSmrg echo "*** I have the capability to make that library automatically link in when" 94893f6d0e1dSmrg echo "*** you link to this library. But I can only do this if you have a" 94903f6d0e1dSmrg echo "*** shared version of the library, which I believe you do not have" 94913f6d0e1dSmrg echo "*** because a test_compile did reveal that the linker did not use it for" 94923f6d0e1dSmrg echo "*** its dynamic dependency list that programs get resolved with at runtime." 9493c3c9db83Smrg fi 9494c3c9db83Smrg fi 9495c3c9db83Smrg ;; 9496c3c9db83Smrg *) 94973f6d0e1dSmrg func_append newdeplibs " $i" 9498c3c9db83Smrg ;; 9499c3c9db83Smrg esac 9500c3c9db83Smrg done 9501c3c9db83Smrg else 9502c3c9db83Smrg # Error occurred in the first compile. Let's try to salvage 9503c3c9db83Smrg # the situation: Compile a separate program for each library. 9504c3c9db83Smrg for i in $deplibs; do 9505c3c9db83Smrg case $i in 9506c3c9db83Smrg -l*) 9507c3c9db83Smrg func_stripname -l '' "$i" 9508c3c9db83Smrg name=$func_stripname_result 9509c3c9db83Smrg $opt_dry_run || $RM conftest 9510c3c9db83Smrg if $LTCC $LTCFLAGS -o conftest conftest.c $i; then 9511c3c9db83Smrg ldd_output=`ldd conftest` 95122f60eb46Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9513c3c9db83Smrg case " $predeps $postdeps " in 9514c3c9db83Smrg *" $i "*) 95153f6d0e1dSmrg func_append newdeplibs " $i" 95162f60eb46Smrg i= 9517c3c9db83Smrg ;; 9518c3c9db83Smrg esac 9519c3c9db83Smrg fi 95202f60eb46Smrg if test -n "$i"; then 9521c3c9db83Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 9522c3c9db83Smrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 9523c3c9db83Smrg set dummy $deplib_matches; shift 9524c3c9db83Smrg deplib_match=$1 95252f60eb46Smrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then 95263f6d0e1dSmrg func_append newdeplibs " $i" 9527c3c9db83Smrg else 9528c3c9db83Smrg droppeddeps=yes 95293f6d0e1dSmrg echo 9530c3c9db83Smrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 95313f6d0e1dSmrg echo "*** I have the capability to make that library automatically link in when" 95323f6d0e1dSmrg echo "*** you link to this library. But I can only do this if you have a" 95333f6d0e1dSmrg echo "*** shared version of the library, which you do not appear to have" 95343f6d0e1dSmrg echo "*** because a test_compile did reveal that the linker did not use this one" 95353f6d0e1dSmrg echo "*** as a dynamic dependency that programs can get resolved with at runtime." 9536c3c9db83Smrg fi 9537c3c9db83Smrg fi 9538c3c9db83Smrg else 9539c3c9db83Smrg droppeddeps=yes 95403f6d0e1dSmrg echo 9541c3c9db83Smrg $ECHO "*** Warning! Library $i is needed by this library but I was not able to" 95423f6d0e1dSmrg echo "*** make it link in! You will probably need to install it or some" 95433f6d0e1dSmrg echo "*** library that it depends on before this library will be fully" 95443f6d0e1dSmrg echo "*** functional. Installing it before continuing would be even better." 9545c3c9db83Smrg fi 9546c3c9db83Smrg ;; 9547c3c9db83Smrg *) 95483f6d0e1dSmrg func_append newdeplibs " $i" 9549c3c9db83Smrg ;; 9550c3c9db83Smrg esac 9551c3c9db83Smrg done 9552c3c9db83Smrg fi 9553c3c9db83Smrg ;; 9554c3c9db83Smrg file_magic*) 9555c3c9db83Smrg set dummy $deplibs_check_method; shift 9556c3c9db83Smrg file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 9557c3c9db83Smrg for a_deplib in $deplibs; do 9558c3c9db83Smrg case $a_deplib in 9559c3c9db83Smrg -l*) 9560c3c9db83Smrg func_stripname -l '' "$a_deplib" 9561c3c9db83Smrg name=$func_stripname_result 95622f60eb46Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9563c3c9db83Smrg case " $predeps $postdeps " in 9564c3c9db83Smrg *" $a_deplib "*) 95653f6d0e1dSmrg func_append newdeplibs " $a_deplib" 95662f60eb46Smrg a_deplib= 9567c3c9db83Smrg ;; 9568c3c9db83Smrg esac 9569c3c9db83Smrg fi 95702f60eb46Smrg if test -n "$a_deplib"; then 9571c3c9db83Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 95723f6d0e1dSmrg if test -n "$file_magic_glob"; then 95733f6d0e1dSmrg libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob` 95743f6d0e1dSmrg else 95753f6d0e1dSmrg libnameglob=$libname 95763f6d0e1dSmrg fi 95772f60eb46Smrg test yes = "$want_nocaseglob" && nocaseglob=`shopt -p nocaseglob` 9578c3c9db83Smrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 95792f60eb46Smrg if test yes = "$want_nocaseglob"; then 95803f6d0e1dSmrg shopt -s nocaseglob 95813f6d0e1dSmrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 95823f6d0e1dSmrg $nocaseglob 95833f6d0e1dSmrg else 95843f6d0e1dSmrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 95853f6d0e1dSmrg fi 9586c3c9db83Smrg for potent_lib in $potential_libs; do 9587c3c9db83Smrg # Follow soft links. 9588c3c9db83Smrg if ls -lLd "$potent_lib" 2>/dev/null | 9589c3c9db83Smrg $GREP " -> " >/dev/null; then 9590c3c9db83Smrg continue 9591c3c9db83Smrg fi 9592c3c9db83Smrg # The statement above tries to avoid entering an 9593c3c9db83Smrg # endless loop below, in case of cyclic links. 9594c3c9db83Smrg # We might still enter an endless loop, since a link 9595c3c9db83Smrg # loop can be closed while we follow links, 9596c3c9db83Smrg # but so what? 95972f60eb46Smrg potlib=$potent_lib 9598c3c9db83Smrg while test -h "$potlib" 2>/dev/null; do 95992f60eb46Smrg potliblink=`ls -ld $potlib | $SED 's/.* -> //'` 9600c3c9db83Smrg case $potliblink in 96012f60eb46Smrg [\\/]* | [A-Za-z]:[\\/]*) potlib=$potliblink;; 96022f60eb46Smrg *) potlib=`$ECHO "$potlib" | $SED 's|[^/]*$||'`"$potliblink";; 9603c3c9db83Smrg esac 9604c3c9db83Smrg done 9605c3c9db83Smrg if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | 9606c3c9db83Smrg $SED -e 10q | 9607c3c9db83Smrg $EGREP "$file_magic_regex" > /dev/null; then 96083f6d0e1dSmrg func_append newdeplibs " $a_deplib" 96092f60eb46Smrg a_deplib= 9610c3c9db83Smrg break 2 9611c3c9db83Smrg fi 9612c3c9db83Smrg done 9613c3c9db83Smrg done 9614c3c9db83Smrg fi 96152f60eb46Smrg if test -n "$a_deplib"; then 9616c3c9db83Smrg droppeddeps=yes 96173f6d0e1dSmrg echo 9618c3c9db83Smrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 96193f6d0e1dSmrg echo "*** I have the capability to make that library automatically link in when" 96203f6d0e1dSmrg echo "*** you link to this library. But I can only do this if you have a" 96213f6d0e1dSmrg echo "*** shared version of the library, which you do not appear to have" 96223f6d0e1dSmrg echo "*** because I did check the linker path looking for a file starting" 96232f60eb46Smrg if test -z "$potlib"; then 9624c3c9db83Smrg $ECHO "*** with $libname but no candidates were found. (...for file magic test)" 9625c3c9db83Smrg else 9626c3c9db83Smrg $ECHO "*** with $libname and none of the candidates passed a file format test" 9627c3c9db83Smrg $ECHO "*** using a file magic. Last file checked: $potlib" 9628c3c9db83Smrg fi 9629c3c9db83Smrg fi 9630c3c9db83Smrg ;; 9631c3c9db83Smrg *) 9632c3c9db83Smrg # Add a -L argument. 96333f6d0e1dSmrg func_append newdeplibs " $a_deplib" 9634c3c9db83Smrg ;; 9635c3c9db83Smrg esac 9636c3c9db83Smrg done # Gone through all deplibs. 9637c3c9db83Smrg ;; 9638c3c9db83Smrg match_pattern*) 9639c3c9db83Smrg set dummy $deplibs_check_method; shift 9640c3c9db83Smrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 9641c3c9db83Smrg for a_deplib in $deplibs; do 9642c3c9db83Smrg case $a_deplib in 9643c3c9db83Smrg -l*) 9644c3c9db83Smrg func_stripname -l '' "$a_deplib" 9645c3c9db83Smrg name=$func_stripname_result 96462f60eb46Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9647c3c9db83Smrg case " $predeps $postdeps " in 9648c3c9db83Smrg *" $a_deplib "*) 96493f6d0e1dSmrg func_append newdeplibs " $a_deplib" 96502f60eb46Smrg a_deplib= 9651c3c9db83Smrg ;; 9652c3c9db83Smrg esac 9653c3c9db83Smrg fi 96542f60eb46Smrg if test -n "$a_deplib"; then 9655c3c9db83Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 9656c3c9db83Smrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 9657c3c9db83Smrg potential_libs=`ls $i/$libname[.-]* 2>/dev/null` 9658c3c9db83Smrg for potent_lib in $potential_libs; do 96592f60eb46Smrg potlib=$potent_lib # see symlink-check above in file_magic test 96603f6d0e1dSmrg if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ 9661c3c9db83Smrg $EGREP "$match_pattern_regex" > /dev/null; then 96623f6d0e1dSmrg func_append newdeplibs " $a_deplib" 96632f60eb46Smrg a_deplib= 9664c3c9db83Smrg break 2 9665c3c9db83Smrg fi 9666c3c9db83Smrg done 9667c3c9db83Smrg done 9668c3c9db83Smrg fi 96692f60eb46Smrg if test -n "$a_deplib"; then 9670c3c9db83Smrg droppeddeps=yes 96713f6d0e1dSmrg echo 9672c3c9db83Smrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 96733f6d0e1dSmrg echo "*** I have the capability to make that library automatically link in when" 96743f6d0e1dSmrg echo "*** you link to this library. But I can only do this if you have a" 96753f6d0e1dSmrg echo "*** shared version of the library, which you do not appear to have" 96763f6d0e1dSmrg echo "*** because I did check the linker path looking for a file starting" 96772f60eb46Smrg if test -z "$potlib"; then 9678c3c9db83Smrg $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" 9679c3c9db83Smrg else 9680c3c9db83Smrg $ECHO "*** with $libname and none of the candidates passed a file format test" 9681c3c9db83Smrg $ECHO "*** using a regex pattern. Last file checked: $potlib" 9682c3c9db83Smrg fi 9683c3c9db83Smrg fi 9684c3c9db83Smrg ;; 9685c3c9db83Smrg *) 9686c3c9db83Smrg # Add a -L argument. 96873f6d0e1dSmrg func_append newdeplibs " $a_deplib" 9688c3c9db83Smrg ;; 9689c3c9db83Smrg esac 9690c3c9db83Smrg done # Gone through all deplibs. 9691c3c9db83Smrg ;; 9692c3c9db83Smrg none | unknown | *) 96932f60eb46Smrg newdeplibs= 96943f6d0e1dSmrg tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` 96952f60eb46Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 96962f60eb46Smrg for i in $predeps $postdeps; do 9697c3c9db83Smrg # can't use Xsed below, because $i might contain '/' 96982f60eb46Smrg tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s|$i||"` 9699c3c9db83Smrg done 9700c3c9db83Smrg fi 97013f6d0e1dSmrg case $tmp_deplibs in 97023f6d0e1dSmrg *[!\ \ ]*) 97033f6d0e1dSmrg echo 97042f60eb46Smrg if test none = "$deplibs_check_method"; then 97053f6d0e1dSmrg echo "*** Warning: inter-library dependencies are not supported in this platform." 9706c3c9db83Smrg else 97073f6d0e1dSmrg echo "*** Warning: inter-library dependencies are not known to be supported." 9708c3c9db83Smrg fi 97093f6d0e1dSmrg echo "*** All declared inter-library dependencies are being dropped." 9710c3c9db83Smrg droppeddeps=yes 97113f6d0e1dSmrg ;; 97123f6d0e1dSmrg esac 9713c3c9db83Smrg ;; 9714c3c9db83Smrg esac 9715c3c9db83Smrg versuffix=$versuffix_save 9716c3c9db83Smrg major=$major_save 9717c3c9db83Smrg release=$release_save 9718c3c9db83Smrg libname=$libname_save 9719c3c9db83Smrg name=$name_save 9720c3c9db83Smrg 9721c3c9db83Smrg case $host in 9722c3c9db83Smrg *-*-rhapsody* | *-*-darwin1.[012]) 9723c3c9db83Smrg # On Rhapsody replace the C library with the System framework 97243f6d0e1dSmrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` 9725c3c9db83Smrg ;; 9726c3c9db83Smrg esac 9727c3c9db83Smrg 97282f60eb46Smrg if test yes = "$droppeddeps"; then 97292f60eb46Smrg if test yes = "$module"; then 97303f6d0e1dSmrg echo 97313f6d0e1dSmrg echo "*** Warning: libtool could not satisfy all declared inter-library" 9732c3c9db83Smrg $ECHO "*** dependencies of module $libname. Therefore, libtool will create" 97333f6d0e1dSmrg echo "*** a static module, that should work as long as the dlopening" 97343f6d0e1dSmrg echo "*** application is linked with the -dlopen flag." 9735c3c9db83Smrg if test -z "$global_symbol_pipe"; then 97363f6d0e1dSmrg echo 97373f6d0e1dSmrg echo "*** However, this would only work if libtool was able to extract symbol" 97382f60eb46Smrg echo "*** lists from a program, using 'nm' or equivalent, but libtool could" 97393f6d0e1dSmrg echo "*** not find such a program. So, this module is probably useless." 97402f60eb46Smrg echo "*** 'nm' from GNU binutils and a full rebuild may help." 9741c3c9db83Smrg fi 97422f60eb46Smrg if test no = "$build_old_libs"; then 97432f60eb46Smrg oldlibs=$output_objdir/$libname.$libext 9744c3c9db83Smrg build_libtool_libs=module 9745c3c9db83Smrg build_old_libs=yes 9746c3c9db83Smrg else 9747c3c9db83Smrg build_libtool_libs=no 9748c3c9db83Smrg fi 9749c3c9db83Smrg else 97503f6d0e1dSmrg echo "*** The inter-library dependencies that have been dropped here will be" 97513f6d0e1dSmrg echo "*** automatically added whenever a program is linked with this library" 97523f6d0e1dSmrg echo "*** or is declared to -dlopen it." 9753c3c9db83Smrg 97542f60eb46Smrg if test no = "$allow_undefined"; then 97553f6d0e1dSmrg echo 97563f6d0e1dSmrg echo "*** Since this library must not contain undefined symbols," 97573f6d0e1dSmrg echo "*** because either the platform does not support them or" 97583f6d0e1dSmrg echo "*** it was explicitly requested with -no-undefined," 97593f6d0e1dSmrg echo "*** libtool will only create a static version of it." 97602f60eb46Smrg if test no = "$build_old_libs"; then 97612f60eb46Smrg oldlibs=$output_objdir/$libname.$libext 9762c3c9db83Smrg build_libtool_libs=module 9763c3c9db83Smrg build_old_libs=yes 9764c3c9db83Smrg else 9765c3c9db83Smrg build_libtool_libs=no 9766c3c9db83Smrg fi 9767c3c9db83Smrg fi 9768c3c9db83Smrg fi 9769c3c9db83Smrg fi 9770c3c9db83Smrg # Done checking deplibs! 9771c3c9db83Smrg deplibs=$newdeplibs 9772c3c9db83Smrg fi 9773c3c9db83Smrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 9774c3c9db83Smrg case $host in 9775c3c9db83Smrg *-*-darwin*) 97763f6d0e1dSmrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 97773f6d0e1dSmrg new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 97783f6d0e1dSmrg deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 9779c3c9db83Smrg ;; 9780c3c9db83Smrg esac 9781c3c9db83Smrg 9782c3c9db83Smrg # move library search paths that coincide with paths to not yet 9783c3c9db83Smrg # installed libraries to the beginning of the library search list 9784c3c9db83Smrg new_libs= 9785c3c9db83Smrg for path in $notinst_path; do 9786c3c9db83Smrg case " $new_libs " in 9787c3c9db83Smrg *" -L$path/$objdir "*) ;; 9788c3c9db83Smrg *) 9789c3c9db83Smrg case " $deplibs " in 9790c3c9db83Smrg *" -L$path/$objdir "*) 97913f6d0e1dSmrg func_append new_libs " -L$path/$objdir" ;; 9792c3c9db83Smrg esac 9793c3c9db83Smrg ;; 9794c3c9db83Smrg esac 9795c3c9db83Smrg done 9796c3c9db83Smrg for deplib in $deplibs; do 9797c3c9db83Smrg case $deplib in 9798c3c9db83Smrg -L*) 9799c3c9db83Smrg case " $new_libs " in 9800c3c9db83Smrg *" $deplib "*) ;; 98013f6d0e1dSmrg *) func_append new_libs " $deplib" ;; 9802c3c9db83Smrg esac 9803c3c9db83Smrg ;; 98043f6d0e1dSmrg *) func_append new_libs " $deplib" ;; 9805c3c9db83Smrg esac 9806c3c9db83Smrg done 98072f60eb46Smrg deplibs=$new_libs 9808c3c9db83Smrg 9809c3c9db83Smrg # All the library-specific variables (install_libdir is set above). 9810c3c9db83Smrg library_names= 9811c3c9db83Smrg old_library= 9812c3c9db83Smrg dlname= 9813c3c9db83Smrg 9814c3c9db83Smrg # Test again, we may have decided not to build it any more 98152f60eb46Smrg if test yes = "$build_libtool_libs"; then 98162f60eb46Smrg # Remove $wl instances when linking with ld. 981795903e71Smrg # FIXME: should test the right _cmds variable. 981895903e71Smrg case $archive_cmds in 981995903e71Smrg *\$LD\ *) wl= ;; 982095903e71Smrg esac 98212f60eb46Smrg if test yes = "$hardcode_into_libs"; then 9822c3c9db83Smrg # Hardcode the library paths 9823c3c9db83Smrg hardcode_libdirs= 9824c3c9db83Smrg dep_rpath= 98252f60eb46Smrg rpath=$finalize_rpath 98262f60eb46Smrg test relink = "$opt_mode" || rpath=$compile_rpath$rpath 9827c3c9db83Smrg for libdir in $rpath; do 9828c3c9db83Smrg if test -n "$hardcode_libdir_flag_spec"; then 9829c3c9db83Smrg if test -n "$hardcode_libdir_separator"; then 98303f6d0e1dSmrg func_replace_sysroot "$libdir" 98313f6d0e1dSmrg libdir=$func_replace_sysroot_result 9832c3c9db83Smrg if test -z "$hardcode_libdirs"; then 98332f60eb46Smrg hardcode_libdirs=$libdir 9834c3c9db83Smrg else 9835c3c9db83Smrg # Just accumulate the unique libdirs. 9836c3c9db83Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 9837c3c9db83Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 9838c3c9db83Smrg ;; 9839c3c9db83Smrg *) 98403f6d0e1dSmrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 9841c3c9db83Smrg ;; 9842c3c9db83Smrg esac 9843c3c9db83Smrg fi 9844c3c9db83Smrg else 9845c3c9db83Smrg eval flag=\"$hardcode_libdir_flag_spec\" 98463f6d0e1dSmrg func_append dep_rpath " $flag" 9847c3c9db83Smrg fi 9848c3c9db83Smrg elif test -n "$runpath_var"; then 9849c3c9db83Smrg case "$perm_rpath " in 9850c3c9db83Smrg *" $libdir "*) ;; 985195903e71Smrg *) func_append perm_rpath " $libdir" ;; 9852c3c9db83Smrg esac 9853c3c9db83Smrg fi 9854c3c9db83Smrg done 9855c3c9db83Smrg # Substitute the hardcoded libdirs into the rpath. 9856c3c9db83Smrg if test -n "$hardcode_libdir_separator" && 9857c3c9db83Smrg test -n "$hardcode_libdirs"; then 98582f60eb46Smrg libdir=$hardcode_libdirs 985995903e71Smrg eval "dep_rpath=\"$hardcode_libdir_flag_spec\"" 9860c3c9db83Smrg fi 9861c3c9db83Smrg if test -n "$runpath_var" && test -n "$perm_rpath"; then 9862c3c9db83Smrg # We should set the runpath_var. 9863c3c9db83Smrg rpath= 9864c3c9db83Smrg for dir in $perm_rpath; do 98653f6d0e1dSmrg func_append rpath "$dir:" 9866c3c9db83Smrg done 9867c3c9db83Smrg eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" 9868c3c9db83Smrg fi 9869c3c9db83Smrg test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" 9870c3c9db83Smrg fi 9871692f60a7Smrg 98722f60eb46Smrg shlibpath=$finalize_shlibpath 98732f60eb46Smrg test relink = "$opt_mode" || shlibpath=$compile_shlibpath$shlibpath 9874c3c9db83Smrg if test -n "$shlibpath"; then 9875c3c9db83Smrg eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" 9876c3c9db83Smrg fi 9877692f60a7Smrg 9878c3c9db83Smrg # Get the real and link names of the library. 9879c3c9db83Smrg eval shared_ext=\"$shrext_cmds\" 9880c3c9db83Smrg eval library_names=\"$library_names_spec\" 9881c3c9db83Smrg set dummy $library_names 9882c3c9db83Smrg shift 98832f60eb46Smrg realname=$1 9884c3c9db83Smrg shift 9885692f60a7Smrg 9886c3c9db83Smrg if test -n "$soname_spec"; then 9887c3c9db83Smrg eval soname=\"$soname_spec\" 9888c3c9db83Smrg else 98892f60eb46Smrg soname=$realname 9890c3c9db83Smrg fi 9891c3c9db83Smrg if test -z "$dlname"; then 9892c3c9db83Smrg dlname=$soname 9893c3c9db83Smrg fi 9894692f60a7Smrg 98952f60eb46Smrg lib=$output_objdir/$realname 9896c3c9db83Smrg linknames= 9897c3c9db83Smrg for link 9898c3c9db83Smrg do 98993f6d0e1dSmrg func_append linknames " $link" 9900c3c9db83Smrg done 9901692f60a7Smrg 9902c3c9db83Smrg # Use standard objects if they are pic 99033f6d0e1dSmrg test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` 9904c3c9db83Smrg test "X$libobjs" = "X " && libobjs= 9905692f60a7Smrg 9906c3c9db83Smrg delfiles= 9907c3c9db83Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 9908c3c9db83Smrg $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" 99092f60eb46Smrg export_symbols=$output_objdir/$libname.uexp 99103f6d0e1dSmrg func_append delfiles " $export_symbols" 9911c3c9db83Smrg fi 9912692f60a7Smrg 9913c3c9db83Smrg orig_export_symbols= 9914c3c9db83Smrg case $host_os in 9915c3c9db83Smrg cygwin* | mingw* | cegcc*) 9916c3c9db83Smrg if test -n "$export_symbols" && test -z "$export_symbols_regex"; then 9917c3c9db83Smrg # exporting using user supplied symfile 99182f60eb46Smrg func_dll_def_p "$export_symbols" || { 9919c3c9db83Smrg # and it's NOT already a .def file. Must figure out 9920c3c9db83Smrg # which of the given symbols are data symbols and tag 9921c3c9db83Smrg # them as such. So, trigger use of export_symbols_cmds. 9922c3c9db83Smrg # export_symbols gets reassigned inside the "prepare 9923c3c9db83Smrg # the list of exported symbols" if statement, so the 9924c3c9db83Smrg # include_expsyms logic still works. 99252f60eb46Smrg orig_export_symbols=$export_symbols 9926c3c9db83Smrg export_symbols= 9927c3c9db83Smrg always_export_symbols=yes 99282f60eb46Smrg } 9929c3c9db83Smrg fi 9930c3c9db83Smrg ;; 9931c3c9db83Smrg esac 9932692f60a7Smrg 9933c3c9db83Smrg # Prepare the list of exported symbols 9934c3c9db83Smrg if test -z "$export_symbols"; then 99352f60eb46Smrg if test yes = "$always_export_symbols" || test -n "$export_symbols_regex"; then 99362f60eb46Smrg func_verbose "generating symbol list for '$libname.la'" 99372f60eb46Smrg export_symbols=$output_objdir/$libname.exp 9938c3c9db83Smrg $opt_dry_run || $RM $export_symbols 9939c3c9db83Smrg cmds=$export_symbols_cmds 99402f60eb46Smrg save_ifs=$IFS; IFS='~' 99413f6d0e1dSmrg for cmd1 in $cmds; do 99422f60eb46Smrg IFS=$save_ifs 99433f6d0e1dSmrg # Take the normal branch if the nm_file_list_spec branch 99443f6d0e1dSmrg # doesn't work or if tool conversion is not needed. 99453f6d0e1dSmrg case $nm_file_list_spec~$to_tool_file_cmd in 99463f6d0e1dSmrg *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) 99473f6d0e1dSmrg try_normal_branch=yes 99483f6d0e1dSmrg eval cmd=\"$cmd1\" 99493f6d0e1dSmrg func_len " $cmd" 99503f6d0e1dSmrg len=$func_len_result 99513f6d0e1dSmrg ;; 99523f6d0e1dSmrg *) 99533f6d0e1dSmrg try_normal_branch=no 99543f6d0e1dSmrg ;; 99553f6d0e1dSmrg esac 99562f60eb46Smrg if test yes = "$try_normal_branch" \ 99573f6d0e1dSmrg && { test "$len" -lt "$max_cmd_len" \ 99583f6d0e1dSmrg || test "$max_cmd_len" -le -1; } 99593f6d0e1dSmrg then 99603f6d0e1dSmrg func_show_eval "$cmd" 'exit $?' 99613f6d0e1dSmrg skipped_export=false 99623f6d0e1dSmrg elif test -n "$nm_file_list_spec"; then 99633f6d0e1dSmrg func_basename "$output" 99643f6d0e1dSmrg output_la=$func_basename_result 99653f6d0e1dSmrg save_libobjs=$libobjs 99663f6d0e1dSmrg save_output=$output 99672f60eb46Smrg output=$output_objdir/$output_la.nm 99683f6d0e1dSmrg func_to_tool_file "$output" 99693f6d0e1dSmrg libobjs=$nm_file_list_spec$func_to_tool_file_result 99703f6d0e1dSmrg func_append delfiles " $output" 99713f6d0e1dSmrg func_verbose "creating $NM input file list: $output" 99723f6d0e1dSmrg for obj in $save_libobjs; do 99733f6d0e1dSmrg func_to_tool_file "$obj" 99743f6d0e1dSmrg $ECHO "$func_to_tool_file_result" 99753f6d0e1dSmrg done > "$output" 99763f6d0e1dSmrg eval cmd=\"$cmd1\" 9977c3c9db83Smrg func_show_eval "$cmd" 'exit $?' 99783f6d0e1dSmrg output=$save_output 99793f6d0e1dSmrg libobjs=$save_libobjs 9980c3c9db83Smrg skipped_export=false 9981c3c9db83Smrg else 9982c3c9db83Smrg # The command line is too long to execute in one step. 9983c3c9db83Smrg func_verbose "using reloadable object file for export list..." 9984c3c9db83Smrg skipped_export=: 9985c3c9db83Smrg # Break out early, otherwise skipped_export may be 9986c3c9db83Smrg # set to false by a later but shorter cmd. 9987c3c9db83Smrg break 9988c3c9db83Smrg fi 9989c3c9db83Smrg done 99902f60eb46Smrg IFS=$save_ifs 99912f60eb46Smrg if test -n "$export_symbols_regex" && test : != "$skipped_export"; then 9992c3c9db83Smrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 9993c3c9db83Smrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 9994c3c9db83Smrg fi 9995c3c9db83Smrg fi 9996692f60a7Smrg fi 9997692f60a7Smrg 9998c3c9db83Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 99992f60eb46Smrg tmp_export_symbols=$export_symbols 100002f60eb46Smrg test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols 100013f6d0e1dSmrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 10002c3c9db83Smrg fi 10003692f60a7Smrg 100042f60eb46Smrg if test : != "$skipped_export" && test -n "$orig_export_symbols"; then 10005c3c9db83Smrg # The given exports_symbols file has to be filtered, so filter it. 100062f60eb46Smrg func_verbose "filter symbol list for '$libname.la' to tag DATA exports" 10007c3c9db83Smrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 100082f60eb46Smrg # 's' commands, which not all seds can handle. GNU sed should be fine 10009c3c9db83Smrg # though. Also, the filter scales superlinearly with the number of 10010c3c9db83Smrg # global variables. join(1) would be nice here, but unfortunately 10011c3c9db83Smrg # isn't a blessed tool. 10012c3c9db83Smrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 100133f6d0e1dSmrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 10014c3c9db83Smrg export_symbols=$output_objdir/$libname.def 10015c3c9db83Smrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 10016c3c9db83Smrg fi 10017692f60a7Smrg 10018c3c9db83Smrg tmp_deplibs= 10019c3c9db83Smrg for test_deplib in $deplibs; do 10020c3c9db83Smrg case " $convenience " in 10021c3c9db83Smrg *" $test_deplib "*) ;; 10022c3c9db83Smrg *) 100233f6d0e1dSmrg func_append tmp_deplibs " $test_deplib" 10024c3c9db83Smrg ;; 10025c3c9db83Smrg esac 10026c3c9db83Smrg done 100272f60eb46Smrg deplibs=$tmp_deplibs 10028692f60a7Smrg 10029c3c9db83Smrg if test -n "$convenience"; then 10030c3c9db83Smrg if test -n "$whole_archive_flag_spec" && 100312f60eb46Smrg test yes = "$compiler_needs_object" && 10032c3c9db83Smrg test -z "$libobjs"; then 10033c3c9db83Smrg # extract the archives, so we have objects to list. 10034c3c9db83Smrg # TODO: could optimize this to just extract one archive. 10035c3c9db83Smrg whole_archive_flag_spec= 10036c3c9db83Smrg fi 10037c3c9db83Smrg if test -n "$whole_archive_flag_spec"; then 10038c3c9db83Smrg save_libobjs=$libobjs 10039c3c9db83Smrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 10040c3c9db83Smrg test "X$libobjs" = "X " && libobjs= 10041c3c9db83Smrg else 100422f60eb46Smrg gentop=$output_objdir/${outputname}x 100433f6d0e1dSmrg func_append generated " $gentop" 10044692f60a7Smrg 10045c3c9db83Smrg func_extract_archives $gentop $convenience 100463f6d0e1dSmrg func_append libobjs " $func_extract_archives_result" 10047c3c9db83Smrg test "X$libobjs" = "X " && libobjs= 10048c3c9db83Smrg fi 100492e71ea71Smrg fi 10050692f60a7Smrg 100512f60eb46Smrg if test yes = "$thread_safe" && test -n "$thread_safe_flag_spec"; then 10052c3c9db83Smrg eval flag=\"$thread_safe_flag_spec\" 100533f6d0e1dSmrg func_append linker_flags " $flag" 100542e71ea71Smrg fi 1005585ee4c00Smrg 10056c3c9db83Smrg # Make a backup of the uninstalled library when relinking 100572f60eb46Smrg if test relink = "$opt_mode"; then 10058c3c9db83Smrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? 10059c3c9db83Smrg fi 10060692f60a7Smrg 10061c3c9db83Smrg # Do each of the archive commands. 100622f60eb46Smrg if test yes = "$module" && test -n "$module_cmds"; then 10063c3c9db83Smrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 10064c3c9db83Smrg eval test_cmds=\"$module_expsym_cmds\" 10065c3c9db83Smrg cmds=$module_expsym_cmds 10066c3c9db83Smrg else 10067c3c9db83Smrg eval test_cmds=\"$module_cmds\" 10068c3c9db83Smrg cmds=$module_cmds 10069c3c9db83Smrg fi 100702e71ea71Smrg else 10071c3c9db83Smrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 10072c3c9db83Smrg eval test_cmds=\"$archive_expsym_cmds\" 10073c3c9db83Smrg cmds=$archive_expsym_cmds 10074c3c9db83Smrg else 10075c3c9db83Smrg eval test_cmds=\"$archive_cmds\" 10076c3c9db83Smrg cmds=$archive_cmds 10077c3c9db83Smrg fi 100782e71ea71Smrg fi 10079692f60a7Smrg 100802f60eb46Smrg if test : != "$skipped_export" && 10081c3c9db83Smrg func_len " $test_cmds" && 10082c3c9db83Smrg len=$func_len_result && 10083c3c9db83Smrg test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 10084c3c9db83Smrg : 10085c3c9db83Smrg else 10086c3c9db83Smrg # The command line is too long to link in one step, link piecewise 10087c3c9db83Smrg # or, if using GNU ld and skipped_export is not :, use a linker 10088c3c9db83Smrg # script. 10089692f60a7Smrg 10090c3c9db83Smrg # Save the value of $output and $libobjs because we want to 10091c3c9db83Smrg # use them later. If we have whole_archive_flag_spec, we 10092c3c9db83Smrg # want to use save_libobjs as it was before 10093c3c9db83Smrg # whole_archive_flag_spec was expanded, because we can't 10094c3c9db83Smrg # assume the linker understands whole_archive_flag_spec. 10095c3c9db83Smrg # This may have to be revisited, in case too many 10096c3c9db83Smrg # convenience libraries get linked in and end up exceeding 10097c3c9db83Smrg # the spec. 10098c3c9db83Smrg if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then 10099c3c9db83Smrg save_libobjs=$libobjs 10100c3c9db83Smrg fi 10101c3c9db83Smrg save_output=$output 101023f6d0e1dSmrg func_basename "$output" 101033f6d0e1dSmrg output_la=$func_basename_result 10104692f60a7Smrg 10105c3c9db83Smrg # Clear the reloadable object creation command queue and 10106c3c9db83Smrg # initialize k to one. 10107c3c9db83Smrg test_cmds= 10108c3c9db83Smrg concat_cmds= 10109c3c9db83Smrg objlist= 10110c3c9db83Smrg last_robj= 10111c3c9db83Smrg k=1 10112c3c9db83Smrg 101132f60eb46Smrg if test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then 101142f60eb46Smrg output=$output_objdir/$output_la.lnkscript 10115c3c9db83Smrg func_verbose "creating GNU ld script: $output" 101163f6d0e1dSmrg echo 'INPUT (' > $output 10117c3c9db83Smrg for obj in $save_libobjs 101182e71ea71Smrg do 101193f6d0e1dSmrg func_to_tool_file "$obj" 101203f6d0e1dSmrg $ECHO "$func_to_tool_file_result" >> $output 10121c3c9db83Smrg done 101223f6d0e1dSmrg echo ')' >> $output 101233f6d0e1dSmrg func_append delfiles " $output" 101243f6d0e1dSmrg func_to_tool_file "$output" 101253f6d0e1dSmrg output=$func_to_tool_file_result 101262f60eb46Smrg elif test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then 101272f60eb46Smrg output=$output_objdir/$output_la.lnk 10128c3c9db83Smrg func_verbose "creating linker input file list: $output" 10129c3c9db83Smrg : > $output 10130c3c9db83Smrg set x $save_libobjs 10131c3c9db83Smrg shift 10132c3c9db83Smrg firstobj= 101332f60eb46Smrg if test yes = "$compiler_needs_object"; then 10134c3c9db83Smrg firstobj="$1 " 10135c3c9db83Smrg shift 10136c3c9db83Smrg fi 10137c3c9db83Smrg for obj 10138c3c9db83Smrg do 101393f6d0e1dSmrg func_to_tool_file "$obj" 101403f6d0e1dSmrg $ECHO "$func_to_tool_file_result" >> $output 10141c3c9db83Smrg done 101423f6d0e1dSmrg func_append delfiles " $output" 101433f6d0e1dSmrg func_to_tool_file "$output" 101443f6d0e1dSmrg output=$firstobj\"$file_list_spec$func_to_tool_file_result\" 10145c3c9db83Smrg else 10146c3c9db83Smrg if test -n "$save_libobjs"; then 10147c3c9db83Smrg func_verbose "creating reloadable object files..." 101482f60eb46Smrg output=$output_objdir/$output_la-$k.$objext 10149c3c9db83Smrg eval test_cmds=\"$reload_cmds\" 10150c3c9db83Smrg func_len " $test_cmds" 10151c3c9db83Smrg len0=$func_len_result 10152c3c9db83Smrg len=$len0 10153c3c9db83Smrg 10154c3c9db83Smrg # Loop over the list of objects to be linked. 10155c3c9db83Smrg for obj in $save_libobjs 10156c3c9db83Smrg do 10157c3c9db83Smrg func_len " $obj" 10158c3c9db83Smrg func_arith $len + $func_len_result 10159c3c9db83Smrg len=$func_arith_result 101602f60eb46Smrg if test -z "$objlist" || 10161c3c9db83Smrg test "$len" -lt "$max_cmd_len"; then 10162c3c9db83Smrg func_append objlist " $obj" 10163c3c9db83Smrg else 10164c3c9db83Smrg # The command $test_cmds is almost too long, add a 10165c3c9db83Smrg # command to the queue. 101662f60eb46Smrg if test 1 -eq "$k"; then 10167c3c9db83Smrg # The first file doesn't have a previous command to add. 101683f6d0e1dSmrg reload_objs=$objlist 101693f6d0e1dSmrg eval concat_cmds=\"$reload_cmds\" 10170c3c9db83Smrg else 10171c3c9db83Smrg # All subsequent reloadable object files will link in 10172c3c9db83Smrg # the last one created. 101733f6d0e1dSmrg reload_objs="$objlist $last_robj" 101743f6d0e1dSmrg eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" 10175c3c9db83Smrg fi 101762f60eb46Smrg last_robj=$output_objdir/$output_la-$k.$objext 10177c3c9db83Smrg func_arith $k + 1 10178c3c9db83Smrg k=$func_arith_result 101792f60eb46Smrg output=$output_objdir/$output_la-$k.$objext 101803f6d0e1dSmrg objlist=" $obj" 10181c3c9db83Smrg func_len " $last_robj" 10182c3c9db83Smrg func_arith $len0 + $func_len_result 10183c3c9db83Smrg len=$func_arith_result 10184c3c9db83Smrg fi 10185c3c9db83Smrg done 10186c3c9db83Smrg # Handle the remaining objects by creating one last 10187c3c9db83Smrg # reloadable object file. All subsequent reloadable object 10188c3c9db83Smrg # files will link in the last one created. 10189c3c9db83Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 101903f6d0e1dSmrg reload_objs="$objlist $last_robj" 101912f60eb46Smrg eval concat_cmds=\"\$concat_cmds$reload_cmds\" 10192c3c9db83Smrg if test -n "$last_robj"; then 101932f60eb46Smrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 10194c3c9db83Smrg fi 101953f6d0e1dSmrg func_append delfiles " $output" 10196692f60a7Smrg 10197c3c9db83Smrg else 10198c3c9db83Smrg output= 10199c3c9db83Smrg fi 10200692f60a7Smrg 102012f60eb46Smrg ${skipped_export-false} && { 102022f60eb46Smrg func_verbose "generating symbol list for '$libname.la'" 102032f60eb46Smrg export_symbols=$output_objdir/$libname.exp 10204c3c9db83Smrg $opt_dry_run || $RM $export_symbols 10205c3c9db83Smrg libobjs=$output 10206c3c9db83Smrg # Append the command to create the export file. 10207c3c9db83Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 10208c3c9db83Smrg eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" 10209c3c9db83Smrg if test -n "$last_robj"; then 10210c3c9db83Smrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 10211c3c9db83Smrg fi 102122f60eb46Smrg } 10213692f60a7Smrg 10214c3c9db83Smrg test -n "$save_libobjs" && 10215c3c9db83Smrg func_verbose "creating a temporary reloadable object file: $output" 10216692f60a7Smrg 10217c3c9db83Smrg # Loop through the commands generated above and execute them. 102182f60eb46Smrg save_ifs=$IFS; IFS='~' 10219c3c9db83Smrg for cmd in $concat_cmds; do 102202f60eb46Smrg IFS=$save_ifs 102212f60eb46Smrg $opt_quiet || { 10222efb46889Smrg func_quote_arg expand,pretty "$cmd" 10223efb46889Smrg eval "func_echo $func_quote_arg_result" 10224c3c9db83Smrg } 10225c3c9db83Smrg $opt_dry_run || eval "$cmd" || { 10226c3c9db83Smrg lt_exit=$? 10227c3c9db83Smrg 10228c3c9db83Smrg # Restore the uninstalled library and exit 102292f60eb46Smrg if test relink = "$opt_mode"; then 10230c3c9db83Smrg ( cd "$output_objdir" && \ 10231c3c9db83Smrg $RM "${realname}T" && \ 10232c3c9db83Smrg $MV "${realname}U" "$realname" ) 10233c3c9db83Smrg fi 10234692f60a7Smrg 10235c3c9db83Smrg exit $lt_exit 10236c3c9db83Smrg } 10237c3c9db83Smrg done 102382f60eb46Smrg IFS=$save_ifs 102392e71ea71Smrg 10240c3c9db83Smrg if test -n "$export_symbols_regex" && ${skipped_export-false}; then 10241c3c9db83Smrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 10242c3c9db83Smrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 10243692f60a7Smrg fi 10244692f60a7Smrg fi 10245692f60a7Smrg 102462f60eb46Smrg ${skipped_export-false} && { 10247c3c9db83Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 102482f60eb46Smrg tmp_export_symbols=$export_symbols 102492f60eb46Smrg test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols 102503f6d0e1dSmrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 10251c3c9db83Smrg fi 1025285ee4c00Smrg 10253c3c9db83Smrg if test -n "$orig_export_symbols"; then 10254c3c9db83Smrg # The given exports_symbols file has to be filtered, so filter it. 102552f60eb46Smrg func_verbose "filter symbol list for '$libname.la' to tag DATA exports" 10256c3c9db83Smrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 102572f60eb46Smrg # 's' commands, which not all seds can handle. GNU sed should be fine 10258c3c9db83Smrg # though. Also, the filter scales superlinearly with the number of 10259c3c9db83Smrg # global variables. join(1) would be nice here, but unfortunately 10260c3c9db83Smrg # isn't a blessed tool. 10261c3c9db83Smrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 102623f6d0e1dSmrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 10263c3c9db83Smrg export_symbols=$output_objdir/$libname.def 10264c3c9db83Smrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 10265c3c9db83Smrg fi 102662f60eb46Smrg } 10267692f60a7Smrg 10268c3c9db83Smrg libobjs=$output 10269c3c9db83Smrg # Restore the value of output. 10270c3c9db83Smrg output=$save_output 10271692f60a7Smrg 10272c3c9db83Smrg if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then 10273c3c9db83Smrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 10274c3c9db83Smrg test "X$libobjs" = "X " && libobjs= 10275c3c9db83Smrg fi 10276c3c9db83Smrg # Expand the library linking commands again to reset the 10277c3c9db83Smrg # value of $libobjs for piecewise linking. 10278692f60a7Smrg 10279c3c9db83Smrg # Do each of the archive commands. 102802f60eb46Smrg if test yes = "$module" && test -n "$module_cmds"; then 10281c3c9db83Smrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 10282c3c9db83Smrg cmds=$module_expsym_cmds 10283c3c9db83Smrg else 10284c3c9db83Smrg cmds=$module_cmds 102852e71ea71Smrg fi 102862e71ea71Smrg else 10287c3c9db83Smrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 10288c3c9db83Smrg cmds=$archive_expsym_cmds 10289c3c9db83Smrg else 10290c3c9db83Smrg cmds=$archive_cmds 10291c3c9db83Smrg fi 102922e71ea71Smrg fi 10293c3c9db83Smrg fi 10294692f60a7Smrg 10295c3c9db83Smrg if test -n "$delfiles"; then 10296c3c9db83Smrg # Append the command to remove temporary files to $cmds. 10297c3c9db83Smrg eval cmds=\"\$cmds~\$RM $delfiles\" 10298c3c9db83Smrg fi 10299692f60a7Smrg 10300c3c9db83Smrg # Add any objects from preloaded convenience libraries 10301c3c9db83Smrg if test -n "$dlprefiles"; then 103022f60eb46Smrg gentop=$output_objdir/${outputname}x 103033f6d0e1dSmrg func_append generated " $gentop" 10304692f60a7Smrg 10305c3c9db83Smrg func_extract_archives $gentop $dlprefiles 103063f6d0e1dSmrg func_append libobjs " $func_extract_archives_result" 10307c3c9db83Smrg test "X$libobjs" = "X " && libobjs= 10308c3c9db83Smrg fi 10309692f60a7Smrg 103102f60eb46Smrg save_ifs=$IFS; IFS='~' 10311c3c9db83Smrg for cmd in $cmds; do 103122f60eb46Smrg IFS=$sp$nl 10313c3c9db83Smrg eval cmd=\"$cmd\" 103142f60eb46Smrg IFS=$save_ifs 103152f60eb46Smrg $opt_quiet || { 10316efb46889Smrg func_quote_arg expand,pretty "$cmd" 10317efb46889Smrg eval "func_echo $func_quote_arg_result" 10318c3c9db83Smrg } 10319c3c9db83Smrg $opt_dry_run || eval "$cmd" || { 10320c3c9db83Smrg lt_exit=$? 1032185ee4c00Smrg 10322c3c9db83Smrg # Restore the uninstalled library and exit 103232f60eb46Smrg if test relink = "$opt_mode"; then 10324c3c9db83Smrg ( cd "$output_objdir" && \ 10325c3c9db83Smrg $RM "${realname}T" && \ 10326c3c9db83Smrg $MV "${realname}U" "$realname" ) 10327c3c9db83Smrg fi 1032885ee4c00Smrg 10329c3c9db83Smrg exit $lt_exit 10330c3c9db83Smrg } 10331c3c9db83Smrg done 103322f60eb46Smrg IFS=$save_ifs 1033385ee4c00Smrg 10334c3c9db83Smrg # Restore the uninstalled library and exit 103352f60eb46Smrg if test relink = "$opt_mode"; then 10336c3c9db83Smrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? 1033785ee4c00Smrg 10338c3c9db83Smrg if test -n "$convenience"; then 10339c3c9db83Smrg if test -z "$whole_archive_flag_spec"; then 10340c3c9db83Smrg func_show_eval '${RM}r "$gentop"' 10341c3c9db83Smrg fi 10342c3c9db83Smrg fi 1034385ee4c00Smrg 10344c3c9db83Smrg exit $EXIT_SUCCESS 10345c3c9db83Smrg fi 10346c3c9db83Smrg 10347c3c9db83Smrg # Create links to the real library. 10348c3c9db83Smrg for linkname in $linknames; do 10349c3c9db83Smrg if test "$realname" != "$linkname"; then 10350c3c9db83Smrg func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' 103512e71ea71Smrg fi 103522e71ea71Smrg done 1035385ee4c00Smrg 10354c3c9db83Smrg # If -module or -export-dynamic was specified, set the dlname. 103552f60eb46Smrg if test yes = "$module" || test yes = "$export_dynamic"; then 10356c3c9db83Smrg # On all known operating systems, these are identical. 103572f60eb46Smrg dlname=$soname 10358c3c9db83Smrg fi 10359c3c9db83Smrg fi 10360692f60a7Smrg ;; 10361692f60a7Smrg 10362c3c9db83Smrg obj) 103632f60eb46Smrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 103642f60eb46Smrg func_warning "'-dlopen' is ignored for objects" 10365c3c9db83Smrg fi 103662e71ea71Smrg 10367c3c9db83Smrg case " $deplibs" in 10368c3c9db83Smrg *\ -l* | *\ -L*) 103692f60eb46Smrg func_warning "'-l' and '-L' are ignored for objects" ;; 1037085ee4c00Smrg esac 10371692f60a7Smrg 10372c3c9db83Smrg test -n "$rpath" && \ 103732f60eb46Smrg func_warning "'-rpath' is ignored for objects" 10374c3c9db83Smrg 10375c3c9db83Smrg test -n "$xrpath" && \ 103762f60eb46Smrg func_warning "'-R' is ignored for objects" 10377692f60a7Smrg 10378c3c9db83Smrg test -n "$vinfo" && \ 103792f60eb46Smrg func_warning "'-version-info' is ignored for objects" 1038085ee4c00Smrg 10381c3c9db83Smrg test -n "$release" && \ 103822f60eb46Smrg func_warning "'-release' is ignored for objects" 10383c3c9db83Smrg 10384c3c9db83Smrg case $output in 10385c3c9db83Smrg *.lo) 10386c3c9db83Smrg test -n "$objs$old_deplibs" && \ 103872f60eb46Smrg func_fatal_error "cannot build library object '$output' from non-libtool objects" 10388c3c9db83Smrg 10389c3c9db83Smrg libobj=$output 10390c3c9db83Smrg func_lo2o "$libobj" 10391c3c9db83Smrg obj=$func_lo2o_result 103922e71ea71Smrg ;; 103932e71ea71Smrg *) 10394c3c9db83Smrg libobj= 103952f60eb46Smrg obj=$output 10396692f60a7Smrg ;; 1039785ee4c00Smrg esac 10398692f60a7Smrg 10399c3c9db83Smrg # Delete the old objects. 10400c3c9db83Smrg $opt_dry_run || $RM $obj $libobj 10401692f60a7Smrg 10402c3c9db83Smrg # Objects from convenience libraries. This assumes 10403c3c9db83Smrg # single-version convenience libraries. Whenever we create 10404c3c9db83Smrg # different ones for PIC/non-PIC, this we'll have to duplicate 10405c3c9db83Smrg # the extraction. 10406c3c9db83Smrg reload_conv_objs= 10407c3c9db83Smrg gentop= 104082f60eb46Smrg # if reload_cmds runs $LD directly, get rid of -Wl from 104092f60eb46Smrg # whole_archive_flag_spec and hope we can get by with turning comma 104102f60eb46Smrg # into space. 104112f60eb46Smrg case $reload_cmds in 104122f60eb46Smrg *\$LD[\ \$]*) wl= ;; 104132f60eb46Smrg esac 10414c3c9db83Smrg if test -n "$convenience"; then 10415c3c9db83Smrg if test -n "$whole_archive_flag_spec"; then 10416c3c9db83Smrg eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" 104172f60eb46Smrg test -n "$wl" || tmp_whole_archive_flags=`$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` 104182f60eb46Smrg reload_conv_objs=$reload_objs\ $tmp_whole_archive_flags 10419c3c9db83Smrg else 104202f60eb46Smrg gentop=$output_objdir/${obj}x 104213f6d0e1dSmrg func_append generated " $gentop" 104222e71ea71Smrg 10423c3c9db83Smrg func_extract_archives $gentop $convenience 10424c3c9db83Smrg reload_conv_objs="$reload_objs $func_extract_archives_result" 10425c3c9db83Smrg fi 104262e71ea71Smrg fi 104272e71ea71Smrg 104283f6d0e1dSmrg # If we're not building shared, we need to use non_pic_objs 104292f60eb46Smrg test yes = "$build_libtool_libs" || libobjs=$non_pic_objects 104303f6d0e1dSmrg 10431c3c9db83Smrg # Create the old-style object. 104322f60eb46Smrg reload_objs=$objs$old_deplibs' '`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; /\.lib$/d; $lo2o" | $NL2SP`' '$reload_conv_objs 104332e71ea71Smrg 104342f60eb46Smrg output=$obj 10435c3c9db83Smrg func_execute_cmds "$reload_cmds" 'exit $?' 104362e71ea71Smrg 10437c3c9db83Smrg # Exit if we aren't doing a library object file. 10438c3c9db83Smrg if test -z "$libobj"; then 10439c3c9db83Smrg if test -n "$gentop"; then 10440c3c9db83Smrg func_show_eval '${RM}r "$gentop"' 10441c3c9db83Smrg fi 10442c3c9db83Smrg 10443c3c9db83Smrg exit $EXIT_SUCCESS 104442e71ea71Smrg fi 10445c3c9db83Smrg 104462f60eb46Smrg test yes = "$build_libtool_libs" || { 10447c3c9db83Smrg if test -n "$gentop"; then 10448c3c9db83Smrg func_show_eval '${RM}r "$gentop"' 10449c3c9db83Smrg fi 10450c3c9db83Smrg 10451c3c9db83Smrg # Create an invalid libtool object if no PIC, so that we don't 10452c3c9db83Smrg # accidentally link it into a program. 10453c3c9db83Smrg # $show "echo timestamp > $libobj" 10454c3c9db83Smrg # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? 10455c3c9db83Smrg exit $EXIT_SUCCESS 104562f60eb46Smrg } 10457c3c9db83Smrg 104582f60eb46Smrg if test -n "$pic_flag" || test default != "$pic_mode"; then 10459c3c9db83Smrg # Only do commands if we really have different PIC objects. 10460c3c9db83Smrg reload_objs="$libobjs $reload_conv_objs" 104612f60eb46Smrg output=$libobj 10462c3c9db83Smrg func_execute_cmds "$reload_cmds" 'exit $?' 10463c3c9db83Smrg fi 10464c3c9db83Smrg 10465c3c9db83Smrg if test -n "$gentop"; then 10466c3c9db83Smrg func_show_eval '${RM}r "$gentop"' 10467c3c9db83Smrg fi 10468c3c9db83Smrg 10469c3c9db83Smrg exit $EXIT_SUCCESS 104702e71ea71Smrg ;; 10471692f60a7Smrg 10472c3c9db83Smrg prog) 10473c3c9db83Smrg case $host in 10474c3c9db83Smrg *cygwin*) func_stripname '' '.exe' "$output" 10475c3c9db83Smrg output=$func_stripname_result.exe;; 10476c3c9db83Smrg esac 10477c3c9db83Smrg test -n "$vinfo" && \ 104782f60eb46Smrg func_warning "'-version-info' is ignored for programs" 10479692f60a7Smrg 10480c3c9db83Smrg test -n "$release" && \ 104812f60eb46Smrg func_warning "'-release' is ignored for programs" 10482692f60a7Smrg 104832f60eb46Smrg $preload \ 104842f60eb46Smrg && test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \ 104852f60eb46Smrg && func_warning "'LT_INIT([dlopen])' not used. Assuming no dlopen support." 10486c3c9db83Smrg 10487c3c9db83Smrg case $host in 10488c3c9db83Smrg *-*-rhapsody* | *-*-darwin1.[012]) 10489c3c9db83Smrg # On Rhapsody replace the C library is the System framework 104903f6d0e1dSmrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` 104913f6d0e1dSmrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` 104922e71ea71Smrg ;; 10493c3c9db83Smrg esac 104942e71ea71Smrg 10495c3c9db83Smrg case $host in 10496c3c9db83Smrg *-*-darwin*) 10497c3c9db83Smrg # Don't allow lazy linking, it breaks C++ global constructors 10498c3c9db83Smrg # But is supposedly fixed on 10.4 or later (yay!). 104992f60eb46Smrg if test CXX = "$tagname"; then 10500c3c9db83Smrg case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 10501c3c9db83Smrg 10.[0123]) 105022f60eb46Smrg func_append compile_command " $wl-bind_at_load" 105032f60eb46Smrg func_append finalize_command " $wl-bind_at_load" 10504c3c9db83Smrg ;; 10505c3c9db83Smrg esac 105062e71ea71Smrg fi 10507c3c9db83Smrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 105083f6d0e1dSmrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 105093f6d0e1dSmrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 10510c3c9db83Smrg ;; 10511c3c9db83Smrg esac 105122e71ea71Smrg 105132e71ea71Smrg 10514c3c9db83Smrg # move library search paths that coincide with paths to not yet 10515c3c9db83Smrg # installed libraries to the beginning of the library search list 10516c3c9db83Smrg new_libs= 10517c3c9db83Smrg for path in $notinst_path; do 10518c3c9db83Smrg case " $new_libs " in 10519c3c9db83Smrg *" -L$path/$objdir "*) ;; 10520c3c9db83Smrg *) 10521c3c9db83Smrg case " $compile_deplibs " in 10522c3c9db83Smrg *" -L$path/$objdir "*) 105233f6d0e1dSmrg func_append new_libs " -L$path/$objdir" ;; 1052485ee4c00Smrg esac 10525c3c9db83Smrg ;; 10526c3c9db83Smrg esac 10527c3c9db83Smrg done 10528c3c9db83Smrg for deplib in $compile_deplibs; do 10529c3c9db83Smrg case $deplib in 10530c3c9db83Smrg -L*) 10531c3c9db83Smrg case " $new_libs " in 10532c3c9db83Smrg *" $deplib "*) ;; 105333f6d0e1dSmrg *) func_append new_libs " $deplib" ;; 1053485ee4c00Smrg esac 10535c3c9db83Smrg ;; 105363f6d0e1dSmrg *) func_append new_libs " $deplib" ;; 10537c3c9db83Smrg esac 10538c3c9db83Smrg done 105392f60eb46Smrg compile_deplibs=$new_libs 10540692f60a7Smrg 105412e71ea71Smrg 105423f6d0e1dSmrg func_append compile_command " $compile_deplibs" 105433f6d0e1dSmrg func_append finalize_command " $finalize_deplibs" 105442e71ea71Smrg 10545c3c9db83Smrg if test -n "$rpath$xrpath"; then 10546c3c9db83Smrg # If the user specified any rpath flags, then add them. 10547c3c9db83Smrg for libdir in $rpath $xrpath; do 10548c3c9db83Smrg # This is the magic to use -rpath. 10549c3c9db83Smrg case "$finalize_rpath " in 10550c3c9db83Smrg *" $libdir "*) ;; 105513f6d0e1dSmrg *) func_append finalize_rpath " $libdir" ;; 10552c3c9db83Smrg esac 10553c3c9db83Smrg done 10554c3c9db83Smrg fi 105552e71ea71Smrg 10556c3c9db83Smrg # Now hardcode the library paths 10557c3c9db83Smrg rpath= 10558c3c9db83Smrg hardcode_libdirs= 10559c3c9db83Smrg for libdir in $compile_rpath $finalize_rpath; do 10560c3c9db83Smrg if test -n "$hardcode_libdir_flag_spec"; then 10561c3c9db83Smrg if test -n "$hardcode_libdir_separator"; then 10562c3c9db83Smrg if test -z "$hardcode_libdirs"; then 105632f60eb46Smrg hardcode_libdirs=$libdir 10564c3c9db83Smrg else 10565c3c9db83Smrg # Just accumulate the unique libdirs. 10566c3c9db83Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 10567c3c9db83Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 10568c3c9db83Smrg ;; 10569c3c9db83Smrg *) 105703f6d0e1dSmrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 10571c3c9db83Smrg ;; 10572c3c9db83Smrg esac 10573c3c9db83Smrg fi 105742e71ea71Smrg else 10575c3c9db83Smrg eval flag=\"$hardcode_libdir_flag_spec\" 105763f6d0e1dSmrg func_append rpath " $flag" 105772e71ea71Smrg fi 10578c3c9db83Smrg elif test -n "$runpath_var"; then 10579c3c9db83Smrg case "$perm_rpath " in 10580c3c9db83Smrg *" $libdir "*) ;; 105813f6d0e1dSmrg *) func_append perm_rpath " $libdir" ;; 10582c3c9db83Smrg esac 10583c3c9db83Smrg fi 10584c3c9db83Smrg case $host in 10585c3c9db83Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 105862f60eb46Smrg testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'` 10587c3c9db83Smrg case :$dllsearchpath: in 10588c3c9db83Smrg *":$libdir:"*) ;; 10589c3c9db83Smrg ::) dllsearchpath=$libdir;; 105903f6d0e1dSmrg *) func_append dllsearchpath ":$libdir";; 10591c3c9db83Smrg esac 10592c3c9db83Smrg case :$dllsearchpath: in 10593c3c9db83Smrg *":$testbindir:"*) ;; 10594c3c9db83Smrg ::) dllsearchpath=$testbindir;; 105953f6d0e1dSmrg *) func_append dllsearchpath ":$testbindir";; 10596c3c9db83Smrg esac 10597c3c9db83Smrg ;; 10598c3c9db83Smrg esac 10599c3c9db83Smrg done 10600c3c9db83Smrg # Substitute the hardcoded libdirs into the rpath. 10601c3c9db83Smrg if test -n "$hardcode_libdir_separator" && 10602c3c9db83Smrg test -n "$hardcode_libdirs"; then 106032f60eb46Smrg libdir=$hardcode_libdirs 10604c3c9db83Smrg eval rpath=\" $hardcode_libdir_flag_spec\" 10605c3c9db83Smrg fi 106062f60eb46Smrg compile_rpath=$rpath 106072e71ea71Smrg 10608c3c9db83Smrg rpath= 10609c3c9db83Smrg hardcode_libdirs= 10610c3c9db83Smrg for libdir in $finalize_rpath; do 10611c3c9db83Smrg if test -n "$hardcode_libdir_flag_spec"; then 10612c3c9db83Smrg if test -n "$hardcode_libdir_separator"; then 10613c3c9db83Smrg if test -z "$hardcode_libdirs"; then 106142f60eb46Smrg hardcode_libdirs=$libdir 10615c3c9db83Smrg else 10616c3c9db83Smrg # Just accumulate the unique libdirs. 10617c3c9db83Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 10618c3c9db83Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 10619c3c9db83Smrg ;; 10620c3c9db83Smrg *) 106213f6d0e1dSmrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 10622c3c9db83Smrg ;; 10623c3c9db83Smrg esac 10624c3c9db83Smrg fi 10625692f60a7Smrg else 10626c3c9db83Smrg eval flag=\"$hardcode_libdir_flag_spec\" 106273f6d0e1dSmrg func_append rpath " $flag" 10628692f60a7Smrg fi 10629c3c9db83Smrg elif test -n "$runpath_var"; then 10630c3c9db83Smrg case "$finalize_perm_rpath " in 10631c3c9db83Smrg *" $libdir "*) ;; 106323f6d0e1dSmrg *) func_append finalize_perm_rpath " $libdir" ;; 10633c3c9db83Smrg esac 10634692f60a7Smrg fi 10635c3c9db83Smrg done 10636c3c9db83Smrg # Substitute the hardcoded libdirs into the rpath. 10637c3c9db83Smrg if test -n "$hardcode_libdir_separator" && 10638c3c9db83Smrg test -n "$hardcode_libdirs"; then 106392f60eb46Smrg libdir=$hardcode_libdirs 10640c3c9db83Smrg eval rpath=\" $hardcode_libdir_flag_spec\" 10641c3c9db83Smrg fi 106422f60eb46Smrg finalize_rpath=$rpath 10643692f60a7Smrg 106442f60eb46Smrg if test -n "$libobjs" && test yes = "$build_old_libs"; then 10645c3c9db83Smrg # Transform all the library objects into standard objects. 106463f6d0e1dSmrg compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 106473f6d0e1dSmrg finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 10648c3c9db83Smrg fi 10649692f60a7Smrg 106502f60eb46Smrg func_generate_dlsyms "$outputname" "@PROGRAM@" false 10651692f60a7Smrg 10652c3c9db83Smrg # template prelinking step 10653c3c9db83Smrg if test -n "$prelink_cmds"; then 10654c3c9db83Smrg func_execute_cmds "$prelink_cmds" 'exit $?' 10655c3c9db83Smrg fi 10656692f60a7Smrg 106572f60eb46Smrg wrappers_required=: 10658c3c9db83Smrg case $host in 106593f6d0e1dSmrg *cegcc* | *mingw32ce*) 106603f6d0e1dSmrg # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. 106612f60eb46Smrg wrappers_required=false 106623f6d0e1dSmrg ;; 10663c3c9db83Smrg *cygwin* | *mingw* ) 106642f60eb46Smrg test yes = "$build_libtool_libs" || wrappers_required=false 10665c3c9db83Smrg ;; 10666c3c9db83Smrg *) 106672f60eb46Smrg if test no = "$need_relink" || test yes != "$build_libtool_libs"; then 106682f60eb46Smrg wrappers_required=false 10669c3c9db83Smrg fi 10670c3c9db83Smrg ;; 10671c3c9db83Smrg esac 106722f60eb46Smrg $wrappers_required || { 10673c3c9db83Smrg # Replace the output file specification. 106743f6d0e1dSmrg compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 106752f60eb46Smrg link_command=$compile_command$compile_rpath 10676692f60a7Smrg 10677c3c9db83Smrg # We have no uninstalled library dependencies, so finalize right now. 10678c3c9db83Smrg exit_status=0 10679c3c9db83Smrg func_show_eval "$link_command" 'exit_status=$?' 10680692f60a7Smrg 106813f6d0e1dSmrg if test -n "$postlink_cmds"; then 106823f6d0e1dSmrg func_to_tool_file "$output" 106833f6d0e1dSmrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 106843f6d0e1dSmrg func_execute_cmds "$postlink_cmds" 'exit $?' 106853f6d0e1dSmrg fi 106863f6d0e1dSmrg 10687c3c9db83Smrg # Delete the generated files. 106882f60eb46Smrg if test -f "$output_objdir/${outputname}S.$objext"; then 106892f60eb46Smrg func_show_eval '$RM "$output_objdir/${outputname}S.$objext"' 10690692f60a7Smrg fi 10691692f60a7Smrg 10692c3c9db83Smrg exit $exit_status 106932f60eb46Smrg } 10694692f60a7Smrg 10695c3c9db83Smrg if test -n "$compile_shlibpath$finalize_shlibpath"; then 10696c3c9db83Smrg compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" 10697c3c9db83Smrg fi 10698c3c9db83Smrg if test -n "$finalize_shlibpath"; then 10699c3c9db83Smrg finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" 10700c3c9db83Smrg fi 107012e71ea71Smrg 10702c3c9db83Smrg compile_var= 10703c3c9db83Smrg finalize_var= 10704c3c9db83Smrg if test -n "$runpath_var"; then 10705c3c9db83Smrg if test -n "$perm_rpath"; then 10706c3c9db83Smrg # We should set the runpath_var. 10707c3c9db83Smrg rpath= 10708c3c9db83Smrg for dir in $perm_rpath; do 107093f6d0e1dSmrg func_append rpath "$dir:" 10710c3c9db83Smrg done 10711c3c9db83Smrg compile_var="$runpath_var=\"$rpath\$$runpath_var\" " 10712692f60a7Smrg fi 10713c3c9db83Smrg if test -n "$finalize_perm_rpath"; then 10714c3c9db83Smrg # We should set the runpath_var. 10715c3c9db83Smrg rpath= 10716c3c9db83Smrg for dir in $finalize_perm_rpath; do 107173f6d0e1dSmrg func_append rpath "$dir:" 10718c3c9db83Smrg done 10719c3c9db83Smrg finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " 10720692f60a7Smrg fi 10721c3c9db83Smrg fi 10722692f60a7Smrg 107232f60eb46Smrg if test yes = "$no_install"; then 10724c3c9db83Smrg # We don't need to create a wrapper script. 107252f60eb46Smrg link_command=$compile_var$compile_command$compile_rpath 10726c3c9db83Smrg # Replace the output file specification. 107273f6d0e1dSmrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 10728c3c9db83Smrg # Delete the old output file. 10729c3c9db83Smrg $opt_dry_run || $RM $output 10730c3c9db83Smrg # Link the executable and exit 10731c3c9db83Smrg func_show_eval "$link_command" 'exit $?' 107323f6d0e1dSmrg 107333f6d0e1dSmrg if test -n "$postlink_cmds"; then 107343f6d0e1dSmrg func_to_tool_file "$output" 107353f6d0e1dSmrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 107363f6d0e1dSmrg func_execute_cmds "$postlink_cmds" 'exit $?' 107373f6d0e1dSmrg fi 107383f6d0e1dSmrg 107392e71ea71Smrg exit $EXIT_SUCCESS 10740c3c9db83Smrg fi 1074185ee4c00Smrg 107422f60eb46Smrg case $hardcode_action,$fast_install in 107432f60eb46Smrg relink,*) 107442f60eb46Smrg # Fast installation is not supported 107452f60eb46Smrg link_command=$compile_var$compile_command$compile_rpath 107462f60eb46Smrg relink_command=$finalize_var$finalize_command$finalize_rpath 10747c3c9db83Smrg 107482f60eb46Smrg func_warning "this platform does not like uninstalled shared libraries" 107492f60eb46Smrg func_warning "'$output' will be relinked during installation" 107502f60eb46Smrg ;; 107512f60eb46Smrg *,yes) 107522f60eb46Smrg link_command=$finalize_var$compile_command$finalize_rpath 107532f60eb46Smrg relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` 107542f60eb46Smrg ;; 107552f60eb46Smrg *,no) 107562f60eb46Smrg link_command=$compile_var$compile_command$compile_rpath 107572f60eb46Smrg relink_command=$finalize_var$finalize_command$finalize_rpath 107582f60eb46Smrg ;; 107592f60eb46Smrg *,needless) 107602f60eb46Smrg link_command=$finalize_var$compile_command$finalize_rpath 107612f60eb46Smrg relink_command= 107622f60eb46Smrg ;; 107632f60eb46Smrg esac 10764692f60a7Smrg 10765c3c9db83Smrg # Replace the output file specification. 107663f6d0e1dSmrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` 10767692f60a7Smrg 10768c3c9db83Smrg # Delete the old output files. 10769c3c9db83Smrg $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname 10770692f60a7Smrg 10771c3c9db83Smrg func_show_eval "$link_command" 'exit $?' 107722e71ea71Smrg 107733f6d0e1dSmrg if test -n "$postlink_cmds"; then 107743f6d0e1dSmrg func_to_tool_file "$output_objdir/$outputname" 107753f6d0e1dSmrg 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'` 107763f6d0e1dSmrg func_execute_cmds "$postlink_cmds" 'exit $?' 107773f6d0e1dSmrg fi 107783f6d0e1dSmrg 10779c3c9db83Smrg # Now create the wrapper script. 10780c3c9db83Smrg func_verbose "creating $output" 107812e71ea71Smrg 10782c3c9db83Smrg # Quote the relink command for shipping. 10783c3c9db83Smrg if test -n "$relink_command"; then 10784c3c9db83Smrg # Preserve any variables that may affect compiler behavior 10785c3c9db83Smrg for var in $variables_saved_for_relink; do 10786c3c9db83Smrg if eval test -z \"\${$var+set}\"; then 10787c3c9db83Smrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 10788c3c9db83Smrg elif eval var_value=\$$var; test -z "$var_value"; then 10789c3c9db83Smrg relink_command="$var=; export $var; $relink_command" 10790692f60a7Smrg else 10791efb46889Smrg func_quote_arg pretty "$var_value" 10792efb46889Smrg relink_command="$var=$func_quote_arg_result; export $var; $relink_command" 10793692f60a7Smrg fi 10794c3c9db83Smrg done 10795efb46889Smrg func_quote eval cd "`pwd`" 10796efb46889Smrg func_quote_arg pretty,unquoted "($func_quote_result; $relink_command)" 10797efb46889Smrg relink_command=$func_quote_arg_unquoted_result 10798c3c9db83Smrg fi 10799c3c9db83Smrg 10800c3c9db83Smrg # Only actually do things if not in dry run mode. 10801c3c9db83Smrg $opt_dry_run || { 10802c3c9db83Smrg # win32 will think the script is a binary if it has 10803c3c9db83Smrg # a .exe suffix, so we strip it off here. 10804c3c9db83Smrg case $output in 10805c3c9db83Smrg *.exe) func_stripname '' '.exe' "$output" 10806c3c9db83Smrg output=$func_stripname_result ;; 10807c3c9db83Smrg esac 10808c3c9db83Smrg # test for cygwin because mv fails w/o .exe extensions 10809c3c9db83Smrg case $host in 10810c3c9db83Smrg *cygwin*) 10811c3c9db83Smrg exeext=.exe 10812c3c9db83Smrg func_stripname '' '.exe' "$outputname" 10813c3c9db83Smrg outputname=$func_stripname_result ;; 10814c3c9db83Smrg *) exeext= ;; 10815692f60a7Smrg esac 10816c3c9db83Smrg case $host in 10817c3c9db83Smrg *cygwin* | *mingw* ) 10818c3c9db83Smrg func_dirname_and_basename "$output" "" "." 10819c3c9db83Smrg output_name=$func_basename_result 10820c3c9db83Smrg output_path=$func_dirname_result 108212f60eb46Smrg cwrappersource=$output_path/$objdir/lt-$output_name.c 108222f60eb46Smrg cwrapper=$output_path/$output_name.exe 10823c3c9db83Smrg $RM $cwrappersource $cwrapper 10824c3c9db83Smrg trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 10825c3c9db83Smrg 10826c3c9db83Smrg func_emit_cwrapperexe_src > $cwrappersource 10827c3c9db83Smrg 10828c3c9db83Smrg # The wrapper executable is built using the $host compiler, 10829c3c9db83Smrg # because it contains $host paths and files. If cross- 10830c3c9db83Smrg # compiling, it, like the target executable, must be 10831c3c9db83Smrg # executed on the $host or under an emulation environment. 10832c3c9db83Smrg $opt_dry_run || { 10833c3c9db83Smrg $LTCC $LTCFLAGS -o $cwrapper $cwrappersource 10834c3c9db83Smrg $STRIP $cwrapper 10835c3c9db83Smrg } 10836692f60a7Smrg 10837c3c9db83Smrg # Now, create the wrapper script for func_source use: 10838c3c9db83Smrg func_ltwrapper_scriptname $cwrapper 10839c3c9db83Smrg $RM $func_ltwrapper_scriptname_result 10840c3c9db83Smrg trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 10841c3c9db83Smrg $opt_dry_run || { 10842c3c9db83Smrg # note: this script will not be executed, so do not chmod. 108432f60eb46Smrg if test "x$build" = "x$host"; then 10844c3c9db83Smrg $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result 10845c3c9db83Smrg else 10846c3c9db83Smrg func_emit_wrapper no > $func_ltwrapper_scriptname_result 10847c3c9db83Smrg fi 10848c3c9db83Smrg } 10849c3c9db83Smrg ;; 10850c3c9db83Smrg * ) 10851c3c9db83Smrg $RM $output 10852c3c9db83Smrg trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 10853692f60a7Smrg 10854c3c9db83Smrg func_emit_wrapper no > $output 10855c3c9db83Smrg chmod +x $output 10856c3c9db83Smrg ;; 10857c3c9db83Smrg esac 10858c3c9db83Smrg } 10859c3c9db83Smrg exit $EXIT_SUCCESS 10860c3c9db83Smrg ;; 10861c3c9db83Smrg esac 10862692f60a7Smrg 10863c3c9db83Smrg # See if we need to build an old-fashioned archive. 10864c3c9db83Smrg for oldlib in $oldlibs; do 10865692f60a7Smrg 108662f60eb46Smrg case $build_libtool_libs in 108672f60eb46Smrg convenience) 108682f60eb46Smrg oldobjs="$libobjs_save $symfileobj" 108692f60eb46Smrg addlibs=$convenience 10870c3c9db83Smrg build_libtool_libs=no 108712f60eb46Smrg ;; 108722f60eb46Smrg module) 108732f60eb46Smrg oldobjs=$libobjs_save 108742f60eb46Smrg addlibs=$old_convenience 108752f60eb46Smrg build_libtool_libs=no 108762f60eb46Smrg ;; 108772f60eb46Smrg *) 10878c3c9db83Smrg oldobjs="$old_deplibs $non_pic_objects" 108792f60eb46Smrg $preload && test -f "$symfileobj" \ 108802f60eb46Smrg && func_append oldobjs " $symfileobj" 108812f60eb46Smrg addlibs=$old_convenience 108822f60eb46Smrg ;; 108832f60eb46Smrg esac 10884692f60a7Smrg 10885c3c9db83Smrg if test -n "$addlibs"; then 108862f60eb46Smrg gentop=$output_objdir/${outputname}x 108873f6d0e1dSmrg func_append generated " $gentop" 10888692f60a7Smrg 10889c3c9db83Smrg func_extract_archives $gentop $addlibs 108903f6d0e1dSmrg func_append oldobjs " $func_extract_archives_result" 10891c3c9db83Smrg fi 10892692f60a7Smrg 10893c3c9db83Smrg # Do each command in the archive commands. 108942f60eb46Smrg if test -n "$old_archive_from_new_cmds" && test yes = "$build_libtool_libs"; then 10895c3c9db83Smrg cmds=$old_archive_from_new_cmds 10896c3c9db83Smrg else 10897692f60a7Smrg 10898c3c9db83Smrg # Add any objects from preloaded convenience libraries 10899c3c9db83Smrg if test -n "$dlprefiles"; then 109002f60eb46Smrg gentop=$output_objdir/${outputname}x 109013f6d0e1dSmrg func_append generated " $gentop" 10902692f60a7Smrg 10903c3c9db83Smrg func_extract_archives $gentop $dlprefiles 109043f6d0e1dSmrg func_append oldobjs " $func_extract_archives_result" 10905c3c9db83Smrg fi 10906692f60a7Smrg 10907c3c9db83Smrg # POSIX demands no paths to be encoded in archives. We have 10908c3c9db83Smrg # to avoid creating archives with duplicate basenames if we 10909c3c9db83Smrg # might have to extract them afterwards, e.g., when creating a 10910c3c9db83Smrg # static archive out of a convenience library, or when linking 10911c3c9db83Smrg # the entirety of a libtool archive into another (currently 10912c3c9db83Smrg # not supported by libtool). 10913c3c9db83Smrg if (for obj in $oldobjs 10914c3c9db83Smrg do 10915c3c9db83Smrg func_basename "$obj" 10916c3c9db83Smrg $ECHO "$func_basename_result" 10917c3c9db83Smrg done | sort | sort -uc >/dev/null 2>&1); then 10918c3c9db83Smrg : 10919c3c9db83Smrg else 109203f6d0e1dSmrg echo "copying selected object files to avoid basename conflicts..." 109212f60eb46Smrg gentop=$output_objdir/${outputname}x 109223f6d0e1dSmrg func_append generated " $gentop" 10923c3c9db83Smrg func_mkdir_p "$gentop" 10924c3c9db83Smrg save_oldobjs=$oldobjs 10925c3c9db83Smrg oldobjs= 10926c3c9db83Smrg counter=1 10927c3c9db83Smrg for obj in $save_oldobjs 10928c3c9db83Smrg do 10929c3c9db83Smrg func_basename "$obj" 109302f60eb46Smrg objbase=$func_basename_result 10931c3c9db83Smrg case " $oldobjs " in 10932c3c9db83Smrg " ") oldobjs=$obj ;; 10933c3c9db83Smrg *[\ /]"$objbase "*) 10934c3c9db83Smrg while :; do 10935c3c9db83Smrg # Make sure we don't pick an alternate name that also 10936c3c9db83Smrg # overlaps. 10937c3c9db83Smrg newobj=lt$counter-$objbase 10938c3c9db83Smrg func_arith $counter + 1 10939c3c9db83Smrg counter=$func_arith_result 10940c3c9db83Smrg case " $oldobjs " in 10941c3c9db83Smrg *[\ /]"$newobj "*) ;; 10942c3c9db83Smrg *) if test ! -f "$gentop/$newobj"; then break; fi ;; 10943c3c9db83Smrg esac 10944c3c9db83Smrg done 10945c3c9db83Smrg func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" 109463f6d0e1dSmrg func_append oldobjs " $gentop/$newobj" 10947c3c9db83Smrg ;; 109483f6d0e1dSmrg *) func_append oldobjs " $obj" ;; 10949c3c9db83Smrg esac 10950692f60a7Smrg done 1095185ee4c00Smrg fi 1095295903e71Smrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 1095395903e71Smrg tool_oldlib=$func_to_tool_file_result 10954c3c9db83Smrg eval cmds=\"$old_archive_cmds\" 109552e71ea71Smrg 10956c3c9db83Smrg func_len " $cmds" 10957c3c9db83Smrg len=$func_len_result 10958c3c9db83Smrg if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 10959c3c9db83Smrg cmds=$old_archive_cmds 109603f6d0e1dSmrg elif test -n "$archiver_list_spec"; then 109613f6d0e1dSmrg func_verbose "using command file archive linking..." 109623f6d0e1dSmrg for obj in $oldobjs 109633f6d0e1dSmrg do 109643f6d0e1dSmrg func_to_tool_file "$obj" 109653f6d0e1dSmrg $ECHO "$func_to_tool_file_result" 109663f6d0e1dSmrg done > $output_objdir/$libname.libcmd 109673f6d0e1dSmrg func_to_tool_file "$output_objdir/$libname.libcmd" 109683f6d0e1dSmrg oldobjs=" $archiver_list_spec$func_to_tool_file_result" 109693f6d0e1dSmrg cmds=$old_archive_cmds 10970c3c9db83Smrg else 10971c3c9db83Smrg # the command line is too long to link in one step, link in parts 10972c3c9db83Smrg func_verbose "using piecewise archive linking..." 10973c3c9db83Smrg save_RANLIB=$RANLIB 10974c3c9db83Smrg RANLIB=: 10975c3c9db83Smrg objlist= 10976c3c9db83Smrg concat_cmds= 10977c3c9db83Smrg save_oldobjs=$oldobjs 10978c3c9db83Smrg oldobjs= 10979c3c9db83Smrg # Is there a better way of finding the last object in the list? 10980c3c9db83Smrg for obj in $save_oldobjs 10981c3c9db83Smrg do 10982c3c9db83Smrg last_oldobj=$obj 10983c3c9db83Smrg done 10984c3c9db83Smrg eval test_cmds=\"$old_archive_cmds\" 10985c3c9db83Smrg func_len " $test_cmds" 10986c3c9db83Smrg len0=$func_len_result 10987c3c9db83Smrg len=$len0 10988c3c9db83Smrg for obj in $save_oldobjs 10989c3c9db83Smrg do 10990c3c9db83Smrg func_len " $obj" 10991c3c9db83Smrg func_arith $len + $func_len_result 10992c3c9db83Smrg len=$func_arith_result 10993c3c9db83Smrg func_append objlist " $obj" 10994c3c9db83Smrg if test "$len" -lt "$max_cmd_len"; then 10995c3c9db83Smrg : 10996c3c9db83Smrg else 10997c3c9db83Smrg # the above command should be used before it gets too long 10998c3c9db83Smrg oldobjs=$objlist 109992f60eb46Smrg if test "$obj" = "$last_oldobj"; then 11000c3c9db83Smrg RANLIB=$save_RANLIB 11001c3c9db83Smrg fi 11002c3c9db83Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 110032f60eb46Smrg eval concat_cmds=\"\$concat_cmds$old_archive_cmds\" 11004c3c9db83Smrg objlist= 11005c3c9db83Smrg len=$len0 11006c3c9db83Smrg fi 11007c3c9db83Smrg done 11008c3c9db83Smrg RANLIB=$save_RANLIB 11009c3c9db83Smrg oldobjs=$objlist 110102f60eb46Smrg if test -z "$oldobjs"; then 11011c3c9db83Smrg eval cmds=\"\$concat_cmds\" 11012c3c9db83Smrg else 11013c3c9db83Smrg eval cmds=\"\$concat_cmds~\$old_archive_cmds\" 11014c3c9db83Smrg fi 11015c3c9db83Smrg fi 11016c3c9db83Smrg fi 11017c3c9db83Smrg func_execute_cmds "$cmds" 'exit $?' 11018692f60a7Smrg done 11019692f60a7Smrg 11020c3c9db83Smrg test -n "$generated" && \ 11021c3c9db83Smrg func_show_eval "${RM}r$generated" 11022692f60a7Smrg 11023c3c9db83Smrg # Now create the libtool archive. 11024c3c9db83Smrg case $output in 11025c3c9db83Smrg *.la) 11026c3c9db83Smrg old_library= 110272f60eb46Smrg test yes = "$build_old_libs" && old_library=$libname.$libext 11028c3c9db83Smrg func_verbose "creating $output" 1102985ee4c00Smrg 11030c3c9db83Smrg # Preserve any variables that may affect compiler behavior 11031c3c9db83Smrg for var in $variables_saved_for_relink; do 11032c3c9db83Smrg if eval test -z \"\${$var+set}\"; then 11033c3c9db83Smrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 11034c3c9db83Smrg elif eval var_value=\$$var; test -z "$var_value"; then 11035c3c9db83Smrg relink_command="$var=; export $var; $relink_command" 110362e71ea71Smrg else 11037efb46889Smrg func_quote_arg pretty,unquoted "$var_value" 11038efb46889Smrg relink_command="$var=$func_quote_arg_unquoted_result; export $var; $relink_command" 110392e71ea71Smrg fi 11040c3c9db83Smrg done 11041c3c9db83Smrg # Quote the link command for shipping. 11042efb46889Smrg func_quote eval cd "`pwd`" 11043efb46889Smrg relink_command="($func_quote_result; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" 11044efb46889Smrg func_quote_arg pretty,unquoted "$relink_command" 11045efb46889Smrg relink_command=$func_quote_arg_unquoted_result 110462f60eb46Smrg if test yes = "$hardcode_automatic"; then 11047c3c9db83Smrg relink_command= 11048c3c9db83Smrg fi 11049692f60a7Smrg 11050c3c9db83Smrg # Only create the output if not a dry run. 11051c3c9db83Smrg $opt_dry_run || { 11052c3c9db83Smrg for installed in no yes; do 110532f60eb46Smrg if test yes = "$installed"; then 11054c3c9db83Smrg if test -z "$install_libdir"; then 11055c3c9db83Smrg break 11056c3c9db83Smrg fi 110572f60eb46Smrg output=$output_objdir/${outputname}i 11058c3c9db83Smrg # Replace all uninstalled libtool libraries with the installed ones 11059c3c9db83Smrg newdependency_libs= 11060c3c9db83Smrg for deplib in $dependency_libs; do 11061c3c9db83Smrg case $deplib in 11062c3c9db83Smrg *.la) 11063c3c9db83Smrg func_basename "$deplib" 110642f60eb46Smrg name=$func_basename_result 1106595903e71Smrg func_resolve_sysroot "$deplib" 110662f60eb46Smrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` 11067c3c9db83Smrg test -z "$libdir" && \ 110682f60eb46Smrg func_fatal_error "'$deplib' is not a valid libtool archive" 110693f6d0e1dSmrg func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" 110703f6d0e1dSmrg ;; 110713f6d0e1dSmrg -L*) 110723f6d0e1dSmrg func_stripname -L '' "$deplib" 110733f6d0e1dSmrg func_replace_sysroot "$func_stripname_result" 110743f6d0e1dSmrg func_append newdependency_libs " -L$func_replace_sysroot_result" 11075c3c9db83Smrg ;; 110763f6d0e1dSmrg -R*) 110773f6d0e1dSmrg func_stripname -R '' "$deplib" 110783f6d0e1dSmrg func_replace_sysroot "$func_stripname_result" 110793f6d0e1dSmrg func_append newdependency_libs " -R$func_replace_sysroot_result" 110803f6d0e1dSmrg ;; 110813f6d0e1dSmrg *) func_append newdependency_libs " $deplib" ;; 11082c3c9db83Smrg esac 11083c3c9db83Smrg done 110842f60eb46Smrg dependency_libs=$newdependency_libs 11085c3c9db83Smrg newdlfiles= 11086c3c9db83Smrg 11087c3c9db83Smrg for lib in $dlfiles; do 11088c3c9db83Smrg case $lib in 11089c3c9db83Smrg *.la) 11090c3c9db83Smrg func_basename "$lib" 110912f60eb46Smrg name=$func_basename_result 110922f60eb46Smrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 11093c3c9db83Smrg test -z "$libdir" && \ 110942f60eb46Smrg func_fatal_error "'$lib' is not a valid libtool archive" 110953f6d0e1dSmrg func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" 11096c3c9db83Smrg ;; 110973f6d0e1dSmrg *) func_append newdlfiles " $lib" ;; 11098c3c9db83Smrg esac 11099c3c9db83Smrg done 111002f60eb46Smrg dlfiles=$newdlfiles 11101c3c9db83Smrg newdlprefiles= 11102c3c9db83Smrg for lib in $dlprefiles; do 11103c3c9db83Smrg case $lib in 11104c3c9db83Smrg *.la) 11105c3c9db83Smrg # Only pass preopened files to the pseudo-archive (for 11106c3c9db83Smrg # eventual linking with the app. that links it) if we 11107c3c9db83Smrg # didn't already link the preopened objects directly into 11108c3c9db83Smrg # the library: 11109c3c9db83Smrg func_basename "$lib" 111102f60eb46Smrg name=$func_basename_result 111112f60eb46Smrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 11112c3c9db83Smrg test -z "$libdir" && \ 111132f60eb46Smrg func_fatal_error "'$lib' is not a valid libtool archive" 111143f6d0e1dSmrg func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" 11115c3c9db83Smrg ;; 11116c3c9db83Smrg esac 11117c3c9db83Smrg done 111182f60eb46Smrg dlprefiles=$newdlprefiles 11119c3c9db83Smrg else 11120c3c9db83Smrg newdlfiles= 11121c3c9db83Smrg for lib in $dlfiles; do 11122c3c9db83Smrg case $lib in 111232f60eb46Smrg [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; 11124c3c9db83Smrg *) abs=`pwd`"/$lib" ;; 11125c3c9db83Smrg esac 111263f6d0e1dSmrg func_append newdlfiles " $abs" 11127c3c9db83Smrg done 111282f60eb46Smrg dlfiles=$newdlfiles 11129c3c9db83Smrg newdlprefiles= 11130c3c9db83Smrg for lib in $dlprefiles; do 11131c3c9db83Smrg case $lib in 111322f60eb46Smrg [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; 11133c3c9db83Smrg *) abs=`pwd`"/$lib" ;; 11134c3c9db83Smrg esac 111353f6d0e1dSmrg func_append newdlprefiles " $abs" 11136c3c9db83Smrg done 111372f60eb46Smrg dlprefiles=$newdlprefiles 11138c3c9db83Smrg fi 11139c3c9db83Smrg $RM $output 11140c3c9db83Smrg # place dlname in correct position for cygwin 111413f6d0e1dSmrg # In fact, it would be nice if we could use this code for all target 111423f6d0e1dSmrg # systems that can't hard-code library paths into their executables 111433f6d0e1dSmrg # and that have no shared library path variable independent of PATH, 111443f6d0e1dSmrg # but it turns out we can't easily determine that from inspecting 111453f6d0e1dSmrg # libtool variables, so we have to hard-code the OSs to which it 111463f6d0e1dSmrg # applies here; at the moment, that means platforms that use the PE 111473f6d0e1dSmrg # object format with DLL files. See the long comment at the top of 111483f6d0e1dSmrg # tests/bindir.at for full details. 11149c3c9db83Smrg tdlname=$dlname 11150c3c9db83Smrg case $host,$output,$installed,$module,$dlname in 111513f6d0e1dSmrg *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) 111523f6d0e1dSmrg # If a -bindir argument was supplied, place the dll there. 111532f60eb46Smrg if test -n "$bindir"; then 111543f6d0e1dSmrg func_relative_path "$install_libdir" "$bindir" 111552f60eb46Smrg tdlname=$func_relative_path_result/$dlname 111563f6d0e1dSmrg else 111573f6d0e1dSmrg # Otherwise fall back on heuristic. 111583f6d0e1dSmrg tdlname=../bin/$dlname 111593f6d0e1dSmrg fi 111603f6d0e1dSmrg ;; 11161c3c9db83Smrg esac 11162c3c9db83Smrg $ECHO > $output "\ 11163c3c9db83Smrg# $outputname - a libtool library file 111642f60eb46Smrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 11165c3c9db83Smrg# 11166c3c9db83Smrg# Please DO NOT delete this file! 11167c3c9db83Smrg# It is necessary for linking the library. 11168692f60a7Smrg 11169c3c9db83Smrg# The name that we can dlopen(3). 11170c3c9db83Smrgdlname='$tdlname' 11171692f60a7Smrg 11172c3c9db83Smrg# Names of this library. 11173c3c9db83Smrglibrary_names='$library_names' 11174692f60a7Smrg 11175c3c9db83Smrg# The name of the static archive. 11176c3c9db83Smrgold_library='$old_library' 11177692f60a7Smrg 111782f60eb46Smrg# Linker flags that cannot go in dependency_libs. 11179c3c9db83Smrginherited_linker_flags='$new_inherited_linker_flags' 11180692f60a7Smrg 11181c3c9db83Smrg# Libraries that this one depends upon. 11182c3c9db83Smrgdependency_libs='$dependency_libs' 11183692f60a7Smrg 11184c3c9db83Smrg# Names of additional weak libraries provided by this library 11185c3c9db83Smrgweak_library_names='$weak_libs' 11186692f60a7Smrg 11187c3c9db83Smrg# Version information for $libname. 11188c3c9db83Smrgcurrent=$current 11189c3c9db83Smrgage=$age 11190c3c9db83Smrgrevision=$revision 11191692f60a7Smrg 11192c3c9db83Smrg# Is this an already installed library? 11193c3c9db83Smrginstalled=$installed 11194692f60a7Smrg 11195c3c9db83Smrg# Should we warn about portability when linking against -modules? 11196c3c9db83Smrgshouldnotlink=$module 11197692f60a7Smrg 11198c3c9db83Smrg# Files to dlopen/dlpreopen 11199c3c9db83Smrgdlopen='$dlfiles' 11200c3c9db83Smrgdlpreopen='$dlprefiles' 11201692f60a7Smrg 11202c3c9db83Smrg# Directory that this library needs to be installed in: 11203c3c9db83Smrglibdir='$install_libdir'" 112042f60eb46Smrg if test no,yes = "$installed,$need_relink"; then 11205c3c9db83Smrg $ECHO >> $output "\ 11206c3c9db83Smrgrelink_command=\"$relink_command\"" 11207c3c9db83Smrg fi 11208c3c9db83Smrg done 11209c3c9db83Smrg } 11210692f60a7Smrg 11211c3c9db83Smrg # Do a symbolic link so that the libtool archive can be found in 11212c3c9db83Smrg # LD_LIBRARY_PATH before the program is installed. 11213c3c9db83Smrg func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' 11214c3c9db83Smrg ;; 11215c3c9db83Smrg esac 11216c3c9db83Smrg exit $EXIT_SUCCESS 11217c3c9db83Smrg} 112182e71ea71Smrg 112192f60eb46Smrgif test link = "$opt_mode" || test relink = "$opt_mode"; then 112202f60eb46Smrg func_mode_link ${1+"$@"} 112212f60eb46Smrgfi 11222692f60a7Smrg 11223692f60a7Smrg 11224c3c9db83Smrg# func_mode_uninstall arg... 11225c3c9db83Smrgfunc_mode_uninstall () 11226c3c9db83Smrg{ 112272f60eb46Smrg $debug_cmd 112282f60eb46Smrg 112292f60eb46Smrg RM=$nonopt 11230692f60a7Smrg files= 112312f60eb46Smrg rmforce=false 11232692f60a7Smrg exit_status=0 11233692f60a7Smrg 11234692f60a7Smrg # This variable tells wrapper scripts just to set variables rather 11235692f60a7Smrg # than running their programs. 112362f60eb46Smrg libtool_install_magic=$magic 11237692f60a7Smrg 11238692f60a7Smrg for arg 11239692f60a7Smrg do 11240692f60a7Smrg case $arg in 112412f60eb46Smrg -f) func_append RM " $arg"; rmforce=: ;; 112423f6d0e1dSmrg -*) func_append RM " $arg" ;; 112433f6d0e1dSmrg *) func_append files " $arg" ;; 11244692f60a7Smrg esac 11245692f60a7Smrg done 11246692f60a7Smrg 11247c3c9db83Smrg test -z "$RM" && \ 11248c3c9db83Smrg func_fatal_help "you must specify an RM program" 11249692f60a7Smrg 11250692f60a7Smrg rmdirs= 11251692f60a7Smrg 11252692f60a7Smrg for file in $files; do 11253c3c9db83Smrg func_dirname "$file" "" "." 112542f60eb46Smrg dir=$func_dirname_result 112552f60eb46Smrg if test . = "$dir"; then 112562f60eb46Smrg odir=$objdir 11257692f60a7Smrg else 112582f60eb46Smrg odir=$dir/$objdir 11259692f60a7Smrg fi 11260c3c9db83Smrg func_basename "$file" 112612f60eb46Smrg name=$func_basename_result 112622f60eb46Smrg test uninstall = "$opt_mode" && odir=$dir 11263692f60a7Smrg 112643f6d0e1dSmrg # Remember odir for removal later, being careful to avoid duplicates 112652f60eb46Smrg if test clean = "$opt_mode"; then 11266692f60a7Smrg case " $rmdirs " in 112673f6d0e1dSmrg *" $odir "*) ;; 112683f6d0e1dSmrg *) func_append rmdirs " $odir" ;; 11269692f60a7Smrg esac 11270692f60a7Smrg fi 11271692f60a7Smrg 11272692f60a7Smrg # Don't error if the file doesn't exist and rm -f was used. 11273c3c9db83Smrg if { test -L "$file"; } >/dev/null 2>&1 || 11274c3c9db83Smrg { test -h "$file"; } >/dev/null 2>&1 || 11275c3c9db83Smrg test -f "$file"; then 11276692f60a7Smrg : 11277692f60a7Smrg elif test -d "$file"; then 11278692f60a7Smrg exit_status=1 11279692f60a7Smrg continue 112802f60eb46Smrg elif $rmforce; then 11281692f60a7Smrg continue 11282692f60a7Smrg fi 11283692f60a7Smrg 112842f60eb46Smrg rmfiles=$file 11285692f60a7Smrg 11286692f60a7Smrg case $name in 11287692f60a7Smrg *.la) 11288692f60a7Smrg # Possibly a libtool archive, so verify it. 11289c3c9db83Smrg if func_lalib_p "$file"; then 11290c3c9db83Smrg func_source $dir/$name 11291692f60a7Smrg 11292692f60a7Smrg # Delete the libtool libraries and symlinks. 11293692f60a7Smrg for n in $library_names; do 112943f6d0e1dSmrg func_append rmfiles " $odir/$n" 11295692f60a7Smrg done 112963f6d0e1dSmrg test -n "$old_library" && func_append rmfiles " $odir/$old_library" 11297692f60a7Smrg 112982f60eb46Smrg case $opt_mode in 11299692f60a7Smrg clean) 113003f6d0e1dSmrg case " $library_names " in 11301692f60a7Smrg *" $dlname "*) ;; 113023f6d0e1dSmrg *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; 11303692f60a7Smrg esac 113043f6d0e1dSmrg test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" 11305692f60a7Smrg ;; 11306692f60a7Smrg uninstall) 11307692f60a7Smrg if test -n "$library_names"; then 11308692f60a7Smrg # Do each command in the postuninstall commands. 113092f60eb46Smrg func_execute_cmds "$postuninstall_cmds" '$rmforce || exit_status=1' 11310692f60a7Smrg fi 11311692f60a7Smrg 11312692f60a7Smrg if test -n "$old_library"; then 11313692f60a7Smrg # Do each command in the old_postuninstall commands. 113142f60eb46Smrg func_execute_cmds "$old_postuninstall_cmds" '$rmforce || exit_status=1' 11315692f60a7Smrg fi 11316692f60a7Smrg # FIXME: should reinstall the best remaining shared library. 11317692f60a7Smrg ;; 11318692f60a7Smrg esac 11319692f60a7Smrg fi 11320692f60a7Smrg ;; 11321692f60a7Smrg 11322692f60a7Smrg *.lo) 11323692f60a7Smrg # Possibly a libtool object, so verify it. 11324c3c9db83Smrg if func_lalib_p "$file"; then 11325692f60a7Smrg 11326692f60a7Smrg # Read the .lo file 11327c3c9db83Smrg func_source $dir/$name 11328692f60a7Smrg 11329692f60a7Smrg # Add PIC object to the list of files to remove. 113302f60eb46Smrg if test -n "$pic_object" && test none != "$pic_object"; then 113313f6d0e1dSmrg func_append rmfiles " $dir/$pic_object" 11332692f60a7Smrg fi 11333692f60a7Smrg 11334692f60a7Smrg # Add non-PIC object to the list of files to remove. 113352f60eb46Smrg if test -n "$non_pic_object" && test none != "$non_pic_object"; then 113363f6d0e1dSmrg func_append rmfiles " $dir/$non_pic_object" 11337692f60a7Smrg fi 11338692f60a7Smrg fi 11339692f60a7Smrg ;; 11340692f60a7Smrg 11341692f60a7Smrg *) 113422f60eb46Smrg if test clean = "$opt_mode"; then 11343692f60a7Smrg noexename=$name 11344692f60a7Smrg case $file in 11345692f60a7Smrg *.exe) 11346c3c9db83Smrg func_stripname '' '.exe' "$file" 11347c3c9db83Smrg file=$func_stripname_result 11348c3c9db83Smrg func_stripname '' '.exe' "$name" 11349c3c9db83Smrg noexename=$func_stripname_result 11350692f60a7Smrg # $file with .exe has already been added to rmfiles, 11351692f60a7Smrg # add $file without .exe 113523f6d0e1dSmrg func_append rmfiles " $file" 11353692f60a7Smrg ;; 11354692f60a7Smrg esac 11355692f60a7Smrg # Do a test to see if this is a libtool program. 11356c3c9db83Smrg if func_ltwrapper_p "$file"; then 11357c3c9db83Smrg if func_ltwrapper_executable_p "$file"; then 11358c3c9db83Smrg func_ltwrapper_scriptname "$file" 11359c3c9db83Smrg relink_command= 11360c3c9db83Smrg func_source $func_ltwrapper_scriptname_result 113613f6d0e1dSmrg func_append rmfiles " $func_ltwrapper_scriptname_result" 11362c3c9db83Smrg else 11363c3c9db83Smrg relink_command= 11364c3c9db83Smrg func_source $dir/$noexename 11365c3c9db83Smrg fi 11366692f60a7Smrg 11367692f60a7Smrg # note $name still contains .exe if it was in $file originally 11368692f60a7Smrg # as does the version of $file that was added into $rmfiles 113692f60eb46Smrg func_append rmfiles " $odir/$name $odir/${name}S.$objext" 113702f60eb46Smrg if test yes = "$fast_install" && test -n "$relink_command"; then 113713f6d0e1dSmrg func_append rmfiles " $odir/lt-$name" 11372692f60a7Smrg fi 113732f60eb46Smrg if test "X$noexename" != "X$name"; then 113742f60eb46Smrg func_append rmfiles " $odir/lt-$noexename.c" 11375692f60a7Smrg fi 11376692f60a7Smrg fi 11377692f60a7Smrg fi 11378692f60a7Smrg ;; 11379692f60a7Smrg esac 11380c3c9db83Smrg func_show_eval "$RM $rmfiles" 'exit_status=1' 11381692f60a7Smrg done 11382692f60a7Smrg 113832f60eb46Smrg # Try to remove the $objdir's in the directories where we deleted files 11384692f60a7Smrg for dir in $rmdirs; do 11385692f60a7Smrg if test -d "$dir"; then 11386c3c9db83Smrg func_show_eval "rmdir $dir >/dev/null 2>&1" 11387692f60a7Smrg fi 11388692f60a7Smrg done 11389692f60a7Smrg 11390692f60a7Smrg exit $exit_status 11391c3c9db83Smrg} 11392692f60a7Smrg 113932f60eb46Smrgif test uninstall = "$opt_mode" || test clean = "$opt_mode"; then 113942f60eb46Smrg func_mode_uninstall ${1+"$@"} 113952f60eb46Smrgfi 1139685ee4c00Smrg 113973f6d0e1dSmrgtest -z "$opt_mode" && { 113982f60eb46Smrg help=$generic_help 11399c3c9db83Smrg func_fatal_help "you must specify a MODE" 11400c3c9db83Smrg} 11401c3c9db83Smrg 11402c3c9db83Smrgtest -z "$exec_cmd" && \ 114032f60eb46Smrg func_fatal_help "invalid operation mode '$opt_mode'" 11404692f60a7Smrg 11405692f60a7Smrgif test -n "$exec_cmd"; then 11406c3c9db83Smrg eval exec "$exec_cmd" 11407692f60a7Smrg exit $EXIT_FAILURE 11408692f60a7Smrgfi 11409692f60a7Smrg 11410c3c9db83Smrgexit $exit_status 11411692f60a7Smrg 11412692f60a7Smrg 11413692f60a7Smrg# The TAGs below are defined such that we never get into a situation 114142f60eb46Smrg# where we disable both kinds of libraries. Given conflicting 11415692f60a7Smrg# choices, we go for a static library, that is the most portable, 11416692f60a7Smrg# since we can't tell whether shared libraries were disabled because 11417692f60a7Smrg# the user asked for that or because the platform doesn't support 11418692f60a7Smrg# them. This is particularly important on AIX, because we don't 11419692f60a7Smrg# support having both static and shared libraries enabled at the same 11420692f60a7Smrg# time on that platform, so we default to a shared-only configuration. 11421692f60a7Smrg# If a disable-shared tag is given, we'll fallback to a static-only 11422692f60a7Smrg# configuration. But we'll never go from static-only to shared-only. 11423692f60a7Smrg 11424692f60a7Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared 11425c3c9db83Smrgbuild_libtool_libs=no 11426c3c9db83Smrgbuild_old_libs=yes 11427692f60a7Smrg# ### END LIBTOOL TAG CONFIG: disable-shared 11428692f60a7Smrg 11429692f60a7Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static 11430c3c9db83Smrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` 11431692f60a7Smrg# ### END LIBTOOL TAG CONFIG: disable-static 11432692f60a7Smrg 11433692f60a7Smrg# Local Variables: 11434692f60a7Smrg# mode:shell-script 11435692f60a7Smrg# sh-indentation:2 11436692f60a7Smrg# End: 11437