18d0bc965Smrg#! /usr/bin/env sh 23169be4bSmrg## DO NOT EDIT - This file generated from ./build-aux/ltmain.in 38d0bc965Smrg## by inline-source v2019-02-19.15 48c4a8e55Smrg 58d0bc965Smrg# libtool (GNU libtool) 2.4.7 63169be4bSmrg# Provide generalized library-building support services. 78c4a8e55Smrg# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 88c4a8e55Smrg 98d0bc965Smrg# Copyright (C) 1996-2019, 2021-2022 Free Software Foundation, Inc. 108c4a8e55Smrg# This is free software; see the source for copying conditions. There is NO 118c4a8e55Smrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 128c4a8e55Smrg 138c4a8e55Smrg# GNU Libtool is free software; you can redistribute it and/or modify 14b042e37fSmrg# it under the terms of the GNU General Public License as published by 15b042e37fSmrg# the Free Software Foundation; either version 2 of the License, or 16b042e37fSmrg# (at your option) any later version. 17b042e37fSmrg# 188c4a8e55Smrg# As a special exception to the GNU General Public License, 198c4a8e55Smrg# if you distribute this file as part of a program or library that 208c4a8e55Smrg# is built using GNU Libtool, you may include this file under the 218c4a8e55Smrg# same distribution terms that you use for the rest of that program. 228c4a8e55Smrg# 238c4a8e55Smrg# GNU Libtool is distributed in the hope that it will be useful, but 24b042e37fSmrg# WITHOUT ANY WARRANTY; without even the implied warranty of 25b042e37fSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 26b042e37fSmrg# General Public License for more details. 27b042e37fSmrg# 28b042e37fSmrg# You should have received a copy of the GNU General Public License 293169be4bSmrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 308c4a8e55Smrg 318c4a8e55Smrg 32706b6b52SmrgPROGRAM=libtool 338c4a8e55SmrgPACKAGE=libtool 348d0bc965SmrgVERSION=2.4.7 358d0bc965Smrgpackage_revision=2.4.7 368c4a8e55Smrg 373169be4bSmrg 383169be4bSmrg## ------ ## 393169be4bSmrg## Usage. ## 403169be4bSmrg## ------ ## 413169be4bSmrg 423169be4bSmrg# Run './libtool --help' for help with using this script from the 433169be4bSmrg# command line. 443169be4bSmrg 453169be4bSmrg 463169be4bSmrg## ------------------------------- ## 473169be4bSmrg## User overridable command paths. ## 483169be4bSmrg## ------------------------------- ## 493169be4bSmrg 503169be4bSmrg# After configure completes, it has a better idea of some of the 513169be4bSmrg# shell tools we need than the defaults used by the functions shared 523169be4bSmrg# with bootstrap, so set those here where they can still be over- 533169be4bSmrg# ridden by the user, but otherwise take precedence. 543169be4bSmrg 553169be4bSmrg: ${AUTOCONF="autoconf"} 563169be4bSmrg: ${AUTOMAKE="automake"} 573169be4bSmrg 583169be4bSmrg 593169be4bSmrg## -------------------------- ## 603169be4bSmrg## Source external libraries. ## 613169be4bSmrg## -------------------------- ## 623169be4bSmrg 633169be4bSmrg# Much of our low-level functionality needs to be sourced from external 643169be4bSmrg# libraries, which are installed to $pkgauxdir. 653169be4bSmrg 663169be4bSmrg# Set a version string for this script. 678d0bc965Smrgscriptversion=2019-02-19.15; # UTC 683169be4bSmrg 693169be4bSmrg# General shell script boiler plate, and helper functions. 703169be4bSmrg# Written by Gary V. Vaughan, 2004 713169be4bSmrg 728d0bc965Smrg# This is free software. There is NO warranty; not even for 738d0bc965Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 748d0bc965Smrg# 758d0bc965Smrg# Copyright (C) 2004-2019, 2021 Bootstrap Authors 768d0bc965Smrg# 778d0bc965Smrg# This file is dual licensed under the terms of the MIT license 788d0bc965Smrg# <https://opensource.org/license/MIT>, and GPL version 2 or later 798d0bc965Smrg# <http://www.gnu.org/licenses/gpl-2.0.html>. You must apply one of 808d0bc965Smrg# these licenses when using or redistributing this software or any of 818d0bc965Smrg# the files within it. See the URLs above, or the file `LICENSE` 828d0bc965Smrg# included in the Bootstrap distribution for the full license texts. 833169be4bSmrg 848d0bc965Smrg# Please report bugs or propose patches to: 858d0bc965Smrg# <https://github.com/gnulib-modules/bootstrap/issues> 863169be4bSmrg 873169be4bSmrg 883169be4bSmrg## ------ ## 893169be4bSmrg## Usage. ## 903169be4bSmrg## ------ ## 913169be4bSmrg 923169be4bSmrg# Evaluate this file near the top of your script to gain access to 933169be4bSmrg# the functions and variables defined here: 943169be4bSmrg# 953169be4bSmrg# . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh 963169be4bSmrg# 973169be4bSmrg# If you need to override any of the default environment variable 983169be4bSmrg# settings, do that before evaluating this file. 993169be4bSmrg 1003169be4bSmrg 1013169be4bSmrg## -------------------- ## 1023169be4bSmrg## Shell normalisation. ## 1033169be4bSmrg## -------------------- ## 1043169be4bSmrg 1053169be4bSmrg# Some shells need a little help to be as Bourne compatible as possible. 1063169be4bSmrg# Before doing anything else, make sure all that help has been provided! 1073169be4bSmrg 1083169be4bSmrgDUALCASE=1; export DUALCASE # for MKS sh 1093169be4bSmrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : 1108c4a8e55Smrg emulate sh 1118c4a8e55Smrg NULLCMD=: 1123169be4bSmrg # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which 1138c4a8e55Smrg # is contrary to our usage. Disable this feature. 1148c4a8e55Smrg alias -g '${1+"$@"}'='"$@"' 1158c4a8e55Smrg setopt NO_GLOB_SUBST 1168c4a8e55Smrgelse 1173169be4bSmrg case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac 1188c4a8e55Smrgfi 119706b6b52Smrg 1203169be4bSmrg# NLS nuisances: We save the old values in case they are required later. 1213169be4bSmrg_G_user_locale= 1223169be4bSmrg_G_safe_locale= 1233169be4bSmrgfor _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 1248c4a8e55Smrgdo 1253169be4bSmrg eval "if test set = \"\${$_G_var+set}\"; then 1263169be4bSmrg save_$_G_var=\$$_G_var 1273169be4bSmrg $_G_var=C 1283169be4bSmrg export $_G_var 1293169be4bSmrg _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\" 1303169be4bSmrg _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\" 1318c4a8e55Smrg fi" 1328c4a8e55Smrgdone 1338d0bc965Smrg# These NLS vars are set unconditionally (bootstrap issue #24). Unset those 1348d0bc965Smrg# in case the environment reset is needed later and the $save_* variant is not 1358d0bc965Smrg# defined (see the code above). 1368d0bc965SmrgLC_ALL=C 1378d0bc965SmrgLANGUAGE=C 1388d0bc965Smrgexport LANGUAGE LC_ALL 1398c4a8e55Smrg 1403169be4bSmrg# Make sure IFS has a sensible default 1413169be4bSmrgsp=' ' 1423169be4bSmrgnl=' 1433169be4bSmrg' 1443169be4bSmrgIFS="$sp $nl" 1453169be4bSmrg 1463169be4bSmrg# There are apparently some retarded systems that use ';' as a PATH separator! 1473169be4bSmrgif test "${PATH_SEPARATOR+set}" != set; then 1483169be4bSmrg PATH_SEPARATOR=: 1493169be4bSmrg (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { 1503169be4bSmrg (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || 1513169be4bSmrg PATH_SEPARATOR=';' 1523169be4bSmrg } 1533169be4bSmrgfi 1548c4a8e55Smrg 1558c4a8e55Smrg 1568d0bc965Smrg# func_unset VAR 1578d0bc965Smrg# -------------- 1588d0bc965Smrg# Portably unset VAR. 1598d0bc965Smrg# In some shells, an 'unset VAR' statement leaves a non-zero return 1608d0bc965Smrg# status if VAR is already unset, which might be problematic if the 1618d0bc965Smrg# statement is used at the end of a function (thus poisoning its return 1628d0bc965Smrg# value) or when 'set -e' is active (causing even a spurious abort of 1638d0bc965Smrg# the script in this case). 1648d0bc965Smrgfunc_unset () 1658d0bc965Smrg{ 1668d0bc965Smrg { eval $1=; (eval unset $1) >/dev/null 2>&1 && eval unset $1 || : ; } 1678d0bc965Smrg} 1688d0bc965Smrg 1698d0bc965Smrg 1708d0bc965Smrg# Make sure CDPATH doesn't cause `cd` commands to output the target dir. 1718d0bc965Smrgfunc_unset CDPATH 1728d0bc965Smrg 1738d0bc965Smrg# Make sure ${,E,F}GREP behave sanely. 1748d0bc965Smrgfunc_unset GREP_OPTIONS 1758d0bc965Smrg 1768c4a8e55Smrg 1773169be4bSmrg## ------------------------- ## 1783169be4bSmrg## Locate command utilities. ## 1793169be4bSmrg## ------------------------- ## 1803169be4bSmrg 1813169be4bSmrg 1823169be4bSmrg# func_executable_p FILE 1833169be4bSmrg# ---------------------- 1843169be4bSmrg# Check that FILE is an executable regular file. 1853169be4bSmrgfunc_executable_p () 1863169be4bSmrg{ 1873169be4bSmrg test -f "$1" && test -x "$1" 1883169be4bSmrg} 1893169be4bSmrg 1903169be4bSmrg 1913169be4bSmrg# func_path_progs PROGS_LIST CHECK_FUNC [PATH] 1923169be4bSmrg# -------------------------------------------- 1933169be4bSmrg# Search for either a program that responds to --version with output 1943169be4bSmrg# containing "GNU", or else returned by CHECK_FUNC otherwise, by 1953169be4bSmrg# trying all the directories in PATH with each of the elements of 1963169be4bSmrg# PROGS_LIST. 1973169be4bSmrg# 1983169be4bSmrg# CHECK_FUNC should accept the path to a candidate program, and 1993169be4bSmrg# set $func_check_prog_result if it truncates its output less than 2003169be4bSmrg# $_G_path_prog_max characters. 2013169be4bSmrgfunc_path_progs () 2023169be4bSmrg{ 2033169be4bSmrg _G_progs_list=$1 2043169be4bSmrg _G_check_func=$2 2053169be4bSmrg _G_PATH=${3-"$PATH"} 2063169be4bSmrg 2073169be4bSmrg _G_path_prog_max=0 2083169be4bSmrg _G_path_prog_found=false 2093169be4bSmrg _G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:} 2103169be4bSmrg for _G_dir in $_G_PATH; do 2113169be4bSmrg IFS=$_G_save_IFS 2123169be4bSmrg test -z "$_G_dir" && _G_dir=. 2133169be4bSmrg for _G_prog_name in $_G_progs_list; do 2143169be4bSmrg for _exeext in '' .EXE; do 2153169be4bSmrg _G_path_prog=$_G_dir/$_G_prog_name$_exeext 2163169be4bSmrg func_executable_p "$_G_path_prog" || continue 2173169be4bSmrg case `"$_G_path_prog" --version 2>&1` in 2183169be4bSmrg *GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;; 2193169be4bSmrg *) $_G_check_func $_G_path_prog 2203169be4bSmrg func_path_progs_result=$func_check_prog_result 2213169be4bSmrg ;; 2223169be4bSmrg esac 2233169be4bSmrg $_G_path_prog_found && break 3 2243169be4bSmrg done 2253169be4bSmrg done 2263169be4bSmrg done 2273169be4bSmrg IFS=$_G_save_IFS 2283169be4bSmrg test -z "$func_path_progs_result" && { 2293169be4bSmrg echo "no acceptable sed could be found in \$PATH" >&2 2303169be4bSmrg exit 1 2313169be4bSmrg } 2323169be4bSmrg} 2333169be4bSmrg 2343169be4bSmrg 2353169be4bSmrg# We want to be able to use the functions in this file before configure 2363169be4bSmrg# has figured out where the best binaries are kept, which means we have 2373169be4bSmrg# to search for them ourselves - except when the results are already set 2383169be4bSmrg# where we skip the searches. 2393169be4bSmrg 2403169be4bSmrg# Unless the user overrides by setting SED, search the path for either GNU 2413169be4bSmrg# sed, or the sed that truncates its output the least. 2423169be4bSmrgtest -z "$SED" && { 2433169be4bSmrg _G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ 2443169be4bSmrg for _G_i in 1 2 3 4 5 6 7; do 2453169be4bSmrg _G_sed_script=$_G_sed_script$nl$_G_sed_script 2463169be4bSmrg done 2473169be4bSmrg echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed 2483169be4bSmrg _G_sed_script= 2493169be4bSmrg 2503169be4bSmrg func_check_prog_sed () 2513169be4bSmrg { 2523169be4bSmrg _G_path_prog=$1 2533169be4bSmrg 2543169be4bSmrg _G_count=0 2553169be4bSmrg printf 0123456789 >conftest.in 2563169be4bSmrg while : 2573169be4bSmrg do 2583169be4bSmrg cat conftest.in conftest.in >conftest.tmp 2593169be4bSmrg mv conftest.tmp conftest.in 2603169be4bSmrg cp conftest.in conftest.nl 2613169be4bSmrg echo '' >> conftest.nl 2623169be4bSmrg "$_G_path_prog" -f conftest.sed <conftest.nl >conftest.out 2>/dev/null || break 2633169be4bSmrg diff conftest.out conftest.nl >/dev/null 2>&1 || break 2643169be4bSmrg _G_count=`expr $_G_count + 1` 2653169be4bSmrg if test "$_G_count" -gt "$_G_path_prog_max"; then 2663169be4bSmrg # Best one so far, save it but keep looking for a better one 2673169be4bSmrg func_check_prog_result=$_G_path_prog 2683169be4bSmrg _G_path_prog_max=$_G_count 2693169be4bSmrg fi 2703169be4bSmrg # 10*(2^10) chars as input seems more than enough 2713169be4bSmrg test 10 -lt "$_G_count" && break 2723169be4bSmrg done 2733169be4bSmrg rm -f conftest.in conftest.tmp conftest.nl conftest.out 2743169be4bSmrg } 2753169be4bSmrg 2768d0bc965Smrg func_path_progs "sed gsed" func_check_prog_sed "$PATH:/usr/xpg4/bin" 2773169be4bSmrg rm -f conftest.sed 2783169be4bSmrg SED=$func_path_progs_result 2793169be4bSmrg} 2803169be4bSmrg 2813169be4bSmrg 2823169be4bSmrg# Unless the user overrides by setting GREP, search the path for either GNU 2833169be4bSmrg# grep, or the grep that truncates its output the least. 2843169be4bSmrgtest -z "$GREP" && { 2853169be4bSmrg func_check_prog_grep () 2863169be4bSmrg { 2873169be4bSmrg _G_path_prog=$1 2883169be4bSmrg 2893169be4bSmrg _G_count=0 2903169be4bSmrg _G_path_prog_max=0 2913169be4bSmrg printf 0123456789 >conftest.in 2923169be4bSmrg while : 2933169be4bSmrg do 2943169be4bSmrg cat conftest.in conftest.in >conftest.tmp 2953169be4bSmrg mv conftest.tmp conftest.in 2963169be4bSmrg cp conftest.in conftest.nl 2973169be4bSmrg echo 'GREP' >> conftest.nl 2983169be4bSmrg "$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' <conftest.nl >conftest.out 2>/dev/null || break 2993169be4bSmrg diff conftest.out conftest.nl >/dev/null 2>&1 || break 3003169be4bSmrg _G_count=`expr $_G_count + 1` 3013169be4bSmrg if test "$_G_count" -gt "$_G_path_prog_max"; then 3023169be4bSmrg # Best one so far, save it but keep looking for a better one 3033169be4bSmrg func_check_prog_result=$_G_path_prog 3043169be4bSmrg _G_path_prog_max=$_G_count 3053169be4bSmrg fi 3063169be4bSmrg # 10*(2^10) chars as input seems more than enough 3073169be4bSmrg test 10 -lt "$_G_count" && break 3083169be4bSmrg done 3093169be4bSmrg rm -f conftest.in conftest.tmp conftest.nl conftest.out 3103169be4bSmrg } 3113169be4bSmrg 3128d0bc965Smrg func_path_progs "grep ggrep" func_check_prog_grep "$PATH:/usr/xpg4/bin" 3133169be4bSmrg GREP=$func_path_progs_result 3143169be4bSmrg} 3153169be4bSmrg 3163169be4bSmrg 3173169be4bSmrg## ------------------------------- ## 3183169be4bSmrg## User overridable command paths. ## 3193169be4bSmrg## ------------------------------- ## 3203169be4bSmrg 3213169be4bSmrg# All uppercase variable names are used for environment variables. These 3223169be4bSmrg# variables can be overridden by the user before calling a script that 3233169be4bSmrg# uses them if a suitable command of that name is not already available 3243169be4bSmrg# in the command search PATH. 3258c4a8e55Smrg 3268c4a8e55Smrg: ${CP="cp -f"} 3273169be4bSmrg: ${ECHO="printf %s\n"} 3283169be4bSmrg: ${EGREP="$GREP -E"} 3293169be4bSmrg: ${FGREP="$GREP -F"} 3303169be4bSmrg: ${LN_S="ln -s"} 3318c4a8e55Smrg: ${MAKE="make"} 3328c4a8e55Smrg: ${MKDIR="mkdir"} 3338c4a8e55Smrg: ${MV="mv -f"} 3348c4a8e55Smrg: ${RM="rm -f"} 3358c4a8e55Smrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"} 3368c4a8e55Smrg 3378c4a8e55Smrg 3383169be4bSmrg## -------------------- ## 3393169be4bSmrg## Useful sed snippets. ## 3403169be4bSmrg## -------------------- ## 341bd23fbfaSmrg 3423169be4bSmrgsed_dirname='s|/[^/]*$||' 3433169be4bSmrgsed_basename='s|^.*/||' 344bd23fbfaSmrg 3453169be4bSmrg# Sed substitution that helps us do robust quoting. It backslashifies 3463169be4bSmrg# metacharacters that are still active within double-quoted strings. 3473169be4bSmrgsed_quote_subst='s|\([`"$\\]\)|\\\1|g' 348bd23fbfaSmrg 3493169be4bSmrg# Same as above, but do not quote variable references. 3503169be4bSmrgsed_double_quote_subst='s/\(["`\\]\)/\\\1/g' 351bd23fbfaSmrg 3523169be4bSmrg# Sed substitution that turns a string into a regex matching for the 3533169be4bSmrg# string literally. 3543169be4bSmrgsed_make_literal_regex='s|[].[^$\\*\/]|\\&|g' 355bd23fbfaSmrg 3563169be4bSmrg# Sed substitution that converts a w32 file name or path 3573169be4bSmrg# that contains forward slashes, into one that contains 3583169be4bSmrg# (escaped) backslashes. A very naive implementation. 3593169be4bSmrgsed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' 3603169be4bSmrg 3613169be4bSmrg# Re-'\' parameter expansions in output of sed_double_quote_subst that 3623169be4bSmrg# were '\'-ed in input to the same. If an odd number of '\' preceded a 3633169be4bSmrg# '$' in input to sed_double_quote_subst, that '$' was protected from 3643169be4bSmrg# expansion. Since each input '\' is now two '\'s, look for any number 3653169be4bSmrg# of runs of four '\'s followed by two '\'s and then a '$'. '\' that '$'. 3663169be4bSmrg_G_bs='\\' 3673169be4bSmrg_G_bs2='\\\\' 3683169be4bSmrg_G_bs4='\\\\\\\\' 3693169be4bSmrg_G_dollar='\$' 3703169be4bSmrgsed_double_backslash="\ 3713169be4bSmrg s/$_G_bs4/&\\ 3723169be4bSmrg/g 3733169be4bSmrg s/^$_G_bs2$_G_dollar/$_G_bs&/ 3743169be4bSmrg s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g 3753169be4bSmrg s/\n//g" 376bd23fbfaSmrg 3778d0bc965Smrg# require_check_ifs_backslash 3788d0bc965Smrg# --------------------------- 3798d0bc965Smrg# Check if we can use backslash as IFS='\' separator, and set 3808d0bc965Smrg# $check_ifs_backshlash_broken to ':' or 'false'. 3818d0bc965Smrgrequire_check_ifs_backslash=func_require_check_ifs_backslash 3828d0bc965Smrgfunc_require_check_ifs_backslash () 3838d0bc965Smrg{ 3848d0bc965Smrg _G_save_IFS=$IFS 3858d0bc965Smrg IFS='\' 3868d0bc965Smrg _G_check_ifs_backshlash='a\\b' 3878d0bc965Smrg for _G_i in $_G_check_ifs_backshlash 3888d0bc965Smrg do 3898d0bc965Smrg case $_G_i in 3908d0bc965Smrg a) 3918d0bc965Smrg check_ifs_backshlash_broken=false 3928d0bc965Smrg ;; 3938d0bc965Smrg '') 3948d0bc965Smrg break 3958d0bc965Smrg ;; 3968d0bc965Smrg *) 3978d0bc965Smrg check_ifs_backshlash_broken=: 3988d0bc965Smrg break 3998d0bc965Smrg ;; 4008d0bc965Smrg esac 4018d0bc965Smrg done 4028d0bc965Smrg IFS=$_G_save_IFS 4038d0bc965Smrg require_check_ifs_backslash=: 4048d0bc965Smrg} 4058d0bc965Smrg 4068c4a8e55Smrg 4073169be4bSmrg## ----------------- ## 4083169be4bSmrg## Global variables. ## 4093169be4bSmrg## ----------------- ## 410b042e37fSmrg 4113169be4bSmrg# Except for the global variables explicitly listed below, the following 4123169be4bSmrg# functions in the '^func_' namespace, and the '^require_' namespace 4133169be4bSmrg# variables initialised in the 'Resource management' section, sourcing 4143169be4bSmrg# this file will not pollute your global namespace with anything 4153169be4bSmrg# else. There's no portable way to scope variables in Bourne shell 4163169be4bSmrg# though, so actually running these functions will sometimes place 4173169be4bSmrg# results into a variable named after the function, and often use 4183169be4bSmrg# temporary variables in the '^_G_' namespace. If you are careful to 4193169be4bSmrg# avoid using those namespaces casually in your sourcing script, things 4203169be4bSmrg# should continue to work as you expect. And, of course, you can freely 4213169be4bSmrg# overwrite any of the functions or variables defined here before 4223169be4bSmrg# calling anything to customize them. 423706b6b52Smrg 4243169be4bSmrgEXIT_SUCCESS=0 4253169be4bSmrgEXIT_FAILURE=1 4263169be4bSmrgEXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. 4273169be4bSmrgEXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. 428706b6b52Smrg 4293169be4bSmrg# Allow overriding, eg assuming that you follow the convention of 4303169be4bSmrg# putting '$debug_cmd' at the start of all your functions, you can get 4313169be4bSmrg# bash to show function call trace with: 4323169be4bSmrg# 4333169be4bSmrg# debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name 4343169be4bSmrgdebug_cmd=${debug_cmd-":"} 4353169be4bSmrgexit_cmd=: 436706b6b52Smrg 4373169be4bSmrg# By convention, finish your script with: 4383169be4bSmrg# 4393169be4bSmrg# exit $exit_status 4403169be4bSmrg# 4413169be4bSmrg# so that you can set exit_status to non-zero if you want to indicate 4423169be4bSmrg# something went wrong during execution without actually bailing out at 4433169be4bSmrg# the point of failure. 4443169be4bSmrgexit_status=$EXIT_SUCCESS 445706b6b52Smrg 4463169be4bSmrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh 4473169be4bSmrg# is ksh but when the shell is invoked as "sh" and the current value of 4483169be4bSmrg# the _XPG environment variable is not equal to 1 (one), the special 4493169be4bSmrg# positional parameter $0, within a function call, is the name of the 4503169be4bSmrg# function. 4513169be4bSmrgprogpath=$0 452b042e37fSmrg 4533169be4bSmrg# The name of this program. 4543169be4bSmrgprogname=`$ECHO "$progpath" |$SED "$sed_basename"` 455b042e37fSmrg 4563169be4bSmrg# Make sure we have an absolute progpath for reexecution: 4578c4a8e55Smrgcase $progpath in 4588c4a8e55Smrg [\\/]*|[A-Za-z]:\\*) ;; 4598c4a8e55Smrg *[\\/]*) 4603169be4bSmrg progdir=`$ECHO "$progpath" |$SED "$sed_dirname"` 4618c4a8e55Smrg progdir=`cd "$progdir" && pwd` 4623169be4bSmrg progpath=$progdir/$progname 4638c4a8e55Smrg ;; 4648c4a8e55Smrg *) 4653169be4bSmrg _G_IFS=$IFS 4660597fb56Smrg IFS=${PATH_SEPARATOR-:} 4678c4a8e55Smrg for progdir in $PATH; do 4683169be4bSmrg IFS=$_G_IFS 4698c4a8e55Smrg test -x "$progdir/$progname" && break 4708c4a8e55Smrg done 4713169be4bSmrg IFS=$_G_IFS 4728c4a8e55Smrg test -n "$progdir" || progdir=`pwd` 4733169be4bSmrg progpath=$progdir/$progname 4748c4a8e55Smrg ;; 4758c4a8e55Smrgesac 476b042e37fSmrg 4778c4a8e55Smrg 4783169be4bSmrg## ----------------- ## 4793169be4bSmrg## Standard options. ## 4803169be4bSmrg## ----------------- ## 481bd23fbfaSmrg 4823169be4bSmrg# The following options affect the operation of the functions defined 4833169be4bSmrg# below, and should be set appropriately depending on run-time para- 4843169be4bSmrg# meters passed on the command line. 4858c4a8e55Smrg 4868c4a8e55Smrgopt_dry_run=false 4878c4a8e55Smrgopt_quiet=false 4888c4a8e55Smrgopt_verbose=false 4898c4a8e55Smrg 4903169be4bSmrg# Categories 'all' and 'none' are always available. Append any others 4913169be4bSmrg# you will pass as the first argument to func_warning from your own 4923169be4bSmrg# code. 4933169be4bSmrgwarning_categories= 494b042e37fSmrg 4953169be4bSmrg# By default, display warnings according to 'opt_warning_types'. Set 4963169be4bSmrg# 'warning_func' to ':' to elide all warnings, or func_fatal_error to 4973169be4bSmrg# treat the next displayed warning as a fatal error. 4983169be4bSmrgwarning_func=func_warn_and_continue 499b042e37fSmrg 5003169be4bSmrg# Set to 'all' to display all warnings, 'none' to suppress all 5013169be4bSmrg# warnings, or a space delimited list of some subset of 5023169be4bSmrg# 'warning_categories' to display only the listed warnings. 5033169be4bSmrgopt_warning_types=all 504b042e37fSmrg 505706b6b52Smrg 5063169be4bSmrg## -------------------- ## 5073169be4bSmrg## Resource management. ## 5083169be4bSmrg## -------------------- ## 509b042e37fSmrg 5103169be4bSmrg# This section contains definitions for functions that each ensure a 5113169be4bSmrg# particular resource (a file, or a non-empty configuration variable for 5123169be4bSmrg# example) is available, and if appropriate to extract default values 5133169be4bSmrg# from pertinent package files. Call them using their associated 5143169be4bSmrg# 'require_*' variable to ensure that they are executed, at most, once. 5153169be4bSmrg# 5163169be4bSmrg# It's entirely deliberate that calling these functions can set 5173169be4bSmrg# variables that don't obey the namespace limitations obeyed by the rest 5183169be4bSmrg# of this file, in order that that they be as useful as possible to 5193169be4bSmrg# callers. 520b042e37fSmrg 521b042e37fSmrg 5223169be4bSmrg# require_term_colors 5233169be4bSmrg# ------------------- 5243169be4bSmrg# Allow display of bold text on terminals that support it. 5253169be4bSmrgrequire_term_colors=func_require_term_colors 5263169be4bSmrgfunc_require_term_colors () 5278c4a8e55Smrg{ 5283169be4bSmrg $debug_cmd 5293169be4bSmrg 5303169be4bSmrg test -t 1 && { 5313169be4bSmrg # COLORTERM and USE_ANSI_COLORS environment variables take 5323169be4bSmrg # precedence, because most terminfo databases neglect to describe 5333169be4bSmrg # whether color sequences are supported. 5343169be4bSmrg test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"} 5353169be4bSmrg 5363169be4bSmrg if test 1 = "$USE_ANSI_COLORS"; then 5373169be4bSmrg # Standard ANSI escape sequences 5383169be4bSmrg tc_reset='[0m' 5393169be4bSmrg tc_bold='[1m'; tc_standout='[7m' 5403169be4bSmrg tc_red='[31m'; tc_green='[32m' 5413169be4bSmrg tc_blue='[34m'; tc_cyan='[36m' 5423169be4bSmrg else 5433169be4bSmrg # Otherwise trust the terminfo database after all. 5443169be4bSmrg test -n "`tput sgr0 2>/dev/null`" && { 5453169be4bSmrg tc_reset=`tput sgr0` 5463169be4bSmrg test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold` 5473169be4bSmrg tc_standout=$tc_bold 5483169be4bSmrg test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso` 5493169be4bSmrg test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1` 5503169be4bSmrg test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2` 5513169be4bSmrg test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4` 5523169be4bSmrg test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5` 5533169be4bSmrg } 5543169be4bSmrg fi 5553169be4bSmrg } 556b042e37fSmrg 5573169be4bSmrg require_term_colors=: 5588c4a8e55Smrg} 559b042e37fSmrg 560b042e37fSmrg 5613169be4bSmrg## ----------------- ## 5623169be4bSmrg## Function library. ## 5633169be4bSmrg## ----------------- ## 5643169be4bSmrg 5653169be4bSmrg# This section contains a variety of useful functions to call in your 5663169be4bSmrg# scripts. Take note of the portable wrappers for features provided by 5673169be4bSmrg# some modern shells, which will fall back to slower equivalents on 5683169be4bSmrg# less featureful shells. 5693169be4bSmrg 5703169be4bSmrg 5713169be4bSmrg# func_append VAR VALUE 5723169be4bSmrg# --------------------- 5733169be4bSmrg# Append VALUE onto the existing contents of VAR. 5743169be4bSmrg 5753169be4bSmrg # We should try to minimise forks, especially on Windows where they are 5763169be4bSmrg # unreasonably slow, so skip the feature probes when bash or zsh are 5773169be4bSmrg # being used: 5783169be4bSmrg if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then 5793169be4bSmrg : ${_G_HAVE_ARITH_OP="yes"} 5803169be4bSmrg : ${_G_HAVE_XSI_OPS="yes"} 5813169be4bSmrg # The += operator was introduced in bash 3.1 5823169be4bSmrg case $BASH_VERSION in 5833169be4bSmrg [12].* | 3.0 | 3.0*) ;; 5843169be4bSmrg *) 5853169be4bSmrg : ${_G_HAVE_PLUSEQ_OP="yes"} 5863169be4bSmrg ;; 5873169be4bSmrg esac 5883169be4bSmrg fi 5893169be4bSmrg 5903169be4bSmrg # _G_HAVE_PLUSEQ_OP 5913169be4bSmrg # Can be empty, in which case the shell is probed, "yes" if += is 5923169be4bSmrg # useable or anything else if it does not work. 5933169be4bSmrg test -z "$_G_HAVE_PLUSEQ_OP" \ 5943169be4bSmrg && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \ 5953169be4bSmrg && _G_HAVE_PLUSEQ_OP=yes 5963169be4bSmrg 5973169be4bSmrgif test yes = "$_G_HAVE_PLUSEQ_OP" 5983169be4bSmrgthen 5993169be4bSmrg # This is an XSI compatible shell, allowing a faster implementation... 6003169be4bSmrg eval 'func_append () 6013169be4bSmrg { 6023169be4bSmrg $debug_cmd 6033169be4bSmrg 6043169be4bSmrg eval "$1+=\$2" 6053169be4bSmrg }' 6063169be4bSmrgelse 6073169be4bSmrg # ...otherwise fall back to using expr, which is often a shell builtin. 6083169be4bSmrg func_append () 6093169be4bSmrg { 6103169be4bSmrg $debug_cmd 6113169be4bSmrg 6123169be4bSmrg eval "$1=\$$1\$2" 6133169be4bSmrg } 6143169be4bSmrgfi 6153169be4bSmrg 6163169be4bSmrg 6173169be4bSmrg# func_append_quoted VAR VALUE 6183169be4bSmrg# ---------------------------- 6193169be4bSmrg# Quote VALUE and append to the end of shell variable VAR, separated 6203169be4bSmrg# by a space. 6213169be4bSmrgif test yes = "$_G_HAVE_PLUSEQ_OP"; then 6223169be4bSmrg eval 'func_append_quoted () 6233169be4bSmrg { 6243169be4bSmrg $debug_cmd 6253169be4bSmrg 6268d0bc965Smrg func_quote_arg pretty "$2" 6278d0bc965Smrg eval "$1+=\\ \$func_quote_arg_result" 6283169be4bSmrg }' 6293169be4bSmrgelse 6303169be4bSmrg func_append_quoted () 6313169be4bSmrg { 6323169be4bSmrg $debug_cmd 6333169be4bSmrg 6348d0bc965Smrg func_quote_arg pretty "$2" 6358d0bc965Smrg eval "$1=\$$1\\ \$func_quote_arg_result" 6363169be4bSmrg } 6373169be4bSmrgfi 6383169be4bSmrg 6393169be4bSmrg 6403169be4bSmrg# func_append_uniq VAR VALUE 6413169be4bSmrg# -------------------------- 6423169be4bSmrg# Append unique VALUE onto the existing contents of VAR, assuming 6433169be4bSmrg# entries are delimited by the first character of VALUE. For example: 6443169be4bSmrg# 6453169be4bSmrg# func_append_uniq options " --another-option option-argument" 6463169be4bSmrg# 6473169be4bSmrg# will only append to $options if " --another-option option-argument " 6483169be4bSmrg# is not already present somewhere in $options already (note spaces at 6493169be4bSmrg# each end implied by leading space in second argument). 6503169be4bSmrgfunc_append_uniq () 6513169be4bSmrg{ 6523169be4bSmrg $debug_cmd 6533169be4bSmrg 6543169be4bSmrg eval _G_current_value='`$ECHO $'$1'`' 6553169be4bSmrg _G_delim=`expr "$2" : '\(.\)'` 6563169be4bSmrg 6573169be4bSmrg case $_G_delim$_G_current_value$_G_delim in 6583169be4bSmrg *"$2$_G_delim"*) ;; 6593169be4bSmrg *) func_append "$@" ;; 6603169be4bSmrg esac 6613169be4bSmrg} 6623169be4bSmrg 6633169be4bSmrg 6643169be4bSmrg# func_arith TERM... 6653169be4bSmrg# ------------------ 6663169be4bSmrg# Set func_arith_result to the result of evaluating TERMs. 6673169be4bSmrg test -z "$_G_HAVE_ARITH_OP" \ 6683169be4bSmrg && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \ 6693169be4bSmrg && _G_HAVE_ARITH_OP=yes 6703169be4bSmrg 6713169be4bSmrgif test yes = "$_G_HAVE_ARITH_OP"; then 6723169be4bSmrg eval 'func_arith () 6733169be4bSmrg { 6743169be4bSmrg $debug_cmd 6753169be4bSmrg 6763169be4bSmrg func_arith_result=$(( $* )) 6773169be4bSmrg }' 6783169be4bSmrgelse 6793169be4bSmrg func_arith () 6803169be4bSmrg { 6813169be4bSmrg $debug_cmd 6823169be4bSmrg 6833169be4bSmrg func_arith_result=`expr "$@"` 6843169be4bSmrg } 6853169be4bSmrgfi 6863169be4bSmrg 6873169be4bSmrg 6883169be4bSmrg# func_basename FILE 6893169be4bSmrg# ------------------ 6903169be4bSmrg# Set func_basename_result to FILE with everything up to and including 6913169be4bSmrg# the last / stripped. 6923169be4bSmrgif test yes = "$_G_HAVE_XSI_OPS"; then 6933169be4bSmrg # If this shell supports suffix pattern removal, then use it to avoid 6943169be4bSmrg # forking. Hide the definitions single quotes in case the shell chokes 6953169be4bSmrg # on unsupported syntax... 6963169be4bSmrg _b='func_basename_result=${1##*/}' 6973169be4bSmrg _d='case $1 in 6983169be4bSmrg */*) func_dirname_result=${1%/*}$2 ;; 6993169be4bSmrg * ) func_dirname_result=$3 ;; 7003169be4bSmrg esac' 7013169be4bSmrg 7023169be4bSmrgelse 7033169be4bSmrg # ...otherwise fall back to using sed. 7043169be4bSmrg _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`' 7053169be4bSmrg _d='func_dirname_result=`$ECHO "$1" |$SED "$sed_dirname"` 7063169be4bSmrg if test "X$func_dirname_result" = "X$1"; then 7073169be4bSmrg func_dirname_result=$3 7083169be4bSmrg else 7093169be4bSmrg func_append func_dirname_result "$2" 7103169be4bSmrg fi' 7113169be4bSmrgfi 7123169be4bSmrg 7133169be4bSmrgeval 'func_basename () 7143169be4bSmrg{ 7153169be4bSmrg $debug_cmd 7163169be4bSmrg 7173169be4bSmrg '"$_b"' 7183169be4bSmrg}' 7193169be4bSmrg 7203169be4bSmrg 7213169be4bSmrg# func_dirname FILE APPEND NONDIR_REPLACEMENT 7223169be4bSmrg# ------------------------------------------- 7233169be4bSmrg# Compute the dirname of FILE. If nonempty, add APPEND to the result, 7243169be4bSmrg# otherwise set result to NONDIR_REPLACEMENT. 7253169be4bSmrgeval 'func_dirname () 7263169be4bSmrg{ 7273169be4bSmrg $debug_cmd 7283169be4bSmrg 7293169be4bSmrg '"$_d"' 7303169be4bSmrg}' 7313169be4bSmrg 7323169be4bSmrg 7333169be4bSmrg# func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT 7343169be4bSmrg# -------------------------------------------------------- 7353169be4bSmrg# Perform func_basename and func_dirname in a single function 7363169be4bSmrg# call: 7373169be4bSmrg# dirname: Compute the dirname of FILE. If nonempty, 7383169be4bSmrg# add APPEND to the result, otherwise set result 7393169be4bSmrg# to NONDIR_REPLACEMENT. 7403169be4bSmrg# value returned in "$func_dirname_result" 7413169be4bSmrg# basename: Compute filename of FILE. 7423169be4bSmrg# value retuned in "$func_basename_result" 7433169be4bSmrg# For efficiency, we do not delegate to the functions above but instead 7443169be4bSmrg# duplicate the functionality here. 7453169be4bSmrgeval 'func_dirname_and_basename () 7463169be4bSmrg{ 7473169be4bSmrg $debug_cmd 7483169be4bSmrg 7493169be4bSmrg '"$_b"' 7503169be4bSmrg '"$_d"' 7513169be4bSmrg}' 7523169be4bSmrg 7533169be4bSmrg 7543169be4bSmrg# func_echo ARG... 7553169be4bSmrg# ---------------- 7563169be4bSmrg# Echo program name prefixed message. 7573169be4bSmrgfunc_echo () 7583169be4bSmrg{ 7593169be4bSmrg $debug_cmd 7603169be4bSmrg 7613169be4bSmrg _G_message=$* 7623169be4bSmrg 7633169be4bSmrg func_echo_IFS=$IFS 7643169be4bSmrg IFS=$nl 7653169be4bSmrg for _G_line in $_G_message; do 7663169be4bSmrg IFS=$func_echo_IFS 7673169be4bSmrg $ECHO "$progname: $_G_line" 7683169be4bSmrg done 7693169be4bSmrg IFS=$func_echo_IFS 7703169be4bSmrg} 7713169be4bSmrg 7723169be4bSmrg 7733169be4bSmrg# func_echo_all ARG... 7743169be4bSmrg# -------------------- 7753169be4bSmrg# Invoke $ECHO with all args, space-separated. 7763169be4bSmrgfunc_echo_all () 7773169be4bSmrg{ 7783169be4bSmrg $ECHO "$*" 7793169be4bSmrg} 7803169be4bSmrg 7813169be4bSmrg 7823169be4bSmrg# func_echo_infix_1 INFIX ARG... 7833169be4bSmrg# ------------------------------ 7843169be4bSmrg# Echo program name, followed by INFIX on the first line, with any 7853169be4bSmrg# additional lines not showing INFIX. 7863169be4bSmrgfunc_echo_infix_1 () 7873169be4bSmrg{ 7883169be4bSmrg $debug_cmd 7893169be4bSmrg 7903169be4bSmrg $require_term_colors 7913169be4bSmrg 7923169be4bSmrg _G_infix=$1; shift 7933169be4bSmrg _G_indent=$_G_infix 7943169be4bSmrg _G_prefix="$progname: $_G_infix: " 7953169be4bSmrg _G_message=$* 7963169be4bSmrg 7973169be4bSmrg # Strip color escape sequences before counting printable length 7983169be4bSmrg for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan" 7993169be4bSmrg do 8003169be4bSmrg test -n "$_G_tc" && { 8013169be4bSmrg _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"` 8023169be4bSmrg _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"` 8033169be4bSmrg } 8043169be4bSmrg done 8053169be4bSmrg _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`" " ## exclude from sc_prohibit_nested_quotes 8063169be4bSmrg 8073169be4bSmrg func_echo_infix_1_IFS=$IFS 8083169be4bSmrg IFS=$nl 8093169be4bSmrg for _G_line in $_G_message; do 8103169be4bSmrg IFS=$func_echo_infix_1_IFS 8113169be4bSmrg $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2 8123169be4bSmrg _G_prefix=$_G_indent 8133169be4bSmrg done 8143169be4bSmrg IFS=$func_echo_infix_1_IFS 8153169be4bSmrg} 8163169be4bSmrg 8173169be4bSmrg 8183169be4bSmrg# func_error ARG... 8193169be4bSmrg# ----------------- 8203169be4bSmrg# Echo program name prefixed message to standard error. 8213169be4bSmrgfunc_error () 8223169be4bSmrg{ 8233169be4bSmrg $debug_cmd 8243169be4bSmrg 8253169be4bSmrg $require_term_colors 8263169be4bSmrg 8273169be4bSmrg func_echo_infix_1 " $tc_standout${tc_red}error$tc_reset" "$*" >&2 8283169be4bSmrg} 8293169be4bSmrg 8303169be4bSmrg 8313169be4bSmrg# func_fatal_error ARG... 8323169be4bSmrg# ----------------------- 8333169be4bSmrg# Echo program name prefixed message to standard error, and exit. 8343169be4bSmrgfunc_fatal_error () 8353169be4bSmrg{ 8363169be4bSmrg $debug_cmd 8373169be4bSmrg 8383169be4bSmrg func_error "$*" 8393169be4bSmrg exit $EXIT_FAILURE 8403169be4bSmrg} 8413169be4bSmrg 8423169be4bSmrg 8433169be4bSmrg# func_grep EXPRESSION FILENAME 8443169be4bSmrg# ----------------------------- 8458c4a8e55Smrg# Check whether EXPRESSION matches any line of FILENAME, without output. 8468c4a8e55Smrgfunc_grep () 8478c4a8e55Smrg{ 8483169be4bSmrg $debug_cmd 8493169be4bSmrg 8508c4a8e55Smrg $GREP "$1" "$2" >/dev/null 2>&1 8518c4a8e55Smrg} 8528c4a8e55Smrg 8538c4a8e55Smrg 8543169be4bSmrg# func_len STRING 8553169be4bSmrg# --------------- 8563169be4bSmrg# Set func_len_result to the length of STRING. STRING may not 8573169be4bSmrg# start with a hyphen. 8583169be4bSmrg test -z "$_G_HAVE_XSI_OPS" \ 8593169be4bSmrg && (eval 'x=a/b/c; 8603169be4bSmrg test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ 8613169be4bSmrg && _G_HAVE_XSI_OPS=yes 8623169be4bSmrg 8633169be4bSmrgif test yes = "$_G_HAVE_XSI_OPS"; then 8643169be4bSmrg eval 'func_len () 8653169be4bSmrg { 8663169be4bSmrg $debug_cmd 8673169be4bSmrg 8683169be4bSmrg func_len_result=${#1} 8693169be4bSmrg }' 8703169be4bSmrgelse 8713169be4bSmrg func_len () 8723169be4bSmrg { 8733169be4bSmrg $debug_cmd 8743169be4bSmrg 8753169be4bSmrg func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len` 8763169be4bSmrg } 8773169be4bSmrgfi 8783169be4bSmrg 8793169be4bSmrg 8803169be4bSmrg# func_mkdir_p DIRECTORY-PATH 8813169be4bSmrg# --------------------------- 8828c4a8e55Smrg# Make sure the entire path to DIRECTORY-PATH is available. 8838c4a8e55Smrgfunc_mkdir_p () 8848c4a8e55Smrg{ 8853169be4bSmrg $debug_cmd 8863169be4bSmrg 8873169be4bSmrg _G_directory_path=$1 8883169be4bSmrg _G_dir_list= 8898c4a8e55Smrg 8903169be4bSmrg if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then 8918c4a8e55Smrg 8923169be4bSmrg # Protect directory names starting with '-' 8933169be4bSmrg case $_G_directory_path in 8943169be4bSmrg -*) _G_directory_path=./$_G_directory_path ;; 8958c4a8e55Smrg esac 8968c4a8e55Smrg 8978c4a8e55Smrg # While some portion of DIR does not yet exist... 8983169be4bSmrg while test ! -d "$_G_directory_path"; do 8998c4a8e55Smrg # ...make a list in topmost first order. Use a colon delimited 9008c4a8e55Smrg # list incase some portion of path contains whitespace. 9013169be4bSmrg _G_dir_list=$_G_directory_path:$_G_dir_list 9028c4a8e55Smrg 9038c4a8e55Smrg # If the last portion added has no slash in it, the list is done 9043169be4bSmrg case $_G_directory_path in */*) ;; *) break ;; esac 9058c4a8e55Smrg 9068c4a8e55Smrg # ...otherwise throw away the child directory and loop 9073169be4bSmrg _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"` 9088c4a8e55Smrg done 9093169be4bSmrg _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'` 9108c4a8e55Smrg 9113169be4bSmrg func_mkdir_p_IFS=$IFS; IFS=: 9123169be4bSmrg for _G_dir in $_G_dir_list; do 9133169be4bSmrg IFS=$func_mkdir_p_IFS 9143169be4bSmrg # mkdir can fail with a 'File exist' error if two processes 9158c4a8e55Smrg # try to create one of the directories concurrently. Don't 9168c4a8e55Smrg # stop in that case! 9173169be4bSmrg $MKDIR "$_G_dir" 2>/dev/null || : 9188c4a8e55Smrg done 9193169be4bSmrg IFS=$func_mkdir_p_IFS 9208c4a8e55Smrg 9218c4a8e55Smrg # Bail out if we (or some other process) failed to create a directory. 9223169be4bSmrg test -d "$_G_directory_path" || \ 9233169be4bSmrg func_fatal_error "Failed to create '$1'" 9248c4a8e55Smrg fi 9258c4a8e55Smrg} 926b042e37fSmrg 927b042e37fSmrg 9283169be4bSmrg# func_mktempdir [BASENAME] 9293169be4bSmrg# ------------------------- 930b042e37fSmrg# Make a temporary directory that won't clash with other running 931b042e37fSmrg# libtool processes, and avoids race conditions if possible. If 9323169be4bSmrg# given, BASENAME is the basename for that directory. 933b042e37fSmrgfunc_mktempdir () 934b042e37fSmrg{ 9353169be4bSmrg $debug_cmd 9363169be4bSmrg 9373169be4bSmrg _G_template=${TMPDIR-/tmp}/${1-$progname} 938b042e37fSmrg 9393169be4bSmrg if test : = "$opt_dry_run"; then 940b042e37fSmrg # Return a directory name, but don't create it in dry-run mode 9413169be4bSmrg _G_tmpdir=$_G_template-$$ 942b042e37fSmrg else 943b042e37fSmrg 944b042e37fSmrg # If mktemp works, use that first and foremost 9453169be4bSmrg _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null` 946b042e37fSmrg 9473169be4bSmrg if test ! -d "$_G_tmpdir"; then 9488c4a8e55Smrg # Failing that, at least try and use $RANDOM to avoid a race 9493169be4bSmrg _G_tmpdir=$_G_template-${RANDOM-0}$$ 950b042e37fSmrg 9513169be4bSmrg func_mktempdir_umask=`umask` 9528c4a8e55Smrg umask 0077 9533169be4bSmrg $MKDIR "$_G_tmpdir" 9543169be4bSmrg umask $func_mktempdir_umask 955b042e37fSmrg fi 956b042e37fSmrg 957b042e37fSmrg # If we're not in dry-run mode, bomb out on failure 9583169be4bSmrg test -d "$_G_tmpdir" || \ 9593169be4bSmrg func_fatal_error "cannot create temporary directory '$_G_tmpdir'" 960b042e37fSmrg fi 961b042e37fSmrg 9623169be4bSmrg $ECHO "$_G_tmpdir" 963b042e37fSmrg} 964b042e37fSmrg 965b042e37fSmrg 9663169be4bSmrg# func_normal_abspath PATH 9673169be4bSmrg# ------------------------ 9683169be4bSmrg# Remove doubled-up and trailing slashes, "." path components, 9693169be4bSmrg# and cancel out any ".." path components in PATH after making 9703169be4bSmrg# it an absolute path. 9713169be4bSmrgfunc_normal_abspath () 972b042e37fSmrg{ 9733169be4bSmrg $debug_cmd 9748c4a8e55Smrg 9753169be4bSmrg # These SED scripts presuppose an absolute path with a trailing slash. 9763169be4bSmrg _G_pathcar='s|^/\([^/]*\).*$|\1|' 9773169be4bSmrg _G_pathcdr='s|^/[^/]*||' 9783169be4bSmrg _G_removedotparts=':dotsl 9793169be4bSmrg s|/\./|/|g 9803169be4bSmrg t dotsl 9813169be4bSmrg s|/\.$|/|' 9823169be4bSmrg _G_collapseslashes='s|/\{1,\}|/|g' 9833169be4bSmrg _G_finalslash='s|/*$|/|' 9843169be4bSmrg 9853169be4bSmrg # Start from root dir and reassemble the path. 9863169be4bSmrg func_normal_abspath_result= 9873169be4bSmrg func_normal_abspath_tpath=$1 9883169be4bSmrg func_normal_abspath_altnamespace= 9893169be4bSmrg case $func_normal_abspath_tpath in 9903169be4bSmrg "") 9913169be4bSmrg # Empty path, that just means $cwd. 9923169be4bSmrg func_stripname '' '/' "`pwd`" 9933169be4bSmrg func_normal_abspath_result=$func_stripname_result 9943169be4bSmrg return 9953169be4bSmrg ;; 9963169be4bSmrg # The next three entries are used to spot a run of precisely 9973169be4bSmrg # two leading slashes without using negated character classes; 9983169be4bSmrg # we take advantage of case's first-match behaviour. 9993169be4bSmrg ///*) 10003169be4bSmrg # Unusual form of absolute path, do nothing. 10013169be4bSmrg ;; 10023169be4bSmrg //*) 10033169be4bSmrg # Not necessarily an ordinary path; POSIX reserves leading '//' 10043169be4bSmrg # and for example Cygwin uses it to access remote file shares 10053169be4bSmrg # over CIFS/SMB, so we conserve a leading double slash if found. 10063169be4bSmrg func_normal_abspath_altnamespace=/ 10073169be4bSmrg ;; 10083169be4bSmrg /*) 10093169be4bSmrg # Absolute path, do nothing. 10108c4a8e55Smrg ;; 10118c4a8e55Smrg *) 10123169be4bSmrg # Relative path, prepend $cwd. 10133169be4bSmrg func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath 10143169be4bSmrg ;; 1015b042e37fSmrg esac 10163169be4bSmrg 10173169be4bSmrg # Cancel out all the simple stuff to save iterations. We also want 10183169be4bSmrg # the path to end with a slash for ease of parsing, so make sure 10193169be4bSmrg # there is one (and only one) here. 10203169be4bSmrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 10213169be4bSmrg -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"` 10223169be4bSmrg while :; do 10233169be4bSmrg # Processed it all yet? 10243169be4bSmrg if test / = "$func_normal_abspath_tpath"; then 10253169be4bSmrg # If we ascended to the root using ".." the result may be empty now. 10263169be4bSmrg if test -z "$func_normal_abspath_result"; then 10273169be4bSmrg func_normal_abspath_result=/ 10283169be4bSmrg fi 10293169be4bSmrg break 10303169be4bSmrg fi 10313169be4bSmrg func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ 10323169be4bSmrg -e "$_G_pathcar"` 10333169be4bSmrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 10343169be4bSmrg -e "$_G_pathcdr"` 10353169be4bSmrg # Figure out what to do with it 10363169be4bSmrg case $func_normal_abspath_tcomponent in 10373169be4bSmrg "") 10383169be4bSmrg # Trailing empty path component, ignore it. 10393169be4bSmrg ;; 10403169be4bSmrg ..) 10413169be4bSmrg # Parent dir; strip last assembled component from result. 10423169be4bSmrg func_dirname "$func_normal_abspath_result" 10433169be4bSmrg func_normal_abspath_result=$func_dirname_result 10443169be4bSmrg ;; 10453169be4bSmrg *) 10463169be4bSmrg # Actual path component, append it. 10473169be4bSmrg func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent" 10483169be4bSmrg ;; 10493169be4bSmrg esac 10503169be4bSmrg done 10513169be4bSmrg # Restore leading double-slash if one was found on entry. 10523169be4bSmrg func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result 10533169be4bSmrg} 10543169be4bSmrg 10553169be4bSmrg 10563169be4bSmrg# func_notquiet ARG... 10573169be4bSmrg# -------------------- 10583169be4bSmrg# Echo program name prefixed message only when not in quiet mode. 10593169be4bSmrgfunc_notquiet () 10603169be4bSmrg{ 10613169be4bSmrg $debug_cmd 10623169be4bSmrg 10633169be4bSmrg $opt_quiet || func_echo ${1+"$@"} 10643169be4bSmrg 10653169be4bSmrg # A bug in bash halts the script if the last line of a function 10663169be4bSmrg # fails when set -e is in force, so we need another command to 10673169be4bSmrg # work around that: 10683169be4bSmrg : 10693169be4bSmrg} 10703169be4bSmrg 10713169be4bSmrg 10723169be4bSmrg# func_relative_path SRCDIR DSTDIR 10733169be4bSmrg# -------------------------------- 10743169be4bSmrg# Set func_relative_path_result to the relative path from SRCDIR to DSTDIR. 10753169be4bSmrgfunc_relative_path () 10763169be4bSmrg{ 10773169be4bSmrg $debug_cmd 10783169be4bSmrg 10793169be4bSmrg func_relative_path_result= 10803169be4bSmrg func_normal_abspath "$1" 10813169be4bSmrg func_relative_path_tlibdir=$func_normal_abspath_result 10823169be4bSmrg func_normal_abspath "$2" 10833169be4bSmrg func_relative_path_tbindir=$func_normal_abspath_result 10843169be4bSmrg 10853169be4bSmrg # Ascend the tree starting from libdir 10863169be4bSmrg while :; do 10873169be4bSmrg # check if we have found a prefix of bindir 10883169be4bSmrg case $func_relative_path_tbindir in 10893169be4bSmrg $func_relative_path_tlibdir) 10903169be4bSmrg # found an exact match 10913169be4bSmrg func_relative_path_tcancelled= 10923169be4bSmrg break 10933169be4bSmrg ;; 10943169be4bSmrg $func_relative_path_tlibdir*) 10953169be4bSmrg # found a matching prefix 10963169be4bSmrg func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" 10973169be4bSmrg func_relative_path_tcancelled=$func_stripname_result 10983169be4bSmrg if test -z "$func_relative_path_result"; then 10993169be4bSmrg func_relative_path_result=. 11003169be4bSmrg fi 11013169be4bSmrg break 11023169be4bSmrg ;; 11033169be4bSmrg *) 11043169be4bSmrg func_dirname $func_relative_path_tlibdir 11053169be4bSmrg func_relative_path_tlibdir=$func_dirname_result 11063169be4bSmrg if test -z "$func_relative_path_tlibdir"; then 11073169be4bSmrg # Have to descend all the way to the root! 11083169be4bSmrg func_relative_path_result=../$func_relative_path_result 11093169be4bSmrg func_relative_path_tcancelled=$func_relative_path_tbindir 11103169be4bSmrg break 11113169be4bSmrg fi 11123169be4bSmrg func_relative_path_result=../$func_relative_path_result 11133169be4bSmrg ;; 11143169be4bSmrg esac 11153169be4bSmrg done 11163169be4bSmrg 11173169be4bSmrg # Now calculate path; take care to avoid doubling-up slashes. 11183169be4bSmrg func_stripname '' '/' "$func_relative_path_result" 11193169be4bSmrg func_relative_path_result=$func_stripname_result 11203169be4bSmrg func_stripname '/' '/' "$func_relative_path_tcancelled" 11213169be4bSmrg if test -n "$func_stripname_result"; then 11223169be4bSmrg func_append func_relative_path_result "/$func_stripname_result" 11233169be4bSmrg fi 11243169be4bSmrg 11253169be4bSmrg # Normalisation. If bindir is libdir, return '.' else relative path. 11263169be4bSmrg if test -n "$func_relative_path_result"; then 11273169be4bSmrg func_stripname './' '' "$func_relative_path_result" 11283169be4bSmrg func_relative_path_result=$func_stripname_result 11293169be4bSmrg fi 11303169be4bSmrg 11313169be4bSmrg test -n "$func_relative_path_result" || func_relative_path_result=. 11323169be4bSmrg 11333169be4bSmrg : 1134b042e37fSmrg} 1135b042e37fSmrg 1136b042e37fSmrg 11378d0bc965Smrg# func_quote_portable EVAL ARG 11388d0bc965Smrg# ---------------------------- 11398d0bc965Smrg# Internal function to portably implement func_quote_arg. Note that we still 11408d0bc965Smrg# keep attention to performance here so we as much as possible try to avoid 11418d0bc965Smrg# calling sed binary (so far O(N) complexity as long as func_append is O(1)). 11428d0bc965Smrgfunc_quote_portable () 11433169be4bSmrg{ 11443169be4bSmrg $debug_cmd 11453169be4bSmrg 11468d0bc965Smrg $require_check_ifs_backslash 11478d0bc965Smrg 11488d0bc965Smrg func_quote_portable_result=$2 11498d0bc965Smrg 11508d0bc965Smrg # one-time-loop (easy break) 11518d0bc965Smrg while true 11528d0bc965Smrg do 11538d0bc965Smrg if $1; then 11548d0bc965Smrg func_quote_portable_result=`$ECHO "$2" | $SED \ 11558d0bc965Smrg -e "$sed_double_quote_subst" -e "$sed_double_backslash"` 11568d0bc965Smrg break 11573169be4bSmrg fi 11583169be4bSmrg 11598d0bc965Smrg # Quote for eval. 11608d0bc965Smrg case $func_quote_portable_result in 11618d0bc965Smrg *[\\\`\"\$]*) 11628d0bc965Smrg # Fallback to sed for $func_check_bs_ifs_broken=:, or when the string 11638d0bc965Smrg # contains the shell wildcard characters. 11648d0bc965Smrg case $check_ifs_backshlash_broken$func_quote_portable_result in 11658d0bc965Smrg :*|*[\[\*\?]*) 11668d0bc965Smrg func_quote_portable_result=`$ECHO "$func_quote_portable_result" \ 11678d0bc965Smrg | $SED "$sed_quote_subst"` 11688d0bc965Smrg break 11698d0bc965Smrg ;; 11708d0bc965Smrg esac 11718d0bc965Smrg 11728d0bc965Smrg func_quote_portable_old_IFS=$IFS 11738d0bc965Smrg for _G_char in '\' '`' '"' '$' 11748d0bc965Smrg do 11758d0bc965Smrg # STATE($1) PREV($2) SEPARATOR($3) 11768d0bc965Smrg set start "" "" 11778d0bc965Smrg func_quote_portable_result=dummy"$_G_char$func_quote_portable_result$_G_char"dummy 11788d0bc965Smrg IFS=$_G_char 11798d0bc965Smrg for _G_part in $func_quote_portable_result 11808d0bc965Smrg do 11818d0bc965Smrg case $1 in 11828d0bc965Smrg quote) 11838d0bc965Smrg func_append func_quote_portable_result "$3$2" 11848d0bc965Smrg set quote "$_G_part" "\\$_G_char" 11858d0bc965Smrg ;; 11868d0bc965Smrg start) 11878d0bc965Smrg set first "" "" 11888d0bc965Smrg func_quote_portable_result= 11898d0bc965Smrg ;; 11908d0bc965Smrg first) 11918d0bc965Smrg set quote "$_G_part" "" 11928d0bc965Smrg ;; 11938d0bc965Smrg esac 11948d0bc965Smrg done 11958d0bc965Smrg done 11968d0bc965Smrg IFS=$func_quote_portable_old_IFS 11973169be4bSmrg ;; 11988d0bc965Smrg *) ;; 11993169be4bSmrg esac 12008d0bc965Smrg break 12013169be4bSmrg done 12028d0bc965Smrg 12038d0bc965Smrg func_quote_portable_unquoted_result=$func_quote_portable_result 12048d0bc965Smrg case $func_quote_portable_result in 12058d0bc965Smrg # double-quote args containing shell metacharacters to delay 12068d0bc965Smrg # word splitting, command substitution and variable expansion 12078d0bc965Smrg # for a subsequent eval. 12088d0bc965Smrg # many bourne shells cannot handle close brackets correctly 12098d0bc965Smrg # in scan sets, so we specify it separately. 12108d0bc965Smrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 12118d0bc965Smrg func_quote_portable_result=\"$func_quote_portable_result\" 12128d0bc965Smrg ;; 12138d0bc965Smrg esac 12143169be4bSmrg} 12153169be4bSmrg 12163169be4bSmrg 12178d0bc965Smrg# func_quotefast_eval ARG 12188d0bc965Smrg# ----------------------- 12198d0bc965Smrg# Quote one ARG (internal). This is equivalent to 'func_quote_arg eval ARG', 12208d0bc965Smrg# but optimized for speed. Result is stored in $func_quotefast_eval. 12218d0bc965Smrgif test xyes = `(x=; printf -v x %q yes; echo x"$x") 2>/dev/null`; then 12228d0bc965Smrg printf -v _GL_test_printf_tilde %q '~' 12238d0bc965Smrg if test '\~' = "$_GL_test_printf_tilde"; then 12248d0bc965Smrg func_quotefast_eval () 12258d0bc965Smrg { 12268d0bc965Smrg printf -v func_quotefast_eval_result %q "$1" 12278d0bc965Smrg } 12288d0bc965Smrg else 12298d0bc965Smrg # Broken older Bash implementations. Make those faster too if possible. 12308d0bc965Smrg func_quotefast_eval () 12318d0bc965Smrg { 12328d0bc965Smrg case $1 in 12338d0bc965Smrg '~'*) 12348d0bc965Smrg func_quote_portable false "$1" 12358d0bc965Smrg func_quotefast_eval_result=$func_quote_portable_result 12368d0bc965Smrg ;; 12378d0bc965Smrg *) 12388d0bc965Smrg printf -v func_quotefast_eval_result %q "$1" 12398d0bc965Smrg ;; 12408d0bc965Smrg esac 12418d0bc965Smrg } 12428d0bc965Smrg fi 12438d0bc965Smrgelse 12448d0bc965Smrg func_quotefast_eval () 12458d0bc965Smrg { 12468d0bc965Smrg func_quote_portable false "$1" 12478d0bc965Smrg func_quotefast_eval_result=$func_quote_portable_result 12488d0bc965Smrg } 12498d0bc965Smrgfi 12503169be4bSmrg 12518d0bc965Smrg 12528d0bc965Smrg# func_quote_arg MODEs ARG 12538d0bc965Smrg# ------------------------ 12548d0bc965Smrg# Quote one ARG to be evaled later. MODEs argument may contain zero or more 12558d0bc965Smrg# specifiers listed below separated by ',' character. This function returns two 12568d0bc965Smrg# values: 12578d0bc965Smrg# i) func_quote_arg_result 12588d0bc965Smrg# double-quoted (when needed), suitable for a subsequent eval 12598d0bc965Smrg# ii) func_quote_arg_unquoted_result 12608d0bc965Smrg# has all characters that are still active within double 12618d0bc965Smrg# quotes backslashified. Available only if 'unquoted' is specified. 12628d0bc965Smrg# 12638d0bc965Smrg# Available modes: 12648d0bc965Smrg# ---------------- 12658d0bc965Smrg# 'eval' (default) 12668d0bc965Smrg# - escape shell special characters 12678d0bc965Smrg# 'expand' 12688d0bc965Smrg# - the same as 'eval'; but do not quote variable references 12698d0bc965Smrg# 'pretty' 12708d0bc965Smrg# - request aesthetic output, i.e. '"a b"' instead of 'a\ b'. This might 12718d0bc965Smrg# be used later in func_quote to get output like: 'echo "a b"' instead 12728d0bc965Smrg# of 'echo a\ b'. This is slower than default on some shells. 12738d0bc965Smrg# 'unquoted' 12748d0bc965Smrg# - produce also $func_quote_arg_unquoted_result which does not contain 12758d0bc965Smrg# wrapping double-quotes. 12768d0bc965Smrg# 12778d0bc965Smrg# Examples for 'func_quote_arg pretty,unquoted string': 12788d0bc965Smrg# 12798d0bc965Smrg# string | *_result | *_unquoted_result 12808d0bc965Smrg# ------------+-----------------------+------------------- 12818d0bc965Smrg# " | \" | \" 12828d0bc965Smrg# a b | "a b" | a b 12838d0bc965Smrg# "a b" | "\"a b\"" | \"a b\" 12848d0bc965Smrg# * | "*" | * 12858d0bc965Smrg# z="${x-$y}" | "z=\"\${x-\$y}\"" | z=\"\${x-\$y}\" 12868d0bc965Smrg# 12878d0bc965Smrg# Examples for 'func_quote_arg pretty,unquoted,expand string': 12888d0bc965Smrg# 12898d0bc965Smrg# string | *_result | *_unquoted_result 12908d0bc965Smrg# --------------+---------------------+-------------------- 12918d0bc965Smrg# z="${x-$y}" | "z=\"${x-$y}\"" | z=\"${x-$y}\" 12928d0bc965Smrgfunc_quote_arg () 12938d0bc965Smrg{ 12948d0bc965Smrg _G_quote_expand=false 12958d0bc965Smrg case ,$1, in 12968d0bc965Smrg *,expand,*) 12978d0bc965Smrg _G_quote_expand=: 12988d0bc965Smrg ;; 12998c4a8e55Smrg esac 1300b042e37fSmrg 13018d0bc965Smrg case ,$1, in 13028d0bc965Smrg *,pretty,*|*,expand,*|*,unquoted,*) 13038d0bc965Smrg func_quote_portable $_G_quote_expand "$2" 13048d0bc965Smrg func_quote_arg_result=$func_quote_portable_result 13058d0bc965Smrg func_quote_arg_unquoted_result=$func_quote_portable_unquoted_result 13068d0bc965Smrg ;; 13078d0bc965Smrg *) 13088d0bc965Smrg # Faster quote-for-eval for some shells. 13098d0bc965Smrg func_quotefast_eval "$2" 13108d0bc965Smrg func_quote_arg_result=$func_quotefast_eval_result 13118c4a8e55Smrg ;; 13128c4a8e55Smrg esac 13138d0bc965Smrg} 13148d0bc965Smrg 13158c4a8e55Smrg 13168d0bc965Smrg# func_quote MODEs ARGs... 13178d0bc965Smrg# ------------------------ 13188d0bc965Smrg# Quote all ARGs to be evaled later and join them into single command. See 13198d0bc965Smrg# func_quote_arg's description for more info. 13208d0bc965Smrgfunc_quote () 13218d0bc965Smrg{ 13228d0bc965Smrg $debug_cmd 13238d0bc965Smrg _G_func_quote_mode=$1 ; shift 13248d0bc965Smrg func_quote_result= 13258d0bc965Smrg while test 0 -lt $#; do 13268d0bc965Smrg func_quote_arg "$_G_func_quote_mode" "$1" 13278d0bc965Smrg if test -n "$func_quote_result"; then 13288d0bc965Smrg func_append func_quote_result " $func_quote_arg_result" 13298d0bc965Smrg else 13308d0bc965Smrg func_append func_quote_result "$func_quote_arg_result" 13318d0bc965Smrg fi 13328d0bc965Smrg shift 13338d0bc965Smrg done 13343169be4bSmrg} 13353169be4bSmrg 13363169be4bSmrg 13373169be4bSmrg# func_stripname PREFIX SUFFIX NAME 13383169be4bSmrg# --------------------------------- 13393169be4bSmrg# strip PREFIX and SUFFIX from NAME, and store in func_stripname_result. 13403169be4bSmrg# PREFIX and SUFFIX must not contain globbing or regex special 13413169be4bSmrg# characters, hashes, percent signs, but SUFFIX may contain a leading 13423169be4bSmrg# dot (in which case that matches only a dot). 13433169be4bSmrgif test yes = "$_G_HAVE_XSI_OPS"; then 13443169be4bSmrg eval 'func_stripname () 13453169be4bSmrg { 13463169be4bSmrg $debug_cmd 13473169be4bSmrg 13483169be4bSmrg # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are 13493169be4bSmrg # positional parameters, so assign one to ordinary variable first. 13503169be4bSmrg func_stripname_result=$3 13513169be4bSmrg func_stripname_result=${func_stripname_result#"$1"} 13523169be4bSmrg func_stripname_result=${func_stripname_result%"$2"} 13533169be4bSmrg }' 13543169be4bSmrgelse 13553169be4bSmrg func_stripname () 13563169be4bSmrg { 13573169be4bSmrg $debug_cmd 13583169be4bSmrg 13593169be4bSmrg case $2 in 13603169be4bSmrg .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;; 13613169be4bSmrg *) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;; 13623169be4bSmrg esac 13633169be4bSmrg } 13643169be4bSmrgfi 13653169be4bSmrg 13663169be4bSmrg 13673169be4bSmrg# func_show_eval CMD [FAIL_EXP] 13683169be4bSmrg# ----------------------------- 13693169be4bSmrg# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is 13703169be4bSmrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 13713169be4bSmrg# is given, then evaluate it. 13723169be4bSmrgfunc_show_eval () 13733169be4bSmrg{ 13743169be4bSmrg $debug_cmd 13753169be4bSmrg 13763169be4bSmrg _G_cmd=$1 13773169be4bSmrg _G_fail_exp=${2-':'} 13783169be4bSmrg 13798d0bc965Smrg func_quote_arg pretty,expand "$_G_cmd" 13808d0bc965Smrg eval "func_notquiet $func_quote_arg_result" 13813169be4bSmrg 13823169be4bSmrg $opt_dry_run || { 13833169be4bSmrg eval "$_G_cmd" 13843169be4bSmrg _G_status=$? 13853169be4bSmrg if test 0 -ne "$_G_status"; then 13863169be4bSmrg eval "(exit $_G_status); $_G_fail_exp" 13873169be4bSmrg fi 13883169be4bSmrg } 13893169be4bSmrg} 13903169be4bSmrg 13913169be4bSmrg 13923169be4bSmrg# func_show_eval_locale CMD [FAIL_EXP] 13933169be4bSmrg# ------------------------------------ 13943169be4bSmrg# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is 13953169be4bSmrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 13963169be4bSmrg# is given, then evaluate it. Use the saved locale for evaluation. 13973169be4bSmrgfunc_show_eval_locale () 13983169be4bSmrg{ 13993169be4bSmrg $debug_cmd 14003169be4bSmrg 14013169be4bSmrg _G_cmd=$1 14023169be4bSmrg _G_fail_exp=${2-':'} 14033169be4bSmrg 14043169be4bSmrg $opt_quiet || { 14058d0bc965Smrg func_quote_arg expand,pretty "$_G_cmd" 14068d0bc965Smrg eval "func_echo $func_quote_arg_result" 14073169be4bSmrg } 14083169be4bSmrg 14093169be4bSmrg $opt_dry_run || { 14103169be4bSmrg eval "$_G_user_locale 14113169be4bSmrg $_G_cmd" 14123169be4bSmrg _G_status=$? 14133169be4bSmrg eval "$_G_safe_locale" 14143169be4bSmrg if test 0 -ne "$_G_status"; then 14153169be4bSmrg eval "(exit $_G_status); $_G_fail_exp" 14163169be4bSmrg fi 14173169be4bSmrg } 14183169be4bSmrg} 14193169be4bSmrg 14203169be4bSmrg 14213169be4bSmrg# func_tr_sh 14223169be4bSmrg# ---------- 14233169be4bSmrg# Turn $1 into a string suitable for a shell variable name. 14243169be4bSmrg# Result is stored in $func_tr_sh_result. All characters 14253169be4bSmrg# not in the set a-zA-Z0-9_ are replaced with '_'. Further, 14263169be4bSmrg# if $1 begins with a digit, a '_' is prepended as well. 14273169be4bSmrgfunc_tr_sh () 14283169be4bSmrg{ 14293169be4bSmrg $debug_cmd 14303169be4bSmrg 14313169be4bSmrg case $1 in 14323169be4bSmrg [0-9]* | *[!a-zA-Z0-9_]*) 14333169be4bSmrg func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'` 14343169be4bSmrg ;; 14353169be4bSmrg * ) 14363169be4bSmrg func_tr_sh_result=$1 14373169be4bSmrg ;; 14383169be4bSmrg esac 14393169be4bSmrg} 14403169be4bSmrg 14413169be4bSmrg 14423169be4bSmrg# func_verbose ARG... 14433169be4bSmrg# ------------------- 14443169be4bSmrg# Echo program name prefixed message in verbose mode only. 14453169be4bSmrgfunc_verbose () 14463169be4bSmrg{ 14473169be4bSmrg $debug_cmd 14483169be4bSmrg 14493169be4bSmrg $opt_verbose && func_echo "$*" 14503169be4bSmrg 14513169be4bSmrg : 14523169be4bSmrg} 14533169be4bSmrg 14543169be4bSmrg 14553169be4bSmrg# func_warn_and_continue ARG... 14563169be4bSmrg# ----------------------------- 14573169be4bSmrg# Echo program name prefixed warning message to standard error. 14583169be4bSmrgfunc_warn_and_continue () 14593169be4bSmrg{ 14603169be4bSmrg $debug_cmd 14613169be4bSmrg 14623169be4bSmrg $require_term_colors 14633169be4bSmrg 14643169be4bSmrg func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2 14653169be4bSmrg} 14663169be4bSmrg 14673169be4bSmrg 14683169be4bSmrg# func_warning CATEGORY ARG... 14693169be4bSmrg# ---------------------------- 14703169be4bSmrg# Echo program name prefixed warning message to standard error. Warning 14713169be4bSmrg# messages can be filtered according to CATEGORY, where this function 14723169be4bSmrg# elides messages where CATEGORY is not listed in the global variable 14733169be4bSmrg# 'opt_warning_types'. 14743169be4bSmrgfunc_warning () 14753169be4bSmrg{ 14763169be4bSmrg $debug_cmd 14773169be4bSmrg 14783169be4bSmrg # CATEGORY must be in the warning_categories list! 14793169be4bSmrg case " $warning_categories " in 14803169be4bSmrg *" $1 "*) ;; 14813169be4bSmrg *) func_internal_error "invalid warning category '$1'" ;; 14823169be4bSmrg esac 14833169be4bSmrg 14843169be4bSmrg _G_category=$1 14853169be4bSmrg shift 14863169be4bSmrg 14873169be4bSmrg case " $opt_warning_types " in 14883169be4bSmrg *" $_G_category "*) $warning_func ${1+"$@"} ;; 14893169be4bSmrg esac 1490b042e37fSmrg} 1491b042e37fSmrg 1492b042e37fSmrg 14933169be4bSmrg# func_sort_ver VER1 VER2 14943169be4bSmrg# ----------------------- 14953169be4bSmrg# 'sort -V' is not generally available. 14963169be4bSmrg# Note this deviates from the version comparison in automake 14973169be4bSmrg# in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a 14983169be4bSmrg# but this should suffice as we won't be specifying old 14993169be4bSmrg# version formats or redundant trailing .0 in bootstrap.conf. 15003169be4bSmrg# If we did want full compatibility then we should probably 15013169be4bSmrg# use m4_version_compare from autoconf. 15023169be4bSmrgfunc_sort_ver () 15033169be4bSmrg{ 15043169be4bSmrg $debug_cmd 15053169be4bSmrg 15063169be4bSmrg printf '%s\n%s\n' "$1" "$2" \ 15073169be4bSmrg | 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 15083169be4bSmrg} 15093169be4bSmrg 15103169be4bSmrg# func_lt_ver PREV CURR 15113169be4bSmrg# --------------------- 15123169be4bSmrg# Return true if PREV and CURR are in the correct order according to 15133169be4bSmrg# func_sort_ver, otherwise false. Use it like this: 15143169be4bSmrg# 15153169be4bSmrg# func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..." 15163169be4bSmrgfunc_lt_ver () 15173169be4bSmrg{ 15183169be4bSmrg $debug_cmd 15193169be4bSmrg 15203169be4bSmrg test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q` 15213169be4bSmrg} 15223169be4bSmrg 15233169be4bSmrg 15243169be4bSmrg# Local variables: 15253169be4bSmrg# mode: shell-script 15263169be4bSmrg# sh-indentation: 2 15273169be4bSmrg# eval: (add-hook 'before-save-hook 'time-stamp) 15283169be4bSmrg# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" 15293169be4bSmrg# time-stamp-time-zone: "UTC" 15303169be4bSmrg# End: 15313169be4bSmrg#! /bin/sh 15323169be4bSmrg 15333169be4bSmrg# A portable, pluggable option parser for Bourne shell. 15343169be4bSmrg# Written by Gary V. Vaughan, 2010 15353169be4bSmrg 15368d0bc965Smrg# This is free software. There is NO warranty; not even for 15378d0bc965Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 15388d0bc965Smrg# 15398d0bc965Smrg# Copyright (C) 2010-2019, 2021 Bootstrap Authors 15408d0bc965Smrg# 15418d0bc965Smrg# This file is dual licensed under the terms of the MIT license 15428d0bc965Smrg# <https://opensource.org/license/MIT>, and GPL version 2 or later 15438d0bc965Smrg# <http://www.gnu.org/licenses/gpl-2.0.html>. You must apply one of 15448d0bc965Smrg# these licenses when using or redistributing this software or any of 15458d0bc965Smrg# the files within it. See the URLs above, or the file `LICENSE` 15468d0bc965Smrg# included in the Bootstrap distribution for the full license texts. 15473169be4bSmrg 15488d0bc965Smrg# Please report bugs or propose patches to: 15498d0bc965Smrg# <https://github.com/gnulib-modules/bootstrap/issues> 15503169be4bSmrg 15518d0bc965Smrg# Set a version string for this script. 15528d0bc965Smrgscriptversion=2019-02-19.15; # UTC 15533169be4bSmrg 15543169be4bSmrg 15553169be4bSmrg## ------ ## 15563169be4bSmrg## Usage. ## 15573169be4bSmrg## ------ ## 15583169be4bSmrg 15593169be4bSmrg# This file is a library for parsing options in your shell scripts along 15603169be4bSmrg# with assorted other useful supporting features that you can make use 15613169be4bSmrg# of too. 15623169be4bSmrg# 15633169be4bSmrg# For the simplest scripts you might need only: 15643169be4bSmrg# 15653169be4bSmrg# #!/bin/sh 15663169be4bSmrg# . relative/path/to/funclib.sh 15673169be4bSmrg# . relative/path/to/options-parser 15683169be4bSmrg# scriptversion=1.0 15693169be4bSmrg# func_options ${1+"$@"} 15703169be4bSmrg# eval set dummy "$func_options_result"; shift 15713169be4bSmrg# ...rest of your script... 15723169be4bSmrg# 15733169be4bSmrg# In order for the '--version' option to work, you will need to have a 15743169be4bSmrg# suitably formatted comment like the one at the top of this file 15758d0bc965Smrg# starting with '# Written by ' and ending with '# Copyright'. 15763169be4bSmrg# 15773169be4bSmrg# For '-h' and '--help' to work, you will also need a one line 15783169be4bSmrg# description of your script's purpose in a comment directly above the 15793169be4bSmrg# '# Written by ' line, like the one at the top of this file. 15803169be4bSmrg# 15813169be4bSmrg# The default options also support '--debug', which will turn on shell 15823169be4bSmrg# execution tracing (see the comment above debug_cmd below for another 15833169be4bSmrg# use), and '--verbose' and the func_verbose function to allow your script 15843169be4bSmrg# to display verbose messages only when your user has specified 15853169be4bSmrg# '--verbose'. 15863169be4bSmrg# 15878d0bc965Smrg# After sourcing this file, you can plug in processing for additional 15883169be4bSmrg# options by amending the variables from the 'Configuration' section 15893169be4bSmrg# below, and following the instructions in the 'Option parsing' 15903169be4bSmrg# section further down. 15913169be4bSmrg 15923169be4bSmrg## -------------- ## 15933169be4bSmrg## Configuration. ## 15943169be4bSmrg## -------------- ## 15953169be4bSmrg 15963169be4bSmrg# You should override these variables in your script after sourcing this 15973169be4bSmrg# file so that they reflect the customisations you have added to the 15983169be4bSmrg# option parser. 15993169be4bSmrg 16003169be4bSmrg# The usage line for option parsing errors and the start of '-h' and 16013169be4bSmrg# '--help' output messages. You can embed shell variables for delayed 16023169be4bSmrg# expansion at the time the message is displayed, but you will need to 16033169be4bSmrg# quote other shell meta-characters carefully to prevent them being 16043169be4bSmrg# expanded when the contents are evaled. 16053169be4bSmrgusage='$progpath [OPTION]...' 16063169be4bSmrg 16073169be4bSmrg# Short help message in response to '-h' and '--help'. Add to this or 16083169be4bSmrg# override it after sourcing this library to reflect the full set of 16093169be4bSmrg# options your script accepts. 16103169be4bSmrgusage_message="\ 16113169be4bSmrg --debug enable verbose shell tracing 16123169be4bSmrg -W, --warnings=CATEGORY 16133169be4bSmrg report the warnings falling in CATEGORY [all] 16143169be4bSmrg -v, --verbose verbosely report processing 16153169be4bSmrg --version print version information and exit 16163169be4bSmrg -h, --help print short or long help message and exit 16173169be4bSmrg" 16183169be4bSmrg 16193169be4bSmrg# Additional text appended to 'usage_message' in response to '--help'. 16203169be4bSmrglong_help_message=" 16213169be4bSmrgWarning categories include: 16223169be4bSmrg 'all' show all warnings 16233169be4bSmrg 'none' turn off all the warnings 16243169be4bSmrg 'error' warnings are treated as fatal errors" 16253169be4bSmrg 16263169be4bSmrg# Help message printed before fatal option parsing errors. 16273169be4bSmrgfatal_help="Try '\$progname --help' for more information." 16283169be4bSmrg 16293169be4bSmrg 16303169be4bSmrg 16313169be4bSmrg## ------------------------- ## 16323169be4bSmrg## Hook function management. ## 16333169be4bSmrg## ------------------------- ## 16343169be4bSmrg 16353169be4bSmrg# This section contains functions for adding, removing, and running hooks 16368d0bc965Smrg# in the main code. A hook is just a list of function names that can be 16378d0bc965Smrg# run in order later on. 16383169be4bSmrg 16393169be4bSmrg# func_hookable FUNC_NAME 16403169be4bSmrg# ----------------------- 16413169be4bSmrg# Declare that FUNC_NAME will run hooks added with 16423169be4bSmrg# 'func_add_hook FUNC_NAME ...'. 16433169be4bSmrgfunc_hookable () 16443169be4bSmrg{ 16453169be4bSmrg $debug_cmd 16463169be4bSmrg 16473169be4bSmrg func_append hookable_fns " $1" 16483169be4bSmrg} 16493169be4bSmrg 16503169be4bSmrg 16513169be4bSmrg# func_add_hook FUNC_NAME HOOK_FUNC 16523169be4bSmrg# --------------------------------- 16533169be4bSmrg# Request that FUNC_NAME call HOOK_FUNC before it returns. FUNC_NAME must 16543169be4bSmrg# first have been declared "hookable" by a call to 'func_hookable'. 16553169be4bSmrgfunc_add_hook () 16563169be4bSmrg{ 16573169be4bSmrg $debug_cmd 16583169be4bSmrg 16593169be4bSmrg case " $hookable_fns " in 16603169be4bSmrg *" $1 "*) ;; 16613169be4bSmrg *) func_fatal_error "'$1' does not accept hook functions." ;; 16623169be4bSmrg esac 16633169be4bSmrg 16643169be4bSmrg eval func_append ${1}_hooks '" $2"' 16653169be4bSmrg} 16663169be4bSmrg 16673169be4bSmrg 16683169be4bSmrg# func_remove_hook FUNC_NAME HOOK_FUNC 16693169be4bSmrg# ------------------------------------ 16708d0bc965Smrg# Remove HOOK_FUNC from the list of hook functions to be called by 16718d0bc965Smrg# FUNC_NAME. 16723169be4bSmrgfunc_remove_hook () 16733169be4bSmrg{ 16743169be4bSmrg $debug_cmd 16753169be4bSmrg 16763169be4bSmrg eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`' 16773169be4bSmrg} 16783169be4bSmrg 16793169be4bSmrg 16808d0bc965Smrg# func_propagate_result FUNC_NAME_A FUNC_NAME_B 16818d0bc965Smrg# --------------------------------------------- 16828d0bc965Smrg# If the *_result variable of FUNC_NAME_A _is set_, assign its value to 16838d0bc965Smrg# *_result variable of FUNC_NAME_B. 16848d0bc965Smrgfunc_propagate_result () 16858d0bc965Smrg{ 16868d0bc965Smrg $debug_cmd 16878d0bc965Smrg 16888d0bc965Smrg func_propagate_result_result=: 16898d0bc965Smrg if eval "test \"\${${1}_result+set}\" = set" 16908d0bc965Smrg then 16918d0bc965Smrg eval "${2}_result=\$${1}_result" 16928d0bc965Smrg else 16938d0bc965Smrg func_propagate_result_result=false 16948d0bc965Smrg fi 16958d0bc965Smrg} 16968d0bc965Smrg 16978d0bc965Smrg 16983169be4bSmrg# func_run_hooks FUNC_NAME [ARG]... 16993169be4bSmrg# --------------------------------- 17003169be4bSmrg# Run all hook functions registered to FUNC_NAME. 17018d0bc965Smrg# It's assumed that the list of hook functions contains nothing more 17023169be4bSmrg# than a whitespace-delimited list of legal shell function names, and 17033169be4bSmrg# no effort is wasted trying to catch shell meta-characters or preserve 17043169be4bSmrg# whitespace. 17053169be4bSmrgfunc_run_hooks () 17063169be4bSmrg{ 17073169be4bSmrg $debug_cmd 17083169be4bSmrg 17093169be4bSmrg case " $hookable_fns " in 17103169be4bSmrg *" $1 "*) ;; 17118d0bc965Smrg *) func_fatal_error "'$1' does not support hook functions." ;; 17123169be4bSmrg esac 17133169be4bSmrg 17143169be4bSmrg eval _G_hook_fns=\$$1_hooks; shift 17153169be4bSmrg 17163169be4bSmrg for _G_hook in $_G_hook_fns; do 17178d0bc965Smrg func_unset "${_G_hook}_result" 17188d0bc965Smrg eval $_G_hook '${1+"$@"}' 17198d0bc965Smrg func_propagate_result $_G_hook func_run_hooks 17208d0bc965Smrg if $func_propagate_result_result; then 17218d0bc965Smrg eval set dummy "$func_run_hooks_result"; shift 17228d0bc965Smrg fi 17233169be4bSmrg done 17243169be4bSmrg} 17253169be4bSmrg 17263169be4bSmrg 17273169be4bSmrg 17283169be4bSmrg## --------------- ## 17293169be4bSmrg## Option parsing. ## 17303169be4bSmrg## --------------- ## 17313169be4bSmrg 17323169be4bSmrg# In order to add your own option parsing hooks, you must accept the 17338d0bc965Smrg# full positional parameter list from your hook function. You may remove 17348d0bc965Smrg# or edit any options that you action, and then pass back the remaining 17358d0bc965Smrg# unprocessed options in '<hooked_function_name>_result', escaped 17368d0bc965Smrg# suitably for 'eval'. 17378d0bc965Smrg# 17388d0bc965Smrg# The '<hooked_function_name>_result' variable is automatically unset 17398d0bc965Smrg# before your hook gets called; for best performance, only set the 17408d0bc965Smrg# *_result variable when necessary (i.e. don't call the 'func_quote' 17418d0bc965Smrg# function unnecessarily because it can be an expensive operation on some 17428d0bc965Smrg# machines). 17438d0bc965Smrg# 17448d0bc965Smrg# Like this: 17453169be4bSmrg# 17463169be4bSmrg# my_options_prep () 17473169be4bSmrg# { 17483169be4bSmrg# $debug_cmd 17493169be4bSmrg# 17503169be4bSmrg# # Extend the existing usage message. 17513169be4bSmrg# usage_message=$usage_message' 17523169be4bSmrg# -s, --silent don'\''t print informational messages 17533169be4bSmrg# ' 17548d0bc965Smrg# # No change in '$@' (ignored completely by this hook). Leave 17558d0bc965Smrg# # my_options_prep_result variable intact. 17563169be4bSmrg# } 17573169be4bSmrg# func_add_hook func_options_prep my_options_prep 17583169be4bSmrg# 17593169be4bSmrg# 17603169be4bSmrg# my_silent_option () 17613169be4bSmrg# { 17623169be4bSmrg# $debug_cmd 17633169be4bSmrg# 17648d0bc965Smrg# args_changed=false 17658d0bc965Smrg# 17668d0bc965Smrg# # Note that, for efficiency, we parse as many options as we can 17673169be4bSmrg# # recognise in a loop before passing the remainder back to the 17683169be4bSmrg# # caller on the first unrecognised argument we encounter. 17693169be4bSmrg# while test $# -gt 0; do 17703169be4bSmrg# opt=$1; shift 17713169be4bSmrg# case $opt in 17728d0bc965Smrg# --silent|-s) opt_silent=: 17738d0bc965Smrg# args_changed=: 17748d0bc965Smrg# ;; 17753169be4bSmrg# # Separate non-argument short options: 17763169be4bSmrg# -s*) func_split_short_opt "$_G_opt" 17773169be4bSmrg# set dummy "$func_split_short_opt_name" \ 17783169be4bSmrg# "-$func_split_short_opt_arg" ${1+"$@"} 17793169be4bSmrg# shift 17808d0bc965Smrg# args_changed=: 17813169be4bSmrg# ;; 17828d0bc965Smrg# *) # Make sure the first unrecognised option "$_G_opt" 17838d0bc965Smrg# # is added back to "$@" in case we need it later, 17848d0bc965Smrg# # if $args_changed was set to 'true'. 17858d0bc965Smrg# set dummy "$_G_opt" ${1+"$@"}; shift; break ;; 17863169be4bSmrg# esac 17873169be4bSmrg# done 17883169be4bSmrg# 17898d0bc965Smrg# # Only call 'func_quote' here if we processed at least one argument. 17908d0bc965Smrg# if $args_changed; then 17918d0bc965Smrg# func_quote eval ${1+"$@"} 17928d0bc965Smrg# my_silent_option_result=$func_quote_result 17938d0bc965Smrg# fi 17943169be4bSmrg# } 17953169be4bSmrg# func_add_hook func_parse_options my_silent_option 17963169be4bSmrg# 17973169be4bSmrg# 17983169be4bSmrg# my_option_validation () 17993169be4bSmrg# { 18003169be4bSmrg# $debug_cmd 18013169be4bSmrg# 18023169be4bSmrg# $opt_silent && $opt_verbose && func_fatal_help "\ 18033169be4bSmrg# '--silent' and '--verbose' options are mutually exclusive." 18043169be4bSmrg# } 18053169be4bSmrg# func_add_hook func_validate_options my_option_validation 18063169be4bSmrg# 18078d0bc965Smrg# You'll also need to manually amend $usage_message to reflect the extra 18083169be4bSmrg# options you parse. It's preferable to append if you can, so that 18093169be4bSmrg# multiple option parsing hooks can be added safely. 18103169be4bSmrg 18113169be4bSmrg 18128d0bc965Smrg# func_options_finish [ARG]... 18138d0bc965Smrg# ---------------------------- 18148d0bc965Smrg# Finishing the option parse loop (call 'func_options' hooks ATM). 18158d0bc965Smrgfunc_options_finish () 18168d0bc965Smrg{ 18178d0bc965Smrg $debug_cmd 18188d0bc965Smrg 18198d0bc965Smrg func_run_hooks func_options ${1+"$@"} 18208d0bc965Smrg func_propagate_result func_run_hooks func_options_finish 18218d0bc965Smrg} 18228d0bc965Smrg 18238d0bc965Smrg 18243169be4bSmrg# func_options [ARG]... 18253169be4bSmrg# --------------------- 18263169be4bSmrg# All the functions called inside func_options are hookable. See the 18273169be4bSmrg# individual implementations for details. 18283169be4bSmrgfunc_hookable func_options 18293169be4bSmrgfunc_options () 1830b042e37fSmrg{ 18313169be4bSmrg $debug_cmd 1832b042e37fSmrg 18338d0bc965Smrg _G_options_quoted=false 18348c4a8e55Smrg 18358d0bc965Smrg for my_func in options_prep parse_options validate_options options_finish 18368d0bc965Smrg do 18378d0bc965Smrg func_unset func_${my_func}_result 18388d0bc965Smrg func_unset func_run_hooks_result 18398d0bc965Smrg eval func_$my_func '${1+"$@"}' 18408d0bc965Smrg func_propagate_result func_$my_func func_options 18418d0bc965Smrg if $func_propagate_result_result; then 18428d0bc965Smrg eval set dummy "$func_options_result"; shift 18438d0bc965Smrg _G_options_quoted=: 18448d0bc965Smrg fi 18458d0bc965Smrg done 18463169be4bSmrg 18478d0bc965Smrg $_G_options_quoted || { 18488d0bc965Smrg # As we (func_options) are top-level options-parser function and 18498d0bc965Smrg # nobody quoted "$@" for us yet, we need to do it explicitly for 18508d0bc965Smrg # caller. 18518d0bc965Smrg func_quote eval ${1+"$@"} 18528d0bc965Smrg func_options_result=$func_quote_result 18538d0bc965Smrg } 1854b042e37fSmrg} 1855b042e37fSmrg 18568c4a8e55Smrg 18573169be4bSmrg# func_options_prep [ARG]... 18583169be4bSmrg# -------------------------- 18593169be4bSmrg# All initialisations required before starting the option parse loop. 18603169be4bSmrg# Note that when calling hook functions, we pass through the list of 18613169be4bSmrg# positional parameters. If a hook function modifies that list, and 18628d0bc965Smrg# needs to propagate that back to rest of this script, then the complete 18638d0bc965Smrg# modified list must be put in 'func_run_hooks_result' before returning. 18643169be4bSmrgfunc_hookable func_options_prep 18653169be4bSmrgfunc_options_prep () 1866b042e37fSmrg{ 18673169be4bSmrg $debug_cmd 1868b042e37fSmrg 18693169be4bSmrg # Option defaults: 18703169be4bSmrg opt_verbose=false 18713169be4bSmrg opt_warning_types= 18728c4a8e55Smrg 18733169be4bSmrg func_run_hooks func_options_prep ${1+"$@"} 18748d0bc965Smrg func_propagate_result func_run_hooks func_options_prep 1875b042e37fSmrg} 1876b042e37fSmrg 18773169be4bSmrg 18783169be4bSmrg# func_parse_options [ARG]... 18793169be4bSmrg# --------------------------- 18803169be4bSmrg# The main option parsing loop. 18813169be4bSmrgfunc_hookable func_parse_options 18823169be4bSmrgfunc_parse_options () 1883bd23fbfaSmrg{ 18843169be4bSmrg $debug_cmd 18853169be4bSmrg 18868d0bc965Smrg _G_parse_options_requote=false 18873169be4bSmrg # this just eases exit handling 18883169be4bSmrg while test $# -gt 0; do 18893169be4bSmrg # Defer to hook functions for initial option parsing, so they 18903169be4bSmrg # get priority in the event of reusing an option name. 18913169be4bSmrg func_run_hooks func_parse_options ${1+"$@"} 18928d0bc965Smrg func_propagate_result func_run_hooks func_parse_options 18938d0bc965Smrg if $func_propagate_result_result; then 18948d0bc965Smrg eval set dummy "$func_parse_options_result"; shift 18958d0bc965Smrg # Even though we may have changed "$@", we passed the "$@" array 18968d0bc965Smrg # down into the hook and it quoted it for us (because we are in 18978d0bc965Smrg # this if-branch). No need to quote it again. 18988d0bc965Smrg _G_parse_options_requote=false 18998d0bc965Smrg fi 19003169be4bSmrg 19013169be4bSmrg # Break out of the loop if we already parsed every option. 19023169be4bSmrg test $# -gt 0 || break 19033169be4bSmrg 19048d0bc965Smrg # We expect that one of the options parsed in this function matches 19058d0bc965Smrg # and thus we remove _G_opt from "$@" and need to re-quote. 19068d0bc965Smrg _G_match_parse_options=: 19073169be4bSmrg _G_opt=$1 19083169be4bSmrg shift 19093169be4bSmrg case $_G_opt in 19103169be4bSmrg --debug|-x) debug_cmd='set -x' 19118d0bc965Smrg func_echo "enabling shell trace mode" >&2 19123169be4bSmrg $debug_cmd 19133169be4bSmrg ;; 19143169be4bSmrg 19153169be4bSmrg --no-warnings|--no-warning|--no-warn) 19163169be4bSmrg set dummy --warnings none ${1+"$@"} 19173169be4bSmrg shift 19183169be4bSmrg ;; 19193169be4bSmrg 19203169be4bSmrg --warnings|--warning|-W) 19218d0bc965Smrg if test $# = 0 && func_missing_arg $_G_opt; then 19228d0bc965Smrg _G_parse_options_requote=: 19238d0bc965Smrg break 19248d0bc965Smrg fi 19253169be4bSmrg case " $warning_categories $1" in 19263169be4bSmrg *" $1 "*) 19273169be4bSmrg # trailing space prevents matching last $1 above 19283169be4bSmrg func_append_uniq opt_warning_types " $1" 19293169be4bSmrg ;; 19303169be4bSmrg *all) 19313169be4bSmrg opt_warning_types=$warning_categories 19323169be4bSmrg ;; 19333169be4bSmrg *none) 19343169be4bSmrg opt_warning_types=none 19353169be4bSmrg warning_func=: 19363169be4bSmrg ;; 19373169be4bSmrg *error) 19383169be4bSmrg opt_warning_types=$warning_categories 19393169be4bSmrg warning_func=func_fatal_error 19403169be4bSmrg ;; 19413169be4bSmrg *) 19423169be4bSmrg func_fatal_error \ 19433169be4bSmrg "unsupported warning category: '$1'" 19443169be4bSmrg ;; 19453169be4bSmrg esac 19463169be4bSmrg shift 19473169be4bSmrg ;; 19483169be4bSmrg 19493169be4bSmrg --verbose|-v) opt_verbose=: ;; 19503169be4bSmrg --version) func_version ;; 19513169be4bSmrg -\?|-h) func_usage ;; 19523169be4bSmrg --help) func_help ;; 19533169be4bSmrg 19543169be4bSmrg # Separate optargs to long options (plugins may need this): 19553169be4bSmrg --*=*) func_split_equals "$_G_opt" 19563169be4bSmrg set dummy "$func_split_equals_lhs" \ 19573169be4bSmrg "$func_split_equals_rhs" ${1+"$@"} 19583169be4bSmrg shift 19593169be4bSmrg ;; 19603169be4bSmrg 19613169be4bSmrg # Separate optargs to short options: 19623169be4bSmrg -W*) 19633169be4bSmrg func_split_short_opt "$_G_opt" 19643169be4bSmrg set dummy "$func_split_short_opt_name" \ 19653169be4bSmrg "$func_split_short_opt_arg" ${1+"$@"} 19663169be4bSmrg shift 19673169be4bSmrg ;; 19683169be4bSmrg 19693169be4bSmrg # Separate non-argument short options: 19703169be4bSmrg -\?*|-h*|-v*|-x*) 19713169be4bSmrg func_split_short_opt "$_G_opt" 19723169be4bSmrg set dummy "$func_split_short_opt_name" \ 19733169be4bSmrg "-$func_split_short_opt_arg" ${1+"$@"} 19743169be4bSmrg shift 19753169be4bSmrg ;; 19763169be4bSmrg 19778d0bc965Smrg --) _G_parse_options_requote=: ; break ;; 19783169be4bSmrg -*) func_fatal_help "unrecognised option: '$_G_opt'" ;; 19798d0bc965Smrg *) set dummy "$_G_opt" ${1+"$@"}; shift 19808d0bc965Smrg _G_match_parse_options=false 19818d0bc965Smrg break 19828d0bc965Smrg ;; 19833169be4bSmrg esac 19848d0bc965Smrg 19858d0bc965Smrg if $_G_match_parse_options; then 19868d0bc965Smrg _G_parse_options_requote=: 19878d0bc965Smrg fi 19883169be4bSmrg done 19893169be4bSmrg 19908d0bc965Smrg if $_G_parse_options_requote; then 19918d0bc965Smrg # save modified positional parameters for caller 19928d0bc965Smrg func_quote eval ${1+"$@"} 19938d0bc965Smrg func_parse_options_result=$func_quote_result 19948d0bc965Smrg fi 1995bd23fbfaSmrg} 1996bd23fbfaSmrg 1997b042e37fSmrg 19983169be4bSmrg# func_validate_options [ARG]... 19993169be4bSmrg# ------------------------------ 20003169be4bSmrg# Perform any sanity checks on option settings and/or unconsumed 20013169be4bSmrg# arguments. 20023169be4bSmrgfunc_hookable func_validate_options 20033169be4bSmrgfunc_validate_options () 20048c4a8e55Smrg{ 20053169be4bSmrg $debug_cmd 2006bd23fbfaSmrg 20073169be4bSmrg # Display all warnings if -W was not given. 20083169be4bSmrg test -n "$opt_warning_types" || opt_warning_types=" $warning_categories" 20093169be4bSmrg 20103169be4bSmrg func_run_hooks func_validate_options ${1+"$@"} 20118d0bc965Smrg func_propagate_result func_run_hooks func_validate_options 20123169be4bSmrg 20133169be4bSmrg # Bail if the options were screwed! 20143169be4bSmrg $exit_cmd $EXIT_FAILURE 20158c4a8e55Smrg} 20168c4a8e55Smrg 20173169be4bSmrg 20183169be4bSmrg 20193169be4bSmrg## ----------------- ## 20203169be4bSmrg## Helper functions. ## 20213169be4bSmrg## ----------------- ## 20223169be4bSmrg 20233169be4bSmrg# This section contains the helper functions used by the rest of the 20243169be4bSmrg# hookable option parser framework in ascii-betical order. 20253169be4bSmrg 20263169be4bSmrg 20273169be4bSmrg# func_fatal_help ARG... 20283169be4bSmrg# ---------------------- 20293169be4bSmrg# Echo program name prefixed message to standard error, followed by 20303169be4bSmrg# a help hint, and exit. 20313169be4bSmrgfunc_fatal_help () 20328c4a8e55Smrg{ 20333169be4bSmrg $debug_cmd 2034bd23fbfaSmrg 20353169be4bSmrg eval \$ECHO \""Usage: $usage"\" 20363169be4bSmrg eval \$ECHO \""$fatal_help"\" 20373169be4bSmrg func_error ${1+"$@"} 20383169be4bSmrg exit $EXIT_FAILURE 20398c4a8e55Smrg} 20408c4a8e55Smrg 20413169be4bSmrg 20423169be4bSmrg# func_help 20433169be4bSmrg# --------- 20443169be4bSmrg# Echo long help message to standard output and exit. 20458c4a8e55Smrgfunc_help () 20468c4a8e55Smrg{ 20473169be4bSmrg $debug_cmd 20483169be4bSmrg 20493169be4bSmrg func_usage_message 20503169be4bSmrg $ECHO "$long_help_message" 20513169be4bSmrg exit 0 20528c4a8e55Smrg} 20538c4a8e55Smrg 20543169be4bSmrg 20553169be4bSmrg# func_missing_arg ARGNAME 20563169be4bSmrg# ------------------------ 20578c4a8e55Smrg# Echo program name prefixed message to standard error and set global 20588c4a8e55Smrg# exit_cmd. 20598c4a8e55Smrgfunc_missing_arg () 20608c4a8e55Smrg{ 20613169be4bSmrg $debug_cmd 2062bd23fbfaSmrg 20633169be4bSmrg func_error "Missing argument for '$1'." 20648c4a8e55Smrg exit_cmd=exit 20658c4a8e55Smrg} 20668c4a8e55Smrg 20678c4a8e55Smrg 20683169be4bSmrg# func_split_equals STRING 20693169be4bSmrg# ------------------------ 20708d0bc965Smrg# Set func_split_equals_lhs and func_split_equals_rhs shell variables 20718d0bc965Smrg# after splitting STRING at the '=' sign. 20723169be4bSmrgtest -z "$_G_HAVE_XSI_OPS" \ 20733169be4bSmrg && (eval 'x=a/b/c; 20743169be4bSmrg test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ 20753169be4bSmrg && _G_HAVE_XSI_OPS=yes 20763169be4bSmrg 20773169be4bSmrgif test yes = "$_G_HAVE_XSI_OPS" 20783169be4bSmrgthen 20793169be4bSmrg # This is an XSI compatible shell, allowing a faster implementation... 20803169be4bSmrg eval 'func_split_equals () 20813169be4bSmrg { 20823169be4bSmrg $debug_cmd 20833169be4bSmrg 20843169be4bSmrg func_split_equals_lhs=${1%%=*} 20853169be4bSmrg func_split_equals_rhs=${1#*=} 20868d0bc965Smrg if test "x$func_split_equals_lhs" = "x$1"; then 20878d0bc965Smrg func_split_equals_rhs= 20888d0bc965Smrg fi 20893169be4bSmrg }' 20903169be4bSmrgelse 20913169be4bSmrg # ...otherwise fall back to using expr, which is often a shell builtin. 20923169be4bSmrg func_split_equals () 20933169be4bSmrg { 20943169be4bSmrg $debug_cmd 20953169be4bSmrg 20963169be4bSmrg func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'` 20973169be4bSmrg func_split_equals_rhs= 20988d0bc965Smrg test "x$func_split_equals_lhs=" = "x$1" \ 20993169be4bSmrg || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'` 21003169be4bSmrg } 21013169be4bSmrgfi #func_split_equals 21023169be4bSmrg 21033169be4bSmrg 21043169be4bSmrg# func_split_short_opt SHORTOPT 21053169be4bSmrg# ----------------------------- 2106bd23fbfaSmrg# Set func_split_short_opt_name and func_split_short_opt_arg shell 2107bd23fbfaSmrg# variables after splitting SHORTOPT after the 2nd character. 21083169be4bSmrgif test yes = "$_G_HAVE_XSI_OPS" 21093169be4bSmrgthen 21103169be4bSmrg # This is an XSI compatible shell, allowing a faster implementation... 21113169be4bSmrg eval 'func_split_short_opt () 21123169be4bSmrg { 21133169be4bSmrg $debug_cmd 21143169be4bSmrg 21153169be4bSmrg func_split_short_opt_arg=${1#??} 21163169be4bSmrg func_split_short_opt_name=${1%"$func_split_short_opt_arg"} 21173169be4bSmrg }' 21183169be4bSmrgelse 21193169be4bSmrg # ...otherwise fall back to using expr, which is often a shell builtin. 21203169be4bSmrg func_split_short_opt () 21213169be4bSmrg { 21223169be4bSmrg $debug_cmd 21233169be4bSmrg 21248d0bc965Smrg func_split_short_opt_name=`expr "x$1" : 'x\(-.\)'` 21253169be4bSmrg func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'` 21263169be4bSmrg } 21273169be4bSmrgfi #func_split_short_opt 21283169be4bSmrg 21293169be4bSmrg 21303169be4bSmrg# func_usage 21313169be4bSmrg# ---------- 21323169be4bSmrg# Echo short help message to standard output and exit. 21333169be4bSmrgfunc_usage () 2134bd23fbfaSmrg{ 21353169be4bSmrg $debug_cmd 2136bd23fbfaSmrg 21373169be4bSmrg func_usage_message 21383169be4bSmrg $ECHO "Run '$progname --help |${PAGER-more}' for full usage" 21393169be4bSmrg exit 0 21403169be4bSmrg} 2141bd23fbfaSmrg 2142bd23fbfaSmrg 21433169be4bSmrg# func_usage_message 21443169be4bSmrg# ------------------ 21453169be4bSmrg# Echo short help message to standard output. 21463169be4bSmrgfunc_usage_message () 2147bd23fbfaSmrg{ 21483169be4bSmrg $debug_cmd 2149bd23fbfaSmrg 21503169be4bSmrg eval \$ECHO \""Usage: $usage"\" 21513169be4bSmrg echo 21523169be4bSmrg $SED -n 's|^# || 21533169be4bSmrg /^Written by/{ 21543169be4bSmrg x;p;x 21553169be4bSmrg } 21563169be4bSmrg h 21573169be4bSmrg /^Written by/q' < "$progpath" 21583169be4bSmrg echo 21593169be4bSmrg eval \$ECHO \""$usage_message"\" 21603169be4bSmrg} 2161bd23fbfaSmrg 21628c4a8e55Smrg 21633169be4bSmrg# func_version 21643169be4bSmrg# ------------ 21653169be4bSmrg# Echo version message to standard output and exit. 21668d0bc965Smrg# The version message is extracted from the calling file's header 21678d0bc965Smrg# comments, with leading '# ' stripped: 21688d0bc965Smrg# 1. First display the progname and version 21698d0bc965Smrg# 2. Followed by the header comment line matching /^# Written by / 21708d0bc965Smrg# 3. Then a blank line followed by the first following line matching 21718d0bc965Smrg# /^# Copyright / 21728d0bc965Smrg# 4. Immediately followed by any lines between the previous matches, 21738d0bc965Smrg# except lines preceding the intervening completely blank line. 21748d0bc965Smrg# For example, see the header comments of this file. 21753169be4bSmrgfunc_version () 21763169be4bSmrg{ 21773169be4bSmrg $debug_cmd 21788c4a8e55Smrg 21793169be4bSmrg printf '%s\n' "$progname $scriptversion" 21803169be4bSmrg $SED -n ' 21818d0bc965Smrg /^# Written by /!b 21828d0bc965Smrg s|^# ||; p; n 21838d0bc965Smrg 21848d0bc965Smrg :fwd2blnk 21858d0bc965Smrg /./ { 21868d0bc965Smrg n 21878d0bc965Smrg b fwd2blnk 21883169be4bSmrg } 21898d0bc965Smrg p; n 21908d0bc965Smrg 21918d0bc965Smrg :holdwrnt 21928d0bc965Smrg s|^# || 21938d0bc965Smrg s|^# *$|| 21948d0bc965Smrg /^Copyright /!{ 21958d0bc965Smrg /./H 21968d0bc965Smrg n 21978d0bc965Smrg b holdwrnt 21983169be4bSmrg } 21998d0bc965Smrg 22008d0bc965Smrg s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2| 22018d0bc965Smrg G 22028d0bc965Smrg s|\(\n\)\n*|\1|g 22038d0bc965Smrg p; q' < "$progpath" 22048c4a8e55Smrg 22053169be4bSmrg exit $? 22063169be4bSmrg} 22078c4a8e55Smrg 2208b042e37fSmrg 22093169be4bSmrg# Local variables: 22103169be4bSmrg# mode: shell-script 22113169be4bSmrg# sh-indentation: 2 22123169be4bSmrg# eval: (add-hook 'before-save-hook 'time-stamp) 22138d0bc965Smrg# time-stamp-pattern: "30/scriptversion=%:y-%02m-%02d.%02H; # UTC" 22143169be4bSmrg# time-stamp-time-zone: "UTC" 22153169be4bSmrg# End: 2216b042e37fSmrg 22173169be4bSmrg# Set a version string. 22188d0bc965Smrgscriptversion='(GNU libtool) 2.4.7' 2219b042e37fSmrg 22208c4a8e55Smrg 22213169be4bSmrg# func_echo ARG... 22223169be4bSmrg# ---------------- 22233169be4bSmrg# Libtool also displays the current mode in messages, so override 22243169be4bSmrg# funclib.sh func_echo with this custom definition. 22253169be4bSmrgfunc_echo () 2226bd23fbfaSmrg{ 22273169be4bSmrg $debug_cmd 2228bd23fbfaSmrg 22293169be4bSmrg _G_message=$* 22303169be4bSmrg 22313169be4bSmrg func_echo_IFS=$IFS 22323169be4bSmrg IFS=$nl 22333169be4bSmrg for _G_line in $_G_message; do 22343169be4bSmrg IFS=$func_echo_IFS 22353169be4bSmrg $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line" 22363169be4bSmrg done 22373169be4bSmrg IFS=$func_echo_IFS 22383169be4bSmrg} 2239bd23fbfaSmrg 2240bd23fbfaSmrg 22413169be4bSmrg# func_warning ARG... 22423169be4bSmrg# ------------------- 22433169be4bSmrg# Libtool warnings are not categorized, so override funclib.sh 22443169be4bSmrg# func_warning with this simpler definition. 22453169be4bSmrgfunc_warning () 2246bd23fbfaSmrg{ 22473169be4bSmrg $debug_cmd 22483169be4bSmrg 22493169be4bSmrg $warning_func ${1+"$@"} 22503169be4bSmrg} 22513169be4bSmrg 2252bd23fbfaSmrg 22533169be4bSmrg## ---------------- ## 22543169be4bSmrg## Options parsing. ## 22553169be4bSmrg## ---------------- ## 22563169be4bSmrg 22573169be4bSmrg# Hook in the functions to make sure our own options are parsed during 22583169be4bSmrg# the option parsing loop. 22593169be4bSmrg 22603169be4bSmrgusage='$progpath [OPTION]... [MODE-ARG]...' 22613169be4bSmrg 22623169be4bSmrg# Short help message in response to '-h'. 22633169be4bSmrgusage_message="Options: 22643169be4bSmrg --config show all configuration variables 22653169be4bSmrg --debug enable verbose shell tracing 22663169be4bSmrg -n, --dry-run display commands without modifying any files 22673169be4bSmrg --features display basic configuration information and exit 22683169be4bSmrg --mode=MODE use operation mode MODE 22693169be4bSmrg --no-warnings equivalent to '-Wnone' 22703169be4bSmrg --preserve-dup-deps don't remove duplicate dependency libraries 22713169be4bSmrg --quiet, --silent don't print informational messages 22723169be4bSmrg --tag=TAG use configuration variables from tag TAG 22733169be4bSmrg -v, --verbose print more informational messages than default 22743169be4bSmrg --version print version information 22753169be4bSmrg -W, --warnings=CATEGORY report the warnings falling in CATEGORY [all] 22763169be4bSmrg -h, --help, --help-all print short, long, or detailed help message 22773169be4bSmrg" 2278bd23fbfaSmrg 22793169be4bSmrg# Additional text appended to 'usage_message' in response to '--help'. 22803169be4bSmrgfunc_help () 2281bd23fbfaSmrg{ 22823169be4bSmrg $debug_cmd 22833169be4bSmrg 22843169be4bSmrg func_usage_message 22853169be4bSmrg $ECHO "$long_help_message 22863169be4bSmrg 22873169be4bSmrgMODE must be one of the following: 22883169be4bSmrg 22893169be4bSmrg clean remove files from the build directory 22903169be4bSmrg compile compile a source file into a libtool object 22913169be4bSmrg execute automatically set library path, then run a program 22923169be4bSmrg finish complete the installation of libtool libraries 22933169be4bSmrg install install libraries or executables 22943169be4bSmrg link create a library or an executable 22953169be4bSmrg uninstall remove libraries from an installed directory 22963169be4bSmrg 22973169be4bSmrgMODE-ARGS vary depending on the MODE. When passed as first option, 22983169be4bSmrg'--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that. 22993169be4bSmrgTry '$progname --help --mode=MODE' for a more detailed description of MODE. 23003169be4bSmrg 23013169be4bSmrgWhen reporting a bug, please describe a test case to reproduce it and 23023169be4bSmrginclude the following information: 23033169be4bSmrg 23043169be4bSmrg host-triplet: $host 23053169be4bSmrg shell: $SHELL 23063169be4bSmrg compiler: $LTCC 23073169be4bSmrg compiler flags: $LTCFLAGS 23083169be4bSmrg linker: $LD (gnu? $with_gnu_ld) 23098d0bc965Smrg version: $progname (GNU libtool) 2.4.7 23103169be4bSmrg automake: `($AUTOMAKE --version) 2>/dev/null |$SED 1q` 23113169be4bSmrg autoconf: `($AUTOCONF --version) 2>/dev/null |$SED 1q` 23123169be4bSmrg 23133169be4bSmrgReport bugs to <bug-libtool@gnu.org>. 23148d0bc965SmrgGNU libtool home page: <http://www.gnu.org/software/libtool/>. 23153169be4bSmrgGeneral help using GNU software: <http://www.gnu.org/gethelp/>." 23163169be4bSmrg exit 0 23173169be4bSmrg} 2318bd23fbfaSmrg 2319bd23fbfaSmrg 23203169be4bSmrg# func_lo2o OBJECT-NAME 23213169be4bSmrg# --------------------- 23223169be4bSmrg# Transform OBJECT-NAME from a '.lo' suffix to the platform specific 23233169be4bSmrg# object suffix. 2324bd23fbfaSmrg 23253169be4bSmrglo2o=s/\\.lo\$/.$objext/ 23263169be4bSmrgo2lo=s/\\.$objext\$/.lo/ 2327bd23fbfaSmrg 23283169be4bSmrgif test yes = "$_G_HAVE_XSI_OPS"; then 23293169be4bSmrg eval 'func_lo2o () 23303169be4bSmrg { 23313169be4bSmrg case $1 in 23323169be4bSmrg *.lo) func_lo2o_result=${1%.lo}.$objext ;; 23333169be4bSmrg * ) func_lo2o_result=$1 ;; 23343169be4bSmrg esac 23353169be4bSmrg }' 23363169be4bSmrg 23373169be4bSmrg # func_xform LIBOBJ-OR-SOURCE 23383169be4bSmrg # --------------------------- 23393169be4bSmrg # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise) 23403169be4bSmrg # suffix to a '.lo' libtool-object suffix. 23413169be4bSmrg eval 'func_xform () 23423169be4bSmrg { 23433169be4bSmrg func_xform_result=${1%.*}.lo 23443169be4bSmrg }' 23453169be4bSmrgelse 23463169be4bSmrg # ...otherwise fall back to using sed. 23473169be4bSmrg func_lo2o () 23483169be4bSmrg { 23493169be4bSmrg func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"` 23503169be4bSmrg } 23513169be4bSmrg 23523169be4bSmrg func_xform () 23533169be4bSmrg { 23543169be4bSmrg func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'` 23553169be4bSmrg } 23563169be4bSmrgfi 2357bd23fbfaSmrg 2358bd23fbfaSmrg 23593169be4bSmrg# func_fatal_configuration ARG... 23603169be4bSmrg# ------------------------------- 23618c4a8e55Smrg# Echo program name prefixed message to standard error, followed by 23628c4a8e55Smrg# a configuration failure hint, and exit. 23638c4a8e55Smrgfunc_fatal_configuration () 23648c4a8e55Smrg{ 23658d0bc965Smrg func_fatal_error ${1+"$@"} \ 23663169be4bSmrg "See the $PACKAGE documentation for more information." \ 23673169be4bSmrg "Fatal configuration error." 23688c4a8e55Smrg} 2369b042e37fSmrg 2370b042e37fSmrg 23718c4a8e55Smrg# func_config 23723169be4bSmrg# ----------- 23738c4a8e55Smrg# Display the configuration for all the tags in this script. 23748c4a8e55Smrgfunc_config () 23758c4a8e55Smrg{ 23768c4a8e55Smrg re_begincf='^# ### BEGIN LIBTOOL' 23778c4a8e55Smrg re_endcf='^# ### END LIBTOOL' 23788c4a8e55Smrg 23798c4a8e55Smrg # Default configuration. 23808c4a8e55Smrg $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" 23818c4a8e55Smrg 2382b042e37fSmrg # Now print the configurations for the tags. 2383b042e37fSmrg for tagname in $taglist; do 23848c4a8e55Smrg $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" 2385b042e37fSmrg done 2386b042e37fSmrg 23878c4a8e55Smrg exit $? 23888c4a8e55Smrg} 2389b042e37fSmrg 23903169be4bSmrg 23918c4a8e55Smrg# func_features 23923169be4bSmrg# ------------- 23938c4a8e55Smrg# Display the features supported by this script. 23948c4a8e55Smrgfunc_features () 23958c4a8e55Smrg{ 2396706b6b52Smrg echo "host: $host" 23973169be4bSmrg if test yes = "$build_libtool_libs"; then 2398706b6b52Smrg echo "enable shared libraries" 2399b042e37fSmrg else 2400706b6b52Smrg echo "disable shared libraries" 2401b042e37fSmrg fi 24023169be4bSmrg if test yes = "$build_old_libs"; then 2403706b6b52Smrg echo "enable static libraries" 2404b042e37fSmrg else 2405706b6b52Smrg echo "disable static libraries" 2406b042e37fSmrg fi 24078c4a8e55Smrg 2408b042e37fSmrg exit $? 24098c4a8e55Smrg} 2410b042e37fSmrg 24113169be4bSmrg 24123169be4bSmrg# func_enable_tag TAGNAME 24133169be4bSmrg# ----------------------- 24148c4a8e55Smrg# Verify that TAGNAME is valid, and either flag an error and exit, or 24158c4a8e55Smrg# enable the TAGNAME tag. We also add TAGNAME to the global $taglist 24168c4a8e55Smrg# variable here. 24178c4a8e55Smrgfunc_enable_tag () 24188c4a8e55Smrg{ 24193169be4bSmrg # Global variable: 24203169be4bSmrg tagname=$1 2421b042e37fSmrg 24223169be4bSmrg re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" 24233169be4bSmrg re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" 24243169be4bSmrg sed_extractcf=/$re_begincf/,/$re_endcf/p 2425b042e37fSmrg 24263169be4bSmrg # Validate tagname. 24273169be4bSmrg case $tagname in 24283169be4bSmrg *[!-_A-Za-z0-9,/]*) 24293169be4bSmrg func_fatal_error "invalid tag name: $tagname" 24303169be4bSmrg ;; 24313169be4bSmrg esac 2432b042e37fSmrg 24333169be4bSmrg # Don't test for the "default" C tag, as we know it's 24343169be4bSmrg # there but not specially marked. 24353169be4bSmrg case $tagname in 24363169be4bSmrg CC) ;; 24378c4a8e55Smrg *) 24383169be4bSmrg if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then 24393169be4bSmrg taglist="$taglist $tagname" 24403169be4bSmrg 24413169be4bSmrg # Evaluate the configuration. Be careful to quote the path 24423169be4bSmrg # and the sed script, to avoid splitting on whitespace, but 24433169be4bSmrg # also don't use non-portable quotes within backquotes within 24443169be4bSmrg # quotes we have to do it in 2 steps: 24453169be4bSmrg extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` 24463169be4bSmrg eval "$extractedcf" 24473169be4bSmrg else 24483169be4bSmrg func_error "ignoring unknown tag $tagname" 24493169be4bSmrg fi 24503169be4bSmrg ;; 24513169be4bSmrg esac 24528c4a8e55Smrg} 2453b042e37fSmrg 24543169be4bSmrg 2455bd23fbfaSmrg# func_check_version_match 24563169be4bSmrg# ------------------------ 2457bd23fbfaSmrg# Ensure that we are using m4 macros, and libtool script from the same 2458bd23fbfaSmrg# release of libtool. 2459bd23fbfaSmrgfunc_check_version_match () 24608c4a8e55Smrg{ 24613169be4bSmrg if test "$package_revision" != "$macro_revision"; then 24623169be4bSmrg if test "$VERSION" != "$macro_version"; then 24633169be4bSmrg if test -z "$macro_version"; then 24643169be4bSmrg cat >&2 <<_LT_EOF 2465bd23fbfaSmrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 2466bd23fbfaSmrg$progname: definition of this LT_INIT comes from an older release. 2467bd23fbfaSmrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 2468bd23fbfaSmrg$progname: and run autoconf again. 2469bd23fbfaSmrg_LT_EOF 24703169be4bSmrg else 24713169be4bSmrg cat >&2 <<_LT_EOF 2472bd23fbfaSmrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 2473bd23fbfaSmrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version. 2474bd23fbfaSmrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 2475bd23fbfaSmrg$progname: and run autoconf again. 2476bd23fbfaSmrg_LT_EOF 24773169be4bSmrg fi 24783169be4bSmrg else 24793169be4bSmrg cat >&2 <<_LT_EOF 2480bd23fbfaSmrg$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, 2481bd23fbfaSmrg$progname: but the definition of this LT_INIT comes from revision $macro_revision. 2482bd23fbfaSmrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision 2483bd23fbfaSmrg$progname: of $PACKAGE $VERSION and run autoconf again. 2484bd23fbfaSmrg_LT_EOF 24853169be4bSmrg fi 24868c4a8e55Smrg 24873169be4bSmrg exit $EXIT_MISMATCH 24883169be4bSmrg fi 2489bd23fbfaSmrg} 2490bd23fbfaSmrg 2491bd23fbfaSmrg 24923169be4bSmrg# libtool_options_prep [ARG]... 24933169be4bSmrg# ----------------------------- 24943169be4bSmrg# Preparation for options parsed by libtool. 24953169be4bSmrglibtool_options_prep () 24963169be4bSmrg{ 24973169be4bSmrg $debug_mode 2498b042e37fSmrg 24993169be4bSmrg # Option defaults: 25003169be4bSmrg opt_config=false 25013169be4bSmrg opt_dlopen= 25023169be4bSmrg opt_dry_run=false 25033169be4bSmrg opt_help=false 25043169be4bSmrg opt_mode= 25053169be4bSmrg opt_preserve_dup_deps=false 25063169be4bSmrg opt_quiet=false 2507bd23fbfaSmrg 25083169be4bSmrg nonopt= 25093169be4bSmrg preserve_args= 2510bd23fbfaSmrg 25118d0bc965Smrg _G_rc_lt_options_prep=: 25128d0bc965Smrg 25133169be4bSmrg # Shorthand for --mode=foo, only valid as the first argument 25143169be4bSmrg case $1 in 25153169be4bSmrg clean|clea|cle|cl) 25163169be4bSmrg shift; set dummy --mode clean ${1+"$@"}; shift 25173169be4bSmrg ;; 25183169be4bSmrg compile|compil|compi|comp|com|co|c) 25193169be4bSmrg shift; set dummy --mode compile ${1+"$@"}; shift 25203169be4bSmrg ;; 25213169be4bSmrg execute|execut|execu|exec|exe|ex|e) 25223169be4bSmrg shift; set dummy --mode execute ${1+"$@"}; shift 25233169be4bSmrg ;; 25243169be4bSmrg finish|finis|fini|fin|fi|f) 25253169be4bSmrg shift; set dummy --mode finish ${1+"$@"}; shift 25263169be4bSmrg ;; 25273169be4bSmrg install|instal|insta|inst|ins|in|i) 25283169be4bSmrg shift; set dummy --mode install ${1+"$@"}; shift 25293169be4bSmrg ;; 25303169be4bSmrg link|lin|li|l) 25313169be4bSmrg shift; set dummy --mode link ${1+"$@"}; shift 25323169be4bSmrg ;; 25333169be4bSmrg uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) 25343169be4bSmrg shift; set dummy --mode uninstall ${1+"$@"}; shift 25353169be4bSmrg ;; 25368d0bc965Smrg *) 25378d0bc965Smrg _G_rc_lt_options_prep=false 25388d0bc965Smrg ;; 25393169be4bSmrg esac 25403169be4bSmrg 25418d0bc965Smrg if $_G_rc_lt_options_prep; then 25428d0bc965Smrg # Pass back the list of options. 25438d0bc965Smrg func_quote eval ${1+"$@"} 25448d0bc965Smrg libtool_options_prep_result=$func_quote_result 25458d0bc965Smrg fi 25463169be4bSmrg} 25473169be4bSmrgfunc_add_hook func_options_prep libtool_options_prep 2548bd23fbfaSmrg 2549bd23fbfaSmrg 25503169be4bSmrg# libtool_parse_options [ARG]... 25513169be4bSmrg# --------------------------------- 25523169be4bSmrg# Provide handling for libtool specific options. 25533169be4bSmrglibtool_parse_options () 2554bd23fbfaSmrg{ 25553169be4bSmrg $debug_cmd 25568c4a8e55Smrg 25578d0bc965Smrg _G_rc_lt_parse_options=false 25588d0bc965Smrg 25593169be4bSmrg # Perform our own loop to consume as many options as possible in 25603169be4bSmrg # each iteration. 25613169be4bSmrg while test $# -gt 0; do 25628d0bc965Smrg _G_match_lt_parse_options=: 25633169be4bSmrg _G_opt=$1 25643169be4bSmrg shift 25653169be4bSmrg case $_G_opt in 25663169be4bSmrg --dry-run|--dryrun|-n) 25673169be4bSmrg opt_dry_run=: 25683169be4bSmrg ;; 25693169be4bSmrg 25703169be4bSmrg --config) func_config ;; 25713169be4bSmrg 25723169be4bSmrg --dlopen|-dlopen) 25733169be4bSmrg opt_dlopen="${opt_dlopen+$opt_dlopen 25743169be4bSmrg}$1" 25753169be4bSmrg shift 25763169be4bSmrg ;; 25773169be4bSmrg 25783169be4bSmrg --preserve-dup-deps) 25793169be4bSmrg opt_preserve_dup_deps=: ;; 25803169be4bSmrg 25813169be4bSmrg --features) func_features ;; 25823169be4bSmrg 25833169be4bSmrg --finish) set dummy --mode finish ${1+"$@"}; shift ;; 25843169be4bSmrg 25853169be4bSmrg --help) opt_help=: ;; 25863169be4bSmrg 25873169be4bSmrg --help-all) opt_help=': help-all' ;; 25883169be4bSmrg 25893169be4bSmrg --mode) test $# = 0 && func_missing_arg $_G_opt && break 25903169be4bSmrg opt_mode=$1 25913169be4bSmrg case $1 in 25923169be4bSmrg # Valid mode arguments: 25933169be4bSmrg clean|compile|execute|finish|install|link|relink|uninstall) ;; 25943169be4bSmrg 25953169be4bSmrg # Catch anything else as an error 25963169be4bSmrg *) func_error "invalid argument for $_G_opt" 25973169be4bSmrg exit_cmd=exit 25983169be4bSmrg break 25993169be4bSmrg ;; 26003169be4bSmrg esac 26013169be4bSmrg shift 26023169be4bSmrg ;; 26033169be4bSmrg 26043169be4bSmrg --no-silent|--no-quiet) 26053169be4bSmrg opt_quiet=false 26063169be4bSmrg func_append preserve_args " $_G_opt" 26073169be4bSmrg ;; 26083169be4bSmrg 26093169be4bSmrg --no-warnings|--no-warning|--no-warn) 26103169be4bSmrg opt_warning=false 26113169be4bSmrg func_append preserve_args " $_G_opt" 26123169be4bSmrg ;; 26133169be4bSmrg 26143169be4bSmrg --no-verbose) 26153169be4bSmrg opt_verbose=false 26163169be4bSmrg func_append preserve_args " $_G_opt" 26173169be4bSmrg ;; 26183169be4bSmrg 26193169be4bSmrg --silent|--quiet) 26203169be4bSmrg opt_quiet=: 26213169be4bSmrg opt_verbose=false 26223169be4bSmrg func_append preserve_args " $_G_opt" 26233169be4bSmrg ;; 26243169be4bSmrg 26253169be4bSmrg --tag) test $# = 0 && func_missing_arg $_G_opt && break 26263169be4bSmrg opt_tag=$1 26273169be4bSmrg func_append preserve_args " $_G_opt $1" 26283169be4bSmrg func_enable_tag "$1" 26293169be4bSmrg shift 26303169be4bSmrg ;; 26313169be4bSmrg 26323169be4bSmrg --verbose|-v) opt_quiet=false 26333169be4bSmrg opt_verbose=: 26343169be4bSmrg func_append preserve_args " $_G_opt" 26353169be4bSmrg ;; 26363169be4bSmrg 26378d0bc965Smrg # An option not handled by this hook function: 26388d0bc965Smrg *) set dummy "$_G_opt" ${1+"$@"} ; shift 26398d0bc965Smrg _G_match_lt_parse_options=false 26408d0bc965Smrg break 26418d0bc965Smrg ;; 26423169be4bSmrg esac 26438d0bc965Smrg $_G_match_lt_parse_options && _G_rc_lt_parse_options=: 26443169be4bSmrg done 2645bd23fbfaSmrg 26468d0bc965Smrg if $_G_rc_lt_parse_options; then 26478d0bc965Smrg # save modified positional parameters for caller 26488d0bc965Smrg func_quote eval ${1+"$@"} 26498d0bc965Smrg libtool_parse_options_result=$func_quote_result 26508d0bc965Smrg fi 26513169be4bSmrg} 26523169be4bSmrgfunc_add_hook func_parse_options libtool_parse_options 26538c4a8e55Smrg 2654b042e37fSmrg 26558c4a8e55Smrg 26563169be4bSmrg# libtool_validate_options [ARG]... 26573169be4bSmrg# --------------------------------- 26583169be4bSmrg# Perform any sanity checks on option settings and/or unconsumed 26593169be4bSmrg# arguments. 26603169be4bSmrglibtool_validate_options () 26613169be4bSmrg{ 26623169be4bSmrg # save first non-option argument 26633169be4bSmrg if test 0 -lt $#; then 26643169be4bSmrg nonopt=$1 26653169be4bSmrg shift 26668c4a8e55Smrg fi 26678c4a8e55Smrg 26683169be4bSmrg # preserve --debug 26693169be4bSmrg test : = "$debug_cmd" || func_append preserve_args " --debug" 26708c4a8e55Smrg 26713169be4bSmrg case $host in 26723169be4bSmrg # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452 26733169be4bSmrg # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788 26743169be4bSmrg *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*) 26753169be4bSmrg # don't eliminate duplications in $postdeps and $predeps 26763169be4bSmrg opt_duplicate_compiler_generated_deps=: 26773169be4bSmrg ;; 26783169be4bSmrg *) 26793169be4bSmrg opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps 26803169be4bSmrg ;; 26813169be4bSmrg esac 26828c4a8e55Smrg 26833169be4bSmrg $opt_help || { 26843169be4bSmrg # Sanity checks first: 26853169be4bSmrg func_check_version_match 26868c4a8e55Smrg 26873169be4bSmrg test yes != "$build_libtool_libs" \ 26883169be4bSmrg && test yes != "$build_old_libs" \ 26893169be4bSmrg && func_fatal_configuration "not configured to build any kind of library" 26908c4a8e55Smrg 26913169be4bSmrg # Darwin sucks 26923169be4bSmrg eval std_shrext=\"$shrext_cmds\" 26933169be4bSmrg 26943169be4bSmrg # Only execute mode is allowed to have -dlopen flags. 26953169be4bSmrg if test -n "$opt_dlopen" && test execute != "$opt_mode"; then 26963169be4bSmrg func_error "unrecognized option '-dlopen'" 26973169be4bSmrg $ECHO "$help" 1>&2 26983169be4bSmrg exit $EXIT_FAILURE 26993169be4bSmrg fi 27003169be4bSmrg 27013169be4bSmrg # Change the help message to a mode-specific one. 27023169be4bSmrg generic_help=$help 27033169be4bSmrg help="Try '$progname --help --mode=$opt_mode' for more information." 27043169be4bSmrg } 27053169be4bSmrg 27063169be4bSmrg # Pass back the unparsed argument list 27078d0bc965Smrg func_quote eval ${1+"$@"} 27088d0bc965Smrg libtool_validate_options_result=$func_quote_result 2709bd23fbfaSmrg} 27103169be4bSmrgfunc_add_hook func_validate_options libtool_validate_options 27113169be4bSmrg 27128c4a8e55Smrg 27133169be4bSmrg# Process options as early as possible so that --help and --version 27143169be4bSmrg# can return quickly. 27153169be4bSmrgfunc_options ${1+"$@"} 27163169be4bSmrgeval set dummy "$func_options_result"; shift 27178c4a8e55Smrg 2718b042e37fSmrg 2719b042e37fSmrg 2720bd23fbfaSmrg## ----------- ## 2721bd23fbfaSmrg## Main. ## 2722bd23fbfaSmrg## ----------- ## 2723b042e37fSmrg 27243169be4bSmrgmagic='%%%MAGIC variable%%%' 27253169be4bSmrgmagic_exe='%%%MAGIC EXE variable%%%' 27263169be4bSmrg 27273169be4bSmrg# Global variables. 27283169be4bSmrgextracted_archives= 27293169be4bSmrgextracted_serial=0 27303169be4bSmrg 27313169be4bSmrg# If this variable is set in any of the actions, the command in it 27323169be4bSmrg# will be execed at the end. This prevents here-documents from being 27333169be4bSmrg# left over by shells. 27343169be4bSmrgexec_cmd= 27353169be4bSmrg 27363169be4bSmrg 27373169be4bSmrg# A function that is used when there is no print builtin or printf. 27383169be4bSmrgfunc_fallback_echo () 27393169be4bSmrg{ 27403169be4bSmrg eval 'cat <<_LTECHO_EOF 27413169be4bSmrg$1 27423169be4bSmrg_LTECHO_EOF' 27433169be4bSmrg} 27443169be4bSmrg 27453169be4bSmrg# func_generated_by_libtool 27463169be4bSmrg# True iff stdin has been generated by Libtool. This function is only 27473169be4bSmrg# a basic sanity check; it will hardly flush out determined imposters. 27483169be4bSmrgfunc_generated_by_libtool_p () 27493169be4bSmrg{ 27503169be4bSmrg $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 27513169be4bSmrg} 27523169be4bSmrg 27538c4a8e55Smrg# func_lalib_p file 27543169be4bSmrg# True iff FILE is a libtool '.la' library or '.lo' object file. 27558c4a8e55Smrg# This function is only a basic sanity check; it will hardly flush out 27568c4a8e55Smrg# determined imposters. 27578c4a8e55Smrgfunc_lalib_p () 27588c4a8e55Smrg{ 27598c4a8e55Smrg test -f "$1" && 27603169be4bSmrg $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p 27618c4a8e55Smrg} 2762b042e37fSmrg 27638c4a8e55Smrg# func_lalib_unsafe_p file 27643169be4bSmrg# True iff FILE is a libtool '.la' library or '.lo' object file. 27658c4a8e55Smrg# This function implements the same check as func_lalib_p without 27668c4a8e55Smrg# resorting to external programs. To this end, it redirects stdin and 27678c4a8e55Smrg# closes it afterwards, without saving the original file descriptor. 27688c4a8e55Smrg# As a safety measure, use it only where a negative result would be 27693169be4bSmrg# fatal anyway. Works if 'file' does not exist. 27708c4a8e55Smrgfunc_lalib_unsafe_p () 27718c4a8e55Smrg{ 27728c4a8e55Smrg lalib_p=no 27738c4a8e55Smrg if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then 27748c4a8e55Smrg for lalib_p_l in 1 2 3 4 27758c4a8e55Smrg do 27768c4a8e55Smrg read lalib_p_line 27773169be4bSmrg case $lalib_p_line in 27788c4a8e55Smrg \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; 27798c4a8e55Smrg esac 27808c4a8e55Smrg done 27818c4a8e55Smrg exec 0<&5 5<&- 27828c4a8e55Smrg fi 27833169be4bSmrg test yes = "$lalib_p" 27848c4a8e55Smrg} 2785b042e37fSmrg 27868c4a8e55Smrg# func_ltwrapper_script_p file 27878c4a8e55Smrg# True iff FILE is a libtool wrapper script 27888c4a8e55Smrg# This function is only a basic sanity check; it will hardly flush out 27898c4a8e55Smrg# determined imposters. 27908c4a8e55Smrgfunc_ltwrapper_script_p () 27918c4a8e55Smrg{ 27923169be4bSmrg test -f "$1" && 27933169be4bSmrg $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p 27948c4a8e55Smrg} 2795b042e37fSmrg 27968c4a8e55Smrg# func_ltwrapper_executable_p file 27978c4a8e55Smrg# True iff FILE is a libtool wrapper executable 27988c4a8e55Smrg# This function is only a basic sanity check; it will hardly flush out 27998c4a8e55Smrg# determined imposters. 28008c4a8e55Smrgfunc_ltwrapper_executable_p () 28018c4a8e55Smrg{ 28028c4a8e55Smrg func_ltwrapper_exec_suffix= 28038c4a8e55Smrg case $1 in 28048c4a8e55Smrg *.exe) ;; 28058c4a8e55Smrg *) func_ltwrapper_exec_suffix=.exe ;; 28068c4a8e55Smrg esac 28078c4a8e55Smrg $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 28088c4a8e55Smrg} 2809b042e37fSmrg 28108c4a8e55Smrg# func_ltwrapper_scriptname file 28118c4a8e55Smrg# Assumes file is an ltwrapper_executable 28128c4a8e55Smrg# uses $file to determine the appropriate filename for a 28138c4a8e55Smrg# temporary ltwrapper_script. 28148c4a8e55Smrgfunc_ltwrapper_scriptname () 28158c4a8e55Smrg{ 2816bd23fbfaSmrg func_dirname_and_basename "$1" "" "." 2817bd23fbfaSmrg func_stripname '' '.exe' "$func_basename_result" 28183169be4bSmrg func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper 28198c4a8e55Smrg} 2820b042e37fSmrg 28218c4a8e55Smrg# func_ltwrapper_p file 28228c4a8e55Smrg# True iff FILE is a libtool wrapper script or wrapper executable 28238c4a8e55Smrg# This function is only a basic sanity check; it will hardly flush out 28248c4a8e55Smrg# determined imposters. 28258c4a8e55Smrgfunc_ltwrapper_p () 28268c4a8e55Smrg{ 28278c4a8e55Smrg func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" 28288c4a8e55Smrg} 28298c4a8e55Smrg 28308c4a8e55Smrg 28318c4a8e55Smrg# func_execute_cmds commands fail_cmd 28328c4a8e55Smrg# Execute tilde-delimited COMMANDS. 28338c4a8e55Smrg# If FAIL_CMD is given, eval that upon failure. 28348c4a8e55Smrg# FAIL_CMD may read-access the current command in variable CMD! 28358c4a8e55Smrgfunc_execute_cmds () 28368c4a8e55Smrg{ 28373169be4bSmrg $debug_cmd 28383169be4bSmrg 28398c4a8e55Smrg save_ifs=$IFS; IFS='~' 28408c4a8e55Smrg for cmd in $1; do 28413169be4bSmrg IFS=$sp$nl 28428c4a8e55Smrg eval cmd=\"$cmd\" 28433169be4bSmrg IFS=$save_ifs 28448c4a8e55Smrg func_show_eval "$cmd" "${2-:}" 28458c4a8e55Smrg done 28468c4a8e55Smrg IFS=$save_ifs 28478c4a8e55Smrg} 28488c4a8e55Smrg 28498c4a8e55Smrg 28508c4a8e55Smrg# func_source file 28518c4a8e55Smrg# Source FILE, adding directory component if necessary. 28528c4a8e55Smrg# Note that it is not necessary on cygwin/mingw to append a dot to 28538c4a8e55Smrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe 28548c4a8e55Smrg# behavior happens only for exec(3), not for open(2)! Also, sourcing 28553169be4bSmrg# 'FILE.' does not work on cygwin managed mounts. 28568c4a8e55Smrgfunc_source () 28578c4a8e55Smrg{ 28583169be4bSmrg $debug_cmd 28593169be4bSmrg 28608c4a8e55Smrg case $1 in 28618c4a8e55Smrg */* | *\\*) . "$1" ;; 28628c4a8e55Smrg *) . "./$1" ;; 28638c4a8e55Smrg esac 28648c4a8e55Smrg} 28658c4a8e55Smrg 28668c4a8e55Smrg 2867bd23fbfaSmrg# func_resolve_sysroot PATH 2868bd23fbfaSmrg# Replace a leading = in PATH with a sysroot. Store the result into 2869bd23fbfaSmrg# func_resolve_sysroot_result 2870bd23fbfaSmrgfunc_resolve_sysroot () 2871bd23fbfaSmrg{ 2872bd23fbfaSmrg func_resolve_sysroot_result=$1 2873bd23fbfaSmrg case $func_resolve_sysroot_result in 2874bd23fbfaSmrg =*) 2875bd23fbfaSmrg func_stripname '=' '' "$func_resolve_sysroot_result" 2876bd23fbfaSmrg func_resolve_sysroot_result=$lt_sysroot$func_stripname_result 2877bd23fbfaSmrg ;; 2878bd23fbfaSmrg esac 2879bd23fbfaSmrg} 2880bd23fbfaSmrg 2881bd23fbfaSmrg# func_replace_sysroot PATH 2882bd23fbfaSmrg# If PATH begins with the sysroot, replace it with = and 2883bd23fbfaSmrg# store the result into func_replace_sysroot_result. 2884bd23fbfaSmrgfunc_replace_sysroot () 2885bd23fbfaSmrg{ 28863169be4bSmrg case $lt_sysroot:$1 in 2887bd23fbfaSmrg ?*:"$lt_sysroot"*) 2888bd23fbfaSmrg func_stripname "$lt_sysroot" '' "$1" 28893169be4bSmrg func_replace_sysroot_result='='$func_stripname_result 2890bd23fbfaSmrg ;; 2891bd23fbfaSmrg *) 2892bd23fbfaSmrg # Including no sysroot. 2893bd23fbfaSmrg func_replace_sysroot_result=$1 2894bd23fbfaSmrg ;; 2895bd23fbfaSmrg esac 2896bd23fbfaSmrg} 2897bd23fbfaSmrg 28988c4a8e55Smrg# func_infer_tag arg 28998c4a8e55Smrg# Infer tagged configuration to use if any are available and 29008c4a8e55Smrg# if one wasn't chosen via the "--tag" command line option. 29018c4a8e55Smrg# Only attempt this if the compiler in the base compile 29028c4a8e55Smrg# command doesn't match the default compiler. 29038c4a8e55Smrg# arg is usually of the form 'gcc ...' 29048c4a8e55Smrgfunc_infer_tag () 29058c4a8e55Smrg{ 29063169be4bSmrg $debug_cmd 29073169be4bSmrg 29088c4a8e55Smrg if test -n "$available_tags" && test -z "$tagname"; then 29098c4a8e55Smrg CC_quoted= 29108c4a8e55Smrg for arg in $CC; do 2911bd23fbfaSmrg func_append_quoted CC_quoted "$arg" 29128c4a8e55Smrg done 2913706b6b52Smrg CC_expanded=`func_echo_all $CC` 2914706b6b52Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 29158c4a8e55Smrg case $@ in 29168c4a8e55Smrg # Blanks in the command may have been stripped by the calling shell, 29178c4a8e55Smrg # but not from the CC environment variable when configure was run. 2918706b6b52Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 2919706b6b52Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; 29208c4a8e55Smrg # Blanks at the start of $base_compile will cause this to fail 29218c4a8e55Smrg # if we don't check for them as well. 29228c4a8e55Smrg *) 29238c4a8e55Smrg for z in $available_tags; do 29248c4a8e55Smrg if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then 29258c4a8e55Smrg # Evaluate the configuration. 29263169be4bSmrg eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" 29278c4a8e55Smrg CC_quoted= 29288c4a8e55Smrg for arg in $CC; do 29298c4a8e55Smrg # Double-quote args containing other shell metacharacters. 2930bd23fbfaSmrg func_append_quoted CC_quoted "$arg" 29318c4a8e55Smrg done 2932706b6b52Smrg CC_expanded=`func_echo_all $CC` 2933706b6b52Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 29348c4a8e55Smrg case "$@ " in 2935706b6b52Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 2936706b6b52Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) 29378c4a8e55Smrg # The compiler in the base compile command matches 29388c4a8e55Smrg # the one in the tagged configuration. 29398c4a8e55Smrg # Assume this is the tagged configuration we want. 29408c4a8e55Smrg tagname=$z 29418c4a8e55Smrg break 29428c4a8e55Smrg ;; 29438c4a8e55Smrg esac 29448c4a8e55Smrg fi 29458c4a8e55Smrg done 29468c4a8e55Smrg # If $tagname still isn't set, then no tagged configuration 29478c4a8e55Smrg # was found and let the user know that the "--tag" command 29488c4a8e55Smrg # line option must be used. 29498c4a8e55Smrg if test -z "$tagname"; then 29508c4a8e55Smrg func_echo "unable to infer tagged configuration" 29513169be4bSmrg func_fatal_error "specify a tag with '--tag'" 29528c4a8e55Smrg# else 29538c4a8e55Smrg# func_verbose "using $tagname tagged configuration" 29548c4a8e55Smrg fi 29558c4a8e55Smrg ;; 29568c4a8e55Smrg esac 29578c4a8e55Smrg fi 29588c4a8e55Smrg} 29598c4a8e55Smrg 29608c4a8e55Smrg 29618c4a8e55Smrg 2962bd23fbfaSmrg# func_write_libtool_object output_name pic_name nonpic_name 2963bd23fbfaSmrg# Create a libtool object file (analogous to a ".la" file), 2964bd23fbfaSmrg# but don't create it if we're doing a dry run. 2965bd23fbfaSmrgfunc_write_libtool_object () 2966bd23fbfaSmrg{ 29673169be4bSmrg write_libobj=$1 29683169be4bSmrg if test yes = "$build_libtool_libs"; then 29693169be4bSmrg write_lobj=\'$2\' 2970bd23fbfaSmrg else 2971bd23fbfaSmrg write_lobj=none 2972bd23fbfaSmrg fi 2973bd23fbfaSmrg 29743169be4bSmrg if test yes = "$build_old_libs"; then 29753169be4bSmrg write_oldobj=\'$3\' 2976bd23fbfaSmrg else 2977bd23fbfaSmrg write_oldobj=none 2978bd23fbfaSmrg fi 2979bd23fbfaSmrg 2980bd23fbfaSmrg $opt_dry_run || { 2981bd23fbfaSmrg cat >${write_libobj}T <<EOF 2982bd23fbfaSmrg# $write_libobj - a libtool object file 29833169be4bSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 2984bd23fbfaSmrg# 2985bd23fbfaSmrg# Please DO NOT delete this file! 2986bd23fbfaSmrg# It is necessary for linking the library. 2987bd23fbfaSmrg 2988bd23fbfaSmrg# Name of the PIC object. 2989bd23fbfaSmrgpic_object=$write_lobj 2990bd23fbfaSmrg 2991bd23fbfaSmrg# Name of the non-PIC object 2992bd23fbfaSmrgnon_pic_object=$write_oldobj 2993bd23fbfaSmrg 2994bd23fbfaSmrgEOF 29953169be4bSmrg $MV "${write_libobj}T" "$write_libobj" 2996bd23fbfaSmrg } 2997bd23fbfaSmrg} 2998bd23fbfaSmrg 2999bd23fbfaSmrg 3000bd23fbfaSmrg################################################## 3001bd23fbfaSmrg# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS # 3002bd23fbfaSmrg################################################## 3003bd23fbfaSmrg 3004bd23fbfaSmrg# func_convert_core_file_wine_to_w32 ARG 3005bd23fbfaSmrg# Helper function used by file name conversion functions when $build is *nix, 3006bd23fbfaSmrg# and $host is mingw, cygwin, or some other w32 environment. Relies on a 3007bd23fbfaSmrg# correctly configured wine environment available, with the winepath program 3008bd23fbfaSmrg# in $build's $PATH. 3009bd23fbfaSmrg# 3010bd23fbfaSmrg# ARG is the $build file name to be converted to w32 format. 3011bd23fbfaSmrg# Result is available in $func_convert_core_file_wine_to_w32_result, and will 3012bd23fbfaSmrg# be empty on error (or when ARG is empty) 3013bd23fbfaSmrgfunc_convert_core_file_wine_to_w32 () 3014bd23fbfaSmrg{ 30153169be4bSmrg $debug_cmd 30163169be4bSmrg 30173169be4bSmrg func_convert_core_file_wine_to_w32_result=$1 3018bd23fbfaSmrg if test -n "$1"; then 3019bd23fbfaSmrg # Unfortunately, winepath does not exit with a non-zero error code, so we 3020bd23fbfaSmrg # are forced to check the contents of stdout. On the other hand, if the 3021bd23fbfaSmrg # command is not found, the shell will set an exit code of 127 and print 3022bd23fbfaSmrg # *an error message* to stdout. So we must check for both error code of 3023bd23fbfaSmrg # zero AND non-empty stdout, which explains the odd construction: 3024bd23fbfaSmrg func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null` 30253169be4bSmrg if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then 3026bd23fbfaSmrg func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | 30273169be4bSmrg $SED -e "$sed_naive_backslashify"` 3028bd23fbfaSmrg else 3029bd23fbfaSmrg func_convert_core_file_wine_to_w32_result= 3030bd23fbfaSmrg fi 3031bd23fbfaSmrg fi 3032bd23fbfaSmrg} 3033bd23fbfaSmrg# end: func_convert_core_file_wine_to_w32 3034bd23fbfaSmrg 3035bd23fbfaSmrg 3036bd23fbfaSmrg# func_convert_core_path_wine_to_w32 ARG 3037bd23fbfaSmrg# Helper function used by path conversion functions when $build is *nix, and 3038bd23fbfaSmrg# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly 3039bd23fbfaSmrg# configured wine environment available, with the winepath program in $build's 3040bd23fbfaSmrg# $PATH. Assumes ARG has no leading or trailing path separator characters. 3041bd23fbfaSmrg# 3042bd23fbfaSmrg# ARG is path to be converted from $build format to win32. 3043bd23fbfaSmrg# Result is available in $func_convert_core_path_wine_to_w32_result. 3044bd23fbfaSmrg# Unconvertible file (directory) names in ARG are skipped; if no directory names 3045bd23fbfaSmrg# are convertible, then the result may be empty. 3046bd23fbfaSmrgfunc_convert_core_path_wine_to_w32 () 3047bd23fbfaSmrg{ 30483169be4bSmrg $debug_cmd 30493169be4bSmrg 3050bd23fbfaSmrg # unfortunately, winepath doesn't convert paths, only file names 30513169be4bSmrg func_convert_core_path_wine_to_w32_result= 3052bd23fbfaSmrg if test -n "$1"; then 3053bd23fbfaSmrg oldIFS=$IFS 3054bd23fbfaSmrg IFS=: 3055bd23fbfaSmrg for func_convert_core_path_wine_to_w32_f in $1; do 3056bd23fbfaSmrg IFS=$oldIFS 3057bd23fbfaSmrg func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" 30583169be4bSmrg if test -n "$func_convert_core_file_wine_to_w32_result"; then 3059bd23fbfaSmrg if test -z "$func_convert_core_path_wine_to_w32_result"; then 30603169be4bSmrg func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result 3061bd23fbfaSmrg else 3062bd23fbfaSmrg func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" 3063bd23fbfaSmrg fi 3064bd23fbfaSmrg fi 3065bd23fbfaSmrg done 3066bd23fbfaSmrg IFS=$oldIFS 3067bd23fbfaSmrg fi 3068bd23fbfaSmrg} 3069bd23fbfaSmrg# end: func_convert_core_path_wine_to_w32 3070bd23fbfaSmrg 3071bd23fbfaSmrg 3072bd23fbfaSmrg# func_cygpath ARGS... 3073bd23fbfaSmrg# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when 3074bd23fbfaSmrg# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) 3075bd23fbfaSmrg# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or 3076bd23fbfaSmrg# (2), returns the Cygwin file name or path in func_cygpath_result (input 3077bd23fbfaSmrg# file name or path is assumed to be in w32 format, as previously converted 3078bd23fbfaSmrg# from $build's *nix or MSYS format). In case (3), returns the w32 file name 3079bd23fbfaSmrg# or path in func_cygpath_result (input file name or path is assumed to be in 3080bd23fbfaSmrg# Cygwin format). Returns an empty string on error. 3081bd23fbfaSmrg# 3082bd23fbfaSmrg# ARGS are passed to cygpath, with the last one being the file name or path to 3083bd23fbfaSmrg# be converted. 3084bd23fbfaSmrg# 3085bd23fbfaSmrg# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH 3086bd23fbfaSmrg# environment variable; do not put it in $PATH. 3087bd23fbfaSmrgfunc_cygpath () 3088bd23fbfaSmrg{ 30893169be4bSmrg $debug_cmd 30903169be4bSmrg 3091bd23fbfaSmrg if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then 3092bd23fbfaSmrg func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` 3093bd23fbfaSmrg if test "$?" -ne 0; then 3094bd23fbfaSmrg # on failure, ensure result is empty 3095bd23fbfaSmrg func_cygpath_result= 3096bd23fbfaSmrg fi 3097bd23fbfaSmrg else 3098bd23fbfaSmrg func_cygpath_result= 30993169be4bSmrg func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'" 3100bd23fbfaSmrg fi 3101bd23fbfaSmrg} 3102bd23fbfaSmrg#end: func_cygpath 3103bd23fbfaSmrg 3104bd23fbfaSmrg 3105bd23fbfaSmrg# func_convert_core_msys_to_w32 ARG 3106bd23fbfaSmrg# Convert file name or path ARG from MSYS format to w32 format. Return 3107bd23fbfaSmrg# result in func_convert_core_msys_to_w32_result. 3108bd23fbfaSmrgfunc_convert_core_msys_to_w32 () 3109bd23fbfaSmrg{ 31103169be4bSmrg $debug_cmd 31113169be4bSmrg 3112bd23fbfaSmrg # awkward: cmd appends spaces to result 3113bd23fbfaSmrg func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | 31143169be4bSmrg $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"` 3115bd23fbfaSmrg} 3116bd23fbfaSmrg#end: func_convert_core_msys_to_w32 3117bd23fbfaSmrg 3118bd23fbfaSmrg 3119bd23fbfaSmrg# func_convert_file_check ARG1 ARG2 3120bd23fbfaSmrg# Verify that ARG1 (a file name in $build format) was converted to $host 3121bd23fbfaSmrg# format in ARG2. Otherwise, emit an error message, but continue (resetting 3122bd23fbfaSmrg# func_to_host_file_result to ARG1). 3123bd23fbfaSmrgfunc_convert_file_check () 3124bd23fbfaSmrg{ 31253169be4bSmrg $debug_cmd 31263169be4bSmrg 31273169be4bSmrg if test -z "$2" && test -n "$1"; then 3128bd23fbfaSmrg func_error "Could not determine host file name corresponding to" 31293169be4bSmrg func_error " '$1'" 3130bd23fbfaSmrg func_error "Continuing, but uninstalled executables may not work." 3131bd23fbfaSmrg # Fallback: 31323169be4bSmrg func_to_host_file_result=$1 3133bd23fbfaSmrg fi 3134bd23fbfaSmrg} 3135bd23fbfaSmrg# end func_convert_file_check 3136bd23fbfaSmrg 3137bd23fbfaSmrg 3138bd23fbfaSmrg# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH 3139bd23fbfaSmrg# Verify that FROM_PATH (a path in $build format) was converted to $host 3140bd23fbfaSmrg# format in TO_PATH. Otherwise, emit an error message, but continue, resetting 3141bd23fbfaSmrg# func_to_host_file_result to a simplistic fallback value (see below). 3142bd23fbfaSmrgfunc_convert_path_check () 3143bd23fbfaSmrg{ 31443169be4bSmrg $debug_cmd 31453169be4bSmrg 3146bd23fbfaSmrg if test -z "$4" && test -n "$3"; then 3147bd23fbfaSmrg func_error "Could not determine the host path corresponding to" 31483169be4bSmrg func_error " '$3'" 3149bd23fbfaSmrg func_error "Continuing, but uninstalled executables may not work." 3150bd23fbfaSmrg # Fallback. This is a deliberately simplistic "conversion" and 3151bd23fbfaSmrg # should not be "improved". See libtool.info. 3152bd23fbfaSmrg if test "x$1" != "x$2"; then 3153bd23fbfaSmrg lt_replace_pathsep_chars="s|$1|$2|g" 3154bd23fbfaSmrg func_to_host_path_result=`echo "$3" | 3155bd23fbfaSmrg $SED -e "$lt_replace_pathsep_chars"` 3156bd23fbfaSmrg else 31573169be4bSmrg func_to_host_path_result=$3 3158bd23fbfaSmrg fi 3159bd23fbfaSmrg fi 3160bd23fbfaSmrg} 3161bd23fbfaSmrg# end func_convert_path_check 3162bd23fbfaSmrg 3163bd23fbfaSmrg 3164bd23fbfaSmrg# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG 3165bd23fbfaSmrg# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT 3166bd23fbfaSmrg# and appending REPL if ORIG matches BACKPAT. 3167bd23fbfaSmrgfunc_convert_path_front_back_pathsep () 3168bd23fbfaSmrg{ 31693169be4bSmrg $debug_cmd 31703169be4bSmrg 3171bd23fbfaSmrg case $4 in 31723169be4bSmrg $1 ) func_to_host_path_result=$3$func_to_host_path_result 3173bd23fbfaSmrg ;; 3174bd23fbfaSmrg esac 3175bd23fbfaSmrg case $4 in 3176bd23fbfaSmrg $2 ) func_append func_to_host_path_result "$3" 3177bd23fbfaSmrg ;; 3178bd23fbfaSmrg esac 3179bd23fbfaSmrg} 3180bd23fbfaSmrg# end func_convert_path_front_back_pathsep 3181bd23fbfaSmrg 3182bd23fbfaSmrg 3183bd23fbfaSmrg################################################## 3184bd23fbfaSmrg# $build to $host FILE NAME CONVERSION FUNCTIONS # 3185bd23fbfaSmrg################################################## 31863169be4bSmrg# invoked via '$to_host_file_cmd ARG' 3187bd23fbfaSmrg# 3188bd23fbfaSmrg# In each case, ARG is the path to be converted from $build to $host format. 3189bd23fbfaSmrg# Result will be available in $func_to_host_file_result. 3190bd23fbfaSmrg 3191bd23fbfaSmrg 3192bd23fbfaSmrg# func_to_host_file ARG 3193bd23fbfaSmrg# Converts the file name ARG from $build format to $host format. Return result 3194bd23fbfaSmrg# in func_to_host_file_result. 3195bd23fbfaSmrgfunc_to_host_file () 3196bd23fbfaSmrg{ 31973169be4bSmrg $debug_cmd 31983169be4bSmrg 3199bd23fbfaSmrg $to_host_file_cmd "$1" 3200bd23fbfaSmrg} 3201bd23fbfaSmrg# end func_to_host_file 3202bd23fbfaSmrg 3203bd23fbfaSmrg 3204bd23fbfaSmrg# func_to_tool_file ARG LAZY 3205bd23fbfaSmrg# converts the file name ARG from $build format to toolchain format. Return 3206bd23fbfaSmrg# result in func_to_tool_file_result. If the conversion in use is listed 3207bd23fbfaSmrg# in (the comma separated) LAZY, no conversion takes place. 3208bd23fbfaSmrgfunc_to_tool_file () 3209bd23fbfaSmrg{ 32103169be4bSmrg $debug_cmd 32113169be4bSmrg 3212bd23fbfaSmrg case ,$2, in 3213bd23fbfaSmrg *,"$to_tool_file_cmd",*) 3214bd23fbfaSmrg func_to_tool_file_result=$1 3215bd23fbfaSmrg ;; 3216bd23fbfaSmrg *) 3217bd23fbfaSmrg $to_tool_file_cmd "$1" 3218bd23fbfaSmrg func_to_tool_file_result=$func_to_host_file_result 3219bd23fbfaSmrg ;; 3220bd23fbfaSmrg esac 3221bd23fbfaSmrg} 3222bd23fbfaSmrg# end func_to_tool_file 3223bd23fbfaSmrg 3224bd23fbfaSmrg 3225bd23fbfaSmrg# func_convert_file_noop ARG 3226bd23fbfaSmrg# Copy ARG to func_to_host_file_result. 3227bd23fbfaSmrgfunc_convert_file_noop () 3228bd23fbfaSmrg{ 32293169be4bSmrg func_to_host_file_result=$1 3230bd23fbfaSmrg} 3231bd23fbfaSmrg# end func_convert_file_noop 3232bd23fbfaSmrg 3233bd23fbfaSmrg 3234bd23fbfaSmrg# func_convert_file_msys_to_w32 ARG 3235bd23fbfaSmrg# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic 3236bd23fbfaSmrg# conversion to w32 is not available inside the cwrapper. Returns result in 3237bd23fbfaSmrg# func_to_host_file_result. 3238bd23fbfaSmrgfunc_convert_file_msys_to_w32 () 3239bd23fbfaSmrg{ 32403169be4bSmrg $debug_cmd 32413169be4bSmrg 32423169be4bSmrg func_to_host_file_result=$1 3243bd23fbfaSmrg if test -n "$1"; then 3244bd23fbfaSmrg func_convert_core_msys_to_w32 "$1" 32453169be4bSmrg func_to_host_file_result=$func_convert_core_msys_to_w32_result 3246bd23fbfaSmrg fi 3247bd23fbfaSmrg func_convert_file_check "$1" "$func_to_host_file_result" 3248bd23fbfaSmrg} 3249bd23fbfaSmrg# end func_convert_file_msys_to_w32 3250bd23fbfaSmrg 3251bd23fbfaSmrg 3252bd23fbfaSmrg# func_convert_file_cygwin_to_w32 ARG 3253bd23fbfaSmrg# Convert file name ARG from Cygwin to w32 format. Returns result in 3254bd23fbfaSmrg# func_to_host_file_result. 3255bd23fbfaSmrgfunc_convert_file_cygwin_to_w32 () 3256bd23fbfaSmrg{ 32573169be4bSmrg $debug_cmd 32583169be4bSmrg 32593169be4bSmrg func_to_host_file_result=$1 3260bd23fbfaSmrg if test -n "$1"; then 3261bd23fbfaSmrg # because $build is cygwin, we call "the" cygpath in $PATH; no need to use 3262bd23fbfaSmrg # LT_CYGPATH in this case. 3263bd23fbfaSmrg func_to_host_file_result=`cygpath -m "$1"` 3264bd23fbfaSmrg fi 3265bd23fbfaSmrg func_convert_file_check "$1" "$func_to_host_file_result" 3266bd23fbfaSmrg} 3267bd23fbfaSmrg# end func_convert_file_cygwin_to_w32 3268bd23fbfaSmrg 3269bd23fbfaSmrg 3270bd23fbfaSmrg# func_convert_file_nix_to_w32 ARG 3271bd23fbfaSmrg# Convert file name ARG from *nix to w32 format. Requires a wine environment 3272bd23fbfaSmrg# and a working winepath. Returns result in func_to_host_file_result. 3273bd23fbfaSmrgfunc_convert_file_nix_to_w32 () 3274bd23fbfaSmrg{ 32753169be4bSmrg $debug_cmd 32763169be4bSmrg 32773169be4bSmrg func_to_host_file_result=$1 3278bd23fbfaSmrg if test -n "$1"; then 3279bd23fbfaSmrg func_convert_core_file_wine_to_w32 "$1" 32803169be4bSmrg func_to_host_file_result=$func_convert_core_file_wine_to_w32_result 3281bd23fbfaSmrg fi 3282bd23fbfaSmrg func_convert_file_check "$1" "$func_to_host_file_result" 3283bd23fbfaSmrg} 3284bd23fbfaSmrg# end func_convert_file_nix_to_w32 3285bd23fbfaSmrg 3286bd23fbfaSmrg 3287bd23fbfaSmrg# func_convert_file_msys_to_cygwin ARG 3288bd23fbfaSmrg# Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 3289bd23fbfaSmrg# Returns result in func_to_host_file_result. 3290bd23fbfaSmrgfunc_convert_file_msys_to_cygwin () 3291bd23fbfaSmrg{ 32923169be4bSmrg $debug_cmd 32933169be4bSmrg 32943169be4bSmrg func_to_host_file_result=$1 3295bd23fbfaSmrg if test -n "$1"; then 3296bd23fbfaSmrg func_convert_core_msys_to_w32 "$1" 3297bd23fbfaSmrg func_cygpath -u "$func_convert_core_msys_to_w32_result" 32983169be4bSmrg func_to_host_file_result=$func_cygpath_result 3299bd23fbfaSmrg fi 3300bd23fbfaSmrg func_convert_file_check "$1" "$func_to_host_file_result" 3301bd23fbfaSmrg} 3302bd23fbfaSmrg# end func_convert_file_msys_to_cygwin 3303bd23fbfaSmrg 3304bd23fbfaSmrg 3305bd23fbfaSmrg# func_convert_file_nix_to_cygwin ARG 3306bd23fbfaSmrg# Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed 3307bd23fbfaSmrg# in a wine environment, working winepath, and LT_CYGPATH set. Returns result 3308bd23fbfaSmrg# in func_to_host_file_result. 3309bd23fbfaSmrgfunc_convert_file_nix_to_cygwin () 3310bd23fbfaSmrg{ 33113169be4bSmrg $debug_cmd 33123169be4bSmrg 33133169be4bSmrg func_to_host_file_result=$1 3314bd23fbfaSmrg if test -n "$1"; then 3315bd23fbfaSmrg # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. 3316bd23fbfaSmrg func_convert_core_file_wine_to_w32 "$1" 3317bd23fbfaSmrg func_cygpath -u "$func_convert_core_file_wine_to_w32_result" 33183169be4bSmrg func_to_host_file_result=$func_cygpath_result 3319bd23fbfaSmrg fi 3320bd23fbfaSmrg func_convert_file_check "$1" "$func_to_host_file_result" 3321bd23fbfaSmrg} 3322bd23fbfaSmrg# end func_convert_file_nix_to_cygwin 3323bd23fbfaSmrg 3324bd23fbfaSmrg 3325bd23fbfaSmrg############################################# 3326bd23fbfaSmrg# $build to $host PATH CONVERSION FUNCTIONS # 3327bd23fbfaSmrg############################################# 33283169be4bSmrg# invoked via '$to_host_path_cmd ARG' 3329bd23fbfaSmrg# 3330bd23fbfaSmrg# In each case, ARG is the path to be converted from $build to $host format. 3331bd23fbfaSmrg# The result will be available in $func_to_host_path_result. 3332bd23fbfaSmrg# 3333bd23fbfaSmrg# Path separators are also converted from $build format to $host format. If 3334bd23fbfaSmrg# ARG begins or ends with a path separator character, it is preserved (but 3335bd23fbfaSmrg# converted to $host format) on output. 3336bd23fbfaSmrg# 3337bd23fbfaSmrg# All path conversion functions are named using the following convention: 3338bd23fbfaSmrg# file name conversion function : func_convert_file_X_to_Y () 3339bd23fbfaSmrg# path conversion function : func_convert_path_X_to_Y () 3340bd23fbfaSmrg# where, for any given $build/$host combination the 'X_to_Y' value is the 3341bd23fbfaSmrg# same. If conversion functions are added for new $build/$host combinations, 3342bd23fbfaSmrg# the two new functions must follow this pattern, or func_init_to_host_path_cmd 3343bd23fbfaSmrg# will break. 3344bd23fbfaSmrg 3345bd23fbfaSmrg 3346bd23fbfaSmrg# func_init_to_host_path_cmd 3347bd23fbfaSmrg# Ensures that function "pointer" variable $to_host_path_cmd is set to the 3348bd23fbfaSmrg# appropriate value, based on the value of $to_host_file_cmd. 3349bd23fbfaSmrgto_host_path_cmd= 3350bd23fbfaSmrgfunc_init_to_host_path_cmd () 3351bd23fbfaSmrg{ 33523169be4bSmrg $debug_cmd 33533169be4bSmrg 3354bd23fbfaSmrg if test -z "$to_host_path_cmd"; then 3355bd23fbfaSmrg func_stripname 'func_convert_file_' '' "$to_host_file_cmd" 33563169be4bSmrg to_host_path_cmd=func_convert_path_$func_stripname_result 3357bd23fbfaSmrg fi 3358bd23fbfaSmrg} 3359bd23fbfaSmrg 3360bd23fbfaSmrg 3361bd23fbfaSmrg# func_to_host_path ARG 3362bd23fbfaSmrg# Converts the path ARG from $build format to $host format. Return result 3363bd23fbfaSmrg# in func_to_host_path_result. 3364bd23fbfaSmrgfunc_to_host_path () 3365bd23fbfaSmrg{ 33663169be4bSmrg $debug_cmd 33673169be4bSmrg 3368bd23fbfaSmrg func_init_to_host_path_cmd 3369bd23fbfaSmrg $to_host_path_cmd "$1" 3370bd23fbfaSmrg} 3371bd23fbfaSmrg# end func_to_host_path 3372bd23fbfaSmrg 3373bd23fbfaSmrg 3374bd23fbfaSmrg# func_convert_path_noop ARG 3375bd23fbfaSmrg# Copy ARG to func_to_host_path_result. 3376bd23fbfaSmrgfunc_convert_path_noop () 3377bd23fbfaSmrg{ 33783169be4bSmrg func_to_host_path_result=$1 3379bd23fbfaSmrg} 3380bd23fbfaSmrg# end func_convert_path_noop 3381bd23fbfaSmrg 3382bd23fbfaSmrg 3383bd23fbfaSmrg# func_convert_path_msys_to_w32 ARG 3384bd23fbfaSmrg# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic 3385bd23fbfaSmrg# conversion to w32 is not available inside the cwrapper. Returns result in 3386bd23fbfaSmrg# func_to_host_path_result. 3387bd23fbfaSmrgfunc_convert_path_msys_to_w32 () 33888c4a8e55Smrg{ 33893169be4bSmrg $debug_cmd 33903169be4bSmrg 33913169be4bSmrg func_to_host_path_result=$1 3392bd23fbfaSmrg if test -n "$1"; then 3393bd23fbfaSmrg # Remove leading and trailing path separator characters from ARG. MSYS 3394bd23fbfaSmrg # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; 3395bd23fbfaSmrg # and winepath ignores them completely. 3396bd23fbfaSmrg func_stripname : : "$1" 3397bd23fbfaSmrg func_to_host_path_tmp1=$func_stripname_result 3398bd23fbfaSmrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 33993169be4bSmrg func_to_host_path_result=$func_convert_core_msys_to_w32_result 3400bd23fbfaSmrg func_convert_path_check : ";" \ 3401bd23fbfaSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3402bd23fbfaSmrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 3403bd23fbfaSmrg fi 3404bd23fbfaSmrg} 3405bd23fbfaSmrg# end func_convert_path_msys_to_w32 34068c4a8e55Smrg 34078c4a8e55Smrg 3408bd23fbfaSmrg# func_convert_path_cygwin_to_w32 ARG 3409bd23fbfaSmrg# Convert path ARG from Cygwin to w32 format. Returns result in 3410bd23fbfaSmrg# func_to_host_file_result. 3411bd23fbfaSmrgfunc_convert_path_cygwin_to_w32 () 3412bd23fbfaSmrg{ 34133169be4bSmrg $debug_cmd 34143169be4bSmrg 34153169be4bSmrg func_to_host_path_result=$1 3416bd23fbfaSmrg if test -n "$1"; then 3417bd23fbfaSmrg # See func_convert_path_msys_to_w32: 3418bd23fbfaSmrg func_stripname : : "$1" 3419bd23fbfaSmrg func_to_host_path_tmp1=$func_stripname_result 3420bd23fbfaSmrg func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` 3421bd23fbfaSmrg func_convert_path_check : ";" \ 3422bd23fbfaSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3423bd23fbfaSmrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 3424bd23fbfaSmrg fi 3425bd23fbfaSmrg} 3426bd23fbfaSmrg# end func_convert_path_cygwin_to_w32 34278c4a8e55Smrg 34288c4a8e55Smrg 3429bd23fbfaSmrg# func_convert_path_nix_to_w32 ARG 3430bd23fbfaSmrg# Convert path ARG from *nix to w32 format. Requires a wine environment and 3431bd23fbfaSmrg# a working winepath. Returns result in func_to_host_file_result. 3432bd23fbfaSmrgfunc_convert_path_nix_to_w32 () 3433bd23fbfaSmrg{ 34343169be4bSmrg $debug_cmd 34353169be4bSmrg 34363169be4bSmrg func_to_host_path_result=$1 3437bd23fbfaSmrg if test -n "$1"; then 3438bd23fbfaSmrg # See func_convert_path_msys_to_w32: 3439bd23fbfaSmrg func_stripname : : "$1" 3440bd23fbfaSmrg func_to_host_path_tmp1=$func_stripname_result 3441bd23fbfaSmrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 34423169be4bSmrg func_to_host_path_result=$func_convert_core_path_wine_to_w32_result 3443bd23fbfaSmrg func_convert_path_check : ";" \ 3444bd23fbfaSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3445bd23fbfaSmrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 3446bd23fbfaSmrg fi 3447bd23fbfaSmrg} 3448bd23fbfaSmrg# end func_convert_path_nix_to_w32 34498c4a8e55Smrg 3450bd23fbfaSmrg 3451bd23fbfaSmrg# func_convert_path_msys_to_cygwin ARG 3452bd23fbfaSmrg# Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 3453bd23fbfaSmrg# Returns result in func_to_host_file_result. 3454bd23fbfaSmrgfunc_convert_path_msys_to_cygwin () 3455bd23fbfaSmrg{ 34563169be4bSmrg $debug_cmd 34573169be4bSmrg 34583169be4bSmrg func_to_host_path_result=$1 3459bd23fbfaSmrg if test -n "$1"; then 3460bd23fbfaSmrg # See func_convert_path_msys_to_w32: 3461bd23fbfaSmrg func_stripname : : "$1" 3462bd23fbfaSmrg func_to_host_path_tmp1=$func_stripname_result 3463bd23fbfaSmrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 3464bd23fbfaSmrg func_cygpath -u -p "$func_convert_core_msys_to_w32_result" 34653169be4bSmrg func_to_host_path_result=$func_cygpath_result 3466bd23fbfaSmrg func_convert_path_check : : \ 3467bd23fbfaSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3468bd23fbfaSmrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 3469bd23fbfaSmrg fi 3470bd23fbfaSmrg} 3471bd23fbfaSmrg# end func_convert_path_msys_to_cygwin 3472bd23fbfaSmrg 3473bd23fbfaSmrg 3474bd23fbfaSmrg# func_convert_path_nix_to_cygwin ARG 3475bd23fbfaSmrg# Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a 3476bd23fbfaSmrg# a wine environment, working winepath, and LT_CYGPATH set. Returns result in 3477bd23fbfaSmrg# func_to_host_file_result. 3478bd23fbfaSmrgfunc_convert_path_nix_to_cygwin () 3479bd23fbfaSmrg{ 34803169be4bSmrg $debug_cmd 34813169be4bSmrg 34823169be4bSmrg func_to_host_path_result=$1 3483bd23fbfaSmrg if test -n "$1"; then 3484bd23fbfaSmrg # Remove leading and trailing path separator characters from 3485bd23fbfaSmrg # ARG. msys behavior is inconsistent here, cygpath turns them 3486bd23fbfaSmrg # into '.;' and ';.', and winepath ignores them completely. 3487bd23fbfaSmrg func_stripname : : "$1" 3488bd23fbfaSmrg func_to_host_path_tmp1=$func_stripname_result 3489bd23fbfaSmrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 3490bd23fbfaSmrg func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" 34913169be4bSmrg func_to_host_path_result=$func_cygpath_result 3492bd23fbfaSmrg func_convert_path_check : : \ 3493bd23fbfaSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3494bd23fbfaSmrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 3495bd23fbfaSmrg fi 34968c4a8e55Smrg} 3497bd23fbfaSmrg# end func_convert_path_nix_to_cygwin 3498bd23fbfaSmrg 34998c4a8e55Smrg 35003169be4bSmrg# func_dll_def_p FILE 35013169be4bSmrg# True iff FILE is a Windows DLL '.def' file. 35023169be4bSmrg# Keep in sync with _LT_DLL_DEF_P in libtool.m4 35033169be4bSmrgfunc_dll_def_p () 35043169be4bSmrg{ 35053169be4bSmrg $debug_cmd 35063169be4bSmrg 35073169be4bSmrg func_dll_def_p_tmp=`$SED -n \ 35083169be4bSmrg -e 's/^[ ]*//' \ 35093169be4bSmrg -e '/^\(;.*\)*$/d' \ 35103169be4bSmrg -e 's/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p' \ 35113169be4bSmrg -e q \ 35123169be4bSmrg "$1"` 35133169be4bSmrg test DEF = "$func_dll_def_p_tmp" 35143169be4bSmrg} 35153169be4bSmrg 35163169be4bSmrg 35178c4a8e55Smrg# func_mode_compile arg... 35188c4a8e55Smrgfunc_mode_compile () 35198c4a8e55Smrg{ 35203169be4bSmrg $debug_cmd 35213169be4bSmrg 35228c4a8e55Smrg # Get the compilation command and the source file. 35238c4a8e55Smrg base_compile= 35243169be4bSmrg srcfile=$nonopt # always keep a non-empty value in "srcfile" 35258c4a8e55Smrg suppress_opt=yes 35268c4a8e55Smrg suppress_output= 35278c4a8e55Smrg arg_mode=normal 35288c4a8e55Smrg libobj= 35298c4a8e55Smrg later= 35308c4a8e55Smrg pie_flag= 35318c4a8e55Smrg 35328c4a8e55Smrg for arg 35338c4a8e55Smrg do 35348c4a8e55Smrg case $arg_mode in 35358c4a8e55Smrg arg ) 35368c4a8e55Smrg # do not "continue". Instead, add this to base_compile 35373169be4bSmrg lastarg=$arg 35388c4a8e55Smrg arg_mode=normal 35398c4a8e55Smrg ;; 35408c4a8e55Smrg 35418c4a8e55Smrg target ) 35423169be4bSmrg libobj=$arg 35438c4a8e55Smrg arg_mode=normal 35448c4a8e55Smrg continue 35458c4a8e55Smrg ;; 35468c4a8e55Smrg 35478c4a8e55Smrg normal ) 35488c4a8e55Smrg # Accept any command-line options. 35498c4a8e55Smrg case $arg in 35508c4a8e55Smrg -o) 35518c4a8e55Smrg test -n "$libobj" && \ 35523169be4bSmrg func_fatal_error "you cannot specify '-o' more than once" 35538c4a8e55Smrg arg_mode=target 35548c4a8e55Smrg continue 35558c4a8e55Smrg ;; 35568c4a8e55Smrg 35578c4a8e55Smrg -pie | -fpie | -fPIE) 3558bd23fbfaSmrg func_append pie_flag " $arg" 35598c4a8e55Smrg continue 35608c4a8e55Smrg ;; 35618c4a8e55Smrg 35628c4a8e55Smrg -shared | -static | -prefer-pic | -prefer-non-pic) 3563bd23fbfaSmrg func_append later " $arg" 35648c4a8e55Smrg continue 35658c4a8e55Smrg ;; 35668c4a8e55Smrg 35678c4a8e55Smrg -no-suppress) 35688c4a8e55Smrg suppress_opt=no 35698c4a8e55Smrg continue 35708c4a8e55Smrg ;; 35718c4a8e55Smrg 35728c4a8e55Smrg -Xcompiler) 35738c4a8e55Smrg arg_mode=arg # the next one goes into the "base_compile" arg list 35748c4a8e55Smrg continue # The current "srcfile" will either be retained or 35758c4a8e55Smrg ;; # replaced later. I would guess that would be a bug. 3576b042e37fSmrg 3577b042e37fSmrg -Wc,*) 35788c4a8e55Smrg func_stripname '-Wc,' '' "$arg" 35798c4a8e55Smrg args=$func_stripname_result 3580b042e37fSmrg lastarg= 35813169be4bSmrg save_ifs=$IFS; IFS=, 35828c4a8e55Smrg for arg in $args; do 35833169be4bSmrg IFS=$save_ifs 3584bd23fbfaSmrg func_append_quoted lastarg "$arg" 3585b042e37fSmrg done 35863169be4bSmrg IFS=$save_ifs 35878c4a8e55Smrg func_stripname ' ' '' "$lastarg" 35888c4a8e55Smrg lastarg=$func_stripname_result 3589b042e37fSmrg 3590b042e37fSmrg # Add the arguments to base_compile. 3591bd23fbfaSmrg func_append base_compile " $lastarg" 3592b042e37fSmrg continue 3593b042e37fSmrg ;; 3594b042e37fSmrg 35958c4a8e55Smrg *) 3596b042e37fSmrg # Accept the current argument as the source file. 3597b042e37fSmrg # The previous "srcfile" becomes the current argument. 3598b042e37fSmrg # 35993169be4bSmrg lastarg=$srcfile 36003169be4bSmrg srcfile=$arg 3601b042e37fSmrg ;; 3602b042e37fSmrg esac # case $arg 3603b042e37fSmrg ;; 3604b042e37fSmrg esac # case $arg_mode 3605b042e37fSmrg 3606b042e37fSmrg # Aesthetically quote the previous argument. 3607bd23fbfaSmrg func_append_quoted base_compile "$lastarg" 3608b042e37fSmrg done # for arg 3609b042e37fSmrg 3610b042e37fSmrg case $arg_mode in 3611b042e37fSmrg arg) 36128c4a8e55Smrg func_fatal_error "you must specify an argument for -Xcompile" 3613b042e37fSmrg ;; 3614b042e37fSmrg target) 36153169be4bSmrg func_fatal_error "you must specify a target with '-o'" 3616b042e37fSmrg ;; 3617b042e37fSmrg *) 3618b042e37fSmrg # Get the name of the library object. 36198c4a8e55Smrg test -z "$libobj" && { 36208c4a8e55Smrg func_basename "$srcfile" 36213169be4bSmrg libobj=$func_basename_result 36228c4a8e55Smrg } 3623b042e37fSmrg ;; 3624b042e37fSmrg esac 3625b042e37fSmrg 3626b042e37fSmrg # Recognize several different file suffixes. 3627b042e37fSmrg # If the user specifies -o file.o, it is replaced with file.lo 3628b042e37fSmrg case $libobj in 36298c4a8e55Smrg *.[cCFSifmso] | \ 36308c4a8e55Smrg *.ada | *.adb | *.ads | *.asm | \ 36318c4a8e55Smrg *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ 36320597fb56Smrg *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup) 36338c4a8e55Smrg func_xform "$libobj" 36348c4a8e55Smrg libobj=$func_xform_result 36358c4a8e55Smrg ;; 3636b042e37fSmrg esac 3637b042e37fSmrg 3638b042e37fSmrg case $libobj in 36398c4a8e55Smrg *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; 3640b042e37fSmrg *) 36413169be4bSmrg func_fatal_error "cannot determine name of library object from '$libobj'" 3642b042e37fSmrg ;; 3643b042e37fSmrg esac 3644b042e37fSmrg 3645b042e37fSmrg func_infer_tag $base_compile 3646b042e37fSmrg 3647b042e37fSmrg for arg in $later; do 3648b042e37fSmrg case $arg in 36498c4a8e55Smrg -shared) 36503169be4bSmrg test yes = "$build_libtool_libs" \ 36513169be4bSmrg || func_fatal_configuration "cannot build a shared library" 36528c4a8e55Smrg build_old_libs=no 36538c4a8e55Smrg continue 36548c4a8e55Smrg ;; 36558c4a8e55Smrg 3656b042e37fSmrg -static) 36578c4a8e55Smrg build_libtool_libs=no 3658b042e37fSmrg build_old_libs=yes 3659b042e37fSmrg continue 3660b042e37fSmrg ;; 3661b042e37fSmrg 3662b042e37fSmrg -prefer-pic) 3663b042e37fSmrg pic_mode=yes 3664b042e37fSmrg continue 3665b042e37fSmrg ;; 3666b042e37fSmrg 3667b042e37fSmrg -prefer-non-pic) 3668b042e37fSmrg pic_mode=no 3669b042e37fSmrg continue 3670b042e37fSmrg ;; 3671b042e37fSmrg esac 3672b042e37fSmrg done 3673b042e37fSmrg 36748d0bc965Smrg func_quote_arg pretty "$libobj" 36758d0bc965Smrg test "X$libobj" != "X$func_quote_arg_result" \ 36768c4a8e55Smrg && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ 36773169be4bSmrg && func_warning "libobj name '$libobj' may not contain shell special characters." 36788c4a8e55Smrg func_dirname_and_basename "$obj" "/" "" 36793169be4bSmrg objname=$func_basename_result 36803169be4bSmrg xdir=$func_dirname_result 36813169be4bSmrg lobj=$xdir$objdir/$objname 3682b042e37fSmrg 36838c4a8e55Smrg test -z "$base_compile" && \ 36848c4a8e55Smrg func_fatal_help "you must specify a compilation command" 3685b042e37fSmrg 3686b042e37fSmrg # Delete any leftover library objects. 36873169be4bSmrg if test yes = "$build_old_libs"; then 3688b042e37fSmrg removelist="$obj $lobj $libobj ${libobj}T" 3689b042e37fSmrg else 3690b042e37fSmrg removelist="$lobj $libobj ${libobj}T" 3691b042e37fSmrg fi 3692b042e37fSmrg 3693b042e37fSmrg # On Cygwin there's no "real" PIC flag so we must build both object types 3694b042e37fSmrg case $host_os in 36958c4a8e55Smrg cygwin* | mingw* | pw32* | os2* | cegcc*) 3696b042e37fSmrg pic_mode=default 3697b042e37fSmrg ;; 3698b042e37fSmrg esac 36993169be4bSmrg if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then 3700b042e37fSmrg # non-PIC code in shared libraries is not supported 3701b042e37fSmrg pic_mode=default 3702b042e37fSmrg fi 3703b042e37fSmrg 3704b042e37fSmrg # Calculate the filename of the output object if compiler does 3705b042e37fSmrg # not support -o with -c 37063169be4bSmrg if test no = "$compiler_c_o"; then 37073169be4bSmrg output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext 37083169be4bSmrg lockfile=$output_obj.lock 3709b042e37fSmrg else 3710b042e37fSmrg output_obj= 3711b042e37fSmrg need_locks=no 3712b042e37fSmrg lockfile= 3713b042e37fSmrg fi 3714b042e37fSmrg 3715b042e37fSmrg # Lock this critical section if it is needed 3716b042e37fSmrg # We use this script file to make the link, it avoids creating a new file 37173169be4bSmrg if test yes = "$need_locks"; then 37188c4a8e55Smrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 37198c4a8e55Smrg func_echo "Waiting for $lockfile to be removed" 3720b042e37fSmrg sleep 2 3721b042e37fSmrg done 37223169be4bSmrg elif test warn = "$need_locks"; then 3723b042e37fSmrg if test -f "$lockfile"; then 37248c4a8e55Smrg $ECHO "\ 3725b042e37fSmrg*** ERROR, $lockfile exists and contains: 3726b042e37fSmrg`cat $lockfile 2>/dev/null` 3727b042e37fSmrg 3728b042e37fSmrgThis indicates that another process is trying to use the same 3729b042e37fSmrgtemporary object file, and libtool could not work around it because 37303169be4bSmrgyour compiler does not support '-c' and '-o' together. If you 3731b042e37fSmrgrepeat this compilation, it may succeed, by chance, but you had better 3732b042e37fSmrgavoid parallel builds (make -j) in this platform, or get a better 3733b042e37fSmrgcompiler." 3734b042e37fSmrg 37358c4a8e55Smrg $opt_dry_run || $RM $removelist 3736b042e37fSmrg exit $EXIT_FAILURE 3737b042e37fSmrg fi 3738bd23fbfaSmrg func_append removelist " $output_obj" 37398c4a8e55Smrg $ECHO "$srcfile" > "$lockfile" 3740b042e37fSmrg fi 3741b042e37fSmrg 37428c4a8e55Smrg $opt_dry_run || $RM $removelist 3743bd23fbfaSmrg func_append removelist " $lockfile" 37448c4a8e55Smrg trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 37458c4a8e55Smrg 3746bd23fbfaSmrg func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 3747bd23fbfaSmrg srcfile=$func_to_tool_file_result 37488d0bc965Smrg func_quote_arg pretty "$srcfile" 37498d0bc965Smrg qsrcfile=$func_quote_arg_result 3750b042e37fSmrg 3751b042e37fSmrg # Only build a PIC object if we are building libtool libraries. 37523169be4bSmrg if test yes = "$build_libtool_libs"; then 3753b042e37fSmrg # Without this assignment, base_compile gets emptied. 3754b042e37fSmrg fbsd_hideous_sh_bug=$base_compile 3755b042e37fSmrg 37563169be4bSmrg if test no != "$pic_mode"; then 3757b042e37fSmrg command="$base_compile $qsrcfile $pic_flag" 3758b042e37fSmrg else 3759b042e37fSmrg # Don't build PIC code 3760b042e37fSmrg command="$base_compile $qsrcfile" 3761b042e37fSmrg fi 3762b042e37fSmrg 37638c4a8e55Smrg func_mkdir_p "$xdir$objdir" 3764b042e37fSmrg 3765b042e37fSmrg if test -z "$output_obj"; then 3766b042e37fSmrg # Place PIC objects in $objdir 3767bd23fbfaSmrg func_append command " -o $lobj" 3768b042e37fSmrg fi 3769b042e37fSmrg 37708c4a8e55Smrg func_show_eval_locale "$command" \ 37718c4a8e55Smrg 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' 3772b042e37fSmrg 37733169be4bSmrg if test warn = "$need_locks" && 3774b042e37fSmrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 37758c4a8e55Smrg $ECHO "\ 3776b042e37fSmrg*** ERROR, $lockfile contains: 3777b042e37fSmrg`cat $lockfile 2>/dev/null` 3778b042e37fSmrg 3779b042e37fSmrgbut it should contain: 3780b042e37fSmrg$srcfile 3781b042e37fSmrg 3782b042e37fSmrgThis indicates that another process is trying to use the same 3783b042e37fSmrgtemporary object file, and libtool could not work around it because 37843169be4bSmrgyour compiler does not support '-c' and '-o' together. If you 3785b042e37fSmrgrepeat this compilation, it may succeed, by chance, but you had better 3786b042e37fSmrgavoid parallel builds (make -j) in this platform, or get a better 3787b042e37fSmrgcompiler." 3788b042e37fSmrg 37898c4a8e55Smrg $opt_dry_run || $RM $removelist 3790b042e37fSmrg exit $EXIT_FAILURE 3791b042e37fSmrg fi 3792b042e37fSmrg 3793b042e37fSmrg # Just move the object if needed, then go on to compile the next one 3794b042e37fSmrg if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then 37958c4a8e55Smrg func_show_eval '$MV "$output_obj" "$lobj"' \ 37968c4a8e55Smrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 3797b042e37fSmrg fi 3798b042e37fSmrg 3799b042e37fSmrg # Allow error messages only from the first compilation. 38003169be4bSmrg if test yes = "$suppress_opt"; then 38018c4a8e55Smrg suppress_output=' >/dev/null 2>&1' 3802b042e37fSmrg fi 3803b042e37fSmrg fi 3804b042e37fSmrg 3805b042e37fSmrg # Only build a position-dependent object if we build old libraries. 38063169be4bSmrg if test yes = "$build_old_libs"; then 38073169be4bSmrg if test yes != "$pic_mode"; then 3808b042e37fSmrg # Don't build PIC code 38098c4a8e55Smrg command="$base_compile $qsrcfile$pie_flag" 3810b042e37fSmrg else 3811b042e37fSmrg command="$base_compile $qsrcfile $pic_flag" 3812b042e37fSmrg fi 38133169be4bSmrg if test yes = "$compiler_c_o"; then 3814bd23fbfaSmrg func_append command " -o $obj" 3815b042e37fSmrg fi 3816b042e37fSmrg 3817b042e37fSmrg # Suppress compiler output if we already did a PIC compilation. 3818bd23fbfaSmrg func_append command "$suppress_output" 38198c4a8e55Smrg func_show_eval_locale "$command" \ 38208c4a8e55Smrg '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 3821b042e37fSmrg 38223169be4bSmrg if test warn = "$need_locks" && 3823b042e37fSmrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 38248c4a8e55Smrg $ECHO "\ 3825b042e37fSmrg*** ERROR, $lockfile contains: 3826b042e37fSmrg`cat $lockfile 2>/dev/null` 3827b042e37fSmrg 3828b042e37fSmrgbut it should contain: 3829b042e37fSmrg$srcfile 3830b042e37fSmrg 3831b042e37fSmrgThis indicates that another process is trying to use the same 3832b042e37fSmrgtemporary object file, and libtool could not work around it because 38333169be4bSmrgyour compiler does not support '-c' and '-o' together. If you 3834b042e37fSmrgrepeat this compilation, it may succeed, by chance, but you had better 3835b042e37fSmrgavoid parallel builds (make -j) in this platform, or get a better 3836b042e37fSmrgcompiler." 3837b042e37fSmrg 38388c4a8e55Smrg $opt_dry_run || $RM $removelist 3839b042e37fSmrg exit $EXIT_FAILURE 3840b042e37fSmrg fi 3841b042e37fSmrg 3842b042e37fSmrg # Just move the object if needed 3843b042e37fSmrg if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then 38448c4a8e55Smrg func_show_eval '$MV "$output_obj" "$obj"' \ 38458c4a8e55Smrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 3846b042e37fSmrg fi 38478c4a8e55Smrg fi 3848b042e37fSmrg 38498c4a8e55Smrg $opt_dry_run || { 38508c4a8e55Smrg func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" 3851b042e37fSmrg 38528c4a8e55Smrg # Unlock the critical section if it was locked 38533169be4bSmrg if test no != "$need_locks"; then 38548c4a8e55Smrg removelist=$lockfile 38558c4a8e55Smrg $RM "$lockfile" 38568c4a8e55Smrg fi 38578c4a8e55Smrg } 3858b042e37fSmrg 38598c4a8e55Smrg exit $EXIT_SUCCESS 38608c4a8e55Smrg} 3861b042e37fSmrg 38628c4a8e55Smrg$opt_help || { 38633169be4bSmrg test compile = "$opt_mode" && func_mode_compile ${1+"$@"} 38648c4a8e55Smrg} 3865b042e37fSmrg 38668c4a8e55Smrgfunc_mode_help () 38678c4a8e55Smrg{ 38688c4a8e55Smrg # We need to display help for each of the modes. 3869bd23fbfaSmrg case $opt_mode in 38708c4a8e55Smrg "") 38718c4a8e55Smrg # Generic help is extracted from the usage comments 38728c4a8e55Smrg # at the start of this file. 38738c4a8e55Smrg func_help 38748c4a8e55Smrg ;; 3875b042e37fSmrg 38768c4a8e55Smrg clean) 38778c4a8e55Smrg $ECHO \ 38788c4a8e55Smrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... 3879b042e37fSmrg 38808c4a8e55SmrgRemove files from the build directory. 3881b042e37fSmrg 38828c4a8e55SmrgRM is the name of the program to use to delete files associated with each FILE 38833169be4bSmrg(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 38848c4a8e55Smrgto RM. 3885b042e37fSmrg 38868c4a8e55SmrgIf FILE is a libtool library, object or program, all the files associated 38878c4a8e55Smrgwith it are deleted. Otherwise, only FILE itself is deleted using RM." 38888c4a8e55Smrg ;; 3889b042e37fSmrg 38908c4a8e55Smrg compile) 38918c4a8e55Smrg $ECHO \ 38928c4a8e55Smrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE 3893b042e37fSmrg 38948c4a8e55SmrgCompile a source file into a libtool library object. 3895b042e37fSmrg 38968c4a8e55SmrgThis mode accepts the following additional options: 3897b042e37fSmrg 38988c4a8e55Smrg -o OUTPUT-FILE set the output file name to OUTPUT-FILE 38998c4a8e55Smrg -no-suppress do not suppress compiler output for multiple passes 3900706b6b52Smrg -prefer-pic try to build PIC objects only 3901706b6b52Smrg -prefer-non-pic try to build non-PIC objects only 39023169be4bSmrg -shared do not build a '.o' file suitable for static linking 39033169be4bSmrg -static only build a '.o' file suitable for static linking 39048d0bc965Smrg -Wc,FLAG 39058d0bc965Smrg -Xcompiler FLAG pass FLAG directly to the compiler 3906b042e37fSmrg 39073169be4bSmrgCOMPILE-COMMAND is a command to be used in creating a 'standard' object file 39088c4a8e55Smrgfrom the given SOURCEFILE. 3909b042e37fSmrg 39108c4a8e55SmrgThe output file name is determined by removing the directory component from 39113169be4bSmrgSOURCEFILE, then substituting the C source code suffix '.c' with the 39123169be4bSmrglibrary object suffix, '.lo'." 39138c4a8e55Smrg ;; 3914b042e37fSmrg 39158c4a8e55Smrg execute) 39168c4a8e55Smrg $ECHO \ 39178c4a8e55Smrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... 3918b042e37fSmrg 39198c4a8e55SmrgAutomatically set library path, then run a program. 3920b042e37fSmrg 39218c4a8e55SmrgThis mode accepts the following additional options: 3922b042e37fSmrg 39238c4a8e55Smrg -dlopen FILE add the directory containing FILE to the library path 3924b042e37fSmrg 39253169be4bSmrgThis mode sets the library path environment variable according to '-dlopen' 39268c4a8e55Smrgflags. 3927b042e37fSmrg 39288c4a8e55SmrgIf any of the ARGS are libtool executable wrappers, then they are translated 39298c4a8e55Smrginto their corresponding uninstalled binary, and any of their required library 39308c4a8e55Smrgdirectories are added to the library path. 3931b042e37fSmrg 39328c4a8e55SmrgThen, COMMAND is executed, with ARGS as arguments." 39338c4a8e55Smrg ;; 3934b042e37fSmrg 39358c4a8e55Smrg finish) 39368c4a8e55Smrg $ECHO \ 39378c4a8e55Smrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]... 3938b042e37fSmrg 39398c4a8e55SmrgComplete the installation of libtool libraries. 3940b042e37fSmrg 39418c4a8e55SmrgEach LIBDIR is a directory that contains libtool libraries. 3942b042e37fSmrg 39438c4a8e55SmrgThe commands that this mode executes may require superuser privileges. Use 39443169be4bSmrgthe '--dry-run' option if you just want to see what would be executed." 39458c4a8e55Smrg ;; 3946b042e37fSmrg 39478c4a8e55Smrg install) 39488c4a8e55Smrg $ECHO \ 39498c4a8e55Smrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... 3950b042e37fSmrg 39518c4a8e55SmrgInstall executables or libraries. 3952b042e37fSmrg 39538c4a8e55SmrgINSTALL-COMMAND is the installation command. The first component should be 39543169be4bSmrgeither the 'install' or 'cp' program. 3955b042e37fSmrg 39568c4a8e55SmrgThe following components of INSTALL-COMMAND are treated specially: 3957b042e37fSmrg 3958706b6b52Smrg -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation 3959b042e37fSmrg 39608c4a8e55SmrgThe rest of the components are interpreted as arguments to that command (only 39618c4a8e55SmrgBSD-compatible install options are recognized)." 39628c4a8e55Smrg ;; 3963b042e37fSmrg 39648c4a8e55Smrg link) 39658c4a8e55Smrg $ECHO \ 39668c4a8e55Smrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND... 3967b042e37fSmrg 39688c4a8e55SmrgLink object files or libraries together to form another library, or to 39698c4a8e55Smrgcreate an executable program. 3970b042e37fSmrg 39718c4a8e55SmrgLINK-COMMAND is a command using the C compiler that you would use to create 39728c4a8e55Smrga program from several object files. 3973b042e37fSmrg 39748c4a8e55SmrgThe following components of LINK-COMMAND are treated specially: 3975b042e37fSmrg 39768c4a8e55Smrg -all-static do not do any dynamic linking at all 39778c4a8e55Smrg -avoid-version do not add a version suffix if possible 3978706b6b52Smrg -bindir BINDIR specify path to binaries directory (for systems where 3979706b6b52Smrg libraries must be found in the PATH setting at runtime) 39803169be4bSmrg -dlopen FILE '-dlpreopen' FILE if it cannot be dlopened at runtime 39818c4a8e55Smrg -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols 39828c4a8e55Smrg -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) 39838c4a8e55Smrg -export-symbols SYMFILE 39848c4a8e55Smrg try to export only the symbols listed in SYMFILE 39858c4a8e55Smrg -export-symbols-regex REGEX 39868c4a8e55Smrg try to export only the symbols matching REGEX 39878c4a8e55Smrg -LLIBDIR search LIBDIR for required installed libraries 39888c4a8e55Smrg -lNAME OUTPUT-FILE requires the installed library libNAME 39898c4a8e55Smrg -module build a library that can dlopened 39908c4a8e55Smrg -no-fast-install disable the fast-install mode 39918c4a8e55Smrg -no-install link a not-installable executable 39928c4a8e55Smrg -no-undefined declare that a library does not refer to external symbols 39938c4a8e55Smrg -o OUTPUT-FILE create OUTPUT-FILE from the specified objects 39943169be4bSmrg -objectlist FILE use a list of object files found in FILE to specify objects 39953169be4bSmrg -os2dllname NAME force a short DLL name on OS/2 (no effect on other OSes) 39968c4a8e55Smrg -precious-files-regex REGEX 39978c4a8e55Smrg don't remove output files matching REGEX 39988c4a8e55Smrg -release RELEASE specify package release information 39998c4a8e55Smrg -rpath LIBDIR the created library will eventually be installed in LIBDIR 40008c4a8e55Smrg -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries 40018c4a8e55Smrg -shared only do dynamic linking of libtool libraries 40028c4a8e55Smrg -shrext SUFFIX override the standard shared library file extension 40038c4a8e55Smrg -static do not do any dynamic linking of uninstalled libtool libraries 40048c4a8e55Smrg -static-libtool-libs 40058c4a8e55Smrg do not do any dynamic linking of libtool libraries 40068c4a8e55Smrg -version-info CURRENT[:REVISION[:AGE]] 40078c4a8e55Smrg specify library version info [each variable defaults to 0] 40088c4a8e55Smrg -weak LIBNAME declare that the target provides the LIBNAME interface 4009706b6b52Smrg -Wc,FLAG 4010706b6b52Smrg -Xcompiler FLAG pass linker-specific FLAG directly to the compiler 40118d0bc965Smrg -Wa,FLAG 40128d0bc965Smrg -Xassembler FLAG pass linker-specific FLAG directly to the assembler 4013706b6b52Smrg -Wl,FLAG 4014706b6b52Smrg -Xlinker FLAG pass linker-specific FLAG directly to the linker 4015706b6b52Smrg -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) 4016b042e37fSmrg 40173169be4bSmrgAll other options (arguments beginning with '-') are ignored. 4018b042e37fSmrg 40193169be4bSmrgEvery other argument is treated as a filename. Files ending in '.la' are 40208c4a8e55Smrgtreated as uninstalled libtool libraries, other files are standard or library 40218c4a8e55Smrgobject files. 4022b042e37fSmrg 40233169be4bSmrgIf the OUTPUT-FILE ends in '.la', then a libtool library is created, 40243169be4bSmrgonly library objects ('.lo' files) may be specified, and '-rpath' is 40258c4a8e55Smrgrequired, except when creating a convenience library. 4026b042e37fSmrg 40273169be4bSmrgIf OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created 40283169be4bSmrgusing 'ar' and 'ranlib', or on Windows using 'lib'. 4029b042e37fSmrg 40303169be4bSmrgIf OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file 40318c4a8e55Smrgis created, otherwise an executable program is created." 40328c4a8e55Smrg ;; 4033b042e37fSmrg 40348c4a8e55Smrg uninstall) 40358c4a8e55Smrg $ECHO \ 40368c4a8e55Smrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... 4037b042e37fSmrg 40388c4a8e55SmrgRemove libraries from an installation directory. 4039b042e37fSmrg 40408c4a8e55SmrgRM is the name of the program to use to delete files associated with each FILE 40413169be4bSmrg(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 40428c4a8e55Smrgto RM. 4043b042e37fSmrg 40448c4a8e55SmrgIf FILE is a libtool library, all the files associated with it are deleted. 40458c4a8e55SmrgOtherwise, only FILE itself is deleted using RM." 4046b042e37fSmrg ;; 4047b042e37fSmrg 40488c4a8e55Smrg *) 40493169be4bSmrg func_fatal_help "invalid operation mode '$opt_mode'" 40508c4a8e55Smrg ;; 40518c4a8e55Smrg esac 4052b042e37fSmrg 4053706b6b52Smrg echo 40543169be4bSmrg $ECHO "Try '$progname --help' for more information about other modes." 40558c4a8e55Smrg} 4056b042e37fSmrg 4057706b6b52Smrg# Now that we've collected a possible --mode arg, show help if necessary 4058706b6b52Smrgif $opt_help; then 40593169be4bSmrg if test : = "$opt_help"; then 4060706b6b52Smrg func_mode_help 4061706b6b52Smrg else 4062706b6b52Smrg { 4063706b6b52Smrg func_help noexit 4064bd23fbfaSmrg for opt_mode in compile link execute install finish uninstall clean; do 4065706b6b52Smrg func_mode_help 4066706b6b52Smrg done 40673169be4bSmrg } | $SED -n '1p; 2,$s/^Usage:/ or: /p' 4068706b6b52Smrg { 4069706b6b52Smrg func_help noexit 4070bd23fbfaSmrg for opt_mode in compile link execute install finish uninstall clean; do 4071706b6b52Smrg echo 4072706b6b52Smrg func_mode_help 4073706b6b52Smrg done 4074706b6b52Smrg } | 40753169be4bSmrg $SED '1d 4076706b6b52Smrg /^When reporting/,/^Report/{ 4077706b6b52Smrg H 4078706b6b52Smrg d 4079706b6b52Smrg } 4080706b6b52Smrg $x 4081706b6b52Smrg /information about other modes/d 4082706b6b52Smrg /more detailed .*MODE/d 4083706b6b52Smrg s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' 4084706b6b52Smrg fi 4085706b6b52Smrg exit $? 4086706b6b52Smrgfi 4087b042e37fSmrg 4088b042e37fSmrg 40898c4a8e55Smrg# func_mode_execute arg... 40908c4a8e55Smrgfunc_mode_execute () 40918c4a8e55Smrg{ 40923169be4bSmrg $debug_cmd 40933169be4bSmrg 40948c4a8e55Smrg # The first argument is the command name. 40953169be4bSmrg cmd=$nonopt 40968c4a8e55Smrg test -z "$cmd" && \ 40978c4a8e55Smrg func_fatal_help "you must specify a COMMAND" 4098b042e37fSmrg 40998c4a8e55Smrg # Handle -dlopen flags immediately. 4100bd23fbfaSmrg for file in $opt_dlopen; do 41018c4a8e55Smrg test -f "$file" \ 41023169be4bSmrg || func_fatal_help "'$file' is not a file" 4103b042e37fSmrg 41048c4a8e55Smrg dir= 41058c4a8e55Smrg case $file in 41068c4a8e55Smrg *.la) 4107bd23fbfaSmrg func_resolve_sysroot "$file" 4108bd23fbfaSmrg file=$func_resolve_sysroot_result 4109bd23fbfaSmrg 41108c4a8e55Smrg # Check to see that this really is a libtool archive. 41118c4a8e55Smrg func_lalib_unsafe_p "$file" \ 41123169be4bSmrg || func_fatal_help "'$lib' is not a valid libtool archive" 4113b042e37fSmrg 41148c4a8e55Smrg # Read the libtool library. 41158c4a8e55Smrg dlname= 41168c4a8e55Smrg library_names= 41178c4a8e55Smrg func_source "$file" 4118b042e37fSmrg 41198c4a8e55Smrg # Skip this library if it cannot be dlopened. 41208c4a8e55Smrg if test -z "$dlname"; then 41218c4a8e55Smrg # Warn if it was a shared library. 41228c4a8e55Smrg test -n "$library_names" && \ 41233169be4bSmrg func_warning "'$file' was not linked with '-export-dynamic'" 41248c4a8e55Smrg continue 41258c4a8e55Smrg fi 4126b042e37fSmrg 41278c4a8e55Smrg func_dirname "$file" "" "." 41283169be4bSmrg dir=$func_dirname_result 4129b042e37fSmrg 41308c4a8e55Smrg if test -f "$dir/$objdir/$dlname"; then 4131bd23fbfaSmrg func_append dir "/$objdir" 41328c4a8e55Smrg else 41338c4a8e55Smrg if test ! -f "$dir/$dlname"; then 41343169be4bSmrg func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'" 41358c4a8e55Smrg fi 41368c4a8e55Smrg fi 4137b042e37fSmrg ;; 4138b042e37fSmrg 41398c4a8e55Smrg *.lo) 41408c4a8e55Smrg # Just add the directory containing the .lo file. 41418c4a8e55Smrg func_dirname "$file" "" "." 41423169be4bSmrg dir=$func_dirname_result 4143b042e37fSmrg ;; 4144b042e37fSmrg 41458c4a8e55Smrg *) 41463169be4bSmrg func_warning "'-dlopen' is ignored for non-libtool libraries and objects" 4147b042e37fSmrg continue 4148b042e37fSmrg ;; 41498c4a8e55Smrg esac 4150b042e37fSmrg 41518c4a8e55Smrg # Get the absolute pathname. 41528c4a8e55Smrg absdir=`cd "$dir" && pwd` 41533169be4bSmrg test -n "$absdir" && dir=$absdir 4154b042e37fSmrg 41558c4a8e55Smrg # Now add the directory to shlibpath_var. 41568c4a8e55Smrg if eval "test -z \"\$$shlibpath_var\""; then 41578c4a8e55Smrg eval "$shlibpath_var=\"\$dir\"" 41588c4a8e55Smrg else 41598c4a8e55Smrg eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" 41608c4a8e55Smrg fi 41618c4a8e55Smrg done 4162b042e37fSmrg 41638c4a8e55Smrg # This variable tells wrapper scripts just to set shlibpath_var 41648c4a8e55Smrg # rather than running their programs. 41653169be4bSmrg libtool_execute_magic=$magic 4166b042e37fSmrg 41678c4a8e55Smrg # Check if any of the arguments is a wrapper script. 41688c4a8e55Smrg args= 41698c4a8e55Smrg for file 41708c4a8e55Smrg do 41718c4a8e55Smrg case $file in 4172706b6b52Smrg -* | *.la | *.lo ) ;; 41738c4a8e55Smrg *) 41748c4a8e55Smrg # Do a test to see if this is really a libtool program. 41758c4a8e55Smrg if func_ltwrapper_script_p "$file"; then 41768c4a8e55Smrg func_source "$file" 41778c4a8e55Smrg # Transform arg to wrapped name. 41783169be4bSmrg file=$progdir/$program 41798c4a8e55Smrg elif func_ltwrapper_executable_p "$file"; then 41808c4a8e55Smrg func_ltwrapper_scriptname "$file" 41818c4a8e55Smrg func_source "$func_ltwrapper_scriptname_result" 41828c4a8e55Smrg # Transform arg to wrapped name. 41833169be4bSmrg file=$progdir/$program 41848c4a8e55Smrg fi 4185b042e37fSmrg ;; 41868c4a8e55Smrg esac 41878c4a8e55Smrg # Quote arguments (to preserve shell metacharacters). 4188bd23fbfaSmrg func_append_quoted args "$file" 41898c4a8e55Smrg done 4190b042e37fSmrg 41913169be4bSmrg if $opt_dry_run; then 41923169be4bSmrg # Display what would be done. 41933169be4bSmrg if test -n "$shlibpath_var"; then 41943169be4bSmrg eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" 41953169be4bSmrg echo "export $shlibpath_var" 41963169be4bSmrg fi 41973169be4bSmrg $ECHO "$cmd$args" 41983169be4bSmrg exit $EXIT_SUCCESS 41993169be4bSmrg else 42008c4a8e55Smrg if test -n "$shlibpath_var"; then 42018c4a8e55Smrg # Export the shlibpath_var. 42028c4a8e55Smrg eval "export $shlibpath_var" 42038c4a8e55Smrg fi 4204b042e37fSmrg 42058c4a8e55Smrg # Restore saved environment variables 42068c4a8e55Smrg for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 42078c4a8e55Smrg do 42088c4a8e55Smrg eval "if test \"\${save_$lt_var+set}\" = set; then 42098c4a8e55Smrg $lt_var=\$save_$lt_var; export $lt_var 42108c4a8e55Smrg else 42118c4a8e55Smrg $lt_unset $lt_var 42128c4a8e55Smrg fi" 42138c4a8e55Smrg done 4214b042e37fSmrg 42158c4a8e55Smrg # Now prepare to actually exec the command. 42163169be4bSmrg exec_cmd=\$cmd$args 42178c4a8e55Smrg fi 42188c4a8e55Smrg} 4219b042e37fSmrg 42203169be4bSmrgtest execute = "$opt_mode" && func_mode_execute ${1+"$@"} 4221b042e37fSmrg 4222b042e37fSmrg 42238c4a8e55Smrg# func_mode_finish arg... 42248c4a8e55Smrgfunc_mode_finish () 42258c4a8e55Smrg{ 42263169be4bSmrg $debug_cmd 42273169be4bSmrg 4228bd23fbfaSmrg libs= 4229bd23fbfaSmrg libdirs= 42308c4a8e55Smrg admincmds= 4231b042e37fSmrg 4232bd23fbfaSmrg for opt in "$nonopt" ${1+"$@"} 4233bd23fbfaSmrg do 4234bd23fbfaSmrg if test -d "$opt"; then 4235bd23fbfaSmrg func_append libdirs " $opt" 4236bd23fbfaSmrg 4237bd23fbfaSmrg elif test -f "$opt"; then 4238bd23fbfaSmrg if func_lalib_unsafe_p "$opt"; then 4239bd23fbfaSmrg func_append libs " $opt" 4240bd23fbfaSmrg else 42413169be4bSmrg func_warning "'$opt' is not a valid libtool archive" 4242bd23fbfaSmrg fi 4243bd23fbfaSmrg 4244bd23fbfaSmrg else 42453169be4bSmrg func_fatal_error "invalid argument '$opt'" 4246bd23fbfaSmrg fi 4247bd23fbfaSmrg done 4248bd23fbfaSmrg 4249bd23fbfaSmrg if test -n "$libs"; then 4250bd23fbfaSmrg if test -n "$lt_sysroot"; then 4251bd23fbfaSmrg sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` 4252bd23fbfaSmrg sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" 4253bd23fbfaSmrg else 4254bd23fbfaSmrg sysroot_cmd= 4255bd23fbfaSmrg fi 4256bd23fbfaSmrg 4257bd23fbfaSmrg # Remove sysroot references 4258bd23fbfaSmrg if $opt_dry_run; then 4259bd23fbfaSmrg for lib in $libs; do 42603169be4bSmrg echo "removing references to $lt_sysroot and '=' prefixes from $lib" 4261bd23fbfaSmrg done 4262bd23fbfaSmrg else 4263bd23fbfaSmrg tmpdir=`func_mktempdir` 4264bd23fbfaSmrg for lib in $libs; do 42653169be4bSmrg $SED -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ 4266bd23fbfaSmrg > $tmpdir/tmp-la 4267bd23fbfaSmrg mv -f $tmpdir/tmp-la $lib 4268bd23fbfaSmrg done 4269bd23fbfaSmrg ${RM}r "$tmpdir" 4270bd23fbfaSmrg fi 4271bd23fbfaSmrg fi 4272b042e37fSmrg 4273bd23fbfaSmrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 42748c4a8e55Smrg for libdir in $libdirs; do 42758c4a8e55Smrg if test -n "$finish_cmds"; then 42768c4a8e55Smrg # Do each command in the finish commands. 42778c4a8e55Smrg func_execute_cmds "$finish_cmds" 'admincmds="$admincmds 42788c4a8e55Smrg'"$cmd"'"' 42798c4a8e55Smrg fi 42808c4a8e55Smrg if test -n "$finish_eval"; then 42818c4a8e55Smrg # Do the single finish_eval. 42828c4a8e55Smrg eval cmds=\"$finish_eval\" 4283bd23fbfaSmrg $opt_dry_run || eval "$cmds" || func_append admincmds " 42848c4a8e55Smrg $cmds" 42858c4a8e55Smrg fi 42868c4a8e55Smrg done 42878c4a8e55Smrg fi 4288b042e37fSmrg 42898c4a8e55Smrg # Exit here if they wanted silent mode. 42903169be4bSmrg $opt_quiet && exit $EXIT_SUCCESS 4291b042e37fSmrg 4292bd23fbfaSmrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 4293bd23fbfaSmrg echo "----------------------------------------------------------------------" 4294bd23fbfaSmrg echo "Libraries have been installed in:" 4295bd23fbfaSmrg for libdir in $libdirs; do 4296bd23fbfaSmrg $ECHO " $libdir" 4297bd23fbfaSmrg done 4298bd23fbfaSmrg echo 4299bd23fbfaSmrg echo "If you ever happen to want to link against installed libraries" 4300bd23fbfaSmrg echo "in a given directory, LIBDIR, you must either use libtool, and" 43013169be4bSmrg echo "specify the full pathname of the library, or use the '-LLIBDIR'" 4302bd23fbfaSmrg echo "flag during linking and do at least one of the following:" 4303bd23fbfaSmrg if test -n "$shlibpath_var"; then 43043169be4bSmrg echo " - add LIBDIR to the '$shlibpath_var' environment variable" 4305bd23fbfaSmrg echo " during execution" 4306bd23fbfaSmrg fi 4307bd23fbfaSmrg if test -n "$runpath_var"; then 43083169be4bSmrg echo " - add LIBDIR to the '$runpath_var' environment variable" 4309bd23fbfaSmrg echo " during linking" 4310bd23fbfaSmrg fi 4311bd23fbfaSmrg if test -n "$hardcode_libdir_flag_spec"; then 4312bd23fbfaSmrg libdir=LIBDIR 4313bd23fbfaSmrg eval flag=\"$hardcode_libdir_flag_spec\" 4314b042e37fSmrg 43153169be4bSmrg $ECHO " - use the '$flag' linker flag" 4316bd23fbfaSmrg fi 4317bd23fbfaSmrg if test -n "$admincmds"; then 4318bd23fbfaSmrg $ECHO " - have your system administrator run these commands:$admincmds" 4319bd23fbfaSmrg fi 4320bd23fbfaSmrg if test -f /etc/ld.so.conf; then 43213169be4bSmrg echo " - have your system administrator add LIBDIR to '/etc/ld.so.conf'" 4322bd23fbfaSmrg fi 4323bd23fbfaSmrg echo 4324b042e37fSmrg 4325bd23fbfaSmrg echo "See any operating system documentation about shared libraries for" 4326bd23fbfaSmrg case $host in 4327bd23fbfaSmrg solaris2.[6789]|solaris2.1[0-9]) 4328bd23fbfaSmrg echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" 4329bd23fbfaSmrg echo "pages." 4330bd23fbfaSmrg ;; 4331bd23fbfaSmrg *) 4332bd23fbfaSmrg echo "more information, such as the ld(1) and ld.so(8) manual pages." 4333bd23fbfaSmrg ;; 4334bd23fbfaSmrg esac 4335bd23fbfaSmrg echo "----------------------------------------------------------------------" 4336bd23fbfaSmrg fi 43378c4a8e55Smrg exit $EXIT_SUCCESS 43388c4a8e55Smrg} 4339b042e37fSmrg 43403169be4bSmrgtest finish = "$opt_mode" && func_mode_finish ${1+"$@"} 4341b042e37fSmrg 4342b042e37fSmrg 43438c4a8e55Smrg# func_mode_install arg... 43448c4a8e55Smrgfunc_mode_install () 43458c4a8e55Smrg{ 43463169be4bSmrg $debug_cmd 43473169be4bSmrg 43488c4a8e55Smrg # There may be an optional sh(1) argument at the beginning of 43498c4a8e55Smrg # install_prog (especially on Windows NT). 43503169be4bSmrg if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" || 43518c4a8e55Smrg # Allow the use of GNU shtool's install command. 43523169be4bSmrg case $nonopt in *shtool*) :;; *) false;; esac 43533169be4bSmrg then 43548c4a8e55Smrg # Aesthetically quote it. 43558d0bc965Smrg func_quote_arg pretty "$nonopt" 43568d0bc965Smrg install_prog="$func_quote_arg_result " 43578c4a8e55Smrg arg=$1 43588c4a8e55Smrg shift 43598c4a8e55Smrg else 43608c4a8e55Smrg install_prog= 43618c4a8e55Smrg arg=$nonopt 43628c4a8e55Smrg fi 43638c4a8e55Smrg 43648c4a8e55Smrg # The real first argument should be the name of the installation program. 43658c4a8e55Smrg # Aesthetically quote it. 43668d0bc965Smrg func_quote_arg pretty "$arg" 43678d0bc965Smrg func_append install_prog "$func_quote_arg_result" 4368706b6b52Smrg install_shared_prog=$install_prog 4369706b6b52Smrg case " $install_prog " in 4370706b6b52Smrg *[\\\ /]cp\ *) install_cp=: ;; 4371706b6b52Smrg *) install_cp=false ;; 4372706b6b52Smrg esac 43738c4a8e55Smrg 43748c4a8e55Smrg # We need to accept at least all the BSD install flags. 43758c4a8e55Smrg dest= 43768c4a8e55Smrg files= 43778c4a8e55Smrg opts= 43788c4a8e55Smrg prev= 43798c4a8e55Smrg install_type= 43803169be4bSmrg isdir=false 43818c4a8e55Smrg stripme= 4382706b6b52Smrg no_mode=: 43838c4a8e55Smrg for arg 43848c4a8e55Smrg do 4385706b6b52Smrg arg2= 43868c4a8e55Smrg if test -n "$dest"; then 4387bd23fbfaSmrg func_append files " $dest" 43888c4a8e55Smrg dest=$arg 4389b042e37fSmrg continue 43908c4a8e55Smrg fi 4391b042e37fSmrg 43928c4a8e55Smrg case $arg in 43933169be4bSmrg -d) isdir=: ;; 43948c4a8e55Smrg -f) 4395706b6b52Smrg if $install_cp; then :; else 4396706b6b52Smrg prev=$arg 4397706b6b52Smrg fi 4398b042e37fSmrg ;; 43998c4a8e55Smrg -g | -m | -o) 44008c4a8e55Smrg prev=$arg 44018c4a8e55Smrg ;; 44028c4a8e55Smrg -s) 44038c4a8e55Smrg stripme=" -s" 44048c4a8e55Smrg continue 44058c4a8e55Smrg ;; 44068c4a8e55Smrg -*) 44078c4a8e55Smrg ;; 44088c4a8e55Smrg *) 44098c4a8e55Smrg # If the previous option needed an argument, then skip it. 44108c4a8e55Smrg if test -n "$prev"; then 44113169be4bSmrg if test X-m = "X$prev" && test -n "$install_override_mode"; then 4412706b6b52Smrg arg2=$install_override_mode 4413706b6b52Smrg no_mode=false 4414706b6b52Smrg fi 44158c4a8e55Smrg prev= 44168c4a8e55Smrg else 44178c4a8e55Smrg dest=$arg 44188c4a8e55Smrg continue 44198c4a8e55Smrg fi 44208c4a8e55Smrg ;; 44218c4a8e55Smrg esac 4422b042e37fSmrg 44238c4a8e55Smrg # Aesthetically quote the argument. 44248d0bc965Smrg func_quote_arg pretty "$arg" 44258d0bc965Smrg func_append install_prog " $func_quote_arg_result" 4426706b6b52Smrg if test -n "$arg2"; then 44278d0bc965Smrg func_quote_arg pretty "$arg2" 4428706b6b52Smrg fi 44298d0bc965Smrg func_append install_shared_prog " $func_quote_arg_result" 44308c4a8e55Smrg done 4431b042e37fSmrg 44328c4a8e55Smrg test -z "$install_prog" && \ 44338c4a8e55Smrg func_fatal_help "you must specify an install program" 4434b042e37fSmrg 44358c4a8e55Smrg test -n "$prev" && \ 44363169be4bSmrg func_fatal_help "the '$prev' option requires an argument" 44378c4a8e55Smrg 4438706b6b52Smrg if test -n "$install_override_mode" && $no_mode; then 4439706b6b52Smrg if $install_cp; then :; else 44408d0bc965Smrg func_quote_arg pretty "$install_override_mode" 44418d0bc965Smrg func_append install_shared_prog " -m $func_quote_arg_result" 4442706b6b52Smrg fi 4443706b6b52Smrg fi 4444706b6b52Smrg 44458c4a8e55Smrg if test -z "$files"; then 44468c4a8e55Smrg if test -z "$dest"; then 44478c4a8e55Smrg func_fatal_help "no file or destination specified" 44488c4a8e55Smrg else 44498c4a8e55Smrg func_fatal_help "you must specify a destination" 44508c4a8e55Smrg fi 4451b042e37fSmrg fi 4452b042e37fSmrg 44538c4a8e55Smrg # Strip any trailing slash from the destination. 44548c4a8e55Smrg func_stripname '' '/' "$dest" 44558c4a8e55Smrg dest=$func_stripname_result 4456b042e37fSmrg 44578c4a8e55Smrg # Check to see that the destination is a directory. 44583169be4bSmrg test -d "$dest" && isdir=: 44593169be4bSmrg if $isdir; then 44603169be4bSmrg destdir=$dest 44618c4a8e55Smrg destname= 4462b042e37fSmrg else 44638c4a8e55Smrg func_dirname_and_basename "$dest" "" "." 44643169be4bSmrg destdir=$func_dirname_result 44653169be4bSmrg destname=$func_basename_result 4466b042e37fSmrg 44678c4a8e55Smrg # Not a directory, so check to see that there is only one file specified. 44688c4a8e55Smrg set dummy $files; shift 44698c4a8e55Smrg test "$#" -gt 1 && \ 44703169be4bSmrg func_fatal_help "'$dest' is not a directory" 4471b042e37fSmrg fi 44728c4a8e55Smrg case $destdir in 44738c4a8e55Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 4474b042e37fSmrg *) 44758c4a8e55Smrg for file in $files; do 44768c4a8e55Smrg case $file in 44778c4a8e55Smrg *.lo) ;; 44788c4a8e55Smrg *) 44793169be4bSmrg func_fatal_help "'$destdir' must be an absolute directory name" 44808c4a8e55Smrg ;; 44818c4a8e55Smrg esac 44828c4a8e55Smrg done 4483b042e37fSmrg ;; 4484b042e37fSmrg esac 4485b042e37fSmrg 44868c4a8e55Smrg # This variable tells wrapper scripts just to set variables rather 44878c4a8e55Smrg # than running their programs. 44883169be4bSmrg libtool_install_magic=$magic 4489b042e37fSmrg 44908c4a8e55Smrg staticlibs= 44918c4a8e55Smrg future_libdirs= 44928c4a8e55Smrg current_libdirs= 44938c4a8e55Smrg for file in $files; do 4494b042e37fSmrg 44958c4a8e55Smrg # Do each installation. 44968c4a8e55Smrg case $file in 44978c4a8e55Smrg *.$libext) 44988c4a8e55Smrg # Do the static libraries later. 4499bd23fbfaSmrg func_append staticlibs " $file" 45008c4a8e55Smrg ;; 45018c4a8e55Smrg 45028c4a8e55Smrg *.la) 4503bd23fbfaSmrg func_resolve_sysroot "$file" 4504bd23fbfaSmrg file=$func_resolve_sysroot_result 4505bd23fbfaSmrg 45068c4a8e55Smrg # Check to see that this really is a libtool archive. 45078c4a8e55Smrg func_lalib_unsafe_p "$file" \ 45083169be4bSmrg || func_fatal_help "'$file' is not a valid libtool archive" 45098c4a8e55Smrg 45108c4a8e55Smrg library_names= 45118c4a8e55Smrg old_library= 45128c4a8e55Smrg relink_command= 45138c4a8e55Smrg func_source "$file" 45148c4a8e55Smrg 45158c4a8e55Smrg # Add the libdir to current_libdirs if it is the destination. 45168c4a8e55Smrg if test "X$destdir" = "X$libdir"; then 45178c4a8e55Smrg case "$current_libdirs " in 45188c4a8e55Smrg *" $libdir "*) ;; 4519bd23fbfaSmrg *) func_append current_libdirs " $libdir" ;; 4520b042e37fSmrg esac 45218c4a8e55Smrg else 45228c4a8e55Smrg # Note the libdir as a future libdir. 45238c4a8e55Smrg case "$future_libdirs " in 45248c4a8e55Smrg *" $libdir "*) ;; 4525bd23fbfaSmrg *) func_append future_libdirs " $libdir" ;; 45268c4a8e55Smrg esac 45278c4a8e55Smrg fi 4528b042e37fSmrg 45298c4a8e55Smrg func_dirname "$file" "/" "" 45303169be4bSmrg dir=$func_dirname_result 4531bd23fbfaSmrg func_append dir "$objdir" 45328c4a8e55Smrg 45338c4a8e55Smrg if test -n "$relink_command"; then 45348c4a8e55Smrg # Determine the prefix the user has applied to our future dir. 4535706b6b52Smrg inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` 45368c4a8e55Smrg 45378c4a8e55Smrg # Don't allow the user to place us outside of our expected 45388c4a8e55Smrg # location b/c this prevents finding dependent libraries that 45398c4a8e55Smrg # are installed to the same prefix. 45408c4a8e55Smrg # At present, this check doesn't affect windows .dll's that 45418c4a8e55Smrg # are installed into $libdir/../bin (currently, that works fine) 45428c4a8e55Smrg # but it's something to keep an eye on. 45438c4a8e55Smrg test "$inst_prefix_dir" = "$destdir" && \ 45443169be4bSmrg func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir" 45458c4a8e55Smrg 45468c4a8e55Smrg if test -n "$inst_prefix_dir"; then 45478c4a8e55Smrg # Stick the inst_prefix_dir data into the link command. 4548706b6b52Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` 45498c4a8e55Smrg else 4550706b6b52Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` 45518c4a8e55Smrg fi 45528c4a8e55Smrg 45533169be4bSmrg func_warning "relinking '$file'" 45548c4a8e55Smrg func_show_eval "$relink_command" \ 45553169be4bSmrg 'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"' 45568c4a8e55Smrg fi 45578c4a8e55Smrg 45588c4a8e55Smrg # See the names of the shared library. 45598c4a8e55Smrg set dummy $library_names; shift 45608c4a8e55Smrg if test -n "$1"; then 45613169be4bSmrg realname=$1 45628c4a8e55Smrg shift 45638c4a8e55Smrg 45643169be4bSmrg srcname=$realname 45653169be4bSmrg test -n "$relink_command" && srcname=${realname}T 45668c4a8e55Smrg 45678c4a8e55Smrg # Install the shared library and build the symlinks. 4568706b6b52Smrg func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ 45698c4a8e55Smrg 'exit $?' 45703169be4bSmrg tstripme=$stripme 45718c4a8e55Smrg case $host_os in 45728c4a8e55Smrg cygwin* | mingw* | pw32* | cegcc*) 45738c4a8e55Smrg case $realname in 45748c4a8e55Smrg *.dll.a) 45753169be4bSmrg tstripme= 45763169be4bSmrg ;; 45773169be4bSmrg esac 45783169be4bSmrg ;; 45793169be4bSmrg os2*) 45803169be4bSmrg case $realname in 45813169be4bSmrg *_dll.a) 45823169be4bSmrg tstripme= 45838c4a8e55Smrg ;; 45848c4a8e55Smrg esac 4585b042e37fSmrg ;; 4586b042e37fSmrg esac 45878c4a8e55Smrg if test -n "$tstripme" && test -n "$striplib"; then 45888c4a8e55Smrg func_show_eval "$striplib $destdir/$realname" 'exit $?' 4589b042e37fSmrg fi 4590b042e37fSmrg 45918c4a8e55Smrg if test "$#" -gt 0; then 45928c4a8e55Smrg # Delete the old symlinks, and create new ones. 45933169be4bSmrg # Try 'ln -sf' first, because the 'ln' binary might depend on 45948c4a8e55Smrg # the symlink we replace! Solaris /bin/ln does not understand -f, 45958c4a8e55Smrg # so we also need to try rm && ln -s. 45968c4a8e55Smrg for linkname 45978c4a8e55Smrg do 45988c4a8e55Smrg test "$linkname" != "$realname" \ 45998c4a8e55Smrg && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" 4600b042e37fSmrg done 4601b042e37fSmrg fi 4602b042e37fSmrg 46038c4a8e55Smrg # Do each command in the postinstall commands. 46043169be4bSmrg lib=$destdir/$realname 46058c4a8e55Smrg func_execute_cmds "$postinstall_cmds" 'exit $?' 4606b042e37fSmrg fi 4607b042e37fSmrg 46088c4a8e55Smrg # Install the pseudo-library for information purposes. 46098c4a8e55Smrg func_basename "$file" 46103169be4bSmrg name=$func_basename_result 46113169be4bSmrg instname=$dir/${name}i 46128c4a8e55Smrg func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' 4613b042e37fSmrg 46148c4a8e55Smrg # Maybe install the static library, too. 4615bd23fbfaSmrg test -n "$old_library" && func_append staticlibs " $dir/$old_library" 46168c4a8e55Smrg ;; 4617b042e37fSmrg 46188c4a8e55Smrg *.lo) 46198c4a8e55Smrg # Install (i.e. copy) a libtool object. 4620b042e37fSmrg 46218c4a8e55Smrg # Figure out destination file name, if it wasn't already specified. 46228c4a8e55Smrg if test -n "$destname"; then 46233169be4bSmrg destfile=$destdir/$destname 46248c4a8e55Smrg else 46258c4a8e55Smrg func_basename "$file" 46263169be4bSmrg destfile=$func_basename_result 46273169be4bSmrg destfile=$destdir/$destfile 4628b042e37fSmrg fi 4629b042e37fSmrg 46308c4a8e55Smrg # Deduce the name of the destination old-style object file. 46318c4a8e55Smrg case $destfile in 46328c4a8e55Smrg *.lo) 46338c4a8e55Smrg func_lo2o "$destfile" 46348c4a8e55Smrg staticdest=$func_lo2o_result 46358c4a8e55Smrg ;; 46368c4a8e55Smrg *.$objext) 46373169be4bSmrg staticdest=$destfile 46388c4a8e55Smrg destfile= 46398c4a8e55Smrg ;; 46408c4a8e55Smrg *) 46413169be4bSmrg func_fatal_help "cannot copy a libtool object to '$destfile'" 46428c4a8e55Smrg ;; 46438c4a8e55Smrg esac 4644b042e37fSmrg 46458c4a8e55Smrg # Install the libtool object if requested. 46468c4a8e55Smrg test -n "$destfile" && \ 46478c4a8e55Smrg func_show_eval "$install_prog $file $destfile" 'exit $?' 4648b042e37fSmrg 46498c4a8e55Smrg # Install the old object if enabled. 46503169be4bSmrg if test yes = "$build_old_libs"; then 46518c4a8e55Smrg # Deduce the name of the old-style object file. 46528c4a8e55Smrg func_lo2o "$file" 46538c4a8e55Smrg staticobj=$func_lo2o_result 46548c4a8e55Smrg func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' 4655b042e37fSmrg fi 46568c4a8e55Smrg exit $EXIT_SUCCESS 46578c4a8e55Smrg ;; 4658b042e37fSmrg 46598c4a8e55Smrg *) 46608c4a8e55Smrg # Figure out destination file name, if it wasn't already specified. 46618c4a8e55Smrg if test -n "$destname"; then 46623169be4bSmrg destfile=$destdir/$destname 46638c4a8e55Smrg else 46648c4a8e55Smrg func_basename "$file" 46653169be4bSmrg destfile=$func_basename_result 46663169be4bSmrg destfile=$destdir/$destfile 46678c4a8e55Smrg fi 4668b042e37fSmrg 46698c4a8e55Smrg # If the file is missing, and there is a .exe on the end, strip it 46708c4a8e55Smrg # because it is most likely a libtool script we actually want to 46718c4a8e55Smrg # install 46723169be4bSmrg stripped_ext= 46738c4a8e55Smrg case $file in 46748c4a8e55Smrg *.exe) 46758c4a8e55Smrg if test ! -f "$file"; then 46768c4a8e55Smrg func_stripname '' '.exe' "$file" 46778c4a8e55Smrg file=$func_stripname_result 46783169be4bSmrg stripped_ext=.exe 46798c4a8e55Smrg fi 46808c4a8e55Smrg ;; 46818c4a8e55Smrg esac 46828c4a8e55Smrg 46838c4a8e55Smrg # Do a test to see if this is really a libtool program. 46848c4a8e55Smrg case $host in 46858c4a8e55Smrg *cygwin* | *mingw*) 46868c4a8e55Smrg if func_ltwrapper_executable_p "$file"; then 46878c4a8e55Smrg func_ltwrapper_scriptname "$file" 46888c4a8e55Smrg wrapper=$func_ltwrapper_scriptname_result 46898c4a8e55Smrg else 46908c4a8e55Smrg func_stripname '' '.exe' "$file" 46918c4a8e55Smrg wrapper=$func_stripname_result 46928c4a8e55Smrg fi 46938c4a8e55Smrg ;; 4694b042e37fSmrg *) 46958c4a8e55Smrg wrapper=$file 46968c4a8e55Smrg ;; 46978c4a8e55Smrg esac 46988c4a8e55Smrg if func_ltwrapper_script_p "$wrapper"; then 46998c4a8e55Smrg notinst_deplibs= 47008c4a8e55Smrg relink_command= 47018c4a8e55Smrg 47028c4a8e55Smrg func_source "$wrapper" 47038c4a8e55Smrg 47048c4a8e55Smrg # Check the variables that should have been set. 47058c4a8e55Smrg test -z "$generated_by_libtool_version" && \ 47063169be4bSmrg func_fatal_error "invalid libtool wrapper script '$wrapper'" 47078c4a8e55Smrg 47083169be4bSmrg finalize=: 47098c4a8e55Smrg for lib in $notinst_deplibs; do 47108c4a8e55Smrg # Check to see that each library is installed. 47118c4a8e55Smrg libdir= 47128c4a8e55Smrg if test -f "$lib"; then 47138c4a8e55Smrg func_source "$lib" 47148c4a8e55Smrg fi 47153169be4bSmrg libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'` 47168c4a8e55Smrg if test -n "$libdir" && test ! -f "$libfile"; then 47173169be4bSmrg func_warning "'$lib' has not been installed in '$libdir'" 47183169be4bSmrg finalize=false 47198c4a8e55Smrg fi 47208c4a8e55Smrg done 47218c4a8e55Smrg 47228c4a8e55Smrg relink_command= 47238c4a8e55Smrg func_source "$wrapper" 47248c4a8e55Smrg 47258c4a8e55Smrg outputname= 47263169be4bSmrg if test no = "$fast_install" && test -n "$relink_command"; then 47278c4a8e55Smrg $opt_dry_run || { 47283169be4bSmrg if $finalize; then 47298c4a8e55Smrg tmpdir=`func_mktempdir` 47308c4a8e55Smrg func_basename "$file$stripped_ext" 47313169be4bSmrg file=$func_basename_result 47323169be4bSmrg outputname=$tmpdir/$file 47338c4a8e55Smrg # Replace the output file specification. 4734706b6b52Smrg relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` 47358c4a8e55Smrg 47363169be4bSmrg $opt_quiet || { 47378d0bc965Smrg func_quote_arg expand,pretty "$relink_command" 47388d0bc965Smrg eval "func_echo $func_quote_arg_result" 47398c4a8e55Smrg } 47408c4a8e55Smrg if eval "$relink_command"; then : 47418c4a8e55Smrg else 47423169be4bSmrg func_error "error: relink '$file' with the above command before installing it" 47438c4a8e55Smrg $opt_dry_run || ${RM}r "$tmpdir" 47448c4a8e55Smrg continue 47458c4a8e55Smrg fi 47463169be4bSmrg file=$outputname 47478c4a8e55Smrg else 47483169be4bSmrg func_warning "cannot relink '$file'" 47498c4a8e55Smrg fi 47508c4a8e55Smrg } 47518c4a8e55Smrg else 47528c4a8e55Smrg # Install the binary that we compiled earlier. 4753706b6b52Smrg file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` 4754b042e37fSmrg fi 47558c4a8e55Smrg fi 47568c4a8e55Smrg 47578c4a8e55Smrg # remove .exe since cygwin /usr/bin/install will append another 47588c4a8e55Smrg # one anyway 47598c4a8e55Smrg case $install_prog,$host in 47608c4a8e55Smrg */usr/bin/install*,*cygwin*) 47618c4a8e55Smrg case $file:$destfile in 47628c4a8e55Smrg *.exe:*.exe) 47638c4a8e55Smrg # this is ok 47648c4a8e55Smrg ;; 47658c4a8e55Smrg *.exe:*) 47668c4a8e55Smrg destfile=$destfile.exe 47678c4a8e55Smrg ;; 47688c4a8e55Smrg *:*.exe) 47698c4a8e55Smrg func_stripname '' '.exe' "$destfile" 47708c4a8e55Smrg destfile=$func_stripname_result 47718c4a8e55Smrg ;; 47728c4a8e55Smrg esac 4773b042e37fSmrg ;; 4774b042e37fSmrg esac 47758c4a8e55Smrg func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' 47768c4a8e55Smrg $opt_dry_run || if test -n "$outputname"; then 47778c4a8e55Smrg ${RM}r "$tmpdir" 47788c4a8e55Smrg fi 47798c4a8e55Smrg ;; 47808c4a8e55Smrg esac 47818c4a8e55Smrg done 4782b042e37fSmrg 47838c4a8e55Smrg for file in $staticlibs; do 47848c4a8e55Smrg func_basename "$file" 47853169be4bSmrg name=$func_basename_result 47868c4a8e55Smrg 47878c4a8e55Smrg # Set up the ranlib parameters. 47883169be4bSmrg oldlib=$destdir/$name 47890597fb56Smrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 47900597fb56Smrg tool_oldlib=$func_to_tool_file_result 47918c4a8e55Smrg 47928c4a8e55Smrg func_show_eval "$install_prog \$file \$oldlib" 'exit $?' 47938c4a8e55Smrg 47948c4a8e55Smrg if test -n "$stripme" && test -n "$old_striplib"; then 47950597fb56Smrg func_show_eval "$old_striplib $tool_oldlib" 'exit $?' 47968c4a8e55Smrg fi 47978c4a8e55Smrg 47988c4a8e55Smrg # Do each command in the postinstall commands. 47998c4a8e55Smrg func_execute_cmds "$old_postinstall_cmds" 'exit $?' 48008c4a8e55Smrg done 48018c4a8e55Smrg 48028c4a8e55Smrg test -n "$future_libdirs" && \ 48033169be4bSmrg func_warning "remember to run '$progname --finish$future_libdirs'" 48048c4a8e55Smrg 48058c4a8e55Smrg if test -n "$current_libdirs"; then 48068c4a8e55Smrg # Maybe just do a dry run. 48078c4a8e55Smrg $opt_dry_run && current_libdirs=" -n$current_libdirs" 48083169be4bSmrg exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs' 48098c4a8e55Smrg else 48108c4a8e55Smrg exit $EXIT_SUCCESS 48118c4a8e55Smrg fi 48128c4a8e55Smrg} 48138c4a8e55Smrg 48143169be4bSmrgtest install = "$opt_mode" && func_mode_install ${1+"$@"} 48158c4a8e55Smrg 48168c4a8e55Smrg 48178c4a8e55Smrg# func_generate_dlsyms outputname originator pic_p 48188c4a8e55Smrg# Extract symbols from dlprefiles and create ${outputname}S.o with 48198c4a8e55Smrg# a dlpreopen symbol table. 48208c4a8e55Smrgfunc_generate_dlsyms () 48218c4a8e55Smrg{ 48223169be4bSmrg $debug_cmd 48233169be4bSmrg 48243169be4bSmrg my_outputname=$1 48253169be4bSmrg my_originator=$2 48263169be4bSmrg my_pic_p=${3-false} 48273169be4bSmrg my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'` 48288c4a8e55Smrg my_dlsyms= 48298c4a8e55Smrg 48303169be4bSmrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 48318c4a8e55Smrg if test -n "$NM" && test -n "$global_symbol_pipe"; then 48323169be4bSmrg my_dlsyms=${my_outputname}S.c 48338c4a8e55Smrg else 48348c4a8e55Smrg func_error "not configured to extract global symbols from dlpreopened files" 48358c4a8e55Smrg fi 48368c4a8e55Smrg fi 48378c4a8e55Smrg 48388c4a8e55Smrg if test -n "$my_dlsyms"; then 48398c4a8e55Smrg case $my_dlsyms in 48408c4a8e55Smrg "") ;; 48418c4a8e55Smrg *.c) 48428c4a8e55Smrg # Discover the nlist of each of the dlfiles. 48433169be4bSmrg nlist=$output_objdir/$my_outputname.nm 48448c4a8e55Smrg 48458c4a8e55Smrg func_show_eval "$RM $nlist ${nlist}S ${nlist}T" 48468c4a8e55Smrg 48478c4a8e55Smrg # Parse the name list into a source file. 48488c4a8e55Smrg func_verbose "creating $output_objdir/$my_dlsyms" 48498c4a8e55Smrg 48508c4a8e55Smrg $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ 48513169be4bSmrg/* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */ 48523169be4bSmrg/* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */ 48538c4a8e55Smrg 48548c4a8e55Smrg#ifdef __cplusplus 48558c4a8e55Smrgextern \"C\" { 48568c4a8e55Smrg#endif 48578c4a8e55Smrg 48583169be4bSmrg#if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) 4859706b6b52Smrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\" 4860706b6b52Smrg#endif 4861706b6b52Smrg 4862bd23fbfaSmrg/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ 48633169be4bSmrg#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE 48643169be4bSmrg/* DATA imports from DLLs on WIN32 can't be const, because runtime 4865bd23fbfaSmrg relocations are performed -- see ld's documentation on pseudo-relocs. */ 4866bd23fbfaSmrg# define LT_DLSYM_CONST 48673169be4bSmrg#elif defined __osf__ 4868bd23fbfaSmrg/* This system does not cope well with relocations in const data. */ 4869bd23fbfaSmrg# define LT_DLSYM_CONST 4870bd23fbfaSmrg#else 4871bd23fbfaSmrg# define LT_DLSYM_CONST const 4872bd23fbfaSmrg#endif 4873bd23fbfaSmrg 48743169be4bSmrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 48753169be4bSmrg 48768c4a8e55Smrg/* External symbol declarations for the compiler. */\ 48778c4a8e55Smrg" 48788c4a8e55Smrg 48793169be4bSmrg if test yes = "$dlself"; then 48803169be4bSmrg func_verbose "generating symbol list for '$output'" 48818c4a8e55Smrg 48828c4a8e55Smrg $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" 48838c4a8e55Smrg 48848c4a8e55Smrg # Add our own program objects to the symbol list. 4885706b6b52Smrg progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` 48868c4a8e55Smrg for progfile in $progfiles; do 4887bd23fbfaSmrg func_to_tool_file "$progfile" func_convert_file_msys_to_w32 48883169be4bSmrg func_verbose "extracting global C symbols from '$func_to_tool_file_result'" 4889bd23fbfaSmrg $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" 48908c4a8e55Smrg done 48918c4a8e55Smrg 48928c4a8e55Smrg if test -n "$exclude_expsyms"; then 48938c4a8e55Smrg $opt_dry_run || { 48948c4a8e55Smrg eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' 48958c4a8e55Smrg eval '$MV "$nlist"T "$nlist"' 48968c4a8e55Smrg } 4897b042e37fSmrg fi 48988c4a8e55Smrg 48998c4a8e55Smrg if test -n "$export_symbols_regex"; then 49008c4a8e55Smrg $opt_dry_run || { 49018c4a8e55Smrg eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' 49028c4a8e55Smrg eval '$MV "$nlist"T "$nlist"' 49038c4a8e55Smrg } 49048c4a8e55Smrg fi 49058c4a8e55Smrg 49068c4a8e55Smrg # Prepare the list of exported symbols 49078c4a8e55Smrg if test -z "$export_symbols"; then 49083169be4bSmrg export_symbols=$output_objdir/$outputname.exp 49098c4a8e55Smrg $opt_dry_run || { 49108c4a8e55Smrg $RM $export_symbols 49113169be4bSmrg eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' 49128c4a8e55Smrg case $host in 49138c4a8e55Smrg *cygwin* | *mingw* | *cegcc* ) 49148c4a8e55Smrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 49158c4a8e55Smrg eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' 49168c4a8e55Smrg ;; 49178c4a8e55Smrg esac 49188c4a8e55Smrg } 4919b042e37fSmrg else 49208c4a8e55Smrg $opt_dry_run || { 49213169be4bSmrg eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' 49228c4a8e55Smrg eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' 49238c4a8e55Smrg eval '$MV "$nlist"T "$nlist"' 49248c4a8e55Smrg case $host in 4925706b6b52Smrg *cygwin* | *mingw* | *cegcc* ) 49268c4a8e55Smrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 49278c4a8e55Smrg eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' 49288c4a8e55Smrg ;; 49298c4a8e55Smrg esac 49308c4a8e55Smrg } 4931b042e37fSmrg fi 49328c4a8e55Smrg fi 4933b042e37fSmrg 49348c4a8e55Smrg for dlprefile in $dlprefiles; do 49353169be4bSmrg func_verbose "extracting global C symbols from '$dlprefile'" 49368c4a8e55Smrg func_basename "$dlprefile" 49373169be4bSmrg name=$func_basename_result 4938bd23fbfaSmrg case $host in 4939bd23fbfaSmrg *cygwin* | *mingw* | *cegcc* ) 4940bd23fbfaSmrg # if an import library, we need to obtain dlname 4941bd23fbfaSmrg if func_win32_import_lib_p "$dlprefile"; then 4942bd23fbfaSmrg func_tr_sh "$dlprefile" 4943bd23fbfaSmrg eval "curr_lafile=\$libfile_$func_tr_sh_result" 49443169be4bSmrg dlprefile_dlbasename= 4945bd23fbfaSmrg if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then 4946bd23fbfaSmrg # Use subshell, to avoid clobbering current variable values 4947bd23fbfaSmrg dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` 49483169be4bSmrg if test -n "$dlprefile_dlname"; then 4949bd23fbfaSmrg func_basename "$dlprefile_dlname" 49503169be4bSmrg dlprefile_dlbasename=$func_basename_result 4951bd23fbfaSmrg else 4952bd23fbfaSmrg # no lafile. user explicitly requested -dlpreopen <import library>. 4953bd23fbfaSmrg $sharedlib_from_linklib_cmd "$dlprefile" 4954bd23fbfaSmrg dlprefile_dlbasename=$sharedlib_from_linklib_result 4955bd23fbfaSmrg fi 4956bd23fbfaSmrg fi 4957bd23fbfaSmrg $opt_dry_run || { 49583169be4bSmrg if test -n "$dlprefile_dlbasename"; then 4959bd23fbfaSmrg eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' 4960bd23fbfaSmrg else 4961bd23fbfaSmrg func_warning "Could not compute DLL name from $name" 4962bd23fbfaSmrg eval '$ECHO ": $name " >> "$nlist"' 4963bd23fbfaSmrg fi 4964bd23fbfaSmrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 4965bd23fbfaSmrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | 4966bd23fbfaSmrg $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" 4967bd23fbfaSmrg } 4968bd23fbfaSmrg else # not an import lib 4969bd23fbfaSmrg $opt_dry_run || { 4970bd23fbfaSmrg eval '$ECHO ": $name " >> "$nlist"' 4971bd23fbfaSmrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 4972bd23fbfaSmrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 4973bd23fbfaSmrg } 4974bd23fbfaSmrg fi 4975bd23fbfaSmrg ;; 4976bd23fbfaSmrg *) 4977bd23fbfaSmrg $opt_dry_run || { 4978bd23fbfaSmrg eval '$ECHO ": $name " >> "$nlist"' 4979bd23fbfaSmrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 4980bd23fbfaSmrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 4981bd23fbfaSmrg } 4982bd23fbfaSmrg ;; 4983bd23fbfaSmrg esac 49848c4a8e55Smrg done 49858c4a8e55Smrg 49868c4a8e55Smrg $opt_dry_run || { 49878c4a8e55Smrg # Make sure we have at least an empty file. 49888c4a8e55Smrg test -f "$nlist" || : > "$nlist" 49898c4a8e55Smrg 49908c4a8e55Smrg if test -n "$exclude_expsyms"; then 49918c4a8e55Smrg $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T 49928c4a8e55Smrg $MV "$nlist"T "$nlist" 4993b042e37fSmrg fi 49948c4a8e55Smrg 49958c4a8e55Smrg # Try sorting and uniquifying the output. 49968c4a8e55Smrg if $GREP -v "^: " < "$nlist" | 49978c4a8e55Smrg if sort -k 3 </dev/null >/dev/null 2>&1; then 49988c4a8e55Smrg sort -k 3 49998c4a8e55Smrg else 50008c4a8e55Smrg sort +2 50018c4a8e55Smrg fi | 50028c4a8e55Smrg uniq > "$nlist"S; then 50038c4a8e55Smrg : 5004b042e37fSmrg else 50058c4a8e55Smrg $GREP -v "^: " < "$nlist" > "$nlist"S 5006b042e37fSmrg fi 5007b042e37fSmrg 50088c4a8e55Smrg if test -f "$nlist"S; then 50098c4a8e55Smrg eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' 5010b042e37fSmrg else 5011706b6b52Smrg echo '/* NONE */' >> "$output_objdir/$my_dlsyms" 5012b042e37fSmrg fi 5013b042e37fSmrg 50143169be4bSmrg func_show_eval '$RM "${nlist}I"' 50153169be4bSmrg if test -n "$global_symbol_to_import"; then 50163169be4bSmrg eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I' 50173169be4bSmrg fi 50183169be4bSmrg 5019706b6b52Smrg echo >> "$output_objdir/$my_dlsyms" "\ 5020b042e37fSmrg 50218c4a8e55Smrg/* The mapping between symbol names and symbols. */ 50228c4a8e55Smrgtypedef struct { 50238c4a8e55Smrg const char *name; 50248c4a8e55Smrg void *address; 50258c4a8e55Smrg} lt_dlsymlist; 5026bd23fbfaSmrgextern LT_DLSYM_CONST lt_dlsymlist 50273169be4bSmrglt_${my_prefix}_LTX_preloaded_symbols[];\ 50283169be4bSmrg" 50293169be4bSmrg 50303169be4bSmrg if test -s "$nlist"I; then 50313169be4bSmrg echo >> "$output_objdir/$my_dlsyms" "\ 50323169be4bSmrgstatic void lt_syminit(void) 50333169be4bSmrg{ 50343169be4bSmrg LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols; 50353169be4bSmrg for (; symbol->name; ++symbol) 50363169be4bSmrg {" 50373169be4bSmrg $SED 's/.*/ if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms" 50383169be4bSmrg echo >> "$output_objdir/$my_dlsyms" "\ 50393169be4bSmrg } 50403169be4bSmrg}" 50413169be4bSmrg fi 50423169be4bSmrg echo >> "$output_objdir/$my_dlsyms" "\ 5043bd23fbfaSmrgLT_DLSYM_CONST lt_dlsymlist 50448c4a8e55Smrglt_${my_prefix}_LTX_preloaded_symbols[] = 50453169be4bSmrg{ {\"$my_originator\", (void *) 0}," 50463169be4bSmrg 50473169be4bSmrg if test -s "$nlist"I; then 50483169be4bSmrg echo >> "$output_objdir/$my_dlsyms" "\ 50493169be4bSmrg {\"@INIT@\", (void *) <_syminit}," 50503169be4bSmrg fi 5051b042e37fSmrg 50528c4a8e55Smrg case $need_lib_prefix in 50538c4a8e55Smrg no) 50548c4a8e55Smrg eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" 50558c4a8e55Smrg ;; 50568c4a8e55Smrg *) 50578c4a8e55Smrg eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" 50588c4a8e55Smrg ;; 50598c4a8e55Smrg esac 5060706b6b52Smrg echo >> "$output_objdir/$my_dlsyms" "\ 50618c4a8e55Smrg {0, (void *) 0} 50628c4a8e55Smrg}; 5063b042e37fSmrg 50648c4a8e55Smrg/* This works around a problem in FreeBSD linker */ 50658c4a8e55Smrg#ifdef FREEBSD_WORKAROUND 50668c4a8e55Smrgstatic const void *lt_preloaded_setup() { 50678c4a8e55Smrg return lt_${my_prefix}_LTX_preloaded_symbols; 50688c4a8e55Smrg} 50698c4a8e55Smrg#endif 5070b042e37fSmrg 50718c4a8e55Smrg#ifdef __cplusplus 50728c4a8e55Smrg} 50738c4a8e55Smrg#endif\ 50748c4a8e55Smrg" 50758c4a8e55Smrg } # !$opt_dry_run 5076b042e37fSmrg 50778c4a8e55Smrg pic_flag_for_symtable= 50788c4a8e55Smrg case "$compile_command " in 50798c4a8e55Smrg *" -static "*) ;; 50808c4a8e55Smrg *) 50818c4a8e55Smrg case $host in 50828c4a8e55Smrg # compiling the symbol table file with pic_flag works around 50838c4a8e55Smrg # a FreeBSD bug that causes programs to crash when -lm is 50848c4a8e55Smrg # linked before any other PIC object. But we must not use 50858c4a8e55Smrg # pic_flag when linking with -static. The problem exists in 50868c4a8e55Smrg # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. 50870597fb56Smrg *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) 50888c4a8e55Smrg pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; 50898c4a8e55Smrg *-*-hpux*) 50908c4a8e55Smrg pic_flag_for_symtable=" $pic_flag" ;; 50918c4a8e55Smrg *) 50923169be4bSmrg $my_pic_p && pic_flag_for_symtable=" $pic_flag" 50938c4a8e55Smrg ;; 50948c4a8e55Smrg esac 50958c4a8e55Smrg ;; 50968c4a8e55Smrg esac 50978c4a8e55Smrg symtab_cflags= 50988c4a8e55Smrg for arg in $LTCFLAGS; do 50998c4a8e55Smrg case $arg in 51008c4a8e55Smrg -pie | -fpie | -fPIE) ;; 5101bd23fbfaSmrg *) func_append symtab_cflags " $arg" ;; 51028c4a8e55Smrg esac 51038c4a8e55Smrg done 5104b042e37fSmrg 51058c4a8e55Smrg # Now compile the dynamic symbol file. 51068c4a8e55Smrg func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' 5107b042e37fSmrg 51088c4a8e55Smrg # Clean up the generated files. 51093169be4bSmrg func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"' 51108c4a8e55Smrg 51118c4a8e55Smrg # Transform the symbol file into the correct name. 51123169be4bSmrg symfileobj=$output_objdir/${my_outputname}S.$objext 51138c4a8e55Smrg case $host in 51148c4a8e55Smrg *cygwin* | *mingw* | *cegcc* ) 51158c4a8e55Smrg if test -f "$output_objdir/$my_outputname.def"; then 5116706b6b52Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 5117706b6b52Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 51188c4a8e55Smrg else 5119706b6b52Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 5120706b6b52Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 5121b042e37fSmrg fi 51228c4a8e55Smrg ;; 51238c4a8e55Smrg *) 5124706b6b52Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 5125706b6b52Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 51268c4a8e55Smrg ;; 51278c4a8e55Smrg esac 51288c4a8e55Smrg ;; 51298c4a8e55Smrg *) 51303169be4bSmrg func_fatal_error "unknown suffix for '$my_dlsyms'" 51318c4a8e55Smrg ;; 51328c4a8e55Smrg esac 51338c4a8e55Smrg else 51348c4a8e55Smrg # We keep going just in case the user didn't refer to 51358c4a8e55Smrg # lt_preloaded_symbols. The linker will fail if global_symbol_pipe 51368c4a8e55Smrg # really was required. 5137b042e37fSmrg 51388c4a8e55Smrg # Nullify the symbol file. 5139706b6b52Smrg compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` 5140706b6b52Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` 51418c4a8e55Smrg fi 51428c4a8e55Smrg} 5143b042e37fSmrg 51443169be4bSmrg# func_cygming_gnu_implib_p ARG 51453169be4bSmrg# This predicate returns with zero status (TRUE) if 51463169be4bSmrg# ARG is a GNU/binutils-style import library. Returns 51473169be4bSmrg# with nonzero status (FALSE) otherwise. 51483169be4bSmrgfunc_cygming_gnu_implib_p () 51493169be4bSmrg{ 51503169be4bSmrg $debug_cmd 51513169be4bSmrg 51523169be4bSmrg func_to_tool_file "$1" func_convert_file_msys_to_w32 51533169be4bSmrg 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)$'` 51543169be4bSmrg test -n "$func_cygming_gnu_implib_tmp" 51553169be4bSmrg} 51563169be4bSmrg 51573169be4bSmrg# func_cygming_ms_implib_p ARG 51583169be4bSmrg# This predicate returns with zero status (TRUE) if 51593169be4bSmrg# ARG is an MS-style import library. Returns 51603169be4bSmrg# with nonzero status (FALSE) otherwise. 51613169be4bSmrgfunc_cygming_ms_implib_p () 51623169be4bSmrg{ 51633169be4bSmrg $debug_cmd 51643169be4bSmrg 51653169be4bSmrg func_to_tool_file "$1" func_convert_file_msys_to_w32 51663169be4bSmrg func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` 51673169be4bSmrg test -n "$func_cygming_ms_implib_tmp" 51683169be4bSmrg} 51693169be4bSmrg 51708c4a8e55Smrg# func_win32_libid arg 51718c4a8e55Smrg# return the library type of file 'arg' 51728c4a8e55Smrg# 51738c4a8e55Smrg# Need a lot of goo to handle *both* DLLs and import libs 51748c4a8e55Smrg# Has to be a shell function in order to 'eat' the argument 51758c4a8e55Smrg# that is supplied when $file_magic_command is called. 5176706b6b52Smrg# Despite the name, also deal with 64 bit binaries. 51778c4a8e55Smrgfunc_win32_libid () 51788c4a8e55Smrg{ 51793169be4bSmrg $debug_cmd 51803169be4bSmrg 51813169be4bSmrg win32_libid_type=unknown 51828c4a8e55Smrg win32_fileres=`file -L $1 2>/dev/null` 51838c4a8e55Smrg case $win32_fileres in 51848c4a8e55Smrg *ar\ archive\ import\ library*) # definitely import 51858c4a8e55Smrg win32_libid_type="x86 archive import" 51868c4a8e55Smrg ;; 51878c4a8e55Smrg *ar\ archive*) # could be an import, or static 5188706b6b52Smrg # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. 51898c4a8e55Smrg if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | 5190706b6b52Smrg $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then 51913169be4bSmrg case $nm_interface in 51923169be4bSmrg "MS dumpbin") 51933169be4bSmrg if func_cygming_ms_implib_p "$1" || 51943169be4bSmrg func_cygming_gnu_implib_p "$1" 51953169be4bSmrg then 51963169be4bSmrg win32_nmres=import 51973169be4bSmrg else 51983169be4bSmrg win32_nmres= 51993169be4bSmrg fi 52003169be4bSmrg ;; 52013169be4bSmrg *) 52023169be4bSmrg func_to_tool_file "$1" func_convert_file_msys_to_w32 52033169be4bSmrg win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | 52043169be4bSmrg $SED -n -e ' 52058c4a8e55Smrg 1,100{ 52068c4a8e55Smrg / I /{ 52073169be4bSmrg s|.*|import| 52088c4a8e55Smrg p 52098c4a8e55Smrg q 52108c4a8e55Smrg } 52118c4a8e55Smrg }'` 52123169be4bSmrg ;; 52133169be4bSmrg esac 52148c4a8e55Smrg case $win32_nmres in 52158c4a8e55Smrg import*) win32_libid_type="x86 archive import";; 52168c4a8e55Smrg *) win32_libid_type="x86 archive static";; 52178c4a8e55Smrg esac 52188c4a8e55Smrg fi 52198c4a8e55Smrg ;; 52208c4a8e55Smrg *DLL*) 52218c4a8e55Smrg win32_libid_type="x86 DLL" 52228c4a8e55Smrg ;; 52238c4a8e55Smrg *executable*) # but shell scripts are "executable" too... 52248c4a8e55Smrg case $win32_fileres in 52258c4a8e55Smrg *MS\ Windows\ PE\ Intel*) 52268c4a8e55Smrg win32_libid_type="x86 DLL" 52278c4a8e55Smrg ;; 52288c4a8e55Smrg esac 52298c4a8e55Smrg ;; 52308c4a8e55Smrg esac 52318c4a8e55Smrg $ECHO "$win32_libid_type" 52328c4a8e55Smrg} 5233b042e37fSmrg 5234bd23fbfaSmrg# func_cygming_dll_for_implib ARG 5235bd23fbfaSmrg# 5236bd23fbfaSmrg# Platform-specific function to extract the 5237bd23fbfaSmrg# name of the DLL associated with the specified 5238bd23fbfaSmrg# import library ARG. 5239bd23fbfaSmrg# Invoked by eval'ing the libtool variable 5240bd23fbfaSmrg# $sharedlib_from_linklib_cmd 5241bd23fbfaSmrg# Result is available in the variable 5242bd23fbfaSmrg# $sharedlib_from_linklib_result 5243bd23fbfaSmrgfunc_cygming_dll_for_implib () 5244bd23fbfaSmrg{ 52453169be4bSmrg $debug_cmd 52463169be4bSmrg 5247bd23fbfaSmrg sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` 5248bd23fbfaSmrg} 5249bd23fbfaSmrg 5250bd23fbfaSmrg# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs 5251bd23fbfaSmrg# 5252bd23fbfaSmrg# The is the core of a fallback implementation of a 5253bd23fbfaSmrg# platform-specific function to extract the name of the 5254bd23fbfaSmrg# DLL associated with the specified import library LIBNAME. 5255bd23fbfaSmrg# 5256bd23fbfaSmrg# SECTION_NAME is either .idata$6 or .idata$7, depending 5257bd23fbfaSmrg# on the platform and compiler that created the implib. 5258bd23fbfaSmrg# 5259bd23fbfaSmrg# Echos the name of the DLL associated with the 5260bd23fbfaSmrg# specified import library. 5261bd23fbfaSmrgfunc_cygming_dll_for_implib_fallback_core () 5262bd23fbfaSmrg{ 52633169be4bSmrg $debug_cmd 52643169be4bSmrg 5265bd23fbfaSmrg match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` 5266bd23fbfaSmrg $OBJDUMP -s --section "$1" "$2" 2>/dev/null | 5267bd23fbfaSmrg $SED '/^Contents of section '"$match_literal"':/{ 5268bd23fbfaSmrg # Place marker at beginning of archive member dllname section 5269bd23fbfaSmrg s/.*/====MARK====/ 5270bd23fbfaSmrg p 5271bd23fbfaSmrg d 5272bd23fbfaSmrg } 5273bd23fbfaSmrg # These lines can sometimes be longer than 43 characters, but 5274bd23fbfaSmrg # are always uninteresting 5275bd23fbfaSmrg /:[ ]*file format pe[i]\{,1\}-/d 5276bd23fbfaSmrg /^In archive [^:]*:/d 5277bd23fbfaSmrg # Ensure marker is printed 5278bd23fbfaSmrg /^====MARK====/p 5279bd23fbfaSmrg # Remove all lines with less than 43 characters 5280bd23fbfaSmrg /^.\{43\}/!d 5281bd23fbfaSmrg # From remaining lines, remove first 43 characters 5282bd23fbfaSmrg s/^.\{43\}//' | 5283bd23fbfaSmrg $SED -n ' 5284bd23fbfaSmrg # Join marker and all lines until next marker into a single line 5285bd23fbfaSmrg /^====MARK====/ b para 5286bd23fbfaSmrg H 5287bd23fbfaSmrg $ b para 5288bd23fbfaSmrg b 5289bd23fbfaSmrg :para 5290bd23fbfaSmrg x 5291bd23fbfaSmrg s/\n//g 5292bd23fbfaSmrg # Remove the marker 5293bd23fbfaSmrg s/^====MARK====// 5294bd23fbfaSmrg # Remove trailing dots and whitespace 5295bd23fbfaSmrg s/[\. \t]*$// 5296bd23fbfaSmrg # Print 5297bd23fbfaSmrg /./p' | 5298bd23fbfaSmrg # we now have a list, one entry per line, of the stringified 5299bd23fbfaSmrg # contents of the appropriate section of all members of the 53003169be4bSmrg # archive that possess that section. Heuristic: eliminate 53013169be4bSmrg # all those that have a first or second character that is 5302bd23fbfaSmrg # a '.' (that is, objdump's representation of an unprintable 5303bd23fbfaSmrg # character.) This should work for all archives with less than 5304bd23fbfaSmrg # 0x302f exports -- but will fail for DLLs whose name actually 5305bd23fbfaSmrg # begins with a literal '.' or a single character followed by 5306bd23fbfaSmrg # a '.'. 5307bd23fbfaSmrg # 5308bd23fbfaSmrg # Of those that remain, print the first one. 5309bd23fbfaSmrg $SED -e '/^\./d;/^.\./d;q' 5310bd23fbfaSmrg} 5311bd23fbfaSmrg 5312bd23fbfaSmrg# func_cygming_dll_for_implib_fallback ARG 5313bd23fbfaSmrg# Platform-specific function to extract the 5314bd23fbfaSmrg# name of the DLL associated with the specified 5315bd23fbfaSmrg# import library ARG. 5316bd23fbfaSmrg# 5317bd23fbfaSmrg# This fallback implementation is for use when $DLLTOOL 5318bd23fbfaSmrg# does not support the --identify-strict option. 5319bd23fbfaSmrg# Invoked by eval'ing the libtool variable 5320bd23fbfaSmrg# $sharedlib_from_linklib_cmd 5321bd23fbfaSmrg# Result is available in the variable 5322bd23fbfaSmrg# $sharedlib_from_linklib_result 5323bd23fbfaSmrgfunc_cygming_dll_for_implib_fallback () 5324bd23fbfaSmrg{ 53253169be4bSmrg $debug_cmd 53263169be4bSmrg 53273169be4bSmrg if func_cygming_gnu_implib_p "$1"; then 5328bd23fbfaSmrg # binutils import library 5329bd23fbfaSmrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` 53303169be4bSmrg elif func_cygming_ms_implib_p "$1"; then 5331bd23fbfaSmrg # ms-generated import library 5332bd23fbfaSmrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` 5333bd23fbfaSmrg else 5334bd23fbfaSmrg # unknown 53353169be4bSmrg sharedlib_from_linklib_result= 5336bd23fbfaSmrg fi 5337bd23fbfaSmrg} 5338b042e37fSmrg 5339b042e37fSmrg 53408c4a8e55Smrg# func_extract_an_archive dir oldlib 53418c4a8e55Smrgfunc_extract_an_archive () 53428c4a8e55Smrg{ 53433169be4bSmrg $debug_cmd 53443169be4bSmrg 53453169be4bSmrg f_ex_an_ar_dir=$1; shift 53463169be4bSmrg f_ex_an_ar_oldlib=$1 53473169be4bSmrg if test yes = "$lock_old_archive_extraction"; then 5348706b6b52Smrg lockfile=$f_ex_an_ar_oldlib.lock 5349706b6b52Smrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 5350706b6b52Smrg func_echo "Waiting for $lockfile to be removed" 5351706b6b52Smrg sleep 2 5352706b6b52Smrg done 5353706b6b52Smrg fi 5354706b6b52Smrg func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ 5355706b6b52Smrg 'stat=$?; rm -f "$lockfile"; exit $stat' 53563169be4bSmrg if test yes = "$lock_old_archive_extraction"; then 5357706b6b52Smrg $opt_dry_run || rm -f "$lockfile" 5358706b6b52Smrg fi 53598c4a8e55Smrg if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then 53608c4a8e55Smrg : 53618c4a8e55Smrg else 53628c4a8e55Smrg func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 53638c4a8e55Smrg fi 53648c4a8e55Smrg} 5365b042e37fSmrg 5366b042e37fSmrg 53678c4a8e55Smrg# func_extract_archives gentop oldlib ... 53688c4a8e55Smrgfunc_extract_archives () 53698c4a8e55Smrg{ 53703169be4bSmrg $debug_cmd 53713169be4bSmrg 53723169be4bSmrg my_gentop=$1; shift 53738c4a8e55Smrg my_oldlibs=${1+"$@"} 53743169be4bSmrg my_oldobjs= 53753169be4bSmrg my_xlib= 53763169be4bSmrg my_xabs= 53773169be4bSmrg my_xdir= 5378b042e37fSmrg 53798c4a8e55Smrg for my_xlib in $my_oldlibs; do 53808c4a8e55Smrg # Extract the objects. 53818c4a8e55Smrg case $my_xlib in 53823169be4bSmrg [\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;; 53838c4a8e55Smrg *) my_xabs=`pwd`"/$my_xlib" ;; 53848c4a8e55Smrg esac 53858c4a8e55Smrg func_basename "$my_xlib" 53863169be4bSmrg my_xlib=$func_basename_result 53878c4a8e55Smrg my_xlib_u=$my_xlib 53888c4a8e55Smrg while :; do 53898c4a8e55Smrg case " $extracted_archives " in 53908c4a8e55Smrg *" $my_xlib_u "*) 53918c4a8e55Smrg func_arith $extracted_serial + 1 53928c4a8e55Smrg extracted_serial=$func_arith_result 53938c4a8e55Smrg my_xlib_u=lt$extracted_serial-$my_xlib ;; 53948c4a8e55Smrg *) break ;; 53958c4a8e55Smrg esac 53968c4a8e55Smrg done 53978c4a8e55Smrg extracted_archives="$extracted_archives $my_xlib_u" 53983169be4bSmrg my_xdir=$my_gentop/$my_xlib_u 5399b042e37fSmrg 54008c4a8e55Smrg func_mkdir_p "$my_xdir" 5401b042e37fSmrg 54028c4a8e55Smrg case $host in 54038c4a8e55Smrg *-darwin*) 54048c4a8e55Smrg func_verbose "Extracting $my_xabs" 54058c4a8e55Smrg # Do not bother doing anything if just a dry run 54068c4a8e55Smrg $opt_dry_run || { 54078c4a8e55Smrg darwin_orig_dir=`pwd` 54088c4a8e55Smrg cd $my_xdir || exit $? 54098c4a8e55Smrg darwin_archive=$my_xabs 54108c4a8e55Smrg darwin_curdir=`pwd` 54113169be4bSmrg func_basename "$darwin_archive" 54123169be4bSmrg darwin_base_archive=$func_basename_result 54138c4a8e55Smrg darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` 54148c4a8e55Smrg if test -n "$darwin_arches"; then 54158c4a8e55Smrg darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` 54168c4a8e55Smrg darwin_arch= 54178c4a8e55Smrg func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" 54183169be4bSmrg for darwin_arch in $darwin_arches; do 54193169be4bSmrg func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch" 54203169be4bSmrg $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive" 54213169be4bSmrg cd "unfat-$$/$darwin_base_archive-$darwin_arch" 54223169be4bSmrg func_extract_an_archive "`pwd`" "$darwin_base_archive" 54238c4a8e55Smrg cd "$darwin_curdir" 54243169be4bSmrg $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" 54258c4a8e55Smrg done # $darwin_arches 54268c4a8e55Smrg ## Okay now we've a bunch of thin objects, gotta fatten them up :) 54273169be4bSmrg darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$sed_basename" | sort -u` 54288c4a8e55Smrg darwin_file= 54298c4a8e55Smrg darwin_files= 54308c4a8e55Smrg for darwin_file in $darwin_filelist; do 5431706b6b52Smrg darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` 54328c4a8e55Smrg $LIPO -create -output "$darwin_file" $darwin_files 54338c4a8e55Smrg done # $darwin_filelist 54348c4a8e55Smrg $RM -rf unfat-$$ 54358c4a8e55Smrg cd "$darwin_orig_dir" 5436b042e37fSmrg else 54378c4a8e55Smrg cd $darwin_orig_dir 54388c4a8e55Smrg func_extract_an_archive "$my_xdir" "$my_xabs" 54398c4a8e55Smrg fi # $darwin_arches 54408c4a8e55Smrg } # !$opt_dry_run 54418c4a8e55Smrg ;; 54428c4a8e55Smrg *) 54438c4a8e55Smrg func_extract_an_archive "$my_xdir" "$my_xabs" 54448c4a8e55Smrg ;; 54458c4a8e55Smrg esac 5446706b6b52Smrg my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` 54478c4a8e55Smrg done 5448b042e37fSmrg 54493169be4bSmrg func_extract_archives_result=$my_oldobjs 54508c4a8e55Smrg} 5451b042e37fSmrg 5452b042e37fSmrg 5453706b6b52Smrg# func_emit_wrapper [arg=no] 5454706b6b52Smrg# 5455706b6b52Smrg# Emit a libtool wrapper script on stdout. 5456706b6b52Smrg# Don't directly open a file because we may want to 5457706b6b52Smrg# incorporate the script contents within a cygwin/mingw 5458706b6b52Smrg# wrapper executable. Must ONLY be called from within 5459706b6b52Smrg# func_mode_link because it depends on a number of variables 5460706b6b52Smrg# set therein. 54618c4a8e55Smrg# 5462706b6b52Smrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR 5463706b6b52Smrg# variable will take. If 'yes', then the emitted script 54643169be4bSmrg# will assume that the directory where it is stored is 5465706b6b52Smrg# the $objdir directory. This is a cygwin/mingw-specific 5466706b6b52Smrg# behavior. 5467706b6b52Smrgfunc_emit_wrapper () 54688c4a8e55Smrg{ 5469706b6b52Smrg func_emit_wrapper_arg1=${1-no} 5470b042e37fSmrg 54718c4a8e55Smrg $ECHO "\ 54728c4a8e55Smrg#! $SHELL 5473b042e37fSmrg 54748c4a8e55Smrg# $output - temporary wrapper script for $objdir/$outputname 54753169be4bSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 54768c4a8e55Smrg# 54778c4a8e55Smrg# The $output program cannot be directly executed until all the libtool 54788c4a8e55Smrg# libraries that it depends on are installed. 54798c4a8e55Smrg# 54808c4a8e55Smrg# This wrapper script should never be moved out of the build directory. 54818c4a8e55Smrg# If it is, it will not operate correctly. 5482b042e37fSmrg 54838c4a8e55Smrg# Sed substitution that helps us do robust quoting. It backslashifies 54848c4a8e55Smrg# metacharacters that are still active within double-quoted strings. 54858c4a8e55Smrgsed_quote_subst='$sed_quote_subst' 5486b042e37fSmrg 54878c4a8e55Smrg# Be Bourne compatible 54888c4a8e55Smrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then 54898c4a8e55Smrg emulate sh 54908c4a8e55Smrg NULLCMD=: 54918c4a8e55Smrg # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which 54928c4a8e55Smrg # is contrary to our usage. Disable this feature. 54938c4a8e55Smrg alias -g '\${1+\"\$@\"}'='\"\$@\"' 54948c4a8e55Smrg setopt NO_GLOB_SUBST 54958c4a8e55Smrgelse 54968c4a8e55Smrg case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac 54978c4a8e55Smrgfi 54988c4a8e55SmrgBIN_SH=xpg4; export BIN_SH # for Tru64 54998c4a8e55SmrgDUALCASE=1; export DUALCASE # for MKS sh 5500b042e37fSmrg 55018c4a8e55Smrg# The HP-UX ksh and POSIX shell print the target directory to stdout 55028c4a8e55Smrg# if CDPATH is set. 55038c4a8e55Smrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 5504b042e37fSmrg 55058c4a8e55Smrgrelink_command=\"$relink_command\" 5506b042e37fSmrg 55078c4a8e55Smrg# This environment variable determines our operation mode. 55088c4a8e55Smrgif test \"\$libtool_install_magic\" = \"$magic\"; then 55098c4a8e55Smrg # install mode needs the following variables: 55108c4a8e55Smrg generated_by_libtool_version='$macro_version' 55118c4a8e55Smrg notinst_deplibs='$notinst_deplibs' 55128c4a8e55Smrgelse 55138c4a8e55Smrg # When we are sourced in execute mode, \$file and \$ECHO are already set. 55148c4a8e55Smrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 5515706b6b52Smrg file=\"\$0\"" 5516706b6b52Smrg 55178d0bc965Smrg func_quote_arg pretty "$ECHO" 55188d0bc965Smrg qECHO=$func_quote_arg_result 5519706b6b52Smrg $ECHO "\ 5520706b6b52Smrg 5521706b6b52Smrg# A function that is used when there is no print builtin or printf. 5522706b6b52Smrgfunc_fallback_echo () 5523706b6b52Smrg{ 5524706b6b52Smrg eval 'cat <<_LTECHO_EOF 5525706b6b52Smrg\$1 5526706b6b52Smrg_LTECHO_EOF' 5527706b6b52Smrg} 55288d0bc965Smrg ECHO=$qECHO 5529706b6b52Smrg fi 5530706b6b52Smrg 5531706b6b52Smrg# Very basic option parsing. These options are (a) specific to 5532706b6b52Smrg# the libtool wrapper, (b) are identical between the wrapper 55333169be4bSmrg# /script/ and the wrapper /executable/ that is used only on 5534706b6b52Smrg# windows platforms, and (c) all begin with the string "--lt-" 55353169be4bSmrg# (application programs are unlikely to have options that match 5536706b6b52Smrg# this pattern). 5537706b6b52Smrg# 5538706b6b52Smrg# There are only two supported options: --lt-debug and 5539706b6b52Smrg# --lt-dump-script. There is, deliberately, no --lt-help. 5540706b6b52Smrg# 5541706b6b52Smrg# The first argument to this parsing function should be the 5542706b6b52Smrg# script's $0 value, followed by "$@". 5543706b6b52Smrglt_option_debug= 5544706b6b52Smrgfunc_parse_lt_options () 5545706b6b52Smrg{ 5546706b6b52Smrg lt_script_arg0=\$0 5547706b6b52Smrg shift 5548706b6b52Smrg for lt_opt 5549706b6b52Smrg do 5550706b6b52Smrg case \"\$lt_opt\" in 5551706b6b52Smrg --lt-debug) lt_option_debug=1 ;; 5552706b6b52Smrg --lt-dump-script) 5553706b6b52Smrg lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` 5554706b6b52Smrg test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. 5555706b6b52Smrg lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` 5556706b6b52Smrg cat \"\$lt_dump_D/\$lt_dump_F\" 5557706b6b52Smrg exit 0 5558706b6b52Smrg ;; 5559706b6b52Smrg --lt-*) 5560706b6b52Smrg \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 5561706b6b52Smrg exit 1 5562706b6b52Smrg ;; 5563706b6b52Smrg esac 5564706b6b52Smrg done 5565706b6b52Smrg 5566706b6b52Smrg # Print the debug banner immediately: 5567706b6b52Smrg if test -n \"\$lt_option_debug\"; then 55683169be4bSmrg echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2 5569706b6b52Smrg fi 5570706b6b52Smrg} 5571706b6b52Smrg 5572706b6b52Smrg# Used when --lt-debug. Prints its arguments to stdout 5573706b6b52Smrg# (redirection is the responsibility of the caller) 5574706b6b52Smrgfunc_lt_dump_args () 5575706b6b52Smrg{ 5576706b6b52Smrg lt_dump_args_N=1; 5577706b6b52Smrg for lt_arg 5578706b6b52Smrg do 55793169be4bSmrg \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\" 5580706b6b52Smrg lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` 5581706b6b52Smrg done 5582706b6b52Smrg} 5583706b6b52Smrg 5584706b6b52Smrg# Core function for launching the target application 5585706b6b52Smrgfunc_exec_program_core () 5586706b6b52Smrg{ 55878c4a8e55Smrg" 5588706b6b52Smrg case $host in 5589706b6b52Smrg # Backslashes separate directories on plain windows 5590706b6b52Smrg *-*-mingw | *-*-os2* | *-cegcc*) 5591706b6b52Smrg $ECHO "\ 5592706b6b52Smrg if test -n \"\$lt_option_debug\"; then 55933169be4bSmrg \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2 5594706b6b52Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 5595706b6b52Smrg fi 5596706b6b52Smrg exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} 5597706b6b52Smrg" 5598706b6b52Smrg ;; 5599706b6b52Smrg 5600706b6b52Smrg *) 5601706b6b52Smrg $ECHO "\ 5602706b6b52Smrg if test -n \"\$lt_option_debug\"; then 56033169be4bSmrg \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2 5604706b6b52Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 5605706b6b52Smrg fi 5606706b6b52Smrg exec \"\$progdir/\$program\" \${1+\"\$@\"} 5607706b6b52Smrg" 5608706b6b52Smrg ;; 5609706b6b52Smrg esac 5610706b6b52Smrg $ECHO "\ 5611706b6b52Smrg \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 5612706b6b52Smrg exit 1 5613706b6b52Smrg} 5614706b6b52Smrg 5615706b6b52Smrg# A function to encapsulate launching the target application 5616706b6b52Smrg# Strips options in the --lt-* namespace from \$@ and 5617706b6b52Smrg# launches target application with the remaining arguments. 5618706b6b52Smrgfunc_exec_program () 5619706b6b52Smrg{ 56200597fb56Smrg case \" \$* \" in 56210597fb56Smrg *\\ --lt-*) 56220597fb56Smrg for lt_wr_arg 56230597fb56Smrg do 56240597fb56Smrg case \$lt_wr_arg in 56250597fb56Smrg --lt-*) ;; 56260597fb56Smrg *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; 56270597fb56Smrg esac 56280597fb56Smrg shift 56290597fb56Smrg done ;; 56300597fb56Smrg esac 5631706b6b52Smrg func_exec_program_core \${1+\"\$@\"} 5632706b6b52Smrg} 5633706b6b52Smrg 5634706b6b52Smrg # Parse options 5635706b6b52Smrg func_parse_lt_options \"\$0\" \${1+\"\$@\"} 5636b042e37fSmrg 56378c4a8e55Smrg # Find the directory that this script lives in. 5638706b6b52Smrg thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` 56398c4a8e55Smrg test \"x\$thisdir\" = \"x\$file\" && thisdir=. 5640b042e37fSmrg 56418c4a8e55Smrg # Follow symbolic links until we get to the real thisdir. 5642706b6b52Smrg file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` 56438c4a8e55Smrg while test -n \"\$file\"; do 5644706b6b52Smrg destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` 56458c4a8e55Smrg 56468c4a8e55Smrg # If there was a directory component, then change thisdir. 56478c4a8e55Smrg if test \"x\$destdir\" != \"x\$file\"; then 56488c4a8e55Smrg case \"\$destdir\" in 56498c4a8e55Smrg [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; 56508c4a8e55Smrg *) thisdir=\"\$thisdir/\$destdir\" ;; 5651b042e37fSmrg esac 56528c4a8e55Smrg fi 5653b042e37fSmrg 5654706b6b52Smrg file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` 5655706b6b52Smrg file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` 56568c4a8e55Smrg done 5657b042e37fSmrg 56588c4a8e55Smrg # Usually 'no', except on cygwin/mingw when embedded into 56598c4a8e55Smrg # the cwrapper. 5660706b6b52Smrg WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 56618c4a8e55Smrg if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then 56628c4a8e55Smrg # special case for '.' 56638c4a8e55Smrg if test \"\$thisdir\" = \".\"; then 56648c4a8e55Smrg thisdir=\`pwd\` 56658c4a8e55Smrg fi 56668c4a8e55Smrg # remove .libs from thisdir 56678c4a8e55Smrg case \"\$thisdir\" in 5668706b6b52Smrg *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; 56698c4a8e55Smrg $objdir ) thisdir=. ;; 56708c4a8e55Smrg esac 56718c4a8e55Smrg fi 56728c4a8e55Smrg 56738c4a8e55Smrg # Try to get the absolute directory name. 56748c4a8e55Smrg absdir=\`cd \"\$thisdir\" && pwd\` 56758c4a8e55Smrg test -n \"\$absdir\" && thisdir=\"\$absdir\" 56768c4a8e55Smrg" 56778c4a8e55Smrg 56783169be4bSmrg if test yes = "$fast_install"; then 56798c4a8e55Smrg $ECHO "\ 56808c4a8e55Smrg program=lt-'$outputname'$exeext 56818c4a8e55Smrg progdir=\"\$thisdir/$objdir\" 56828c4a8e55Smrg 56838c4a8e55Smrg if test ! -f \"\$progdir/\$program\" || 56843169be4bSmrg { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\ 56858c4a8e55Smrg test \"X\$file\" != \"X\$progdir/\$program\"; }; then 56868c4a8e55Smrg 56878c4a8e55Smrg file=\"\$\$-\$program\" 56888c4a8e55Smrg 56898c4a8e55Smrg if test ! -d \"\$progdir\"; then 56908c4a8e55Smrg $MKDIR \"\$progdir\" 56918c4a8e55Smrg else 56928c4a8e55Smrg $RM \"\$progdir/\$file\" 56938c4a8e55Smrg fi" 56948c4a8e55Smrg 56958c4a8e55Smrg $ECHO "\ 56968c4a8e55Smrg 56978c4a8e55Smrg # relink executable if necessary 56988c4a8e55Smrg if test -n \"\$relink_command\"; then 56998c4a8e55Smrg if relink_command_output=\`eval \$relink_command 2>&1\`; then : 57008c4a8e55Smrg else 57013169be4bSmrg \$ECHO \"\$relink_command_output\" >&2 57028c4a8e55Smrg $RM \"\$progdir/\$file\" 57038c4a8e55Smrg exit 1 5704b042e37fSmrg fi 57058c4a8e55Smrg fi 5706b042e37fSmrg 57078c4a8e55Smrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || 57088c4a8e55Smrg { $RM \"\$progdir/\$program\"; 57098c4a8e55Smrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } 57108c4a8e55Smrg $RM \"\$progdir/\$file\" 57118c4a8e55Smrg fi" 57128c4a8e55Smrg else 57138c4a8e55Smrg $ECHO "\ 57148c4a8e55Smrg program='$outputname' 57158c4a8e55Smrg progdir=\"\$thisdir/$objdir\" 57168c4a8e55Smrg" 5717b042e37fSmrg fi 5718b042e37fSmrg 57198c4a8e55Smrg $ECHO "\ 5720b042e37fSmrg 57218c4a8e55Smrg if test -f \"\$progdir/\$program\"; then" 5722b042e37fSmrg 5723bd23fbfaSmrg # fixup the dll searchpath if we need to. 5724bd23fbfaSmrg # 5725bd23fbfaSmrg # Fix the DLL searchpath if we need to. Do this before prepending 5726bd23fbfaSmrg # to shlibpath, because on Windows, both are PATH and uninstalled 5727bd23fbfaSmrg # libraries must come first. 5728bd23fbfaSmrg if test -n "$dllsearchpath"; then 5729bd23fbfaSmrg $ECHO "\ 5730bd23fbfaSmrg # Add the dll search path components to the executable PATH 5731bd23fbfaSmrg PATH=$dllsearchpath:\$PATH 5732bd23fbfaSmrg" 5733bd23fbfaSmrg fi 5734bd23fbfaSmrg 57358c4a8e55Smrg # Export our shlibpath_var if we have one. 57363169be4bSmrg if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 57378c4a8e55Smrg $ECHO "\ 57388c4a8e55Smrg # Add our own library path to $shlibpath_var 57398c4a8e55Smrg $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" 57408c4a8e55Smrg 57418c4a8e55Smrg # Some systems cannot cope with colon-terminated $shlibpath_var 57428c4a8e55Smrg # The second colon is a workaround for a bug in BeOS R4 sed 5743706b6b52Smrg $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` 5744b042e37fSmrg 57458c4a8e55Smrg export $shlibpath_var 57468c4a8e55Smrg" 5747b042e37fSmrg fi 5748b042e37fSmrg 57498c4a8e55Smrg $ECHO "\ 57508c4a8e55Smrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 57518c4a8e55Smrg # Run the actual program with our arguments. 5752706b6b52Smrg func_exec_program \${1+\"\$@\"} 57538c4a8e55Smrg fi 57548c4a8e55Smrg else 57558c4a8e55Smrg # The program doesn't exist. 57563169be4bSmrg \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2 57578c4a8e55Smrg \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 5758706b6b52Smrg \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 57598c4a8e55Smrg exit 1 57608c4a8e55Smrg fi 57618c4a8e55Smrgfi\ 57628c4a8e55Smrg" 57638c4a8e55Smrg} 5764b042e37fSmrg 5765b042e37fSmrg 57668c4a8e55Smrg# func_emit_cwrapperexe_src 57678c4a8e55Smrg# emit the source code for a wrapper executable on stdout 57688c4a8e55Smrg# Must ONLY be called from within func_mode_link because 57698c4a8e55Smrg# it depends on a number of variable set therein. 57708c4a8e55Smrgfunc_emit_cwrapperexe_src () 57718c4a8e55Smrg{ 57728c4a8e55Smrg cat <<EOF 5773b042e37fSmrg 57748c4a8e55Smrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname 57753169be4bSmrg Generated by $PROGRAM (GNU $PACKAGE) $VERSION 5776b042e37fSmrg 57778c4a8e55Smrg The $output program cannot be directly executed until all the libtool 57788c4a8e55Smrg libraries that it depends on are installed. 5779b042e37fSmrg 57808c4a8e55Smrg This wrapper executable should never be moved out of the build directory. 57818c4a8e55Smrg If it is, it will not operate correctly. 57828c4a8e55Smrg*/ 57838c4a8e55SmrgEOF 57848c4a8e55Smrg cat <<"EOF" 5785706b6b52Smrg#ifdef _MSC_VER 5786706b6b52Smrg# define _CRT_SECURE_NO_DEPRECATE 1 5787706b6b52Smrg#endif 57888c4a8e55Smrg#include <stdio.h> 57898c4a8e55Smrg#include <stdlib.h> 57908c4a8e55Smrg#ifdef _MSC_VER 57918c4a8e55Smrg# include <direct.h> 57928c4a8e55Smrg# include <process.h> 57938c4a8e55Smrg# include <io.h> 57948c4a8e55Smrg#else 57958c4a8e55Smrg# include <unistd.h> 57968c4a8e55Smrg# include <stdint.h> 57978c4a8e55Smrg# ifdef __CYGWIN__ 57988c4a8e55Smrg# include <io.h> 57998c4a8e55Smrg# endif 58008c4a8e55Smrg#endif 58018c4a8e55Smrg#include <malloc.h> 58028c4a8e55Smrg#include <stdarg.h> 58038c4a8e55Smrg#include <assert.h> 58048c4a8e55Smrg#include <string.h> 58058c4a8e55Smrg#include <ctype.h> 58068c4a8e55Smrg#include <errno.h> 58078c4a8e55Smrg#include <fcntl.h> 58088c4a8e55Smrg#include <sys/stat.h> 5809b042e37fSmrg 58103169be4bSmrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 58113169be4bSmrg 5812706b6b52Smrg/* declarations of non-ANSI functions */ 58133169be4bSmrg#if defined __MINGW32__ 5814706b6b52Smrg# ifdef __STRICT_ANSI__ 5815706b6b52Smrgint _putenv (const char *); 5816706b6b52Smrg# endif 58173169be4bSmrg#elif defined __CYGWIN__ 5818706b6b52Smrg# ifdef __STRICT_ANSI__ 5819706b6b52Smrgchar *realpath (const char *, char *); 5820706b6b52Smrgint putenv (char *); 5821706b6b52Smrgint setenv (const char *, const char *, int); 5822706b6b52Smrg# endif 58233169be4bSmrg/* #elif defined other_platform || defined ... */ 5824706b6b52Smrg#endif 5825706b6b52Smrg 5826706b6b52Smrg/* portability defines, excluding path handling macros */ 58273169be4bSmrg#if defined _MSC_VER 5828706b6b52Smrg# define setmode _setmode 5829706b6b52Smrg# define stat _stat 5830706b6b52Smrg# define chmod _chmod 5831706b6b52Smrg# define getcwd _getcwd 5832706b6b52Smrg# define putenv _putenv 5833706b6b52Smrg# define S_IXUSR _S_IEXEC 58343169be4bSmrg#elif defined __MINGW32__ 5835706b6b52Smrg# define setmode _setmode 5836706b6b52Smrg# define stat _stat 5837706b6b52Smrg# define chmod _chmod 5838706b6b52Smrg# define getcwd _getcwd 5839706b6b52Smrg# define putenv _putenv 58403169be4bSmrg#elif defined __CYGWIN__ 5841706b6b52Smrg# define HAVE_SETENV 5842706b6b52Smrg# define FOPEN_WB "wb" 58433169be4bSmrg/* #elif defined other platforms ... */ 5844706b6b52Smrg#endif 5845706b6b52Smrg 58463169be4bSmrg#if defined PATH_MAX 58478c4a8e55Smrg# define LT_PATHMAX PATH_MAX 58483169be4bSmrg#elif defined MAXPATHLEN 58498c4a8e55Smrg# define LT_PATHMAX MAXPATHLEN 58508c4a8e55Smrg#else 58518c4a8e55Smrg# define LT_PATHMAX 1024 58528c4a8e55Smrg#endif 5853b042e37fSmrg 58548c4a8e55Smrg#ifndef S_IXOTH 58558c4a8e55Smrg# define S_IXOTH 0 58568c4a8e55Smrg#endif 58578c4a8e55Smrg#ifndef S_IXGRP 58588c4a8e55Smrg# define S_IXGRP 0 58598c4a8e55Smrg#endif 5860b042e37fSmrg 5861706b6b52Smrg/* path handling portability macros */ 58628c4a8e55Smrg#ifndef DIR_SEPARATOR 58638c4a8e55Smrg# define DIR_SEPARATOR '/' 58648c4a8e55Smrg# define PATH_SEPARATOR ':' 58658c4a8e55Smrg#endif 5866b042e37fSmrg 58673169be4bSmrg#if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \ 58683169be4bSmrg defined __OS2__ 58698c4a8e55Smrg# define HAVE_DOS_BASED_FILE_SYSTEM 58708c4a8e55Smrg# define FOPEN_WB "wb" 58718c4a8e55Smrg# ifndef DIR_SEPARATOR_2 58728c4a8e55Smrg# define DIR_SEPARATOR_2 '\\' 58738c4a8e55Smrg# endif 58748c4a8e55Smrg# ifndef PATH_SEPARATOR_2 58758c4a8e55Smrg# define PATH_SEPARATOR_2 ';' 58768c4a8e55Smrg# endif 58778c4a8e55Smrg#endif 5878b042e37fSmrg 58798c4a8e55Smrg#ifndef DIR_SEPARATOR_2 58808c4a8e55Smrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) 58818c4a8e55Smrg#else /* DIR_SEPARATOR_2 */ 58828c4a8e55Smrg# define IS_DIR_SEPARATOR(ch) \ 58838c4a8e55Smrg (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) 58848c4a8e55Smrg#endif /* DIR_SEPARATOR_2 */ 5885b042e37fSmrg 58868c4a8e55Smrg#ifndef PATH_SEPARATOR_2 58878c4a8e55Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) 58888c4a8e55Smrg#else /* PATH_SEPARATOR_2 */ 58898c4a8e55Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) 58908c4a8e55Smrg#endif /* PATH_SEPARATOR_2 */ 5891b042e37fSmrg 58928c4a8e55Smrg#ifndef FOPEN_WB 58938c4a8e55Smrg# define FOPEN_WB "w" 58948c4a8e55Smrg#endif 58958c4a8e55Smrg#ifndef _O_BINARY 58968c4a8e55Smrg# define _O_BINARY 0 58978c4a8e55Smrg#endif 5898b042e37fSmrg 58998c4a8e55Smrg#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) 59008c4a8e55Smrg#define XFREE(stale) do { \ 59013169be4bSmrg if (stale) { free (stale); stale = 0; } \ 59028c4a8e55Smrg} while (0) 5903b042e37fSmrg 59043169be4bSmrg#if defined LT_DEBUGWRAPPER 5905706b6b52Smrgstatic int lt_debug = 1; 59068c4a8e55Smrg#else 5907706b6b52Smrgstatic int lt_debug = 0; 59088c4a8e55Smrg#endif 5909b042e37fSmrg 5910706b6b52Smrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ 5911b042e37fSmrg 59128c4a8e55Smrgvoid *xmalloc (size_t num); 59138c4a8e55Smrgchar *xstrdup (const char *string); 59148c4a8e55Smrgconst char *base_name (const char *name); 59158c4a8e55Smrgchar *find_executable (const char *wrapper); 59168c4a8e55Smrgchar *chase_symlinks (const char *pathspec); 59178c4a8e55Smrgint make_executable (const char *path); 59188c4a8e55Smrgint check_executable (const char *path); 59198c4a8e55Smrgchar *strendzap (char *str, const char *pat); 5920706b6b52Smrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...); 5921706b6b52Smrgvoid lt_fatal (const char *file, int line, const char *message, ...); 5922706b6b52Smrgstatic const char *nonnull (const char *s); 5923706b6b52Smrgstatic const char *nonempty (const char *s); 59248c4a8e55Smrgvoid lt_setenv (const char *name, const char *value); 59258c4a8e55Smrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end); 59268c4a8e55Smrgvoid lt_update_exe_path (const char *name, const char *value); 59278c4a8e55Smrgvoid lt_update_lib_path (const char *name, const char *value); 5928706b6b52Smrgchar **prepare_spawn (char **argv); 5929706b6b52Smrgvoid lt_dump_script (FILE *f); 59308c4a8e55SmrgEOF 59318c4a8e55Smrg 59328c4a8e55Smrg cat <<EOF 59333169be4bSmrg#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5) 59343169be4bSmrg# define externally_visible volatile 59353169be4bSmrg#else 59363169be4bSmrg# define externally_visible __attribute__((externally_visible)) volatile 59373169be4bSmrg#endif 59383169be4bSmrgexternally_visible const char * MAGIC_EXE = "$magic_exe"; 59398c4a8e55Smrgconst char * LIB_PATH_VARNAME = "$shlibpath_var"; 59408c4a8e55SmrgEOF 5941b042e37fSmrg 59423169be4bSmrg if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 5943bd23fbfaSmrg func_to_host_path "$temp_rpath" 59448c4a8e55Smrg cat <<EOF 5945bd23fbfaSmrgconst char * LIB_PATH_VALUE = "$func_to_host_path_result"; 5946b042e37fSmrgEOF 5947b042e37fSmrg else 59488c4a8e55Smrg cat <<"EOF" 59498c4a8e55Smrgconst char * LIB_PATH_VALUE = ""; 59508c4a8e55SmrgEOF 5951b042e37fSmrg fi 59528c4a8e55Smrg 59538c4a8e55Smrg if test -n "$dllsearchpath"; then 5954bd23fbfaSmrg func_to_host_path "$dllsearchpath:" 59558c4a8e55Smrg cat <<EOF 59568c4a8e55Smrgconst char * EXE_PATH_VARNAME = "PATH"; 5957bd23fbfaSmrgconst char * EXE_PATH_VALUE = "$func_to_host_path_result"; 59588c4a8e55SmrgEOF 5959b042e37fSmrg else 59608c4a8e55Smrg cat <<"EOF" 59618c4a8e55Smrgconst char * EXE_PATH_VARNAME = ""; 59628c4a8e55Smrgconst char * EXE_PATH_VALUE = ""; 59638c4a8e55SmrgEOF 5964b042e37fSmrg fi 59658c4a8e55Smrg 59663169be4bSmrg if test yes = "$fast_install"; then 59678c4a8e55Smrg cat <<EOF 59688c4a8e55Smrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */ 59698c4a8e55SmrgEOF 5970b042e37fSmrg else 59718c4a8e55Smrg cat <<EOF 59728c4a8e55Smrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */ 59738c4a8e55SmrgEOF 5974b042e37fSmrg fi 5975b042e37fSmrg 5976b042e37fSmrg 59778c4a8e55Smrg cat <<"EOF" 5978b042e37fSmrg 59798c4a8e55Smrg#define LTWRAPPER_OPTION_PREFIX "--lt-" 5980b042e37fSmrg 59818c4a8e55Smrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX; 59828c4a8e55Smrgstatic const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script"; 5983706b6b52Smrgstatic const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug"; 5984b042e37fSmrg 59858c4a8e55Smrgint 59868c4a8e55Smrgmain (int argc, char *argv[]) 59878c4a8e55Smrg{ 59888c4a8e55Smrg char **newargz; 59898c4a8e55Smrg int newargc; 59908c4a8e55Smrg char *tmp_pathspec; 59918c4a8e55Smrg char *actual_cwrapper_path; 59928c4a8e55Smrg char *actual_cwrapper_name; 59938c4a8e55Smrg char *target_name; 59948c4a8e55Smrg char *lt_argv_zero; 59953169be4bSmrg int rval = 127; 5996b042e37fSmrg 59978c4a8e55Smrg int i; 5998b042e37fSmrg 59998c4a8e55Smrg program_name = (char *) xstrdup (base_name (argv[0])); 60003169be4bSmrg newargz = XMALLOC (char *, (size_t) argc + 1); 6001b042e37fSmrg 6002706b6b52Smrg /* very simple arg parsing; don't want to rely on getopt 6003706b6b52Smrg * also, copy all non cwrapper options to newargz, except 6004706b6b52Smrg * argz[0], which is handled differently 6005706b6b52Smrg */ 6006706b6b52Smrg newargc=0; 60078c4a8e55Smrg for (i = 1; i < argc; i++) 60088c4a8e55Smrg { 60093169be4bSmrg if (STREQ (argv[i], dumpscript_opt)) 60108c4a8e55Smrg { 60118c4a8e55SmrgEOF 60123169be4bSmrg case $host in 60138c4a8e55Smrg *mingw* | *cygwin* ) 60148c4a8e55Smrg # make stdout use "unix" line endings 60158c4a8e55Smrg echo " setmode(1,_O_BINARY);" 60168c4a8e55Smrg ;; 60178c4a8e55Smrg esac 6018b042e37fSmrg 60198c4a8e55Smrg cat <<"EOF" 6020706b6b52Smrg lt_dump_script (stdout); 60218c4a8e55Smrg return 0; 60228c4a8e55Smrg } 60233169be4bSmrg if (STREQ (argv[i], debug_opt)) 6024706b6b52Smrg { 6025706b6b52Smrg lt_debug = 1; 6026706b6b52Smrg continue; 6027706b6b52Smrg } 60283169be4bSmrg if (STREQ (argv[i], ltwrapper_option_prefix)) 6029706b6b52Smrg { 6030706b6b52Smrg /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX 6031706b6b52Smrg namespace, but it is not one of the ones we know about and 6032706b6b52Smrg have already dealt with, above (inluding dump-script), then 6033706b6b52Smrg report an error. Otherwise, targets might begin to believe 6034706b6b52Smrg they are allowed to use options in the LTWRAPPER_OPTION_PREFIX 6035706b6b52Smrg namespace. The first time any user complains about this, we'll 6036706b6b52Smrg need to make LTWRAPPER_OPTION_PREFIX a configure-time option 6037706b6b52Smrg or a configure.ac-settable value. 6038706b6b52Smrg */ 6039706b6b52Smrg lt_fatal (__FILE__, __LINE__, 6040706b6b52Smrg "unrecognized %s option: '%s'", 6041706b6b52Smrg ltwrapper_option_prefix, argv[i]); 6042706b6b52Smrg } 6043706b6b52Smrg /* otherwise ... */ 6044706b6b52Smrg newargz[++newargc] = xstrdup (argv[i]); 60458c4a8e55Smrg } 6046706b6b52Smrg newargz[++newargc] = NULL; 6047706b6b52Smrg 6048706b6b52SmrgEOF 6049706b6b52Smrg cat <<EOF 6050706b6b52Smrg /* The GNU banner must be the first non-error debug message */ 60513169be4bSmrg lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE) $VERSION\n"); 6052706b6b52SmrgEOF 6053706b6b52Smrg cat <<"EOF" 6054706b6b52Smrg lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]); 6055706b6b52Smrg lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name); 6056b042e37fSmrg 60578c4a8e55Smrg tmp_pathspec = find_executable (argv[0]); 60588c4a8e55Smrg if (tmp_pathspec == NULL) 6059706b6b52Smrg lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]); 6060706b6b52Smrg lt_debugprintf (__FILE__, __LINE__, 6061706b6b52Smrg "(main) found exe (before symlink chase) at: %s\n", 6062706b6b52Smrg tmp_pathspec); 60638c4a8e55Smrg 60648c4a8e55Smrg actual_cwrapper_path = chase_symlinks (tmp_pathspec); 6065706b6b52Smrg lt_debugprintf (__FILE__, __LINE__, 6066706b6b52Smrg "(main) found exe (after symlink chase) at: %s\n", 6067706b6b52Smrg actual_cwrapper_path); 60688c4a8e55Smrg XFREE (tmp_pathspec); 60698c4a8e55Smrg 6070706b6b52Smrg actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path)); 60718c4a8e55Smrg strendzap (actual_cwrapper_path, actual_cwrapper_name); 60728c4a8e55Smrg 60738c4a8e55Smrg /* wrapper name transforms */ 60748c4a8e55Smrg strendzap (actual_cwrapper_name, ".exe"); 60758c4a8e55Smrg tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1); 60768c4a8e55Smrg XFREE (actual_cwrapper_name); 60778c4a8e55Smrg actual_cwrapper_name = tmp_pathspec; 60788c4a8e55Smrg tmp_pathspec = 0; 60798c4a8e55Smrg 60808c4a8e55Smrg /* target_name transforms -- use actual target program name; might have lt- prefix */ 60818c4a8e55Smrg target_name = xstrdup (base_name (TARGET_PROGRAM_NAME)); 60828c4a8e55Smrg strendzap (target_name, ".exe"); 60838c4a8e55Smrg tmp_pathspec = lt_extend_str (target_name, ".exe", 1); 60848c4a8e55Smrg XFREE (target_name); 60858c4a8e55Smrg target_name = tmp_pathspec; 60868c4a8e55Smrg tmp_pathspec = 0; 60878c4a8e55Smrg 6088706b6b52Smrg lt_debugprintf (__FILE__, __LINE__, 6089706b6b52Smrg "(main) libtool target name: %s\n", 6090706b6b52Smrg target_name); 60918c4a8e55SmrgEOF 6092b042e37fSmrg 60938c4a8e55Smrg cat <<EOF 60948c4a8e55Smrg newargz[0] = 60958c4a8e55Smrg XMALLOC (char, (strlen (actual_cwrapper_path) + 60968c4a8e55Smrg strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1)); 60978c4a8e55Smrg strcpy (newargz[0], actual_cwrapper_path); 60988c4a8e55Smrg strcat (newargz[0], "$objdir"); 60998c4a8e55Smrg strcat (newargz[0], "/"); 61008c4a8e55SmrgEOF 6101b042e37fSmrg 61028c4a8e55Smrg cat <<"EOF" 61038c4a8e55Smrg /* stop here, and copy so we don't have to do this twice */ 61048c4a8e55Smrg tmp_pathspec = xstrdup (newargz[0]); 6105b042e37fSmrg 61068c4a8e55Smrg /* do NOT want the lt- prefix here, so use actual_cwrapper_name */ 61078c4a8e55Smrg strcat (newargz[0], actual_cwrapper_name); 6108b042e37fSmrg 61098c4a8e55Smrg /* DO want the lt- prefix here if it exists, so use target_name */ 61108c4a8e55Smrg lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1); 61118c4a8e55Smrg XFREE (tmp_pathspec); 61128c4a8e55Smrg tmp_pathspec = NULL; 61138c4a8e55SmrgEOF 6114b042e37fSmrg 61158c4a8e55Smrg case $host_os in 61168c4a8e55Smrg mingw*) 61178c4a8e55Smrg cat <<"EOF" 61188c4a8e55Smrg { 61198c4a8e55Smrg char* p; 61208c4a8e55Smrg while ((p = strchr (newargz[0], '\\')) != NULL) 61218c4a8e55Smrg { 61228c4a8e55Smrg *p = '/'; 61238c4a8e55Smrg } 61248c4a8e55Smrg while ((p = strchr (lt_argv_zero, '\\')) != NULL) 61258c4a8e55Smrg { 61268c4a8e55Smrg *p = '/'; 61278c4a8e55Smrg } 61288c4a8e55Smrg } 61298c4a8e55SmrgEOF 61308c4a8e55Smrg ;; 61318c4a8e55Smrg esac 6132b042e37fSmrg 61338c4a8e55Smrg cat <<"EOF" 61348c4a8e55Smrg XFREE (target_name); 61358c4a8e55Smrg XFREE (actual_cwrapper_path); 61368c4a8e55Smrg XFREE (actual_cwrapper_name); 6137b042e37fSmrg 61388c4a8e55Smrg lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */ 61398c4a8e55Smrg lt_setenv ("DUALCASE", "1"); /* for MSK sh */ 6140bd23fbfaSmrg /* Update the DLL searchpath. EXE_PATH_VALUE ($dllsearchpath) must 6141bd23fbfaSmrg be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath) 6142bd23fbfaSmrg because on Windows, both *_VARNAMEs are PATH but uninstalled 6143bd23fbfaSmrg libraries must come first. */ 61448c4a8e55Smrg lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE); 6145bd23fbfaSmrg lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE); 6146b042e37fSmrg 6147706b6b52Smrg lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n", 6148706b6b52Smrg nonnull (lt_argv_zero)); 61498c4a8e55Smrg for (i = 0; i < newargc; i++) 61508c4a8e55Smrg { 6151706b6b52Smrg lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n", 6152706b6b52Smrg i, nonnull (newargz[i])); 61538c4a8e55Smrg } 6154b042e37fSmrg 61558c4a8e55SmrgEOF 6156b042e37fSmrg 61578c4a8e55Smrg case $host_os in 61588c4a8e55Smrg mingw*) 61598c4a8e55Smrg cat <<"EOF" 61608c4a8e55Smrg /* execv doesn't actually work on mingw as expected on unix */ 6161706b6b52Smrg newargz = prepare_spawn (newargz); 61623169be4bSmrg rval = (int) _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz); 61638c4a8e55Smrg if (rval == -1) 61648c4a8e55Smrg { 61658c4a8e55Smrg /* failed to start process */ 6166706b6b52Smrg lt_debugprintf (__FILE__, __LINE__, 6167706b6b52Smrg "(main) failed to launch target \"%s\": %s\n", 6168706b6b52Smrg lt_argv_zero, nonnull (strerror (errno))); 61698c4a8e55Smrg return 127; 61708c4a8e55Smrg } 61718c4a8e55Smrg return rval; 61728c4a8e55SmrgEOF 61738c4a8e55Smrg ;; 61748c4a8e55Smrg *) 61758c4a8e55Smrg cat <<"EOF" 61768c4a8e55Smrg execv (lt_argv_zero, newargz); 61778c4a8e55Smrg return rval; /* =127, but avoids unused variable warning */ 61788c4a8e55SmrgEOF 61798c4a8e55Smrg ;; 61808c4a8e55Smrg esac 6181b042e37fSmrg 61828c4a8e55Smrg cat <<"EOF" 61838c4a8e55Smrg} 6184b042e37fSmrg 61858c4a8e55Smrgvoid * 61868c4a8e55Smrgxmalloc (size_t num) 61878c4a8e55Smrg{ 61888c4a8e55Smrg void *p = (void *) malloc (num); 61898c4a8e55Smrg if (!p) 6190706b6b52Smrg lt_fatal (__FILE__, __LINE__, "memory exhausted"); 6191b042e37fSmrg 61928c4a8e55Smrg return p; 61938c4a8e55Smrg} 6194b042e37fSmrg 61958c4a8e55Smrgchar * 61968c4a8e55Smrgxstrdup (const char *string) 61978c4a8e55Smrg{ 61988c4a8e55Smrg return string ? strcpy ((char *) xmalloc (strlen (string) + 1), 61998c4a8e55Smrg string) : NULL; 62008c4a8e55Smrg} 6201b042e37fSmrg 62028c4a8e55Smrgconst char * 62038c4a8e55Smrgbase_name (const char *name) 62048c4a8e55Smrg{ 62058c4a8e55Smrg const char *base; 6206b042e37fSmrg 62073169be4bSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 62088c4a8e55Smrg /* Skip over the disk name in MSDOS pathnames. */ 62098c4a8e55Smrg if (isalpha ((unsigned char) name[0]) && name[1] == ':') 62108c4a8e55Smrg name += 2; 62118c4a8e55Smrg#endif 6212b042e37fSmrg 62138c4a8e55Smrg for (base = name; *name; name++) 62148c4a8e55Smrg if (IS_DIR_SEPARATOR (*name)) 62158c4a8e55Smrg base = name + 1; 62168c4a8e55Smrg return base; 62178c4a8e55Smrg} 6218b042e37fSmrg 62198c4a8e55Smrgint 62208c4a8e55Smrgcheck_executable (const char *path) 62218c4a8e55Smrg{ 62228c4a8e55Smrg struct stat st; 6223b042e37fSmrg 6224706b6b52Smrg lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n", 6225706b6b52Smrg nonempty (path)); 62268c4a8e55Smrg if ((!path) || (!*path)) 62278c4a8e55Smrg return 0; 6228b042e37fSmrg 62298c4a8e55Smrg if ((stat (path, &st) >= 0) 62308c4a8e55Smrg && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) 62318c4a8e55Smrg return 1; 62328c4a8e55Smrg else 62338c4a8e55Smrg return 0; 62348c4a8e55Smrg} 6235b042e37fSmrg 62368c4a8e55Smrgint 62378c4a8e55Smrgmake_executable (const char *path) 62388c4a8e55Smrg{ 62398c4a8e55Smrg int rval = 0; 62408c4a8e55Smrg struct stat st; 6241b042e37fSmrg 6242706b6b52Smrg lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", 6243706b6b52Smrg nonempty (path)); 62448c4a8e55Smrg if ((!path) || (!*path)) 62458c4a8e55Smrg return 0; 6246b042e37fSmrg 62478c4a8e55Smrg if (stat (path, &st) >= 0) 62488c4a8e55Smrg { 62498c4a8e55Smrg rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); 62508c4a8e55Smrg } 62518c4a8e55Smrg return rval; 62528c4a8e55Smrg} 6253b042e37fSmrg 62548c4a8e55Smrg/* Searches for the full path of the wrapper. Returns 62558c4a8e55Smrg newly allocated full path name if found, NULL otherwise 62568c4a8e55Smrg Does not chase symlinks, even on platforms that support them. 62578c4a8e55Smrg*/ 62588c4a8e55Smrgchar * 62598c4a8e55Smrgfind_executable (const char *wrapper) 62608c4a8e55Smrg{ 62618c4a8e55Smrg int has_slash = 0; 62628c4a8e55Smrg const char *p; 62638c4a8e55Smrg const char *p_next; 62648c4a8e55Smrg /* static buffer for getcwd */ 62658c4a8e55Smrg char tmp[LT_PATHMAX + 1]; 62663169be4bSmrg size_t tmp_len; 62678c4a8e55Smrg char *concat_name; 6268b042e37fSmrg 6269706b6b52Smrg lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", 6270706b6b52Smrg nonempty (wrapper)); 6271b042e37fSmrg 62728c4a8e55Smrg if ((wrapper == NULL) || (*wrapper == '\0')) 62738c4a8e55Smrg return NULL; 6274b042e37fSmrg 62758c4a8e55Smrg /* Absolute path? */ 62763169be4bSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 62778c4a8e55Smrg if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') 62788c4a8e55Smrg { 62798c4a8e55Smrg concat_name = xstrdup (wrapper); 62808c4a8e55Smrg if (check_executable (concat_name)) 62818c4a8e55Smrg return concat_name; 62828c4a8e55Smrg XFREE (concat_name); 62838c4a8e55Smrg } 62848c4a8e55Smrg else 62858c4a8e55Smrg { 62868c4a8e55Smrg#endif 62878c4a8e55Smrg if (IS_DIR_SEPARATOR (wrapper[0])) 62888c4a8e55Smrg { 62898c4a8e55Smrg concat_name = xstrdup (wrapper); 62908c4a8e55Smrg if (check_executable (concat_name)) 62918c4a8e55Smrg return concat_name; 62928c4a8e55Smrg XFREE (concat_name); 62938c4a8e55Smrg } 62943169be4bSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 62958c4a8e55Smrg } 62968c4a8e55Smrg#endif 6297b042e37fSmrg 62988c4a8e55Smrg for (p = wrapper; *p; p++) 62998c4a8e55Smrg if (*p == '/') 63008c4a8e55Smrg { 63018c4a8e55Smrg has_slash = 1; 63028c4a8e55Smrg break; 63038c4a8e55Smrg } 63048c4a8e55Smrg if (!has_slash) 63058c4a8e55Smrg { 63068c4a8e55Smrg /* no slashes; search PATH */ 63078c4a8e55Smrg const char *path = getenv ("PATH"); 63088c4a8e55Smrg if (path != NULL) 63098c4a8e55Smrg { 63108c4a8e55Smrg for (p = path; *p; p = p_next) 63118c4a8e55Smrg { 63128c4a8e55Smrg const char *q; 63138c4a8e55Smrg size_t p_len; 63148c4a8e55Smrg for (q = p; *q; q++) 63158c4a8e55Smrg if (IS_PATH_SEPARATOR (*q)) 63168c4a8e55Smrg break; 63173169be4bSmrg p_len = (size_t) (q - p); 63188c4a8e55Smrg p_next = (*q == '\0' ? q : q + 1); 63198c4a8e55Smrg if (p_len == 0) 63208c4a8e55Smrg { 63218c4a8e55Smrg /* empty path: current directory */ 63228c4a8e55Smrg if (getcwd (tmp, LT_PATHMAX) == NULL) 6323706b6b52Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 6324706b6b52Smrg nonnull (strerror (errno))); 63258c4a8e55Smrg tmp_len = strlen (tmp); 63268c4a8e55Smrg concat_name = 63278c4a8e55Smrg XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 63288c4a8e55Smrg memcpy (concat_name, tmp, tmp_len); 63298c4a8e55Smrg concat_name[tmp_len] = '/'; 63308c4a8e55Smrg strcpy (concat_name + tmp_len + 1, wrapper); 63318c4a8e55Smrg } 63328c4a8e55Smrg else 63338c4a8e55Smrg { 63348c4a8e55Smrg concat_name = 63358c4a8e55Smrg XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); 63368c4a8e55Smrg memcpy (concat_name, p, p_len); 63378c4a8e55Smrg concat_name[p_len] = '/'; 63388c4a8e55Smrg strcpy (concat_name + p_len + 1, wrapper); 63398c4a8e55Smrg } 63408c4a8e55Smrg if (check_executable (concat_name)) 63418c4a8e55Smrg return concat_name; 63428c4a8e55Smrg XFREE (concat_name); 63438c4a8e55Smrg } 63448c4a8e55Smrg } 63458c4a8e55Smrg /* not found in PATH; assume curdir */ 63468c4a8e55Smrg } 63478c4a8e55Smrg /* Relative path | not found in path: prepend cwd */ 63488c4a8e55Smrg if (getcwd (tmp, LT_PATHMAX) == NULL) 6349706b6b52Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 6350706b6b52Smrg nonnull (strerror (errno))); 63518c4a8e55Smrg tmp_len = strlen (tmp); 63528c4a8e55Smrg concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 63538c4a8e55Smrg memcpy (concat_name, tmp, tmp_len); 63548c4a8e55Smrg concat_name[tmp_len] = '/'; 63558c4a8e55Smrg strcpy (concat_name + tmp_len + 1, wrapper); 6356b042e37fSmrg 63578c4a8e55Smrg if (check_executable (concat_name)) 63588c4a8e55Smrg return concat_name; 63598c4a8e55Smrg XFREE (concat_name); 63608c4a8e55Smrg return NULL; 63618c4a8e55Smrg} 6362b042e37fSmrg 63638c4a8e55Smrgchar * 63648c4a8e55Smrgchase_symlinks (const char *pathspec) 63658c4a8e55Smrg{ 63668c4a8e55Smrg#ifndef S_ISLNK 63678c4a8e55Smrg return xstrdup (pathspec); 63688c4a8e55Smrg#else 63698c4a8e55Smrg char buf[LT_PATHMAX]; 63708c4a8e55Smrg struct stat s; 63718c4a8e55Smrg char *tmp_pathspec = xstrdup (pathspec); 63728c4a8e55Smrg char *p; 63738c4a8e55Smrg int has_symlinks = 0; 63748c4a8e55Smrg while (strlen (tmp_pathspec) && !has_symlinks) 63758c4a8e55Smrg { 6376706b6b52Smrg lt_debugprintf (__FILE__, __LINE__, 6377706b6b52Smrg "checking path component for symlinks: %s\n", 6378706b6b52Smrg tmp_pathspec); 63798c4a8e55Smrg if (lstat (tmp_pathspec, &s) == 0) 63808c4a8e55Smrg { 63818c4a8e55Smrg if (S_ISLNK (s.st_mode) != 0) 63828c4a8e55Smrg { 63838c4a8e55Smrg has_symlinks = 1; 63848c4a8e55Smrg break; 63858c4a8e55Smrg } 6386b042e37fSmrg 63878c4a8e55Smrg /* search backwards for last DIR_SEPARATOR */ 63888c4a8e55Smrg p = tmp_pathspec + strlen (tmp_pathspec) - 1; 63898c4a8e55Smrg while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 63908c4a8e55Smrg p--; 63918c4a8e55Smrg if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 63928c4a8e55Smrg { 63938c4a8e55Smrg /* no more DIR_SEPARATORS left */ 63948c4a8e55Smrg break; 63958c4a8e55Smrg } 63968c4a8e55Smrg *p = '\0'; 63978c4a8e55Smrg } 63988c4a8e55Smrg else 63998c4a8e55Smrg { 6400706b6b52Smrg lt_fatal (__FILE__, __LINE__, 6401706b6b52Smrg "error accessing file \"%s\": %s", 6402706b6b52Smrg tmp_pathspec, nonnull (strerror (errno))); 64038c4a8e55Smrg } 64048c4a8e55Smrg } 64058c4a8e55Smrg XFREE (tmp_pathspec); 6406b042e37fSmrg 64078c4a8e55Smrg if (!has_symlinks) 64088c4a8e55Smrg { 64098c4a8e55Smrg return xstrdup (pathspec); 64108c4a8e55Smrg } 6411b042e37fSmrg 64128c4a8e55Smrg tmp_pathspec = realpath (pathspec, buf); 64138c4a8e55Smrg if (tmp_pathspec == 0) 64148c4a8e55Smrg { 6415706b6b52Smrg lt_fatal (__FILE__, __LINE__, 6416706b6b52Smrg "could not follow symlinks for %s", pathspec); 64178c4a8e55Smrg } 64188c4a8e55Smrg return xstrdup (tmp_pathspec); 64198c4a8e55Smrg#endif 64208c4a8e55Smrg} 6421b042e37fSmrg 64228c4a8e55Smrgchar * 64238c4a8e55Smrgstrendzap (char *str, const char *pat) 64248c4a8e55Smrg{ 64258c4a8e55Smrg size_t len, patlen; 6426b042e37fSmrg 64278c4a8e55Smrg assert (str != NULL); 64288c4a8e55Smrg assert (pat != NULL); 6429b042e37fSmrg 64308c4a8e55Smrg len = strlen (str); 64318c4a8e55Smrg patlen = strlen (pat); 6432b042e37fSmrg 64338c4a8e55Smrg if (patlen <= len) 64348c4a8e55Smrg { 64358c4a8e55Smrg str += len - patlen; 64363169be4bSmrg if (STREQ (str, pat)) 64378c4a8e55Smrg *str = '\0'; 64388c4a8e55Smrg } 64398c4a8e55Smrg return str; 64408c4a8e55Smrg} 6441b042e37fSmrg 6442706b6b52Smrgvoid 6443706b6b52Smrglt_debugprintf (const char *file, int line, const char *fmt, ...) 6444706b6b52Smrg{ 6445706b6b52Smrg va_list args; 6446706b6b52Smrg if (lt_debug) 6447706b6b52Smrg { 6448706b6b52Smrg (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); 6449706b6b52Smrg va_start (args, fmt); 6450706b6b52Smrg (void) vfprintf (stderr, fmt, args); 6451706b6b52Smrg va_end (args); 6452706b6b52Smrg } 6453706b6b52Smrg} 6454706b6b52Smrg 64558c4a8e55Smrgstatic void 6456706b6b52Smrglt_error_core (int exit_status, const char *file, 6457706b6b52Smrg int line, const char *mode, 64588c4a8e55Smrg const char *message, va_list ap) 64598c4a8e55Smrg{ 6460706b6b52Smrg fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); 64618c4a8e55Smrg vfprintf (stderr, message, ap); 64628c4a8e55Smrg fprintf (stderr, ".\n"); 6463b042e37fSmrg 64648c4a8e55Smrg if (exit_status >= 0) 64658c4a8e55Smrg exit (exit_status); 64668c4a8e55Smrg} 6467b042e37fSmrg 64688c4a8e55Smrgvoid 6469706b6b52Smrglt_fatal (const char *file, int line, const char *message, ...) 64708c4a8e55Smrg{ 64718c4a8e55Smrg va_list ap; 64728c4a8e55Smrg va_start (ap, message); 6473706b6b52Smrg lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); 64748c4a8e55Smrg va_end (ap); 64758c4a8e55Smrg} 6476b042e37fSmrg 6477706b6b52Smrgstatic const char * 6478706b6b52Smrgnonnull (const char *s) 6479706b6b52Smrg{ 6480706b6b52Smrg return s ? s : "(null)"; 6481706b6b52Smrg} 6482706b6b52Smrg 6483706b6b52Smrgstatic const char * 6484706b6b52Smrgnonempty (const char *s) 6485706b6b52Smrg{ 6486706b6b52Smrg return (s && !*s) ? "(empty)" : nonnull (s); 6487706b6b52Smrg} 6488706b6b52Smrg 64898c4a8e55Smrgvoid 64908c4a8e55Smrglt_setenv (const char *name, const char *value) 64918c4a8e55Smrg{ 6492706b6b52Smrg lt_debugprintf (__FILE__, __LINE__, 6493706b6b52Smrg "(lt_setenv) setting '%s' to '%s'\n", 6494706b6b52Smrg nonnull (name), nonnull (value)); 64958c4a8e55Smrg { 64968c4a8e55Smrg#ifdef HAVE_SETENV 64978c4a8e55Smrg /* always make a copy, for consistency with !HAVE_SETENV */ 64988c4a8e55Smrg char *str = xstrdup (value); 64998c4a8e55Smrg setenv (name, str, 1); 65008c4a8e55Smrg#else 65013169be4bSmrg size_t len = strlen (name) + 1 + strlen (value) + 1; 65028c4a8e55Smrg char *str = XMALLOC (char, len); 65038c4a8e55Smrg sprintf (str, "%s=%s", name, value); 65048c4a8e55Smrg if (putenv (str) != EXIT_SUCCESS) 65058c4a8e55Smrg { 65068c4a8e55Smrg XFREE (str); 65078c4a8e55Smrg } 65088c4a8e55Smrg#endif 65098c4a8e55Smrg } 65108c4a8e55Smrg} 6511b042e37fSmrg 65128c4a8e55Smrgchar * 65138c4a8e55Smrglt_extend_str (const char *orig_value, const char *add, int to_end) 65148c4a8e55Smrg{ 65158c4a8e55Smrg char *new_value; 65168c4a8e55Smrg if (orig_value && *orig_value) 65178c4a8e55Smrg { 65183169be4bSmrg size_t orig_value_len = strlen (orig_value); 65193169be4bSmrg size_t add_len = strlen (add); 65208c4a8e55Smrg new_value = XMALLOC (char, add_len + orig_value_len + 1); 65218c4a8e55Smrg if (to_end) 65228c4a8e55Smrg { 65238c4a8e55Smrg strcpy (new_value, orig_value); 65248c4a8e55Smrg strcpy (new_value + orig_value_len, add); 65258c4a8e55Smrg } 65268c4a8e55Smrg else 65278c4a8e55Smrg { 65288c4a8e55Smrg strcpy (new_value, add); 65298c4a8e55Smrg strcpy (new_value + add_len, orig_value); 65308c4a8e55Smrg } 65318c4a8e55Smrg } 65328c4a8e55Smrg else 65338c4a8e55Smrg { 65348c4a8e55Smrg new_value = xstrdup (add); 65358c4a8e55Smrg } 65368c4a8e55Smrg return new_value; 65378c4a8e55Smrg} 6538b042e37fSmrg 65398c4a8e55Smrgvoid 65408c4a8e55Smrglt_update_exe_path (const char *name, const char *value) 65418c4a8e55Smrg{ 6542706b6b52Smrg lt_debugprintf (__FILE__, __LINE__, 6543706b6b52Smrg "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", 6544706b6b52Smrg nonnull (name), nonnull (value)); 6545b042e37fSmrg 65468c4a8e55Smrg if (name && *name && value && *value) 65478c4a8e55Smrg { 65488c4a8e55Smrg char *new_value = lt_extend_str (getenv (name), value, 0); 65498c4a8e55Smrg /* some systems can't cope with a ':'-terminated path #' */ 65503169be4bSmrg size_t len = strlen (new_value); 65513169be4bSmrg while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1])) 65528c4a8e55Smrg { 65533169be4bSmrg new_value[--len] = '\0'; 65548c4a8e55Smrg } 65558c4a8e55Smrg lt_setenv (name, new_value); 65568c4a8e55Smrg XFREE (new_value); 65578c4a8e55Smrg } 65588c4a8e55Smrg} 6559b042e37fSmrg 65608c4a8e55Smrgvoid 65618c4a8e55Smrglt_update_lib_path (const char *name, const char *value) 65628c4a8e55Smrg{ 6563706b6b52Smrg lt_debugprintf (__FILE__, __LINE__, 6564706b6b52Smrg "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", 6565706b6b52Smrg nonnull (name), nonnull (value)); 6566b042e37fSmrg 65678c4a8e55Smrg if (name && *name && value && *value) 65688c4a8e55Smrg { 65698c4a8e55Smrg char *new_value = lt_extend_str (getenv (name), value, 0); 65708c4a8e55Smrg lt_setenv (name, new_value); 65718c4a8e55Smrg XFREE (new_value); 65728c4a8e55Smrg } 65738c4a8e55Smrg} 6574b042e37fSmrg 6575706b6b52SmrgEOF 6576706b6b52Smrg case $host_os in 6577706b6b52Smrg mingw*) 6578706b6b52Smrg cat <<"EOF" 6579706b6b52Smrg 6580706b6b52Smrg/* Prepares an argument vector before calling spawn(). 6581706b6b52Smrg Note that spawn() does not by itself call the command interpreter 6582706b6b52Smrg (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : 6583706b6b52Smrg ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); 6584706b6b52Smrg GetVersionEx(&v); 6585706b6b52Smrg v.dwPlatformId == VER_PLATFORM_WIN32_NT; 6586706b6b52Smrg }) ? "cmd.exe" : "command.com"). 6587706b6b52Smrg Instead it simply concatenates the arguments, separated by ' ', and calls 6588706b6b52Smrg CreateProcess(). We must quote the arguments since Win32 CreateProcess() 6589706b6b52Smrg interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a 6590706b6b52Smrg special way: 6591706b6b52Smrg - Space and tab are interpreted as delimiters. They are not treated as 6592706b6b52Smrg delimiters if they are surrounded by double quotes: "...". 6593706b6b52Smrg - Unescaped double quotes are removed from the input. Their only effect is 6594706b6b52Smrg that within double quotes, space and tab are treated like normal 6595706b6b52Smrg characters. 6596706b6b52Smrg - Backslashes not followed by double quotes are not special. 6597706b6b52Smrg - But 2*n+1 backslashes followed by a double quote become 6598706b6b52Smrg n backslashes followed by a double quote (n >= 0): 6599706b6b52Smrg \" -> " 6600706b6b52Smrg \\\" -> \" 6601706b6b52Smrg \\\\\" -> \\" 6602706b6b52Smrg */ 6603706b6b52Smrg#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" 6604706b6b52Smrg#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" 6605706b6b52Smrgchar ** 6606706b6b52Smrgprepare_spawn (char **argv) 6607706b6b52Smrg{ 6608706b6b52Smrg size_t argc; 6609706b6b52Smrg char **new_argv; 6610706b6b52Smrg size_t i; 6611706b6b52Smrg 6612706b6b52Smrg /* Count number of arguments. */ 6613706b6b52Smrg for (argc = 0; argv[argc] != NULL; argc++) 6614706b6b52Smrg ; 6615706b6b52Smrg 6616706b6b52Smrg /* Allocate new argument vector. */ 6617706b6b52Smrg new_argv = XMALLOC (char *, argc + 1); 6618706b6b52Smrg 6619706b6b52Smrg /* Put quoted arguments into the new argument vector. */ 6620706b6b52Smrg for (i = 0; i < argc; i++) 6621706b6b52Smrg { 6622706b6b52Smrg const char *string = argv[i]; 6623706b6b52Smrg 6624706b6b52Smrg if (string[0] == '\0') 6625706b6b52Smrg new_argv[i] = xstrdup ("\"\""); 6626706b6b52Smrg else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) 6627706b6b52Smrg { 6628706b6b52Smrg int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); 6629706b6b52Smrg size_t length; 6630706b6b52Smrg unsigned int backslashes; 6631706b6b52Smrg const char *s; 6632706b6b52Smrg char *quoted_string; 6633706b6b52Smrg char *p; 6634706b6b52Smrg 6635706b6b52Smrg length = 0; 6636706b6b52Smrg backslashes = 0; 6637706b6b52Smrg if (quote_around) 6638706b6b52Smrg length++; 6639706b6b52Smrg for (s = string; *s != '\0'; s++) 6640706b6b52Smrg { 6641706b6b52Smrg char c = *s; 6642706b6b52Smrg if (c == '"') 6643706b6b52Smrg length += backslashes + 1; 6644706b6b52Smrg length++; 6645706b6b52Smrg if (c == '\\') 6646706b6b52Smrg backslashes++; 6647706b6b52Smrg else 6648706b6b52Smrg backslashes = 0; 6649706b6b52Smrg } 6650706b6b52Smrg if (quote_around) 6651706b6b52Smrg length += backslashes + 1; 6652706b6b52Smrg 6653706b6b52Smrg quoted_string = XMALLOC (char, length + 1); 6654706b6b52Smrg 6655706b6b52Smrg p = quoted_string; 6656706b6b52Smrg backslashes = 0; 6657706b6b52Smrg if (quote_around) 6658706b6b52Smrg *p++ = '"'; 6659706b6b52Smrg for (s = string; *s != '\0'; s++) 6660706b6b52Smrg { 6661706b6b52Smrg char c = *s; 6662706b6b52Smrg if (c == '"') 6663706b6b52Smrg { 6664706b6b52Smrg unsigned int j; 6665706b6b52Smrg for (j = backslashes + 1; j > 0; j--) 6666706b6b52Smrg *p++ = '\\'; 6667706b6b52Smrg } 6668706b6b52Smrg *p++ = c; 6669706b6b52Smrg if (c == '\\') 6670706b6b52Smrg backslashes++; 6671706b6b52Smrg else 6672706b6b52Smrg backslashes = 0; 6673706b6b52Smrg } 6674706b6b52Smrg if (quote_around) 6675706b6b52Smrg { 6676706b6b52Smrg unsigned int j; 6677706b6b52Smrg for (j = backslashes; j > 0; j--) 6678706b6b52Smrg *p++ = '\\'; 6679706b6b52Smrg *p++ = '"'; 6680706b6b52Smrg } 6681706b6b52Smrg *p = '\0'; 6682706b6b52Smrg 6683706b6b52Smrg new_argv[i] = quoted_string; 6684706b6b52Smrg } 6685706b6b52Smrg else 6686706b6b52Smrg new_argv[i] = (char *) string; 6687706b6b52Smrg } 6688706b6b52Smrg new_argv[argc] = NULL; 6689706b6b52Smrg 6690706b6b52Smrg return new_argv; 6691706b6b52Smrg} 6692706b6b52SmrgEOF 6693706b6b52Smrg ;; 6694706b6b52Smrg esac 6695706b6b52Smrg 6696706b6b52Smrg cat <<"EOF" 6697706b6b52Smrgvoid lt_dump_script (FILE* f) 6698706b6b52Smrg{ 6699706b6b52SmrgEOF 6700706b6b52Smrg func_emit_wrapper yes | 67010597fb56Smrg $SED -n -e ' 67020597fb56Smrgs/^\(.\{79\}\)\(..*\)/\1\ 67030597fb56Smrg\2/ 67040597fb56Smrgh 67050597fb56Smrgs/\([\\"]\)/\\\1/g 67060597fb56Smrgs/$/\\n/ 67070597fb56Smrgs/\([^\n]*\).*/ fputs ("\1", f);/p 67080597fb56Smrgg 67090597fb56SmrgD' 6710706b6b52Smrg cat <<"EOF" 6711706b6b52Smrg} 67128c4a8e55SmrgEOF 67138c4a8e55Smrg} 67148c4a8e55Smrg# end: func_emit_cwrapperexe_src 6715b042e37fSmrg 6716706b6b52Smrg# func_win32_import_lib_p ARG 6717706b6b52Smrg# True if ARG is an import lib, as indicated by $file_magic_cmd 6718706b6b52Smrgfunc_win32_import_lib_p () 6719706b6b52Smrg{ 67203169be4bSmrg $debug_cmd 67213169be4bSmrg 6722706b6b52Smrg case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in 6723706b6b52Smrg *import*) : ;; 6724706b6b52Smrg *) false ;; 6725706b6b52Smrg esac 6726706b6b52Smrg} 6727706b6b52Smrg 67283169be4bSmrg# func_suncc_cstd_abi 67293169be4bSmrg# !!ONLY CALL THIS FOR SUN CC AFTER $compile_command IS FULLY EXPANDED!! 67303169be4bSmrg# Several compiler flags select an ABI that is incompatible with the 67313169be4bSmrg# Cstd library. Avoid specifying it if any are in CXXFLAGS. 67323169be4bSmrgfunc_suncc_cstd_abi () 67333169be4bSmrg{ 67343169be4bSmrg $debug_cmd 67353169be4bSmrg 67363169be4bSmrg case " $compile_command " in 67373169be4bSmrg *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*) 67383169be4bSmrg suncc_use_cstd_abi=no 67393169be4bSmrg ;; 67403169be4bSmrg *) 67413169be4bSmrg suncc_use_cstd_abi=yes 67423169be4bSmrg ;; 67433169be4bSmrg esac 67443169be4bSmrg} 67453169be4bSmrg 67468c4a8e55Smrg# func_mode_link arg... 67478c4a8e55Smrgfunc_mode_link () 67488c4a8e55Smrg{ 67493169be4bSmrg $debug_cmd 67503169be4bSmrg 67518c4a8e55Smrg case $host in 67528c4a8e55Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 67538c4a8e55Smrg # It is impossible to link a dll without this setting, and 67548c4a8e55Smrg # we shouldn't force the makefile maintainer to figure out 67553169be4bSmrg # what system we are compiling for in order to pass an extra 67568c4a8e55Smrg # flag for every libtool invocation. 67578c4a8e55Smrg # allow_undefined=no 6758b042e37fSmrg 67598c4a8e55Smrg # FIXME: Unfortunately, there are problems with the above when trying 67603169be4bSmrg # to make a dll that has undefined symbols, in which case not 67618c4a8e55Smrg # even a static library is built. For now, we need to specify 67628c4a8e55Smrg # -no-undefined on the libtool link line when we can be certain 67638c4a8e55Smrg # that all symbols are satisfied, otherwise we get a static library. 67648c4a8e55Smrg allow_undefined=yes 67658c4a8e55Smrg ;; 67668c4a8e55Smrg *) 67678c4a8e55Smrg allow_undefined=yes 67688c4a8e55Smrg ;; 67698c4a8e55Smrg esac 67708c4a8e55Smrg libtool_args=$nonopt 67718c4a8e55Smrg base_compile="$nonopt $@" 67728c4a8e55Smrg compile_command=$nonopt 67738c4a8e55Smrg finalize_command=$nonopt 6774b042e37fSmrg 67758c4a8e55Smrg compile_rpath= 67768c4a8e55Smrg finalize_rpath= 67778c4a8e55Smrg compile_shlibpath= 67788c4a8e55Smrg finalize_shlibpath= 67798c4a8e55Smrg convenience= 67808c4a8e55Smrg old_convenience= 67818c4a8e55Smrg deplibs= 67828c4a8e55Smrg old_deplibs= 67838c4a8e55Smrg compiler_flags= 67848c4a8e55Smrg linker_flags= 67858c4a8e55Smrg dllsearchpath= 67868c4a8e55Smrg lib_search_path=`pwd` 67878c4a8e55Smrg inst_prefix_dir= 67888c4a8e55Smrg new_inherited_linker_flags= 6789b042e37fSmrg 67908c4a8e55Smrg avoid_version=no 6791706b6b52Smrg bindir= 67928c4a8e55Smrg dlfiles= 67938c4a8e55Smrg dlprefiles= 67948c4a8e55Smrg dlself=no 67958c4a8e55Smrg export_dynamic=no 67968c4a8e55Smrg export_symbols= 67978c4a8e55Smrg export_symbols_regex= 67988c4a8e55Smrg generated= 67998c4a8e55Smrg libobjs= 68008c4a8e55Smrg ltlibs= 68018c4a8e55Smrg module=no 68028c4a8e55Smrg no_install=no 68038c4a8e55Smrg objs= 68043169be4bSmrg os2dllname= 68058c4a8e55Smrg non_pic_objects= 68068c4a8e55Smrg precious_files_regex= 68078c4a8e55Smrg prefer_static_libs=no 68083169be4bSmrg preload=false 68098c4a8e55Smrg prev= 68108c4a8e55Smrg prevarg= 68118c4a8e55Smrg release= 68128c4a8e55Smrg rpath= 68138c4a8e55Smrg xrpath= 68148c4a8e55Smrg perm_rpath= 68158c4a8e55Smrg temp_rpath= 68168c4a8e55Smrg thread_safe=no 68178c4a8e55Smrg vinfo= 68188c4a8e55Smrg vinfo_number=no 68198c4a8e55Smrg weak_libs= 68203169be4bSmrg single_module=$wl-single_module 68218c4a8e55Smrg func_infer_tag $base_compile 6822b042e37fSmrg 68238c4a8e55Smrg # We need to know -static, to get the right output filenames. 68248c4a8e55Smrg for arg 68258c4a8e55Smrg do 68268c4a8e55Smrg case $arg in 68278c4a8e55Smrg -shared) 68283169be4bSmrg test yes != "$build_libtool_libs" \ 68293169be4bSmrg && func_fatal_configuration "cannot build a shared library" 68308c4a8e55Smrg build_old_libs=no 68318c4a8e55Smrg break 68328c4a8e55Smrg ;; 68338c4a8e55Smrg -all-static | -static | -static-libtool-libs) 68348c4a8e55Smrg case $arg in 68358c4a8e55Smrg -all-static) 68363169be4bSmrg if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then 68378c4a8e55Smrg func_warning "complete static linking is impossible in this configuration" 68388c4a8e55Smrg fi 68398c4a8e55Smrg if test -n "$link_static_flag"; then 68408c4a8e55Smrg dlopen_self=$dlopen_self_static 68418c4a8e55Smrg fi 68428c4a8e55Smrg prefer_static_libs=yes 68438c4a8e55Smrg ;; 68448c4a8e55Smrg -static) 68458c4a8e55Smrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 68468c4a8e55Smrg dlopen_self=$dlopen_self_static 68478c4a8e55Smrg fi 68488c4a8e55Smrg prefer_static_libs=built 68498c4a8e55Smrg ;; 68508c4a8e55Smrg -static-libtool-libs) 68518c4a8e55Smrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 68528c4a8e55Smrg dlopen_self=$dlopen_self_static 68538c4a8e55Smrg fi 68548c4a8e55Smrg prefer_static_libs=yes 68558c4a8e55Smrg ;; 68568c4a8e55Smrg esac 68578c4a8e55Smrg build_libtool_libs=no 68588c4a8e55Smrg build_old_libs=yes 68598c4a8e55Smrg break 68608c4a8e55Smrg ;; 68618c4a8e55Smrg esac 68628c4a8e55Smrg done 6863b042e37fSmrg 68648c4a8e55Smrg # See if our shared archives depend on static archives. 68658c4a8e55Smrg test -n "$old_archive_from_new_cmds" && build_old_libs=yes 6866b042e37fSmrg 68678c4a8e55Smrg # Go through the arguments, transforming them on the way. 68688c4a8e55Smrg while test "$#" -gt 0; do 68693169be4bSmrg arg=$1 68708c4a8e55Smrg shift 68718d0bc965Smrg func_quote_arg pretty,unquoted "$arg" 68728d0bc965Smrg qarg=$func_quote_arg_unquoted_result 68738d0bc965Smrg func_append libtool_args " $func_quote_arg_result" 6874b042e37fSmrg 68758c4a8e55Smrg # If the previous option needs an argument, assign it. 68768c4a8e55Smrg if test -n "$prev"; then 68778c4a8e55Smrg case $prev in 68788c4a8e55Smrg output) 68798c4a8e55Smrg func_append compile_command " @OUTPUT@" 68808c4a8e55Smrg func_append finalize_command " @OUTPUT@" 68818c4a8e55Smrg ;; 68828c4a8e55Smrg esac 6883b042e37fSmrg 68848c4a8e55Smrg case $prev in 6885706b6b52Smrg bindir) 68863169be4bSmrg bindir=$arg 6887706b6b52Smrg prev= 6888706b6b52Smrg continue 6889706b6b52Smrg ;; 68908c4a8e55Smrg dlfiles|dlprefiles) 68913169be4bSmrg $preload || { 68928c4a8e55Smrg # Add the symbol object into the linking commands. 68938c4a8e55Smrg func_append compile_command " @SYMFILE@" 68948c4a8e55Smrg func_append finalize_command " @SYMFILE@" 68953169be4bSmrg preload=: 68963169be4bSmrg } 68978c4a8e55Smrg case $arg in 68988c4a8e55Smrg *.la | *.lo) ;; # We handle these cases below. 68998c4a8e55Smrg force) 69003169be4bSmrg if test no = "$dlself"; then 69018c4a8e55Smrg dlself=needless 69028c4a8e55Smrg export_dynamic=yes 69038c4a8e55Smrg fi 69048c4a8e55Smrg prev= 69058c4a8e55Smrg continue 69068c4a8e55Smrg ;; 69078c4a8e55Smrg self) 69083169be4bSmrg if test dlprefiles = "$prev"; then 69098c4a8e55Smrg dlself=yes 69103169be4bSmrg elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then 69118c4a8e55Smrg dlself=yes 69128c4a8e55Smrg else 69138c4a8e55Smrg dlself=needless 69148c4a8e55Smrg export_dynamic=yes 69158c4a8e55Smrg fi 69168c4a8e55Smrg prev= 69178c4a8e55Smrg continue 69188c4a8e55Smrg ;; 69198c4a8e55Smrg *) 69203169be4bSmrg if test dlfiles = "$prev"; then 6921bd23fbfaSmrg func_append dlfiles " $arg" 69228c4a8e55Smrg else 6923bd23fbfaSmrg func_append dlprefiles " $arg" 69248c4a8e55Smrg fi 69258c4a8e55Smrg prev= 69268c4a8e55Smrg continue 69278c4a8e55Smrg ;; 69288c4a8e55Smrg esac 69298c4a8e55Smrg ;; 69308c4a8e55Smrg expsyms) 69313169be4bSmrg export_symbols=$arg 69328c4a8e55Smrg test -f "$arg" \ 69333169be4bSmrg || func_fatal_error "symbol file '$arg' does not exist" 69348c4a8e55Smrg prev= 69358c4a8e55Smrg continue 69368c4a8e55Smrg ;; 69378c4a8e55Smrg expsyms_regex) 69383169be4bSmrg export_symbols_regex=$arg 69398c4a8e55Smrg prev= 69408c4a8e55Smrg continue 69418c4a8e55Smrg ;; 69428c4a8e55Smrg framework) 69438c4a8e55Smrg case $host in 69448c4a8e55Smrg *-*-darwin*) 69458c4a8e55Smrg case "$deplibs " in 69468c4a8e55Smrg *" $qarg.ltframework "*) ;; 6947bd23fbfaSmrg *) func_append deplibs " $qarg.ltframework" # this is fixed later 69488c4a8e55Smrg ;; 69498c4a8e55Smrg esac 6950b042e37fSmrg ;; 69518c4a8e55Smrg esac 69528c4a8e55Smrg prev= 69538c4a8e55Smrg continue 69548c4a8e55Smrg ;; 69558c4a8e55Smrg inst_prefix) 69563169be4bSmrg inst_prefix_dir=$arg 69573169be4bSmrg prev= 69583169be4bSmrg continue 69593169be4bSmrg ;; 69603169be4bSmrg mllvm) 69613169be4bSmrg # Clang does not use LLVM to link, so we can simply discard any 69623169be4bSmrg # '-mllvm $arg' options when doing the link step. 69638c4a8e55Smrg prev= 69648c4a8e55Smrg continue 69658c4a8e55Smrg ;; 69668c4a8e55Smrg objectlist) 69678c4a8e55Smrg if test -f "$arg"; then 69688c4a8e55Smrg save_arg=$arg 69698c4a8e55Smrg moreargs= 69708c4a8e55Smrg for fil in `cat "$save_arg"` 69718c4a8e55Smrg do 6972bd23fbfaSmrg# func_append moreargs " $fil" 69738c4a8e55Smrg arg=$fil 69748c4a8e55Smrg # A libtool-controlled object. 6975b042e37fSmrg 69768c4a8e55Smrg # Check to see that this really is a libtool object. 69778c4a8e55Smrg if func_lalib_unsafe_p "$arg"; then 69788c4a8e55Smrg pic_object= 69798c4a8e55Smrg non_pic_object= 6980b042e37fSmrg 69818c4a8e55Smrg # Read the .lo file 69828c4a8e55Smrg func_source "$arg" 6983b042e37fSmrg 69848c4a8e55Smrg if test -z "$pic_object" || 69858c4a8e55Smrg test -z "$non_pic_object" || 69863169be4bSmrg test none = "$pic_object" && 69873169be4bSmrg test none = "$non_pic_object"; then 69883169be4bSmrg func_fatal_error "cannot find name of object for '$arg'" 69898c4a8e55Smrg fi 6990b042e37fSmrg 69918c4a8e55Smrg # Extract subdirectory from the argument. 69928c4a8e55Smrg func_dirname "$arg" "/" "" 69933169be4bSmrg xdir=$func_dirname_result 6994b042e37fSmrg 69953169be4bSmrg if test none != "$pic_object"; then 69968c4a8e55Smrg # Prepend the subdirectory the object is found in. 69973169be4bSmrg pic_object=$xdir$pic_object 6998b042e37fSmrg 69993169be4bSmrg if test dlfiles = "$prev"; then 70003169be4bSmrg if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 7001bd23fbfaSmrg func_append dlfiles " $pic_object" 70028c4a8e55Smrg prev= 70038c4a8e55Smrg continue 70048c4a8e55Smrg else 70058c4a8e55Smrg # If libtool objects are unsupported, then we need to preload. 70068c4a8e55Smrg prev=dlprefiles 70078c4a8e55Smrg fi 70088c4a8e55Smrg fi 7009b042e37fSmrg 70108c4a8e55Smrg # CHECK ME: I think I busted this. -Ossama 70113169be4bSmrg if test dlprefiles = "$prev"; then 70128c4a8e55Smrg # Preload the old-style object. 7013bd23fbfaSmrg func_append dlprefiles " $pic_object" 70148c4a8e55Smrg prev= 70158c4a8e55Smrg fi 7016b042e37fSmrg 70178c4a8e55Smrg # A PIC object. 70188c4a8e55Smrg func_append libobjs " $pic_object" 70193169be4bSmrg arg=$pic_object 70208c4a8e55Smrg fi 7021b042e37fSmrg 70228c4a8e55Smrg # Non-PIC object. 70233169be4bSmrg if test none != "$non_pic_object"; then 70248c4a8e55Smrg # Prepend the subdirectory the object is found in. 70253169be4bSmrg non_pic_object=$xdir$non_pic_object 7026b042e37fSmrg 70278c4a8e55Smrg # A standard non-PIC object 70288c4a8e55Smrg func_append non_pic_objects " $non_pic_object" 70293169be4bSmrg if test -z "$pic_object" || test none = "$pic_object"; then 70303169be4bSmrg arg=$non_pic_object 70318c4a8e55Smrg fi 70328c4a8e55Smrg else 70338c4a8e55Smrg # If the PIC object exists, use it instead. 70348c4a8e55Smrg # $xdir was prepended to $pic_object above. 70353169be4bSmrg non_pic_object=$pic_object 70368c4a8e55Smrg func_append non_pic_objects " $non_pic_object" 70378c4a8e55Smrg fi 70388c4a8e55Smrg else 70398c4a8e55Smrg # Only an error if not doing a dry-run. 70408c4a8e55Smrg if $opt_dry_run; then 70418c4a8e55Smrg # Extract subdirectory from the argument. 70428c4a8e55Smrg func_dirname "$arg" "/" "" 70433169be4bSmrg xdir=$func_dirname_result 70448c4a8e55Smrg 70458c4a8e55Smrg func_lo2o "$arg" 70468c4a8e55Smrg pic_object=$xdir$objdir/$func_lo2o_result 70478c4a8e55Smrg non_pic_object=$xdir$func_lo2o_result 70488c4a8e55Smrg func_append libobjs " $pic_object" 70498c4a8e55Smrg func_append non_pic_objects " $non_pic_object" 70508c4a8e55Smrg else 70513169be4bSmrg func_fatal_error "'$arg' is not a valid libtool object" 70528c4a8e55Smrg fi 70538c4a8e55Smrg fi 70548c4a8e55Smrg done 70558c4a8e55Smrg else 70563169be4bSmrg func_fatal_error "link input file '$arg' does not exist" 70578c4a8e55Smrg fi 70588c4a8e55Smrg arg=$save_arg 70598c4a8e55Smrg prev= 70608c4a8e55Smrg continue 7061b042e37fSmrg ;; 70623169be4bSmrg os2dllname) 70633169be4bSmrg os2dllname=$arg 70643169be4bSmrg prev= 70653169be4bSmrg continue 70663169be4bSmrg ;; 70678c4a8e55Smrg precious_regex) 70683169be4bSmrg precious_files_regex=$arg 70698c4a8e55Smrg prev= 70708c4a8e55Smrg continue 7071b042e37fSmrg ;; 70728c4a8e55Smrg release) 70733169be4bSmrg release=-$arg 70748c4a8e55Smrg prev= 70758c4a8e55Smrg continue 7076b042e37fSmrg ;; 70778c4a8e55Smrg rpath | xrpath) 70788c4a8e55Smrg # We need an absolute path. 70798c4a8e55Smrg case $arg in 70808c4a8e55Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 7081b042e37fSmrg *) 70828c4a8e55Smrg func_fatal_error "only absolute run-paths are allowed" 7083b042e37fSmrg ;; 7084b042e37fSmrg esac 70853169be4bSmrg if test rpath = "$prev"; then 70868c4a8e55Smrg case "$rpath " in 70878c4a8e55Smrg *" $arg "*) ;; 7088bd23fbfaSmrg *) func_append rpath " $arg" ;; 70898c4a8e55Smrg esac 70908c4a8e55Smrg else 70918c4a8e55Smrg case "$xrpath " in 70928c4a8e55Smrg *" $arg "*) ;; 7093bd23fbfaSmrg *) func_append xrpath " $arg" ;; 70948c4a8e55Smrg esac 70958c4a8e55Smrg fi 70968c4a8e55Smrg prev= 70978c4a8e55Smrg continue 70988c4a8e55Smrg ;; 70998c4a8e55Smrg shrext) 71003169be4bSmrg shrext_cmds=$arg 71018c4a8e55Smrg prev= 71028c4a8e55Smrg continue 71038c4a8e55Smrg ;; 71048c4a8e55Smrg weak) 7105bd23fbfaSmrg func_append weak_libs " $arg" 71068c4a8e55Smrg prev= 71078c4a8e55Smrg continue 71088c4a8e55Smrg ;; 71098d0bc965Smrg xassembler) 71108d0bc965Smrg func_append compiler_flags " -Xassembler $qarg" 71118d0bc965Smrg prev= 71128d0bc965Smrg func_append compile_command " -Xassembler $qarg" 71138d0bc965Smrg func_append finalize_command " -Xassembler $qarg" 71148d0bc965Smrg continue 71158d0bc965Smrg ;; 71168c4a8e55Smrg xcclinker) 7117bd23fbfaSmrg func_append linker_flags " $qarg" 7118bd23fbfaSmrg func_append compiler_flags " $qarg" 71198c4a8e55Smrg prev= 71208c4a8e55Smrg func_append compile_command " $qarg" 71218c4a8e55Smrg func_append finalize_command " $qarg" 71228c4a8e55Smrg continue 71238c4a8e55Smrg ;; 71248c4a8e55Smrg xcompiler) 7125bd23fbfaSmrg func_append compiler_flags " $qarg" 71268c4a8e55Smrg prev= 71278c4a8e55Smrg func_append compile_command " $qarg" 71288c4a8e55Smrg func_append finalize_command " $qarg" 71298c4a8e55Smrg continue 71308c4a8e55Smrg ;; 71318c4a8e55Smrg xlinker) 7132bd23fbfaSmrg func_append linker_flags " $qarg" 7133bd23fbfaSmrg func_append compiler_flags " $wl$qarg" 71348c4a8e55Smrg prev= 71358c4a8e55Smrg func_append compile_command " $wl$qarg" 71368c4a8e55Smrg func_append finalize_command " $wl$qarg" 71378c4a8e55Smrg continue 71388c4a8e55Smrg ;; 71398c4a8e55Smrg *) 71408c4a8e55Smrg eval "$prev=\"\$arg\"" 71418c4a8e55Smrg prev= 71428c4a8e55Smrg continue 71438c4a8e55Smrg ;; 71448c4a8e55Smrg esac 71458c4a8e55Smrg fi # test -n "$prev" 71468c4a8e55Smrg 71473169be4bSmrg prevarg=$arg 71488c4a8e55Smrg 71498c4a8e55Smrg case $arg in 71508c4a8e55Smrg -all-static) 71518c4a8e55Smrg if test -n "$link_static_flag"; then 71528c4a8e55Smrg # See comment for -static flag below, for more details. 71538c4a8e55Smrg func_append compile_command " $link_static_flag" 71548c4a8e55Smrg func_append finalize_command " $link_static_flag" 7155b042e37fSmrg fi 71568c4a8e55Smrg continue 71578c4a8e55Smrg ;; 7158b042e37fSmrg 71598c4a8e55Smrg -allow-undefined) 71608c4a8e55Smrg # FIXME: remove this flag sometime in the future. 71613169be4bSmrg func_fatal_error "'-allow-undefined' must not be used because it is the default" 71628c4a8e55Smrg ;; 7163b042e37fSmrg 71648c4a8e55Smrg -avoid-version) 71658c4a8e55Smrg avoid_version=yes 71668c4a8e55Smrg continue 71678c4a8e55Smrg ;; 7168b042e37fSmrg 7169706b6b52Smrg -bindir) 7170706b6b52Smrg prev=bindir 7171706b6b52Smrg continue 7172706b6b52Smrg ;; 7173706b6b52Smrg 71748c4a8e55Smrg -dlopen) 71758c4a8e55Smrg prev=dlfiles 71768c4a8e55Smrg continue 71778c4a8e55Smrg ;; 71788c4a8e55Smrg 71798c4a8e55Smrg -dlpreopen) 71808c4a8e55Smrg prev=dlprefiles 71818c4a8e55Smrg continue 71828c4a8e55Smrg ;; 71838c4a8e55Smrg 71848c4a8e55Smrg -export-dynamic) 71858c4a8e55Smrg export_dynamic=yes 71868c4a8e55Smrg continue 71878c4a8e55Smrg ;; 71888c4a8e55Smrg 71898c4a8e55Smrg -export-symbols | -export-symbols-regex) 71908c4a8e55Smrg if test -n "$export_symbols" || test -n "$export_symbols_regex"; then 71918c4a8e55Smrg func_fatal_error "more than one -exported-symbols argument is not allowed" 71928c4a8e55Smrg fi 71933169be4bSmrg if test X-export-symbols = "X$arg"; then 71948c4a8e55Smrg prev=expsyms 7195b042e37fSmrg else 71968c4a8e55Smrg prev=expsyms_regex 7197b042e37fSmrg fi 71988c4a8e55Smrg continue 71998c4a8e55Smrg ;; 7200b042e37fSmrg 72018c4a8e55Smrg -framework) 72028c4a8e55Smrg prev=framework 72038c4a8e55Smrg continue 72048c4a8e55Smrg ;; 7205b042e37fSmrg 72068c4a8e55Smrg -inst-prefix-dir) 72078c4a8e55Smrg prev=inst_prefix 72088c4a8e55Smrg continue 72098c4a8e55Smrg ;; 7210b042e37fSmrg 72118c4a8e55Smrg # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* 72128c4a8e55Smrg # so, if we see these flags be careful not to treat them like -L 72138c4a8e55Smrg -L[A-Z][A-Z]*:*) 72148c4a8e55Smrg case $with_gcc/$host in 72158c4a8e55Smrg no/*-*-irix* | /*-*-irix*) 72168c4a8e55Smrg func_append compile_command " $arg" 72178c4a8e55Smrg func_append finalize_command " $arg" 72188c4a8e55Smrg ;; 72198c4a8e55Smrg esac 72208c4a8e55Smrg continue 72218c4a8e55Smrg ;; 7222b042e37fSmrg 72238c4a8e55Smrg -L*) 7224bd23fbfaSmrg func_stripname "-L" '' "$arg" 7225bd23fbfaSmrg if test -z "$func_stripname_result"; then 72268c4a8e55Smrg if test "$#" -gt 0; then 72273169be4bSmrg func_fatal_error "require no space between '-L' and '$1'" 7228b042e37fSmrg else 72293169be4bSmrg func_fatal_error "need path for '-L' option" 7230b042e37fSmrg fi 72318c4a8e55Smrg fi 7232bd23fbfaSmrg func_resolve_sysroot "$func_stripname_result" 7233bd23fbfaSmrg dir=$func_resolve_sysroot_result 72348c4a8e55Smrg # We need an absolute path. 72358c4a8e55Smrg case $dir in 72368c4a8e55Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 72378c4a8e55Smrg *) 72388c4a8e55Smrg absdir=`cd "$dir" && pwd` 72398c4a8e55Smrg test -z "$absdir" && \ 72403169be4bSmrg func_fatal_error "cannot determine absolute directory name of '$dir'" 72413169be4bSmrg dir=$absdir 72428c4a8e55Smrg ;; 7243b042e37fSmrg esac 72448c4a8e55Smrg case "$deplibs " in 7245bd23fbfaSmrg *" -L$dir "* | *" $arg "*) 7246bd23fbfaSmrg # Will only happen for absolute or sysroot arguments 7247bd23fbfaSmrg ;; 72488c4a8e55Smrg *) 7249bd23fbfaSmrg # Preserve sysroot, but never include relative directories 7250bd23fbfaSmrg case $dir in 7251bd23fbfaSmrg [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; 7252bd23fbfaSmrg *) func_append deplibs " -L$dir" ;; 7253bd23fbfaSmrg esac 7254bd23fbfaSmrg func_append lib_search_path " $dir" 72558c4a8e55Smrg ;; 7256b042e37fSmrg esac 7257b042e37fSmrg case $host in 72588c4a8e55Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 7259706b6b52Smrg testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` 72608c4a8e55Smrg case :$dllsearchpath: in 72618c4a8e55Smrg *":$dir:"*) ;; 72628c4a8e55Smrg ::) dllsearchpath=$dir;; 7263bd23fbfaSmrg *) func_append dllsearchpath ":$dir";; 72648c4a8e55Smrg esac 72658c4a8e55Smrg case :$dllsearchpath: in 72668c4a8e55Smrg *":$testbindir:"*) ;; 72678c4a8e55Smrg ::) dllsearchpath=$testbindir;; 7268bd23fbfaSmrg *) func_append dllsearchpath ":$testbindir";; 72698c4a8e55Smrg esac 72708c4a8e55Smrg ;; 7271b042e37fSmrg esac 72728c4a8e55Smrg continue 72738c4a8e55Smrg ;; 7274b042e37fSmrg 72758c4a8e55Smrg -l*) 72763169be4bSmrg if test X-lc = "X$arg" || test X-lm = "X$arg"; then 72778c4a8e55Smrg case $host in 7278706b6b52Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) 72798c4a8e55Smrg # These systems don't actually have a C or math library (as such) 72808c4a8e55Smrg continue 72818c4a8e55Smrg ;; 72828c4a8e55Smrg *-*-os2*) 72838c4a8e55Smrg # These systems don't actually have a C library (as such) 72843169be4bSmrg test X-lc = "X$arg" && continue 72858c4a8e55Smrg ;; 72868d0bc965Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig* | *-*-midnightbsd*) 72878c4a8e55Smrg # Do not include libc due to us having libc/libc_r. 72883169be4bSmrg test X-lc = "X$arg" && continue 72898c4a8e55Smrg ;; 72908c4a8e55Smrg *-*-rhapsody* | *-*-darwin1.[012]) 72918c4a8e55Smrg # Rhapsody C and math libraries are in the System framework 7292bd23fbfaSmrg func_append deplibs " System.ltframework" 72938c4a8e55Smrg continue 72948c4a8e55Smrg ;; 72958c4a8e55Smrg *-*-sco3.2v5* | *-*-sco5v6*) 72968c4a8e55Smrg # Causes problems with __ctype 72973169be4bSmrg test X-lc = "X$arg" && continue 72988c4a8e55Smrg ;; 72998c4a8e55Smrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 73008c4a8e55Smrg # Compiler inserts libc in the correct place for threads to work 73013169be4bSmrg test X-lc = "X$arg" && continue 73028c4a8e55Smrg ;; 73038c4a8e55Smrg esac 73043169be4bSmrg elif test X-lc_r = "X$arg"; then 73058c4a8e55Smrg case $host in 73068d0bc965Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig* | *-*-midnightbsd*) 73078c4a8e55Smrg # Do not include libc_r directly, use -pthread flag. 73088c4a8e55Smrg continue 73098c4a8e55Smrg ;; 73108c4a8e55Smrg esac 73118c4a8e55Smrg fi 7312bd23fbfaSmrg func_append deplibs " $arg" 73138c4a8e55Smrg continue 73148c4a8e55Smrg ;; 7315b042e37fSmrg 73163169be4bSmrg -mllvm) 73173169be4bSmrg prev=mllvm 73183169be4bSmrg continue 73193169be4bSmrg ;; 73203169be4bSmrg 73218c4a8e55Smrg -module) 73228c4a8e55Smrg module=yes 73238c4a8e55Smrg continue 73248c4a8e55Smrg ;; 7325b042e37fSmrg 73268c4a8e55Smrg # Tru64 UNIX uses -model [arg] to determine the layout of C++ 73278c4a8e55Smrg # classes, name mangling, and exception handling. 73288c4a8e55Smrg # Darwin uses the -arch flag to determine output architecture. 7329bd23fbfaSmrg -model|-arch|-isysroot|--sysroot) 7330bd23fbfaSmrg func_append compiler_flags " $arg" 73318c4a8e55Smrg func_append compile_command " $arg" 73328c4a8e55Smrg func_append finalize_command " $arg" 73338c4a8e55Smrg prev=xcompiler 73348c4a8e55Smrg continue 73358c4a8e55Smrg ;; 73368d0bc965Smrg # Solaris ld rejects as of 11.4. Refer to Oracle bug 22985199. 73378d0bc965Smrg -pthread) 73388d0bc965Smrg case $host in 73398d0bc965Smrg *solaris2*) ;; 73408d0bc965Smrg *) 73418d0bc965Smrg case "$new_inherited_linker_flags " in 73428d0bc965Smrg *" $arg "*) ;; 73438d0bc965Smrg * ) func_append new_inherited_linker_flags " $arg" ;; 73448d0bc965Smrg esac 73458d0bc965Smrg ;; 73468d0bc965Smrg esac 73478d0bc965Smrg continue 73488d0bc965Smrg ;; 73498d0bc965Smrg -mt|-mthreads|-kthread|-Kthread|-pthreads|--thread-safe \ 73500597fb56Smrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 7351bd23fbfaSmrg func_append compiler_flags " $arg" 73528c4a8e55Smrg func_append compile_command " $arg" 73538c4a8e55Smrg func_append finalize_command " $arg" 73548c4a8e55Smrg case "$new_inherited_linker_flags " in 73558c4a8e55Smrg *" $arg "*) ;; 7356bd23fbfaSmrg * ) func_append new_inherited_linker_flags " $arg" ;; 73578c4a8e55Smrg esac 73588c4a8e55Smrg continue 73598c4a8e55Smrg ;; 7360b042e37fSmrg 73618c4a8e55Smrg -multi_module) 73623169be4bSmrg single_module=$wl-multi_module 73638c4a8e55Smrg continue 73648c4a8e55Smrg ;; 7365b042e37fSmrg 73668c4a8e55Smrg -no-fast-install) 73678c4a8e55Smrg fast_install=no 73688c4a8e55Smrg continue 73698c4a8e55Smrg ;; 7370b042e37fSmrg 73718c4a8e55Smrg -no-install) 73728c4a8e55Smrg case $host in 73738c4a8e55Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) 73748c4a8e55Smrg # The PATH hackery in wrapper scripts is required on Windows 73758c4a8e55Smrg # and Darwin in order for the loader to find any dlls it needs. 73763169be4bSmrg func_warning "'-no-install' is ignored for $host" 73773169be4bSmrg func_warning "assuming '-no-fast-install' instead" 73788c4a8e55Smrg fast_install=no 73798c4a8e55Smrg ;; 73808c4a8e55Smrg *) no_install=yes ;; 73818c4a8e55Smrg esac 73828c4a8e55Smrg continue 73838c4a8e55Smrg ;; 7384b042e37fSmrg 73858c4a8e55Smrg -no-undefined) 73868c4a8e55Smrg allow_undefined=no 73878c4a8e55Smrg continue 73888c4a8e55Smrg ;; 7389b042e37fSmrg 73908c4a8e55Smrg -objectlist) 73918c4a8e55Smrg prev=objectlist 73928c4a8e55Smrg continue 73938c4a8e55Smrg ;; 7394b042e37fSmrg 73953169be4bSmrg -os2dllname) 73963169be4bSmrg prev=os2dllname 73973169be4bSmrg continue 73983169be4bSmrg ;; 73993169be4bSmrg 74008c4a8e55Smrg -o) prev=output ;; 7401b042e37fSmrg 74028c4a8e55Smrg -precious-files-regex) 74038c4a8e55Smrg prev=precious_regex 74048c4a8e55Smrg continue 74058c4a8e55Smrg ;; 7406b042e37fSmrg 74078c4a8e55Smrg -release) 74088c4a8e55Smrg prev=release 74098c4a8e55Smrg continue 74108c4a8e55Smrg ;; 7411b042e37fSmrg 74128c4a8e55Smrg -rpath) 74138c4a8e55Smrg prev=rpath 74148c4a8e55Smrg continue 74158c4a8e55Smrg ;; 7416b042e37fSmrg 74178c4a8e55Smrg -R) 74188c4a8e55Smrg prev=xrpath 74198c4a8e55Smrg continue 74208c4a8e55Smrg ;; 7421b042e37fSmrg 74228c4a8e55Smrg -R*) 74238c4a8e55Smrg func_stripname '-R' '' "$arg" 74248c4a8e55Smrg dir=$func_stripname_result 74258c4a8e55Smrg # We need an absolute path. 74268c4a8e55Smrg case $dir in 74278c4a8e55Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 7428bd23fbfaSmrg =*) 7429bd23fbfaSmrg func_stripname '=' '' "$dir" 7430bd23fbfaSmrg dir=$lt_sysroot$func_stripname_result 7431bd23fbfaSmrg ;; 74328c4a8e55Smrg *) 74338c4a8e55Smrg func_fatal_error "only absolute run-paths are allowed" 74348c4a8e55Smrg ;; 74358c4a8e55Smrg esac 74368c4a8e55Smrg case "$xrpath " in 74378c4a8e55Smrg *" $dir "*) ;; 7438bd23fbfaSmrg *) func_append xrpath " $dir" ;; 74398c4a8e55Smrg esac 74408c4a8e55Smrg continue 74418c4a8e55Smrg ;; 7442b042e37fSmrg 74438c4a8e55Smrg -shared) 74448c4a8e55Smrg # The effects of -shared are defined in a previous loop. 74458c4a8e55Smrg continue 74468c4a8e55Smrg ;; 7447b042e37fSmrg 74488c4a8e55Smrg -shrext) 74498c4a8e55Smrg prev=shrext 74508c4a8e55Smrg continue 74518c4a8e55Smrg ;; 7452b042e37fSmrg 74538c4a8e55Smrg -static | -static-libtool-libs) 74548c4a8e55Smrg # The effects of -static are defined in a previous loop. 74558c4a8e55Smrg # We used to do the same as -all-static on platforms that 74568c4a8e55Smrg # didn't have a PIC flag, but the assumption that the effects 74578c4a8e55Smrg # would be equivalent was wrong. It would break on at least 74588c4a8e55Smrg # Digital Unix and AIX. 74598c4a8e55Smrg continue 74608c4a8e55Smrg ;; 7461b042e37fSmrg 74628c4a8e55Smrg -thread-safe) 74638c4a8e55Smrg thread_safe=yes 74648c4a8e55Smrg continue 74658c4a8e55Smrg ;; 7466b042e37fSmrg 74678c4a8e55Smrg -version-info) 74688c4a8e55Smrg prev=vinfo 74698c4a8e55Smrg continue 74708c4a8e55Smrg ;; 7471b042e37fSmrg 74728c4a8e55Smrg -version-number) 74738c4a8e55Smrg prev=vinfo 74748c4a8e55Smrg vinfo_number=yes 74758c4a8e55Smrg continue 74768c4a8e55Smrg ;; 7477b042e37fSmrg 74788c4a8e55Smrg -weak) 74798c4a8e55Smrg prev=weak 74808c4a8e55Smrg continue 74818c4a8e55Smrg ;; 7482b042e37fSmrg 74838c4a8e55Smrg -Wc,*) 74848c4a8e55Smrg func_stripname '-Wc,' '' "$arg" 74858c4a8e55Smrg args=$func_stripname_result 74868c4a8e55Smrg arg= 74873169be4bSmrg save_ifs=$IFS; IFS=, 74888c4a8e55Smrg for flag in $args; do 74893169be4bSmrg IFS=$save_ifs 74908d0bc965Smrg func_quote_arg pretty "$flag" 74918d0bc965Smrg func_append arg " $func_quote_arg_result" 74928d0bc965Smrg func_append compiler_flags " $func_quote_arg_result" 74938c4a8e55Smrg done 74943169be4bSmrg IFS=$save_ifs 74958c4a8e55Smrg func_stripname ' ' '' "$arg" 74968c4a8e55Smrg arg=$func_stripname_result 74978c4a8e55Smrg ;; 7498b042e37fSmrg 74998c4a8e55Smrg -Wl,*) 75008c4a8e55Smrg func_stripname '-Wl,' '' "$arg" 75018c4a8e55Smrg args=$func_stripname_result 75028c4a8e55Smrg arg= 75033169be4bSmrg save_ifs=$IFS; IFS=, 75048c4a8e55Smrg for flag in $args; do 75053169be4bSmrg IFS=$save_ifs 75068d0bc965Smrg func_quote_arg pretty "$flag" 75078d0bc965Smrg func_append arg " $wl$func_quote_arg_result" 75088d0bc965Smrg func_append compiler_flags " $wl$func_quote_arg_result" 75098d0bc965Smrg func_append linker_flags " $func_quote_arg_result" 75108c4a8e55Smrg done 75113169be4bSmrg IFS=$save_ifs 75128c4a8e55Smrg func_stripname ' ' '' "$arg" 75138c4a8e55Smrg arg=$func_stripname_result 75148c4a8e55Smrg ;; 7515b042e37fSmrg 75168d0bc965Smrg -Xassembler) 75178d0bc965Smrg prev=xassembler 75188d0bc965Smrg continue 75198d0bc965Smrg ;; 75208d0bc965Smrg 75218c4a8e55Smrg -Xcompiler) 75228c4a8e55Smrg prev=xcompiler 75238c4a8e55Smrg continue 75248c4a8e55Smrg ;; 7525b042e37fSmrg 75268c4a8e55Smrg -Xlinker) 75278c4a8e55Smrg prev=xlinker 75288c4a8e55Smrg continue 75298c4a8e55Smrg ;; 7530b042e37fSmrg 75318c4a8e55Smrg -XCClinker) 75328c4a8e55Smrg prev=xcclinker 75338c4a8e55Smrg continue 75348c4a8e55Smrg ;; 7535b042e37fSmrg 75368c4a8e55Smrg # -msg_* for osf cc 75378c4a8e55Smrg -msg_*) 75388d0bc965Smrg func_quote_arg pretty "$arg" 75398d0bc965Smrg arg=$func_quote_arg_result 75408c4a8e55Smrg ;; 7541b042e37fSmrg 7542706b6b52Smrg # Flags to be passed through unchanged, with rationale: 7543706b6b52Smrg # -64, -mips[0-9] enable 64-bit mode for the SGI compiler 7544706b6b52Smrg # -r[0-9][0-9]* specify processor for the SGI compiler 7545706b6b52Smrg # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler 7546706b6b52Smrg # +DA*, +DD* enable 64-bit mode for the HP compiler 7547706b6b52Smrg # -q* compiler args for the IBM compiler 7548706b6b52Smrg # -m*, -t[45]*, -txscale* architecture-specific flags for GCC 7549706b6b52Smrg # -F/path path to uninstalled frameworks, gcc on darwin 7550706b6b52Smrg # -p, -pg, --coverage, -fprofile-* profiling flags for GCC 75513169be4bSmrg # -fstack-protector* stack protector flags for GCC 7552706b6b52Smrg # @file GCC response files 7553706b6b52Smrg # -tp=* Portland pgcc target processor selection 7554bd23fbfaSmrg # --sysroot=* for sysroot support 75553169be4bSmrg # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization 75568d0bc965Smrg # -specs=* GCC specs files 75573169be4bSmrg # -stdlib=* select c++ std lib with clang 75588d0bc965Smrg # -fsanitize=* Clang/GCC memory and address sanitizer 75598d0bc965Smrg # -fuse-ld=* Linker select flags for GCC 75608d0bc965Smrg # -Wa,* Pass flags directly to the assembler 75618c4a8e55Smrg -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ 7562bd23fbfaSmrg -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ 75638d0bc965Smrg -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*| \ 75648d0bc965Smrg -specs=*|-fsanitize=*|-fuse-ld=*|-Wa,*) 75658d0bc965Smrg func_quote_arg pretty "$arg" 75668d0bc965Smrg arg=$func_quote_arg_result 75678c4a8e55Smrg func_append compile_command " $arg" 75688c4a8e55Smrg func_append finalize_command " $arg" 7569bd23fbfaSmrg func_append compiler_flags " $arg" 75708c4a8e55Smrg continue 75718c4a8e55Smrg ;; 7572b042e37fSmrg 75733169be4bSmrg -Z*) 75743169be4bSmrg if test os2 = "`expr $host : '.*\(os2\)'`"; then 75753169be4bSmrg # OS/2 uses -Zxxx to specify OS/2-specific options 75763169be4bSmrg compiler_flags="$compiler_flags $arg" 75773169be4bSmrg func_append compile_command " $arg" 75783169be4bSmrg func_append finalize_command " $arg" 75793169be4bSmrg case $arg in 75803169be4bSmrg -Zlinker | -Zstack) 75813169be4bSmrg prev=xcompiler 75823169be4bSmrg ;; 75833169be4bSmrg esac 75843169be4bSmrg continue 75853169be4bSmrg else 75863169be4bSmrg # Otherwise treat like 'Some other compiler flag' below 75878d0bc965Smrg func_quote_arg pretty "$arg" 75888d0bc965Smrg arg=$func_quote_arg_result 75893169be4bSmrg fi 75903169be4bSmrg ;; 75913169be4bSmrg 75928c4a8e55Smrg # Some other compiler flag. 75938c4a8e55Smrg -* | +*) 75948d0bc965Smrg func_quote_arg pretty "$arg" 75958d0bc965Smrg arg=$func_quote_arg_result 75968c4a8e55Smrg ;; 7597b042e37fSmrg 75988c4a8e55Smrg *.$objext) 75998c4a8e55Smrg # A standard object. 7600bd23fbfaSmrg func_append objs " $arg" 76018c4a8e55Smrg ;; 7602b042e37fSmrg 76038c4a8e55Smrg *.lo) 76048c4a8e55Smrg # A libtool-controlled object. 7605b042e37fSmrg 76068c4a8e55Smrg # Check to see that this really is a libtool object. 76078c4a8e55Smrg if func_lalib_unsafe_p "$arg"; then 76088c4a8e55Smrg pic_object= 76098c4a8e55Smrg non_pic_object= 7610b042e37fSmrg 76118c4a8e55Smrg # Read the .lo file 76128c4a8e55Smrg func_source "$arg" 7613b042e37fSmrg 76148c4a8e55Smrg if test -z "$pic_object" || 76158c4a8e55Smrg test -z "$non_pic_object" || 76163169be4bSmrg test none = "$pic_object" && 76173169be4bSmrg test none = "$non_pic_object"; then 76183169be4bSmrg func_fatal_error "cannot find name of object for '$arg'" 76198c4a8e55Smrg fi 7620b042e37fSmrg 76218c4a8e55Smrg # Extract subdirectory from the argument. 76228c4a8e55Smrg func_dirname "$arg" "/" "" 76233169be4bSmrg xdir=$func_dirname_result 7624b042e37fSmrg 76253169be4bSmrg test none = "$pic_object" || { 76268c4a8e55Smrg # Prepend the subdirectory the object is found in. 76273169be4bSmrg pic_object=$xdir$pic_object 7628b042e37fSmrg 76293169be4bSmrg if test dlfiles = "$prev"; then 76303169be4bSmrg if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 7631bd23fbfaSmrg func_append dlfiles " $pic_object" 76328c4a8e55Smrg prev= 76338c4a8e55Smrg continue 76348c4a8e55Smrg else 76358c4a8e55Smrg # If libtool objects are unsupported, then we need to preload. 76368c4a8e55Smrg prev=dlprefiles 76378c4a8e55Smrg fi 76388c4a8e55Smrg fi 7639b042e37fSmrg 76408c4a8e55Smrg # CHECK ME: I think I busted this. -Ossama 76413169be4bSmrg if test dlprefiles = "$prev"; then 76428c4a8e55Smrg # Preload the old-style object. 7643bd23fbfaSmrg func_append dlprefiles " $pic_object" 76448c4a8e55Smrg prev= 76458c4a8e55Smrg fi 7646b042e37fSmrg 76478c4a8e55Smrg # A PIC object. 76488c4a8e55Smrg func_append libobjs " $pic_object" 76493169be4bSmrg arg=$pic_object 76503169be4bSmrg } 7651b042e37fSmrg 76528c4a8e55Smrg # Non-PIC object. 76533169be4bSmrg if test none != "$non_pic_object"; then 76548c4a8e55Smrg # Prepend the subdirectory the object is found in. 76553169be4bSmrg non_pic_object=$xdir$non_pic_object 7656b042e37fSmrg 76578c4a8e55Smrg # A standard non-PIC object 76588c4a8e55Smrg func_append non_pic_objects " $non_pic_object" 76593169be4bSmrg if test -z "$pic_object" || test none = "$pic_object"; then 76603169be4bSmrg arg=$non_pic_object 76618c4a8e55Smrg fi 76628c4a8e55Smrg else 76638c4a8e55Smrg # If the PIC object exists, use it instead. 76648c4a8e55Smrg # $xdir was prepended to $pic_object above. 76653169be4bSmrg non_pic_object=$pic_object 76668c4a8e55Smrg func_append non_pic_objects " $non_pic_object" 76678c4a8e55Smrg fi 76688c4a8e55Smrg else 76698c4a8e55Smrg # Only an error if not doing a dry-run. 76708c4a8e55Smrg if $opt_dry_run; then 76718c4a8e55Smrg # Extract subdirectory from the argument. 76728c4a8e55Smrg func_dirname "$arg" "/" "" 76733169be4bSmrg xdir=$func_dirname_result 76748c4a8e55Smrg 76758c4a8e55Smrg func_lo2o "$arg" 76768c4a8e55Smrg pic_object=$xdir$objdir/$func_lo2o_result 76778c4a8e55Smrg non_pic_object=$xdir$func_lo2o_result 76788c4a8e55Smrg func_append libobjs " $pic_object" 76798c4a8e55Smrg func_append non_pic_objects " $non_pic_object" 76808c4a8e55Smrg else 76813169be4bSmrg func_fatal_error "'$arg' is not a valid libtool object" 76828c4a8e55Smrg fi 76838c4a8e55Smrg fi 76848c4a8e55Smrg ;; 7685b042e37fSmrg 76868c4a8e55Smrg *.$libext) 76878c4a8e55Smrg # An archive. 7688bd23fbfaSmrg func_append deplibs " $arg" 7689bd23fbfaSmrg func_append old_deplibs " $arg" 76908c4a8e55Smrg continue 76918c4a8e55Smrg ;; 7692b042e37fSmrg 76938c4a8e55Smrg *.la) 76948c4a8e55Smrg # A libtool-controlled library. 7695b042e37fSmrg 7696bd23fbfaSmrg func_resolve_sysroot "$arg" 76973169be4bSmrg if test dlfiles = "$prev"; then 76988c4a8e55Smrg # This library was specified with -dlopen. 7699bd23fbfaSmrg func_append dlfiles " $func_resolve_sysroot_result" 77008c4a8e55Smrg prev= 77013169be4bSmrg elif test dlprefiles = "$prev"; then 77028c4a8e55Smrg # The library was specified with -dlpreopen. 7703bd23fbfaSmrg func_append dlprefiles " $func_resolve_sysroot_result" 77048c4a8e55Smrg prev= 77058c4a8e55Smrg else 7706bd23fbfaSmrg func_append deplibs " $func_resolve_sysroot_result" 77078c4a8e55Smrg fi 77088c4a8e55Smrg continue 77098c4a8e55Smrg ;; 7710b042e37fSmrg 77118c4a8e55Smrg # Some other compiler argument. 77128c4a8e55Smrg *) 77138c4a8e55Smrg # Unknown arguments in both finalize_command and compile_command need 77148c4a8e55Smrg # to be aesthetically quoted because they are evaled later. 77158d0bc965Smrg func_quote_arg pretty "$arg" 77168d0bc965Smrg arg=$func_quote_arg_result 77178c4a8e55Smrg ;; 77188c4a8e55Smrg esac # arg 7719b042e37fSmrg 77208c4a8e55Smrg # Now actually substitute the argument into the commands. 77218c4a8e55Smrg if test -n "$arg"; then 77228c4a8e55Smrg func_append compile_command " $arg" 77238c4a8e55Smrg func_append finalize_command " $arg" 77248c4a8e55Smrg fi 77258c4a8e55Smrg done # argument parsing loop 7726b042e37fSmrg 77278c4a8e55Smrg test -n "$prev" && \ 77283169be4bSmrg func_fatal_help "the '$prevarg' option requires an argument" 7729b042e37fSmrg 77303169be4bSmrg if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then 77318c4a8e55Smrg eval arg=\"$export_dynamic_flag_spec\" 77328c4a8e55Smrg func_append compile_command " $arg" 77338c4a8e55Smrg func_append finalize_command " $arg" 77348c4a8e55Smrg fi 7735b042e37fSmrg 77368c4a8e55Smrg oldlibs= 77378c4a8e55Smrg # calculate the name of the file, without its directory 77388c4a8e55Smrg func_basename "$output" 77393169be4bSmrg outputname=$func_basename_result 77403169be4bSmrg libobjs_save=$libobjs 77418c4a8e55Smrg 77428c4a8e55Smrg if test -n "$shlibpath_var"; then 77438c4a8e55Smrg # get the directories listed in $shlibpath_var 77443169be4bSmrg eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\` 7745b042e37fSmrg else 77468c4a8e55Smrg shlib_search_path= 7747b042e37fSmrg fi 77488c4a8e55Smrg eval sys_lib_search_path=\"$sys_lib_search_path_spec\" 77498c4a8e55Smrg eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" 7750b042e37fSmrg 77513169be4bSmrg # Definition is injected by LT_CONFIG during libtool generation. 77523169be4bSmrg func_munge_path_list sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH" 77533169be4bSmrg 77548c4a8e55Smrg func_dirname "$output" "/" "" 77553169be4bSmrg output_objdir=$func_dirname_result$objdir 7756bd23fbfaSmrg func_to_tool_file "$output_objdir/" 7757bd23fbfaSmrg tool_output_objdir=$func_to_tool_file_result 77588c4a8e55Smrg # Create the object directory. 77598c4a8e55Smrg func_mkdir_p "$output_objdir" 7760b042e37fSmrg 77618c4a8e55Smrg # Determine the type of output 77628c4a8e55Smrg case $output in 77638c4a8e55Smrg "") 77648c4a8e55Smrg func_fatal_help "you must specify an output file" 77658c4a8e55Smrg ;; 77668c4a8e55Smrg *.$libext) linkmode=oldlib ;; 77678c4a8e55Smrg *.lo | *.$objext) linkmode=obj ;; 77688c4a8e55Smrg *.la) linkmode=lib ;; 77698c4a8e55Smrg *) linkmode=prog ;; # Anything else should be a program. 77708c4a8e55Smrg esac 77718c4a8e55Smrg 77728c4a8e55Smrg specialdeplibs= 77738c4a8e55Smrg 77748c4a8e55Smrg libs= 77758c4a8e55Smrg # Find all interdependent deplibs by searching for libraries 77768c4a8e55Smrg # that are linked more than once (e.g. -la -lb -la) 77778c4a8e55Smrg for deplib in $deplibs; do 77783169be4bSmrg if $opt_preserve_dup_deps; then 77798c4a8e55Smrg case "$libs " in 7780bd23fbfaSmrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 77818c4a8e55Smrg esac 77828c4a8e55Smrg fi 7783bd23fbfaSmrg func_append libs " $deplib" 77848c4a8e55Smrg done 77858c4a8e55Smrg 77863169be4bSmrg if test lib = "$linkmode"; then 77878c4a8e55Smrg libs="$predeps $libs $compiler_lib_search_path $postdeps" 77888c4a8e55Smrg 77898c4a8e55Smrg # Compute libraries that are listed more than once in $predeps 77908c4a8e55Smrg # $postdeps and mark them as special (i.e., whose duplicates are 77918c4a8e55Smrg # not to be eliminated). 77928c4a8e55Smrg pre_post_deps= 77938c4a8e55Smrg if $opt_duplicate_compiler_generated_deps; then 77948c4a8e55Smrg for pre_post_dep in $predeps $postdeps; do 77958c4a8e55Smrg case "$pre_post_deps " in 7796bd23fbfaSmrg *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; 77978c4a8e55Smrg esac 7798bd23fbfaSmrg func_append pre_post_deps " $pre_post_dep" 77998c4a8e55Smrg done 78008c4a8e55Smrg fi 78018c4a8e55Smrg pre_post_deps= 78028c4a8e55Smrg fi 78038c4a8e55Smrg 78048c4a8e55Smrg deplibs= 78058c4a8e55Smrg newdependency_libs= 78068c4a8e55Smrg newlib_search_path= 78078c4a8e55Smrg need_relink=no # whether we're linking any uninstalled libtool libraries 78088c4a8e55Smrg notinst_deplibs= # not-installed libtool libraries 78098c4a8e55Smrg notinst_path= # paths that contain not-installed libtool libraries 78108c4a8e55Smrg 78118c4a8e55Smrg case $linkmode in 78128c4a8e55Smrg lib) 78138c4a8e55Smrg passes="conv dlpreopen link" 78148c4a8e55Smrg for file in $dlfiles $dlprefiles; do 78158c4a8e55Smrg case $file in 78168c4a8e55Smrg *.la) ;; 78178c4a8e55Smrg *) 78183169be4bSmrg func_fatal_help "libraries can '-dlopen' only libtool libraries: $file" 78198c4a8e55Smrg ;; 78208c4a8e55Smrg esac 78218c4a8e55Smrg done 78228c4a8e55Smrg ;; 78238c4a8e55Smrg prog) 78248c4a8e55Smrg compile_deplibs= 78258c4a8e55Smrg finalize_deplibs= 78263169be4bSmrg alldeplibs=false 78278c4a8e55Smrg newdlfiles= 78288c4a8e55Smrg newdlprefiles= 78298c4a8e55Smrg passes="conv scan dlopen dlpreopen link" 78308c4a8e55Smrg ;; 78318c4a8e55Smrg *) passes="conv" 78328c4a8e55Smrg ;; 78338c4a8e55Smrg esac 78348c4a8e55Smrg 78358c4a8e55Smrg for pass in $passes; do 78368c4a8e55Smrg # The preopen pass in lib mode reverses $deplibs; put it back here 78378c4a8e55Smrg # so that -L comes before libs that need it for instance... 78383169be4bSmrg if test lib,link = "$linkmode,$pass"; then 78398c4a8e55Smrg ## FIXME: Find the place where the list is rebuilt in the wrong 78408c4a8e55Smrg ## order, and fix it there properly 78418c4a8e55Smrg tmp_deplibs= 78428c4a8e55Smrg for deplib in $deplibs; do 78438c4a8e55Smrg tmp_deplibs="$deplib $tmp_deplibs" 78448c4a8e55Smrg done 78453169be4bSmrg deplibs=$tmp_deplibs 78468c4a8e55Smrg fi 78478c4a8e55Smrg 78483169be4bSmrg if test lib,link = "$linkmode,$pass" || 78493169be4bSmrg test prog,scan = "$linkmode,$pass"; then 78503169be4bSmrg libs=$deplibs 78518c4a8e55Smrg deplibs= 78528c4a8e55Smrg fi 78533169be4bSmrg if test prog = "$linkmode"; then 78548c4a8e55Smrg case $pass in 78553169be4bSmrg dlopen) libs=$dlfiles ;; 78563169be4bSmrg dlpreopen) libs=$dlprefiles ;; 78573169be4bSmrg link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; 78588c4a8e55Smrg esac 78598c4a8e55Smrg fi 78603169be4bSmrg if test lib,dlpreopen = "$linkmode,$pass"; then 78618c4a8e55Smrg # Collect and forward deplibs of preopened libtool libs 78628c4a8e55Smrg for lib in $dlprefiles; do 78638c4a8e55Smrg # Ignore non-libtool-libs 78648c4a8e55Smrg dependency_libs= 7865bd23fbfaSmrg func_resolve_sysroot "$lib" 78668c4a8e55Smrg case $lib in 7867bd23fbfaSmrg *.la) func_source "$func_resolve_sysroot_result" ;; 78688c4a8e55Smrg esac 78698c4a8e55Smrg 78708c4a8e55Smrg # Collect preopened libtool deplibs, except any this library 78718c4a8e55Smrg # has declared as weak libs 78728c4a8e55Smrg for deplib in $dependency_libs; do 7873706b6b52Smrg func_basename "$deplib" 7874706b6b52Smrg deplib_base=$func_basename_result 78758c4a8e55Smrg case " $weak_libs " in 78768c4a8e55Smrg *" $deplib_base "*) ;; 7877bd23fbfaSmrg *) func_append deplibs " $deplib" ;; 78788c4a8e55Smrg esac 78798c4a8e55Smrg done 78808c4a8e55Smrg done 78813169be4bSmrg libs=$dlprefiles 78828c4a8e55Smrg fi 78833169be4bSmrg if test dlopen = "$pass"; then 78848c4a8e55Smrg # Collect dlpreopened libraries 78853169be4bSmrg save_deplibs=$deplibs 78868c4a8e55Smrg deplibs= 78878c4a8e55Smrg fi 78888c4a8e55Smrg 78898c4a8e55Smrg for deplib in $libs; do 78908c4a8e55Smrg lib= 78913169be4bSmrg found=false 78928c4a8e55Smrg case $deplib in 78930597fb56Smrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 78940597fb56Smrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 78953169be4bSmrg if test prog,link = "$linkmode,$pass"; then 78968c4a8e55Smrg compile_deplibs="$deplib $compile_deplibs" 78978c4a8e55Smrg finalize_deplibs="$deplib $finalize_deplibs" 78988c4a8e55Smrg else 7899bd23fbfaSmrg func_append compiler_flags " $deplib" 79003169be4bSmrg if test lib = "$linkmode"; then 79018c4a8e55Smrg case "$new_inherited_linker_flags " in 79028c4a8e55Smrg *" $deplib "*) ;; 7903bd23fbfaSmrg * ) func_append new_inherited_linker_flags " $deplib" ;; 79048c4a8e55Smrg esac 79058c4a8e55Smrg fi 79068c4a8e55Smrg fi 79078c4a8e55Smrg continue 79088c4a8e55Smrg ;; 79098c4a8e55Smrg -l*) 79103169be4bSmrg if test lib != "$linkmode" && test prog != "$linkmode"; then 79113169be4bSmrg func_warning "'-l' is ignored for archives/objects" 79128c4a8e55Smrg continue 79138c4a8e55Smrg fi 79148c4a8e55Smrg func_stripname '-l' '' "$deplib" 79158c4a8e55Smrg name=$func_stripname_result 79163169be4bSmrg if test lib = "$linkmode"; then 79178c4a8e55Smrg searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" 79188c4a8e55Smrg else 79198c4a8e55Smrg searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" 79208c4a8e55Smrg fi 79218c4a8e55Smrg for searchdir in $searchdirs; do 79228c4a8e55Smrg for search_ext in .la $std_shrext .so .a; do 79238c4a8e55Smrg # Search the libtool library 79243169be4bSmrg lib=$searchdir/lib$name$search_ext 79258c4a8e55Smrg if test -f "$lib"; then 79263169be4bSmrg if test .la = "$search_ext"; then 79273169be4bSmrg found=: 79288c4a8e55Smrg else 79293169be4bSmrg found=false 79308c4a8e55Smrg fi 79318c4a8e55Smrg break 2 79328c4a8e55Smrg fi 79338c4a8e55Smrg done 79348c4a8e55Smrg done 79353169be4bSmrg if $found; then 79363169be4bSmrg # deplib is a libtool library 79378c4a8e55Smrg # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, 79388c4a8e55Smrg # We need to do some special things here, and not later. 79393169be4bSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 79408c4a8e55Smrg case " $predeps $postdeps " in 79418c4a8e55Smrg *" $deplib "*) 79428c4a8e55Smrg if func_lalib_p "$lib"; then 79438c4a8e55Smrg library_names= 79448c4a8e55Smrg old_library= 79458c4a8e55Smrg func_source "$lib" 79468c4a8e55Smrg for l in $old_library $library_names; do 79473169be4bSmrg ll=$l 79488c4a8e55Smrg done 79493169be4bSmrg if test "X$ll" = "X$old_library"; then # only static version available 79503169be4bSmrg found=false 79518c4a8e55Smrg func_dirname "$lib" "" "." 79523169be4bSmrg ladir=$func_dirname_result 79538c4a8e55Smrg lib=$ladir/$old_library 79543169be4bSmrg if test prog,link = "$linkmode,$pass"; then 79558c4a8e55Smrg compile_deplibs="$deplib $compile_deplibs" 79568c4a8e55Smrg finalize_deplibs="$deplib $finalize_deplibs" 79578c4a8e55Smrg else 79588c4a8e55Smrg deplibs="$deplib $deplibs" 79593169be4bSmrg test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 79608c4a8e55Smrg fi 79618c4a8e55Smrg continue 79628c4a8e55Smrg fi 79638c4a8e55Smrg fi 79648c4a8e55Smrg ;; 79658c4a8e55Smrg *) ;; 79668c4a8e55Smrg esac 79678c4a8e55Smrg fi 79683169be4bSmrg else 79693169be4bSmrg # deplib doesn't seem to be a libtool library 79703169be4bSmrg if test prog,link = "$linkmode,$pass"; then 79713169be4bSmrg compile_deplibs="$deplib $compile_deplibs" 79723169be4bSmrg finalize_deplibs="$deplib $finalize_deplibs" 79733169be4bSmrg else 79743169be4bSmrg deplibs="$deplib $deplibs" 79753169be4bSmrg test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 79763169be4bSmrg fi 79773169be4bSmrg continue 79788c4a8e55Smrg fi 79798c4a8e55Smrg ;; # -l 79808c4a8e55Smrg *.ltframework) 79813169be4bSmrg if test prog,link = "$linkmode,$pass"; then 79828c4a8e55Smrg compile_deplibs="$deplib $compile_deplibs" 79838c4a8e55Smrg finalize_deplibs="$deplib $finalize_deplibs" 79848c4a8e55Smrg else 79858c4a8e55Smrg deplibs="$deplib $deplibs" 79863169be4bSmrg if test lib = "$linkmode"; then 79878c4a8e55Smrg case "$new_inherited_linker_flags " in 79888c4a8e55Smrg *" $deplib "*) ;; 7989bd23fbfaSmrg * ) func_append new_inherited_linker_flags " $deplib" ;; 79908c4a8e55Smrg esac 79918c4a8e55Smrg fi 79928c4a8e55Smrg fi 79938c4a8e55Smrg continue 79948c4a8e55Smrg ;; 79958c4a8e55Smrg -L*) 79968c4a8e55Smrg case $linkmode in 79978c4a8e55Smrg lib) 79988c4a8e55Smrg deplibs="$deplib $deplibs" 79993169be4bSmrg test conv = "$pass" && continue 80008c4a8e55Smrg newdependency_libs="$deplib $newdependency_libs" 80018c4a8e55Smrg func_stripname '-L' '' "$deplib" 8002bd23fbfaSmrg func_resolve_sysroot "$func_stripname_result" 8003bd23fbfaSmrg func_append newlib_search_path " $func_resolve_sysroot_result" 80048c4a8e55Smrg ;; 80058c4a8e55Smrg prog) 80063169be4bSmrg if test conv = "$pass"; then 80078c4a8e55Smrg deplibs="$deplib $deplibs" 80088c4a8e55Smrg continue 80098c4a8e55Smrg fi 80103169be4bSmrg if test scan = "$pass"; then 80118c4a8e55Smrg deplibs="$deplib $deplibs" 80128c4a8e55Smrg else 80138c4a8e55Smrg compile_deplibs="$deplib $compile_deplibs" 80148c4a8e55Smrg finalize_deplibs="$deplib $finalize_deplibs" 80158c4a8e55Smrg fi 80168c4a8e55Smrg func_stripname '-L' '' "$deplib" 8017bd23fbfaSmrg func_resolve_sysroot "$func_stripname_result" 8018bd23fbfaSmrg func_append newlib_search_path " $func_resolve_sysroot_result" 80198c4a8e55Smrg ;; 80208c4a8e55Smrg *) 80213169be4bSmrg func_warning "'-L' is ignored for archives/objects" 80228c4a8e55Smrg ;; 80238c4a8e55Smrg esac # linkmode 80248c4a8e55Smrg continue 80258c4a8e55Smrg ;; # -L 80268c4a8e55Smrg -R*) 80273169be4bSmrg if test link = "$pass"; then 80288c4a8e55Smrg func_stripname '-R' '' "$deplib" 8029bd23fbfaSmrg func_resolve_sysroot "$func_stripname_result" 8030bd23fbfaSmrg dir=$func_resolve_sysroot_result 80318c4a8e55Smrg # Make sure the xrpath contains only unique directories. 80328c4a8e55Smrg case "$xrpath " in 80338c4a8e55Smrg *" $dir "*) ;; 8034bd23fbfaSmrg *) func_append xrpath " $dir" ;; 80358c4a8e55Smrg esac 80368c4a8e55Smrg fi 80378c4a8e55Smrg deplibs="$deplib $deplibs" 80388c4a8e55Smrg continue 80398c4a8e55Smrg ;; 8040bd23fbfaSmrg *.la) 8041bd23fbfaSmrg func_resolve_sysroot "$deplib" 8042bd23fbfaSmrg lib=$func_resolve_sysroot_result 8043bd23fbfaSmrg ;; 80448c4a8e55Smrg *.$libext) 80453169be4bSmrg if test conv = "$pass"; then 80468c4a8e55Smrg deplibs="$deplib $deplibs" 80478c4a8e55Smrg continue 80488c4a8e55Smrg fi 80498c4a8e55Smrg case $linkmode in 80508c4a8e55Smrg lib) 80518c4a8e55Smrg # Linking convenience modules into shared libraries is allowed, 80528c4a8e55Smrg # but linking other static libraries is non-portable. 80538c4a8e55Smrg case " $dlpreconveniencelibs " in 80548c4a8e55Smrg *" $deplib "*) ;; 80558c4a8e55Smrg *) 80563169be4bSmrg valid_a_lib=false 80578c4a8e55Smrg case $deplibs_check_method in 80588c4a8e55Smrg match_pattern*) 80598c4a8e55Smrg set dummy $deplibs_check_method; shift 80608c4a8e55Smrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 8061706b6b52Smrg if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ 80628c4a8e55Smrg | $EGREP "$match_pattern_regex" > /dev/null; then 80633169be4bSmrg valid_a_lib=: 80648c4a8e55Smrg fi 80658c4a8e55Smrg ;; 80668c4a8e55Smrg pass_all) 80673169be4bSmrg valid_a_lib=: 80688c4a8e55Smrg ;; 80698c4a8e55Smrg esac 80703169be4bSmrg if $valid_a_lib; then 80713169be4bSmrg echo 80723169be4bSmrg $ECHO "*** Warning: Linking the shared library $output against the" 80733169be4bSmrg $ECHO "*** static library $deplib is not portable!" 80743169be4bSmrg deplibs="$deplib $deplibs" 80753169be4bSmrg else 8076706b6b52Smrg echo 80778c4a8e55Smrg $ECHO "*** Warning: Trying to link with static lib archive $deplib." 8078706b6b52Smrg echo "*** I have the capability to make that library automatically link in when" 8079706b6b52Smrg echo "*** you link to this library. But I can only do this if you have a" 8080706b6b52Smrg echo "*** shared version of the library, which you do not appear to have" 8081706b6b52Smrg echo "*** because the file extensions .$libext of this argument makes me believe" 8082706b6b52Smrg echo "*** that it is just a static archive that I should not use here." 80838c4a8e55Smrg fi 80848c4a8e55Smrg ;; 80858c4a8e55Smrg esac 80868c4a8e55Smrg continue 80878c4a8e55Smrg ;; 80888c4a8e55Smrg prog) 80893169be4bSmrg if test link != "$pass"; then 80908c4a8e55Smrg deplibs="$deplib $deplibs" 80918c4a8e55Smrg else 80928c4a8e55Smrg compile_deplibs="$deplib $compile_deplibs" 80938c4a8e55Smrg finalize_deplibs="$deplib $finalize_deplibs" 80948c4a8e55Smrg fi 80958c4a8e55Smrg continue 80968c4a8e55Smrg ;; 80978c4a8e55Smrg esac # linkmode 80988c4a8e55Smrg ;; # *.$libext 80998c4a8e55Smrg *.lo | *.$objext) 81003169be4bSmrg if test conv = "$pass"; then 81018c4a8e55Smrg deplibs="$deplib $deplibs" 81023169be4bSmrg elif test prog = "$linkmode"; then 81033169be4bSmrg if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then 81048c4a8e55Smrg # If there is no dlopen support or we're linking statically, 81058c4a8e55Smrg # we need to preload. 8106bd23fbfaSmrg func_append newdlprefiles " $deplib" 81078c4a8e55Smrg compile_deplibs="$deplib $compile_deplibs" 81088c4a8e55Smrg finalize_deplibs="$deplib $finalize_deplibs" 81098c4a8e55Smrg else 8110bd23fbfaSmrg func_append newdlfiles " $deplib" 81118c4a8e55Smrg fi 81128c4a8e55Smrg fi 81138c4a8e55Smrg continue 81148c4a8e55Smrg ;; 81158c4a8e55Smrg %DEPLIBS%) 81163169be4bSmrg alldeplibs=: 81178c4a8e55Smrg continue 81188c4a8e55Smrg ;; 81198c4a8e55Smrg esac # case $deplib 81208c4a8e55Smrg 81213169be4bSmrg $found || test -f "$lib" \ 81223169be4bSmrg || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'" 81238c4a8e55Smrg 81248c4a8e55Smrg # Check to see that this really is a libtool archive. 81258c4a8e55Smrg func_lalib_unsafe_p "$lib" \ 81263169be4bSmrg || func_fatal_error "'$lib' is not a valid libtool archive" 81278c4a8e55Smrg 81288c4a8e55Smrg func_dirname "$lib" "" "." 81293169be4bSmrg ladir=$func_dirname_result 81308c4a8e55Smrg 81318c4a8e55Smrg dlname= 81328c4a8e55Smrg dlopen= 81338c4a8e55Smrg dlpreopen= 81348c4a8e55Smrg libdir= 81358c4a8e55Smrg library_names= 81368c4a8e55Smrg old_library= 81378c4a8e55Smrg inherited_linker_flags= 81388c4a8e55Smrg # If the library was installed with an old release of libtool, 81398c4a8e55Smrg # it will not redefine variables installed, or shouldnotlink 81408c4a8e55Smrg installed=yes 81418c4a8e55Smrg shouldnotlink=no 81428c4a8e55Smrg avoidtemprpath= 81438c4a8e55Smrg 81448c4a8e55Smrg 81458c4a8e55Smrg # Read the .la file 81468c4a8e55Smrg func_source "$lib" 81478c4a8e55Smrg 81488c4a8e55Smrg # Convert "-framework foo" to "foo.ltframework" 81498c4a8e55Smrg if test -n "$inherited_linker_flags"; then 8150706b6b52Smrg tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` 81518c4a8e55Smrg for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do 81528c4a8e55Smrg case " $new_inherited_linker_flags " in 81538c4a8e55Smrg *" $tmp_inherited_linker_flag "*) ;; 8154bd23fbfaSmrg *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; 81558c4a8e55Smrg esac 81568c4a8e55Smrg done 81578c4a8e55Smrg fi 8158706b6b52Smrg dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 81593169be4bSmrg if test lib,link = "$linkmode,$pass" || 81603169be4bSmrg test prog,scan = "$linkmode,$pass" || 81613169be4bSmrg { test prog != "$linkmode" && test lib != "$linkmode"; }; then 8162bd23fbfaSmrg test -n "$dlopen" && func_append dlfiles " $dlopen" 8163bd23fbfaSmrg test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" 81648c4a8e55Smrg fi 81658c4a8e55Smrg 81663169be4bSmrg if test conv = "$pass"; then 81678c4a8e55Smrg # Only check for convenience libraries 81688c4a8e55Smrg deplibs="$lib $deplibs" 81698c4a8e55Smrg if test -z "$libdir"; then 81708c4a8e55Smrg if test -z "$old_library"; then 81713169be4bSmrg func_fatal_error "cannot find name of link library for '$lib'" 81728c4a8e55Smrg fi 81738c4a8e55Smrg # It is a libtool convenience library, so add in its objects. 8174bd23fbfaSmrg func_append convenience " $ladir/$objdir/$old_library" 8175bd23fbfaSmrg func_append old_convenience " $ladir/$objdir/$old_library" 81763169be4bSmrg elif test prog != "$linkmode" && test lib != "$linkmode"; then 81773169be4bSmrg func_fatal_error "'$lib' is not a convenience library" 81788c4a8e55Smrg fi 81793169be4bSmrg tmp_libs= 81803169be4bSmrg for deplib in $dependency_libs; do 81813169be4bSmrg deplibs="$deplib $deplibs" 81823169be4bSmrg if $opt_preserve_dup_deps; then 81833169be4bSmrg case "$tmp_libs " in 81843169be4bSmrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 81853169be4bSmrg esac 81863169be4bSmrg fi 81873169be4bSmrg func_append tmp_libs " $deplib" 81883169be4bSmrg done 81898c4a8e55Smrg continue 81908c4a8e55Smrg fi # $pass = conv 81918c4a8e55Smrg 81928c4a8e55Smrg 81938c4a8e55Smrg # Get the name of the library we link against. 81948c4a8e55Smrg linklib= 8195bd23fbfaSmrg if test -n "$old_library" && 81963169be4bSmrg { test yes = "$prefer_static_libs" || 81973169be4bSmrg test built,no = "$prefer_static_libs,$installed"; }; then 8198bd23fbfaSmrg linklib=$old_library 8199bd23fbfaSmrg else 8200bd23fbfaSmrg for l in $old_library $library_names; do 82013169be4bSmrg linklib=$l 8202bd23fbfaSmrg done 8203bd23fbfaSmrg fi 82048c4a8e55Smrg if test -z "$linklib"; then 82053169be4bSmrg func_fatal_error "cannot find name of link library for '$lib'" 82068c4a8e55Smrg fi 82078c4a8e55Smrg 82088c4a8e55Smrg # This library was specified with -dlopen. 82093169be4bSmrg if test dlopen = "$pass"; then 82103169be4bSmrg test -z "$libdir" \ 82113169be4bSmrg && func_fatal_error "cannot -dlopen a convenience library: '$lib'" 82128c4a8e55Smrg if test -z "$dlname" || 82133169be4bSmrg test yes != "$dlopen_support" || 82143169be4bSmrg test no = "$build_libtool_libs" 82153169be4bSmrg then 82168c4a8e55Smrg # If there is no dlname, no dlopen support or we're linking 82178c4a8e55Smrg # statically, we need to preload. We also need to preload any 82188c4a8e55Smrg # dependent libraries so libltdl's deplib preloader doesn't 82198c4a8e55Smrg # bomb out in the load deplibs phase. 8220bd23fbfaSmrg func_append dlprefiles " $lib $dependency_libs" 82218c4a8e55Smrg else 8222bd23fbfaSmrg func_append newdlfiles " $lib" 82238c4a8e55Smrg fi 82248c4a8e55Smrg continue 82258c4a8e55Smrg fi # $pass = dlopen 82268c4a8e55Smrg 82278c4a8e55Smrg # We need an absolute path. 82288c4a8e55Smrg case $ladir in 82293169be4bSmrg [\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;; 82308c4a8e55Smrg *) 82318c4a8e55Smrg abs_ladir=`cd "$ladir" && pwd` 82328c4a8e55Smrg if test -z "$abs_ladir"; then 82333169be4bSmrg func_warning "cannot determine absolute directory name of '$ladir'" 82348c4a8e55Smrg func_warning "passing it literally to the linker, although it might fail" 82353169be4bSmrg abs_ladir=$ladir 82368c4a8e55Smrg fi 82378c4a8e55Smrg ;; 82388c4a8e55Smrg esac 82398c4a8e55Smrg func_basename "$lib" 82403169be4bSmrg laname=$func_basename_result 82418c4a8e55Smrg 82428c4a8e55Smrg # Find the relevant object directory and library name. 82433169be4bSmrg if test yes = "$installed"; then 8244bd23fbfaSmrg if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then 82453169be4bSmrg func_warning "library '$lib' was moved." 82463169be4bSmrg dir=$ladir 82473169be4bSmrg absdir=$abs_ladir 82483169be4bSmrg libdir=$abs_ladir 82498c4a8e55Smrg else 82503169be4bSmrg dir=$lt_sysroot$libdir 82513169be4bSmrg absdir=$lt_sysroot$libdir 82528c4a8e55Smrg fi 82533169be4bSmrg test yes = "$hardcode_automatic" && avoidtemprpath=yes 82548c4a8e55Smrg else 82558c4a8e55Smrg if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then 82563169be4bSmrg dir=$ladir 82573169be4bSmrg absdir=$abs_ladir 82588c4a8e55Smrg # Remove this search path later 8259bd23fbfaSmrg func_append notinst_path " $abs_ladir" 82608c4a8e55Smrg else 82613169be4bSmrg dir=$ladir/$objdir 82623169be4bSmrg absdir=$abs_ladir/$objdir 82638c4a8e55Smrg # Remove this search path later 8264bd23fbfaSmrg func_append notinst_path " $abs_ladir" 82658c4a8e55Smrg fi 82668c4a8e55Smrg fi # $installed = yes 82678c4a8e55Smrg func_stripname 'lib' '.la' "$laname" 82688c4a8e55Smrg name=$func_stripname_result 82698c4a8e55Smrg 82708c4a8e55Smrg # This library was specified with -dlpreopen. 82713169be4bSmrg if test dlpreopen = "$pass"; then 82723169be4bSmrg if test -z "$libdir" && test prog = "$linkmode"; then 82733169be4bSmrg func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'" 82748c4a8e55Smrg fi 82753169be4bSmrg case $host in 8276bd23fbfaSmrg # special handling for platforms with PE-DLLs. 8277bd23fbfaSmrg *cygwin* | *mingw* | *cegcc* ) 8278bd23fbfaSmrg # Linker will automatically link against shared library if both 8279bd23fbfaSmrg # static and shared are present. Therefore, ensure we extract 8280bd23fbfaSmrg # symbols from the import library if a shared library is present 8281bd23fbfaSmrg # (otherwise, the dlopen module name will be incorrect). We do 8282bd23fbfaSmrg # this by putting the import library name into $newdlprefiles. 8283bd23fbfaSmrg # We recover the dlopen module name by 'saving' the la file 8284bd23fbfaSmrg # name in a special purpose variable, and (later) extracting the 8285bd23fbfaSmrg # dlname from the la file. 8286bd23fbfaSmrg if test -n "$dlname"; then 8287bd23fbfaSmrg func_tr_sh "$dir/$linklib" 8288bd23fbfaSmrg eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" 8289bd23fbfaSmrg func_append newdlprefiles " $dir/$linklib" 8290bd23fbfaSmrg else 8291bd23fbfaSmrg func_append newdlprefiles " $dir/$old_library" 8292bd23fbfaSmrg # Keep a list of preopened convenience libraries to check 8293bd23fbfaSmrg # that they are being used correctly in the link pass. 8294bd23fbfaSmrg test -z "$libdir" && \ 8295bd23fbfaSmrg func_append dlpreconveniencelibs " $dir/$old_library" 8296bd23fbfaSmrg fi 8297bd23fbfaSmrg ;; 8298bd23fbfaSmrg * ) 8299bd23fbfaSmrg # Prefer using a static library (so that no silly _DYNAMIC symbols 8300bd23fbfaSmrg # are required to link). 8301bd23fbfaSmrg if test -n "$old_library"; then 8302bd23fbfaSmrg func_append newdlprefiles " $dir/$old_library" 8303bd23fbfaSmrg # Keep a list of preopened convenience libraries to check 8304bd23fbfaSmrg # that they are being used correctly in the link pass. 8305bd23fbfaSmrg test -z "$libdir" && \ 8306bd23fbfaSmrg func_append dlpreconveniencelibs " $dir/$old_library" 8307bd23fbfaSmrg # Otherwise, use the dlname, so that lt_dlopen finds it. 8308bd23fbfaSmrg elif test -n "$dlname"; then 8309bd23fbfaSmrg func_append newdlprefiles " $dir/$dlname" 8310bd23fbfaSmrg else 8311bd23fbfaSmrg func_append newdlprefiles " $dir/$linklib" 8312bd23fbfaSmrg fi 8313bd23fbfaSmrg ;; 8314bd23fbfaSmrg esac 83158c4a8e55Smrg fi # $pass = dlpreopen 83168c4a8e55Smrg 83178c4a8e55Smrg if test -z "$libdir"; then 83188c4a8e55Smrg # Link the convenience library 83193169be4bSmrg if test lib = "$linkmode"; then 83208c4a8e55Smrg deplibs="$dir/$old_library $deplibs" 83213169be4bSmrg elif test prog,link = "$linkmode,$pass"; then 83228c4a8e55Smrg compile_deplibs="$dir/$old_library $compile_deplibs" 83238c4a8e55Smrg finalize_deplibs="$dir/$old_library $finalize_deplibs" 83248c4a8e55Smrg else 83258c4a8e55Smrg deplibs="$lib $deplibs" # used for prog,scan pass 83268c4a8e55Smrg fi 83278c4a8e55Smrg continue 83288c4a8e55Smrg fi 83298c4a8e55Smrg 83308c4a8e55Smrg 83313169be4bSmrg if test prog = "$linkmode" && test link != "$pass"; then 8332bd23fbfaSmrg func_append newlib_search_path " $ladir" 83338c4a8e55Smrg deplibs="$lib $deplibs" 83348c4a8e55Smrg 83353169be4bSmrg linkalldeplibs=false 83363169be4bSmrg if test no != "$link_all_deplibs" || test -z "$library_names" || 83373169be4bSmrg test no = "$build_libtool_libs"; then 83383169be4bSmrg linkalldeplibs=: 83398c4a8e55Smrg fi 83408c4a8e55Smrg 83418c4a8e55Smrg tmp_libs= 83428c4a8e55Smrg for deplib in $dependency_libs; do 83438c4a8e55Smrg case $deplib in 83448c4a8e55Smrg -L*) func_stripname '-L' '' "$deplib" 8345bd23fbfaSmrg func_resolve_sysroot "$func_stripname_result" 8346bd23fbfaSmrg func_append newlib_search_path " $func_resolve_sysroot_result" 83478c4a8e55Smrg ;; 83488c4a8e55Smrg esac 83498c4a8e55Smrg # Need to link against all dependency_libs? 83503169be4bSmrg if $linkalldeplibs; then 83518c4a8e55Smrg deplibs="$deplib $deplibs" 83528c4a8e55Smrg else 83538c4a8e55Smrg # Need to hardcode shared library paths 83548c4a8e55Smrg # or/and link against static libraries 83558c4a8e55Smrg newdependency_libs="$deplib $newdependency_libs" 83568c4a8e55Smrg fi 83573169be4bSmrg if $opt_preserve_dup_deps; then 83588c4a8e55Smrg case "$tmp_libs " in 8359bd23fbfaSmrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 83608c4a8e55Smrg esac 83618c4a8e55Smrg fi 8362bd23fbfaSmrg func_append tmp_libs " $deplib" 83638c4a8e55Smrg done # for deplib 83648c4a8e55Smrg continue 83658c4a8e55Smrg fi # $linkmode = prog... 83668c4a8e55Smrg 83673169be4bSmrg if test prog,link = "$linkmode,$pass"; then 83688c4a8e55Smrg if test -n "$library_names" && 83693169be4bSmrg { { test no = "$prefer_static_libs" || 83703169be4bSmrg test built,yes = "$prefer_static_libs,$installed"; } || 83718c4a8e55Smrg test -z "$old_library"; }; then 83728c4a8e55Smrg # We need to hardcode the library path 83733169be4bSmrg if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then 83748c4a8e55Smrg # Make sure the rpath contains only unique directories. 83753169be4bSmrg case $temp_rpath: in 83768c4a8e55Smrg *"$absdir:"*) ;; 8377bd23fbfaSmrg *) func_append temp_rpath "$absdir:" ;; 83788c4a8e55Smrg esac 83798c4a8e55Smrg fi 83808c4a8e55Smrg 83818c4a8e55Smrg # Hardcode the library path. 83828c4a8e55Smrg # Skip directories that are in the system default run-time 83838c4a8e55Smrg # search path. 83848c4a8e55Smrg case " $sys_lib_dlsearch_path " in 83858c4a8e55Smrg *" $absdir "*) ;; 83868c4a8e55Smrg *) 83878c4a8e55Smrg case "$compile_rpath " in 83888c4a8e55Smrg *" $absdir "*) ;; 8389bd23fbfaSmrg *) func_append compile_rpath " $absdir" ;; 83908c4a8e55Smrg esac 83918c4a8e55Smrg ;; 83928c4a8e55Smrg esac 83938c4a8e55Smrg case " $sys_lib_dlsearch_path " in 83948c4a8e55Smrg *" $libdir "*) ;; 83958c4a8e55Smrg *) 83968c4a8e55Smrg case "$finalize_rpath " in 83978c4a8e55Smrg *" $libdir "*) ;; 8398bd23fbfaSmrg *) func_append finalize_rpath " $libdir" ;; 83998c4a8e55Smrg esac 84008c4a8e55Smrg ;; 84018c4a8e55Smrg esac 84028c4a8e55Smrg fi # $linkmode,$pass = prog,link... 84038c4a8e55Smrg 84043169be4bSmrg if $alldeplibs && 84053169be4bSmrg { test pass_all = "$deplibs_check_method" || 84063169be4bSmrg { test yes = "$build_libtool_libs" && 84078c4a8e55Smrg test -n "$library_names"; }; }; then 84088c4a8e55Smrg # We only need to search for static libraries 84098c4a8e55Smrg continue 84108c4a8e55Smrg fi 84118c4a8e55Smrg fi 84128c4a8e55Smrg 84138c4a8e55Smrg link_static=no # Whether the deplib will be linked statically 84148c4a8e55Smrg use_static_libs=$prefer_static_libs 84153169be4bSmrg if test built = "$use_static_libs" && test yes = "$installed"; then 84168c4a8e55Smrg use_static_libs=no 84178c4a8e55Smrg fi 84188c4a8e55Smrg if test -n "$library_names" && 84193169be4bSmrg { test no = "$use_static_libs" || test -z "$old_library"; }; then 84208c4a8e55Smrg case $host in 84213169be4bSmrg *cygwin* | *mingw* | *cegcc* | *os2*) 84228c4a8e55Smrg # No point in relinking DLLs because paths are not encoded 8423bd23fbfaSmrg func_append notinst_deplibs " $lib" 84248c4a8e55Smrg need_relink=no 84258c4a8e55Smrg ;; 84268c4a8e55Smrg *) 84273169be4bSmrg if test no = "$installed"; then 8428bd23fbfaSmrg func_append notinst_deplibs " $lib" 84298c4a8e55Smrg need_relink=yes 84308c4a8e55Smrg fi 84318c4a8e55Smrg ;; 84328c4a8e55Smrg esac 84338c4a8e55Smrg # This is a shared library 84348c4a8e55Smrg 84358c4a8e55Smrg # Warn about portability, can't link against -module's on some 84368c4a8e55Smrg # systems (darwin). Don't bleat about dlopened modules though! 84373169be4bSmrg dlopenmodule= 84388c4a8e55Smrg for dlpremoduletest in $dlprefiles; do 84398c4a8e55Smrg if test "X$dlpremoduletest" = "X$lib"; then 84403169be4bSmrg dlopenmodule=$dlpremoduletest 84418c4a8e55Smrg break 84428c4a8e55Smrg fi 84438c4a8e55Smrg done 84443169be4bSmrg if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then 8445706b6b52Smrg echo 84463169be4bSmrg if test prog = "$linkmode"; then 84478c4a8e55Smrg $ECHO "*** Warning: Linking the executable $output against the loadable module" 84488c4a8e55Smrg else 84498c4a8e55Smrg $ECHO "*** Warning: Linking the shared library $output against the loadable module" 84508c4a8e55Smrg fi 84518c4a8e55Smrg $ECHO "*** $linklib is not portable!" 84528c4a8e55Smrg fi 84533169be4bSmrg if test lib = "$linkmode" && 84543169be4bSmrg test yes = "$hardcode_into_libs"; then 84558c4a8e55Smrg # Hardcode the library path. 84568c4a8e55Smrg # Skip directories that are in the system default run-time 84578c4a8e55Smrg # search path. 84588c4a8e55Smrg case " $sys_lib_dlsearch_path " in 84598c4a8e55Smrg *" $absdir "*) ;; 84608c4a8e55Smrg *) 84618c4a8e55Smrg case "$compile_rpath " in 84628c4a8e55Smrg *" $absdir "*) ;; 8463bd23fbfaSmrg *) func_append compile_rpath " $absdir" ;; 84648c4a8e55Smrg esac 84658c4a8e55Smrg ;; 84668c4a8e55Smrg esac 84678c4a8e55Smrg case " $sys_lib_dlsearch_path " in 84688c4a8e55Smrg *" $libdir "*) ;; 84698c4a8e55Smrg *) 84708c4a8e55Smrg case "$finalize_rpath " in 84718c4a8e55Smrg *" $libdir "*) ;; 8472bd23fbfaSmrg *) func_append finalize_rpath " $libdir" ;; 84738c4a8e55Smrg esac 84748c4a8e55Smrg ;; 84758c4a8e55Smrg esac 84768c4a8e55Smrg fi 84778c4a8e55Smrg 84788c4a8e55Smrg if test -n "$old_archive_from_expsyms_cmds"; then 84798c4a8e55Smrg # figure out the soname 84808c4a8e55Smrg set dummy $library_names 84818c4a8e55Smrg shift 84823169be4bSmrg realname=$1 84838c4a8e55Smrg shift 84848c4a8e55Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 84858c4a8e55Smrg # use dlname if we got it. it's perfectly good, no? 84868c4a8e55Smrg if test -n "$dlname"; then 84873169be4bSmrg soname=$dlname 84888c4a8e55Smrg elif test -n "$soname_spec"; then 84898c4a8e55Smrg # bleh windows 84908c4a8e55Smrg case $host in 84913169be4bSmrg *cygwin* | mingw* | *cegcc* | *os2*) 84928c4a8e55Smrg func_arith $current - $age 84938c4a8e55Smrg major=$func_arith_result 84943169be4bSmrg versuffix=-$major 84958c4a8e55Smrg ;; 84968c4a8e55Smrg esac 84978c4a8e55Smrg eval soname=\"$soname_spec\" 84988c4a8e55Smrg else 84993169be4bSmrg soname=$realname 85008c4a8e55Smrg fi 85018c4a8e55Smrg 85028c4a8e55Smrg # Make a new name for the extract_expsyms_cmds to use 85033169be4bSmrg soroot=$soname 85048c4a8e55Smrg func_basename "$soroot" 85053169be4bSmrg soname=$func_basename_result 85068c4a8e55Smrg func_stripname 'lib' '.dll' "$soname" 85078c4a8e55Smrg newlib=libimp-$func_stripname_result.a 85088c4a8e55Smrg 85098c4a8e55Smrg # If the library has no export list, then create one now 85108c4a8e55Smrg if test -f "$output_objdir/$soname-def"; then : 85118c4a8e55Smrg else 85123169be4bSmrg func_verbose "extracting exported symbol list from '$soname'" 85138c4a8e55Smrg func_execute_cmds "$extract_expsyms_cmds" 'exit $?' 85148c4a8e55Smrg fi 85158c4a8e55Smrg 85168c4a8e55Smrg # Create $newlib 85178c4a8e55Smrg if test -f "$output_objdir/$newlib"; then :; else 85183169be4bSmrg func_verbose "generating import library for '$soname'" 85198c4a8e55Smrg func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' 85208c4a8e55Smrg fi 85218c4a8e55Smrg # make sure the library variables are pointing to the new library 85228c4a8e55Smrg dir=$output_objdir 85238c4a8e55Smrg linklib=$newlib 85248c4a8e55Smrg fi # test -n "$old_archive_from_expsyms_cmds" 85258c4a8e55Smrg 85263169be4bSmrg if test prog = "$linkmode" || test relink != "$opt_mode"; then 85278c4a8e55Smrg add_shlibpath= 85288c4a8e55Smrg add_dir= 85298c4a8e55Smrg add= 85308c4a8e55Smrg lib_linked=yes 85318c4a8e55Smrg case $hardcode_action in 85328c4a8e55Smrg immediate | unsupported) 85333169be4bSmrg if test no = "$hardcode_direct"; then 85343169be4bSmrg add=$dir/$linklib 85358c4a8e55Smrg case $host in 85363169be4bSmrg *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;; 85373169be4bSmrg *-*-sysv4*uw2*) add_dir=-L$dir ;; 85388c4a8e55Smrg *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ 85393169be4bSmrg *-*-unixware7*) add_dir=-L$dir ;; 85408c4a8e55Smrg *-*-darwin* ) 85413169be4bSmrg # if the lib is a (non-dlopened) module then we cannot 85428c4a8e55Smrg # link against it, someone is ignoring the earlier warnings 85438c4a8e55Smrg if /usr/bin/file -L $add 2> /dev/null | 85443169be4bSmrg $GREP ": [^:]* bundle" >/dev/null; then 85458c4a8e55Smrg if test "X$dlopenmodule" != "X$lib"; then 85468c4a8e55Smrg $ECHO "*** Warning: lib $linklib is a module, not a shared library" 85473169be4bSmrg if test -z "$old_library"; then 8548706b6b52Smrg echo 8549706b6b52Smrg echo "*** And there doesn't seem to be a static archive available" 8550706b6b52Smrg echo "*** The link will probably fail, sorry" 85518c4a8e55Smrg else 85523169be4bSmrg add=$dir/$old_library 85538c4a8e55Smrg fi 85548c4a8e55Smrg elif test -n "$old_library"; then 85553169be4bSmrg add=$dir/$old_library 85568c4a8e55Smrg fi 85578c4a8e55Smrg fi 85588c4a8e55Smrg esac 85593169be4bSmrg elif test no = "$hardcode_minus_L"; then 85608c4a8e55Smrg case $host in 85613169be4bSmrg *-*-sunos*) add_shlibpath=$dir ;; 85628c4a8e55Smrg esac 85633169be4bSmrg add_dir=-L$dir 85643169be4bSmrg add=-l$name 85653169be4bSmrg elif test no = "$hardcode_shlibpath_var"; then 85663169be4bSmrg add_shlibpath=$dir 85673169be4bSmrg add=-l$name 85688c4a8e55Smrg else 85698c4a8e55Smrg lib_linked=no 85708c4a8e55Smrg fi 85718c4a8e55Smrg ;; 85728c4a8e55Smrg relink) 85733169be4bSmrg if test yes = "$hardcode_direct" && 85743169be4bSmrg test no = "$hardcode_direct_absolute"; then 85753169be4bSmrg add=$dir/$linklib 85763169be4bSmrg elif test yes = "$hardcode_minus_L"; then 85773169be4bSmrg add_dir=-L$absdir 85788c4a8e55Smrg # Try looking first in the location we're being installed to. 85798c4a8e55Smrg if test -n "$inst_prefix_dir"; then 85808c4a8e55Smrg case $libdir in 85818c4a8e55Smrg [\\/]*) 8582bd23fbfaSmrg func_append add_dir " -L$inst_prefix_dir$libdir" 85838c4a8e55Smrg ;; 85848c4a8e55Smrg esac 85858c4a8e55Smrg fi 85863169be4bSmrg add=-l$name 85873169be4bSmrg elif test yes = "$hardcode_shlibpath_var"; then 85883169be4bSmrg add_shlibpath=$dir 85893169be4bSmrg add=-l$name 85908c4a8e55Smrg else 85918c4a8e55Smrg lib_linked=no 85928c4a8e55Smrg fi 85938c4a8e55Smrg ;; 85948c4a8e55Smrg *) lib_linked=no ;; 85958c4a8e55Smrg esac 85968c4a8e55Smrg 85973169be4bSmrg if test yes != "$lib_linked"; then 85988c4a8e55Smrg func_fatal_configuration "unsupported hardcode properties" 85998c4a8e55Smrg fi 86008c4a8e55Smrg 86018c4a8e55Smrg if test -n "$add_shlibpath"; then 86028c4a8e55Smrg case :$compile_shlibpath: in 86038c4a8e55Smrg *":$add_shlibpath:"*) ;; 8604bd23fbfaSmrg *) func_append compile_shlibpath "$add_shlibpath:" ;; 86058c4a8e55Smrg esac 86068c4a8e55Smrg fi 86073169be4bSmrg if test prog = "$linkmode"; then 86088c4a8e55Smrg test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" 86098c4a8e55Smrg test -n "$add" && compile_deplibs="$add $compile_deplibs" 86108c4a8e55Smrg else 86118c4a8e55Smrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 86128c4a8e55Smrg test -n "$add" && deplibs="$add $deplibs" 86133169be4bSmrg if test yes != "$hardcode_direct" && 86143169be4bSmrg test yes != "$hardcode_minus_L" && 86153169be4bSmrg test yes = "$hardcode_shlibpath_var"; then 86168c4a8e55Smrg case :$finalize_shlibpath: in 86178c4a8e55Smrg *":$libdir:"*) ;; 8618bd23fbfaSmrg *) func_append finalize_shlibpath "$libdir:" ;; 86198c4a8e55Smrg esac 86208c4a8e55Smrg fi 86218c4a8e55Smrg fi 86228c4a8e55Smrg fi 86238c4a8e55Smrg 86243169be4bSmrg if test prog = "$linkmode" || test relink = "$opt_mode"; then 86258c4a8e55Smrg add_shlibpath= 86268c4a8e55Smrg add_dir= 86278c4a8e55Smrg add= 86288c4a8e55Smrg # Finalize command for both is simple: just hardcode it. 86293169be4bSmrg if test yes = "$hardcode_direct" && 86303169be4bSmrg test no = "$hardcode_direct_absolute"; then 86313169be4bSmrg add=$libdir/$linklib 86323169be4bSmrg elif test yes = "$hardcode_minus_L"; then 86333169be4bSmrg add_dir=-L$libdir 86343169be4bSmrg add=-l$name 86353169be4bSmrg elif test yes = "$hardcode_shlibpath_var"; then 86368c4a8e55Smrg case :$finalize_shlibpath: in 86378c4a8e55Smrg *":$libdir:"*) ;; 8638bd23fbfaSmrg *) func_append finalize_shlibpath "$libdir:" ;; 86398c4a8e55Smrg esac 86403169be4bSmrg add=-l$name 86413169be4bSmrg elif test yes = "$hardcode_automatic"; then 86428c4a8e55Smrg if test -n "$inst_prefix_dir" && 86433169be4bSmrg test -f "$inst_prefix_dir$libdir/$linklib"; then 86443169be4bSmrg add=$inst_prefix_dir$libdir/$linklib 86458c4a8e55Smrg else 86463169be4bSmrg add=$libdir/$linklib 86478c4a8e55Smrg fi 86488c4a8e55Smrg else 86498c4a8e55Smrg # We cannot seem to hardcode it, guess we'll fake it. 86503169be4bSmrg add_dir=-L$libdir 86518c4a8e55Smrg # Try looking first in the location we're being installed to. 86528c4a8e55Smrg if test -n "$inst_prefix_dir"; then 86538c4a8e55Smrg case $libdir in 86548c4a8e55Smrg [\\/]*) 8655bd23fbfaSmrg func_append add_dir " -L$inst_prefix_dir$libdir" 86568c4a8e55Smrg ;; 86578c4a8e55Smrg esac 86588c4a8e55Smrg fi 86593169be4bSmrg add=-l$name 86608c4a8e55Smrg fi 86618c4a8e55Smrg 86623169be4bSmrg if test prog = "$linkmode"; then 86638c4a8e55Smrg test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" 86648c4a8e55Smrg test -n "$add" && finalize_deplibs="$add $finalize_deplibs" 86658c4a8e55Smrg else 86668c4a8e55Smrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 86678c4a8e55Smrg test -n "$add" && deplibs="$add $deplibs" 86688c4a8e55Smrg fi 86698c4a8e55Smrg fi 86703169be4bSmrg elif test prog = "$linkmode"; then 86718c4a8e55Smrg # Here we assume that one of hardcode_direct or hardcode_minus_L 86728c4a8e55Smrg # is not unsupported. This is valid on all known static and 86738c4a8e55Smrg # shared platforms. 86743169be4bSmrg if test unsupported != "$hardcode_direct"; then 86753169be4bSmrg test -n "$old_library" && linklib=$old_library 86768c4a8e55Smrg compile_deplibs="$dir/$linklib $compile_deplibs" 86778c4a8e55Smrg finalize_deplibs="$dir/$linklib $finalize_deplibs" 86788c4a8e55Smrg else 86798c4a8e55Smrg compile_deplibs="-l$name -L$dir $compile_deplibs" 86808c4a8e55Smrg finalize_deplibs="-l$name -L$dir $finalize_deplibs" 86818c4a8e55Smrg fi 86823169be4bSmrg elif test yes = "$build_libtool_libs"; then 86838c4a8e55Smrg # Not a shared library 86843169be4bSmrg if test pass_all != "$deplibs_check_method"; then 86858c4a8e55Smrg # We're trying link a shared library against a static one 86868c4a8e55Smrg # but the system doesn't support it. 86878c4a8e55Smrg 86888c4a8e55Smrg # Just print a warning and add the library to dependency_libs so 86898c4a8e55Smrg # that the program can be linked against the static library. 8690706b6b52Smrg echo 86913169be4bSmrg $ECHO "*** Warning: This system cannot link to static lib archive $lib." 8692706b6b52Smrg echo "*** I have the capability to make that library automatically link in when" 8693706b6b52Smrg echo "*** you link to this library. But I can only do this if you have a" 8694706b6b52Smrg echo "*** shared version of the library, which you do not appear to have." 86953169be4bSmrg if test yes = "$module"; then 8696706b6b52Smrg echo "*** But as you try to build a module library, libtool will still create " 8697706b6b52Smrg echo "*** a static module, that should work as long as the dlopening application" 8698706b6b52Smrg echo "*** is linked with the -dlopen flag to resolve symbols at runtime." 86998c4a8e55Smrg if test -z "$global_symbol_pipe"; then 8700706b6b52Smrg echo 8701706b6b52Smrg echo "*** However, this would only work if libtool was able to extract symbol" 87023169be4bSmrg echo "*** lists from a program, using 'nm' or equivalent, but libtool could" 8703706b6b52Smrg echo "*** not find such a program. So, this module is probably useless." 87043169be4bSmrg echo "*** 'nm' from GNU binutils and a full rebuild may help." 87058c4a8e55Smrg fi 87063169be4bSmrg if test no = "$build_old_libs"; then 87078c4a8e55Smrg build_libtool_libs=module 87088c4a8e55Smrg build_old_libs=yes 87098c4a8e55Smrg else 87108c4a8e55Smrg build_libtool_libs=no 87118c4a8e55Smrg fi 87128c4a8e55Smrg fi 87138c4a8e55Smrg else 87148c4a8e55Smrg deplibs="$dir/$old_library $deplibs" 87158c4a8e55Smrg link_static=yes 87168c4a8e55Smrg fi 87178c4a8e55Smrg fi # link shared/static library? 87188c4a8e55Smrg 87193169be4bSmrg if test lib = "$linkmode"; then 87208c4a8e55Smrg if test -n "$dependency_libs" && 87213169be4bSmrg { test yes != "$hardcode_into_libs" || 87223169be4bSmrg test yes = "$build_old_libs" || 87233169be4bSmrg test yes = "$link_static"; }; then 87248c4a8e55Smrg # Extract -R from dependency_libs 87258c4a8e55Smrg temp_deplibs= 87268c4a8e55Smrg for libdir in $dependency_libs; do 87278c4a8e55Smrg case $libdir in 87288c4a8e55Smrg -R*) func_stripname '-R' '' "$libdir" 87298c4a8e55Smrg temp_xrpath=$func_stripname_result 87308c4a8e55Smrg case " $xrpath " in 87318c4a8e55Smrg *" $temp_xrpath "*) ;; 8732bd23fbfaSmrg *) func_append xrpath " $temp_xrpath";; 87338c4a8e55Smrg esac;; 8734bd23fbfaSmrg *) func_append temp_deplibs " $libdir";; 87358c4a8e55Smrg esac 87368c4a8e55Smrg done 87373169be4bSmrg dependency_libs=$temp_deplibs 87388c4a8e55Smrg fi 87398c4a8e55Smrg 8740bd23fbfaSmrg func_append newlib_search_path " $absdir" 87418c4a8e55Smrg # Link against this library 87423169be4bSmrg test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs" 87438c4a8e55Smrg # ... and its dependency_libs 87448c4a8e55Smrg tmp_libs= 87458c4a8e55Smrg for deplib in $dependency_libs; do 87468c4a8e55Smrg newdependency_libs="$deplib $newdependency_libs" 8747bd23fbfaSmrg case $deplib in 8748bd23fbfaSmrg -L*) func_stripname '-L' '' "$deplib" 8749bd23fbfaSmrg func_resolve_sysroot "$func_stripname_result";; 8750bd23fbfaSmrg *) func_resolve_sysroot "$deplib" ;; 8751bd23fbfaSmrg esac 87523169be4bSmrg if $opt_preserve_dup_deps; then 87538c4a8e55Smrg case "$tmp_libs " in 8754bd23fbfaSmrg *" $func_resolve_sysroot_result "*) 8755bd23fbfaSmrg func_append specialdeplibs " $func_resolve_sysroot_result" ;; 87568c4a8e55Smrg esac 87578c4a8e55Smrg fi 8758bd23fbfaSmrg func_append tmp_libs " $func_resolve_sysroot_result" 87598c4a8e55Smrg done 87608c4a8e55Smrg 87613169be4bSmrg if test no != "$link_all_deplibs"; then 87628c4a8e55Smrg # Add the search paths of all dependency libraries 87638c4a8e55Smrg for deplib in $dependency_libs; do 8764706b6b52Smrg path= 87658c4a8e55Smrg case $deplib in 87663169be4bSmrg -L*) path=$deplib ;; 87678c4a8e55Smrg *.la) 8768bd23fbfaSmrg func_resolve_sysroot "$deplib" 8769bd23fbfaSmrg deplib=$func_resolve_sysroot_result 87708c4a8e55Smrg func_dirname "$deplib" "" "." 8771bd23fbfaSmrg dir=$func_dirname_result 87728c4a8e55Smrg # We need an absolute path. 87738c4a8e55Smrg case $dir in 87743169be4bSmrg [\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;; 87758c4a8e55Smrg *) 87768c4a8e55Smrg absdir=`cd "$dir" && pwd` 87778c4a8e55Smrg if test -z "$absdir"; then 87783169be4bSmrg func_warning "cannot determine absolute directory name of '$dir'" 87793169be4bSmrg absdir=$dir 87808c4a8e55Smrg fi 87818c4a8e55Smrg ;; 87828c4a8e55Smrg esac 87838c4a8e55Smrg if $GREP "^installed=no" $deplib > /dev/null; then 87848c4a8e55Smrg case $host in 87858c4a8e55Smrg *-*-darwin*) 87868c4a8e55Smrg depdepl= 87873169be4bSmrg eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` 87883169be4bSmrg if test -n "$deplibrary_names"; then 87893169be4bSmrg for tmp in $deplibrary_names; do 87908c4a8e55Smrg depdepl=$tmp 87918c4a8e55Smrg done 87923169be4bSmrg if test -f "$absdir/$objdir/$depdepl"; then 87933169be4bSmrg depdepl=$absdir/$objdir/$depdepl 87943169be4bSmrg darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 87958c4a8e55Smrg if test -z "$darwin_install_name"; then 87963169be4bSmrg darwin_install_name=`$OTOOL64 -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 87978c4a8e55Smrg fi 87983169be4bSmrg func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl" 87993169be4bSmrg func_append linker_flags " -dylib_file $darwin_install_name:$depdepl" 88008c4a8e55Smrg path= 88018c4a8e55Smrg fi 88028c4a8e55Smrg fi 88038c4a8e55Smrg ;; 88048c4a8e55Smrg *) 88053169be4bSmrg path=-L$absdir/$objdir 88068c4a8e55Smrg ;; 88078c4a8e55Smrg esac 88088c4a8e55Smrg else 88093169be4bSmrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` 88108c4a8e55Smrg test -z "$libdir" && \ 88113169be4bSmrg func_fatal_error "'$deplib' is not a valid libtool archive" 88128c4a8e55Smrg test "$absdir" != "$libdir" && \ 88133169be4bSmrg func_warning "'$deplib' seems to be moved" 88148c4a8e55Smrg 88153169be4bSmrg path=-L$absdir 88168c4a8e55Smrg fi 88178c4a8e55Smrg ;; 88188c4a8e55Smrg esac 88198c4a8e55Smrg case " $deplibs " in 88208c4a8e55Smrg *" $path "*) ;; 88218c4a8e55Smrg *) deplibs="$path $deplibs" ;; 88228c4a8e55Smrg esac 88238c4a8e55Smrg done 88248c4a8e55Smrg fi # link_all_deplibs != no 88258c4a8e55Smrg fi # linkmode = lib 88268c4a8e55Smrg done # for deplib in $libs 88273169be4bSmrg if test link = "$pass"; then 88283169be4bSmrg if test prog = "$linkmode"; then 88298c4a8e55Smrg compile_deplibs="$new_inherited_linker_flags $compile_deplibs" 88308c4a8e55Smrg finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" 88318c4a8e55Smrg else 8832706b6b52Smrg compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 88338c4a8e55Smrg fi 88348c4a8e55Smrg fi 88353169be4bSmrg dependency_libs=$newdependency_libs 88363169be4bSmrg if test dlpreopen = "$pass"; then 88378c4a8e55Smrg # Link the dlpreopened libraries before other libraries 88388c4a8e55Smrg for deplib in $save_deplibs; do 88398c4a8e55Smrg deplibs="$deplib $deplibs" 88408c4a8e55Smrg done 88418c4a8e55Smrg fi 88423169be4bSmrg if test dlopen != "$pass"; then 88433169be4bSmrg test conv = "$pass" || { 88448c4a8e55Smrg # Make sure lib_search_path contains only unique directories. 88458c4a8e55Smrg lib_search_path= 88468c4a8e55Smrg for dir in $newlib_search_path; do 88478c4a8e55Smrg case "$lib_search_path " in 88488c4a8e55Smrg *" $dir "*) ;; 8849bd23fbfaSmrg *) func_append lib_search_path " $dir" ;; 88508c4a8e55Smrg esac 88518c4a8e55Smrg done 88528c4a8e55Smrg newlib_search_path= 88533169be4bSmrg } 88548c4a8e55Smrg 88553169be4bSmrg if test prog,link = "$linkmode,$pass"; then 88568c4a8e55Smrg vars="compile_deplibs finalize_deplibs" 88573169be4bSmrg else 88583169be4bSmrg vars=deplibs 88598c4a8e55Smrg fi 88608c4a8e55Smrg for var in $vars dependency_libs; do 88618c4a8e55Smrg # Add libraries to $var in reverse order 88628c4a8e55Smrg eval tmp_libs=\"\$$var\" 88638c4a8e55Smrg new_libs= 88648c4a8e55Smrg for deplib in $tmp_libs; do 88658c4a8e55Smrg # FIXME: Pedantically, this is the right thing to do, so 88668c4a8e55Smrg # that some nasty dependency loop isn't accidentally 88678c4a8e55Smrg # broken: 88688c4a8e55Smrg #new_libs="$deplib $new_libs" 88698c4a8e55Smrg # Pragmatically, this seems to cause very few problems in 88708c4a8e55Smrg # practice: 88718c4a8e55Smrg case $deplib in 88728c4a8e55Smrg -L*) new_libs="$deplib $new_libs" ;; 88738c4a8e55Smrg -R*) ;; 88748c4a8e55Smrg *) 88758c4a8e55Smrg # And here is the reason: when a library appears more 88768c4a8e55Smrg # than once as an explicit dependence of a library, or 88778c4a8e55Smrg # is implicitly linked in more than once by the 88788c4a8e55Smrg # compiler, it is considered special, and multiple 88798c4a8e55Smrg # occurrences thereof are not removed. Compare this 88808c4a8e55Smrg # with having the same library being listed as a 88818c4a8e55Smrg # dependency of multiple other libraries: in this case, 88828c4a8e55Smrg # we know (pedantically, we assume) the library does not 88838c4a8e55Smrg # need to be listed more than once, so we keep only the 88848c4a8e55Smrg # last copy. This is not always right, but it is rare 88858c4a8e55Smrg # enough that we require users that really mean to play 88868c4a8e55Smrg # such unportable linking tricks to link the library 88878c4a8e55Smrg # using -Wl,-lname, so that libtool does not consider it 88888c4a8e55Smrg # for duplicate removal. 88898c4a8e55Smrg case " $specialdeplibs " in 88908c4a8e55Smrg *" $deplib "*) new_libs="$deplib $new_libs" ;; 88918c4a8e55Smrg *) 88928c4a8e55Smrg case " $new_libs " in 88938c4a8e55Smrg *" $deplib "*) ;; 88948c4a8e55Smrg *) new_libs="$deplib $new_libs" ;; 88958c4a8e55Smrg esac 88968c4a8e55Smrg ;; 88978c4a8e55Smrg esac 88988c4a8e55Smrg ;; 88998c4a8e55Smrg esac 89008c4a8e55Smrg done 89018c4a8e55Smrg tmp_libs= 89028c4a8e55Smrg for deplib in $new_libs; do 89038c4a8e55Smrg case $deplib in 89048c4a8e55Smrg -L*) 89058c4a8e55Smrg case " $tmp_libs " in 89068c4a8e55Smrg *" $deplib "*) ;; 8907bd23fbfaSmrg *) func_append tmp_libs " $deplib" ;; 89088c4a8e55Smrg esac 89098c4a8e55Smrg ;; 8910bd23fbfaSmrg *) func_append tmp_libs " $deplib" ;; 89118c4a8e55Smrg esac 89128c4a8e55Smrg done 89138c4a8e55Smrg eval $var=\"$tmp_libs\" 89148c4a8e55Smrg done # for var 89158c4a8e55Smrg fi 89163169be4bSmrg 89173169be4bSmrg # Add Sun CC postdeps if required: 89183169be4bSmrg test CXX = "$tagname" && { 89193169be4bSmrg case $host_os in 89203169be4bSmrg linux*) 89218d0bc965Smrg case `$CC -V 2>&1 | $SED 5q` in 89223169be4bSmrg *Sun\ C*) # Sun C++ 5.9 89233169be4bSmrg func_suncc_cstd_abi 89243169be4bSmrg 89253169be4bSmrg if test no != "$suncc_use_cstd_abi"; then 89263169be4bSmrg func_append postdeps ' -library=Cstd -library=Crun' 89273169be4bSmrg fi 89283169be4bSmrg ;; 89293169be4bSmrg esac 89303169be4bSmrg ;; 89313169be4bSmrg 89323169be4bSmrg solaris*) 89333169be4bSmrg func_cc_basename "$CC" 89343169be4bSmrg case $func_cc_basename_result in 89353169be4bSmrg CC* | sunCC*) 89363169be4bSmrg func_suncc_cstd_abi 89373169be4bSmrg 89383169be4bSmrg if test no != "$suncc_use_cstd_abi"; then 89393169be4bSmrg func_append postdeps ' -library=Cstd -library=Crun' 89403169be4bSmrg fi 89413169be4bSmrg ;; 89423169be4bSmrg esac 89433169be4bSmrg ;; 89443169be4bSmrg esac 89453169be4bSmrg } 89463169be4bSmrg 89478c4a8e55Smrg # Last step: remove runtime libs from dependency_libs 89488c4a8e55Smrg # (they stay in deplibs) 89498c4a8e55Smrg tmp_libs= 89503169be4bSmrg for i in $dependency_libs; do 89518c4a8e55Smrg case " $predeps $postdeps $compiler_lib_search_path " in 89528c4a8e55Smrg *" $i "*) 89533169be4bSmrg i= 89548c4a8e55Smrg ;; 89558c4a8e55Smrg esac 89563169be4bSmrg if test -n "$i"; then 8957bd23fbfaSmrg func_append tmp_libs " $i" 89588c4a8e55Smrg fi 89598c4a8e55Smrg done 89608c4a8e55Smrg dependency_libs=$tmp_libs 89618c4a8e55Smrg done # for pass 89623169be4bSmrg if test prog = "$linkmode"; then 89633169be4bSmrg dlfiles=$newdlfiles 89648c4a8e55Smrg fi 89653169be4bSmrg if test prog = "$linkmode" || test lib = "$linkmode"; then 89663169be4bSmrg dlprefiles=$newdlprefiles 89678c4a8e55Smrg fi 89688c4a8e55Smrg 89698c4a8e55Smrg case $linkmode in 89708c4a8e55Smrg oldlib) 89713169be4bSmrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 89723169be4bSmrg func_warning "'-dlopen' is ignored for archives" 89738c4a8e55Smrg fi 89748c4a8e55Smrg 89758c4a8e55Smrg case " $deplibs" in 89768c4a8e55Smrg *\ -l* | *\ -L*) 89773169be4bSmrg func_warning "'-l' and '-L' are ignored for archives" ;; 89788c4a8e55Smrg esac 89798c4a8e55Smrg 89808c4a8e55Smrg test -n "$rpath" && \ 89813169be4bSmrg func_warning "'-rpath' is ignored for archives" 89828c4a8e55Smrg 89838c4a8e55Smrg test -n "$xrpath" && \ 89843169be4bSmrg func_warning "'-R' is ignored for archives" 89858c4a8e55Smrg 89868c4a8e55Smrg test -n "$vinfo" && \ 89873169be4bSmrg func_warning "'-version-info/-version-number' is ignored for archives" 89888c4a8e55Smrg 89898c4a8e55Smrg test -n "$release" && \ 89903169be4bSmrg func_warning "'-release' is ignored for archives" 89918c4a8e55Smrg 89928c4a8e55Smrg test -n "$export_symbols$export_symbols_regex" && \ 89933169be4bSmrg func_warning "'-export-symbols' is ignored for archives" 89948c4a8e55Smrg 89958c4a8e55Smrg # Now set the variables for building old libraries. 89968c4a8e55Smrg build_libtool_libs=no 89973169be4bSmrg oldlibs=$output 8998bd23fbfaSmrg func_append objs "$old_deplibs" 89998c4a8e55Smrg ;; 90008c4a8e55Smrg 90018c4a8e55Smrg lib) 90023169be4bSmrg # Make sure we only generate libraries of the form 'libNAME.la'. 90038c4a8e55Smrg case $outputname in 90048c4a8e55Smrg lib*) 90058c4a8e55Smrg func_stripname 'lib' '.la' "$outputname" 90068c4a8e55Smrg name=$func_stripname_result 90078c4a8e55Smrg eval shared_ext=\"$shrext_cmds\" 90088c4a8e55Smrg eval libname=\"$libname_spec\" 90098c4a8e55Smrg ;; 90108c4a8e55Smrg *) 90113169be4bSmrg test no = "$module" \ 90123169be4bSmrg && func_fatal_help "libtool library '$output' must begin with 'lib'" 90138c4a8e55Smrg 90143169be4bSmrg if test no != "$need_lib_prefix"; then 90158c4a8e55Smrg # Add the "lib" prefix for modules if required 90168c4a8e55Smrg func_stripname '' '.la' "$outputname" 90178c4a8e55Smrg name=$func_stripname_result 90188c4a8e55Smrg eval shared_ext=\"$shrext_cmds\" 90198c4a8e55Smrg eval libname=\"$libname_spec\" 90208c4a8e55Smrg else 90218c4a8e55Smrg func_stripname '' '.la' "$outputname" 90228c4a8e55Smrg libname=$func_stripname_result 90238c4a8e55Smrg fi 90248c4a8e55Smrg ;; 90258c4a8e55Smrg esac 90268c4a8e55Smrg 90278c4a8e55Smrg if test -n "$objs"; then 90283169be4bSmrg if test pass_all != "$deplibs_check_method"; then 90293169be4bSmrg func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs" 90308c4a8e55Smrg else 9031706b6b52Smrg echo 90328c4a8e55Smrg $ECHO "*** Warning: Linking the shared library $output against the non-libtool" 90338c4a8e55Smrg $ECHO "*** objects $objs is not portable!" 9034bd23fbfaSmrg func_append libobjs " $objs" 90358c4a8e55Smrg fi 90368c4a8e55Smrg fi 90378c4a8e55Smrg 90383169be4bSmrg test no = "$dlself" \ 90393169be4bSmrg || func_warning "'-dlopen self' is ignored for libtool libraries" 90408c4a8e55Smrg 90418c4a8e55Smrg set dummy $rpath 90428c4a8e55Smrg shift 90433169be4bSmrg test 1 -lt "$#" \ 90443169be4bSmrg && func_warning "ignoring multiple '-rpath's for a libtool library" 90458c4a8e55Smrg 90463169be4bSmrg install_libdir=$1 90478c4a8e55Smrg 90488c4a8e55Smrg oldlibs= 90498c4a8e55Smrg if test -z "$rpath"; then 90503169be4bSmrg if test yes = "$build_libtool_libs"; then 90518c4a8e55Smrg # Building a libtool convenience library. 90523169be4bSmrg # Some compilers have problems with a '.al' extension so 90538c4a8e55Smrg # convenience libraries should have the same extension an 90548c4a8e55Smrg # archive normally would. 90558c4a8e55Smrg oldlibs="$output_objdir/$libname.$libext $oldlibs" 90568c4a8e55Smrg build_libtool_libs=convenience 90578c4a8e55Smrg build_old_libs=yes 90588c4a8e55Smrg fi 90598c4a8e55Smrg 90608c4a8e55Smrg test -n "$vinfo" && \ 90613169be4bSmrg func_warning "'-version-info/-version-number' is ignored for convenience libraries" 90628c4a8e55Smrg 90638c4a8e55Smrg test -n "$release" && \ 90643169be4bSmrg func_warning "'-release' is ignored for convenience libraries" 90658c4a8e55Smrg else 90668c4a8e55Smrg 90678c4a8e55Smrg # Parse the version information argument. 90683169be4bSmrg save_ifs=$IFS; IFS=: 90698c4a8e55Smrg set dummy $vinfo 0 0 0 90708c4a8e55Smrg shift 90713169be4bSmrg IFS=$save_ifs 90728c4a8e55Smrg 90738c4a8e55Smrg test -n "$7" && \ 90743169be4bSmrg func_fatal_help "too many parameters to '-version-info'" 90758c4a8e55Smrg 90768c4a8e55Smrg # convert absolute version numbers to libtool ages 90778c4a8e55Smrg # this retains compatibility with .la files and attempts 90788c4a8e55Smrg # to make the code below a bit more comprehensible 90798c4a8e55Smrg 90808c4a8e55Smrg case $vinfo_number in 90818c4a8e55Smrg yes) 90823169be4bSmrg number_major=$1 90833169be4bSmrg number_minor=$2 90843169be4bSmrg number_revision=$3 90858c4a8e55Smrg # 90868c4a8e55Smrg # There are really only two kinds -- those that 90878c4a8e55Smrg # use the current revision as the major version 90888c4a8e55Smrg # and those that subtract age and use age as 90898c4a8e55Smrg # a minor version. But, then there is irix 90903169be4bSmrg # that has an extra 1 added just for fun 90918c4a8e55Smrg # 90928c4a8e55Smrg case $version_type in 90930597fb56Smrg # correct linux to gnu/linux during the next big refactor 90948d0bc965Smrg darwin|freebsd-elf|linux|midnightbsd-elf|osf|windows|none) 90958c4a8e55Smrg func_arith $number_major + $number_minor 90968c4a8e55Smrg current=$func_arith_result 90973169be4bSmrg age=$number_minor 90983169be4bSmrg revision=$number_revision 90998c4a8e55Smrg ;; 91003169be4bSmrg freebsd-aout|qnx|sunos) 91013169be4bSmrg current=$number_major 91023169be4bSmrg revision=$number_minor 91033169be4bSmrg age=0 91048c4a8e55Smrg ;; 91058c4a8e55Smrg irix|nonstopux) 91068c4a8e55Smrg func_arith $number_major + $number_minor 91078c4a8e55Smrg current=$func_arith_result 91083169be4bSmrg age=$number_minor 91093169be4bSmrg revision=$number_minor 91108c4a8e55Smrg lt_irix_increment=no 91118c4a8e55Smrg ;; 91128c4a8e55Smrg esac 91138c4a8e55Smrg ;; 91148c4a8e55Smrg no) 91153169be4bSmrg current=$1 91163169be4bSmrg revision=$2 91173169be4bSmrg age=$3 91188c4a8e55Smrg ;; 91198c4a8e55Smrg esac 91208c4a8e55Smrg 91218c4a8e55Smrg # Check that each of the things are valid numbers. 91228c4a8e55Smrg case $current in 91238c4a8e55Smrg 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]) ;; 91248c4a8e55Smrg *) 91253169be4bSmrg func_error "CURRENT '$current' must be a nonnegative integer" 91263169be4bSmrg func_fatal_error "'$vinfo' is not valid version information" 91278c4a8e55Smrg ;; 91288c4a8e55Smrg esac 91298c4a8e55Smrg 91308c4a8e55Smrg case $revision in 91318c4a8e55Smrg 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]) ;; 91328c4a8e55Smrg *) 91333169be4bSmrg func_error "REVISION '$revision' must be a nonnegative integer" 91343169be4bSmrg func_fatal_error "'$vinfo' is not valid version information" 91358c4a8e55Smrg ;; 91368c4a8e55Smrg esac 91378c4a8e55Smrg 91388c4a8e55Smrg case $age in 91398c4a8e55Smrg 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]) ;; 91408c4a8e55Smrg *) 91413169be4bSmrg func_error "AGE '$age' must be a nonnegative integer" 91423169be4bSmrg func_fatal_error "'$vinfo' is not valid version information" 91438c4a8e55Smrg ;; 91448c4a8e55Smrg esac 91458c4a8e55Smrg 91468c4a8e55Smrg if test "$age" -gt "$current"; then 91473169be4bSmrg func_error "AGE '$age' is greater than the current interface number '$current'" 91483169be4bSmrg func_fatal_error "'$vinfo' is not valid version information" 91498c4a8e55Smrg fi 91508c4a8e55Smrg 91518c4a8e55Smrg # Calculate the version variables. 91528c4a8e55Smrg major= 91538c4a8e55Smrg versuffix= 91548c4a8e55Smrg verstring= 91558c4a8e55Smrg case $version_type in 91568c4a8e55Smrg none) ;; 91578c4a8e55Smrg 91588c4a8e55Smrg darwin) 91598c4a8e55Smrg # Like Linux, but with the current version available in 91608c4a8e55Smrg # verstring for coding it into the library header 91618c4a8e55Smrg func_arith $current - $age 91628c4a8e55Smrg major=.$func_arith_result 91633169be4bSmrg versuffix=$major.$age.$revision 91648c4a8e55Smrg # Darwin ld doesn't like 0 for these options... 91658c4a8e55Smrg func_arith $current + 1 91668c4a8e55Smrg minor_current=$func_arith_result 91673169be4bSmrg xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" 91688c4a8e55Smrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 91693169be4bSmrg # On Darwin other compilers 91703169be4bSmrg case $CC in 91713169be4bSmrg nagfor*) 91723169be4bSmrg verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" 91733169be4bSmrg ;; 91743169be4bSmrg *) 91753169be4bSmrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 91763169be4bSmrg ;; 91773169be4bSmrg esac 91788c4a8e55Smrg ;; 91798c4a8e55Smrg 91808c4a8e55Smrg freebsd-aout) 91813169be4bSmrg major=.$current 91823169be4bSmrg versuffix=.$current.$revision 91838c4a8e55Smrg ;; 91848c4a8e55Smrg 91858d0bc965Smrg freebsd-elf | midnightbsd-elf) 91863169be4bSmrg func_arith $current - $age 91873169be4bSmrg major=.$func_arith_result 91883169be4bSmrg versuffix=$major.$age.$revision 91898c4a8e55Smrg ;; 91908c4a8e55Smrg 91918c4a8e55Smrg irix | nonstopux) 91923169be4bSmrg if test no = "$lt_irix_increment"; then 91938c4a8e55Smrg func_arith $current - $age 91948c4a8e55Smrg else 91958c4a8e55Smrg func_arith $current - $age + 1 91968c4a8e55Smrg fi 91978c4a8e55Smrg major=$func_arith_result 91988c4a8e55Smrg 91998c4a8e55Smrg case $version_type in 92008c4a8e55Smrg nonstopux) verstring_prefix=nonstopux ;; 92018c4a8e55Smrg *) verstring_prefix=sgi ;; 92028c4a8e55Smrg esac 92033169be4bSmrg verstring=$verstring_prefix$major.$revision 92048c4a8e55Smrg 92058c4a8e55Smrg # Add in all the interfaces that we are compatible with. 92068c4a8e55Smrg loop=$revision 92073169be4bSmrg while test 0 -ne "$loop"; do 92088c4a8e55Smrg func_arith $revision - $loop 92098c4a8e55Smrg iface=$func_arith_result 92108c4a8e55Smrg func_arith $loop - 1 92118c4a8e55Smrg loop=$func_arith_result 92123169be4bSmrg verstring=$verstring_prefix$major.$iface:$verstring 92138c4a8e55Smrg done 92148c4a8e55Smrg 92153169be4bSmrg # Before this point, $major must not contain '.'. 92168c4a8e55Smrg major=.$major 92173169be4bSmrg versuffix=$major.$revision 92188c4a8e55Smrg ;; 92198c4a8e55Smrg 92200597fb56Smrg linux) # correct to gnu/linux during the next big refactor 92218c4a8e55Smrg func_arith $current - $age 92228c4a8e55Smrg major=.$func_arith_result 92233169be4bSmrg versuffix=$major.$age.$revision 92248c4a8e55Smrg ;; 92258c4a8e55Smrg 92268c4a8e55Smrg osf) 92278c4a8e55Smrg func_arith $current - $age 92288c4a8e55Smrg major=.$func_arith_result 92293169be4bSmrg versuffix=.$current.$age.$revision 92303169be4bSmrg verstring=$current.$age.$revision 92318c4a8e55Smrg 92328c4a8e55Smrg # Add in all the interfaces that we are compatible with. 92338c4a8e55Smrg loop=$age 92343169be4bSmrg while test 0 -ne "$loop"; do 92358c4a8e55Smrg func_arith $current - $loop 92368c4a8e55Smrg iface=$func_arith_result 92378c4a8e55Smrg func_arith $loop - 1 92388c4a8e55Smrg loop=$func_arith_result 92393169be4bSmrg verstring=$verstring:$iface.0 92408c4a8e55Smrg done 92418c4a8e55Smrg 92428c4a8e55Smrg # Make executables depend on our current version. 92433169be4bSmrg func_append verstring ":$current.0" 92448c4a8e55Smrg ;; 92458c4a8e55Smrg 92468c4a8e55Smrg qnx) 92473169be4bSmrg major=.$current 92483169be4bSmrg versuffix=.$current 92493169be4bSmrg ;; 92503169be4bSmrg 92513169be4bSmrg sco) 92523169be4bSmrg major=.$current 92533169be4bSmrg versuffix=.$current 92548c4a8e55Smrg ;; 92558c4a8e55Smrg 92568c4a8e55Smrg sunos) 92573169be4bSmrg major=.$current 92583169be4bSmrg versuffix=.$current.$revision 92598c4a8e55Smrg ;; 92608c4a8e55Smrg 92618c4a8e55Smrg windows) 92628c4a8e55Smrg # Use '-' rather than '.', since we only want one 92633169be4bSmrg # extension on DOS 8.3 file systems. 92648c4a8e55Smrg func_arith $current - $age 92658c4a8e55Smrg major=$func_arith_result 92663169be4bSmrg versuffix=-$major 92678c4a8e55Smrg ;; 92688c4a8e55Smrg 92698c4a8e55Smrg *) 92703169be4bSmrg func_fatal_configuration "unknown library version type '$version_type'" 92718c4a8e55Smrg ;; 92728c4a8e55Smrg esac 92738c4a8e55Smrg 92748c4a8e55Smrg # Clear the version info if we defaulted, and they specified a release. 92758c4a8e55Smrg if test -z "$vinfo" && test -n "$release"; then 92768c4a8e55Smrg major= 92778c4a8e55Smrg case $version_type in 92788c4a8e55Smrg darwin) 92798c4a8e55Smrg # we can't check for "0.0" in archive_cmds due to quoting 92808c4a8e55Smrg # problems, so we reset it completely 92818c4a8e55Smrg verstring= 92828c4a8e55Smrg ;; 92838c4a8e55Smrg *) 92843169be4bSmrg verstring=0.0 92858c4a8e55Smrg ;; 92868c4a8e55Smrg esac 92873169be4bSmrg if test no = "$need_version"; then 92888c4a8e55Smrg versuffix= 92898c4a8e55Smrg else 92903169be4bSmrg versuffix=.0.0 92918c4a8e55Smrg fi 92928c4a8e55Smrg fi 92938c4a8e55Smrg 92948c4a8e55Smrg # Remove version info from name if versioning should be avoided 92953169be4bSmrg if test yes,no = "$avoid_version,$need_version"; then 92968c4a8e55Smrg major= 92978c4a8e55Smrg versuffix= 92983169be4bSmrg verstring= 92998c4a8e55Smrg fi 93008c4a8e55Smrg 93018c4a8e55Smrg # Check to see if the archive will have undefined symbols. 93023169be4bSmrg if test yes = "$allow_undefined"; then 93033169be4bSmrg if test unsupported = "$allow_undefined_flag"; then 93043169be4bSmrg if test yes = "$build_old_libs"; then 93053169be4bSmrg func_warning "undefined symbols not allowed in $host shared libraries; building static only" 93063169be4bSmrg build_libtool_libs=no 93073169be4bSmrg else 93083169be4bSmrg func_fatal_error "can't build $host shared library unless -no-undefined is specified" 93093169be4bSmrg fi 93108c4a8e55Smrg fi 93118c4a8e55Smrg else 93128c4a8e55Smrg # Don't allow undefined symbols. 93133169be4bSmrg allow_undefined_flag=$no_undefined_flag 93148c4a8e55Smrg fi 93158c4a8e55Smrg 93168c4a8e55Smrg fi 93178c4a8e55Smrg 93183169be4bSmrg func_generate_dlsyms "$libname" "$libname" : 9319bd23fbfaSmrg func_append libobjs " $symfileobj" 93203169be4bSmrg test " " = "$libobjs" && libobjs= 93218c4a8e55Smrg 93223169be4bSmrg if test relink != "$opt_mode"; then 93238c4a8e55Smrg # Remove our outputs, but don't remove object files since they 93248c4a8e55Smrg # may have been created when compiling PIC objects. 93258c4a8e55Smrg removelist= 93268c4a8e55Smrg tempremovelist=`$ECHO "$output_objdir/*"` 93278c4a8e55Smrg for p in $tempremovelist; do 93288c4a8e55Smrg case $p in 93298c4a8e55Smrg *.$objext | *.gcno) 93308c4a8e55Smrg ;; 93313169be4bSmrg $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/$libname$release.*) 93323169be4bSmrg if test -n "$precious_files_regex"; then 93338c4a8e55Smrg if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 93348c4a8e55Smrg then 93358c4a8e55Smrg continue 93368c4a8e55Smrg fi 93378c4a8e55Smrg fi 9338bd23fbfaSmrg func_append removelist " $p" 93398c4a8e55Smrg ;; 93408c4a8e55Smrg *) ;; 93418c4a8e55Smrg esac 93428c4a8e55Smrg done 93438c4a8e55Smrg test -n "$removelist" && \ 93448c4a8e55Smrg func_show_eval "${RM}r \$removelist" 93458c4a8e55Smrg fi 93468c4a8e55Smrg 93478c4a8e55Smrg # Now set the variables for building old libraries. 93483169be4bSmrg if test yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; then 9349bd23fbfaSmrg func_append oldlibs " $output_objdir/$libname.$libext" 93508c4a8e55Smrg 93518c4a8e55Smrg # Transform .lo files to .o files. 93523169be4bSmrg oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; $lo2o" | $NL2SP` 93538c4a8e55Smrg fi 93548c4a8e55Smrg 93558c4a8e55Smrg # Eliminate all temporary directories. 93568c4a8e55Smrg #for path in $notinst_path; do 9357706b6b52Smrg # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` 9358706b6b52Smrg # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` 9359706b6b52Smrg # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` 93608c4a8e55Smrg #done 93618c4a8e55Smrg 93628c4a8e55Smrg if test -n "$xrpath"; then 93638c4a8e55Smrg # If the user specified any rpath flags, then add them. 93648c4a8e55Smrg temp_xrpath= 93658c4a8e55Smrg for libdir in $xrpath; do 9366bd23fbfaSmrg func_replace_sysroot "$libdir" 9367bd23fbfaSmrg func_append temp_xrpath " -R$func_replace_sysroot_result" 93688c4a8e55Smrg case "$finalize_rpath " in 93698c4a8e55Smrg *" $libdir "*) ;; 9370bd23fbfaSmrg *) func_append finalize_rpath " $libdir" ;; 93718c4a8e55Smrg esac 93728c4a8e55Smrg done 93733169be4bSmrg if test yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; then 93748c4a8e55Smrg dependency_libs="$temp_xrpath $dependency_libs" 93758c4a8e55Smrg fi 93768c4a8e55Smrg fi 93778c4a8e55Smrg 93788c4a8e55Smrg # Make sure dlfiles contains only unique files that won't be dlpreopened 93793169be4bSmrg old_dlfiles=$dlfiles 93808c4a8e55Smrg dlfiles= 93818c4a8e55Smrg for lib in $old_dlfiles; do 93828c4a8e55Smrg case " $dlprefiles $dlfiles " in 93838c4a8e55Smrg *" $lib "*) ;; 9384bd23fbfaSmrg *) func_append dlfiles " $lib" ;; 93858c4a8e55Smrg esac 93868c4a8e55Smrg done 93878c4a8e55Smrg 93888c4a8e55Smrg # Make sure dlprefiles contains only unique files 93893169be4bSmrg old_dlprefiles=$dlprefiles 93908c4a8e55Smrg dlprefiles= 93918c4a8e55Smrg for lib in $old_dlprefiles; do 93928c4a8e55Smrg case "$dlprefiles " in 93938c4a8e55Smrg *" $lib "*) ;; 9394bd23fbfaSmrg *) func_append dlprefiles " $lib" ;; 93958c4a8e55Smrg esac 93968c4a8e55Smrg done 93978c4a8e55Smrg 93983169be4bSmrg if test yes = "$build_libtool_libs"; then 93998c4a8e55Smrg if test -n "$rpath"; then 94008c4a8e55Smrg case $host in 9401706b6b52Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) 94028c4a8e55Smrg # these systems don't actually have a c library (as such)! 94038c4a8e55Smrg ;; 94048c4a8e55Smrg *-*-rhapsody* | *-*-darwin1.[012]) 94058c4a8e55Smrg # Rhapsody C library is in the System framework 9406bd23fbfaSmrg func_append deplibs " System.ltframework" 94078c4a8e55Smrg ;; 94088c4a8e55Smrg *-*-netbsd*) 94098c4a8e55Smrg # Don't link with libc until the a.out ld.so is fixed. 94108c4a8e55Smrg ;; 94118d0bc965Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-midnightbsd*) 94128c4a8e55Smrg # Do not include libc due to us having libc/libc_r. 94138c4a8e55Smrg ;; 94148c4a8e55Smrg *-*-sco3.2v5* | *-*-sco5v6*) 94158c4a8e55Smrg # Causes problems with __ctype 94168c4a8e55Smrg ;; 94178c4a8e55Smrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 94188c4a8e55Smrg # Compiler inserts libc in the correct place for threads to work 94198c4a8e55Smrg ;; 94208c4a8e55Smrg *) 94218c4a8e55Smrg # Add libc to deplibs on all other systems if necessary. 94223169be4bSmrg if test yes = "$build_libtool_need_lc"; then 9423bd23fbfaSmrg func_append deplibs " -lc" 94248c4a8e55Smrg fi 94258c4a8e55Smrg ;; 94268c4a8e55Smrg esac 94278c4a8e55Smrg fi 94288c4a8e55Smrg 94298c4a8e55Smrg # Transform deplibs into only deplibs that can be linked in shared. 94308c4a8e55Smrg name_save=$name 94318c4a8e55Smrg libname_save=$libname 94328c4a8e55Smrg release_save=$release 94338c4a8e55Smrg versuffix_save=$versuffix 94348c4a8e55Smrg major_save=$major 94358c4a8e55Smrg # I'm not sure if I'm treating the release correctly. I think 94368c4a8e55Smrg # release should show up in the -l (ie -lgmp5) so we don't want to 94378c4a8e55Smrg # add it in twice. Is that correct? 94383169be4bSmrg release= 94393169be4bSmrg versuffix= 94403169be4bSmrg major= 94418c4a8e55Smrg newdeplibs= 94428c4a8e55Smrg droppeddeps=no 94438c4a8e55Smrg case $deplibs_check_method in 94448c4a8e55Smrg pass_all) 94458c4a8e55Smrg # Don't check for shared/static. Everything works. 94468c4a8e55Smrg # This might be a little naive. We might want to check 94478c4a8e55Smrg # whether the library exists or not. But this is on 94488c4a8e55Smrg # osf3 & osf4 and I'm not really sure... Just 94498c4a8e55Smrg # implementing what was already the behavior. 94508c4a8e55Smrg newdeplibs=$deplibs 94518c4a8e55Smrg ;; 94528c4a8e55Smrg test_compile) 94538c4a8e55Smrg # This code stresses the "libraries are programs" paradigm to its 94548c4a8e55Smrg # limits. Maybe even breaks it. We compile a program, linking it 94558c4a8e55Smrg # against the deplibs as a proxy for the library. Then we can check 94568c4a8e55Smrg # whether they linked in statically or dynamically with ldd. 94578c4a8e55Smrg $opt_dry_run || $RM conftest.c 94588c4a8e55Smrg cat > conftest.c <<EOF 94598c4a8e55Smrg int main() { return 0; } 94608c4a8e55SmrgEOF 94618c4a8e55Smrg $opt_dry_run || $RM conftest 94628c4a8e55Smrg if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then 94638c4a8e55Smrg ldd_output=`ldd conftest` 94648c4a8e55Smrg for i in $deplibs; do 94658c4a8e55Smrg case $i in 94668c4a8e55Smrg -l*) 94678c4a8e55Smrg func_stripname -l '' "$i" 94688c4a8e55Smrg name=$func_stripname_result 94693169be4bSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 94708c4a8e55Smrg case " $predeps $postdeps " in 94718c4a8e55Smrg *" $i "*) 9472bd23fbfaSmrg func_append newdeplibs " $i" 94733169be4bSmrg i= 94748c4a8e55Smrg ;; 94758c4a8e55Smrg esac 94768c4a8e55Smrg fi 94773169be4bSmrg if test -n "$i"; then 94788c4a8e55Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 94798c4a8e55Smrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 94808c4a8e55Smrg set dummy $deplib_matches; shift 94818c4a8e55Smrg deplib_match=$1 94823169be4bSmrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then 9483bd23fbfaSmrg func_append newdeplibs " $i" 94848c4a8e55Smrg else 94858c4a8e55Smrg droppeddeps=yes 9486706b6b52Smrg echo 94878c4a8e55Smrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 9488706b6b52Smrg echo "*** I have the capability to make that library automatically link in when" 9489706b6b52Smrg echo "*** you link to this library. But I can only do this if you have a" 9490706b6b52Smrg echo "*** shared version of the library, which I believe you do not have" 9491706b6b52Smrg echo "*** because a test_compile did reveal that the linker did not use it for" 9492706b6b52Smrg echo "*** its dynamic dependency list that programs get resolved with at runtime." 94938c4a8e55Smrg fi 94948c4a8e55Smrg fi 94958c4a8e55Smrg ;; 94968c4a8e55Smrg *) 9497bd23fbfaSmrg func_append newdeplibs " $i" 94988c4a8e55Smrg ;; 94998c4a8e55Smrg esac 95008c4a8e55Smrg done 95018c4a8e55Smrg else 95028c4a8e55Smrg # Error occurred in the first compile. Let's try to salvage 95038c4a8e55Smrg # the situation: Compile a separate program for each library. 95048c4a8e55Smrg for i in $deplibs; do 95058c4a8e55Smrg case $i in 95068c4a8e55Smrg -l*) 95078c4a8e55Smrg func_stripname -l '' "$i" 95088c4a8e55Smrg name=$func_stripname_result 95098c4a8e55Smrg $opt_dry_run || $RM conftest 95108c4a8e55Smrg if $LTCC $LTCFLAGS -o conftest conftest.c $i; then 95118c4a8e55Smrg ldd_output=`ldd conftest` 95123169be4bSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 95138c4a8e55Smrg case " $predeps $postdeps " in 95148c4a8e55Smrg *" $i "*) 9515bd23fbfaSmrg func_append newdeplibs " $i" 95163169be4bSmrg i= 95178c4a8e55Smrg ;; 95188c4a8e55Smrg esac 95198c4a8e55Smrg fi 95203169be4bSmrg if test -n "$i"; then 95218c4a8e55Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 95228c4a8e55Smrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 95238c4a8e55Smrg set dummy $deplib_matches; shift 95248c4a8e55Smrg deplib_match=$1 95253169be4bSmrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then 9526bd23fbfaSmrg func_append newdeplibs " $i" 95278c4a8e55Smrg else 95288c4a8e55Smrg droppeddeps=yes 9529706b6b52Smrg echo 95308c4a8e55Smrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 9531706b6b52Smrg echo "*** I have the capability to make that library automatically link in when" 9532706b6b52Smrg echo "*** you link to this library. But I can only do this if you have a" 9533706b6b52Smrg echo "*** shared version of the library, which you do not appear to have" 9534706b6b52Smrg echo "*** because a test_compile did reveal that the linker did not use this one" 9535706b6b52Smrg echo "*** as a dynamic dependency that programs can get resolved with at runtime." 95368c4a8e55Smrg fi 95378c4a8e55Smrg fi 95388c4a8e55Smrg else 95398c4a8e55Smrg droppeddeps=yes 9540706b6b52Smrg echo 95418c4a8e55Smrg $ECHO "*** Warning! Library $i is needed by this library but I was not able to" 9542706b6b52Smrg echo "*** make it link in! You will probably need to install it or some" 9543706b6b52Smrg echo "*** library that it depends on before this library will be fully" 9544706b6b52Smrg echo "*** functional. Installing it before continuing would be even better." 95458c4a8e55Smrg fi 95468c4a8e55Smrg ;; 95478c4a8e55Smrg *) 9548bd23fbfaSmrg func_append newdeplibs " $i" 95498c4a8e55Smrg ;; 95508c4a8e55Smrg esac 95518c4a8e55Smrg done 95528c4a8e55Smrg fi 95538c4a8e55Smrg ;; 95548c4a8e55Smrg file_magic*) 95558c4a8e55Smrg set dummy $deplibs_check_method; shift 95568c4a8e55Smrg file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 95578c4a8e55Smrg for a_deplib in $deplibs; do 95588c4a8e55Smrg case $a_deplib in 95598c4a8e55Smrg -l*) 95608c4a8e55Smrg func_stripname -l '' "$a_deplib" 95618c4a8e55Smrg name=$func_stripname_result 95623169be4bSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 95638c4a8e55Smrg case " $predeps $postdeps " in 95648c4a8e55Smrg *" $a_deplib "*) 9565bd23fbfaSmrg func_append newdeplibs " $a_deplib" 95663169be4bSmrg a_deplib= 95678c4a8e55Smrg ;; 95688c4a8e55Smrg esac 95698c4a8e55Smrg fi 95703169be4bSmrg if test -n "$a_deplib"; then 95718c4a8e55Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 9572bd23fbfaSmrg if test -n "$file_magic_glob"; then 9573bd23fbfaSmrg libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob` 9574bd23fbfaSmrg else 9575bd23fbfaSmrg libnameglob=$libname 9576bd23fbfaSmrg fi 95773169be4bSmrg test yes = "$want_nocaseglob" && nocaseglob=`shopt -p nocaseglob` 95788c4a8e55Smrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 95793169be4bSmrg if test yes = "$want_nocaseglob"; then 9580bd23fbfaSmrg shopt -s nocaseglob 9581bd23fbfaSmrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 9582bd23fbfaSmrg $nocaseglob 9583bd23fbfaSmrg else 9584bd23fbfaSmrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 9585bd23fbfaSmrg fi 95868c4a8e55Smrg for potent_lib in $potential_libs; do 95878c4a8e55Smrg # Follow soft links. 95888c4a8e55Smrg if ls -lLd "$potent_lib" 2>/dev/null | 95898c4a8e55Smrg $GREP " -> " >/dev/null; then 95908c4a8e55Smrg continue 95918c4a8e55Smrg fi 95928c4a8e55Smrg # The statement above tries to avoid entering an 95938c4a8e55Smrg # endless loop below, in case of cyclic links. 95948c4a8e55Smrg # We might still enter an endless loop, since a link 95958c4a8e55Smrg # loop can be closed while we follow links, 95968c4a8e55Smrg # but so what? 95973169be4bSmrg potlib=$potent_lib 95988c4a8e55Smrg while test -h "$potlib" 2>/dev/null; do 95993169be4bSmrg potliblink=`ls -ld $potlib | $SED 's/.* -> //'` 96008c4a8e55Smrg case $potliblink in 96013169be4bSmrg [\\/]* | [A-Za-z]:[\\/]*) potlib=$potliblink;; 96023169be4bSmrg *) potlib=`$ECHO "$potlib" | $SED 's|[^/]*$||'`"$potliblink";; 96038c4a8e55Smrg esac 96048c4a8e55Smrg done 96058c4a8e55Smrg if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | 96068c4a8e55Smrg $SED -e 10q | 96078c4a8e55Smrg $EGREP "$file_magic_regex" > /dev/null; then 9608bd23fbfaSmrg func_append newdeplibs " $a_deplib" 96093169be4bSmrg a_deplib= 96108c4a8e55Smrg break 2 96118c4a8e55Smrg fi 96128c4a8e55Smrg done 96138c4a8e55Smrg done 96148c4a8e55Smrg fi 96153169be4bSmrg if test -n "$a_deplib"; then 96168c4a8e55Smrg droppeddeps=yes 9617706b6b52Smrg echo 96188c4a8e55Smrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 9619706b6b52Smrg echo "*** I have the capability to make that library automatically link in when" 9620706b6b52Smrg echo "*** you link to this library. But I can only do this if you have a" 9621706b6b52Smrg echo "*** shared version of the library, which you do not appear to have" 9622706b6b52Smrg echo "*** because I did check the linker path looking for a file starting" 96233169be4bSmrg if test -z "$potlib"; then 96248c4a8e55Smrg $ECHO "*** with $libname but no candidates were found. (...for file magic test)" 96258c4a8e55Smrg else 96268c4a8e55Smrg $ECHO "*** with $libname and none of the candidates passed a file format test" 96278c4a8e55Smrg $ECHO "*** using a file magic. Last file checked: $potlib" 96288c4a8e55Smrg fi 96298c4a8e55Smrg fi 96308c4a8e55Smrg ;; 96318c4a8e55Smrg *) 96328c4a8e55Smrg # Add a -L argument. 9633bd23fbfaSmrg func_append newdeplibs " $a_deplib" 96348c4a8e55Smrg ;; 96358c4a8e55Smrg esac 96368c4a8e55Smrg done # Gone through all deplibs. 96378c4a8e55Smrg ;; 96388c4a8e55Smrg match_pattern*) 96398c4a8e55Smrg set dummy $deplibs_check_method; shift 96408c4a8e55Smrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 96418c4a8e55Smrg for a_deplib in $deplibs; do 96428c4a8e55Smrg case $a_deplib in 96438c4a8e55Smrg -l*) 96448c4a8e55Smrg func_stripname -l '' "$a_deplib" 96458c4a8e55Smrg name=$func_stripname_result 96463169be4bSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 96478c4a8e55Smrg case " $predeps $postdeps " in 96488c4a8e55Smrg *" $a_deplib "*) 9649bd23fbfaSmrg func_append newdeplibs " $a_deplib" 96503169be4bSmrg a_deplib= 96518c4a8e55Smrg ;; 96528c4a8e55Smrg esac 96538c4a8e55Smrg fi 96543169be4bSmrg if test -n "$a_deplib"; then 96558c4a8e55Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 96568c4a8e55Smrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 96578c4a8e55Smrg potential_libs=`ls $i/$libname[.-]* 2>/dev/null` 96588c4a8e55Smrg for potent_lib in $potential_libs; do 96593169be4bSmrg potlib=$potent_lib # see symlink-check above in file_magic test 9660706b6b52Smrg if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ 96618c4a8e55Smrg $EGREP "$match_pattern_regex" > /dev/null; then 9662bd23fbfaSmrg func_append newdeplibs " $a_deplib" 96633169be4bSmrg a_deplib= 96648c4a8e55Smrg break 2 96658c4a8e55Smrg fi 96668c4a8e55Smrg done 96678c4a8e55Smrg done 96688c4a8e55Smrg fi 96693169be4bSmrg if test -n "$a_deplib"; then 96708c4a8e55Smrg droppeddeps=yes 9671706b6b52Smrg echo 96728c4a8e55Smrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 9673706b6b52Smrg echo "*** I have the capability to make that library automatically link in when" 9674706b6b52Smrg echo "*** you link to this library. But I can only do this if you have a" 9675706b6b52Smrg echo "*** shared version of the library, which you do not appear to have" 9676706b6b52Smrg echo "*** because I did check the linker path looking for a file starting" 96773169be4bSmrg if test -z "$potlib"; then 96788c4a8e55Smrg $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" 96798c4a8e55Smrg else 96808c4a8e55Smrg $ECHO "*** with $libname and none of the candidates passed a file format test" 96818c4a8e55Smrg $ECHO "*** using a regex pattern. Last file checked: $potlib" 96828c4a8e55Smrg fi 96838c4a8e55Smrg fi 96848c4a8e55Smrg ;; 96858c4a8e55Smrg *) 96868c4a8e55Smrg # Add a -L argument. 9687bd23fbfaSmrg func_append newdeplibs " $a_deplib" 96888c4a8e55Smrg ;; 96898c4a8e55Smrg esac 96908c4a8e55Smrg done # Gone through all deplibs. 96918c4a8e55Smrg ;; 96928c4a8e55Smrg none | unknown | *) 96933169be4bSmrg newdeplibs= 9694706b6b52Smrg tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` 96953169be4bSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 96963169be4bSmrg for i in $predeps $postdeps; do 96978c4a8e55Smrg # can't use Xsed below, because $i might contain '/' 96983169be4bSmrg tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s|$i||"` 96998c4a8e55Smrg done 97008c4a8e55Smrg fi 9701706b6b52Smrg case $tmp_deplibs in 9702706b6b52Smrg *[!\ \ ]*) 9703706b6b52Smrg echo 97043169be4bSmrg if test none = "$deplibs_check_method"; then 9705706b6b52Smrg echo "*** Warning: inter-library dependencies are not supported in this platform." 97068c4a8e55Smrg else 9707706b6b52Smrg echo "*** Warning: inter-library dependencies are not known to be supported." 97088c4a8e55Smrg fi 9709706b6b52Smrg echo "*** All declared inter-library dependencies are being dropped." 97108c4a8e55Smrg droppeddeps=yes 9711706b6b52Smrg ;; 9712706b6b52Smrg esac 97138c4a8e55Smrg ;; 97148c4a8e55Smrg esac 97158c4a8e55Smrg versuffix=$versuffix_save 97168c4a8e55Smrg major=$major_save 97178c4a8e55Smrg release=$release_save 97188c4a8e55Smrg libname=$libname_save 97198c4a8e55Smrg name=$name_save 97208c4a8e55Smrg 97218c4a8e55Smrg case $host in 97228c4a8e55Smrg *-*-rhapsody* | *-*-darwin1.[012]) 97238c4a8e55Smrg # On Rhapsody replace the C library with the System framework 9724706b6b52Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` 97258c4a8e55Smrg ;; 97268c4a8e55Smrg esac 97278c4a8e55Smrg 97283169be4bSmrg if test yes = "$droppeddeps"; then 97293169be4bSmrg if test yes = "$module"; then 9730706b6b52Smrg echo 9731706b6b52Smrg echo "*** Warning: libtool could not satisfy all declared inter-library" 97328c4a8e55Smrg $ECHO "*** dependencies of module $libname. Therefore, libtool will create" 9733706b6b52Smrg echo "*** a static module, that should work as long as the dlopening" 9734706b6b52Smrg echo "*** application is linked with the -dlopen flag." 97358c4a8e55Smrg if test -z "$global_symbol_pipe"; then 9736706b6b52Smrg echo 9737706b6b52Smrg echo "*** However, this would only work if libtool was able to extract symbol" 97383169be4bSmrg echo "*** lists from a program, using 'nm' or equivalent, but libtool could" 9739706b6b52Smrg echo "*** not find such a program. So, this module is probably useless." 97403169be4bSmrg echo "*** 'nm' from GNU binutils and a full rebuild may help." 97418c4a8e55Smrg fi 97423169be4bSmrg if test no = "$build_old_libs"; then 97433169be4bSmrg oldlibs=$output_objdir/$libname.$libext 97448c4a8e55Smrg build_libtool_libs=module 97458c4a8e55Smrg build_old_libs=yes 97468c4a8e55Smrg else 97478c4a8e55Smrg build_libtool_libs=no 97488c4a8e55Smrg fi 97498c4a8e55Smrg else 9750706b6b52Smrg echo "*** The inter-library dependencies that have been dropped here will be" 9751706b6b52Smrg echo "*** automatically added whenever a program is linked with this library" 9752706b6b52Smrg echo "*** or is declared to -dlopen it." 97538c4a8e55Smrg 97543169be4bSmrg if test no = "$allow_undefined"; then 9755706b6b52Smrg echo 9756706b6b52Smrg echo "*** Since this library must not contain undefined symbols," 9757706b6b52Smrg echo "*** because either the platform does not support them or" 9758706b6b52Smrg echo "*** it was explicitly requested with -no-undefined," 9759706b6b52Smrg echo "*** libtool will only create a static version of it." 97603169be4bSmrg if test no = "$build_old_libs"; then 97613169be4bSmrg oldlibs=$output_objdir/$libname.$libext 97628c4a8e55Smrg build_libtool_libs=module 97638c4a8e55Smrg build_old_libs=yes 97648c4a8e55Smrg else 97658c4a8e55Smrg build_libtool_libs=no 97668c4a8e55Smrg fi 97678c4a8e55Smrg fi 97688c4a8e55Smrg fi 97698c4a8e55Smrg fi 97708c4a8e55Smrg # Done checking deplibs! 97718c4a8e55Smrg deplibs=$newdeplibs 97728c4a8e55Smrg fi 97738c4a8e55Smrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 97748c4a8e55Smrg case $host in 97758c4a8e55Smrg *-*-darwin*) 9776706b6b52Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 9777706b6b52Smrg new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 9778706b6b52Smrg deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 97798c4a8e55Smrg ;; 97808c4a8e55Smrg esac 97818c4a8e55Smrg 97828c4a8e55Smrg # move library search paths that coincide with paths to not yet 97838c4a8e55Smrg # installed libraries to the beginning of the library search list 97848c4a8e55Smrg new_libs= 97858c4a8e55Smrg for path in $notinst_path; do 97868c4a8e55Smrg case " $new_libs " in 97878c4a8e55Smrg *" -L$path/$objdir "*) ;; 97888c4a8e55Smrg *) 97898c4a8e55Smrg case " $deplibs " in 97908c4a8e55Smrg *" -L$path/$objdir "*) 9791bd23fbfaSmrg func_append new_libs " -L$path/$objdir" ;; 97928c4a8e55Smrg esac 97938c4a8e55Smrg ;; 97948c4a8e55Smrg esac 97958c4a8e55Smrg done 97968c4a8e55Smrg for deplib in $deplibs; do 97978c4a8e55Smrg case $deplib in 97988c4a8e55Smrg -L*) 97998c4a8e55Smrg case " $new_libs " in 98008c4a8e55Smrg *" $deplib "*) ;; 9801bd23fbfaSmrg *) func_append new_libs " $deplib" ;; 98028c4a8e55Smrg esac 98038c4a8e55Smrg ;; 9804bd23fbfaSmrg *) func_append new_libs " $deplib" ;; 98058c4a8e55Smrg esac 98068c4a8e55Smrg done 98073169be4bSmrg deplibs=$new_libs 98088c4a8e55Smrg 98098c4a8e55Smrg # All the library-specific variables (install_libdir is set above). 98108c4a8e55Smrg library_names= 98118c4a8e55Smrg old_library= 98128c4a8e55Smrg dlname= 98138c4a8e55Smrg 98148c4a8e55Smrg # Test again, we may have decided not to build it any more 98153169be4bSmrg if test yes = "$build_libtool_libs"; then 98163169be4bSmrg # Remove $wl instances when linking with ld. 98170597fb56Smrg # FIXME: should test the right _cmds variable. 98180597fb56Smrg case $archive_cmds in 98190597fb56Smrg *\$LD\ *) wl= ;; 98200597fb56Smrg esac 98213169be4bSmrg if test yes = "$hardcode_into_libs"; then 98228c4a8e55Smrg # Hardcode the library paths 98238c4a8e55Smrg hardcode_libdirs= 98248c4a8e55Smrg dep_rpath= 98253169be4bSmrg rpath=$finalize_rpath 98263169be4bSmrg test relink = "$opt_mode" || rpath=$compile_rpath$rpath 98278c4a8e55Smrg for libdir in $rpath; do 98288c4a8e55Smrg if test -n "$hardcode_libdir_flag_spec"; then 98298c4a8e55Smrg if test -n "$hardcode_libdir_separator"; then 9830bd23fbfaSmrg func_replace_sysroot "$libdir" 9831bd23fbfaSmrg libdir=$func_replace_sysroot_result 98328c4a8e55Smrg if test -z "$hardcode_libdirs"; then 98333169be4bSmrg hardcode_libdirs=$libdir 98348c4a8e55Smrg else 98358c4a8e55Smrg # Just accumulate the unique libdirs. 98368c4a8e55Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 98378c4a8e55Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 98388c4a8e55Smrg ;; 98398c4a8e55Smrg *) 9840bd23fbfaSmrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 98418c4a8e55Smrg ;; 98428c4a8e55Smrg esac 98438c4a8e55Smrg fi 98448c4a8e55Smrg else 98458c4a8e55Smrg eval flag=\"$hardcode_libdir_flag_spec\" 9846bd23fbfaSmrg func_append dep_rpath " $flag" 98478c4a8e55Smrg fi 98488c4a8e55Smrg elif test -n "$runpath_var"; then 98498c4a8e55Smrg case "$perm_rpath " in 98508c4a8e55Smrg *" $libdir "*) ;; 98510597fb56Smrg *) func_append perm_rpath " $libdir" ;; 98528c4a8e55Smrg esac 98538c4a8e55Smrg fi 98548c4a8e55Smrg done 98558c4a8e55Smrg # Substitute the hardcoded libdirs into the rpath. 98568c4a8e55Smrg if test -n "$hardcode_libdir_separator" && 98578c4a8e55Smrg test -n "$hardcode_libdirs"; then 98583169be4bSmrg libdir=$hardcode_libdirs 98590597fb56Smrg eval "dep_rpath=\"$hardcode_libdir_flag_spec\"" 98608c4a8e55Smrg fi 98618c4a8e55Smrg if test -n "$runpath_var" && test -n "$perm_rpath"; then 98628c4a8e55Smrg # We should set the runpath_var. 98638c4a8e55Smrg rpath= 98648c4a8e55Smrg for dir in $perm_rpath; do 9865bd23fbfaSmrg func_append rpath "$dir:" 98668c4a8e55Smrg done 98678c4a8e55Smrg eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" 98688c4a8e55Smrg fi 98698c4a8e55Smrg test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" 98708c4a8e55Smrg fi 9871b042e37fSmrg 98723169be4bSmrg shlibpath=$finalize_shlibpath 98733169be4bSmrg test relink = "$opt_mode" || shlibpath=$compile_shlibpath$shlibpath 98748c4a8e55Smrg if test -n "$shlibpath"; then 98758c4a8e55Smrg eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" 98768c4a8e55Smrg fi 9877b042e37fSmrg 98788c4a8e55Smrg # Get the real and link names of the library. 98798c4a8e55Smrg eval shared_ext=\"$shrext_cmds\" 98808c4a8e55Smrg eval library_names=\"$library_names_spec\" 98818c4a8e55Smrg set dummy $library_names 98828c4a8e55Smrg shift 98833169be4bSmrg realname=$1 98848c4a8e55Smrg shift 9885b042e37fSmrg 98868c4a8e55Smrg if test -n "$soname_spec"; then 98878c4a8e55Smrg eval soname=\"$soname_spec\" 98888c4a8e55Smrg else 98893169be4bSmrg soname=$realname 98908c4a8e55Smrg fi 98918c4a8e55Smrg if test -z "$dlname"; then 98928c4a8e55Smrg dlname=$soname 98938c4a8e55Smrg fi 9894b042e37fSmrg 98953169be4bSmrg lib=$output_objdir/$realname 98968c4a8e55Smrg linknames= 98978c4a8e55Smrg for link 98988c4a8e55Smrg do 9899bd23fbfaSmrg func_append linknames " $link" 99008c4a8e55Smrg done 9901b042e37fSmrg 99028c4a8e55Smrg # Use standard objects if they are pic 9903706b6b52Smrg test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` 99048c4a8e55Smrg test "X$libobjs" = "X " && libobjs= 9905b042e37fSmrg 99068c4a8e55Smrg delfiles= 99078c4a8e55Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 99088c4a8e55Smrg $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" 99093169be4bSmrg export_symbols=$output_objdir/$libname.uexp 9910bd23fbfaSmrg func_append delfiles " $export_symbols" 99118c4a8e55Smrg fi 9912b042e37fSmrg 99138c4a8e55Smrg orig_export_symbols= 99148c4a8e55Smrg case $host_os in 99158c4a8e55Smrg cygwin* | mingw* | cegcc*) 99168c4a8e55Smrg if test -n "$export_symbols" && test -z "$export_symbols_regex"; then 99178c4a8e55Smrg # exporting using user supplied symfile 99183169be4bSmrg func_dll_def_p "$export_symbols" || { 99198c4a8e55Smrg # and it's NOT already a .def file. Must figure out 99208c4a8e55Smrg # which of the given symbols are data symbols and tag 99218c4a8e55Smrg # them as such. So, trigger use of export_symbols_cmds. 99228c4a8e55Smrg # export_symbols gets reassigned inside the "prepare 99238c4a8e55Smrg # the list of exported symbols" if statement, so the 99248c4a8e55Smrg # include_expsyms logic still works. 99253169be4bSmrg orig_export_symbols=$export_symbols 99268c4a8e55Smrg export_symbols= 99278c4a8e55Smrg always_export_symbols=yes 99283169be4bSmrg } 99298c4a8e55Smrg fi 99308c4a8e55Smrg ;; 99318c4a8e55Smrg esac 9932b042e37fSmrg 99338c4a8e55Smrg # Prepare the list of exported symbols 99348c4a8e55Smrg if test -z "$export_symbols"; then 99353169be4bSmrg if test yes = "$always_export_symbols" || test -n "$export_symbols_regex"; then 99363169be4bSmrg func_verbose "generating symbol list for '$libname.la'" 99373169be4bSmrg export_symbols=$output_objdir/$libname.exp 99388c4a8e55Smrg $opt_dry_run || $RM $export_symbols 99398c4a8e55Smrg cmds=$export_symbols_cmds 99403169be4bSmrg save_ifs=$IFS; IFS='~' 9941bd23fbfaSmrg for cmd1 in $cmds; do 99423169be4bSmrg IFS=$save_ifs 9943bd23fbfaSmrg # Take the normal branch if the nm_file_list_spec branch 9944bd23fbfaSmrg # doesn't work or if tool conversion is not needed. 9945bd23fbfaSmrg case $nm_file_list_spec~$to_tool_file_cmd in 9946bd23fbfaSmrg *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) 9947bd23fbfaSmrg try_normal_branch=yes 9948bd23fbfaSmrg eval cmd=\"$cmd1\" 9949bd23fbfaSmrg func_len " $cmd" 9950bd23fbfaSmrg len=$func_len_result 9951bd23fbfaSmrg ;; 9952bd23fbfaSmrg *) 9953bd23fbfaSmrg try_normal_branch=no 9954bd23fbfaSmrg ;; 9955bd23fbfaSmrg esac 99563169be4bSmrg if test yes = "$try_normal_branch" \ 9957bd23fbfaSmrg && { test "$len" -lt "$max_cmd_len" \ 9958bd23fbfaSmrg || test "$max_cmd_len" -le -1; } 9959bd23fbfaSmrg then 9960bd23fbfaSmrg func_show_eval "$cmd" 'exit $?' 9961bd23fbfaSmrg skipped_export=false 9962bd23fbfaSmrg elif test -n "$nm_file_list_spec"; then 9963bd23fbfaSmrg func_basename "$output" 9964bd23fbfaSmrg output_la=$func_basename_result 9965bd23fbfaSmrg save_libobjs=$libobjs 9966bd23fbfaSmrg save_output=$output 99673169be4bSmrg output=$output_objdir/$output_la.nm 9968bd23fbfaSmrg func_to_tool_file "$output" 9969bd23fbfaSmrg libobjs=$nm_file_list_spec$func_to_tool_file_result 9970bd23fbfaSmrg func_append delfiles " $output" 9971bd23fbfaSmrg func_verbose "creating $NM input file list: $output" 9972bd23fbfaSmrg for obj in $save_libobjs; do 9973bd23fbfaSmrg func_to_tool_file "$obj" 9974bd23fbfaSmrg $ECHO "$func_to_tool_file_result" 9975bd23fbfaSmrg done > "$output" 9976bd23fbfaSmrg eval cmd=\"$cmd1\" 99778c4a8e55Smrg func_show_eval "$cmd" 'exit $?' 9978bd23fbfaSmrg output=$save_output 9979bd23fbfaSmrg libobjs=$save_libobjs 99808c4a8e55Smrg skipped_export=false 99818c4a8e55Smrg else 99828c4a8e55Smrg # The command line is too long to execute in one step. 99838c4a8e55Smrg func_verbose "using reloadable object file for export list..." 99848c4a8e55Smrg skipped_export=: 99858c4a8e55Smrg # Break out early, otherwise skipped_export may be 99868c4a8e55Smrg # set to false by a later but shorter cmd. 99878c4a8e55Smrg break 99888c4a8e55Smrg fi 99898c4a8e55Smrg done 99903169be4bSmrg IFS=$save_ifs 99913169be4bSmrg if test -n "$export_symbols_regex" && test : != "$skipped_export"; then 99928c4a8e55Smrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 99938c4a8e55Smrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 99948c4a8e55Smrg fi 99958c4a8e55Smrg fi 99968c4a8e55Smrg fi 9997b042e37fSmrg 99988c4a8e55Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 99993169be4bSmrg tmp_export_symbols=$export_symbols 100003169be4bSmrg test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols 10001706b6b52Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 100028c4a8e55Smrg fi 10003b042e37fSmrg 100043169be4bSmrg if test : != "$skipped_export" && test -n "$orig_export_symbols"; then 100058c4a8e55Smrg # The given exports_symbols file has to be filtered, so filter it. 100063169be4bSmrg func_verbose "filter symbol list for '$libname.la' to tag DATA exports" 100078c4a8e55Smrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 100083169be4bSmrg # 's' commands, which not all seds can handle. GNU sed should be fine 100098c4a8e55Smrg # though. Also, the filter scales superlinearly with the number of 100108c4a8e55Smrg # global variables. join(1) would be nice here, but unfortunately 100118c4a8e55Smrg # isn't a blessed tool. 100128c4a8e55Smrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 10013bd23fbfaSmrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 100148c4a8e55Smrg export_symbols=$output_objdir/$libname.def 100158c4a8e55Smrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 10016b042e37fSmrg fi 10017b042e37fSmrg 100188c4a8e55Smrg tmp_deplibs= 100198c4a8e55Smrg for test_deplib in $deplibs; do 100208c4a8e55Smrg case " $convenience " in 100218c4a8e55Smrg *" $test_deplib "*) ;; 100228c4a8e55Smrg *) 10023bd23fbfaSmrg func_append tmp_deplibs " $test_deplib" 100248c4a8e55Smrg ;; 100258c4a8e55Smrg esac 100268c4a8e55Smrg done 100273169be4bSmrg deplibs=$tmp_deplibs 10028b042e37fSmrg 100298c4a8e55Smrg if test -n "$convenience"; then 100308c4a8e55Smrg if test -n "$whole_archive_flag_spec" && 100313169be4bSmrg test yes = "$compiler_needs_object" && 100328c4a8e55Smrg test -z "$libobjs"; then 100338c4a8e55Smrg # extract the archives, so we have objects to list. 100348c4a8e55Smrg # TODO: could optimize this to just extract one archive. 100358c4a8e55Smrg whole_archive_flag_spec= 100368c4a8e55Smrg fi 100378c4a8e55Smrg if test -n "$whole_archive_flag_spec"; then 100388c4a8e55Smrg save_libobjs=$libobjs 100398c4a8e55Smrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 100408c4a8e55Smrg test "X$libobjs" = "X " && libobjs= 100418c4a8e55Smrg else 100423169be4bSmrg gentop=$output_objdir/${outputname}x 10043bd23fbfaSmrg func_append generated " $gentop" 10044b042e37fSmrg 100458c4a8e55Smrg func_extract_archives $gentop $convenience 10046bd23fbfaSmrg func_append libobjs " $func_extract_archives_result" 100478c4a8e55Smrg test "X$libobjs" = "X " && libobjs= 100488c4a8e55Smrg fi 100498c4a8e55Smrg fi 10050b042e37fSmrg 100513169be4bSmrg if test yes = "$thread_safe" && test -n "$thread_safe_flag_spec"; then 100528c4a8e55Smrg eval flag=\"$thread_safe_flag_spec\" 10053bd23fbfaSmrg func_append linker_flags " $flag" 100548c4a8e55Smrg fi 10055b042e37fSmrg 100568c4a8e55Smrg # Make a backup of the uninstalled library when relinking 100573169be4bSmrg if test relink = "$opt_mode"; then 100588c4a8e55Smrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? 10059b042e37fSmrg fi 10060b042e37fSmrg 100618c4a8e55Smrg # Do each of the archive commands. 100623169be4bSmrg if test yes = "$module" && test -n "$module_cmds"; then 100638c4a8e55Smrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 100648c4a8e55Smrg eval test_cmds=\"$module_expsym_cmds\" 100658c4a8e55Smrg cmds=$module_expsym_cmds 100668c4a8e55Smrg else 100678c4a8e55Smrg eval test_cmds=\"$module_cmds\" 100688c4a8e55Smrg cmds=$module_cmds 100698c4a8e55Smrg fi 100708c4a8e55Smrg else 100718c4a8e55Smrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 100728c4a8e55Smrg eval test_cmds=\"$archive_expsym_cmds\" 100738c4a8e55Smrg cmds=$archive_expsym_cmds 100748c4a8e55Smrg else 100758c4a8e55Smrg eval test_cmds=\"$archive_cmds\" 100768c4a8e55Smrg cmds=$archive_cmds 100778c4a8e55Smrg fi 10078b042e37fSmrg fi 10079b042e37fSmrg 100803169be4bSmrg if test : != "$skipped_export" && 100818c4a8e55Smrg func_len " $test_cmds" && 100828c4a8e55Smrg len=$func_len_result && 100838c4a8e55Smrg test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 100848c4a8e55Smrg : 100858c4a8e55Smrg else 100868c4a8e55Smrg # The command line is too long to link in one step, link piecewise 100878c4a8e55Smrg # or, if using GNU ld and skipped_export is not :, use a linker 100888c4a8e55Smrg # script. 10089b042e37fSmrg 100908c4a8e55Smrg # Save the value of $output and $libobjs because we want to 100918c4a8e55Smrg # use them later. If we have whole_archive_flag_spec, we 100928c4a8e55Smrg # want to use save_libobjs as it was before 100938c4a8e55Smrg # whole_archive_flag_spec was expanded, because we can't 100948c4a8e55Smrg # assume the linker understands whole_archive_flag_spec. 100958c4a8e55Smrg # This may have to be revisited, in case too many 100968c4a8e55Smrg # convenience libraries get linked in and end up exceeding 100978c4a8e55Smrg # the spec. 100988c4a8e55Smrg if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then 100998c4a8e55Smrg save_libobjs=$libobjs 101008c4a8e55Smrg fi 101018c4a8e55Smrg save_output=$output 10102706b6b52Smrg func_basename "$output" 10103706b6b52Smrg output_la=$func_basename_result 10104b042e37fSmrg 101058c4a8e55Smrg # Clear the reloadable object creation command queue and 101068c4a8e55Smrg # initialize k to one. 101078c4a8e55Smrg test_cmds= 101088c4a8e55Smrg concat_cmds= 101098c4a8e55Smrg objlist= 101108c4a8e55Smrg last_robj= 101118c4a8e55Smrg k=1 10112b042e37fSmrg 101133169be4bSmrg if test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then 101143169be4bSmrg output=$output_objdir/$output_la.lnkscript 101158c4a8e55Smrg func_verbose "creating GNU ld script: $output" 10116706b6b52Smrg echo 'INPUT (' > $output 101178c4a8e55Smrg for obj in $save_libobjs 101188c4a8e55Smrg do 10119bd23fbfaSmrg func_to_tool_file "$obj" 10120bd23fbfaSmrg $ECHO "$func_to_tool_file_result" >> $output 101218c4a8e55Smrg done 10122706b6b52Smrg echo ')' >> $output 10123bd23fbfaSmrg func_append delfiles " $output" 10124bd23fbfaSmrg func_to_tool_file "$output" 10125bd23fbfaSmrg output=$func_to_tool_file_result 101263169be4bSmrg elif test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then 101273169be4bSmrg output=$output_objdir/$output_la.lnk 101288c4a8e55Smrg func_verbose "creating linker input file list: $output" 101298c4a8e55Smrg : > $output 101308c4a8e55Smrg set x $save_libobjs 101318c4a8e55Smrg shift 101328c4a8e55Smrg firstobj= 101333169be4bSmrg if test yes = "$compiler_needs_object"; then 101348c4a8e55Smrg firstobj="$1 " 101358c4a8e55Smrg shift 101368c4a8e55Smrg fi 101378c4a8e55Smrg for obj 101388c4a8e55Smrg do 10139bd23fbfaSmrg func_to_tool_file "$obj" 10140bd23fbfaSmrg $ECHO "$func_to_tool_file_result" >> $output 101418c4a8e55Smrg done 10142bd23fbfaSmrg func_append delfiles " $output" 10143bd23fbfaSmrg func_to_tool_file "$output" 10144bd23fbfaSmrg output=$firstobj\"$file_list_spec$func_to_tool_file_result\" 101458c4a8e55Smrg else 101468c4a8e55Smrg if test -n "$save_libobjs"; then 101478c4a8e55Smrg func_verbose "creating reloadable object files..." 101483169be4bSmrg output=$output_objdir/$output_la-$k.$objext 101498c4a8e55Smrg eval test_cmds=\"$reload_cmds\" 101508c4a8e55Smrg func_len " $test_cmds" 101518c4a8e55Smrg len0=$func_len_result 101528c4a8e55Smrg len=$len0 101538c4a8e55Smrg 101548c4a8e55Smrg # Loop over the list of objects to be linked. 101558c4a8e55Smrg for obj in $save_libobjs 101568c4a8e55Smrg do 101578c4a8e55Smrg func_len " $obj" 101588c4a8e55Smrg func_arith $len + $func_len_result 101598c4a8e55Smrg len=$func_arith_result 101603169be4bSmrg if test -z "$objlist" || 101618c4a8e55Smrg test "$len" -lt "$max_cmd_len"; then 101628c4a8e55Smrg func_append objlist " $obj" 101638c4a8e55Smrg else 101648c4a8e55Smrg # The command $test_cmds is almost too long, add a 101658c4a8e55Smrg # command to the queue. 101663169be4bSmrg if test 1 -eq "$k"; then 101678c4a8e55Smrg # The first file doesn't have a previous command to add. 10168706b6b52Smrg reload_objs=$objlist 10169706b6b52Smrg eval concat_cmds=\"$reload_cmds\" 101708c4a8e55Smrg else 101718c4a8e55Smrg # All subsequent reloadable object files will link in 101728c4a8e55Smrg # the last one created. 10173706b6b52Smrg reload_objs="$objlist $last_robj" 10174706b6b52Smrg eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" 101758c4a8e55Smrg fi 101763169be4bSmrg last_robj=$output_objdir/$output_la-$k.$objext 101778c4a8e55Smrg func_arith $k + 1 101788c4a8e55Smrg k=$func_arith_result 101793169be4bSmrg output=$output_objdir/$output_la-$k.$objext 10180706b6b52Smrg objlist=" $obj" 101818c4a8e55Smrg func_len " $last_robj" 101828c4a8e55Smrg func_arith $len0 + $func_len_result 101838c4a8e55Smrg len=$func_arith_result 101848c4a8e55Smrg fi 101858c4a8e55Smrg done 101868c4a8e55Smrg # Handle the remaining objects by creating one last 101878c4a8e55Smrg # reloadable object file. All subsequent reloadable object 101888c4a8e55Smrg # files will link in the last one created. 101898c4a8e55Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 10190706b6b52Smrg reload_objs="$objlist $last_robj" 101913169be4bSmrg eval concat_cmds=\"\$concat_cmds$reload_cmds\" 101928c4a8e55Smrg if test -n "$last_robj"; then 101933169be4bSmrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 101948c4a8e55Smrg fi 10195bd23fbfaSmrg func_append delfiles " $output" 10196b042e37fSmrg 101978c4a8e55Smrg else 101988c4a8e55Smrg output= 101998c4a8e55Smrg fi 10200b042e37fSmrg 102013169be4bSmrg ${skipped_export-false} && { 102023169be4bSmrg func_verbose "generating symbol list for '$libname.la'" 102033169be4bSmrg export_symbols=$output_objdir/$libname.exp 102048c4a8e55Smrg $opt_dry_run || $RM $export_symbols 102058c4a8e55Smrg libobjs=$output 102068c4a8e55Smrg # Append the command to create the export file. 102078c4a8e55Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 102088c4a8e55Smrg eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" 102098c4a8e55Smrg if test -n "$last_robj"; then 102108c4a8e55Smrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 102118c4a8e55Smrg fi 102123169be4bSmrg } 10213b042e37fSmrg 102148c4a8e55Smrg test -n "$save_libobjs" && 102158c4a8e55Smrg func_verbose "creating a temporary reloadable object file: $output" 10216b042e37fSmrg 102178c4a8e55Smrg # Loop through the commands generated above and execute them. 102183169be4bSmrg save_ifs=$IFS; IFS='~' 102198c4a8e55Smrg for cmd in $concat_cmds; do 102203169be4bSmrg IFS=$save_ifs 102213169be4bSmrg $opt_quiet || { 102228d0bc965Smrg func_quote_arg expand,pretty "$cmd" 102238d0bc965Smrg eval "func_echo $func_quote_arg_result" 102248c4a8e55Smrg } 102258c4a8e55Smrg $opt_dry_run || eval "$cmd" || { 102268c4a8e55Smrg lt_exit=$? 102278c4a8e55Smrg 102288c4a8e55Smrg # Restore the uninstalled library and exit 102293169be4bSmrg if test relink = "$opt_mode"; then 102308c4a8e55Smrg ( cd "$output_objdir" && \ 102318c4a8e55Smrg $RM "${realname}T" && \ 102328c4a8e55Smrg $MV "${realname}U" "$realname" ) 102338c4a8e55Smrg fi 10234b042e37fSmrg 102358c4a8e55Smrg exit $lt_exit 102368c4a8e55Smrg } 102378c4a8e55Smrg done 102383169be4bSmrg IFS=$save_ifs 102398c4a8e55Smrg 102408c4a8e55Smrg if test -n "$export_symbols_regex" && ${skipped_export-false}; then 102418c4a8e55Smrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 102428c4a8e55Smrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 10243b042e37fSmrg fi 10244b042e37fSmrg fi 10245b042e37fSmrg 102463169be4bSmrg ${skipped_export-false} && { 102478c4a8e55Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 102483169be4bSmrg tmp_export_symbols=$export_symbols 102493169be4bSmrg test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols 10250706b6b52Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 102518c4a8e55Smrg fi 10252b042e37fSmrg 102538c4a8e55Smrg if test -n "$orig_export_symbols"; then 102548c4a8e55Smrg # The given exports_symbols file has to be filtered, so filter it. 102553169be4bSmrg func_verbose "filter symbol list for '$libname.la' to tag DATA exports" 102568c4a8e55Smrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 102573169be4bSmrg # 's' commands, which not all seds can handle. GNU sed should be fine 102588c4a8e55Smrg # though. Also, the filter scales superlinearly with the number of 102598c4a8e55Smrg # global variables. join(1) would be nice here, but unfortunately 102608c4a8e55Smrg # isn't a blessed tool. 102618c4a8e55Smrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 10262bd23fbfaSmrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 102638c4a8e55Smrg export_symbols=$output_objdir/$libname.def 102648c4a8e55Smrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 102658c4a8e55Smrg fi 102663169be4bSmrg } 10267b042e37fSmrg 102688c4a8e55Smrg libobjs=$output 102698c4a8e55Smrg # Restore the value of output. 102708c4a8e55Smrg output=$save_output 10271b042e37fSmrg 102728c4a8e55Smrg if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then 102738c4a8e55Smrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 102748c4a8e55Smrg test "X$libobjs" = "X " && libobjs= 102758c4a8e55Smrg fi 102768c4a8e55Smrg # Expand the library linking commands again to reset the 102778c4a8e55Smrg # value of $libobjs for piecewise linking. 102788c4a8e55Smrg 102798c4a8e55Smrg # Do each of the archive commands. 102803169be4bSmrg if test yes = "$module" && test -n "$module_cmds"; then 102818c4a8e55Smrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 102828c4a8e55Smrg cmds=$module_expsym_cmds 10283b042e37fSmrg else 102848c4a8e55Smrg cmds=$module_cmds 10285b042e37fSmrg fi 10286b042e37fSmrg else 102878c4a8e55Smrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 102888c4a8e55Smrg cmds=$archive_expsym_cmds 102898c4a8e55Smrg else 102908c4a8e55Smrg cmds=$archive_cmds 102918c4a8e55Smrg fi 10292b042e37fSmrg fi 10293b042e37fSmrg fi 10294b042e37fSmrg 102958c4a8e55Smrg if test -n "$delfiles"; then 102968c4a8e55Smrg # Append the command to remove temporary files to $cmds. 102978c4a8e55Smrg eval cmds=\"\$cmds~\$RM $delfiles\" 102988c4a8e55Smrg fi 10299b042e37fSmrg 103008c4a8e55Smrg # Add any objects from preloaded convenience libraries 103018c4a8e55Smrg if test -n "$dlprefiles"; then 103023169be4bSmrg gentop=$output_objdir/${outputname}x 10303bd23fbfaSmrg func_append generated " $gentop" 10304b042e37fSmrg 103058c4a8e55Smrg func_extract_archives $gentop $dlprefiles 10306bd23fbfaSmrg func_append libobjs " $func_extract_archives_result" 103078c4a8e55Smrg test "X$libobjs" = "X " && libobjs= 10308b042e37fSmrg fi 10309b042e37fSmrg 103103169be4bSmrg save_ifs=$IFS; IFS='~' 103118c4a8e55Smrg for cmd in $cmds; do 103123169be4bSmrg IFS=$sp$nl 103138c4a8e55Smrg eval cmd=\"$cmd\" 103143169be4bSmrg IFS=$save_ifs 103153169be4bSmrg $opt_quiet || { 103168d0bc965Smrg func_quote_arg expand,pretty "$cmd" 103178d0bc965Smrg eval "func_echo $func_quote_arg_result" 103188c4a8e55Smrg } 103198c4a8e55Smrg $opt_dry_run || eval "$cmd" || { 103208c4a8e55Smrg lt_exit=$? 10321b042e37fSmrg 103228c4a8e55Smrg # Restore the uninstalled library and exit 103233169be4bSmrg if test relink = "$opt_mode"; then 103248c4a8e55Smrg ( cd "$output_objdir" && \ 103258c4a8e55Smrg $RM "${realname}T" && \ 103268c4a8e55Smrg $MV "${realname}U" "$realname" ) 103278c4a8e55Smrg fi 103288c4a8e55Smrg 103298c4a8e55Smrg exit $lt_exit 103308c4a8e55Smrg } 103318c4a8e55Smrg done 103323169be4bSmrg IFS=$save_ifs 103338c4a8e55Smrg 103348c4a8e55Smrg # Restore the uninstalled library and exit 103353169be4bSmrg if test relink = "$opt_mode"; then 103368c4a8e55Smrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? 103378c4a8e55Smrg 103388c4a8e55Smrg if test -n "$convenience"; then 103398c4a8e55Smrg if test -z "$whole_archive_flag_spec"; then 103408c4a8e55Smrg func_show_eval '${RM}r "$gentop"' 10341b042e37fSmrg fi 10342b042e37fSmrg fi 10343b042e37fSmrg 103448c4a8e55Smrg exit $EXIT_SUCCESS 103458c4a8e55Smrg fi 10346b042e37fSmrg 103478c4a8e55Smrg # Create links to the real library. 103488c4a8e55Smrg for linkname in $linknames; do 103498c4a8e55Smrg if test "$realname" != "$linkname"; then 103508c4a8e55Smrg func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' 103518c4a8e55Smrg fi 103528c4a8e55Smrg done 103538c4a8e55Smrg 103548c4a8e55Smrg # If -module or -export-dynamic was specified, set the dlname. 103553169be4bSmrg if test yes = "$module" || test yes = "$export_dynamic"; then 103568c4a8e55Smrg # On all known operating systems, these are identical. 103573169be4bSmrg dlname=$soname 103588c4a8e55Smrg fi 103598c4a8e55Smrg fi 103608c4a8e55Smrg ;; 103618c4a8e55Smrg 103628c4a8e55Smrg obj) 103633169be4bSmrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 103643169be4bSmrg func_warning "'-dlopen' is ignored for objects" 103658c4a8e55Smrg fi 103668c4a8e55Smrg 103678c4a8e55Smrg case " $deplibs" in 103688c4a8e55Smrg *\ -l* | *\ -L*) 103693169be4bSmrg func_warning "'-l' and '-L' are ignored for objects" ;; 103708c4a8e55Smrg esac 103718c4a8e55Smrg 103728c4a8e55Smrg test -n "$rpath" && \ 103733169be4bSmrg func_warning "'-rpath' is ignored for objects" 103748c4a8e55Smrg 103758c4a8e55Smrg test -n "$xrpath" && \ 103763169be4bSmrg func_warning "'-R' is ignored for objects" 103778c4a8e55Smrg 103788c4a8e55Smrg test -n "$vinfo" && \ 103793169be4bSmrg func_warning "'-version-info' is ignored for objects" 103808c4a8e55Smrg 103818c4a8e55Smrg test -n "$release" && \ 103823169be4bSmrg func_warning "'-release' is ignored for objects" 103838c4a8e55Smrg 103848c4a8e55Smrg case $output in 103858c4a8e55Smrg *.lo) 103868c4a8e55Smrg test -n "$objs$old_deplibs" && \ 103873169be4bSmrg func_fatal_error "cannot build library object '$output' from non-libtool objects" 103888c4a8e55Smrg 103898c4a8e55Smrg libobj=$output 103908c4a8e55Smrg func_lo2o "$libobj" 103918c4a8e55Smrg obj=$func_lo2o_result 103928c4a8e55Smrg ;; 103938c4a8e55Smrg *) 103948c4a8e55Smrg libobj= 103953169be4bSmrg obj=$output 103968c4a8e55Smrg ;; 103978c4a8e55Smrg esac 103988c4a8e55Smrg 103998c4a8e55Smrg # Delete the old objects. 104008c4a8e55Smrg $opt_dry_run || $RM $obj $libobj 104018c4a8e55Smrg 104028c4a8e55Smrg # Objects from convenience libraries. This assumes 104038c4a8e55Smrg # single-version convenience libraries. Whenever we create 104048c4a8e55Smrg # different ones for PIC/non-PIC, this we'll have to duplicate 104058c4a8e55Smrg # the extraction. 104068c4a8e55Smrg reload_conv_objs= 104078c4a8e55Smrg gentop= 104083169be4bSmrg # if reload_cmds runs $LD directly, get rid of -Wl from 104093169be4bSmrg # whole_archive_flag_spec and hope we can get by with turning comma 104103169be4bSmrg # into space. 104113169be4bSmrg case $reload_cmds in 104123169be4bSmrg *\$LD[\ \$]*) wl= ;; 104133169be4bSmrg esac 104148c4a8e55Smrg if test -n "$convenience"; then 104158c4a8e55Smrg if test -n "$whole_archive_flag_spec"; then 104168c4a8e55Smrg eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" 104173169be4bSmrg test -n "$wl" || tmp_whole_archive_flags=`$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` 104183169be4bSmrg reload_conv_objs=$reload_objs\ $tmp_whole_archive_flags 104198c4a8e55Smrg else 104203169be4bSmrg gentop=$output_objdir/${obj}x 10421bd23fbfaSmrg func_append generated " $gentop" 104228c4a8e55Smrg 104238c4a8e55Smrg func_extract_archives $gentop $convenience 104248c4a8e55Smrg reload_conv_objs="$reload_objs $func_extract_archives_result" 104258c4a8e55Smrg fi 104268c4a8e55Smrg fi 10427b042e37fSmrg 10428bd23fbfaSmrg # If we're not building shared, we need to use non_pic_objs 104293169be4bSmrg test yes = "$build_libtool_libs" || libobjs=$non_pic_objects 10430bd23fbfaSmrg 104318c4a8e55Smrg # Create the old-style object. 104323169be4bSmrg reload_objs=$objs$old_deplibs' '`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; /\.lib$/d; $lo2o" | $NL2SP`' '$reload_conv_objs 10433b042e37fSmrg 104343169be4bSmrg output=$obj 104358c4a8e55Smrg func_execute_cmds "$reload_cmds" 'exit $?' 10436b042e37fSmrg 104378c4a8e55Smrg # Exit if we aren't doing a library object file. 104388c4a8e55Smrg if test -z "$libobj"; then 104398c4a8e55Smrg if test -n "$gentop"; then 104408c4a8e55Smrg func_show_eval '${RM}r "$gentop"' 104418c4a8e55Smrg fi 10442b042e37fSmrg 104438c4a8e55Smrg exit $EXIT_SUCCESS 104448c4a8e55Smrg fi 10445b042e37fSmrg 104463169be4bSmrg test yes = "$build_libtool_libs" || { 104478c4a8e55Smrg if test -n "$gentop"; then 104488c4a8e55Smrg func_show_eval '${RM}r "$gentop"' 104498c4a8e55Smrg fi 10450b042e37fSmrg 104518c4a8e55Smrg # Create an invalid libtool object if no PIC, so that we don't 104528c4a8e55Smrg # accidentally link it into a program. 104538c4a8e55Smrg # $show "echo timestamp > $libobj" 104548c4a8e55Smrg # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? 104558c4a8e55Smrg exit $EXIT_SUCCESS 104563169be4bSmrg } 10457b042e37fSmrg 104583169be4bSmrg if test -n "$pic_flag" || test default != "$pic_mode"; then 104598c4a8e55Smrg # Only do commands if we really have different PIC objects. 104608c4a8e55Smrg reload_objs="$libobjs $reload_conv_objs" 104613169be4bSmrg output=$libobj 104628c4a8e55Smrg func_execute_cmds "$reload_cmds" 'exit $?' 10463b042e37fSmrg fi 10464b042e37fSmrg 104658c4a8e55Smrg if test -n "$gentop"; then 104668c4a8e55Smrg func_show_eval '${RM}r "$gentop"' 104678c4a8e55Smrg fi 10468b042e37fSmrg 104698c4a8e55Smrg exit $EXIT_SUCCESS 104708c4a8e55Smrg ;; 10471b042e37fSmrg 104728c4a8e55Smrg prog) 104738c4a8e55Smrg case $host in 104748c4a8e55Smrg *cygwin*) func_stripname '' '.exe' "$output" 104758c4a8e55Smrg output=$func_stripname_result.exe;; 10476b042e37fSmrg esac 104778c4a8e55Smrg test -n "$vinfo" && \ 104783169be4bSmrg func_warning "'-version-info' is ignored for programs" 10479b042e37fSmrg 104808c4a8e55Smrg test -n "$release" && \ 104813169be4bSmrg func_warning "'-release' is ignored for programs" 10482b042e37fSmrg 104833169be4bSmrg $preload \ 104843169be4bSmrg && test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \ 104853169be4bSmrg && func_warning "'LT_INIT([dlopen])' not used. Assuming no dlopen support." 10486b042e37fSmrg 104878c4a8e55Smrg case $host in 104888c4a8e55Smrg *-*-rhapsody* | *-*-darwin1.[012]) 104898c4a8e55Smrg # On Rhapsody replace the C library is the System framework 10490706b6b52Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` 10491706b6b52Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` 10492b042e37fSmrg ;; 10493b042e37fSmrg esac 10494b042e37fSmrg 104958c4a8e55Smrg case $host in 104968c4a8e55Smrg *-*-darwin*) 104978c4a8e55Smrg # Don't allow lazy linking, it breaks C++ global constructors 104988c4a8e55Smrg # But is supposedly fixed on 10.4 or later (yay!). 104993169be4bSmrg if test CXX = "$tagname"; then 105008c4a8e55Smrg case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 105018c4a8e55Smrg 10.[0123]) 105023169be4bSmrg func_append compile_command " $wl-bind_at_load" 105033169be4bSmrg func_append finalize_command " $wl-bind_at_load" 105048c4a8e55Smrg ;; 105058c4a8e55Smrg esac 105068c4a8e55Smrg fi 105078c4a8e55Smrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 10508706b6b52Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 10509706b6b52Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 10510b042e37fSmrg ;; 10511b042e37fSmrg esac 10512b042e37fSmrg 10513b042e37fSmrg 105148c4a8e55Smrg # move library search paths that coincide with paths to not yet 105158c4a8e55Smrg # installed libraries to the beginning of the library search list 105168c4a8e55Smrg new_libs= 105178c4a8e55Smrg for path in $notinst_path; do 105188c4a8e55Smrg case " $new_libs " in 105198c4a8e55Smrg *" -L$path/$objdir "*) ;; 10520b042e37fSmrg *) 105218c4a8e55Smrg case " $compile_deplibs " in 105228c4a8e55Smrg *" -L$path/$objdir "*) 10523bd23fbfaSmrg func_append new_libs " -L$path/$objdir" ;; 105248c4a8e55Smrg esac 10525b042e37fSmrg ;; 10526b042e37fSmrg esac 10527b042e37fSmrg done 105288c4a8e55Smrg for deplib in $compile_deplibs; do 105298c4a8e55Smrg case $deplib in 105308c4a8e55Smrg -L*) 105318c4a8e55Smrg case " $new_libs " in 105328c4a8e55Smrg *" $deplib "*) ;; 10533bd23fbfaSmrg *) func_append new_libs " $deplib" ;; 105348c4a8e55Smrg esac 105358c4a8e55Smrg ;; 10536bd23fbfaSmrg *) func_append new_libs " $deplib" ;; 105378c4a8e55Smrg esac 105388c4a8e55Smrg done 105393169be4bSmrg compile_deplibs=$new_libs 10540b042e37fSmrg 10541b042e37fSmrg 10542bd23fbfaSmrg func_append compile_command " $compile_deplibs" 10543bd23fbfaSmrg func_append finalize_command " $finalize_deplibs" 10544b042e37fSmrg 105458c4a8e55Smrg if test -n "$rpath$xrpath"; then 105468c4a8e55Smrg # If the user specified any rpath flags, then add them. 105478c4a8e55Smrg for libdir in $rpath $xrpath; do 105488c4a8e55Smrg # This is the magic to use -rpath. 105498c4a8e55Smrg case "$finalize_rpath " in 105508c4a8e55Smrg *" $libdir "*) ;; 10551bd23fbfaSmrg *) func_append finalize_rpath " $libdir" ;; 105528c4a8e55Smrg esac 105538c4a8e55Smrg done 105548c4a8e55Smrg fi 10555b042e37fSmrg 105568c4a8e55Smrg # Now hardcode the library paths 105578c4a8e55Smrg rpath= 105588c4a8e55Smrg hardcode_libdirs= 105598c4a8e55Smrg for libdir in $compile_rpath $finalize_rpath; do 105608c4a8e55Smrg if test -n "$hardcode_libdir_flag_spec"; then 105618c4a8e55Smrg if test -n "$hardcode_libdir_separator"; then 105628c4a8e55Smrg if test -z "$hardcode_libdirs"; then 105633169be4bSmrg hardcode_libdirs=$libdir 105648c4a8e55Smrg else 105658c4a8e55Smrg # Just accumulate the unique libdirs. 105668c4a8e55Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 105678c4a8e55Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 105688c4a8e55Smrg ;; 105698c4a8e55Smrg *) 10570bd23fbfaSmrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 105718c4a8e55Smrg ;; 105728c4a8e55Smrg esac 105738c4a8e55Smrg fi 105748c4a8e55Smrg else 105758c4a8e55Smrg eval flag=\"$hardcode_libdir_flag_spec\" 10576bd23fbfaSmrg func_append rpath " $flag" 105778c4a8e55Smrg fi 105788c4a8e55Smrg elif test -n "$runpath_var"; then 105798c4a8e55Smrg case "$perm_rpath " in 10580b042e37fSmrg *" $libdir "*) ;; 10581bd23fbfaSmrg *) func_append perm_rpath " $libdir" ;; 10582b042e37fSmrg esac 105838c4a8e55Smrg fi 105848c4a8e55Smrg case $host in 105858c4a8e55Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 105863169be4bSmrg testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'` 105878c4a8e55Smrg case :$dllsearchpath: in 105888c4a8e55Smrg *":$libdir:"*) ;; 105898c4a8e55Smrg ::) dllsearchpath=$libdir;; 10590bd23fbfaSmrg *) func_append dllsearchpath ":$libdir";; 105918c4a8e55Smrg esac 105928c4a8e55Smrg case :$dllsearchpath: in 105938c4a8e55Smrg *":$testbindir:"*) ;; 105948c4a8e55Smrg ::) dllsearchpath=$testbindir;; 10595bd23fbfaSmrg *) func_append dllsearchpath ":$testbindir";; 105968c4a8e55Smrg esac 105978c4a8e55Smrg ;; 105988c4a8e55Smrg esac 105998c4a8e55Smrg done 106008c4a8e55Smrg # Substitute the hardcoded libdirs into the rpath. 106018c4a8e55Smrg if test -n "$hardcode_libdir_separator" && 106028c4a8e55Smrg test -n "$hardcode_libdirs"; then 106033169be4bSmrg libdir=$hardcode_libdirs 106048c4a8e55Smrg eval rpath=\" $hardcode_libdir_flag_spec\" 106058c4a8e55Smrg fi 106063169be4bSmrg compile_rpath=$rpath 106078c4a8e55Smrg 106088c4a8e55Smrg rpath= 106098c4a8e55Smrg hardcode_libdirs= 106108c4a8e55Smrg for libdir in $finalize_rpath; do 106118c4a8e55Smrg if test -n "$hardcode_libdir_flag_spec"; then 106128c4a8e55Smrg if test -n "$hardcode_libdir_separator"; then 106138c4a8e55Smrg if test -z "$hardcode_libdirs"; then 106143169be4bSmrg hardcode_libdirs=$libdir 106158c4a8e55Smrg else 106168c4a8e55Smrg # Just accumulate the unique libdirs. 106178c4a8e55Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 106188c4a8e55Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 106198c4a8e55Smrg ;; 106208c4a8e55Smrg *) 10621bd23fbfaSmrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 106228c4a8e55Smrg ;; 106238c4a8e55Smrg esac 106248c4a8e55Smrg fi 106258c4a8e55Smrg else 106268c4a8e55Smrg eval flag=\"$hardcode_libdir_flag_spec\" 10627bd23fbfaSmrg func_append rpath " $flag" 106288c4a8e55Smrg fi 106298c4a8e55Smrg elif test -n "$runpath_var"; then 106308c4a8e55Smrg case "$finalize_perm_rpath " in 10631b042e37fSmrg *" $libdir "*) ;; 10632bd23fbfaSmrg *) func_append finalize_perm_rpath " $libdir" ;; 10633b042e37fSmrg esac 10634b042e37fSmrg fi 106358c4a8e55Smrg done 106368c4a8e55Smrg # Substitute the hardcoded libdirs into the rpath. 106378c4a8e55Smrg if test -n "$hardcode_libdir_separator" && 106388c4a8e55Smrg test -n "$hardcode_libdirs"; then 106393169be4bSmrg libdir=$hardcode_libdirs 106408c4a8e55Smrg eval rpath=\" $hardcode_libdir_flag_spec\" 106418c4a8e55Smrg fi 106423169be4bSmrg finalize_rpath=$rpath 10643b042e37fSmrg 106443169be4bSmrg if test -n "$libobjs" && test yes = "$build_old_libs"; then 106458c4a8e55Smrg # Transform all the library objects into standard objects. 10646706b6b52Smrg compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 10647706b6b52Smrg finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 106488c4a8e55Smrg fi 10649b042e37fSmrg 106503169be4bSmrg func_generate_dlsyms "$outputname" "@PROGRAM@" false 10651b042e37fSmrg 106528c4a8e55Smrg # template prelinking step 106538c4a8e55Smrg if test -n "$prelink_cmds"; then 106548c4a8e55Smrg func_execute_cmds "$prelink_cmds" 'exit $?' 106558c4a8e55Smrg fi 10656b042e37fSmrg 106573169be4bSmrg wrappers_required=: 106588c4a8e55Smrg case $host in 10659706b6b52Smrg *cegcc* | *mingw32ce*) 10660706b6b52Smrg # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. 106613169be4bSmrg wrappers_required=false 10662706b6b52Smrg ;; 106638c4a8e55Smrg *cygwin* | *mingw* ) 106643169be4bSmrg test yes = "$build_libtool_libs" || wrappers_required=false 106658c4a8e55Smrg ;; 106668c4a8e55Smrg *) 106673169be4bSmrg if test no = "$need_relink" || test yes != "$build_libtool_libs"; then 106683169be4bSmrg wrappers_required=false 106698c4a8e55Smrg fi 106708c4a8e55Smrg ;; 106718c4a8e55Smrg esac 106723169be4bSmrg $wrappers_required || { 106738c4a8e55Smrg # Replace the output file specification. 10674706b6b52Smrg compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 106753169be4bSmrg link_command=$compile_command$compile_rpath 10676b042e37fSmrg 106778c4a8e55Smrg # We have no uninstalled library dependencies, so finalize right now. 106788c4a8e55Smrg exit_status=0 106798c4a8e55Smrg func_show_eval "$link_command" 'exit_status=$?' 10680b042e37fSmrg 10681bd23fbfaSmrg if test -n "$postlink_cmds"; then 10682bd23fbfaSmrg func_to_tool_file "$output" 10683bd23fbfaSmrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 10684bd23fbfaSmrg func_execute_cmds "$postlink_cmds" 'exit $?' 10685bd23fbfaSmrg fi 10686bd23fbfaSmrg 106878c4a8e55Smrg # Delete the generated files. 106883169be4bSmrg if test -f "$output_objdir/${outputname}S.$objext"; then 106893169be4bSmrg func_show_eval '$RM "$output_objdir/${outputname}S.$objext"' 106908c4a8e55Smrg fi 10691b042e37fSmrg 106928c4a8e55Smrg exit $exit_status 106933169be4bSmrg } 10694b042e37fSmrg 106958c4a8e55Smrg if test -n "$compile_shlibpath$finalize_shlibpath"; then 106968c4a8e55Smrg compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" 106978c4a8e55Smrg fi 106988c4a8e55Smrg if test -n "$finalize_shlibpath"; then 106998c4a8e55Smrg finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" 107008c4a8e55Smrg fi 10701b042e37fSmrg 107028c4a8e55Smrg compile_var= 107038c4a8e55Smrg finalize_var= 107048c4a8e55Smrg if test -n "$runpath_var"; then 107058c4a8e55Smrg if test -n "$perm_rpath"; then 107068c4a8e55Smrg # We should set the runpath_var. 107078c4a8e55Smrg rpath= 107088c4a8e55Smrg for dir in $perm_rpath; do 10709bd23fbfaSmrg func_append rpath "$dir:" 10710b042e37fSmrg done 107118c4a8e55Smrg compile_var="$runpath_var=\"$rpath\$$runpath_var\" " 10712b042e37fSmrg fi 107138c4a8e55Smrg if test -n "$finalize_perm_rpath"; then 107148c4a8e55Smrg # We should set the runpath_var. 107158c4a8e55Smrg rpath= 107168c4a8e55Smrg for dir in $finalize_perm_rpath; do 10717bd23fbfaSmrg func_append rpath "$dir:" 107188c4a8e55Smrg done 107198c4a8e55Smrg finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " 107208c4a8e55Smrg fi 107218c4a8e55Smrg fi 10722b042e37fSmrg 107233169be4bSmrg if test yes = "$no_install"; then 107248c4a8e55Smrg # We don't need to create a wrapper script. 107253169be4bSmrg link_command=$compile_var$compile_command$compile_rpath 107268c4a8e55Smrg # Replace the output file specification. 10727706b6b52Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 107288c4a8e55Smrg # Delete the old output file. 107298c4a8e55Smrg $opt_dry_run || $RM $output 107308c4a8e55Smrg # Link the executable and exit 107318c4a8e55Smrg func_show_eval "$link_command" 'exit $?' 10732bd23fbfaSmrg 10733bd23fbfaSmrg if test -n "$postlink_cmds"; then 10734bd23fbfaSmrg func_to_tool_file "$output" 10735bd23fbfaSmrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 10736bd23fbfaSmrg func_execute_cmds "$postlink_cmds" 'exit $?' 10737bd23fbfaSmrg fi 10738bd23fbfaSmrg 107398c4a8e55Smrg exit $EXIT_SUCCESS 107408c4a8e55Smrg fi 10741b042e37fSmrg 107423169be4bSmrg case $hardcode_action,$fast_install in 107433169be4bSmrg relink,*) 107443169be4bSmrg # Fast installation is not supported 107453169be4bSmrg link_command=$compile_var$compile_command$compile_rpath 107463169be4bSmrg relink_command=$finalize_var$finalize_command$finalize_rpath 10747b042e37fSmrg 107483169be4bSmrg func_warning "this platform does not like uninstalled shared libraries" 107493169be4bSmrg func_warning "'$output' will be relinked during installation" 107503169be4bSmrg ;; 107513169be4bSmrg *,yes) 107523169be4bSmrg link_command=$finalize_var$compile_command$finalize_rpath 107533169be4bSmrg relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` 107543169be4bSmrg ;; 107553169be4bSmrg *,no) 107563169be4bSmrg link_command=$compile_var$compile_command$compile_rpath 107573169be4bSmrg relink_command=$finalize_var$finalize_command$finalize_rpath 107583169be4bSmrg ;; 107593169be4bSmrg *,needless) 107603169be4bSmrg link_command=$finalize_var$compile_command$finalize_rpath 107613169be4bSmrg relink_command= 107623169be4bSmrg ;; 107633169be4bSmrg esac 10764b042e37fSmrg 107658c4a8e55Smrg # Replace the output file specification. 10766706b6b52Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` 10767b042e37fSmrg 107688c4a8e55Smrg # Delete the old output files. 107698c4a8e55Smrg $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname 10770b042e37fSmrg 107718c4a8e55Smrg func_show_eval "$link_command" 'exit $?' 10772b042e37fSmrg 10773bd23fbfaSmrg if test -n "$postlink_cmds"; then 10774bd23fbfaSmrg func_to_tool_file "$output_objdir/$outputname" 10775bd23fbfaSmrg 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'` 10776bd23fbfaSmrg func_execute_cmds "$postlink_cmds" 'exit $?' 10777bd23fbfaSmrg fi 10778bd23fbfaSmrg 107798c4a8e55Smrg # Now create the wrapper script. 107808c4a8e55Smrg func_verbose "creating $output" 10781b042e37fSmrg 107828c4a8e55Smrg # Quote the relink command for shipping. 107838c4a8e55Smrg if test -n "$relink_command"; then 107848c4a8e55Smrg # Preserve any variables that may affect compiler behavior 107858c4a8e55Smrg for var in $variables_saved_for_relink; do 107868c4a8e55Smrg if eval test -z \"\${$var+set}\"; then 107878c4a8e55Smrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 107888c4a8e55Smrg elif eval var_value=\$$var; test -z "$var_value"; then 107898c4a8e55Smrg relink_command="$var=; export $var; $relink_command" 107908c4a8e55Smrg else 107918d0bc965Smrg func_quote_arg pretty "$var_value" 107928d0bc965Smrg relink_command="$var=$func_quote_arg_result; export $var; $relink_command" 107938c4a8e55Smrg fi 107948c4a8e55Smrg done 107958d0bc965Smrg func_quote eval cd "`pwd`" 107968d0bc965Smrg func_quote_arg pretty,unquoted "($func_quote_result; $relink_command)" 107978d0bc965Smrg relink_command=$func_quote_arg_unquoted_result 107988c4a8e55Smrg fi 10799b042e37fSmrg 108008c4a8e55Smrg # Only actually do things if not in dry run mode. 108018c4a8e55Smrg $opt_dry_run || { 108028c4a8e55Smrg # win32 will think the script is a binary if it has 108038c4a8e55Smrg # a .exe suffix, so we strip it off here. 108048c4a8e55Smrg case $output in 108058c4a8e55Smrg *.exe) func_stripname '' '.exe' "$output" 108068c4a8e55Smrg output=$func_stripname_result ;; 108078c4a8e55Smrg esac 108088c4a8e55Smrg # test for cygwin because mv fails w/o .exe extensions 10809b042e37fSmrg case $host in 108108c4a8e55Smrg *cygwin*) 108118c4a8e55Smrg exeext=.exe 108128c4a8e55Smrg func_stripname '' '.exe' "$outputname" 108138c4a8e55Smrg outputname=$func_stripname_result ;; 108148c4a8e55Smrg *) exeext= ;; 10815b042e37fSmrg esac 108168c4a8e55Smrg case $host in 108178c4a8e55Smrg *cygwin* | *mingw* ) 108188c4a8e55Smrg func_dirname_and_basename "$output" "" "." 108198c4a8e55Smrg output_name=$func_basename_result 108208c4a8e55Smrg output_path=$func_dirname_result 108213169be4bSmrg cwrappersource=$output_path/$objdir/lt-$output_name.c 108223169be4bSmrg cwrapper=$output_path/$output_name.exe 108238c4a8e55Smrg $RM $cwrappersource $cwrapper 108248c4a8e55Smrg trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 108258c4a8e55Smrg 108268c4a8e55Smrg func_emit_cwrapperexe_src > $cwrappersource 108278c4a8e55Smrg 108288c4a8e55Smrg # The wrapper executable is built using the $host compiler, 108298c4a8e55Smrg # because it contains $host paths and files. If cross- 108308c4a8e55Smrg # compiling, it, like the target executable, must be 108318c4a8e55Smrg # executed on the $host or under an emulation environment. 108328c4a8e55Smrg $opt_dry_run || { 108338c4a8e55Smrg $LTCC $LTCFLAGS -o $cwrapper $cwrappersource 108348c4a8e55Smrg $STRIP $cwrapper 108358c4a8e55Smrg } 10836b042e37fSmrg 108378c4a8e55Smrg # Now, create the wrapper script for func_source use: 108388c4a8e55Smrg func_ltwrapper_scriptname $cwrapper 108398c4a8e55Smrg $RM $func_ltwrapper_scriptname_result 108408c4a8e55Smrg trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 108418c4a8e55Smrg $opt_dry_run || { 108428c4a8e55Smrg # note: this script will not be executed, so do not chmod. 108433169be4bSmrg if test "x$build" = "x$host"; then 108448c4a8e55Smrg $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result 10845b042e37fSmrg else 108468c4a8e55Smrg func_emit_wrapper no > $func_ltwrapper_scriptname_result 10847b042e37fSmrg fi 108488c4a8e55Smrg } 108498c4a8e55Smrg ;; 108508c4a8e55Smrg * ) 108518c4a8e55Smrg $RM $output 108528c4a8e55Smrg trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 10853b042e37fSmrg 108548c4a8e55Smrg func_emit_wrapper no > $output 108558c4a8e55Smrg chmod +x $output 10856b042e37fSmrg ;; 10857b042e37fSmrg esac 108588c4a8e55Smrg } 108598c4a8e55Smrg exit $EXIT_SUCCESS 108608c4a8e55Smrg ;; 108618c4a8e55Smrg esac 10862b042e37fSmrg 108638c4a8e55Smrg # See if we need to build an old-fashioned archive. 108648c4a8e55Smrg for oldlib in $oldlibs; do 10865b042e37fSmrg 108663169be4bSmrg case $build_libtool_libs in 108673169be4bSmrg convenience) 108683169be4bSmrg oldobjs="$libobjs_save $symfileobj" 108693169be4bSmrg addlibs=$convenience 108708c4a8e55Smrg build_libtool_libs=no 108713169be4bSmrg ;; 108723169be4bSmrg module) 108733169be4bSmrg oldobjs=$libobjs_save 108743169be4bSmrg addlibs=$old_convenience 108753169be4bSmrg build_libtool_libs=no 108763169be4bSmrg ;; 108773169be4bSmrg *) 108788c4a8e55Smrg oldobjs="$old_deplibs $non_pic_objects" 108793169be4bSmrg $preload && test -f "$symfileobj" \ 108803169be4bSmrg && func_append oldobjs " $symfileobj" 108813169be4bSmrg addlibs=$old_convenience 108823169be4bSmrg ;; 108833169be4bSmrg esac 10884b042e37fSmrg 108858c4a8e55Smrg if test -n "$addlibs"; then 108863169be4bSmrg gentop=$output_objdir/${outputname}x 10887bd23fbfaSmrg func_append generated " $gentop" 10888b042e37fSmrg 108898c4a8e55Smrg func_extract_archives $gentop $addlibs 10890bd23fbfaSmrg func_append oldobjs " $func_extract_archives_result" 108918c4a8e55Smrg fi 10892b042e37fSmrg 108938c4a8e55Smrg # Do each command in the archive commands. 108943169be4bSmrg if test -n "$old_archive_from_new_cmds" && test yes = "$build_libtool_libs"; then 108958c4a8e55Smrg cmds=$old_archive_from_new_cmds 108968c4a8e55Smrg else 10897b042e37fSmrg 108988c4a8e55Smrg # Add any objects from preloaded convenience libraries 108998c4a8e55Smrg if test -n "$dlprefiles"; then 109003169be4bSmrg gentop=$output_objdir/${outputname}x 10901bd23fbfaSmrg func_append generated " $gentop" 10902b042e37fSmrg 109038c4a8e55Smrg func_extract_archives $gentop $dlprefiles 10904bd23fbfaSmrg func_append oldobjs " $func_extract_archives_result" 109058c4a8e55Smrg fi 10906b042e37fSmrg 109078c4a8e55Smrg # POSIX demands no paths to be encoded in archives. We have 109088c4a8e55Smrg # to avoid creating archives with duplicate basenames if we 109098c4a8e55Smrg # might have to extract them afterwards, e.g., when creating a 109108c4a8e55Smrg # static archive out of a convenience library, or when linking 109118c4a8e55Smrg # the entirety of a libtool archive into another (currently 109128c4a8e55Smrg # not supported by libtool). 109138c4a8e55Smrg if (for obj in $oldobjs 109148c4a8e55Smrg do 109158c4a8e55Smrg func_basename "$obj" 109168c4a8e55Smrg $ECHO "$func_basename_result" 109178c4a8e55Smrg done | sort | sort -uc >/dev/null 2>&1); then 109188c4a8e55Smrg : 109198c4a8e55Smrg else 10920706b6b52Smrg echo "copying selected object files to avoid basename conflicts..." 109213169be4bSmrg gentop=$output_objdir/${outputname}x 10922bd23fbfaSmrg func_append generated " $gentop" 109238c4a8e55Smrg func_mkdir_p "$gentop" 109248c4a8e55Smrg save_oldobjs=$oldobjs 109258c4a8e55Smrg oldobjs= 109268c4a8e55Smrg counter=1 109278c4a8e55Smrg for obj in $save_oldobjs 109288c4a8e55Smrg do 109298c4a8e55Smrg func_basename "$obj" 109303169be4bSmrg objbase=$func_basename_result 109318c4a8e55Smrg case " $oldobjs " in 109328c4a8e55Smrg " ") oldobjs=$obj ;; 109338c4a8e55Smrg *[\ /]"$objbase "*) 109348c4a8e55Smrg while :; do 109358c4a8e55Smrg # Make sure we don't pick an alternate name that also 109368c4a8e55Smrg # overlaps. 109378c4a8e55Smrg newobj=lt$counter-$objbase 109388c4a8e55Smrg func_arith $counter + 1 109398c4a8e55Smrg counter=$func_arith_result 109408c4a8e55Smrg case " $oldobjs " in 109418c4a8e55Smrg *[\ /]"$newobj "*) ;; 109428c4a8e55Smrg *) if test ! -f "$gentop/$newobj"; then break; fi ;; 109438c4a8e55Smrg esac 109448c4a8e55Smrg done 109458c4a8e55Smrg func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" 10946bd23fbfaSmrg func_append oldobjs " $gentop/$newobj" 109478c4a8e55Smrg ;; 10948bd23fbfaSmrg *) func_append oldobjs " $obj" ;; 109498c4a8e55Smrg esac 10950b042e37fSmrg done 10951b042e37fSmrg fi 109520597fb56Smrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 109530597fb56Smrg tool_oldlib=$func_to_tool_file_result 109548c4a8e55Smrg eval cmds=\"$old_archive_cmds\" 10955b042e37fSmrg 109568c4a8e55Smrg func_len " $cmds" 109578c4a8e55Smrg len=$func_len_result 109588c4a8e55Smrg if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 109598c4a8e55Smrg cmds=$old_archive_cmds 10960bd23fbfaSmrg elif test -n "$archiver_list_spec"; then 10961bd23fbfaSmrg func_verbose "using command file archive linking..." 10962bd23fbfaSmrg for obj in $oldobjs 10963bd23fbfaSmrg do 10964bd23fbfaSmrg func_to_tool_file "$obj" 10965bd23fbfaSmrg $ECHO "$func_to_tool_file_result" 10966bd23fbfaSmrg done > $output_objdir/$libname.libcmd 10967bd23fbfaSmrg func_to_tool_file "$output_objdir/$libname.libcmd" 10968bd23fbfaSmrg oldobjs=" $archiver_list_spec$func_to_tool_file_result" 10969bd23fbfaSmrg cmds=$old_archive_cmds 109708c4a8e55Smrg else 109718c4a8e55Smrg # the command line is too long to link in one step, link in parts 109728c4a8e55Smrg func_verbose "using piecewise archive linking..." 109738c4a8e55Smrg save_RANLIB=$RANLIB 109748c4a8e55Smrg RANLIB=: 109758c4a8e55Smrg objlist= 109768c4a8e55Smrg concat_cmds= 109778c4a8e55Smrg save_oldobjs=$oldobjs 109788c4a8e55Smrg oldobjs= 109798c4a8e55Smrg # Is there a better way of finding the last object in the list? 109808c4a8e55Smrg for obj in $save_oldobjs 109818c4a8e55Smrg do 109828c4a8e55Smrg last_oldobj=$obj 109838c4a8e55Smrg done 109848c4a8e55Smrg eval test_cmds=\"$old_archive_cmds\" 109858c4a8e55Smrg func_len " $test_cmds" 109868c4a8e55Smrg len0=$func_len_result 109878c4a8e55Smrg len=$len0 109888c4a8e55Smrg for obj in $save_oldobjs 109898c4a8e55Smrg do 109908c4a8e55Smrg func_len " $obj" 109918c4a8e55Smrg func_arith $len + $func_len_result 109928c4a8e55Smrg len=$func_arith_result 109938c4a8e55Smrg func_append objlist " $obj" 109948c4a8e55Smrg if test "$len" -lt "$max_cmd_len"; then 109958c4a8e55Smrg : 109968c4a8e55Smrg else 109978c4a8e55Smrg # the above command should be used before it gets too long 109988c4a8e55Smrg oldobjs=$objlist 109993169be4bSmrg if test "$obj" = "$last_oldobj"; then 110008c4a8e55Smrg RANLIB=$save_RANLIB 110018c4a8e55Smrg fi 110028c4a8e55Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 110033169be4bSmrg eval concat_cmds=\"\$concat_cmds$old_archive_cmds\" 110048c4a8e55Smrg objlist= 110058c4a8e55Smrg len=$len0 110068c4a8e55Smrg fi 110078c4a8e55Smrg done 110088c4a8e55Smrg RANLIB=$save_RANLIB 110098c4a8e55Smrg oldobjs=$objlist 110103169be4bSmrg if test -z "$oldobjs"; then 110118c4a8e55Smrg eval cmds=\"\$concat_cmds\" 110128c4a8e55Smrg else 110138c4a8e55Smrg eval cmds=\"\$concat_cmds~\$old_archive_cmds\" 110148c4a8e55Smrg fi 110158c4a8e55Smrg fi 110168c4a8e55Smrg fi 110178c4a8e55Smrg func_execute_cmds "$cmds" 'exit $?' 11018b042e37fSmrg done 11019b042e37fSmrg 110208c4a8e55Smrg test -n "$generated" && \ 110218c4a8e55Smrg func_show_eval "${RM}r$generated" 11022b042e37fSmrg 110238c4a8e55Smrg # Now create the libtool archive. 110248c4a8e55Smrg case $output in 110258c4a8e55Smrg *.la) 110268c4a8e55Smrg old_library= 110273169be4bSmrg test yes = "$build_old_libs" && old_library=$libname.$libext 110288c4a8e55Smrg func_verbose "creating $output" 11029b042e37fSmrg 110308c4a8e55Smrg # Preserve any variables that may affect compiler behavior 110318c4a8e55Smrg for var in $variables_saved_for_relink; do 110328c4a8e55Smrg if eval test -z \"\${$var+set}\"; then 110338c4a8e55Smrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 110348c4a8e55Smrg elif eval var_value=\$$var; test -z "$var_value"; then 110358c4a8e55Smrg relink_command="$var=; export $var; $relink_command" 11036b042e37fSmrg else 110378d0bc965Smrg func_quote_arg pretty,unquoted "$var_value" 110388d0bc965Smrg relink_command="$var=$func_quote_arg_unquoted_result; export $var; $relink_command" 11039b042e37fSmrg fi 110408c4a8e55Smrg done 110418c4a8e55Smrg # Quote the link command for shipping. 110428d0bc965Smrg func_quote eval cd "`pwd`" 110438d0bc965Smrg relink_command="($func_quote_result; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" 110448d0bc965Smrg func_quote_arg pretty,unquoted "$relink_command" 110458d0bc965Smrg relink_command=$func_quote_arg_unquoted_result 110463169be4bSmrg if test yes = "$hardcode_automatic"; then 110478c4a8e55Smrg relink_command= 110488c4a8e55Smrg fi 11049b042e37fSmrg 110508c4a8e55Smrg # Only create the output if not a dry run. 110518c4a8e55Smrg $opt_dry_run || { 110528c4a8e55Smrg for installed in no yes; do 110533169be4bSmrg if test yes = "$installed"; then 110548c4a8e55Smrg if test -z "$install_libdir"; then 110558c4a8e55Smrg break 110568c4a8e55Smrg fi 110573169be4bSmrg output=$output_objdir/${outputname}i 110588c4a8e55Smrg # Replace all uninstalled libtool libraries with the installed ones 110598c4a8e55Smrg newdependency_libs= 110608c4a8e55Smrg for deplib in $dependency_libs; do 110618c4a8e55Smrg case $deplib in 110628c4a8e55Smrg *.la) 110638c4a8e55Smrg func_basename "$deplib" 110643169be4bSmrg name=$func_basename_result 110650597fb56Smrg func_resolve_sysroot "$deplib" 110663169be4bSmrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` 110678c4a8e55Smrg test -z "$libdir" && \ 110683169be4bSmrg func_fatal_error "'$deplib' is not a valid libtool archive" 11069bd23fbfaSmrg func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" 11070bd23fbfaSmrg ;; 11071bd23fbfaSmrg -L*) 11072bd23fbfaSmrg func_stripname -L '' "$deplib" 11073bd23fbfaSmrg func_replace_sysroot "$func_stripname_result" 11074bd23fbfaSmrg func_append newdependency_libs " -L$func_replace_sysroot_result" 11075bd23fbfaSmrg ;; 11076bd23fbfaSmrg -R*) 11077bd23fbfaSmrg func_stripname -R '' "$deplib" 11078bd23fbfaSmrg func_replace_sysroot "$func_stripname_result" 11079bd23fbfaSmrg func_append newdependency_libs " -R$func_replace_sysroot_result" 110808c4a8e55Smrg ;; 11081bd23fbfaSmrg *) func_append newdependency_libs " $deplib" ;; 110828c4a8e55Smrg esac 110838c4a8e55Smrg done 110843169be4bSmrg dependency_libs=$newdependency_libs 110858c4a8e55Smrg newdlfiles= 110868c4a8e55Smrg 110878c4a8e55Smrg for lib in $dlfiles; do 110888c4a8e55Smrg case $lib in 110898c4a8e55Smrg *.la) 110908c4a8e55Smrg func_basename "$lib" 110913169be4bSmrg name=$func_basename_result 110923169be4bSmrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 110938c4a8e55Smrg test -z "$libdir" && \ 110943169be4bSmrg func_fatal_error "'$lib' is not a valid libtool archive" 11095bd23fbfaSmrg func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" 110968c4a8e55Smrg ;; 11097bd23fbfaSmrg *) func_append newdlfiles " $lib" ;; 110988c4a8e55Smrg esac 110998c4a8e55Smrg done 111003169be4bSmrg dlfiles=$newdlfiles 111018c4a8e55Smrg newdlprefiles= 111028c4a8e55Smrg for lib in $dlprefiles; do 111038c4a8e55Smrg case $lib in 111048c4a8e55Smrg *.la) 111058c4a8e55Smrg # Only pass preopened files to the pseudo-archive (for 111068c4a8e55Smrg # eventual linking with the app. that links it) if we 111078c4a8e55Smrg # didn't already link the preopened objects directly into 111088c4a8e55Smrg # the library: 111098c4a8e55Smrg func_basename "$lib" 111103169be4bSmrg name=$func_basename_result 111113169be4bSmrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 111128c4a8e55Smrg test -z "$libdir" && \ 111133169be4bSmrg func_fatal_error "'$lib' is not a valid libtool archive" 11114bd23fbfaSmrg func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" 111158c4a8e55Smrg ;; 111168c4a8e55Smrg esac 111178c4a8e55Smrg done 111183169be4bSmrg dlprefiles=$newdlprefiles 111198c4a8e55Smrg else 111208c4a8e55Smrg newdlfiles= 111218c4a8e55Smrg for lib in $dlfiles; do 111228c4a8e55Smrg case $lib in 111233169be4bSmrg [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; 111248c4a8e55Smrg *) abs=`pwd`"/$lib" ;; 111258c4a8e55Smrg esac 11126bd23fbfaSmrg func_append newdlfiles " $abs" 111278c4a8e55Smrg done 111283169be4bSmrg dlfiles=$newdlfiles 111298c4a8e55Smrg newdlprefiles= 111308c4a8e55Smrg for lib in $dlprefiles; do 111318c4a8e55Smrg case $lib in 111323169be4bSmrg [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; 111338c4a8e55Smrg *) abs=`pwd`"/$lib" ;; 111348c4a8e55Smrg esac 11135bd23fbfaSmrg func_append newdlprefiles " $abs" 111368c4a8e55Smrg done 111373169be4bSmrg dlprefiles=$newdlprefiles 111388c4a8e55Smrg fi 111398c4a8e55Smrg $RM $output 111408c4a8e55Smrg # place dlname in correct position for cygwin 11141706b6b52Smrg # In fact, it would be nice if we could use this code for all target 11142706b6b52Smrg # systems that can't hard-code library paths into their executables 11143706b6b52Smrg # and that have no shared library path variable independent of PATH, 11144706b6b52Smrg # but it turns out we can't easily determine that from inspecting 11145706b6b52Smrg # libtool variables, so we have to hard-code the OSs to which it 11146706b6b52Smrg # applies here; at the moment, that means platforms that use the PE 11147706b6b52Smrg # object format with DLL files. See the long comment at the top of 11148706b6b52Smrg # tests/bindir.at for full details. 111498c4a8e55Smrg tdlname=$dlname 111508c4a8e55Smrg case $host,$output,$installed,$module,$dlname in 11151706b6b52Smrg *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) 11152706b6b52Smrg # If a -bindir argument was supplied, place the dll there. 111533169be4bSmrg if test -n "$bindir"; then 11154706b6b52Smrg func_relative_path "$install_libdir" "$bindir" 111553169be4bSmrg tdlname=$func_relative_path_result/$dlname 11156706b6b52Smrg else 11157706b6b52Smrg # Otherwise fall back on heuristic. 11158706b6b52Smrg tdlname=../bin/$dlname 11159706b6b52Smrg fi 11160706b6b52Smrg ;; 111618c4a8e55Smrg esac 111628c4a8e55Smrg $ECHO > $output "\ 111638c4a8e55Smrg# $outputname - a libtool library file 111643169be4bSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 111658c4a8e55Smrg# 111668c4a8e55Smrg# Please DO NOT delete this file! 111678c4a8e55Smrg# It is necessary for linking the library. 11168b042e37fSmrg 111698c4a8e55Smrg# The name that we can dlopen(3). 111708c4a8e55Smrgdlname='$tdlname' 11171b042e37fSmrg 111728c4a8e55Smrg# Names of this library. 111738c4a8e55Smrglibrary_names='$library_names' 11174b042e37fSmrg 111758c4a8e55Smrg# The name of the static archive. 111768c4a8e55Smrgold_library='$old_library' 11177b042e37fSmrg 111783169be4bSmrg# Linker flags that cannot go in dependency_libs. 111798c4a8e55Smrginherited_linker_flags='$new_inherited_linker_flags' 11180b042e37fSmrg 111818c4a8e55Smrg# Libraries that this one depends upon. 111828c4a8e55Smrgdependency_libs='$dependency_libs' 11183b042e37fSmrg 111848c4a8e55Smrg# Names of additional weak libraries provided by this library 111858c4a8e55Smrgweak_library_names='$weak_libs' 11186b042e37fSmrg 111878c4a8e55Smrg# Version information for $libname. 111888c4a8e55Smrgcurrent=$current 111898c4a8e55Smrgage=$age 111908c4a8e55Smrgrevision=$revision 11191b042e37fSmrg 111928c4a8e55Smrg# Is this an already installed library? 111938c4a8e55Smrginstalled=$installed 11194b042e37fSmrg 111958c4a8e55Smrg# Should we warn about portability when linking against -modules? 111968c4a8e55Smrgshouldnotlink=$module 11197b042e37fSmrg 111988c4a8e55Smrg# Files to dlopen/dlpreopen 111998c4a8e55Smrgdlopen='$dlfiles' 112008c4a8e55Smrgdlpreopen='$dlprefiles' 11201b042e37fSmrg 112028c4a8e55Smrg# Directory that this library needs to be installed in: 112038c4a8e55Smrglibdir='$install_libdir'" 112043169be4bSmrg if test no,yes = "$installed,$need_relink"; then 112058c4a8e55Smrg $ECHO >> $output "\ 112068c4a8e55Smrgrelink_command=\"$relink_command\"" 112078c4a8e55Smrg fi 112088c4a8e55Smrg done 112098c4a8e55Smrg } 11210b042e37fSmrg 112118c4a8e55Smrg # Do a symbolic link so that the libtool archive can be found in 112128c4a8e55Smrg # LD_LIBRARY_PATH before the program is installed. 112138c4a8e55Smrg func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' 112148c4a8e55Smrg ;; 112158c4a8e55Smrg esac 112168c4a8e55Smrg exit $EXIT_SUCCESS 112178c4a8e55Smrg} 11218b042e37fSmrg 112193169be4bSmrgif test link = "$opt_mode" || test relink = "$opt_mode"; then 112203169be4bSmrg func_mode_link ${1+"$@"} 112213169be4bSmrgfi 11222b042e37fSmrg 11223b042e37fSmrg 112248c4a8e55Smrg# func_mode_uninstall arg... 112258c4a8e55Smrgfunc_mode_uninstall () 112268c4a8e55Smrg{ 112273169be4bSmrg $debug_cmd 112283169be4bSmrg 112293169be4bSmrg RM=$nonopt 11230b042e37fSmrg files= 112313169be4bSmrg rmforce=false 11232b042e37fSmrg exit_status=0 11233b042e37fSmrg 11234b042e37fSmrg # This variable tells wrapper scripts just to set variables rather 11235b042e37fSmrg # than running their programs. 112363169be4bSmrg libtool_install_magic=$magic 11237b042e37fSmrg 11238b042e37fSmrg for arg 11239b042e37fSmrg do 11240b042e37fSmrg case $arg in 112413169be4bSmrg -f) func_append RM " $arg"; rmforce=: ;; 11242bd23fbfaSmrg -*) func_append RM " $arg" ;; 11243bd23fbfaSmrg *) func_append files " $arg" ;; 11244b042e37fSmrg esac 11245b042e37fSmrg done 11246b042e37fSmrg 112478c4a8e55Smrg test -z "$RM" && \ 112488c4a8e55Smrg func_fatal_help "you must specify an RM program" 11249b042e37fSmrg 11250b042e37fSmrg rmdirs= 11251b042e37fSmrg 11252b042e37fSmrg for file in $files; do 112538c4a8e55Smrg func_dirname "$file" "" "." 112543169be4bSmrg dir=$func_dirname_result 112553169be4bSmrg if test . = "$dir"; then 112563169be4bSmrg odir=$objdir 11257b042e37fSmrg else 112583169be4bSmrg odir=$dir/$objdir 11259b042e37fSmrg fi 112608c4a8e55Smrg func_basename "$file" 112613169be4bSmrg name=$func_basename_result 112623169be4bSmrg test uninstall = "$opt_mode" && odir=$dir 11263b042e37fSmrg 11264bd23fbfaSmrg # Remember odir for removal later, being careful to avoid duplicates 112653169be4bSmrg if test clean = "$opt_mode"; then 11266b042e37fSmrg case " $rmdirs " in 11267bd23fbfaSmrg *" $odir "*) ;; 11268bd23fbfaSmrg *) func_append rmdirs " $odir" ;; 11269b042e37fSmrg esac 11270b042e37fSmrg fi 11271b042e37fSmrg 11272b042e37fSmrg # Don't error if the file doesn't exist and rm -f was used. 112738c4a8e55Smrg if { test -L "$file"; } >/dev/null 2>&1 || 112748c4a8e55Smrg { test -h "$file"; } >/dev/null 2>&1 || 112758c4a8e55Smrg test -f "$file"; then 11276b042e37fSmrg : 11277b042e37fSmrg elif test -d "$file"; then 11278b042e37fSmrg exit_status=1 11279b042e37fSmrg continue 112803169be4bSmrg elif $rmforce; then 11281b042e37fSmrg continue 11282b042e37fSmrg fi 11283b042e37fSmrg 112843169be4bSmrg rmfiles=$file 11285b042e37fSmrg 11286b042e37fSmrg case $name in 11287b042e37fSmrg *.la) 11288b042e37fSmrg # Possibly a libtool archive, so verify it. 112898c4a8e55Smrg if func_lalib_p "$file"; then 112908c4a8e55Smrg func_source $dir/$name 11291b042e37fSmrg 11292b042e37fSmrg # Delete the libtool libraries and symlinks. 11293b042e37fSmrg for n in $library_names; do 11294bd23fbfaSmrg func_append rmfiles " $odir/$n" 11295b042e37fSmrg done 11296bd23fbfaSmrg test -n "$old_library" && func_append rmfiles " $odir/$old_library" 11297b042e37fSmrg 112983169be4bSmrg case $opt_mode in 11299b042e37fSmrg clean) 11300bd23fbfaSmrg case " $library_names " in 11301b042e37fSmrg *" $dlname "*) ;; 11302bd23fbfaSmrg *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; 11303b042e37fSmrg esac 11304bd23fbfaSmrg test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" 11305b042e37fSmrg ;; 11306b042e37fSmrg uninstall) 11307b042e37fSmrg if test -n "$library_names"; then 11308b042e37fSmrg # Do each command in the postuninstall commands. 113093169be4bSmrg func_execute_cmds "$postuninstall_cmds" '$rmforce || exit_status=1' 11310b042e37fSmrg fi 11311b042e37fSmrg 11312b042e37fSmrg if test -n "$old_library"; then 11313b042e37fSmrg # Do each command in the old_postuninstall commands. 113143169be4bSmrg func_execute_cmds "$old_postuninstall_cmds" '$rmforce || exit_status=1' 11315b042e37fSmrg fi 11316b042e37fSmrg # FIXME: should reinstall the best remaining shared library. 11317b042e37fSmrg ;; 11318b042e37fSmrg esac 11319b042e37fSmrg fi 11320b042e37fSmrg ;; 11321b042e37fSmrg 11322b042e37fSmrg *.lo) 11323b042e37fSmrg # Possibly a libtool object, so verify it. 113248c4a8e55Smrg if func_lalib_p "$file"; then 11325b042e37fSmrg 11326b042e37fSmrg # Read the .lo file 113278c4a8e55Smrg func_source $dir/$name 11328b042e37fSmrg 11329b042e37fSmrg # Add PIC object to the list of files to remove. 113303169be4bSmrg if test -n "$pic_object" && test none != "$pic_object"; then 11331bd23fbfaSmrg func_append rmfiles " $dir/$pic_object" 11332b042e37fSmrg fi 11333b042e37fSmrg 11334b042e37fSmrg # Add non-PIC object to the list of files to remove. 113353169be4bSmrg if test -n "$non_pic_object" && test none != "$non_pic_object"; then 11336bd23fbfaSmrg func_append rmfiles " $dir/$non_pic_object" 11337b042e37fSmrg fi 11338b042e37fSmrg fi 11339b042e37fSmrg ;; 11340b042e37fSmrg 11341b042e37fSmrg *) 113423169be4bSmrg if test clean = "$opt_mode"; then 11343b042e37fSmrg noexename=$name 11344b042e37fSmrg case $file in 11345b042e37fSmrg *.exe) 113468c4a8e55Smrg func_stripname '' '.exe' "$file" 113478c4a8e55Smrg file=$func_stripname_result 113488c4a8e55Smrg func_stripname '' '.exe' "$name" 113498c4a8e55Smrg noexename=$func_stripname_result 11350b042e37fSmrg # $file with .exe has already been added to rmfiles, 11351b042e37fSmrg # add $file without .exe 11352bd23fbfaSmrg func_append rmfiles " $file" 11353b042e37fSmrg ;; 11354b042e37fSmrg esac 11355b042e37fSmrg # Do a test to see if this is a libtool program. 113568c4a8e55Smrg if func_ltwrapper_p "$file"; then 113578c4a8e55Smrg if func_ltwrapper_executable_p "$file"; then 113588c4a8e55Smrg func_ltwrapper_scriptname "$file" 113598c4a8e55Smrg relink_command= 113608c4a8e55Smrg func_source $func_ltwrapper_scriptname_result 11361bd23fbfaSmrg func_append rmfiles " $func_ltwrapper_scriptname_result" 113628c4a8e55Smrg else 113638c4a8e55Smrg relink_command= 113648c4a8e55Smrg func_source $dir/$noexename 113658c4a8e55Smrg fi 11366b042e37fSmrg 11367b042e37fSmrg # note $name still contains .exe if it was in $file originally 11368b042e37fSmrg # as does the version of $file that was added into $rmfiles 113693169be4bSmrg func_append rmfiles " $odir/$name $odir/${name}S.$objext" 113703169be4bSmrg if test yes = "$fast_install" && test -n "$relink_command"; then 11371bd23fbfaSmrg func_append rmfiles " $odir/lt-$name" 11372b042e37fSmrg fi 113733169be4bSmrg if test "X$noexename" != "X$name"; then 113743169be4bSmrg func_append rmfiles " $odir/lt-$noexename.c" 11375b042e37fSmrg fi 11376b042e37fSmrg fi 11377b042e37fSmrg fi 11378b042e37fSmrg ;; 11379b042e37fSmrg esac 113808c4a8e55Smrg func_show_eval "$RM $rmfiles" 'exit_status=1' 11381b042e37fSmrg done 11382b042e37fSmrg 113833169be4bSmrg # Try to remove the $objdir's in the directories where we deleted files 11384b042e37fSmrg for dir in $rmdirs; do 11385b042e37fSmrg if test -d "$dir"; then 113868c4a8e55Smrg func_show_eval "rmdir $dir >/dev/null 2>&1" 11387b042e37fSmrg fi 11388b042e37fSmrg done 11389b042e37fSmrg 11390b042e37fSmrg exit $exit_status 113918c4a8e55Smrg} 11392b042e37fSmrg 113933169be4bSmrgif test uninstall = "$opt_mode" || test clean = "$opt_mode"; then 113943169be4bSmrg func_mode_uninstall ${1+"$@"} 113953169be4bSmrgfi 11396b042e37fSmrg 11397bd23fbfaSmrgtest -z "$opt_mode" && { 113983169be4bSmrg help=$generic_help 113998c4a8e55Smrg func_fatal_help "you must specify a MODE" 114008c4a8e55Smrg} 114018c4a8e55Smrg 114028c4a8e55Smrgtest -z "$exec_cmd" && \ 114033169be4bSmrg func_fatal_help "invalid operation mode '$opt_mode'" 11404b042e37fSmrg 11405b042e37fSmrgif test -n "$exec_cmd"; then 114068c4a8e55Smrg eval exec "$exec_cmd" 11407b042e37fSmrg exit $EXIT_FAILURE 11408b042e37fSmrgfi 11409b042e37fSmrg 114108c4a8e55Smrgexit $exit_status 11411b042e37fSmrg 11412b042e37fSmrg 11413b042e37fSmrg# The TAGs below are defined such that we never get into a situation 114143169be4bSmrg# where we disable both kinds of libraries. Given conflicting 11415b042e37fSmrg# choices, we go for a static library, that is the most portable, 11416b042e37fSmrg# since we can't tell whether shared libraries were disabled because 11417b042e37fSmrg# the user asked for that or because the platform doesn't support 11418b042e37fSmrg# them. This is particularly important on AIX, because we don't 11419b042e37fSmrg# support having both static and shared libraries enabled at the same 11420b042e37fSmrg# time on that platform, so we default to a shared-only configuration. 11421b042e37fSmrg# If a disable-shared tag is given, we'll fallback to a static-only 11422b042e37fSmrg# configuration. But we'll never go from static-only to shared-only. 11423b042e37fSmrg 11424b042e37fSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared 114258c4a8e55Smrgbuild_libtool_libs=no 114268c4a8e55Smrgbuild_old_libs=yes 11427b042e37fSmrg# ### END LIBTOOL TAG CONFIG: disable-shared 11428b042e37fSmrg 11429b042e37fSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static 114308c4a8e55Smrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` 11431b042e37fSmrg# ### END LIBTOOL TAG CONFIG: disable-static 11432b042e37fSmrg 11433b042e37fSmrg# Local Variables: 11434b042e37fSmrg# mode:shell-script 11435b042e37fSmrg# sh-indentation:2 11436b042e37fSmrg# End: 11437