ltmain.sh revision 5b16253f
15b16253fSmrg#! /usr/bin/env sh 25ec34c4cSmrg## DO NOT EDIT - This file generated from ./build-aux/ltmain.in 35b16253fSmrg## by inline-source v2019-02-19.15 4994689c1Smrg 55b16253fSmrg# libtool (GNU libtool) 2.4.7 65ec34c4cSmrg# Provide generalized library-building support services. 7994689c1Smrg# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 8994689c1Smrg 95b16253fSmrg# Copyright (C) 1996-2019, 2021-2022 Free Software Foundation, Inc. 10994689c1Smrg# This is free software; see the source for copying conditions. There is NO 11994689c1Smrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12994689c1Smrg 13994689c1Smrg# GNU Libtool is free software; you can redistribute it and/or modify 147a84e134Smrg# it under the terms of the GNU General Public License as published by 157a84e134Smrg# the Free Software Foundation; either version 2 of the License, or 167a84e134Smrg# (at your option) any later version. 177a84e134Smrg# 18994689c1Smrg# As a special exception to the GNU General Public License, 19994689c1Smrg# if you distribute this file as part of a program or library that 20994689c1Smrg# is built using GNU Libtool, you may include this file under the 21994689c1Smrg# same distribution terms that you use for the rest of that program. 22994689c1Smrg# 23994689c1Smrg# GNU Libtool is distributed in the hope that it will be useful, but 247a84e134Smrg# WITHOUT ANY WARRANTY; without even the implied warranty of 257a84e134Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 267a84e134Smrg# General Public License for more details. 277a84e134Smrg# 287a84e134Smrg# You should have received a copy of the GNU General Public License 295ec34c4cSmrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 30e1e1713cSmrg 317a84e134Smrg 32994689c1SmrgPROGRAM=libtool 337a84e134SmrgPACKAGE=libtool 345b16253fSmrgVERSION=2.4.7 355b16253fSmrgpackage_revision=2.4.7 36ab902922Smrg 375ec34c4cSmrg 385ec34c4cSmrg## ------ ## 395ec34c4cSmrg## Usage. ## 405ec34c4cSmrg## ------ ## 415ec34c4cSmrg 425ec34c4cSmrg# Run './libtool --help' for help with using this script from the 435ec34c4cSmrg# command line. 445ec34c4cSmrg 455ec34c4cSmrg 465ec34c4cSmrg## ------------------------------- ## 475ec34c4cSmrg## User overridable command paths. ## 485ec34c4cSmrg## ------------------------------- ## 495ec34c4cSmrg 505ec34c4cSmrg# After configure completes, it has a better idea of some of the 515ec34c4cSmrg# shell tools we need than the defaults used by the functions shared 525ec34c4cSmrg# with bootstrap, so set those here where they can still be over- 535ec34c4cSmrg# ridden by the user, but otherwise take precedence. 545ec34c4cSmrg 555ec34c4cSmrg: ${AUTOCONF="autoconf"} 565ec34c4cSmrg: ${AUTOMAKE="automake"} 575ec34c4cSmrg 585ec34c4cSmrg 595ec34c4cSmrg## -------------------------- ## 605ec34c4cSmrg## Source external libraries. ## 615ec34c4cSmrg## -------------------------- ## 625ec34c4cSmrg 635ec34c4cSmrg# Much of our low-level functionality needs to be sourced from external 645ec34c4cSmrg# libraries, which are installed to $pkgauxdir. 655ec34c4cSmrg 665ec34c4cSmrg# Set a version string for this script. 675b16253fSmrgscriptversion=2019-02-19.15; # UTC 685ec34c4cSmrg 695ec34c4cSmrg# General shell script boiler plate, and helper functions. 705ec34c4cSmrg# Written by Gary V. Vaughan, 2004 715ec34c4cSmrg 725b16253fSmrg# This is free software. There is NO warranty; not even for 735b16253fSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 745b16253fSmrg# 755b16253fSmrg# Copyright (C) 2004-2019, 2021 Bootstrap Authors 765b16253fSmrg# 775b16253fSmrg# This file is dual licensed under the terms of the MIT license 785b16253fSmrg# <https://opensource.org/license/MIT>, and GPL version 2 or later 795b16253fSmrg# <http://www.gnu.org/licenses/gpl-2.0.html>. You must apply one of 805b16253fSmrg# these licenses when using or redistributing this software or any of 815b16253fSmrg# the files within it. See the URLs above, or the file `LICENSE` 825b16253fSmrg# included in the Bootstrap distribution for the full license texts. 835ec34c4cSmrg 845b16253fSmrg# Please report bugs or propose patches to: 855b16253fSmrg# <https://github.com/gnulib-modules/bootstrap/issues> 865ec34c4cSmrg 875ec34c4cSmrg 885ec34c4cSmrg## ------ ## 895ec34c4cSmrg## Usage. ## 905ec34c4cSmrg## ------ ## 915ec34c4cSmrg 925ec34c4cSmrg# Evaluate this file near the top of your script to gain access to 935ec34c4cSmrg# the functions and variables defined here: 945ec34c4cSmrg# 955ec34c4cSmrg# . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh 965ec34c4cSmrg# 975ec34c4cSmrg# If you need to override any of the default environment variable 985ec34c4cSmrg# settings, do that before evaluating this file. 995ec34c4cSmrg 1005ec34c4cSmrg 1015ec34c4cSmrg## -------------------- ## 1025ec34c4cSmrg## Shell normalisation. ## 1035ec34c4cSmrg## -------------------- ## 1045ec34c4cSmrg 1055ec34c4cSmrg# Some shells need a little help to be as Bourne compatible as possible. 1065ec34c4cSmrg# Before doing anything else, make sure all that help has been provided! 1075ec34c4cSmrg 1085ec34c4cSmrgDUALCASE=1; export DUALCASE # for MKS sh 1095ec34c4cSmrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : 110ab902922Smrg emulate sh 111ab902922Smrg NULLCMD=: 1125ec34c4cSmrg # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which 113ab902922Smrg # is contrary to our usage. Disable this feature. 114ab902922Smrg alias -g '${1+"$@"}'='"$@"' 1157a84e134Smrg setopt NO_GLOB_SUBST 116ab902922Smrgelse 1175ec34c4cSmrg case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac 1187a84e134Smrgfi 119e1e1713cSmrg 1205ec34c4cSmrg# NLS nuisances: We save the old values in case they are required later. 1215ec34c4cSmrg_G_user_locale= 1225ec34c4cSmrg_G_safe_locale= 1235ec34c4cSmrgfor _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 124ab902922Smrgdo 1255ec34c4cSmrg eval "if test set = \"\${$_G_var+set}\"; then 1265ec34c4cSmrg save_$_G_var=\$$_G_var 1275ec34c4cSmrg $_G_var=C 1285ec34c4cSmrg export $_G_var 1295ec34c4cSmrg _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\" 1305ec34c4cSmrg _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\" 131ab902922Smrg fi" 132ab902922Smrgdone 1335b16253fSmrg# These NLS vars are set unconditionally (bootstrap issue #24). Unset those 1345b16253fSmrg# in case the environment reset is needed later and the $save_* variant is not 1355b16253fSmrg# defined (see the code above). 1365b16253fSmrgLC_ALL=C 1375b16253fSmrgLANGUAGE=C 1385b16253fSmrgexport LANGUAGE LC_ALL 139994689c1Smrg 1405ec34c4cSmrg# Make sure IFS has a sensible default 1415ec34c4cSmrgsp=' ' 1425ec34c4cSmrgnl=' 1435ec34c4cSmrg' 1445ec34c4cSmrgIFS="$sp $nl" 1455ec34c4cSmrg 1465ec34c4cSmrg# There are apparently some retarded systems that use ';' as a PATH separator! 1475ec34c4cSmrgif test "${PATH_SEPARATOR+set}" != set; then 1485ec34c4cSmrg PATH_SEPARATOR=: 1495ec34c4cSmrg (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { 1505ec34c4cSmrg (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || 1515ec34c4cSmrg PATH_SEPARATOR=';' 1525ec34c4cSmrg } 1535ec34c4cSmrgfi 154994689c1Smrg 155994689c1Smrg 1565b16253fSmrg# func_unset VAR 1575b16253fSmrg# -------------- 1585b16253fSmrg# Portably unset VAR. 1595b16253fSmrg# In some shells, an 'unset VAR' statement leaves a non-zero return 1605b16253fSmrg# status if VAR is already unset, which might be problematic if the 1615b16253fSmrg# statement is used at the end of a function (thus poisoning its return 1625b16253fSmrg# value) or when 'set -e' is active (causing even a spurious abort of 1635b16253fSmrg# the script in this case). 1645b16253fSmrgfunc_unset () 1655b16253fSmrg{ 1665b16253fSmrg { eval $1=; (eval unset $1) >/dev/null 2>&1 && eval unset $1 || : ; } 1675b16253fSmrg} 1685b16253fSmrg 1695b16253fSmrg 1705b16253fSmrg# Make sure CDPATH doesn't cause `cd` commands to output the target dir. 1715b16253fSmrgfunc_unset CDPATH 1725b16253fSmrg 1735b16253fSmrg# Make sure ${,E,F}GREP behave sanely. 1745b16253fSmrgfunc_unset GREP_OPTIONS 1755b16253fSmrg 176994689c1Smrg 1775ec34c4cSmrg## ------------------------- ## 1785ec34c4cSmrg## Locate command utilities. ## 1795ec34c4cSmrg## ------------------------- ## 1805ec34c4cSmrg 1815ec34c4cSmrg 1825ec34c4cSmrg# func_executable_p FILE 1835ec34c4cSmrg# ---------------------- 1845ec34c4cSmrg# Check that FILE is an executable regular file. 1855ec34c4cSmrgfunc_executable_p () 1865ec34c4cSmrg{ 1875ec34c4cSmrg test -f "$1" && test -x "$1" 1885ec34c4cSmrg} 1895ec34c4cSmrg 1905ec34c4cSmrg 1915ec34c4cSmrg# func_path_progs PROGS_LIST CHECK_FUNC [PATH] 1925ec34c4cSmrg# -------------------------------------------- 1935ec34c4cSmrg# Search for either a program that responds to --version with output 1945ec34c4cSmrg# containing "GNU", or else returned by CHECK_FUNC otherwise, by 1955ec34c4cSmrg# trying all the directories in PATH with each of the elements of 1965ec34c4cSmrg# PROGS_LIST. 1975ec34c4cSmrg# 1985ec34c4cSmrg# CHECK_FUNC should accept the path to a candidate program, and 1995ec34c4cSmrg# set $func_check_prog_result if it truncates its output less than 2005ec34c4cSmrg# $_G_path_prog_max characters. 2015ec34c4cSmrgfunc_path_progs () 2025ec34c4cSmrg{ 2035ec34c4cSmrg _G_progs_list=$1 2045ec34c4cSmrg _G_check_func=$2 2055ec34c4cSmrg _G_PATH=${3-"$PATH"} 2065ec34c4cSmrg 2075ec34c4cSmrg _G_path_prog_max=0 2085ec34c4cSmrg _G_path_prog_found=false 2095ec34c4cSmrg _G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:} 2105ec34c4cSmrg for _G_dir in $_G_PATH; do 2115ec34c4cSmrg IFS=$_G_save_IFS 2125ec34c4cSmrg test -z "$_G_dir" && _G_dir=. 2135ec34c4cSmrg for _G_prog_name in $_G_progs_list; do 2145ec34c4cSmrg for _exeext in '' .EXE; do 2155ec34c4cSmrg _G_path_prog=$_G_dir/$_G_prog_name$_exeext 2165ec34c4cSmrg func_executable_p "$_G_path_prog" || continue 2175ec34c4cSmrg case `"$_G_path_prog" --version 2>&1` in 2185ec34c4cSmrg *GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;; 2195ec34c4cSmrg *) $_G_check_func $_G_path_prog 2205ec34c4cSmrg func_path_progs_result=$func_check_prog_result 2215ec34c4cSmrg ;; 2225ec34c4cSmrg esac 2235ec34c4cSmrg $_G_path_prog_found && break 3 2245ec34c4cSmrg done 2255ec34c4cSmrg done 2265ec34c4cSmrg done 2275ec34c4cSmrg IFS=$_G_save_IFS 2285ec34c4cSmrg test -z "$func_path_progs_result" && { 2295ec34c4cSmrg echo "no acceptable sed could be found in \$PATH" >&2 2305ec34c4cSmrg exit 1 2315ec34c4cSmrg } 2325ec34c4cSmrg} 2335ec34c4cSmrg 2345ec34c4cSmrg 2355ec34c4cSmrg# We want to be able to use the functions in this file before configure 2365ec34c4cSmrg# has figured out where the best binaries are kept, which means we have 2375ec34c4cSmrg# to search for them ourselves - except when the results are already set 2385ec34c4cSmrg# where we skip the searches. 2395ec34c4cSmrg 2405ec34c4cSmrg# Unless the user overrides by setting SED, search the path for either GNU 2415ec34c4cSmrg# sed, or the sed that truncates its output the least. 2425ec34c4cSmrgtest -z "$SED" && { 2435ec34c4cSmrg _G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ 2445ec34c4cSmrg for _G_i in 1 2 3 4 5 6 7; do 2455ec34c4cSmrg _G_sed_script=$_G_sed_script$nl$_G_sed_script 2465ec34c4cSmrg done 2475ec34c4cSmrg echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed 2485ec34c4cSmrg _G_sed_script= 2495ec34c4cSmrg 2505ec34c4cSmrg func_check_prog_sed () 2515ec34c4cSmrg { 2525ec34c4cSmrg _G_path_prog=$1 2535ec34c4cSmrg 2545ec34c4cSmrg _G_count=0 2555ec34c4cSmrg printf 0123456789 >conftest.in 2565ec34c4cSmrg while : 2575ec34c4cSmrg do 2585ec34c4cSmrg cat conftest.in conftest.in >conftest.tmp 2595ec34c4cSmrg mv conftest.tmp conftest.in 2605ec34c4cSmrg cp conftest.in conftest.nl 2615ec34c4cSmrg echo '' >> conftest.nl 2625ec34c4cSmrg "$_G_path_prog" -f conftest.sed <conftest.nl >conftest.out 2>/dev/null || break 2635ec34c4cSmrg diff conftest.out conftest.nl >/dev/null 2>&1 || break 2645ec34c4cSmrg _G_count=`expr $_G_count + 1` 2655ec34c4cSmrg if test "$_G_count" -gt "$_G_path_prog_max"; then 2665ec34c4cSmrg # Best one so far, save it but keep looking for a better one 2675ec34c4cSmrg func_check_prog_result=$_G_path_prog 2685ec34c4cSmrg _G_path_prog_max=$_G_count 2695ec34c4cSmrg fi 2705ec34c4cSmrg # 10*(2^10) chars as input seems more than enough 2715ec34c4cSmrg test 10 -lt "$_G_count" && break 2725ec34c4cSmrg done 2735ec34c4cSmrg rm -f conftest.in conftest.tmp conftest.nl conftest.out 2745ec34c4cSmrg } 2755ec34c4cSmrg 2765b16253fSmrg func_path_progs "sed gsed" func_check_prog_sed "$PATH:/usr/xpg4/bin" 2775ec34c4cSmrg rm -f conftest.sed 2785ec34c4cSmrg SED=$func_path_progs_result 2795ec34c4cSmrg} 2805ec34c4cSmrg 2815ec34c4cSmrg 2825ec34c4cSmrg# Unless the user overrides by setting GREP, search the path for either GNU 2835ec34c4cSmrg# grep, or the grep that truncates its output the least. 2845ec34c4cSmrgtest -z "$GREP" && { 2855ec34c4cSmrg func_check_prog_grep () 2865ec34c4cSmrg { 2875ec34c4cSmrg _G_path_prog=$1 2885ec34c4cSmrg 2895ec34c4cSmrg _G_count=0 2905ec34c4cSmrg _G_path_prog_max=0 2915ec34c4cSmrg printf 0123456789 >conftest.in 2925ec34c4cSmrg while : 2935ec34c4cSmrg do 2945ec34c4cSmrg cat conftest.in conftest.in >conftest.tmp 2955ec34c4cSmrg mv conftest.tmp conftest.in 2965ec34c4cSmrg cp conftest.in conftest.nl 2975ec34c4cSmrg echo 'GREP' >> conftest.nl 2985ec34c4cSmrg "$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' <conftest.nl >conftest.out 2>/dev/null || break 2995ec34c4cSmrg diff conftest.out conftest.nl >/dev/null 2>&1 || break 3005ec34c4cSmrg _G_count=`expr $_G_count + 1` 3015ec34c4cSmrg if test "$_G_count" -gt "$_G_path_prog_max"; then 3025ec34c4cSmrg # Best one so far, save it but keep looking for a better one 3035ec34c4cSmrg func_check_prog_result=$_G_path_prog 3045ec34c4cSmrg _G_path_prog_max=$_G_count 3055ec34c4cSmrg fi 3065ec34c4cSmrg # 10*(2^10) chars as input seems more than enough 3075ec34c4cSmrg test 10 -lt "$_G_count" && break 3085ec34c4cSmrg done 3095ec34c4cSmrg rm -f conftest.in conftest.tmp conftest.nl conftest.out 3105ec34c4cSmrg } 3115ec34c4cSmrg 3125b16253fSmrg func_path_progs "grep ggrep" func_check_prog_grep "$PATH:/usr/xpg4/bin" 3135ec34c4cSmrg GREP=$func_path_progs_result 3145ec34c4cSmrg} 3155ec34c4cSmrg 3165ec34c4cSmrg 3175ec34c4cSmrg## ------------------------------- ## 3185ec34c4cSmrg## User overridable command paths. ## 3195ec34c4cSmrg## ------------------------------- ## 3205ec34c4cSmrg 3215ec34c4cSmrg# All uppercase variable names are used for environment variables. These 3225ec34c4cSmrg# variables can be overridden by the user before calling a script that 3235ec34c4cSmrg# uses them if a suitable command of that name is not already available 3245ec34c4cSmrg# in the command search PATH. 325994689c1Smrg 326994689c1Smrg: ${CP="cp -f"} 3275ec34c4cSmrg: ${ECHO="printf %s\n"} 3285ec34c4cSmrg: ${EGREP="$GREP -E"} 3295ec34c4cSmrg: ${FGREP="$GREP -F"} 3305ec34c4cSmrg: ${LN_S="ln -s"} 331994689c1Smrg: ${MAKE="make"} 332994689c1Smrg: ${MKDIR="mkdir"} 333994689c1Smrg: ${MV="mv -f"} 334994689c1Smrg: ${RM="rm -f"} 335994689c1Smrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"} 3367a84e134Smrg 337994689c1Smrg 3385ec34c4cSmrg## -------------------- ## 3395ec34c4cSmrg## Useful sed snippets. ## 3405ec34c4cSmrg## -------------------- ## 341f353fbadSmrg 3425ec34c4cSmrgsed_dirname='s|/[^/]*$||' 3435ec34c4cSmrgsed_basename='s|^.*/||' 344f353fbadSmrg 3455ec34c4cSmrg# Sed substitution that helps us do robust quoting. It backslashifies 3465ec34c4cSmrg# metacharacters that are still active within double-quoted strings. 3475ec34c4cSmrgsed_quote_subst='s|\([`"$\\]\)|\\\1|g' 348f353fbadSmrg 3495ec34c4cSmrg# Same as above, but do not quote variable references. 3505ec34c4cSmrgsed_double_quote_subst='s/\(["`\\]\)/\\\1/g' 351f353fbadSmrg 3525ec34c4cSmrg# Sed substitution that turns a string into a regex matching for the 3535ec34c4cSmrg# string literally. 3545ec34c4cSmrgsed_make_literal_regex='s|[].[^$\\*\/]|\\&|g' 355f353fbadSmrg 3565ec34c4cSmrg# Sed substitution that converts a w32 file name or path 3575ec34c4cSmrg# that contains forward slashes, into one that contains 3585ec34c4cSmrg# (escaped) backslashes. A very naive implementation. 3595ec34c4cSmrgsed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' 3605ec34c4cSmrg 3615ec34c4cSmrg# Re-'\' parameter expansions in output of sed_double_quote_subst that 3625ec34c4cSmrg# were '\'-ed in input to the same. If an odd number of '\' preceded a 3635ec34c4cSmrg# '$' in input to sed_double_quote_subst, that '$' was protected from 3645ec34c4cSmrg# expansion. Since each input '\' is now two '\'s, look for any number 3655ec34c4cSmrg# of runs of four '\'s followed by two '\'s and then a '$'. '\' that '$'. 3665ec34c4cSmrg_G_bs='\\' 3675ec34c4cSmrg_G_bs2='\\\\' 3685ec34c4cSmrg_G_bs4='\\\\\\\\' 3695ec34c4cSmrg_G_dollar='\$' 3705ec34c4cSmrgsed_double_backslash="\ 3715ec34c4cSmrg s/$_G_bs4/&\\ 3725ec34c4cSmrg/g 3735ec34c4cSmrg s/^$_G_bs2$_G_dollar/$_G_bs&/ 3745ec34c4cSmrg s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g 3755ec34c4cSmrg s/\n//g" 376f353fbadSmrg 3775b16253fSmrg# require_check_ifs_backslash 3785b16253fSmrg# --------------------------- 3795b16253fSmrg# Check if we can use backslash as IFS='\' separator, and set 3805b16253fSmrg# $check_ifs_backshlash_broken to ':' or 'false'. 3815b16253fSmrgrequire_check_ifs_backslash=func_require_check_ifs_backslash 3825b16253fSmrgfunc_require_check_ifs_backslash () 3835b16253fSmrg{ 3845b16253fSmrg _G_save_IFS=$IFS 3855b16253fSmrg IFS='\' 3865b16253fSmrg _G_check_ifs_backshlash='a\\b' 3875b16253fSmrg for _G_i in $_G_check_ifs_backshlash 3885b16253fSmrg do 3895b16253fSmrg case $_G_i in 3905b16253fSmrg a) 3915b16253fSmrg check_ifs_backshlash_broken=false 3925b16253fSmrg ;; 3935b16253fSmrg '') 3945b16253fSmrg break 3955b16253fSmrg ;; 3965b16253fSmrg *) 3975b16253fSmrg check_ifs_backshlash_broken=: 3985b16253fSmrg break 3995b16253fSmrg ;; 4005b16253fSmrg esac 4015b16253fSmrg done 4025b16253fSmrg IFS=$_G_save_IFS 4035b16253fSmrg require_check_ifs_backslash=: 4045b16253fSmrg} 4055b16253fSmrg 406775e7de9Smrg 4075ec34c4cSmrg## ----------------- ## 4085ec34c4cSmrg## Global variables. ## 4095ec34c4cSmrg## ----------------- ## 410994689c1Smrg 4115ec34c4cSmrg# Except for the global variables explicitly listed below, the following 4125ec34c4cSmrg# functions in the '^func_' namespace, and the '^require_' namespace 4135ec34c4cSmrg# variables initialised in the 'Resource management' section, sourcing 4145ec34c4cSmrg# this file will not pollute your global namespace with anything 4155ec34c4cSmrg# else. There's no portable way to scope variables in Bourne shell 4165ec34c4cSmrg# though, so actually running these functions will sometimes place 4175ec34c4cSmrg# results into a variable named after the function, and often use 4185ec34c4cSmrg# temporary variables in the '^_G_' namespace. If you are careful to 4195ec34c4cSmrg# avoid using those namespaces casually in your sourcing script, things 4205ec34c4cSmrg# should continue to work as you expect. And, of course, you can freely 4215ec34c4cSmrg# overwrite any of the functions or variables defined here before 4225ec34c4cSmrg# calling anything to customize them. 423994689c1Smrg 4245ec34c4cSmrgEXIT_SUCCESS=0 4255ec34c4cSmrgEXIT_FAILURE=1 4265ec34c4cSmrgEXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. 4275ec34c4cSmrgEXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. 428994689c1Smrg 4295ec34c4cSmrg# Allow overriding, eg assuming that you follow the convention of 4305ec34c4cSmrg# putting '$debug_cmd' at the start of all your functions, you can get 4315ec34c4cSmrg# bash to show function call trace with: 4325ec34c4cSmrg# 4335ec34c4cSmrg# debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name 4345ec34c4cSmrgdebug_cmd=${debug_cmd-":"} 4355ec34c4cSmrgexit_cmd=: 436994689c1Smrg 4375ec34c4cSmrg# By convention, finish your script with: 4385ec34c4cSmrg# 4395ec34c4cSmrg# exit $exit_status 4405ec34c4cSmrg# 4415ec34c4cSmrg# so that you can set exit_status to non-zero if you want to indicate 4425ec34c4cSmrg# something went wrong during execution without actually bailing out at 4435ec34c4cSmrg# the point of failure. 4445ec34c4cSmrgexit_status=$EXIT_SUCCESS 445994689c1Smrg 4465ec34c4cSmrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh 4475ec34c4cSmrg# is ksh but when the shell is invoked as "sh" and the current value of 4485ec34c4cSmrg# the _XPG environment variable is not equal to 1 (one), the special 4495ec34c4cSmrg# positional parameter $0, within a function call, is the name of the 4505ec34c4cSmrg# function. 4515ec34c4cSmrgprogpath=$0 452994689c1Smrg 4535ec34c4cSmrg# The name of this program. 4545ec34c4cSmrgprogname=`$ECHO "$progpath" |$SED "$sed_basename"` 455994689c1Smrg 4565ec34c4cSmrg# Make sure we have an absolute progpath for reexecution: 457994689c1Smrgcase $progpath in 458994689c1Smrg [\\/]*|[A-Za-z]:\\*) ;; 459994689c1Smrg *[\\/]*) 4605ec34c4cSmrg progdir=`$ECHO "$progpath" |$SED "$sed_dirname"` 461994689c1Smrg progdir=`cd "$progdir" && pwd` 4625ec34c4cSmrg progpath=$progdir/$progname 463994689c1Smrg ;; 464994689c1Smrg *) 4655ec34c4cSmrg _G_IFS=$IFS 466421c997bSmrg IFS=${PATH_SEPARATOR-:} 467994689c1Smrg for progdir in $PATH; do 4685ec34c4cSmrg IFS=$_G_IFS 469994689c1Smrg test -x "$progdir/$progname" && break 470994689c1Smrg done 4715ec34c4cSmrg IFS=$_G_IFS 472994689c1Smrg test -n "$progdir" || progdir=`pwd` 4735ec34c4cSmrg progpath=$progdir/$progname 474994689c1Smrg ;; 475994689c1Smrgesac 476994689c1Smrg 477994689c1Smrg 4785ec34c4cSmrg## ----------------- ## 4795ec34c4cSmrg## Standard options. ## 4805ec34c4cSmrg## ----------------- ## 481f353fbadSmrg 4825ec34c4cSmrg# The following options affect the operation of the functions defined 4835ec34c4cSmrg# below, and should be set appropriately depending on run-time para- 4845ec34c4cSmrg# meters passed on the command line. 485994689c1Smrg 486994689c1Smrgopt_dry_run=false 487994689c1Smrgopt_quiet=false 488994689c1Smrgopt_verbose=false 489994689c1Smrg 4905ec34c4cSmrg# Categories 'all' and 'none' are always available. Append any others 4915ec34c4cSmrg# you will pass as the first argument to func_warning from your own 4925ec34c4cSmrg# code. 4935ec34c4cSmrgwarning_categories= 494994689c1Smrg 4955ec34c4cSmrg# By default, display warnings according to 'opt_warning_types'. Set 4965ec34c4cSmrg# 'warning_func' to ':' to elide all warnings, or func_fatal_error to 4975ec34c4cSmrg# treat the next displayed warning as a fatal error. 4985ec34c4cSmrgwarning_func=func_warn_and_continue 499994689c1Smrg 5005ec34c4cSmrg# Set to 'all' to display all warnings, 'none' to suppress all 5015ec34c4cSmrg# warnings, or a space delimited list of some subset of 5025ec34c4cSmrg# 'warning_categories' to display only the listed warnings. 5035ec34c4cSmrgopt_warning_types=all 504994689c1Smrg 505994689c1Smrg 5065ec34c4cSmrg## -------------------- ## 5075ec34c4cSmrg## Resource management. ## 5085ec34c4cSmrg## -------------------- ## 509994689c1Smrg 5105ec34c4cSmrg# This section contains definitions for functions that each ensure a 5115ec34c4cSmrg# particular resource (a file, or a non-empty configuration variable for 5125ec34c4cSmrg# example) is available, and if appropriate to extract default values 5135ec34c4cSmrg# from pertinent package files. Call them using their associated 5145ec34c4cSmrg# 'require_*' variable to ensure that they are executed, at most, once. 5155ec34c4cSmrg# 5165ec34c4cSmrg# It's entirely deliberate that calling these functions can set 5175ec34c4cSmrg# variables that don't obey the namespace limitations obeyed by the rest 5185ec34c4cSmrg# of this file, in order that that they be as useful as possible to 5195ec34c4cSmrg# callers. 520994689c1Smrg 521994689c1Smrg 5225ec34c4cSmrg# require_term_colors 5235ec34c4cSmrg# ------------------- 5245ec34c4cSmrg# Allow display of bold text on terminals that support it. 5255ec34c4cSmrgrequire_term_colors=func_require_term_colors 5265ec34c4cSmrgfunc_require_term_colors () 527994689c1Smrg{ 5285ec34c4cSmrg $debug_cmd 5295ec34c4cSmrg 5305ec34c4cSmrg test -t 1 && { 5315ec34c4cSmrg # COLORTERM and USE_ANSI_COLORS environment variables take 5325ec34c4cSmrg # precedence, because most terminfo databases neglect to describe 5335ec34c4cSmrg # whether color sequences are supported. 5345ec34c4cSmrg test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"} 5355ec34c4cSmrg 5365ec34c4cSmrg if test 1 = "$USE_ANSI_COLORS"; then 5375ec34c4cSmrg # Standard ANSI escape sequences 5385ec34c4cSmrg tc_reset='[0m' 5395ec34c4cSmrg tc_bold='[1m'; tc_standout='[7m' 5405ec34c4cSmrg tc_red='[31m'; tc_green='[32m' 5415ec34c4cSmrg tc_blue='[34m'; tc_cyan='[36m' 5425ec34c4cSmrg else 5435ec34c4cSmrg # Otherwise trust the terminfo database after all. 5445ec34c4cSmrg test -n "`tput sgr0 2>/dev/null`" && { 5455ec34c4cSmrg tc_reset=`tput sgr0` 5465ec34c4cSmrg test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold` 5475ec34c4cSmrg tc_standout=$tc_bold 5485ec34c4cSmrg test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso` 5495ec34c4cSmrg test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1` 5505ec34c4cSmrg test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2` 5515ec34c4cSmrg test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4` 5525ec34c4cSmrg test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5` 5535ec34c4cSmrg } 5545ec34c4cSmrg fi 5555ec34c4cSmrg } 556994689c1Smrg 5575ec34c4cSmrg require_term_colors=: 558994689c1Smrg} 559994689c1Smrg 560994689c1Smrg 5615ec34c4cSmrg## ----------------- ## 5625ec34c4cSmrg## Function library. ## 5635ec34c4cSmrg## ----------------- ## 5645ec34c4cSmrg 5655ec34c4cSmrg# This section contains a variety of useful functions to call in your 5665ec34c4cSmrg# scripts. Take note of the portable wrappers for features provided by 5675ec34c4cSmrg# some modern shells, which will fall back to slower equivalents on 5685ec34c4cSmrg# less featureful shells. 5695ec34c4cSmrg 5705ec34c4cSmrg 5715ec34c4cSmrg# func_append VAR VALUE 5725ec34c4cSmrg# --------------------- 5735ec34c4cSmrg# Append VALUE onto the existing contents of VAR. 5745ec34c4cSmrg 5755ec34c4cSmrg # We should try to minimise forks, especially on Windows where they are 5765ec34c4cSmrg # unreasonably slow, so skip the feature probes when bash or zsh are 5775ec34c4cSmrg # being used: 5785ec34c4cSmrg if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then 5795ec34c4cSmrg : ${_G_HAVE_ARITH_OP="yes"} 5805ec34c4cSmrg : ${_G_HAVE_XSI_OPS="yes"} 5815ec34c4cSmrg # The += operator was introduced in bash 3.1 5825ec34c4cSmrg case $BASH_VERSION in 5835ec34c4cSmrg [12].* | 3.0 | 3.0*) ;; 5845ec34c4cSmrg *) 5855ec34c4cSmrg : ${_G_HAVE_PLUSEQ_OP="yes"} 5865ec34c4cSmrg ;; 5875ec34c4cSmrg esac 5885ec34c4cSmrg fi 5895ec34c4cSmrg 5905ec34c4cSmrg # _G_HAVE_PLUSEQ_OP 5915ec34c4cSmrg # Can be empty, in which case the shell is probed, "yes" if += is 5925ec34c4cSmrg # useable or anything else if it does not work. 5935ec34c4cSmrg test -z "$_G_HAVE_PLUSEQ_OP" \ 5945ec34c4cSmrg && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \ 5955ec34c4cSmrg && _G_HAVE_PLUSEQ_OP=yes 5965ec34c4cSmrg 5975ec34c4cSmrgif test yes = "$_G_HAVE_PLUSEQ_OP" 5985ec34c4cSmrgthen 5995ec34c4cSmrg # This is an XSI compatible shell, allowing a faster implementation... 6005ec34c4cSmrg eval 'func_append () 6015ec34c4cSmrg { 6025ec34c4cSmrg $debug_cmd 6035ec34c4cSmrg 6045ec34c4cSmrg eval "$1+=\$2" 6055ec34c4cSmrg }' 6065ec34c4cSmrgelse 6075ec34c4cSmrg # ...otherwise fall back to using expr, which is often a shell builtin. 6085ec34c4cSmrg func_append () 6095ec34c4cSmrg { 6105ec34c4cSmrg $debug_cmd 6115ec34c4cSmrg 6125ec34c4cSmrg eval "$1=\$$1\$2" 6135ec34c4cSmrg } 6145ec34c4cSmrgfi 6155ec34c4cSmrg 6165ec34c4cSmrg 6175ec34c4cSmrg# func_append_quoted VAR VALUE 6185ec34c4cSmrg# ---------------------------- 6195ec34c4cSmrg# Quote VALUE and append to the end of shell variable VAR, separated 6205ec34c4cSmrg# by a space. 6215ec34c4cSmrgif test yes = "$_G_HAVE_PLUSEQ_OP"; then 6225ec34c4cSmrg eval 'func_append_quoted () 6235ec34c4cSmrg { 6245ec34c4cSmrg $debug_cmd 6255ec34c4cSmrg 6265b16253fSmrg func_quote_arg pretty "$2" 6275b16253fSmrg eval "$1+=\\ \$func_quote_arg_result" 6285ec34c4cSmrg }' 6295ec34c4cSmrgelse 6305ec34c4cSmrg func_append_quoted () 6315ec34c4cSmrg { 6325ec34c4cSmrg $debug_cmd 6335ec34c4cSmrg 6345b16253fSmrg func_quote_arg pretty "$2" 6355b16253fSmrg eval "$1=\$$1\\ \$func_quote_arg_result" 6365ec34c4cSmrg } 6375ec34c4cSmrgfi 6385ec34c4cSmrg 6395ec34c4cSmrg 6405ec34c4cSmrg# func_append_uniq VAR VALUE 6415ec34c4cSmrg# -------------------------- 6425ec34c4cSmrg# Append unique VALUE onto the existing contents of VAR, assuming 6435ec34c4cSmrg# entries are delimited by the first character of VALUE. For example: 6445ec34c4cSmrg# 6455ec34c4cSmrg# func_append_uniq options " --another-option option-argument" 6465ec34c4cSmrg# 6475ec34c4cSmrg# will only append to $options if " --another-option option-argument " 6485ec34c4cSmrg# is not already present somewhere in $options already (note spaces at 6495ec34c4cSmrg# each end implied by leading space in second argument). 6505ec34c4cSmrgfunc_append_uniq () 6515ec34c4cSmrg{ 6525ec34c4cSmrg $debug_cmd 6535ec34c4cSmrg 6545ec34c4cSmrg eval _G_current_value='`$ECHO $'$1'`' 6555ec34c4cSmrg _G_delim=`expr "$2" : '\(.\)'` 6565ec34c4cSmrg 6575ec34c4cSmrg case $_G_delim$_G_current_value$_G_delim in 6585ec34c4cSmrg *"$2$_G_delim"*) ;; 6595ec34c4cSmrg *) func_append "$@" ;; 6605ec34c4cSmrg esac 6615ec34c4cSmrg} 6625ec34c4cSmrg 6635ec34c4cSmrg 6645ec34c4cSmrg# func_arith TERM... 6655ec34c4cSmrg# ------------------ 6665ec34c4cSmrg# Set func_arith_result to the result of evaluating TERMs. 6675ec34c4cSmrg test -z "$_G_HAVE_ARITH_OP" \ 6685ec34c4cSmrg && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \ 6695ec34c4cSmrg && _G_HAVE_ARITH_OP=yes 6705ec34c4cSmrg 6715ec34c4cSmrgif test yes = "$_G_HAVE_ARITH_OP"; then 6725ec34c4cSmrg eval 'func_arith () 6735ec34c4cSmrg { 6745ec34c4cSmrg $debug_cmd 6755ec34c4cSmrg 6765ec34c4cSmrg func_arith_result=$(( $* )) 6775ec34c4cSmrg }' 6785ec34c4cSmrgelse 6795ec34c4cSmrg func_arith () 6805ec34c4cSmrg { 6815ec34c4cSmrg $debug_cmd 6825ec34c4cSmrg 6835ec34c4cSmrg func_arith_result=`expr "$@"` 6845ec34c4cSmrg } 6855ec34c4cSmrgfi 6865ec34c4cSmrg 6875ec34c4cSmrg 6885ec34c4cSmrg# func_basename FILE 6895ec34c4cSmrg# ------------------ 6905ec34c4cSmrg# Set func_basename_result to FILE with everything up to and including 6915ec34c4cSmrg# the last / stripped. 6925ec34c4cSmrgif test yes = "$_G_HAVE_XSI_OPS"; then 6935ec34c4cSmrg # If this shell supports suffix pattern removal, then use it to avoid 6945ec34c4cSmrg # forking. Hide the definitions single quotes in case the shell chokes 6955ec34c4cSmrg # on unsupported syntax... 6965ec34c4cSmrg _b='func_basename_result=${1##*/}' 6975ec34c4cSmrg _d='case $1 in 6985ec34c4cSmrg */*) func_dirname_result=${1%/*}$2 ;; 6995ec34c4cSmrg * ) func_dirname_result=$3 ;; 7005ec34c4cSmrg esac' 7015ec34c4cSmrg 7025ec34c4cSmrgelse 7035ec34c4cSmrg # ...otherwise fall back to using sed. 7045ec34c4cSmrg _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`' 7055ec34c4cSmrg _d='func_dirname_result=`$ECHO "$1" |$SED "$sed_dirname"` 7065ec34c4cSmrg if test "X$func_dirname_result" = "X$1"; then 7075ec34c4cSmrg func_dirname_result=$3 7085ec34c4cSmrg else 7095ec34c4cSmrg func_append func_dirname_result "$2" 7105ec34c4cSmrg fi' 7115ec34c4cSmrgfi 7125ec34c4cSmrg 7135ec34c4cSmrgeval 'func_basename () 7145ec34c4cSmrg{ 7155ec34c4cSmrg $debug_cmd 7165ec34c4cSmrg 7175ec34c4cSmrg '"$_b"' 7185ec34c4cSmrg}' 7195ec34c4cSmrg 7205ec34c4cSmrg 7215ec34c4cSmrg# func_dirname FILE APPEND NONDIR_REPLACEMENT 7225ec34c4cSmrg# ------------------------------------------- 7235ec34c4cSmrg# Compute the dirname of FILE. If nonempty, add APPEND to the result, 7245ec34c4cSmrg# otherwise set result to NONDIR_REPLACEMENT. 7255ec34c4cSmrgeval 'func_dirname () 7265ec34c4cSmrg{ 7275ec34c4cSmrg $debug_cmd 7285ec34c4cSmrg 7295ec34c4cSmrg '"$_d"' 7305ec34c4cSmrg}' 7315ec34c4cSmrg 7325ec34c4cSmrg 7335ec34c4cSmrg# func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT 7345ec34c4cSmrg# -------------------------------------------------------- 7355ec34c4cSmrg# Perform func_basename and func_dirname in a single function 7365ec34c4cSmrg# call: 7375ec34c4cSmrg# dirname: Compute the dirname of FILE. If nonempty, 7385ec34c4cSmrg# add APPEND to the result, otherwise set result 7395ec34c4cSmrg# to NONDIR_REPLACEMENT. 7405ec34c4cSmrg# value returned in "$func_dirname_result" 7415ec34c4cSmrg# basename: Compute filename of FILE. 7425ec34c4cSmrg# value retuned in "$func_basename_result" 7435ec34c4cSmrg# For efficiency, we do not delegate to the functions above but instead 7445ec34c4cSmrg# duplicate the functionality here. 7455ec34c4cSmrgeval 'func_dirname_and_basename () 7465ec34c4cSmrg{ 7475ec34c4cSmrg $debug_cmd 7485ec34c4cSmrg 7495ec34c4cSmrg '"$_b"' 7505ec34c4cSmrg '"$_d"' 7515ec34c4cSmrg}' 7525ec34c4cSmrg 7535ec34c4cSmrg 7545ec34c4cSmrg# func_echo ARG... 7555ec34c4cSmrg# ---------------- 7565ec34c4cSmrg# Echo program name prefixed message. 7575ec34c4cSmrgfunc_echo () 7585ec34c4cSmrg{ 7595ec34c4cSmrg $debug_cmd 7605ec34c4cSmrg 7615ec34c4cSmrg _G_message=$* 7625ec34c4cSmrg 7635ec34c4cSmrg func_echo_IFS=$IFS 7645ec34c4cSmrg IFS=$nl 7655ec34c4cSmrg for _G_line in $_G_message; do 7665ec34c4cSmrg IFS=$func_echo_IFS 7675ec34c4cSmrg $ECHO "$progname: $_G_line" 7685ec34c4cSmrg done 7695ec34c4cSmrg IFS=$func_echo_IFS 7705ec34c4cSmrg} 7715ec34c4cSmrg 7725ec34c4cSmrg 7735ec34c4cSmrg# func_echo_all ARG... 7745ec34c4cSmrg# -------------------- 7755ec34c4cSmrg# Invoke $ECHO with all args, space-separated. 7765ec34c4cSmrgfunc_echo_all () 7775ec34c4cSmrg{ 7785ec34c4cSmrg $ECHO "$*" 7795ec34c4cSmrg} 7805ec34c4cSmrg 7815ec34c4cSmrg 7825ec34c4cSmrg# func_echo_infix_1 INFIX ARG... 7835ec34c4cSmrg# ------------------------------ 7845ec34c4cSmrg# Echo program name, followed by INFIX on the first line, with any 7855ec34c4cSmrg# additional lines not showing INFIX. 7865ec34c4cSmrgfunc_echo_infix_1 () 7875ec34c4cSmrg{ 7885ec34c4cSmrg $debug_cmd 7895ec34c4cSmrg 7905ec34c4cSmrg $require_term_colors 7915ec34c4cSmrg 7925ec34c4cSmrg _G_infix=$1; shift 7935ec34c4cSmrg _G_indent=$_G_infix 7945ec34c4cSmrg _G_prefix="$progname: $_G_infix: " 7955ec34c4cSmrg _G_message=$* 7965ec34c4cSmrg 7975ec34c4cSmrg # Strip color escape sequences before counting printable length 7985ec34c4cSmrg for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan" 7995ec34c4cSmrg do 8005ec34c4cSmrg test -n "$_G_tc" && { 8015ec34c4cSmrg _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"` 8025ec34c4cSmrg _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"` 8035ec34c4cSmrg } 8045ec34c4cSmrg done 8055ec34c4cSmrg _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`" " ## exclude from sc_prohibit_nested_quotes 8065ec34c4cSmrg 8075ec34c4cSmrg func_echo_infix_1_IFS=$IFS 8085ec34c4cSmrg IFS=$nl 8095ec34c4cSmrg for _G_line in $_G_message; do 8105ec34c4cSmrg IFS=$func_echo_infix_1_IFS 8115ec34c4cSmrg $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2 8125ec34c4cSmrg _G_prefix=$_G_indent 8135ec34c4cSmrg done 8145ec34c4cSmrg IFS=$func_echo_infix_1_IFS 8155ec34c4cSmrg} 8165ec34c4cSmrg 8175ec34c4cSmrg 8185ec34c4cSmrg# func_error ARG... 8195ec34c4cSmrg# ----------------- 8205ec34c4cSmrg# Echo program name prefixed message to standard error. 8215ec34c4cSmrgfunc_error () 8225ec34c4cSmrg{ 8235ec34c4cSmrg $debug_cmd 8245ec34c4cSmrg 8255ec34c4cSmrg $require_term_colors 8265ec34c4cSmrg 8275ec34c4cSmrg func_echo_infix_1 " $tc_standout${tc_red}error$tc_reset" "$*" >&2 8285ec34c4cSmrg} 8295ec34c4cSmrg 8305ec34c4cSmrg 8315ec34c4cSmrg# func_fatal_error ARG... 8325ec34c4cSmrg# ----------------------- 8335ec34c4cSmrg# Echo program name prefixed message to standard error, and exit. 8345ec34c4cSmrgfunc_fatal_error () 8355ec34c4cSmrg{ 8365ec34c4cSmrg $debug_cmd 8375ec34c4cSmrg 8385ec34c4cSmrg func_error "$*" 8395ec34c4cSmrg exit $EXIT_FAILURE 8405ec34c4cSmrg} 8415ec34c4cSmrg 8425ec34c4cSmrg 8435ec34c4cSmrg# func_grep EXPRESSION FILENAME 8445ec34c4cSmrg# ----------------------------- 845994689c1Smrg# Check whether EXPRESSION matches any line of FILENAME, without output. 846994689c1Smrgfunc_grep () 847994689c1Smrg{ 8485ec34c4cSmrg $debug_cmd 8495ec34c4cSmrg 850994689c1Smrg $GREP "$1" "$2" >/dev/null 2>&1 851994689c1Smrg} 852994689c1Smrg 853994689c1Smrg 8545ec34c4cSmrg# func_len STRING 8555ec34c4cSmrg# --------------- 8565ec34c4cSmrg# Set func_len_result to the length of STRING. STRING may not 8575ec34c4cSmrg# start with a hyphen. 8585ec34c4cSmrg test -z "$_G_HAVE_XSI_OPS" \ 8595ec34c4cSmrg && (eval 'x=a/b/c; 8605ec34c4cSmrg test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ 8615ec34c4cSmrg && _G_HAVE_XSI_OPS=yes 8625ec34c4cSmrg 8635ec34c4cSmrgif test yes = "$_G_HAVE_XSI_OPS"; then 8645ec34c4cSmrg eval 'func_len () 8655ec34c4cSmrg { 8665ec34c4cSmrg $debug_cmd 8675ec34c4cSmrg 8685ec34c4cSmrg func_len_result=${#1} 8695ec34c4cSmrg }' 8705ec34c4cSmrgelse 8715ec34c4cSmrg func_len () 8725ec34c4cSmrg { 8735ec34c4cSmrg $debug_cmd 8745ec34c4cSmrg 8755ec34c4cSmrg func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len` 8765ec34c4cSmrg } 8775ec34c4cSmrgfi 8785ec34c4cSmrg 8795ec34c4cSmrg 8805ec34c4cSmrg# func_mkdir_p DIRECTORY-PATH 8815ec34c4cSmrg# --------------------------- 882994689c1Smrg# Make sure the entire path to DIRECTORY-PATH is available. 883994689c1Smrgfunc_mkdir_p () 884994689c1Smrg{ 8855ec34c4cSmrg $debug_cmd 8865ec34c4cSmrg 8875ec34c4cSmrg _G_directory_path=$1 8885ec34c4cSmrg _G_dir_list= 889994689c1Smrg 8905ec34c4cSmrg if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then 891994689c1Smrg 8925ec34c4cSmrg # Protect directory names starting with '-' 8935ec34c4cSmrg case $_G_directory_path in 8945ec34c4cSmrg -*) _G_directory_path=./$_G_directory_path ;; 895994689c1Smrg esac 896994689c1Smrg 897994689c1Smrg # While some portion of DIR does not yet exist... 8985ec34c4cSmrg while test ! -d "$_G_directory_path"; do 899994689c1Smrg # ...make a list in topmost first order. Use a colon delimited 900994689c1Smrg # list incase some portion of path contains whitespace. 9015ec34c4cSmrg _G_dir_list=$_G_directory_path:$_G_dir_list 902994689c1Smrg 903994689c1Smrg # If the last portion added has no slash in it, the list is done 9045ec34c4cSmrg case $_G_directory_path in */*) ;; *) break ;; esac 905994689c1Smrg 906994689c1Smrg # ...otherwise throw away the child directory and loop 9075ec34c4cSmrg _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"` 908994689c1Smrg done 9095ec34c4cSmrg _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'` 910994689c1Smrg 9115ec34c4cSmrg func_mkdir_p_IFS=$IFS; IFS=: 9125ec34c4cSmrg for _G_dir in $_G_dir_list; do 9135ec34c4cSmrg IFS=$func_mkdir_p_IFS 9145ec34c4cSmrg # mkdir can fail with a 'File exist' error if two processes 915994689c1Smrg # try to create one of the directories concurrently. Don't 916994689c1Smrg # stop in that case! 9175ec34c4cSmrg $MKDIR "$_G_dir" 2>/dev/null || : 918994689c1Smrg done 9195ec34c4cSmrg IFS=$func_mkdir_p_IFS 920994689c1Smrg 921994689c1Smrg # Bail out if we (or some other process) failed to create a directory. 9225ec34c4cSmrg test -d "$_G_directory_path" || \ 9235ec34c4cSmrg func_fatal_error "Failed to create '$1'" 924994689c1Smrg fi 925994689c1Smrg} 9267a84e134Smrg 9277a84e134Smrg 9285ec34c4cSmrg# func_mktempdir [BASENAME] 9295ec34c4cSmrg# ------------------------- 9307a84e134Smrg# Make a temporary directory that won't clash with other running 9317a84e134Smrg# libtool processes, and avoids race conditions if possible. If 9325ec34c4cSmrg# given, BASENAME is the basename for that directory. 9337a84e134Smrgfunc_mktempdir () 9347a84e134Smrg{ 9355ec34c4cSmrg $debug_cmd 9365ec34c4cSmrg 9375ec34c4cSmrg _G_template=${TMPDIR-/tmp}/${1-$progname} 9387a84e134Smrg 9395ec34c4cSmrg if test : = "$opt_dry_run"; then 9407a84e134Smrg # Return a directory name, but don't create it in dry-run mode 9415ec34c4cSmrg _G_tmpdir=$_G_template-$$ 9427a84e134Smrg else 9437a84e134Smrg 9447a84e134Smrg # If mktemp works, use that first and foremost 9455ec34c4cSmrg _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null` 9467a84e134Smrg 9475ec34c4cSmrg if test ! -d "$_G_tmpdir"; then 948994689c1Smrg # Failing that, at least try and use $RANDOM to avoid a race 9495ec34c4cSmrg _G_tmpdir=$_G_template-${RANDOM-0}$$ 9507a84e134Smrg 9515ec34c4cSmrg func_mktempdir_umask=`umask` 952994689c1Smrg umask 0077 9535ec34c4cSmrg $MKDIR "$_G_tmpdir" 9545ec34c4cSmrg umask $func_mktempdir_umask 9557a84e134Smrg fi 9567a84e134Smrg 9577a84e134Smrg # If we're not in dry-run mode, bomb out on failure 9585ec34c4cSmrg test -d "$_G_tmpdir" || \ 9595ec34c4cSmrg func_fatal_error "cannot create temporary directory '$_G_tmpdir'" 9607a84e134Smrg fi 9617a84e134Smrg 9625ec34c4cSmrg $ECHO "$_G_tmpdir" 9635ec34c4cSmrg} 9645ec34c4cSmrg 9655ec34c4cSmrg 9665ec34c4cSmrg# func_normal_abspath PATH 9675ec34c4cSmrg# ------------------------ 9685ec34c4cSmrg# Remove doubled-up and trailing slashes, "." path components, 9695ec34c4cSmrg# and cancel out any ".." path components in PATH after making 9705ec34c4cSmrg# it an absolute path. 9715ec34c4cSmrgfunc_normal_abspath () 9725ec34c4cSmrg{ 9735ec34c4cSmrg $debug_cmd 9745ec34c4cSmrg 9755ec34c4cSmrg # These SED scripts presuppose an absolute path with a trailing slash. 9765ec34c4cSmrg _G_pathcar='s|^/\([^/]*\).*$|\1|' 9775ec34c4cSmrg _G_pathcdr='s|^/[^/]*||' 9785ec34c4cSmrg _G_removedotparts=':dotsl 9795ec34c4cSmrg s|/\./|/|g 9805ec34c4cSmrg t dotsl 9815ec34c4cSmrg s|/\.$|/|' 9825ec34c4cSmrg _G_collapseslashes='s|/\{1,\}|/|g' 9835ec34c4cSmrg _G_finalslash='s|/*$|/|' 9845ec34c4cSmrg 9855ec34c4cSmrg # Start from root dir and reassemble the path. 9865ec34c4cSmrg func_normal_abspath_result= 9875ec34c4cSmrg func_normal_abspath_tpath=$1 9885ec34c4cSmrg func_normal_abspath_altnamespace= 9895ec34c4cSmrg case $func_normal_abspath_tpath in 9905ec34c4cSmrg "") 9915ec34c4cSmrg # Empty path, that just means $cwd. 9925ec34c4cSmrg func_stripname '' '/' "`pwd`" 9935ec34c4cSmrg func_normal_abspath_result=$func_stripname_result 9945ec34c4cSmrg return 9955ec34c4cSmrg ;; 9965ec34c4cSmrg # The next three entries are used to spot a run of precisely 9975ec34c4cSmrg # two leading slashes without using negated character classes; 9985ec34c4cSmrg # we take advantage of case's first-match behaviour. 9995ec34c4cSmrg ///*) 10005ec34c4cSmrg # Unusual form of absolute path, do nothing. 10015ec34c4cSmrg ;; 10025ec34c4cSmrg //*) 10035ec34c4cSmrg # Not necessarily an ordinary path; POSIX reserves leading '//' 10045ec34c4cSmrg # and for example Cygwin uses it to access remote file shares 10055ec34c4cSmrg # over CIFS/SMB, so we conserve a leading double slash if found. 10065ec34c4cSmrg func_normal_abspath_altnamespace=/ 10075ec34c4cSmrg ;; 10085ec34c4cSmrg /*) 10095ec34c4cSmrg # Absolute path, do nothing. 10105ec34c4cSmrg ;; 10115ec34c4cSmrg *) 10125ec34c4cSmrg # Relative path, prepend $cwd. 10135ec34c4cSmrg func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath 10145ec34c4cSmrg ;; 10155ec34c4cSmrg esac 10165ec34c4cSmrg 10175ec34c4cSmrg # Cancel out all the simple stuff to save iterations. We also want 10185ec34c4cSmrg # the path to end with a slash for ease of parsing, so make sure 10195ec34c4cSmrg # there is one (and only one) here. 10205ec34c4cSmrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 10215ec34c4cSmrg -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"` 10225ec34c4cSmrg while :; do 10235ec34c4cSmrg # Processed it all yet? 10245ec34c4cSmrg if test / = "$func_normal_abspath_tpath"; then 10255ec34c4cSmrg # If we ascended to the root using ".." the result may be empty now. 10265ec34c4cSmrg if test -z "$func_normal_abspath_result"; then 10275ec34c4cSmrg func_normal_abspath_result=/ 10285ec34c4cSmrg fi 10295ec34c4cSmrg break 10305ec34c4cSmrg fi 10315ec34c4cSmrg func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ 10325ec34c4cSmrg -e "$_G_pathcar"` 10335ec34c4cSmrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 10345ec34c4cSmrg -e "$_G_pathcdr"` 10355ec34c4cSmrg # Figure out what to do with it 10365ec34c4cSmrg case $func_normal_abspath_tcomponent in 10375ec34c4cSmrg "") 10385ec34c4cSmrg # Trailing empty path component, ignore it. 10395ec34c4cSmrg ;; 10405ec34c4cSmrg ..) 10415ec34c4cSmrg # Parent dir; strip last assembled component from result. 10425ec34c4cSmrg func_dirname "$func_normal_abspath_result" 10435ec34c4cSmrg func_normal_abspath_result=$func_dirname_result 10445ec34c4cSmrg ;; 10455ec34c4cSmrg *) 10465ec34c4cSmrg # Actual path component, append it. 10475ec34c4cSmrg func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent" 10485ec34c4cSmrg ;; 10495ec34c4cSmrg esac 10505ec34c4cSmrg done 10515ec34c4cSmrg # Restore leading double-slash if one was found on entry. 10525ec34c4cSmrg func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result 10535ec34c4cSmrg} 10545ec34c4cSmrg 10555ec34c4cSmrg 10565ec34c4cSmrg# func_notquiet ARG... 10575ec34c4cSmrg# -------------------- 10585ec34c4cSmrg# Echo program name prefixed message only when not in quiet mode. 10595ec34c4cSmrgfunc_notquiet () 10605ec34c4cSmrg{ 10615ec34c4cSmrg $debug_cmd 10625ec34c4cSmrg 10635ec34c4cSmrg $opt_quiet || func_echo ${1+"$@"} 10645ec34c4cSmrg 10655ec34c4cSmrg # A bug in bash halts the script if the last line of a function 10665ec34c4cSmrg # fails when set -e is in force, so we need another command to 10675ec34c4cSmrg # work around that: 10685ec34c4cSmrg : 10695ec34c4cSmrg} 10705ec34c4cSmrg 10715ec34c4cSmrg 10725ec34c4cSmrg# func_relative_path SRCDIR DSTDIR 10735ec34c4cSmrg# -------------------------------- 10745ec34c4cSmrg# Set func_relative_path_result to the relative path from SRCDIR to DSTDIR. 10755ec34c4cSmrgfunc_relative_path () 10765ec34c4cSmrg{ 10775ec34c4cSmrg $debug_cmd 10785ec34c4cSmrg 10795ec34c4cSmrg func_relative_path_result= 10805ec34c4cSmrg func_normal_abspath "$1" 10815ec34c4cSmrg func_relative_path_tlibdir=$func_normal_abspath_result 10825ec34c4cSmrg func_normal_abspath "$2" 10835ec34c4cSmrg func_relative_path_tbindir=$func_normal_abspath_result 10845ec34c4cSmrg 10855ec34c4cSmrg # Ascend the tree starting from libdir 10865ec34c4cSmrg while :; do 10875ec34c4cSmrg # check if we have found a prefix of bindir 10885ec34c4cSmrg case $func_relative_path_tbindir in 10895ec34c4cSmrg $func_relative_path_tlibdir) 10905ec34c4cSmrg # found an exact match 10915ec34c4cSmrg func_relative_path_tcancelled= 10925ec34c4cSmrg break 10935ec34c4cSmrg ;; 10945ec34c4cSmrg $func_relative_path_tlibdir*) 10955ec34c4cSmrg # found a matching prefix 10965ec34c4cSmrg func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" 10975ec34c4cSmrg func_relative_path_tcancelled=$func_stripname_result 10985ec34c4cSmrg if test -z "$func_relative_path_result"; then 10995ec34c4cSmrg func_relative_path_result=. 11005ec34c4cSmrg fi 11015ec34c4cSmrg break 11025ec34c4cSmrg ;; 11035ec34c4cSmrg *) 11045ec34c4cSmrg func_dirname $func_relative_path_tlibdir 11055ec34c4cSmrg func_relative_path_tlibdir=$func_dirname_result 11065ec34c4cSmrg if test -z "$func_relative_path_tlibdir"; then 11075ec34c4cSmrg # Have to descend all the way to the root! 11085ec34c4cSmrg func_relative_path_result=../$func_relative_path_result 11095ec34c4cSmrg func_relative_path_tcancelled=$func_relative_path_tbindir 11105ec34c4cSmrg break 11115ec34c4cSmrg fi 11125ec34c4cSmrg func_relative_path_result=../$func_relative_path_result 11135ec34c4cSmrg ;; 11145ec34c4cSmrg esac 11155ec34c4cSmrg done 11165ec34c4cSmrg 11175ec34c4cSmrg # Now calculate path; take care to avoid doubling-up slashes. 11185ec34c4cSmrg func_stripname '' '/' "$func_relative_path_result" 11195ec34c4cSmrg func_relative_path_result=$func_stripname_result 11205ec34c4cSmrg func_stripname '/' '/' "$func_relative_path_tcancelled" 11215ec34c4cSmrg if test -n "$func_stripname_result"; then 11225ec34c4cSmrg func_append func_relative_path_result "/$func_stripname_result" 11235ec34c4cSmrg fi 11245ec34c4cSmrg 11255ec34c4cSmrg # Normalisation. If bindir is libdir, return '.' else relative path. 11265ec34c4cSmrg if test -n "$func_relative_path_result"; then 11275ec34c4cSmrg func_stripname './' '' "$func_relative_path_result" 11285ec34c4cSmrg func_relative_path_result=$func_stripname_result 11295ec34c4cSmrg fi 11305ec34c4cSmrg 11315ec34c4cSmrg test -n "$func_relative_path_result" || func_relative_path_result=. 11325ec34c4cSmrg 11335ec34c4cSmrg : 11345ec34c4cSmrg} 11355ec34c4cSmrg 11365ec34c4cSmrg 11375b16253fSmrg# func_quote_portable EVAL ARG 11385b16253fSmrg# ---------------------------- 11395b16253fSmrg# Internal function to portably implement func_quote_arg. Note that we still 11405b16253fSmrg# keep attention to performance here so we as much as possible try to avoid 11415b16253fSmrg# calling sed binary (so far O(N) complexity as long as func_append is O(1)). 11425b16253fSmrgfunc_quote_portable () 11435ec34c4cSmrg{ 11445ec34c4cSmrg $debug_cmd 11455ec34c4cSmrg 11465b16253fSmrg $require_check_ifs_backslash 11475ec34c4cSmrg 11485b16253fSmrg func_quote_portable_result=$2 11495ec34c4cSmrg 11505b16253fSmrg # one-time-loop (easy break) 11515b16253fSmrg while true 11525b16253fSmrg do 11535b16253fSmrg if $1; then 11545b16253fSmrg func_quote_portable_result=`$ECHO "$2" | $SED \ 11555b16253fSmrg -e "$sed_double_quote_subst" -e "$sed_double_backslash"` 11565b16253fSmrg break 11575b16253fSmrg fi 11585b16253fSmrg 11595b16253fSmrg # Quote for eval. 11605b16253fSmrg case $func_quote_portable_result in 11615b16253fSmrg *[\\\`\"\$]*) 11625b16253fSmrg # Fallback to sed for $func_check_bs_ifs_broken=:, or when the string 11635b16253fSmrg # contains the shell wildcard characters. 11645b16253fSmrg case $check_ifs_backshlash_broken$func_quote_portable_result in 11655b16253fSmrg :*|*[\[\*\?]*) 11665b16253fSmrg func_quote_portable_result=`$ECHO "$func_quote_portable_result" \ 11675b16253fSmrg | $SED "$sed_quote_subst"` 11685b16253fSmrg break 11695ec34c4cSmrg ;; 11705b16253fSmrg esac 11715b16253fSmrg 11725b16253fSmrg func_quote_portable_old_IFS=$IFS 11735b16253fSmrg for _G_char in '\' '`' '"' '$' 11745b16253fSmrg do 11755b16253fSmrg # STATE($1) PREV($2) SEPARATOR($3) 11765b16253fSmrg set start "" "" 11775b16253fSmrg func_quote_portable_result=dummy"$_G_char$func_quote_portable_result$_G_char"dummy 11785b16253fSmrg IFS=$_G_char 11795b16253fSmrg for _G_part in $func_quote_portable_result 11805b16253fSmrg do 11815b16253fSmrg case $1 in 11825b16253fSmrg quote) 11835b16253fSmrg func_append func_quote_portable_result "$3$2" 11845b16253fSmrg set quote "$_G_part" "\\$_G_char" 11855b16253fSmrg ;; 11865b16253fSmrg start) 11875b16253fSmrg set first "" "" 11885b16253fSmrg func_quote_portable_result= 11895b16253fSmrg ;; 11905b16253fSmrg first) 11915b16253fSmrg set quote "$_G_part" "" 11925b16253fSmrg ;; 11935b16253fSmrg esac 11945b16253fSmrg done 11955ec34c4cSmrg done 11965b16253fSmrg IFS=$func_quote_portable_old_IFS 11975b16253fSmrg ;; 11985b16253fSmrg *) ;; 11995b16253fSmrg esac 12005b16253fSmrg break 12015b16253fSmrg done 12025b16253fSmrg 12035b16253fSmrg func_quote_portable_unquoted_result=$func_quote_portable_result 12045b16253fSmrg case $func_quote_portable_result in 12055b16253fSmrg # double-quote args containing shell metacharacters to delay 12065b16253fSmrg # word splitting, command substitution and variable expansion 12075b16253fSmrg # for a subsequent eval. 12085b16253fSmrg # many bourne shells cannot handle close brackets correctly 12095b16253fSmrg # in scan sets, so we specify it separately. 12105b16253fSmrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 12115b16253fSmrg func_quote_portable_result=\"$func_quote_portable_result\" 12125ec34c4cSmrg ;; 12135ec34c4cSmrg esac 12147a84e134Smrg} 12157a84e134Smrg 12167a84e134Smrg 12175b16253fSmrg# func_quotefast_eval ARG 12185b16253fSmrg# ----------------------- 12195b16253fSmrg# Quote one ARG (internal). This is equivalent to 'func_quote_arg eval ARG', 12205b16253fSmrg# but optimized for speed. Result is stored in $func_quotefast_eval. 12215b16253fSmrgif test xyes = `(x=; printf -v x %q yes; echo x"$x") 2>/dev/null`; then 12225b16253fSmrg printf -v _GL_test_printf_tilde %q '~' 12235b16253fSmrg if test '\~' = "$_GL_test_printf_tilde"; then 12245b16253fSmrg func_quotefast_eval () 12255b16253fSmrg { 12265b16253fSmrg printf -v func_quotefast_eval_result %q "$1" 12275b16253fSmrg } 12285b16253fSmrg else 12295b16253fSmrg # Broken older Bash implementations. Make those faster too if possible. 12305b16253fSmrg func_quotefast_eval () 12315b16253fSmrg { 12325b16253fSmrg case $1 in 12335b16253fSmrg '~'*) 12345b16253fSmrg func_quote_portable false "$1" 12355b16253fSmrg func_quotefast_eval_result=$func_quote_portable_result 12365ec34c4cSmrg ;; 12375ec34c4cSmrg *) 12385b16253fSmrg printf -v func_quotefast_eval_result %q "$1" 12395b16253fSmrg ;; 12405ec34c4cSmrg esac 12415b16253fSmrg } 12425b16253fSmrg fi 12435b16253fSmrgelse 12445b16253fSmrg func_quotefast_eval () 12455b16253fSmrg { 12465b16253fSmrg func_quote_portable false "$1" 12475b16253fSmrg func_quotefast_eval_result=$func_quote_portable_result 12485b16253fSmrg } 12495b16253fSmrgfi 12505ec34c4cSmrg 12515ec34c4cSmrg 12525b16253fSmrg# func_quote_arg MODEs ARG 12535b16253fSmrg# ------------------------ 12545b16253fSmrg# Quote one ARG to be evaled later. MODEs argument may contain zero or more 12555b16253fSmrg# specifiers listed below separated by ',' character. This function returns two 12565b16253fSmrg# values: 12575b16253fSmrg# i) func_quote_arg_result 12585b16253fSmrg# double-quoted (when needed), suitable for a subsequent eval 12595b16253fSmrg# ii) func_quote_arg_unquoted_result 12605b16253fSmrg# has all characters that are still active within double 12615b16253fSmrg# quotes backslashified. Available only if 'unquoted' is specified. 12625b16253fSmrg# 12635b16253fSmrg# Available modes: 12645b16253fSmrg# ---------------- 12655b16253fSmrg# 'eval' (default) 12665b16253fSmrg# - escape shell special characters 12675b16253fSmrg# 'expand' 12685b16253fSmrg# - the same as 'eval'; but do not quote variable references 12695b16253fSmrg# 'pretty' 12705b16253fSmrg# - request aesthetic output, i.e. '"a b"' instead of 'a\ b'. This might 12715b16253fSmrg# be used later in func_quote to get output like: 'echo "a b"' instead 12725b16253fSmrg# of 'echo a\ b'. This is slower than default on some shells. 12735b16253fSmrg# 'unquoted' 12745b16253fSmrg# - produce also $func_quote_arg_unquoted_result which does not contain 12755b16253fSmrg# wrapping double-quotes. 12765b16253fSmrg# 12775b16253fSmrg# Examples for 'func_quote_arg pretty,unquoted string': 12785b16253fSmrg# 12795b16253fSmrg# string | *_result | *_unquoted_result 12805b16253fSmrg# ------------+-----------------------+------------------- 12815b16253fSmrg# " | \" | \" 12825b16253fSmrg# a b | "a b" | a b 12835b16253fSmrg# "a b" | "\"a b\"" | \"a b\" 12845b16253fSmrg# * | "*" | * 12855b16253fSmrg# z="${x-$y}" | "z=\"\${x-\$y}\"" | z=\"\${x-\$y}\" 12865b16253fSmrg# 12875b16253fSmrg# Examples for 'func_quote_arg pretty,unquoted,expand string': 12885b16253fSmrg# 12895b16253fSmrg# string | *_result | *_unquoted_result 12905b16253fSmrg# --------------+---------------------+-------------------- 12915b16253fSmrg# z="${x-$y}" | "z=\"${x-$y}\"" | z=\"${x-$y}\" 12925b16253fSmrgfunc_quote_arg () 12935b16253fSmrg{ 12945b16253fSmrg _G_quote_expand=false 12955b16253fSmrg case ,$1, in 12965b16253fSmrg *,expand,*) 12975b16253fSmrg _G_quote_expand=: 12985b16253fSmrg ;; 1299994689c1Smrg esac 1300994689c1Smrg 13015b16253fSmrg case ,$1, in 13025b16253fSmrg *,pretty,*|*,expand,*|*,unquoted,*) 13035b16253fSmrg func_quote_portable $_G_quote_expand "$2" 13045b16253fSmrg func_quote_arg_result=$func_quote_portable_result 13055b16253fSmrg func_quote_arg_unquoted_result=$func_quote_portable_unquoted_result 13065b16253fSmrg ;; 13075b16253fSmrg *) 13085b16253fSmrg # Faster quote-for-eval for some shells. 13095b16253fSmrg func_quotefast_eval "$2" 13105b16253fSmrg func_quote_arg_result=$func_quotefast_eval_result 1311994689c1Smrg ;; 13125ec34c4cSmrg esac 13135b16253fSmrg} 13145ec34c4cSmrg 13155b16253fSmrg 13165b16253fSmrg# func_quote MODEs ARGs... 13175b16253fSmrg# ------------------------ 13185b16253fSmrg# Quote all ARGs to be evaled later and join them into single command. See 13195b16253fSmrg# func_quote_arg's description for more info. 13205b16253fSmrgfunc_quote () 13215b16253fSmrg{ 13225b16253fSmrg $debug_cmd 13235b16253fSmrg _G_func_quote_mode=$1 ; shift 13245b16253fSmrg func_quote_result= 13255b16253fSmrg while test 0 -lt $#; do 13265b16253fSmrg func_quote_arg "$_G_func_quote_mode" "$1" 13275b16253fSmrg if test -n "$func_quote_result"; then 13285b16253fSmrg func_append func_quote_result " $func_quote_arg_result" 13295b16253fSmrg else 13305b16253fSmrg func_append func_quote_result "$func_quote_arg_result" 13315b16253fSmrg fi 13325b16253fSmrg shift 13335b16253fSmrg done 13345ec34c4cSmrg} 13355ec34c4cSmrg 13365ec34c4cSmrg 13375ec34c4cSmrg# func_stripname PREFIX SUFFIX NAME 13385ec34c4cSmrg# --------------------------------- 13395ec34c4cSmrg# strip PREFIX and SUFFIX from NAME, and store in func_stripname_result. 13405ec34c4cSmrg# PREFIX and SUFFIX must not contain globbing or regex special 13415ec34c4cSmrg# characters, hashes, percent signs, but SUFFIX may contain a leading 13425ec34c4cSmrg# dot (in which case that matches only a dot). 13435ec34c4cSmrgif test yes = "$_G_HAVE_XSI_OPS"; then 13445ec34c4cSmrg eval 'func_stripname () 13455ec34c4cSmrg { 13465ec34c4cSmrg $debug_cmd 13475ec34c4cSmrg 13485ec34c4cSmrg # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are 13495ec34c4cSmrg # positional parameters, so assign one to ordinary variable first. 13505ec34c4cSmrg func_stripname_result=$3 13515ec34c4cSmrg func_stripname_result=${func_stripname_result#"$1"} 13525ec34c4cSmrg func_stripname_result=${func_stripname_result%"$2"} 13535ec34c4cSmrg }' 13545ec34c4cSmrgelse 13555ec34c4cSmrg func_stripname () 13565ec34c4cSmrg { 13575ec34c4cSmrg $debug_cmd 13585ec34c4cSmrg 13595ec34c4cSmrg case $2 in 13605ec34c4cSmrg .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;; 13615ec34c4cSmrg *) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;; 13625ec34c4cSmrg esac 13635ec34c4cSmrg } 13645ec34c4cSmrgfi 13655ec34c4cSmrg 13665ec34c4cSmrg 13675ec34c4cSmrg# func_show_eval CMD [FAIL_EXP] 13685ec34c4cSmrg# ----------------------------- 13695ec34c4cSmrg# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is 13705ec34c4cSmrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 13715ec34c4cSmrg# is given, then evaluate it. 13725ec34c4cSmrgfunc_show_eval () 13735ec34c4cSmrg{ 13745ec34c4cSmrg $debug_cmd 13755ec34c4cSmrg 13765ec34c4cSmrg _G_cmd=$1 13775ec34c4cSmrg _G_fail_exp=${2-':'} 13785ec34c4cSmrg 13795b16253fSmrg func_quote_arg pretty,expand "$_G_cmd" 13805b16253fSmrg eval "func_notquiet $func_quote_arg_result" 13815ec34c4cSmrg 13825ec34c4cSmrg $opt_dry_run || { 13835ec34c4cSmrg eval "$_G_cmd" 13845ec34c4cSmrg _G_status=$? 13855ec34c4cSmrg if test 0 -ne "$_G_status"; then 13865ec34c4cSmrg eval "(exit $_G_status); $_G_fail_exp" 13875ec34c4cSmrg fi 13885ec34c4cSmrg } 13895ec34c4cSmrg} 13905ec34c4cSmrg 13915ec34c4cSmrg 13925ec34c4cSmrg# func_show_eval_locale CMD [FAIL_EXP] 13935ec34c4cSmrg# ------------------------------------ 13945ec34c4cSmrg# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is 13955ec34c4cSmrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 13965ec34c4cSmrg# is given, then evaluate it. Use the saved locale for evaluation. 13975ec34c4cSmrgfunc_show_eval_locale () 13985ec34c4cSmrg{ 13995ec34c4cSmrg $debug_cmd 14005ec34c4cSmrg 14015ec34c4cSmrg _G_cmd=$1 14025ec34c4cSmrg _G_fail_exp=${2-':'} 14035ec34c4cSmrg 14045ec34c4cSmrg $opt_quiet || { 14055b16253fSmrg func_quote_arg expand,pretty "$_G_cmd" 14065b16253fSmrg eval "func_echo $func_quote_arg_result" 14075ec34c4cSmrg } 14085ec34c4cSmrg 14095ec34c4cSmrg $opt_dry_run || { 14105ec34c4cSmrg eval "$_G_user_locale 14115ec34c4cSmrg $_G_cmd" 14125ec34c4cSmrg _G_status=$? 14135ec34c4cSmrg eval "$_G_safe_locale" 14145ec34c4cSmrg if test 0 -ne "$_G_status"; then 14155ec34c4cSmrg eval "(exit $_G_status); $_G_fail_exp" 14165ec34c4cSmrg fi 14175ec34c4cSmrg } 14185ec34c4cSmrg} 14195ec34c4cSmrg 14205ec34c4cSmrg 14215ec34c4cSmrg# func_tr_sh 14225ec34c4cSmrg# ---------- 14235ec34c4cSmrg# Turn $1 into a string suitable for a shell variable name. 14245ec34c4cSmrg# Result is stored in $func_tr_sh_result. All characters 14255ec34c4cSmrg# not in the set a-zA-Z0-9_ are replaced with '_'. Further, 14265ec34c4cSmrg# if $1 begins with a digit, a '_' is prepended as well. 14275ec34c4cSmrgfunc_tr_sh () 14285ec34c4cSmrg{ 14295ec34c4cSmrg $debug_cmd 14305ec34c4cSmrg 14315ec34c4cSmrg case $1 in 14325ec34c4cSmrg [0-9]* | *[!a-zA-Z0-9_]*) 14335ec34c4cSmrg func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'` 14345ec34c4cSmrg ;; 14355ec34c4cSmrg * ) 14365ec34c4cSmrg func_tr_sh_result=$1 14375ec34c4cSmrg ;; 14387a84e134Smrg esac 14397a84e134Smrg} 14407a84e134Smrg 14417a84e134Smrg 14425ec34c4cSmrg# func_verbose ARG... 14435ec34c4cSmrg# ------------------- 14445ec34c4cSmrg# Echo program name prefixed message in verbose mode only. 14455ec34c4cSmrgfunc_verbose () 14465ec34c4cSmrg{ 14475ec34c4cSmrg $debug_cmd 14485ec34c4cSmrg 14495ec34c4cSmrg $opt_verbose && func_echo "$*" 14505ec34c4cSmrg 14515ec34c4cSmrg : 14525ec34c4cSmrg} 14535ec34c4cSmrg 14545ec34c4cSmrg 14555ec34c4cSmrg# func_warn_and_continue ARG... 14565ec34c4cSmrg# ----------------------------- 14575ec34c4cSmrg# Echo program name prefixed warning message to standard error. 14585ec34c4cSmrgfunc_warn_and_continue () 14595ec34c4cSmrg{ 14605ec34c4cSmrg $debug_cmd 14615ec34c4cSmrg 14625ec34c4cSmrg $require_term_colors 14635ec34c4cSmrg 14645ec34c4cSmrg func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2 14655ec34c4cSmrg} 14665ec34c4cSmrg 14675ec34c4cSmrg 14685ec34c4cSmrg# func_warning CATEGORY ARG... 14695ec34c4cSmrg# ---------------------------- 14705ec34c4cSmrg# Echo program name prefixed warning message to standard error. Warning 14715ec34c4cSmrg# messages can be filtered according to CATEGORY, where this function 14725ec34c4cSmrg# elides messages where CATEGORY is not listed in the global variable 14735ec34c4cSmrg# 'opt_warning_types'. 14745ec34c4cSmrgfunc_warning () 14755ec34c4cSmrg{ 14765ec34c4cSmrg $debug_cmd 14775ec34c4cSmrg 14785ec34c4cSmrg # CATEGORY must be in the warning_categories list! 14795ec34c4cSmrg case " $warning_categories " in 14805ec34c4cSmrg *" $1 "*) ;; 14815ec34c4cSmrg *) func_internal_error "invalid warning category '$1'" ;; 14825ec34c4cSmrg esac 14835ec34c4cSmrg 14845ec34c4cSmrg _G_category=$1 14855ec34c4cSmrg shift 14865ec34c4cSmrg 14875ec34c4cSmrg case " $opt_warning_types " in 14885ec34c4cSmrg *" $_G_category "*) $warning_func ${1+"$@"} ;; 14895ec34c4cSmrg esac 14905ec34c4cSmrg} 14915ec34c4cSmrg 14925ec34c4cSmrg 14935ec34c4cSmrg# func_sort_ver VER1 VER2 14945ec34c4cSmrg# ----------------------- 14955ec34c4cSmrg# 'sort -V' is not generally available. 14965ec34c4cSmrg# Note this deviates from the version comparison in automake 14975ec34c4cSmrg# in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a 14985ec34c4cSmrg# but this should suffice as we won't be specifying old 14995ec34c4cSmrg# version formats or redundant trailing .0 in bootstrap.conf. 15005ec34c4cSmrg# If we did want full compatibility then we should probably 15015ec34c4cSmrg# use m4_version_compare from autoconf. 15025ec34c4cSmrgfunc_sort_ver () 15035ec34c4cSmrg{ 15045ec34c4cSmrg $debug_cmd 15055ec34c4cSmrg 15065ec34c4cSmrg printf '%s\n%s\n' "$1" "$2" \ 15075ec34c4cSmrg | 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 15085ec34c4cSmrg} 15095ec34c4cSmrg 15105ec34c4cSmrg# func_lt_ver PREV CURR 15115ec34c4cSmrg# --------------------- 15125ec34c4cSmrg# Return true if PREV and CURR are in the correct order according to 15135ec34c4cSmrg# func_sort_ver, otherwise false. Use it like this: 15145ec34c4cSmrg# 15155ec34c4cSmrg# func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..." 15165ec34c4cSmrgfunc_lt_ver () 15175ec34c4cSmrg{ 15185ec34c4cSmrg $debug_cmd 15195ec34c4cSmrg 15205ec34c4cSmrg test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q` 15215ec34c4cSmrg} 15225ec34c4cSmrg 15235ec34c4cSmrg 15245ec34c4cSmrg# Local variables: 15255ec34c4cSmrg# mode: shell-script 15265ec34c4cSmrg# sh-indentation: 2 15275ec34c4cSmrg# eval: (add-hook 'before-save-hook 'time-stamp) 15285ec34c4cSmrg# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" 15295ec34c4cSmrg# time-stamp-time-zone: "UTC" 15305ec34c4cSmrg# End: 15315ec34c4cSmrg#! /bin/sh 15325ec34c4cSmrg 15335ec34c4cSmrg# A portable, pluggable option parser for Bourne shell. 15345ec34c4cSmrg# Written by Gary V. Vaughan, 2010 15355ec34c4cSmrg 15365b16253fSmrg# This is free software. There is NO warranty; not even for 15375b16253fSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 15385b16253fSmrg# 15395b16253fSmrg# Copyright (C) 2010-2019, 2021 Bootstrap Authors 15405b16253fSmrg# 15415b16253fSmrg# This file is dual licensed under the terms of the MIT license 15425b16253fSmrg# <https://opensource.org/license/MIT>, and GPL version 2 or later 15435b16253fSmrg# <http://www.gnu.org/licenses/gpl-2.0.html>. You must apply one of 15445b16253fSmrg# these licenses when using or redistributing this software or any of 15455b16253fSmrg# the files within it. See the URLs above, or the file `LICENSE` 15465b16253fSmrg# included in the Bootstrap distribution for the full license texts. 15475ec34c4cSmrg 15485b16253fSmrg# Please report bugs or propose patches to: 15495b16253fSmrg# <https://github.com/gnulib-modules/bootstrap/issues> 15505ec34c4cSmrg 15515b16253fSmrg# Set a version string for this script. 15525b16253fSmrgscriptversion=2019-02-19.15; # UTC 15535ec34c4cSmrg 15545ec34c4cSmrg 15555ec34c4cSmrg## ------ ## 15565ec34c4cSmrg## Usage. ## 15575ec34c4cSmrg## ------ ## 15585ec34c4cSmrg 15595ec34c4cSmrg# This file is a library for parsing options in your shell scripts along 15605ec34c4cSmrg# with assorted other useful supporting features that you can make use 15615ec34c4cSmrg# of too. 15625ec34c4cSmrg# 15635ec34c4cSmrg# For the simplest scripts you might need only: 15645ec34c4cSmrg# 15655ec34c4cSmrg# #!/bin/sh 15665ec34c4cSmrg# . relative/path/to/funclib.sh 15675ec34c4cSmrg# . relative/path/to/options-parser 15685ec34c4cSmrg# scriptversion=1.0 15695ec34c4cSmrg# func_options ${1+"$@"} 15705ec34c4cSmrg# eval set dummy "$func_options_result"; shift 15715ec34c4cSmrg# ...rest of your script... 15725ec34c4cSmrg# 15735ec34c4cSmrg# In order for the '--version' option to work, you will need to have a 15745ec34c4cSmrg# suitably formatted comment like the one at the top of this file 15755b16253fSmrg# starting with '# Written by ' and ending with '# Copyright'. 15765ec34c4cSmrg# 15775ec34c4cSmrg# For '-h' and '--help' to work, you will also need a one line 15785ec34c4cSmrg# description of your script's purpose in a comment directly above the 15795ec34c4cSmrg# '# Written by ' line, like the one at the top of this file. 15805ec34c4cSmrg# 15815ec34c4cSmrg# The default options also support '--debug', which will turn on shell 15825ec34c4cSmrg# execution tracing (see the comment above debug_cmd below for another 15835ec34c4cSmrg# use), and '--verbose' and the func_verbose function to allow your script 15845ec34c4cSmrg# to display verbose messages only when your user has specified 15855ec34c4cSmrg# '--verbose'. 15865ec34c4cSmrg# 15875b16253fSmrg# After sourcing this file, you can plug in processing for additional 15885ec34c4cSmrg# options by amending the variables from the 'Configuration' section 15895ec34c4cSmrg# below, and following the instructions in the 'Option parsing' 15905ec34c4cSmrg# section further down. 15915ec34c4cSmrg 15925ec34c4cSmrg## -------------- ## 15935ec34c4cSmrg## Configuration. ## 15945ec34c4cSmrg## -------------- ## 15955ec34c4cSmrg 15965ec34c4cSmrg# You should override these variables in your script after sourcing this 15975ec34c4cSmrg# file so that they reflect the customisations you have added to the 15985ec34c4cSmrg# option parser. 15995ec34c4cSmrg 16005ec34c4cSmrg# The usage line for option parsing errors and the start of '-h' and 16015ec34c4cSmrg# '--help' output messages. You can embed shell variables for delayed 16025ec34c4cSmrg# expansion at the time the message is displayed, but you will need to 16035ec34c4cSmrg# quote other shell meta-characters carefully to prevent them being 16045ec34c4cSmrg# expanded when the contents are evaled. 16055ec34c4cSmrgusage='$progpath [OPTION]...' 16065ec34c4cSmrg 16075ec34c4cSmrg# Short help message in response to '-h' and '--help'. Add to this or 16085ec34c4cSmrg# override it after sourcing this library to reflect the full set of 16095ec34c4cSmrg# options your script accepts. 16105ec34c4cSmrgusage_message="\ 16115ec34c4cSmrg --debug enable verbose shell tracing 16125ec34c4cSmrg -W, --warnings=CATEGORY 16135ec34c4cSmrg report the warnings falling in CATEGORY [all] 16145ec34c4cSmrg -v, --verbose verbosely report processing 16155ec34c4cSmrg --version print version information and exit 16165ec34c4cSmrg -h, --help print short or long help message and exit 16175ec34c4cSmrg" 16185ec34c4cSmrg 16195ec34c4cSmrg# Additional text appended to 'usage_message' in response to '--help'. 16205ec34c4cSmrglong_help_message=" 16215ec34c4cSmrgWarning categories include: 16225ec34c4cSmrg 'all' show all warnings 16235ec34c4cSmrg 'none' turn off all the warnings 16245ec34c4cSmrg 'error' warnings are treated as fatal errors" 16255ec34c4cSmrg 16265ec34c4cSmrg# Help message printed before fatal option parsing errors. 16275ec34c4cSmrgfatal_help="Try '\$progname --help' for more information." 16285ec34c4cSmrg 16295ec34c4cSmrg 16305ec34c4cSmrg 16315ec34c4cSmrg## ------------------------- ## 16325ec34c4cSmrg## Hook function management. ## 16335ec34c4cSmrg## ------------------------- ## 16345ec34c4cSmrg 16355ec34c4cSmrg# This section contains functions for adding, removing, and running hooks 16365b16253fSmrg# in the main code. A hook is just a list of function names that can be 16375b16253fSmrg# run in order later on. 16385ec34c4cSmrg 16395ec34c4cSmrg# func_hookable FUNC_NAME 16405ec34c4cSmrg# ----------------------- 16415ec34c4cSmrg# Declare that FUNC_NAME will run hooks added with 16425ec34c4cSmrg# 'func_add_hook FUNC_NAME ...'. 16435ec34c4cSmrgfunc_hookable () 16445ec34c4cSmrg{ 16455ec34c4cSmrg $debug_cmd 16465ec34c4cSmrg 16475ec34c4cSmrg func_append hookable_fns " $1" 16485ec34c4cSmrg} 16495ec34c4cSmrg 16505ec34c4cSmrg 16515ec34c4cSmrg# func_add_hook FUNC_NAME HOOK_FUNC 16525ec34c4cSmrg# --------------------------------- 16535ec34c4cSmrg# Request that FUNC_NAME call HOOK_FUNC before it returns. FUNC_NAME must 16545ec34c4cSmrg# first have been declared "hookable" by a call to 'func_hookable'. 16555ec34c4cSmrgfunc_add_hook () 16565ec34c4cSmrg{ 16575ec34c4cSmrg $debug_cmd 16585ec34c4cSmrg 16595ec34c4cSmrg case " $hookable_fns " in 16605ec34c4cSmrg *" $1 "*) ;; 16615ec34c4cSmrg *) func_fatal_error "'$1' does not accept hook functions." ;; 16625ec34c4cSmrg esac 16635ec34c4cSmrg 16645ec34c4cSmrg eval func_append ${1}_hooks '" $2"' 16655ec34c4cSmrg} 16665ec34c4cSmrg 16675ec34c4cSmrg 16685ec34c4cSmrg# func_remove_hook FUNC_NAME HOOK_FUNC 16695ec34c4cSmrg# ------------------------------------ 16705b16253fSmrg# Remove HOOK_FUNC from the list of hook functions to be called by 16715b16253fSmrg# FUNC_NAME. 16725ec34c4cSmrgfunc_remove_hook () 16735ec34c4cSmrg{ 16745ec34c4cSmrg $debug_cmd 16755ec34c4cSmrg 16765ec34c4cSmrg eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`' 16775ec34c4cSmrg} 16785ec34c4cSmrg 16795ec34c4cSmrg 16805b16253fSmrg# func_propagate_result FUNC_NAME_A FUNC_NAME_B 16815b16253fSmrg# --------------------------------------------- 16825b16253fSmrg# If the *_result variable of FUNC_NAME_A _is set_, assign its value to 16835b16253fSmrg# *_result variable of FUNC_NAME_B. 16845b16253fSmrgfunc_propagate_result () 16855b16253fSmrg{ 16865b16253fSmrg $debug_cmd 16875b16253fSmrg 16885b16253fSmrg func_propagate_result_result=: 16895b16253fSmrg if eval "test \"\${${1}_result+set}\" = set" 16905b16253fSmrg then 16915b16253fSmrg eval "${2}_result=\$${1}_result" 16925b16253fSmrg else 16935b16253fSmrg func_propagate_result_result=false 16945b16253fSmrg fi 16955b16253fSmrg} 16965b16253fSmrg 16975b16253fSmrg 16985ec34c4cSmrg# func_run_hooks FUNC_NAME [ARG]... 16995ec34c4cSmrg# --------------------------------- 17005ec34c4cSmrg# Run all hook functions registered to FUNC_NAME. 17015b16253fSmrg# It's assumed that the list of hook functions contains nothing more 17025ec34c4cSmrg# than a whitespace-delimited list of legal shell function names, and 17035ec34c4cSmrg# no effort is wasted trying to catch shell meta-characters or preserve 17045ec34c4cSmrg# whitespace. 17055ec34c4cSmrgfunc_run_hooks () 17065ec34c4cSmrg{ 17075ec34c4cSmrg $debug_cmd 17085ec34c4cSmrg 17095ec34c4cSmrg case " $hookable_fns " in 17105ec34c4cSmrg *" $1 "*) ;; 17115b16253fSmrg *) func_fatal_error "'$1' does not support hook functions." ;; 17125ec34c4cSmrg esac 17135ec34c4cSmrg 17145ec34c4cSmrg eval _G_hook_fns=\$$1_hooks; shift 17155ec34c4cSmrg 17165ec34c4cSmrg for _G_hook in $_G_hook_fns; do 17175b16253fSmrg func_unset "${_G_hook}_result" 17185b16253fSmrg eval $_G_hook '${1+"$@"}' 17195b16253fSmrg func_propagate_result $_G_hook func_run_hooks 17205b16253fSmrg if $func_propagate_result_result; then 17215b16253fSmrg eval set dummy "$func_run_hooks_result"; shift 17225b16253fSmrg fi 17235ec34c4cSmrg done 17245ec34c4cSmrg} 17255ec34c4cSmrg 17265ec34c4cSmrg 17275ec34c4cSmrg 17285ec34c4cSmrg## --------------- ## 17295ec34c4cSmrg## Option parsing. ## 17305ec34c4cSmrg## --------------- ## 17315ec34c4cSmrg 17325ec34c4cSmrg# In order to add your own option parsing hooks, you must accept the 17335b16253fSmrg# full positional parameter list from your hook function. You may remove 17345b16253fSmrg# or edit any options that you action, and then pass back the remaining 17355b16253fSmrg# unprocessed options in '<hooked_function_name>_result', escaped 17365b16253fSmrg# suitably for 'eval'. 17375b16253fSmrg# 17385b16253fSmrg# The '<hooked_function_name>_result' variable is automatically unset 17395b16253fSmrg# before your hook gets called; for best performance, only set the 17405b16253fSmrg# *_result variable when necessary (i.e. don't call the 'func_quote' 17415b16253fSmrg# function unnecessarily because it can be an expensive operation on some 17425b16253fSmrg# machines). 17435b16253fSmrg# 17445b16253fSmrg# Like this: 17455ec34c4cSmrg# 17465ec34c4cSmrg# my_options_prep () 17475ec34c4cSmrg# { 17485ec34c4cSmrg# $debug_cmd 17495ec34c4cSmrg# 17505ec34c4cSmrg# # Extend the existing usage message. 17515ec34c4cSmrg# usage_message=$usage_message' 17525ec34c4cSmrg# -s, --silent don'\''t print informational messages 17535ec34c4cSmrg# ' 17545b16253fSmrg# # No change in '$@' (ignored completely by this hook). Leave 17555b16253fSmrg# # my_options_prep_result variable intact. 17565ec34c4cSmrg# } 17575ec34c4cSmrg# func_add_hook func_options_prep my_options_prep 17585ec34c4cSmrg# 17595ec34c4cSmrg# 17605ec34c4cSmrg# my_silent_option () 17615ec34c4cSmrg# { 17625ec34c4cSmrg# $debug_cmd 17635ec34c4cSmrg# 17645b16253fSmrg# args_changed=false 17655b16253fSmrg# 17665b16253fSmrg# # Note that, for efficiency, we parse as many options as we can 17675ec34c4cSmrg# # recognise in a loop before passing the remainder back to the 17685ec34c4cSmrg# # caller on the first unrecognised argument we encounter. 17695ec34c4cSmrg# while test $# -gt 0; do 17705ec34c4cSmrg# opt=$1; shift 17715ec34c4cSmrg# case $opt in 17725b16253fSmrg# --silent|-s) opt_silent=: 17735b16253fSmrg# args_changed=: 17745b16253fSmrg# ;; 17755ec34c4cSmrg# # Separate non-argument short options: 17765ec34c4cSmrg# -s*) func_split_short_opt "$_G_opt" 17775ec34c4cSmrg# set dummy "$func_split_short_opt_name" \ 17785ec34c4cSmrg# "-$func_split_short_opt_arg" ${1+"$@"} 17795ec34c4cSmrg# shift 17805b16253fSmrg# args_changed=: 17815ec34c4cSmrg# ;; 17825b16253fSmrg# *) # Make sure the first unrecognised option "$_G_opt" 17835b16253fSmrg# # is added back to "$@" in case we need it later, 17845b16253fSmrg# # if $args_changed was set to 'true'. 17855b16253fSmrg# set dummy "$_G_opt" ${1+"$@"}; shift; break ;; 17865ec34c4cSmrg# esac 17875ec34c4cSmrg# done 17885ec34c4cSmrg# 17895b16253fSmrg# # Only call 'func_quote' here if we processed at least one argument. 17905b16253fSmrg# if $args_changed; then 17915b16253fSmrg# func_quote eval ${1+"$@"} 17925b16253fSmrg# my_silent_option_result=$func_quote_result 17935b16253fSmrg# fi 17945ec34c4cSmrg# } 17955ec34c4cSmrg# func_add_hook func_parse_options my_silent_option 17965ec34c4cSmrg# 17975ec34c4cSmrg# 17985ec34c4cSmrg# my_option_validation () 17995ec34c4cSmrg# { 18005ec34c4cSmrg# $debug_cmd 18015ec34c4cSmrg# 18025ec34c4cSmrg# $opt_silent && $opt_verbose && func_fatal_help "\ 18035ec34c4cSmrg# '--silent' and '--verbose' options are mutually exclusive." 18045ec34c4cSmrg# } 18055ec34c4cSmrg# func_add_hook func_validate_options my_option_validation 18065ec34c4cSmrg# 18075b16253fSmrg# You'll also need to manually amend $usage_message to reflect the extra 18085ec34c4cSmrg# options you parse. It's preferable to append if you can, so that 18095ec34c4cSmrg# multiple option parsing hooks can be added safely. 18105ec34c4cSmrg 18115ec34c4cSmrg 18125b16253fSmrg# func_options_finish [ARG]... 18135b16253fSmrg# ---------------------------- 18145b16253fSmrg# Finishing the option parse loop (call 'func_options' hooks ATM). 18155b16253fSmrgfunc_options_finish () 18165b16253fSmrg{ 18175b16253fSmrg $debug_cmd 18185b16253fSmrg 18195b16253fSmrg func_run_hooks func_options ${1+"$@"} 18205b16253fSmrg func_propagate_result func_run_hooks func_options_finish 18215b16253fSmrg} 18225b16253fSmrg 18235b16253fSmrg 18245ec34c4cSmrg# func_options [ARG]... 18255ec34c4cSmrg# --------------------- 18265ec34c4cSmrg# All the functions called inside func_options are hookable. See the 18275ec34c4cSmrg# individual implementations for details. 18285ec34c4cSmrgfunc_hookable func_options 18295ec34c4cSmrgfunc_options () 18307a84e134Smrg{ 18315ec34c4cSmrg $debug_cmd 1832994689c1Smrg 18335b16253fSmrg _G_options_quoted=false 1834994689c1Smrg 18355b16253fSmrg for my_func in options_prep parse_options validate_options options_finish 18365b16253fSmrg do 18375b16253fSmrg func_unset func_${my_func}_result 18385b16253fSmrg func_unset func_run_hooks_result 18395b16253fSmrg eval func_$my_func '${1+"$@"}' 18405b16253fSmrg func_propagate_result func_$my_func func_options 18415b16253fSmrg if $func_propagate_result_result; then 18425b16253fSmrg eval set dummy "$func_options_result"; shift 18435b16253fSmrg _G_options_quoted=: 18445b16253fSmrg fi 18455b16253fSmrg done 18465ec34c4cSmrg 18475b16253fSmrg $_G_options_quoted || { 18485b16253fSmrg # As we (func_options) are top-level options-parser function and 18495b16253fSmrg # nobody quoted "$@" for us yet, we need to do it explicitly for 18505b16253fSmrg # caller. 18515b16253fSmrg func_quote eval ${1+"$@"} 18525b16253fSmrg func_options_result=$func_quote_result 18535b16253fSmrg } 18547a84e134Smrg} 18557a84e134Smrg 18567a84e134Smrg 18575ec34c4cSmrg# func_options_prep [ARG]... 18585ec34c4cSmrg# -------------------------- 18595ec34c4cSmrg# All initialisations required before starting the option parse loop. 18605ec34c4cSmrg# Note that when calling hook functions, we pass through the list of 18615ec34c4cSmrg# positional parameters. If a hook function modifies that list, and 18625b16253fSmrg# needs to propagate that back to rest of this script, then the complete 18635b16253fSmrg# modified list must be put in 'func_run_hooks_result' before returning. 18645ec34c4cSmrgfunc_hookable func_options_prep 18655ec34c4cSmrgfunc_options_prep () 18667a84e134Smrg{ 18675ec34c4cSmrg $debug_cmd 1868775e7de9Smrg 18695ec34c4cSmrg # Option defaults: 18705ec34c4cSmrg opt_verbose=false 18715ec34c4cSmrg opt_warning_types= 1872994689c1Smrg 18735ec34c4cSmrg func_run_hooks func_options_prep ${1+"$@"} 18745b16253fSmrg func_propagate_result func_run_hooks func_options_prep 18757a84e134Smrg} 18767a84e134Smrg 1877994689c1Smrg 18785ec34c4cSmrg# func_parse_options [ARG]... 18795ec34c4cSmrg# --------------------------- 18805ec34c4cSmrg# The main option parsing loop. 18815ec34c4cSmrgfunc_hookable func_parse_options 18825ec34c4cSmrgfunc_parse_options () 18837a84e134Smrg{ 18845ec34c4cSmrg $debug_cmd 18857a84e134Smrg 18865b16253fSmrg _G_parse_options_requote=false 18875ec34c4cSmrg # this just eases exit handling 18885ec34c4cSmrg while test $# -gt 0; do 18895ec34c4cSmrg # Defer to hook functions for initial option parsing, so they 18905ec34c4cSmrg # get priority in the event of reusing an option name. 18915ec34c4cSmrg func_run_hooks func_parse_options ${1+"$@"} 18925b16253fSmrg func_propagate_result func_run_hooks func_parse_options 18935b16253fSmrg if $func_propagate_result_result; then 18945b16253fSmrg eval set dummy "$func_parse_options_result"; shift 18955b16253fSmrg # Even though we may have changed "$@", we passed the "$@" array 18965b16253fSmrg # down into the hook and it quoted it for us (because we are in 18975b16253fSmrg # this if-branch). No need to quote it again. 18985b16253fSmrg _G_parse_options_requote=false 18995b16253fSmrg fi 19005ec34c4cSmrg 19015ec34c4cSmrg # Break out of the loop if we already parsed every option. 19025ec34c4cSmrg test $# -gt 0 || break 19035ec34c4cSmrg 19045b16253fSmrg # We expect that one of the options parsed in this function matches 19055b16253fSmrg # and thus we remove _G_opt from "$@" and need to re-quote. 19065b16253fSmrg _G_match_parse_options=: 19075ec34c4cSmrg _G_opt=$1 19085ec34c4cSmrg shift 19095ec34c4cSmrg case $_G_opt in 19105ec34c4cSmrg --debug|-x) debug_cmd='set -x' 19115b16253fSmrg func_echo "enabling shell trace mode" >&2 19125ec34c4cSmrg $debug_cmd 19135ec34c4cSmrg ;; 19145ec34c4cSmrg 19155ec34c4cSmrg --no-warnings|--no-warning|--no-warn) 19165ec34c4cSmrg set dummy --warnings none ${1+"$@"} 19175ec34c4cSmrg shift 19185ec34c4cSmrg ;; 19195ec34c4cSmrg 19205ec34c4cSmrg --warnings|--warning|-W) 19215b16253fSmrg if test $# = 0 && func_missing_arg $_G_opt; then 19225b16253fSmrg _G_parse_options_requote=: 19235b16253fSmrg break 19245b16253fSmrg fi 19255ec34c4cSmrg case " $warning_categories $1" in 19265ec34c4cSmrg *" $1 "*) 19275ec34c4cSmrg # trailing space prevents matching last $1 above 19285ec34c4cSmrg func_append_uniq opt_warning_types " $1" 19295ec34c4cSmrg ;; 19305ec34c4cSmrg *all) 19315ec34c4cSmrg opt_warning_types=$warning_categories 19325ec34c4cSmrg ;; 19335ec34c4cSmrg *none) 19345ec34c4cSmrg opt_warning_types=none 19355ec34c4cSmrg warning_func=: 19365ec34c4cSmrg ;; 19375ec34c4cSmrg *error) 19385ec34c4cSmrg opt_warning_types=$warning_categories 19395ec34c4cSmrg warning_func=func_fatal_error 19405ec34c4cSmrg ;; 19415ec34c4cSmrg *) 19425ec34c4cSmrg func_fatal_error \ 19435ec34c4cSmrg "unsupported warning category: '$1'" 19445ec34c4cSmrg ;; 19455ec34c4cSmrg esac 19465ec34c4cSmrg shift 19475ec34c4cSmrg ;; 19485ec34c4cSmrg 19495ec34c4cSmrg --verbose|-v) opt_verbose=: ;; 19505ec34c4cSmrg --version) func_version ;; 19515ec34c4cSmrg -\?|-h) func_usage ;; 19525ec34c4cSmrg --help) func_help ;; 19535ec34c4cSmrg 19545ec34c4cSmrg # Separate optargs to long options (plugins may need this): 19555ec34c4cSmrg --*=*) func_split_equals "$_G_opt" 19565ec34c4cSmrg set dummy "$func_split_equals_lhs" \ 19575ec34c4cSmrg "$func_split_equals_rhs" ${1+"$@"} 19585ec34c4cSmrg shift 19595ec34c4cSmrg ;; 19605ec34c4cSmrg 19615ec34c4cSmrg # Separate optargs to short options: 19625ec34c4cSmrg -W*) 19635ec34c4cSmrg func_split_short_opt "$_G_opt" 19645ec34c4cSmrg set dummy "$func_split_short_opt_name" \ 19655ec34c4cSmrg "$func_split_short_opt_arg" ${1+"$@"} 19665ec34c4cSmrg shift 19675ec34c4cSmrg ;; 19685ec34c4cSmrg 19695ec34c4cSmrg # Separate non-argument short options: 19705ec34c4cSmrg -\?*|-h*|-v*|-x*) 19715ec34c4cSmrg func_split_short_opt "$_G_opt" 19725ec34c4cSmrg set dummy "$func_split_short_opt_name" \ 19735ec34c4cSmrg "-$func_split_short_opt_arg" ${1+"$@"} 19745ec34c4cSmrg shift 19755ec34c4cSmrg ;; 19765ec34c4cSmrg 19775b16253fSmrg --) _G_parse_options_requote=: ; break ;; 19785ec34c4cSmrg -*) func_fatal_help "unrecognised option: '$_G_opt'" ;; 19795b16253fSmrg *) set dummy "$_G_opt" ${1+"$@"}; shift 19805b16253fSmrg _G_match_parse_options=false 19815b16253fSmrg break 19825b16253fSmrg ;; 19835ec34c4cSmrg esac 19845b16253fSmrg 19855b16253fSmrg if $_G_match_parse_options; then 19865b16253fSmrg _G_parse_options_requote=: 19875b16253fSmrg fi 19885ec34c4cSmrg done 19895ec34c4cSmrg 19905b16253fSmrg if $_G_parse_options_requote; then 19915b16253fSmrg # save modified positional parameters for caller 19925b16253fSmrg func_quote eval ${1+"$@"} 19935b16253fSmrg func_parse_options_result=$func_quote_result 19945b16253fSmrg fi 1995f353fbadSmrg} 1996f353fbadSmrg 1997775e7de9Smrg 19985ec34c4cSmrg# func_validate_options [ARG]... 19995ec34c4cSmrg# ------------------------------ 20005ec34c4cSmrg# Perform any sanity checks on option settings and/or unconsumed 20015ec34c4cSmrg# arguments. 20025ec34c4cSmrgfunc_hookable func_validate_options 20035ec34c4cSmrgfunc_validate_options () 2004994689c1Smrg{ 20055ec34c4cSmrg $debug_cmd 2006f353fbadSmrg 20075ec34c4cSmrg # Display all warnings if -W was not given. 20085ec34c4cSmrg test -n "$opt_warning_types" || opt_warning_types=" $warning_categories" 20095ec34c4cSmrg 20105ec34c4cSmrg func_run_hooks func_validate_options ${1+"$@"} 20115b16253fSmrg func_propagate_result func_run_hooks func_validate_options 20125ec34c4cSmrg 20135ec34c4cSmrg # Bail if the options were screwed! 20145ec34c4cSmrg $exit_cmd $EXIT_FAILURE 2015994689c1Smrg} 2016775e7de9Smrg 20175ec34c4cSmrg 20185ec34c4cSmrg 20195ec34c4cSmrg## ----------------- ## 20205ec34c4cSmrg## Helper functions. ## 20215ec34c4cSmrg## ----------------- ## 20225ec34c4cSmrg 20235ec34c4cSmrg# This section contains the helper functions used by the rest of the 20245ec34c4cSmrg# hookable option parser framework in ascii-betical order. 20255ec34c4cSmrg 20265ec34c4cSmrg 20275ec34c4cSmrg# func_fatal_help ARG... 20285ec34c4cSmrg# ---------------------- 20295ec34c4cSmrg# Echo program name prefixed message to standard error, followed by 20305ec34c4cSmrg# a help hint, and exit. 20315ec34c4cSmrgfunc_fatal_help () 2032994689c1Smrg{ 20335ec34c4cSmrg $debug_cmd 2034f353fbadSmrg 20355ec34c4cSmrg eval \$ECHO \""Usage: $usage"\" 20365ec34c4cSmrg eval \$ECHO \""$fatal_help"\" 20375ec34c4cSmrg func_error ${1+"$@"} 20385ec34c4cSmrg exit $EXIT_FAILURE 2039994689c1Smrg} 20407a84e134Smrg 20415ec34c4cSmrg 20425ec34c4cSmrg# func_help 20435ec34c4cSmrg# --------- 20445ec34c4cSmrg# Echo long help message to standard output and exit. 2045994689c1Smrgfunc_help () 2046994689c1Smrg{ 20475ec34c4cSmrg $debug_cmd 20485ec34c4cSmrg 20495ec34c4cSmrg func_usage_message 20505ec34c4cSmrg $ECHO "$long_help_message" 20515ec34c4cSmrg exit 0 2052994689c1Smrg} 20537a84e134Smrg 20545ec34c4cSmrg 20555ec34c4cSmrg# func_missing_arg ARGNAME 20565ec34c4cSmrg# ------------------------ 2057994689c1Smrg# Echo program name prefixed message to standard error and set global 2058994689c1Smrg# exit_cmd. 2059994689c1Smrgfunc_missing_arg () 2060994689c1Smrg{ 20615ec34c4cSmrg $debug_cmd 2062f353fbadSmrg 20635ec34c4cSmrg func_error "Missing argument for '$1'." 2064994689c1Smrg exit_cmd=exit 2065994689c1Smrg} 20667a84e134Smrg 2067775e7de9Smrg 20685ec34c4cSmrg# func_split_equals STRING 20695ec34c4cSmrg# ------------------------ 20705b16253fSmrg# Set func_split_equals_lhs and func_split_equals_rhs shell variables 20715b16253fSmrg# after splitting STRING at the '=' sign. 20725ec34c4cSmrgtest -z "$_G_HAVE_XSI_OPS" \ 20735ec34c4cSmrg && (eval 'x=a/b/c; 20745ec34c4cSmrg test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ 20755ec34c4cSmrg && _G_HAVE_XSI_OPS=yes 20765ec34c4cSmrg 20775ec34c4cSmrgif test yes = "$_G_HAVE_XSI_OPS" 20785ec34c4cSmrgthen 20795ec34c4cSmrg # This is an XSI compatible shell, allowing a faster implementation... 20805ec34c4cSmrg eval 'func_split_equals () 20815ec34c4cSmrg { 20825ec34c4cSmrg $debug_cmd 20835ec34c4cSmrg 20845ec34c4cSmrg func_split_equals_lhs=${1%%=*} 20855ec34c4cSmrg func_split_equals_rhs=${1#*=} 20865b16253fSmrg if test "x$func_split_equals_lhs" = "x$1"; then 20875b16253fSmrg func_split_equals_rhs= 20885b16253fSmrg fi 20895ec34c4cSmrg }' 20905ec34c4cSmrgelse 20915ec34c4cSmrg # ...otherwise fall back to using expr, which is often a shell builtin. 20925ec34c4cSmrg func_split_equals () 20935ec34c4cSmrg { 20945ec34c4cSmrg $debug_cmd 20955ec34c4cSmrg 20965ec34c4cSmrg func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'` 20975ec34c4cSmrg func_split_equals_rhs= 20985b16253fSmrg test "x$func_split_equals_lhs=" = "x$1" \ 20995ec34c4cSmrg || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'` 21005ec34c4cSmrg } 21015ec34c4cSmrgfi #func_split_equals 21025ec34c4cSmrg 21035ec34c4cSmrg 21045ec34c4cSmrg# func_split_short_opt SHORTOPT 21055ec34c4cSmrg# ----------------------------- 2106f353fbadSmrg# Set func_split_short_opt_name and func_split_short_opt_arg shell 2107f353fbadSmrg# variables after splitting SHORTOPT after the 2nd character. 21085ec34c4cSmrgif test yes = "$_G_HAVE_XSI_OPS" 21095ec34c4cSmrgthen 21105ec34c4cSmrg # This is an XSI compatible shell, allowing a faster implementation... 21115ec34c4cSmrg eval 'func_split_short_opt () 21125ec34c4cSmrg { 21135ec34c4cSmrg $debug_cmd 21145ec34c4cSmrg 21155ec34c4cSmrg func_split_short_opt_arg=${1#??} 21165ec34c4cSmrg func_split_short_opt_name=${1%"$func_split_short_opt_arg"} 21175ec34c4cSmrg }' 21185ec34c4cSmrgelse 21195ec34c4cSmrg # ...otherwise fall back to using expr, which is often a shell builtin. 21205ec34c4cSmrg func_split_short_opt () 21215ec34c4cSmrg { 21225ec34c4cSmrg $debug_cmd 21235ec34c4cSmrg 21245b16253fSmrg func_split_short_opt_name=`expr "x$1" : 'x\(-.\)'` 21255ec34c4cSmrg func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'` 21265ec34c4cSmrg } 21275ec34c4cSmrgfi #func_split_short_opt 21285ec34c4cSmrg 21295ec34c4cSmrg 21305ec34c4cSmrg# func_usage 21315ec34c4cSmrg# ---------- 21325ec34c4cSmrg# Echo short help message to standard output and exit. 21335ec34c4cSmrgfunc_usage () 2134f353fbadSmrg{ 21355ec34c4cSmrg $debug_cmd 2136f353fbadSmrg 21375ec34c4cSmrg func_usage_message 21385ec34c4cSmrg $ECHO "Run '$progname --help |${PAGER-more}' for full usage" 21395ec34c4cSmrg exit 0 21405ec34c4cSmrg} 2141f353fbadSmrg 2142f353fbadSmrg 21435ec34c4cSmrg# func_usage_message 21445ec34c4cSmrg# ------------------ 21455ec34c4cSmrg# Echo short help message to standard output. 21465ec34c4cSmrgfunc_usage_message () 2147f353fbadSmrg{ 21485ec34c4cSmrg $debug_cmd 2149f353fbadSmrg 21505ec34c4cSmrg eval \$ECHO \""Usage: $usage"\" 21515ec34c4cSmrg echo 21525ec34c4cSmrg $SED -n 's|^# || 21535ec34c4cSmrg /^Written by/{ 21545ec34c4cSmrg x;p;x 21555ec34c4cSmrg } 21565ec34c4cSmrg h 21575ec34c4cSmrg /^Written by/q' < "$progpath" 21585ec34c4cSmrg echo 21595ec34c4cSmrg eval \$ECHO \""$usage_message"\" 21605ec34c4cSmrg} 2161f353fbadSmrg 21627a84e134Smrg 21635ec34c4cSmrg# func_version 21645ec34c4cSmrg# ------------ 21655ec34c4cSmrg# Echo version message to standard output and exit. 21665b16253fSmrg# The version message is extracted from the calling file's header 21675b16253fSmrg# comments, with leading '# ' stripped: 21685b16253fSmrg# 1. First display the progname and version 21695b16253fSmrg# 2. Followed by the header comment line matching /^# Written by / 21705b16253fSmrg# 3. Then a blank line followed by the first following line matching 21715b16253fSmrg# /^# Copyright / 21725b16253fSmrg# 4. Immediately followed by any lines between the previous matches, 21735b16253fSmrg# except lines preceding the intervening completely blank line. 21745b16253fSmrg# For example, see the header comments of this file. 21755ec34c4cSmrgfunc_version () 21765ec34c4cSmrg{ 21775ec34c4cSmrg $debug_cmd 2178ab902922Smrg 21795ec34c4cSmrg printf '%s\n' "$progname $scriptversion" 21805ec34c4cSmrg $SED -n ' 21815b16253fSmrg /^# Written by /!b 21825b16253fSmrg s|^# ||; p; n 21835b16253fSmrg 21845b16253fSmrg :fwd2blnk 21855b16253fSmrg /./ { 21865b16253fSmrg n 21875b16253fSmrg b fwd2blnk 21885ec34c4cSmrg } 21895b16253fSmrg p; n 21905b16253fSmrg 21915b16253fSmrg :holdwrnt 21925b16253fSmrg s|^# || 21935b16253fSmrg s|^# *$|| 21945b16253fSmrg /^Copyright /!{ 21955b16253fSmrg /./H 21965b16253fSmrg n 21975b16253fSmrg b holdwrnt 21985ec34c4cSmrg } 21995b16253fSmrg 22005b16253fSmrg s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2| 22015b16253fSmrg G 22025b16253fSmrg s|\(\n\)\n*|\1|g 22035b16253fSmrg p; q' < "$progpath" 2204775e7de9Smrg 22055ec34c4cSmrg exit $? 22065ec34c4cSmrg} 22077a84e134Smrg 2208994689c1Smrg 22095ec34c4cSmrg# Local variables: 22105ec34c4cSmrg# mode: shell-script 22115ec34c4cSmrg# sh-indentation: 2 22125ec34c4cSmrg# eval: (add-hook 'before-save-hook 'time-stamp) 22135b16253fSmrg# time-stamp-pattern: "30/scriptversion=%:y-%02m-%02d.%02H; # UTC" 22145ec34c4cSmrg# time-stamp-time-zone: "UTC" 22155ec34c4cSmrg# End: 2216994689c1Smrg 22175ec34c4cSmrg# Set a version string. 22185b16253fSmrgscriptversion='(GNU libtool) 2.4.7' 2219994689c1Smrg 2220994689c1Smrg 22215ec34c4cSmrg# func_echo ARG... 22225ec34c4cSmrg# ---------------- 22235ec34c4cSmrg# Libtool also displays the current mode in messages, so override 22245ec34c4cSmrg# funclib.sh func_echo with this custom definition. 22255ec34c4cSmrgfunc_echo () 2226f353fbadSmrg{ 22275ec34c4cSmrg $debug_cmd 2228f353fbadSmrg 22295ec34c4cSmrg _G_message=$* 2230f353fbadSmrg 22315ec34c4cSmrg func_echo_IFS=$IFS 22325ec34c4cSmrg IFS=$nl 22335ec34c4cSmrg for _G_line in $_G_message; do 22345ec34c4cSmrg IFS=$func_echo_IFS 22355ec34c4cSmrg $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line" 22365ec34c4cSmrg done 22375ec34c4cSmrg IFS=$func_echo_IFS 22385ec34c4cSmrg} 2239f353fbadSmrg 22405ec34c4cSmrg 22415ec34c4cSmrg# func_warning ARG... 22425ec34c4cSmrg# ------------------- 22435ec34c4cSmrg# Libtool warnings are not categorized, so override funclib.sh 22445ec34c4cSmrg# func_warning with this simpler definition. 22455ec34c4cSmrgfunc_warning () 2246f353fbadSmrg{ 22475ec34c4cSmrg $debug_cmd 2248f353fbadSmrg 22495ec34c4cSmrg $warning_func ${1+"$@"} 22505ec34c4cSmrg} 2251f353fbadSmrg 2252f353fbadSmrg 22535ec34c4cSmrg## ---------------- ## 22545ec34c4cSmrg## Options parsing. ## 22555ec34c4cSmrg## ---------------- ## 22565ec34c4cSmrg 22575ec34c4cSmrg# Hook in the functions to make sure our own options are parsed during 22585ec34c4cSmrg# the option parsing loop. 22595ec34c4cSmrg 22605ec34c4cSmrgusage='$progpath [OPTION]... [MODE-ARG]...' 22615ec34c4cSmrg 22625ec34c4cSmrg# Short help message in response to '-h'. 22635ec34c4cSmrgusage_message="Options: 22645ec34c4cSmrg --config show all configuration variables 22655ec34c4cSmrg --debug enable verbose shell tracing 22665ec34c4cSmrg -n, --dry-run display commands without modifying any files 22675ec34c4cSmrg --features display basic configuration information and exit 22685ec34c4cSmrg --mode=MODE use operation mode MODE 22695ec34c4cSmrg --no-warnings equivalent to '-Wnone' 22705ec34c4cSmrg --preserve-dup-deps don't remove duplicate dependency libraries 22715ec34c4cSmrg --quiet, --silent don't print informational messages 22725ec34c4cSmrg --tag=TAG use configuration variables from tag TAG 22735ec34c4cSmrg -v, --verbose print more informational messages than default 22745ec34c4cSmrg --version print version information 22755ec34c4cSmrg -W, --warnings=CATEGORY report the warnings falling in CATEGORY [all] 22765ec34c4cSmrg -h, --help, --help-all print short, long, or detailed help message 22775ec34c4cSmrg" 2278f353fbadSmrg 22795ec34c4cSmrg# Additional text appended to 'usage_message' in response to '--help'. 22805ec34c4cSmrgfunc_help () 2281f353fbadSmrg{ 22825ec34c4cSmrg $debug_cmd 22835ec34c4cSmrg 22845ec34c4cSmrg func_usage_message 22855ec34c4cSmrg $ECHO "$long_help_message 22865ec34c4cSmrg 22875ec34c4cSmrgMODE must be one of the following: 22885ec34c4cSmrg 22895ec34c4cSmrg clean remove files from the build directory 22905ec34c4cSmrg compile compile a source file into a libtool object 22915ec34c4cSmrg execute automatically set library path, then run a program 22925ec34c4cSmrg finish complete the installation of libtool libraries 22935ec34c4cSmrg install install libraries or executables 22945ec34c4cSmrg link create a library or an executable 22955ec34c4cSmrg uninstall remove libraries from an installed directory 22965ec34c4cSmrg 22975ec34c4cSmrgMODE-ARGS vary depending on the MODE. When passed as first option, 22985ec34c4cSmrg'--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that. 22995ec34c4cSmrgTry '$progname --help --mode=MODE' for a more detailed description of MODE. 23005ec34c4cSmrg 23015ec34c4cSmrgWhen reporting a bug, please describe a test case to reproduce it and 23025ec34c4cSmrginclude the following information: 23035ec34c4cSmrg 23045ec34c4cSmrg host-triplet: $host 23055ec34c4cSmrg shell: $SHELL 23065ec34c4cSmrg compiler: $LTCC 23075ec34c4cSmrg compiler flags: $LTCFLAGS 23085ec34c4cSmrg linker: $LD (gnu? $with_gnu_ld) 23095b16253fSmrg version: $progname (GNU libtool) 2.4.7 23105ec34c4cSmrg automake: `($AUTOMAKE --version) 2>/dev/null |$SED 1q` 23115ec34c4cSmrg autoconf: `($AUTOCONF --version) 2>/dev/null |$SED 1q` 23125ec34c4cSmrg 23135ec34c4cSmrgReport bugs to <bug-libtool@gnu.org>. 23145ec34c4cSmrgGNU libtool home page: <http://www.gnu.org/software/libtool/>. 23155ec34c4cSmrgGeneral help using GNU software: <http://www.gnu.org/gethelp/>." 23165ec34c4cSmrg exit 0 23175ec34c4cSmrg} 2318f353fbadSmrg 2319f353fbadSmrg 23205ec34c4cSmrg# func_lo2o OBJECT-NAME 23215ec34c4cSmrg# --------------------- 23225ec34c4cSmrg# Transform OBJECT-NAME from a '.lo' suffix to the platform specific 23235ec34c4cSmrg# object suffix. 23245ec34c4cSmrg 23255ec34c4cSmrglo2o=s/\\.lo\$/.$objext/ 23265ec34c4cSmrgo2lo=s/\\.$objext\$/.lo/ 23275ec34c4cSmrg 23285ec34c4cSmrgif test yes = "$_G_HAVE_XSI_OPS"; then 23295ec34c4cSmrg eval 'func_lo2o () 23305ec34c4cSmrg { 23315ec34c4cSmrg case $1 in 23325ec34c4cSmrg *.lo) func_lo2o_result=${1%.lo}.$objext ;; 23335ec34c4cSmrg * ) func_lo2o_result=$1 ;; 23345ec34c4cSmrg esac 23355ec34c4cSmrg }' 23365ec34c4cSmrg 23375ec34c4cSmrg # func_xform LIBOBJ-OR-SOURCE 23385ec34c4cSmrg # --------------------------- 23395ec34c4cSmrg # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise) 23405ec34c4cSmrg # suffix to a '.lo' libtool-object suffix. 23415ec34c4cSmrg eval 'func_xform () 23425ec34c4cSmrg { 23435ec34c4cSmrg func_xform_result=${1%.*}.lo 23445ec34c4cSmrg }' 23455ec34c4cSmrgelse 23465ec34c4cSmrg # ...otherwise fall back to using sed. 23475ec34c4cSmrg func_lo2o () 23485ec34c4cSmrg { 23495ec34c4cSmrg func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"` 23505ec34c4cSmrg } 23515ec34c4cSmrg 23525ec34c4cSmrg func_xform () 23535ec34c4cSmrg { 23545ec34c4cSmrg func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'` 23555ec34c4cSmrg } 23565ec34c4cSmrgfi 2357f353fbadSmrg 2358f353fbadSmrg 23595ec34c4cSmrg# func_fatal_configuration ARG... 23605ec34c4cSmrg# ------------------------------- 2361994689c1Smrg# Echo program name prefixed message to standard error, followed by 2362994689c1Smrg# a configuration failure hint, and exit. 2363994689c1Smrgfunc_fatal_configuration () 2364994689c1Smrg{ 23655b16253fSmrg func_fatal_error ${1+"$@"} \ 23665ec34c4cSmrg "See the $PACKAGE documentation for more information." \ 23675ec34c4cSmrg "Fatal configuration error." 2368994689c1Smrg} 2369994689c1Smrg 2370994689c1Smrg 2371994689c1Smrg# func_config 23725ec34c4cSmrg# ----------- 2373994689c1Smrg# Display the configuration for all the tags in this script. 2374994689c1Smrgfunc_config () 2375994689c1Smrg{ 2376994689c1Smrg re_begincf='^# ### BEGIN LIBTOOL' 2377994689c1Smrg re_endcf='^# ### END LIBTOOL' 2378994689c1Smrg 2379994689c1Smrg # Default configuration. 2380994689c1Smrg $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" 2381994689c1Smrg 23827a84e134Smrg # Now print the configurations for the tags. 23837a84e134Smrg for tagname in $taglist; do 2384994689c1Smrg $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" 23857a84e134Smrg done 2386e1e1713cSmrg 2387994689c1Smrg exit $? 2388994689c1Smrg} 2389e1e1713cSmrg 23905ec34c4cSmrg 2391994689c1Smrg# func_features 23925ec34c4cSmrg# ------------- 2393994689c1Smrg# Display the features supported by this script. 2394994689c1Smrgfunc_features () 2395994689c1Smrg{ 2396994689c1Smrg echo "host: $host" 23975ec34c4cSmrg if test yes = "$build_libtool_libs"; then 2398994689c1Smrg echo "enable shared libraries" 23997a84e134Smrg else 2400994689c1Smrg echo "disable shared libraries" 24017a84e134Smrg fi 24025ec34c4cSmrg if test yes = "$build_old_libs"; then 2403994689c1Smrg echo "enable static libraries" 24047a84e134Smrg else 2405994689c1Smrg echo "disable static libraries" 24067a84e134Smrg fi 2407994689c1Smrg 24087a84e134Smrg exit $? 2409994689c1Smrg} 24107a84e134Smrg 24115ec34c4cSmrg 24125ec34c4cSmrg# func_enable_tag TAGNAME 24135ec34c4cSmrg# ----------------------- 2414994689c1Smrg# Verify that TAGNAME is valid, and either flag an error and exit, or 2415994689c1Smrg# enable the TAGNAME tag. We also add TAGNAME to the global $taglist 2416994689c1Smrg# variable here. 2417994689c1Smrgfunc_enable_tag () 2418994689c1Smrg{ 24195ec34c4cSmrg # Global variable: 24205ec34c4cSmrg tagname=$1 24217a84e134Smrg 24225ec34c4cSmrg re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" 24235ec34c4cSmrg re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" 24245ec34c4cSmrg sed_extractcf=/$re_begincf/,/$re_endcf/p 2425775e7de9Smrg 24265ec34c4cSmrg # Validate tagname. 24275ec34c4cSmrg case $tagname in 24285ec34c4cSmrg *[!-_A-Za-z0-9,/]*) 24295ec34c4cSmrg func_fatal_error "invalid tag name: $tagname" 24305ec34c4cSmrg ;; 24315ec34c4cSmrg esac 24327a84e134Smrg 24335ec34c4cSmrg # Don't test for the "default" C tag, as we know it's 24345ec34c4cSmrg # there but not specially marked. 24355ec34c4cSmrg case $tagname in 24365ec34c4cSmrg CC) ;; 2437994689c1Smrg *) 24385ec34c4cSmrg if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then 24395ec34c4cSmrg taglist="$taglist $tagname" 24405ec34c4cSmrg 24415ec34c4cSmrg # Evaluate the configuration. Be careful to quote the path 24425ec34c4cSmrg # and the sed script, to avoid splitting on whitespace, but 24435ec34c4cSmrg # also don't use non-portable quotes within backquotes within 24445ec34c4cSmrg # quotes we have to do it in 2 steps: 24455ec34c4cSmrg extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` 24465ec34c4cSmrg eval "$extractedcf" 24475ec34c4cSmrg else 24485ec34c4cSmrg func_error "ignoring unknown tag $tagname" 24495ec34c4cSmrg fi 24505ec34c4cSmrg ;; 24515ec34c4cSmrg esac 2452994689c1Smrg} 2453994689c1Smrg 24545ec34c4cSmrg 2455f353fbadSmrg# func_check_version_match 24565ec34c4cSmrg# ------------------------ 2457f353fbadSmrg# Ensure that we are using m4 macros, and libtool script from the same 2458f353fbadSmrg# release of libtool. 2459f353fbadSmrgfunc_check_version_match () 2460994689c1Smrg{ 24615ec34c4cSmrg if test "$package_revision" != "$macro_revision"; then 24625ec34c4cSmrg if test "$VERSION" != "$macro_version"; then 24635ec34c4cSmrg if test -z "$macro_version"; then 24645ec34c4cSmrg cat >&2 <<_LT_EOF 2465f353fbadSmrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 2466f353fbadSmrg$progname: definition of this LT_INIT comes from an older release. 2467f353fbadSmrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 2468f353fbadSmrg$progname: and run autoconf again. 2469f353fbadSmrg_LT_EOF 24705ec34c4cSmrg else 24715ec34c4cSmrg cat >&2 <<_LT_EOF 2472f353fbadSmrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 2473f353fbadSmrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version. 2474f353fbadSmrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 2475f353fbadSmrg$progname: and run autoconf again. 2476f353fbadSmrg_LT_EOF 24775ec34c4cSmrg fi 24785ec34c4cSmrg else 24795ec34c4cSmrg cat >&2 <<_LT_EOF 2480f353fbadSmrg$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, 2481f353fbadSmrg$progname: but the definition of this LT_INIT comes from revision $macro_revision. 2482f353fbadSmrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision 2483f353fbadSmrg$progname: of $PACKAGE $VERSION and run autoconf again. 2484f353fbadSmrg_LT_EOF 24855ec34c4cSmrg fi 2486e1e1713cSmrg 24875ec34c4cSmrg exit $EXIT_MISMATCH 24885ec34c4cSmrg fi 2489f353fbadSmrg} 2490f353fbadSmrg 2491f353fbadSmrg 24925ec34c4cSmrg# libtool_options_prep [ARG]... 24935ec34c4cSmrg# ----------------------------- 24945ec34c4cSmrg# Preparation for options parsed by libtool. 24955ec34c4cSmrglibtool_options_prep () 24965ec34c4cSmrg{ 24975ec34c4cSmrg $debug_mode 24987a84e134Smrg 24995ec34c4cSmrg # Option defaults: 25005ec34c4cSmrg opt_config=false 25015ec34c4cSmrg opt_dlopen= 25025ec34c4cSmrg opt_dry_run=false 25035ec34c4cSmrg opt_help=false 25045ec34c4cSmrg opt_mode= 25055ec34c4cSmrg opt_preserve_dup_deps=false 25065ec34c4cSmrg opt_quiet=false 2507f353fbadSmrg 25085ec34c4cSmrg nonopt= 25095ec34c4cSmrg preserve_args= 2510f353fbadSmrg 25115b16253fSmrg _G_rc_lt_options_prep=: 25125b16253fSmrg 25135ec34c4cSmrg # Shorthand for --mode=foo, only valid as the first argument 25145ec34c4cSmrg case $1 in 25155ec34c4cSmrg clean|clea|cle|cl) 25165ec34c4cSmrg shift; set dummy --mode clean ${1+"$@"}; shift 25175ec34c4cSmrg ;; 25185ec34c4cSmrg compile|compil|compi|comp|com|co|c) 25195ec34c4cSmrg shift; set dummy --mode compile ${1+"$@"}; shift 25205ec34c4cSmrg ;; 25215ec34c4cSmrg execute|execut|execu|exec|exe|ex|e) 25225ec34c4cSmrg shift; set dummy --mode execute ${1+"$@"}; shift 25235ec34c4cSmrg ;; 25245ec34c4cSmrg finish|finis|fini|fin|fi|f) 25255ec34c4cSmrg shift; set dummy --mode finish ${1+"$@"}; shift 25265ec34c4cSmrg ;; 25275ec34c4cSmrg install|instal|insta|inst|ins|in|i) 25285ec34c4cSmrg shift; set dummy --mode install ${1+"$@"}; shift 25295ec34c4cSmrg ;; 25305ec34c4cSmrg link|lin|li|l) 25315ec34c4cSmrg shift; set dummy --mode link ${1+"$@"}; shift 25325ec34c4cSmrg ;; 25335ec34c4cSmrg uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) 25345ec34c4cSmrg shift; set dummy --mode uninstall ${1+"$@"}; shift 25355ec34c4cSmrg ;; 25365b16253fSmrg *) 25375b16253fSmrg _G_rc_lt_options_prep=false 25385b16253fSmrg ;; 25395ec34c4cSmrg esac 25405ec34c4cSmrg 25415b16253fSmrg if $_G_rc_lt_options_prep; then 25425b16253fSmrg # Pass back the list of options. 25435b16253fSmrg func_quote eval ${1+"$@"} 25445b16253fSmrg libtool_options_prep_result=$func_quote_result 25455b16253fSmrg fi 25465ec34c4cSmrg} 25475ec34c4cSmrgfunc_add_hook func_options_prep libtool_options_prep 2548f353fbadSmrg 2549f353fbadSmrg 25505ec34c4cSmrg# libtool_parse_options [ARG]... 25515ec34c4cSmrg# --------------------------------- 25525ec34c4cSmrg# Provide handling for libtool specific options. 25535ec34c4cSmrglibtool_parse_options () 2554f353fbadSmrg{ 25555ec34c4cSmrg $debug_cmd 2556994689c1Smrg 25575b16253fSmrg _G_rc_lt_parse_options=false 25585b16253fSmrg 25595ec34c4cSmrg # Perform our own loop to consume as many options as possible in 25605ec34c4cSmrg # each iteration. 25615ec34c4cSmrg while test $# -gt 0; do 25625b16253fSmrg _G_match_lt_parse_options=: 25635ec34c4cSmrg _G_opt=$1 25645ec34c4cSmrg shift 25655ec34c4cSmrg case $_G_opt in 25665ec34c4cSmrg --dry-run|--dryrun|-n) 25675ec34c4cSmrg opt_dry_run=: 25685ec34c4cSmrg ;; 25695ec34c4cSmrg 25705ec34c4cSmrg --config) func_config ;; 25715ec34c4cSmrg 25725ec34c4cSmrg --dlopen|-dlopen) 25735ec34c4cSmrg opt_dlopen="${opt_dlopen+$opt_dlopen 25745ec34c4cSmrg}$1" 25755ec34c4cSmrg shift 25765ec34c4cSmrg ;; 25775ec34c4cSmrg 25785ec34c4cSmrg --preserve-dup-deps) 25795ec34c4cSmrg opt_preserve_dup_deps=: ;; 25805ec34c4cSmrg 25815ec34c4cSmrg --features) func_features ;; 25825ec34c4cSmrg 25835ec34c4cSmrg --finish) set dummy --mode finish ${1+"$@"}; shift ;; 25845ec34c4cSmrg 25855ec34c4cSmrg --help) opt_help=: ;; 25865ec34c4cSmrg 25875ec34c4cSmrg --help-all) opt_help=': help-all' ;; 25885ec34c4cSmrg 25895ec34c4cSmrg --mode) test $# = 0 && func_missing_arg $_G_opt && break 25905ec34c4cSmrg opt_mode=$1 25915ec34c4cSmrg case $1 in 25925ec34c4cSmrg # Valid mode arguments: 25935ec34c4cSmrg clean|compile|execute|finish|install|link|relink|uninstall) ;; 25945ec34c4cSmrg 25955ec34c4cSmrg # Catch anything else as an error 25965ec34c4cSmrg *) func_error "invalid argument for $_G_opt" 25975ec34c4cSmrg exit_cmd=exit 25985ec34c4cSmrg break 25995ec34c4cSmrg ;; 26005ec34c4cSmrg esac 26015ec34c4cSmrg shift 26025ec34c4cSmrg ;; 26035ec34c4cSmrg 26045ec34c4cSmrg --no-silent|--no-quiet) 26055ec34c4cSmrg opt_quiet=false 26065ec34c4cSmrg func_append preserve_args " $_G_opt" 26075ec34c4cSmrg ;; 26085ec34c4cSmrg 26095ec34c4cSmrg --no-warnings|--no-warning|--no-warn) 26105ec34c4cSmrg opt_warning=false 26115ec34c4cSmrg func_append preserve_args " $_G_opt" 26125ec34c4cSmrg ;; 26135ec34c4cSmrg 26145ec34c4cSmrg --no-verbose) 26155ec34c4cSmrg opt_verbose=false 26165ec34c4cSmrg func_append preserve_args " $_G_opt" 26175ec34c4cSmrg ;; 26185ec34c4cSmrg 26195ec34c4cSmrg --silent|--quiet) 26205ec34c4cSmrg opt_quiet=: 26215ec34c4cSmrg opt_verbose=false 26225ec34c4cSmrg func_append preserve_args " $_G_opt" 26235ec34c4cSmrg ;; 26245ec34c4cSmrg 26255ec34c4cSmrg --tag) test $# = 0 && func_missing_arg $_G_opt && break 26265ec34c4cSmrg opt_tag=$1 26275ec34c4cSmrg func_append preserve_args " $_G_opt $1" 26285ec34c4cSmrg func_enable_tag "$1" 26295ec34c4cSmrg shift 26305ec34c4cSmrg ;; 26315ec34c4cSmrg 26325ec34c4cSmrg --verbose|-v) opt_quiet=false 26335ec34c4cSmrg opt_verbose=: 26345ec34c4cSmrg func_append preserve_args " $_G_opt" 26355ec34c4cSmrg ;; 26365ec34c4cSmrg 26375b16253fSmrg # An option not handled by this hook function: 26385b16253fSmrg *) set dummy "$_G_opt" ${1+"$@"} ; shift 26395b16253fSmrg _G_match_lt_parse_options=false 26405b16253fSmrg break 26415b16253fSmrg ;; 26425ec34c4cSmrg esac 26435b16253fSmrg $_G_match_lt_parse_options && _G_rc_lt_parse_options=: 26445ec34c4cSmrg done 2645f353fbadSmrg 26465b16253fSmrg if $_G_rc_lt_parse_options; then 26475b16253fSmrg # save modified positional parameters for caller 26485b16253fSmrg func_quote eval ${1+"$@"} 26495b16253fSmrg libtool_parse_options_result=$func_quote_result 26505b16253fSmrg fi 26515ec34c4cSmrg} 26525ec34c4cSmrgfunc_add_hook func_parse_options libtool_parse_options 2653994689c1Smrg 2654775e7de9Smrg 2655994689c1Smrg 26565ec34c4cSmrg# libtool_validate_options [ARG]... 26575ec34c4cSmrg# --------------------------------- 26585ec34c4cSmrg# Perform any sanity checks on option settings and/or unconsumed 26595ec34c4cSmrg# arguments. 26605ec34c4cSmrglibtool_validate_options () 26615ec34c4cSmrg{ 26625ec34c4cSmrg # save first non-option argument 26635ec34c4cSmrg if test 0 -lt $#; then 26645ec34c4cSmrg nonopt=$1 26655ec34c4cSmrg shift 2666994689c1Smrg fi 2667994689c1Smrg 26685ec34c4cSmrg # preserve --debug 26695ec34c4cSmrg test : = "$debug_cmd" || func_append preserve_args " --debug" 2670994689c1Smrg 26715ec34c4cSmrg case $host in 26725ec34c4cSmrg # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452 26735ec34c4cSmrg # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788 26745ec34c4cSmrg *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*) 26755ec34c4cSmrg # don't eliminate duplications in $postdeps and $predeps 26765ec34c4cSmrg opt_duplicate_compiler_generated_deps=: 26775ec34c4cSmrg ;; 26785ec34c4cSmrg *) 26795ec34c4cSmrg opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps 26805ec34c4cSmrg ;; 26815ec34c4cSmrg esac 2682994689c1Smrg 26835ec34c4cSmrg $opt_help || { 26845ec34c4cSmrg # Sanity checks first: 26855ec34c4cSmrg func_check_version_match 26865ec34c4cSmrg 26875ec34c4cSmrg test yes != "$build_libtool_libs" \ 26885ec34c4cSmrg && test yes != "$build_old_libs" \ 26895ec34c4cSmrg && func_fatal_configuration "not configured to build any kind of library" 26905ec34c4cSmrg 26915ec34c4cSmrg # Darwin sucks 26925ec34c4cSmrg eval std_shrext=\"$shrext_cmds\" 26935ec34c4cSmrg 26945ec34c4cSmrg # Only execute mode is allowed to have -dlopen flags. 26955ec34c4cSmrg if test -n "$opt_dlopen" && test execute != "$opt_mode"; then 26965ec34c4cSmrg func_error "unrecognized option '-dlopen'" 26975ec34c4cSmrg $ECHO "$help" 1>&2 26985ec34c4cSmrg exit $EXIT_FAILURE 26995ec34c4cSmrg fi 2700994689c1Smrg 27015ec34c4cSmrg # Change the help message to a mode-specific one. 27025ec34c4cSmrg generic_help=$help 27035ec34c4cSmrg help="Try '$progname --help --mode=$opt_mode' for more information." 27045ec34c4cSmrg } 2705994689c1Smrg 27065ec34c4cSmrg # Pass back the unparsed argument list 27075b16253fSmrg func_quote eval ${1+"$@"} 27085b16253fSmrg libtool_validate_options_result=$func_quote_result 2709f353fbadSmrg} 27105ec34c4cSmrgfunc_add_hook func_validate_options libtool_validate_options 2711994689c1Smrg 2712994689c1Smrg 27135ec34c4cSmrg# Process options as early as possible so that --help and --version 27145ec34c4cSmrg# can return quickly. 27155ec34c4cSmrgfunc_options ${1+"$@"} 27165ec34c4cSmrgeval set dummy "$func_options_result"; shift 27175ec34c4cSmrg 27187a84e134Smrg 27197a84e134Smrg 2720f353fbadSmrg## ----------- ## 2721f353fbadSmrg## Main. ## 2722f353fbadSmrg## ----------- ## 27237a84e134Smrg 27245ec34c4cSmrgmagic='%%%MAGIC variable%%%' 27255ec34c4cSmrgmagic_exe='%%%MAGIC EXE variable%%%' 27265ec34c4cSmrg 27275ec34c4cSmrg# Global variables. 27285ec34c4cSmrgextracted_archives= 27295ec34c4cSmrgextracted_serial=0 27305ec34c4cSmrg 27315ec34c4cSmrg# If this variable is set in any of the actions, the command in it 27325ec34c4cSmrg# will be execed at the end. This prevents here-documents from being 27335ec34c4cSmrg# left over by shells. 27345ec34c4cSmrgexec_cmd= 27355ec34c4cSmrg 27365ec34c4cSmrg 27375ec34c4cSmrg# A function that is used when there is no print builtin or printf. 27385ec34c4cSmrgfunc_fallback_echo () 27395ec34c4cSmrg{ 27405ec34c4cSmrg eval 'cat <<_LTECHO_EOF 27415ec34c4cSmrg$1 27425ec34c4cSmrg_LTECHO_EOF' 27435ec34c4cSmrg} 27445ec34c4cSmrg 27455ec34c4cSmrg# func_generated_by_libtool 27465ec34c4cSmrg# True iff stdin has been generated by Libtool. This function is only 27475ec34c4cSmrg# a basic sanity check; it will hardly flush out determined imposters. 27485ec34c4cSmrgfunc_generated_by_libtool_p () 27495ec34c4cSmrg{ 27505ec34c4cSmrg $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 27515ec34c4cSmrg} 27525ec34c4cSmrg 2753994689c1Smrg# func_lalib_p file 27545ec34c4cSmrg# True iff FILE is a libtool '.la' library or '.lo' object file. 2755994689c1Smrg# This function is only a basic sanity check; it will hardly flush out 2756994689c1Smrg# determined imposters. 2757994689c1Smrgfunc_lalib_p () 2758994689c1Smrg{ 2759994689c1Smrg test -f "$1" && 27605ec34c4cSmrg $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p 2761994689c1Smrg} 27627a84e134Smrg 2763994689c1Smrg# func_lalib_unsafe_p file 27645ec34c4cSmrg# True iff FILE is a libtool '.la' library or '.lo' object file. 2765994689c1Smrg# This function implements the same check as func_lalib_p without 2766994689c1Smrg# resorting to external programs. To this end, it redirects stdin and 2767994689c1Smrg# closes it afterwards, without saving the original file descriptor. 2768994689c1Smrg# As a safety measure, use it only where a negative result would be 27695ec34c4cSmrg# fatal anyway. Works if 'file' does not exist. 2770994689c1Smrgfunc_lalib_unsafe_p () 2771994689c1Smrg{ 2772994689c1Smrg lalib_p=no 2773994689c1Smrg if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then 2774994689c1Smrg for lalib_p_l in 1 2 3 4 2775994689c1Smrg do 2776994689c1Smrg read lalib_p_line 27775ec34c4cSmrg case $lalib_p_line in 2778994689c1Smrg \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; 2779994689c1Smrg esac 2780994689c1Smrg done 2781994689c1Smrg exec 0<&5 5<&- 2782994689c1Smrg fi 27835ec34c4cSmrg test yes = "$lalib_p" 2784994689c1Smrg} 27857a84e134Smrg 2786994689c1Smrg# func_ltwrapper_script_p file 2787994689c1Smrg# True iff FILE is a libtool wrapper script 2788994689c1Smrg# This function is only a basic sanity check; it will hardly flush out 2789994689c1Smrg# determined imposters. 2790994689c1Smrgfunc_ltwrapper_script_p () 2791994689c1Smrg{ 27925ec34c4cSmrg test -f "$1" && 27935ec34c4cSmrg $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p 2794994689c1Smrg} 27957a84e134Smrg 2796994689c1Smrg# func_ltwrapper_executable_p file 2797994689c1Smrg# True iff FILE is a libtool wrapper executable 2798994689c1Smrg# This function is only a basic sanity check; it will hardly flush out 2799994689c1Smrg# determined imposters. 2800994689c1Smrgfunc_ltwrapper_executable_p () 2801994689c1Smrg{ 2802994689c1Smrg func_ltwrapper_exec_suffix= 2803994689c1Smrg case $1 in 2804994689c1Smrg *.exe) ;; 2805994689c1Smrg *) func_ltwrapper_exec_suffix=.exe ;; 2806994689c1Smrg esac 2807994689c1Smrg $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 2808994689c1Smrg} 2809994689c1Smrg 2810994689c1Smrg# func_ltwrapper_scriptname file 2811994689c1Smrg# Assumes file is an ltwrapper_executable 2812994689c1Smrg# uses $file to determine the appropriate filename for a 2813994689c1Smrg# temporary ltwrapper_script. 2814994689c1Smrgfunc_ltwrapper_scriptname () 2815994689c1Smrg{ 2816f353fbadSmrg func_dirname_and_basename "$1" "" "." 2817f353fbadSmrg func_stripname '' '.exe' "$func_basename_result" 28185ec34c4cSmrg func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper 2819994689c1Smrg} 2820994689c1Smrg 2821994689c1Smrg# func_ltwrapper_p file 2822994689c1Smrg# True iff FILE is a libtool wrapper script or wrapper executable 2823994689c1Smrg# This function is only a basic sanity check; it will hardly flush out 2824994689c1Smrg# determined imposters. 2825994689c1Smrgfunc_ltwrapper_p () 2826994689c1Smrg{ 2827994689c1Smrg func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" 2828994689c1Smrg} 2829994689c1Smrg 2830994689c1Smrg 2831994689c1Smrg# func_execute_cmds commands fail_cmd 2832994689c1Smrg# Execute tilde-delimited COMMANDS. 2833994689c1Smrg# If FAIL_CMD is given, eval that upon failure. 2834994689c1Smrg# FAIL_CMD may read-access the current command in variable CMD! 2835994689c1Smrgfunc_execute_cmds () 2836994689c1Smrg{ 28375ec34c4cSmrg $debug_cmd 28385ec34c4cSmrg 2839994689c1Smrg save_ifs=$IFS; IFS='~' 2840994689c1Smrg for cmd in $1; do 28415ec34c4cSmrg IFS=$sp$nl 2842994689c1Smrg eval cmd=\"$cmd\" 28435ec34c4cSmrg IFS=$save_ifs 2844994689c1Smrg func_show_eval "$cmd" "${2-:}" 2845994689c1Smrg done 2846994689c1Smrg IFS=$save_ifs 2847994689c1Smrg} 2848994689c1Smrg 2849994689c1Smrg 2850994689c1Smrg# func_source file 2851994689c1Smrg# Source FILE, adding directory component if necessary. 2852994689c1Smrg# Note that it is not necessary on cygwin/mingw to append a dot to 2853994689c1Smrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe 2854994689c1Smrg# behavior happens only for exec(3), not for open(2)! Also, sourcing 28555ec34c4cSmrg# 'FILE.' does not work on cygwin managed mounts. 2856994689c1Smrgfunc_source () 2857994689c1Smrg{ 28585ec34c4cSmrg $debug_cmd 28595ec34c4cSmrg 2860994689c1Smrg case $1 in 2861994689c1Smrg */* | *\\*) . "$1" ;; 2862994689c1Smrg *) . "./$1" ;; 2863994689c1Smrg esac 2864994689c1Smrg} 2865994689c1Smrg 2866994689c1Smrg 2867f353fbadSmrg# func_resolve_sysroot PATH 2868f353fbadSmrg# Replace a leading = in PATH with a sysroot. Store the result into 2869f353fbadSmrg# func_resolve_sysroot_result 2870f353fbadSmrgfunc_resolve_sysroot () 2871f353fbadSmrg{ 2872f353fbadSmrg func_resolve_sysroot_result=$1 2873f353fbadSmrg case $func_resolve_sysroot_result in 2874f353fbadSmrg =*) 2875f353fbadSmrg func_stripname '=' '' "$func_resolve_sysroot_result" 2876f353fbadSmrg func_resolve_sysroot_result=$lt_sysroot$func_stripname_result 2877f353fbadSmrg ;; 2878f353fbadSmrg esac 2879f353fbadSmrg} 2880f353fbadSmrg 2881f353fbadSmrg# func_replace_sysroot PATH 2882f353fbadSmrg# If PATH begins with the sysroot, replace it with = and 2883f353fbadSmrg# store the result into func_replace_sysroot_result. 2884f353fbadSmrgfunc_replace_sysroot () 2885f353fbadSmrg{ 28865ec34c4cSmrg case $lt_sysroot:$1 in 2887f353fbadSmrg ?*:"$lt_sysroot"*) 2888f353fbadSmrg func_stripname "$lt_sysroot" '' "$1" 28895ec34c4cSmrg func_replace_sysroot_result='='$func_stripname_result 2890f353fbadSmrg ;; 2891f353fbadSmrg *) 2892f353fbadSmrg # Including no sysroot. 2893f353fbadSmrg func_replace_sysroot_result=$1 2894f353fbadSmrg ;; 2895f353fbadSmrg esac 2896f353fbadSmrg} 2897f353fbadSmrg 2898994689c1Smrg# func_infer_tag arg 2899994689c1Smrg# Infer tagged configuration to use if any are available and 2900994689c1Smrg# if one wasn't chosen via the "--tag" command line option. 2901994689c1Smrg# Only attempt this if the compiler in the base compile 2902994689c1Smrg# command doesn't match the default compiler. 2903994689c1Smrg# arg is usually of the form 'gcc ...' 2904994689c1Smrgfunc_infer_tag () 2905994689c1Smrg{ 29065ec34c4cSmrg $debug_cmd 29075ec34c4cSmrg 2908994689c1Smrg if test -n "$available_tags" && test -z "$tagname"; then 2909994689c1Smrg CC_quoted= 2910994689c1Smrg for arg in $CC; do 2911f353fbadSmrg func_append_quoted CC_quoted "$arg" 2912994689c1Smrg done 2913994689c1Smrg CC_expanded=`func_echo_all $CC` 2914994689c1Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 2915994689c1Smrg case $@ in 2916994689c1Smrg # Blanks in the command may have been stripped by the calling shell, 2917994689c1Smrg # but not from the CC environment variable when configure was run. 2918994689c1Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 2919994689c1Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; 2920994689c1Smrg # Blanks at the start of $base_compile will cause this to fail 2921994689c1Smrg # if we don't check for them as well. 2922994689c1Smrg *) 2923994689c1Smrg for z in $available_tags; do 2924994689c1Smrg if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then 2925994689c1Smrg # Evaluate the configuration. 29265ec34c4cSmrg eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" 2927994689c1Smrg CC_quoted= 2928994689c1Smrg for arg in $CC; do 2929994689c1Smrg # Double-quote args containing other shell metacharacters. 2930f353fbadSmrg func_append_quoted CC_quoted "$arg" 2931994689c1Smrg done 2932994689c1Smrg CC_expanded=`func_echo_all $CC` 2933994689c1Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 2934994689c1Smrg case "$@ " in 2935994689c1Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 2936994689c1Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) 2937994689c1Smrg # The compiler in the base compile command matches 2938994689c1Smrg # the one in the tagged configuration. 2939994689c1Smrg # Assume this is the tagged configuration we want. 2940994689c1Smrg tagname=$z 2941994689c1Smrg break 2942994689c1Smrg ;; 2943994689c1Smrg esac 2944994689c1Smrg fi 2945994689c1Smrg done 2946994689c1Smrg # If $tagname still isn't set, then no tagged configuration 2947994689c1Smrg # was found and let the user know that the "--tag" command 2948994689c1Smrg # line option must be used. 2949994689c1Smrg if test -z "$tagname"; then 2950994689c1Smrg func_echo "unable to infer tagged configuration" 29515ec34c4cSmrg func_fatal_error "specify a tag with '--tag'" 2952994689c1Smrg# else 2953994689c1Smrg# func_verbose "using $tagname tagged configuration" 2954994689c1Smrg fi 2955994689c1Smrg ;; 2956994689c1Smrg esac 2957994689c1Smrg fi 2958994689c1Smrg} 2959994689c1Smrg 2960994689c1Smrg 2961994689c1Smrg 2962f353fbadSmrg# func_write_libtool_object output_name pic_name nonpic_name 2963f353fbadSmrg# Create a libtool object file (analogous to a ".la" file), 2964f353fbadSmrg# but don't create it if we're doing a dry run. 2965f353fbadSmrgfunc_write_libtool_object () 2966f353fbadSmrg{ 29675ec34c4cSmrg write_libobj=$1 29685ec34c4cSmrg if test yes = "$build_libtool_libs"; then 29695ec34c4cSmrg write_lobj=\'$2\' 2970f353fbadSmrg else 2971f353fbadSmrg write_lobj=none 2972f353fbadSmrg fi 2973f353fbadSmrg 29745ec34c4cSmrg if test yes = "$build_old_libs"; then 29755ec34c4cSmrg write_oldobj=\'$3\' 2976f353fbadSmrg else 2977f353fbadSmrg write_oldobj=none 2978f353fbadSmrg fi 2979f353fbadSmrg 2980f353fbadSmrg $opt_dry_run || { 2981f353fbadSmrg cat >${write_libobj}T <<EOF 2982f353fbadSmrg# $write_libobj - a libtool object file 29835ec34c4cSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 2984f353fbadSmrg# 2985f353fbadSmrg# Please DO NOT delete this file! 2986f353fbadSmrg# It is necessary for linking the library. 2987f353fbadSmrg 2988f353fbadSmrg# Name of the PIC object. 2989f353fbadSmrgpic_object=$write_lobj 2990f353fbadSmrg 2991f353fbadSmrg# Name of the non-PIC object 2992f353fbadSmrgnon_pic_object=$write_oldobj 2993f353fbadSmrg 2994f353fbadSmrgEOF 29955ec34c4cSmrg $MV "${write_libobj}T" "$write_libobj" 2996f353fbadSmrg } 2997f353fbadSmrg} 2998f353fbadSmrg 2999f353fbadSmrg 3000f353fbadSmrg################################################## 3001f353fbadSmrg# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS # 3002f353fbadSmrg################################################## 3003f353fbadSmrg 3004f353fbadSmrg# func_convert_core_file_wine_to_w32 ARG 3005f353fbadSmrg# Helper function used by file name conversion functions when $build is *nix, 3006f353fbadSmrg# and $host is mingw, cygwin, or some other w32 environment. Relies on a 3007f353fbadSmrg# correctly configured wine environment available, with the winepath program 3008f353fbadSmrg# in $build's $PATH. 3009f353fbadSmrg# 3010f353fbadSmrg# ARG is the $build file name to be converted to w32 format. 3011f353fbadSmrg# Result is available in $func_convert_core_file_wine_to_w32_result, and will 3012f353fbadSmrg# be empty on error (or when ARG is empty) 3013f353fbadSmrgfunc_convert_core_file_wine_to_w32 () 3014f353fbadSmrg{ 30155ec34c4cSmrg $debug_cmd 30165ec34c4cSmrg 30175ec34c4cSmrg func_convert_core_file_wine_to_w32_result=$1 3018f353fbadSmrg if test -n "$1"; then 3019f353fbadSmrg # Unfortunately, winepath does not exit with a non-zero error code, so we 3020f353fbadSmrg # are forced to check the contents of stdout. On the other hand, if the 3021f353fbadSmrg # command is not found, the shell will set an exit code of 127 and print 3022f353fbadSmrg # *an error message* to stdout. So we must check for both error code of 3023f353fbadSmrg # zero AND non-empty stdout, which explains the odd construction: 3024f353fbadSmrg func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null` 30255ec34c4cSmrg if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then 3026f353fbadSmrg func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | 30275ec34c4cSmrg $SED -e "$sed_naive_backslashify"` 3028f353fbadSmrg else 3029f353fbadSmrg func_convert_core_file_wine_to_w32_result= 3030f353fbadSmrg fi 3031f353fbadSmrg fi 3032f353fbadSmrg} 3033f353fbadSmrg# end: func_convert_core_file_wine_to_w32 3034f353fbadSmrg 3035f353fbadSmrg 3036f353fbadSmrg# func_convert_core_path_wine_to_w32 ARG 3037f353fbadSmrg# Helper function used by path conversion functions when $build is *nix, and 3038f353fbadSmrg# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly 3039f353fbadSmrg# configured wine environment available, with the winepath program in $build's 3040f353fbadSmrg# $PATH. Assumes ARG has no leading or trailing path separator characters. 3041f353fbadSmrg# 3042f353fbadSmrg# ARG is path to be converted from $build format to win32. 3043f353fbadSmrg# Result is available in $func_convert_core_path_wine_to_w32_result. 3044f353fbadSmrg# Unconvertible file (directory) names in ARG are skipped; if no directory names 3045f353fbadSmrg# are convertible, then the result may be empty. 3046f353fbadSmrgfunc_convert_core_path_wine_to_w32 () 3047f353fbadSmrg{ 30485ec34c4cSmrg $debug_cmd 30495ec34c4cSmrg 3050f353fbadSmrg # unfortunately, winepath doesn't convert paths, only file names 30515ec34c4cSmrg func_convert_core_path_wine_to_w32_result= 3052f353fbadSmrg if test -n "$1"; then 3053f353fbadSmrg oldIFS=$IFS 3054f353fbadSmrg IFS=: 3055f353fbadSmrg for func_convert_core_path_wine_to_w32_f in $1; do 3056f353fbadSmrg IFS=$oldIFS 3057f353fbadSmrg func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" 30585ec34c4cSmrg if test -n "$func_convert_core_file_wine_to_w32_result"; then 3059f353fbadSmrg if test -z "$func_convert_core_path_wine_to_w32_result"; then 30605ec34c4cSmrg func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result 3061f353fbadSmrg else 3062f353fbadSmrg func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" 3063f353fbadSmrg fi 3064f353fbadSmrg fi 3065f353fbadSmrg done 3066f353fbadSmrg IFS=$oldIFS 3067f353fbadSmrg fi 3068f353fbadSmrg} 3069f353fbadSmrg# end: func_convert_core_path_wine_to_w32 3070f353fbadSmrg 3071f353fbadSmrg 3072f353fbadSmrg# func_cygpath ARGS... 3073f353fbadSmrg# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when 3074f353fbadSmrg# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) 3075f353fbadSmrg# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or 3076f353fbadSmrg# (2), returns the Cygwin file name or path in func_cygpath_result (input 3077f353fbadSmrg# file name or path is assumed to be in w32 format, as previously converted 3078f353fbadSmrg# from $build's *nix or MSYS format). In case (3), returns the w32 file name 3079f353fbadSmrg# or path in func_cygpath_result (input file name or path is assumed to be in 3080f353fbadSmrg# Cygwin format). Returns an empty string on error. 3081f353fbadSmrg# 3082f353fbadSmrg# ARGS are passed to cygpath, with the last one being the file name or path to 3083f353fbadSmrg# be converted. 3084f353fbadSmrg# 3085f353fbadSmrg# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH 3086f353fbadSmrg# environment variable; do not put it in $PATH. 3087f353fbadSmrgfunc_cygpath () 3088f353fbadSmrg{ 30895ec34c4cSmrg $debug_cmd 30905ec34c4cSmrg 3091f353fbadSmrg if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then 3092f353fbadSmrg func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` 3093f353fbadSmrg if test "$?" -ne 0; then 3094f353fbadSmrg # on failure, ensure result is empty 3095f353fbadSmrg func_cygpath_result= 3096f353fbadSmrg fi 3097f353fbadSmrg else 3098f353fbadSmrg func_cygpath_result= 30995ec34c4cSmrg func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'" 3100f353fbadSmrg fi 3101f353fbadSmrg} 3102f353fbadSmrg#end: func_cygpath 3103f353fbadSmrg 3104f353fbadSmrg 3105f353fbadSmrg# func_convert_core_msys_to_w32 ARG 3106f353fbadSmrg# Convert file name or path ARG from MSYS format to w32 format. Return 3107f353fbadSmrg# result in func_convert_core_msys_to_w32_result. 3108f353fbadSmrgfunc_convert_core_msys_to_w32 () 3109f353fbadSmrg{ 31105ec34c4cSmrg $debug_cmd 31115ec34c4cSmrg 3112f353fbadSmrg # awkward: cmd appends spaces to result 3113f353fbadSmrg func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | 31145ec34c4cSmrg $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"` 3115f353fbadSmrg} 3116f353fbadSmrg#end: func_convert_core_msys_to_w32 3117f353fbadSmrg 3118f353fbadSmrg 3119f353fbadSmrg# func_convert_file_check ARG1 ARG2 3120f353fbadSmrg# Verify that ARG1 (a file name in $build format) was converted to $host 3121f353fbadSmrg# format in ARG2. Otherwise, emit an error message, but continue (resetting 3122f353fbadSmrg# func_to_host_file_result to ARG1). 3123f353fbadSmrgfunc_convert_file_check () 3124f353fbadSmrg{ 31255ec34c4cSmrg $debug_cmd 31265ec34c4cSmrg 31275ec34c4cSmrg if test -z "$2" && test -n "$1"; then 3128f353fbadSmrg func_error "Could not determine host file name corresponding to" 31295ec34c4cSmrg func_error " '$1'" 3130f353fbadSmrg func_error "Continuing, but uninstalled executables may not work." 3131f353fbadSmrg # Fallback: 31325ec34c4cSmrg func_to_host_file_result=$1 3133f353fbadSmrg fi 3134f353fbadSmrg} 3135f353fbadSmrg# end func_convert_file_check 3136f353fbadSmrg 3137f353fbadSmrg 3138f353fbadSmrg# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH 3139f353fbadSmrg# Verify that FROM_PATH (a path in $build format) was converted to $host 3140f353fbadSmrg# format in TO_PATH. Otherwise, emit an error message, but continue, resetting 3141f353fbadSmrg# func_to_host_file_result to a simplistic fallback value (see below). 3142f353fbadSmrgfunc_convert_path_check () 3143f353fbadSmrg{ 31445ec34c4cSmrg $debug_cmd 31455ec34c4cSmrg 3146f353fbadSmrg if test -z "$4" && test -n "$3"; then 3147f353fbadSmrg func_error "Could not determine the host path corresponding to" 31485ec34c4cSmrg func_error " '$3'" 3149f353fbadSmrg func_error "Continuing, but uninstalled executables may not work." 3150f353fbadSmrg # Fallback. This is a deliberately simplistic "conversion" and 3151f353fbadSmrg # should not be "improved". See libtool.info. 3152f353fbadSmrg if test "x$1" != "x$2"; then 3153f353fbadSmrg lt_replace_pathsep_chars="s|$1|$2|g" 3154f353fbadSmrg func_to_host_path_result=`echo "$3" | 3155f353fbadSmrg $SED -e "$lt_replace_pathsep_chars"` 3156f353fbadSmrg else 31575ec34c4cSmrg func_to_host_path_result=$3 3158f353fbadSmrg fi 3159f353fbadSmrg fi 3160f353fbadSmrg} 3161f353fbadSmrg# end func_convert_path_check 3162f353fbadSmrg 3163f353fbadSmrg 3164f353fbadSmrg# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG 3165f353fbadSmrg# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT 3166f353fbadSmrg# and appending REPL if ORIG matches BACKPAT. 3167f353fbadSmrgfunc_convert_path_front_back_pathsep () 3168f353fbadSmrg{ 31695ec34c4cSmrg $debug_cmd 31705ec34c4cSmrg 3171f353fbadSmrg case $4 in 31725ec34c4cSmrg $1 ) func_to_host_path_result=$3$func_to_host_path_result 3173f353fbadSmrg ;; 3174f353fbadSmrg esac 3175f353fbadSmrg case $4 in 3176f353fbadSmrg $2 ) func_append func_to_host_path_result "$3" 3177f353fbadSmrg ;; 3178f353fbadSmrg esac 3179f353fbadSmrg} 3180f353fbadSmrg# end func_convert_path_front_back_pathsep 3181f353fbadSmrg 3182f353fbadSmrg 3183f353fbadSmrg################################################## 3184f353fbadSmrg# $build to $host FILE NAME CONVERSION FUNCTIONS # 3185f353fbadSmrg################################################## 31865ec34c4cSmrg# invoked via '$to_host_file_cmd ARG' 3187f353fbadSmrg# 3188f353fbadSmrg# In each case, ARG is the path to be converted from $build to $host format. 3189f353fbadSmrg# Result will be available in $func_to_host_file_result. 3190f353fbadSmrg 3191f353fbadSmrg 3192f353fbadSmrg# func_to_host_file ARG 3193f353fbadSmrg# Converts the file name ARG from $build format to $host format. Return result 3194f353fbadSmrg# in func_to_host_file_result. 3195f353fbadSmrgfunc_to_host_file () 3196f353fbadSmrg{ 31975ec34c4cSmrg $debug_cmd 31985ec34c4cSmrg 3199f353fbadSmrg $to_host_file_cmd "$1" 3200f353fbadSmrg} 3201f353fbadSmrg# end func_to_host_file 3202f353fbadSmrg 3203f353fbadSmrg 3204f353fbadSmrg# func_to_tool_file ARG LAZY 3205f353fbadSmrg# converts the file name ARG from $build format to toolchain format. Return 3206f353fbadSmrg# result in func_to_tool_file_result. If the conversion in use is listed 3207f353fbadSmrg# in (the comma separated) LAZY, no conversion takes place. 3208f353fbadSmrgfunc_to_tool_file () 3209f353fbadSmrg{ 32105ec34c4cSmrg $debug_cmd 32115ec34c4cSmrg 3212f353fbadSmrg case ,$2, in 3213f353fbadSmrg *,"$to_tool_file_cmd",*) 3214f353fbadSmrg func_to_tool_file_result=$1 3215f353fbadSmrg ;; 3216f353fbadSmrg *) 3217f353fbadSmrg $to_tool_file_cmd "$1" 3218f353fbadSmrg func_to_tool_file_result=$func_to_host_file_result 3219f353fbadSmrg ;; 3220f353fbadSmrg esac 3221f353fbadSmrg} 3222f353fbadSmrg# end func_to_tool_file 3223f353fbadSmrg 3224f353fbadSmrg 3225f353fbadSmrg# func_convert_file_noop ARG 3226f353fbadSmrg# Copy ARG to func_to_host_file_result. 3227f353fbadSmrgfunc_convert_file_noop () 3228f353fbadSmrg{ 32295ec34c4cSmrg func_to_host_file_result=$1 3230f353fbadSmrg} 3231f353fbadSmrg# end func_convert_file_noop 3232f353fbadSmrg 3233f353fbadSmrg 3234f353fbadSmrg# func_convert_file_msys_to_w32 ARG 3235f353fbadSmrg# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic 3236f353fbadSmrg# conversion to w32 is not available inside the cwrapper. Returns result in 3237f353fbadSmrg# func_to_host_file_result. 3238f353fbadSmrgfunc_convert_file_msys_to_w32 () 3239f353fbadSmrg{ 32405ec34c4cSmrg $debug_cmd 32415ec34c4cSmrg 32425ec34c4cSmrg func_to_host_file_result=$1 3243f353fbadSmrg if test -n "$1"; then 3244f353fbadSmrg func_convert_core_msys_to_w32 "$1" 32455ec34c4cSmrg func_to_host_file_result=$func_convert_core_msys_to_w32_result 3246f353fbadSmrg fi 3247f353fbadSmrg func_convert_file_check "$1" "$func_to_host_file_result" 3248f353fbadSmrg} 3249f353fbadSmrg# end func_convert_file_msys_to_w32 3250f353fbadSmrg 3251f353fbadSmrg 3252f353fbadSmrg# func_convert_file_cygwin_to_w32 ARG 3253f353fbadSmrg# Convert file name ARG from Cygwin to w32 format. Returns result in 3254f353fbadSmrg# func_to_host_file_result. 3255f353fbadSmrgfunc_convert_file_cygwin_to_w32 () 3256f353fbadSmrg{ 32575ec34c4cSmrg $debug_cmd 32585ec34c4cSmrg 32595ec34c4cSmrg func_to_host_file_result=$1 3260f353fbadSmrg if test -n "$1"; then 3261f353fbadSmrg # because $build is cygwin, we call "the" cygpath in $PATH; no need to use 3262f353fbadSmrg # LT_CYGPATH in this case. 3263f353fbadSmrg func_to_host_file_result=`cygpath -m "$1"` 3264f353fbadSmrg fi 3265f353fbadSmrg func_convert_file_check "$1" "$func_to_host_file_result" 3266f353fbadSmrg} 3267f353fbadSmrg# end func_convert_file_cygwin_to_w32 3268f353fbadSmrg 3269f353fbadSmrg 3270f353fbadSmrg# func_convert_file_nix_to_w32 ARG 3271f353fbadSmrg# Convert file name ARG from *nix to w32 format. Requires a wine environment 3272f353fbadSmrg# and a working winepath. Returns result in func_to_host_file_result. 3273f353fbadSmrgfunc_convert_file_nix_to_w32 () 3274f353fbadSmrg{ 32755ec34c4cSmrg $debug_cmd 32765ec34c4cSmrg 32775ec34c4cSmrg func_to_host_file_result=$1 3278f353fbadSmrg if test -n "$1"; then 3279f353fbadSmrg func_convert_core_file_wine_to_w32 "$1" 32805ec34c4cSmrg func_to_host_file_result=$func_convert_core_file_wine_to_w32_result 3281f353fbadSmrg fi 3282f353fbadSmrg func_convert_file_check "$1" "$func_to_host_file_result" 3283f353fbadSmrg} 3284f353fbadSmrg# end func_convert_file_nix_to_w32 3285f353fbadSmrg 3286f353fbadSmrg 3287f353fbadSmrg# func_convert_file_msys_to_cygwin ARG 3288f353fbadSmrg# Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 3289f353fbadSmrg# Returns result in func_to_host_file_result. 3290f353fbadSmrgfunc_convert_file_msys_to_cygwin () 3291f353fbadSmrg{ 32925ec34c4cSmrg $debug_cmd 32935ec34c4cSmrg 32945ec34c4cSmrg func_to_host_file_result=$1 3295f353fbadSmrg if test -n "$1"; then 3296f353fbadSmrg func_convert_core_msys_to_w32 "$1" 3297f353fbadSmrg func_cygpath -u "$func_convert_core_msys_to_w32_result" 32985ec34c4cSmrg func_to_host_file_result=$func_cygpath_result 3299f353fbadSmrg fi 3300f353fbadSmrg func_convert_file_check "$1" "$func_to_host_file_result" 3301f353fbadSmrg} 3302f353fbadSmrg# end func_convert_file_msys_to_cygwin 3303f353fbadSmrg 3304f353fbadSmrg 3305f353fbadSmrg# func_convert_file_nix_to_cygwin ARG 3306f353fbadSmrg# Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed 3307f353fbadSmrg# in a wine environment, working winepath, and LT_CYGPATH set. Returns result 3308f353fbadSmrg# in func_to_host_file_result. 3309f353fbadSmrgfunc_convert_file_nix_to_cygwin () 3310f353fbadSmrg{ 33115ec34c4cSmrg $debug_cmd 33125ec34c4cSmrg 33135ec34c4cSmrg func_to_host_file_result=$1 3314f353fbadSmrg if test -n "$1"; then 3315f353fbadSmrg # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. 3316f353fbadSmrg func_convert_core_file_wine_to_w32 "$1" 3317f353fbadSmrg func_cygpath -u "$func_convert_core_file_wine_to_w32_result" 33185ec34c4cSmrg func_to_host_file_result=$func_cygpath_result 3319f353fbadSmrg fi 3320f353fbadSmrg func_convert_file_check "$1" "$func_to_host_file_result" 3321f353fbadSmrg} 3322f353fbadSmrg# end func_convert_file_nix_to_cygwin 3323f353fbadSmrg 3324f353fbadSmrg 3325f353fbadSmrg############################################# 3326f353fbadSmrg# $build to $host PATH CONVERSION FUNCTIONS # 3327f353fbadSmrg############################################# 33285ec34c4cSmrg# invoked via '$to_host_path_cmd ARG' 3329f353fbadSmrg# 3330f353fbadSmrg# In each case, ARG is the path to be converted from $build to $host format. 3331f353fbadSmrg# The result will be available in $func_to_host_path_result. 3332f353fbadSmrg# 3333f353fbadSmrg# Path separators are also converted from $build format to $host format. If 3334f353fbadSmrg# ARG begins or ends with a path separator character, it is preserved (but 3335f353fbadSmrg# converted to $host format) on output. 3336f353fbadSmrg# 3337f353fbadSmrg# All path conversion functions are named using the following convention: 3338f353fbadSmrg# file name conversion function : func_convert_file_X_to_Y () 3339f353fbadSmrg# path conversion function : func_convert_path_X_to_Y () 3340f353fbadSmrg# where, for any given $build/$host combination the 'X_to_Y' value is the 3341f353fbadSmrg# same. If conversion functions are added for new $build/$host combinations, 3342f353fbadSmrg# the two new functions must follow this pattern, or func_init_to_host_path_cmd 3343f353fbadSmrg# will break. 3344f353fbadSmrg 3345f353fbadSmrg 3346f353fbadSmrg# func_init_to_host_path_cmd 3347f353fbadSmrg# Ensures that function "pointer" variable $to_host_path_cmd is set to the 3348f353fbadSmrg# appropriate value, based on the value of $to_host_file_cmd. 3349f353fbadSmrgto_host_path_cmd= 3350f353fbadSmrgfunc_init_to_host_path_cmd () 3351f353fbadSmrg{ 33525ec34c4cSmrg $debug_cmd 33535ec34c4cSmrg 3354f353fbadSmrg if test -z "$to_host_path_cmd"; then 3355f353fbadSmrg func_stripname 'func_convert_file_' '' "$to_host_file_cmd" 33565ec34c4cSmrg to_host_path_cmd=func_convert_path_$func_stripname_result 3357f353fbadSmrg fi 3358f353fbadSmrg} 3359f353fbadSmrg 3360f353fbadSmrg 3361f353fbadSmrg# func_to_host_path ARG 3362f353fbadSmrg# Converts the path ARG from $build format to $host format. Return result 3363f353fbadSmrg# in func_to_host_path_result. 3364f353fbadSmrgfunc_to_host_path () 3365f353fbadSmrg{ 33665ec34c4cSmrg $debug_cmd 33675ec34c4cSmrg 3368f353fbadSmrg func_init_to_host_path_cmd 3369f353fbadSmrg $to_host_path_cmd "$1" 3370f353fbadSmrg} 3371f353fbadSmrg# end func_to_host_path 3372f353fbadSmrg 3373f353fbadSmrg 3374f353fbadSmrg# func_convert_path_noop ARG 3375f353fbadSmrg# Copy ARG to func_to_host_path_result. 3376f353fbadSmrgfunc_convert_path_noop () 3377f353fbadSmrg{ 33785ec34c4cSmrg func_to_host_path_result=$1 3379f353fbadSmrg} 3380f353fbadSmrg# end func_convert_path_noop 3381f353fbadSmrg 3382f353fbadSmrg 3383f353fbadSmrg# func_convert_path_msys_to_w32 ARG 3384f353fbadSmrg# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic 3385f353fbadSmrg# conversion to w32 is not available inside the cwrapper. Returns result in 3386f353fbadSmrg# func_to_host_path_result. 3387f353fbadSmrgfunc_convert_path_msys_to_w32 () 3388994689c1Smrg{ 33895ec34c4cSmrg $debug_cmd 33905ec34c4cSmrg 33915ec34c4cSmrg func_to_host_path_result=$1 3392f353fbadSmrg if test -n "$1"; then 3393f353fbadSmrg # Remove leading and trailing path separator characters from ARG. MSYS 3394f353fbadSmrg # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; 3395f353fbadSmrg # and winepath ignores them completely. 3396f353fbadSmrg func_stripname : : "$1" 3397f353fbadSmrg func_to_host_path_tmp1=$func_stripname_result 3398f353fbadSmrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 33995ec34c4cSmrg func_to_host_path_result=$func_convert_core_msys_to_w32_result 3400f353fbadSmrg func_convert_path_check : ";" \ 3401f353fbadSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3402f353fbadSmrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 3403f353fbadSmrg fi 3404f353fbadSmrg} 3405f353fbadSmrg# end func_convert_path_msys_to_w32 3406994689c1Smrg 3407994689c1Smrg 3408f353fbadSmrg# func_convert_path_cygwin_to_w32 ARG 3409f353fbadSmrg# Convert path ARG from Cygwin to w32 format. Returns result in 3410f353fbadSmrg# func_to_host_file_result. 3411f353fbadSmrgfunc_convert_path_cygwin_to_w32 () 3412f353fbadSmrg{ 34135ec34c4cSmrg $debug_cmd 34145ec34c4cSmrg 34155ec34c4cSmrg func_to_host_path_result=$1 3416f353fbadSmrg if test -n "$1"; then 3417f353fbadSmrg # See func_convert_path_msys_to_w32: 3418f353fbadSmrg func_stripname : : "$1" 3419f353fbadSmrg func_to_host_path_tmp1=$func_stripname_result 3420f353fbadSmrg func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` 3421f353fbadSmrg func_convert_path_check : ";" \ 3422f353fbadSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3423f353fbadSmrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 3424f353fbadSmrg fi 3425f353fbadSmrg} 3426f353fbadSmrg# end func_convert_path_cygwin_to_w32 3427994689c1Smrg 3428994689c1Smrg 3429f353fbadSmrg# func_convert_path_nix_to_w32 ARG 3430f353fbadSmrg# Convert path ARG from *nix to w32 format. Requires a wine environment and 3431f353fbadSmrg# a working winepath. Returns result in func_to_host_file_result. 3432f353fbadSmrgfunc_convert_path_nix_to_w32 () 3433f353fbadSmrg{ 34345ec34c4cSmrg $debug_cmd 34355ec34c4cSmrg 34365ec34c4cSmrg func_to_host_path_result=$1 3437f353fbadSmrg if test -n "$1"; then 3438f353fbadSmrg # See func_convert_path_msys_to_w32: 3439f353fbadSmrg func_stripname : : "$1" 3440f353fbadSmrg func_to_host_path_tmp1=$func_stripname_result 3441f353fbadSmrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 34425ec34c4cSmrg func_to_host_path_result=$func_convert_core_path_wine_to_w32_result 3443f353fbadSmrg func_convert_path_check : ";" \ 3444f353fbadSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3445f353fbadSmrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 3446f353fbadSmrg fi 3447f353fbadSmrg} 3448f353fbadSmrg# end func_convert_path_nix_to_w32 3449994689c1Smrg 3450f353fbadSmrg 3451f353fbadSmrg# func_convert_path_msys_to_cygwin ARG 3452f353fbadSmrg# Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 3453f353fbadSmrg# Returns result in func_to_host_file_result. 3454f353fbadSmrgfunc_convert_path_msys_to_cygwin () 3455f353fbadSmrg{ 34565ec34c4cSmrg $debug_cmd 34575ec34c4cSmrg 34585ec34c4cSmrg func_to_host_path_result=$1 3459f353fbadSmrg if test -n "$1"; then 3460f353fbadSmrg # See func_convert_path_msys_to_w32: 3461f353fbadSmrg func_stripname : : "$1" 3462f353fbadSmrg func_to_host_path_tmp1=$func_stripname_result 3463f353fbadSmrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 3464f353fbadSmrg func_cygpath -u -p "$func_convert_core_msys_to_w32_result" 34655ec34c4cSmrg func_to_host_path_result=$func_cygpath_result 3466f353fbadSmrg func_convert_path_check : : \ 3467f353fbadSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3468f353fbadSmrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 3469f353fbadSmrg fi 3470f353fbadSmrg} 3471f353fbadSmrg# end func_convert_path_msys_to_cygwin 3472f353fbadSmrg 3473f353fbadSmrg 3474f353fbadSmrg# func_convert_path_nix_to_cygwin ARG 3475f353fbadSmrg# Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a 3476f353fbadSmrg# a wine environment, working winepath, and LT_CYGPATH set. Returns result in 3477f353fbadSmrg# func_to_host_file_result. 3478f353fbadSmrgfunc_convert_path_nix_to_cygwin () 3479f353fbadSmrg{ 34805ec34c4cSmrg $debug_cmd 34815ec34c4cSmrg 34825ec34c4cSmrg func_to_host_path_result=$1 3483f353fbadSmrg if test -n "$1"; then 3484f353fbadSmrg # Remove leading and trailing path separator characters from 3485f353fbadSmrg # ARG. msys behavior is inconsistent here, cygpath turns them 3486f353fbadSmrg # into '.;' and ';.', and winepath ignores them completely. 3487f353fbadSmrg func_stripname : : "$1" 3488f353fbadSmrg func_to_host_path_tmp1=$func_stripname_result 3489f353fbadSmrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 3490f353fbadSmrg func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" 34915ec34c4cSmrg func_to_host_path_result=$func_cygpath_result 3492f353fbadSmrg func_convert_path_check : : \ 3493f353fbadSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3494f353fbadSmrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 3495f353fbadSmrg fi 3496994689c1Smrg} 3497f353fbadSmrg# end func_convert_path_nix_to_cygwin 3498f353fbadSmrg 3499994689c1Smrg 35005ec34c4cSmrg# func_dll_def_p FILE 35015ec34c4cSmrg# True iff FILE is a Windows DLL '.def' file. 35025ec34c4cSmrg# Keep in sync with _LT_DLL_DEF_P in libtool.m4 35035ec34c4cSmrgfunc_dll_def_p () 35045ec34c4cSmrg{ 35055ec34c4cSmrg $debug_cmd 35065ec34c4cSmrg 35075ec34c4cSmrg func_dll_def_p_tmp=`$SED -n \ 35085ec34c4cSmrg -e 's/^[ ]*//' \ 35095ec34c4cSmrg -e '/^\(;.*\)*$/d' \ 35105ec34c4cSmrg -e 's/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p' \ 35115ec34c4cSmrg -e q \ 35125ec34c4cSmrg "$1"` 35135ec34c4cSmrg test DEF = "$func_dll_def_p_tmp" 35145ec34c4cSmrg} 35155ec34c4cSmrg 35165ec34c4cSmrg 3517994689c1Smrg# func_mode_compile arg... 3518994689c1Smrgfunc_mode_compile () 3519994689c1Smrg{ 35205ec34c4cSmrg $debug_cmd 35215ec34c4cSmrg 3522994689c1Smrg # Get the compilation command and the source file. 3523994689c1Smrg base_compile= 35245ec34c4cSmrg srcfile=$nonopt # always keep a non-empty value in "srcfile" 3525994689c1Smrg suppress_opt=yes 3526994689c1Smrg suppress_output= 3527994689c1Smrg arg_mode=normal 3528994689c1Smrg libobj= 3529994689c1Smrg later= 3530994689c1Smrg pie_flag= 3531994689c1Smrg 3532994689c1Smrg for arg 3533994689c1Smrg do 3534994689c1Smrg case $arg_mode in 3535994689c1Smrg arg ) 3536994689c1Smrg # do not "continue". Instead, add this to base_compile 35375ec34c4cSmrg lastarg=$arg 3538994689c1Smrg arg_mode=normal 3539994689c1Smrg ;; 3540994689c1Smrg 3541994689c1Smrg target ) 35425ec34c4cSmrg libobj=$arg 3543994689c1Smrg arg_mode=normal 3544994689c1Smrg continue 3545994689c1Smrg ;; 3546994689c1Smrg 3547994689c1Smrg normal ) 3548994689c1Smrg # Accept any command-line options. 3549994689c1Smrg case $arg in 3550994689c1Smrg -o) 3551994689c1Smrg test -n "$libobj" && \ 35525ec34c4cSmrg func_fatal_error "you cannot specify '-o' more than once" 3553994689c1Smrg arg_mode=target 3554994689c1Smrg continue 3555994689c1Smrg ;; 3556994689c1Smrg 3557994689c1Smrg -pie | -fpie | -fPIE) 3558f353fbadSmrg func_append pie_flag " $arg" 3559994689c1Smrg continue 3560994689c1Smrg ;; 3561994689c1Smrg 3562994689c1Smrg -shared | -static | -prefer-pic | -prefer-non-pic) 3563f353fbadSmrg func_append later " $arg" 3564994689c1Smrg continue 3565994689c1Smrg ;; 35667a84e134Smrg 35677a84e134Smrg -no-suppress) 35687a84e134Smrg suppress_opt=no 35697a84e134Smrg continue 35707a84e134Smrg ;; 35717a84e134Smrg 35727a84e134Smrg -Xcompiler) 35737a84e134Smrg arg_mode=arg # the next one goes into the "base_compile" arg list 35747a84e134Smrg continue # The current "srcfile" will either be retained or 35757a84e134Smrg ;; # replaced later. I would guess that would be a bug. 35767a84e134Smrg 35777a84e134Smrg -Wc,*) 3578994689c1Smrg func_stripname '-Wc,' '' "$arg" 3579994689c1Smrg args=$func_stripname_result 35807a84e134Smrg lastarg= 35815ec34c4cSmrg save_ifs=$IFS; IFS=, 3582994689c1Smrg for arg in $args; do 35835ec34c4cSmrg IFS=$save_ifs 3584f353fbadSmrg func_append_quoted lastarg "$arg" 35857a84e134Smrg done 35865ec34c4cSmrg IFS=$save_ifs 3587994689c1Smrg func_stripname ' ' '' "$lastarg" 3588994689c1Smrg lastarg=$func_stripname_result 35897a84e134Smrg 35907a84e134Smrg # Add the arguments to base_compile. 3591f353fbadSmrg func_append base_compile " $lastarg" 35927a84e134Smrg continue 35937a84e134Smrg ;; 35947a84e134Smrg 3595994689c1Smrg *) 35967a84e134Smrg # Accept the current argument as the source file. 35977a84e134Smrg # The previous "srcfile" becomes the current argument. 35987a84e134Smrg # 35995ec34c4cSmrg lastarg=$srcfile 36005ec34c4cSmrg srcfile=$arg 36017a84e134Smrg ;; 36027a84e134Smrg esac # case $arg 36037a84e134Smrg ;; 36047a84e134Smrg esac # case $arg_mode 36057a84e134Smrg 36067a84e134Smrg # Aesthetically quote the previous argument. 3607f353fbadSmrg func_append_quoted base_compile "$lastarg" 36087a84e134Smrg done # for arg 36097a84e134Smrg 36107a84e134Smrg case $arg_mode in 36117a84e134Smrg arg) 3612994689c1Smrg func_fatal_error "you must specify an argument for -Xcompile" 36137a84e134Smrg ;; 36147a84e134Smrg target) 36155ec34c4cSmrg func_fatal_error "you must specify a target with '-o'" 36167a84e134Smrg ;; 36177a84e134Smrg *) 36187a84e134Smrg # Get the name of the library object. 3619994689c1Smrg test -z "$libobj" && { 3620994689c1Smrg func_basename "$srcfile" 36215ec34c4cSmrg libobj=$func_basename_result 3622994689c1Smrg } 36237a84e134Smrg ;; 36247a84e134Smrg esac 36257a84e134Smrg 36267a84e134Smrg # Recognize several different file suffixes. 36277a84e134Smrg # If the user specifies -o file.o, it is replaced with file.lo 36287a84e134Smrg case $libobj in 3629994689c1Smrg *.[cCFSifmso] | \ 3630994689c1Smrg *.ada | *.adb | *.ads | *.asm | \ 3631994689c1Smrg *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ 3632421c997bSmrg *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup) 3633994689c1Smrg func_xform "$libobj" 3634994689c1Smrg libobj=$func_xform_result 3635994689c1Smrg ;; 36367a84e134Smrg esac 36377a84e134Smrg 36387a84e134Smrg case $libobj in 3639994689c1Smrg *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; 36407a84e134Smrg *) 36415ec34c4cSmrg func_fatal_error "cannot determine name of library object from '$libobj'" 36427a84e134Smrg ;; 36437a84e134Smrg esac 36447a84e134Smrg 36457a84e134Smrg func_infer_tag $base_compile 36467a84e134Smrg 36477a84e134Smrg for arg in $later; do 36487a84e134Smrg case $arg in 3649994689c1Smrg -shared) 36505ec34c4cSmrg test yes = "$build_libtool_libs" \ 36515ec34c4cSmrg || func_fatal_configuration "cannot build a shared library" 3652994689c1Smrg build_old_libs=no 3653994689c1Smrg continue 3654994689c1Smrg ;; 3655994689c1Smrg 36567a84e134Smrg -static) 3657994689c1Smrg build_libtool_libs=no 36587a84e134Smrg build_old_libs=yes 36597a84e134Smrg continue 36607a84e134Smrg ;; 36617a84e134Smrg 36627a84e134Smrg -prefer-pic) 36637a84e134Smrg pic_mode=yes 36647a84e134Smrg continue 36657a84e134Smrg ;; 36667a84e134Smrg 36677a84e134Smrg -prefer-non-pic) 36687a84e134Smrg pic_mode=no 36697a84e134Smrg continue 36707a84e134Smrg ;; 36717a84e134Smrg esac 36727a84e134Smrg done 36737a84e134Smrg 36745b16253fSmrg func_quote_arg pretty "$libobj" 36755b16253fSmrg test "X$libobj" != "X$func_quote_arg_result" \ 3676994689c1Smrg && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ 36775ec34c4cSmrg && func_warning "libobj name '$libobj' may not contain shell special characters." 3678994689c1Smrg func_dirname_and_basename "$obj" "/" "" 36795ec34c4cSmrg objname=$func_basename_result 36805ec34c4cSmrg xdir=$func_dirname_result 36815ec34c4cSmrg lobj=$xdir$objdir/$objname 36827a84e134Smrg 3683994689c1Smrg test -z "$base_compile" && \ 3684994689c1Smrg func_fatal_help "you must specify a compilation command" 36857a84e134Smrg 36867a84e134Smrg # Delete any leftover library objects. 36875ec34c4cSmrg if test yes = "$build_old_libs"; then 36887a84e134Smrg removelist="$obj $lobj $libobj ${libobj}T" 36897a84e134Smrg else 36907a84e134Smrg removelist="$lobj $libobj ${libobj}T" 36917a84e134Smrg fi 36927a84e134Smrg 36937a84e134Smrg # On Cygwin there's no "real" PIC flag so we must build both object types 36947a84e134Smrg case $host_os in 3695994689c1Smrg cygwin* | mingw* | pw32* | os2* | cegcc*) 36967a84e134Smrg pic_mode=default 36977a84e134Smrg ;; 36987a84e134Smrg esac 36995ec34c4cSmrg if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then 37007a84e134Smrg # non-PIC code in shared libraries is not supported 37017a84e134Smrg pic_mode=default 37027a84e134Smrg fi 37037a84e134Smrg 37047a84e134Smrg # Calculate the filename of the output object if compiler does 37057a84e134Smrg # not support -o with -c 37065ec34c4cSmrg if test no = "$compiler_c_o"; then 37075ec34c4cSmrg output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext 37085ec34c4cSmrg lockfile=$output_obj.lock 37097a84e134Smrg else 37107a84e134Smrg output_obj= 37117a84e134Smrg need_locks=no 37127a84e134Smrg lockfile= 37137a84e134Smrg fi 37147a84e134Smrg 37157a84e134Smrg # Lock this critical section if it is needed 37167a84e134Smrg # We use this script file to make the link, it avoids creating a new file 37175ec34c4cSmrg if test yes = "$need_locks"; then 3718994689c1Smrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 3719994689c1Smrg func_echo "Waiting for $lockfile to be removed" 37207a84e134Smrg sleep 2 37217a84e134Smrg done 37225ec34c4cSmrg elif test warn = "$need_locks"; then 37237a84e134Smrg if test -f "$lockfile"; then 3724994689c1Smrg $ECHO "\ 37257a84e134Smrg*** ERROR, $lockfile exists and contains: 37267a84e134Smrg`cat $lockfile 2>/dev/null` 37277a84e134Smrg 37287a84e134SmrgThis indicates that another process is trying to use the same 37297a84e134Smrgtemporary object file, and libtool could not work around it because 37305ec34c4cSmrgyour compiler does not support '-c' and '-o' together. If you 37317a84e134Smrgrepeat this compilation, it may succeed, by chance, but you had better 37327a84e134Smrgavoid parallel builds (make -j) in this platform, or get a better 37337a84e134Smrgcompiler." 37347a84e134Smrg 3735994689c1Smrg $opt_dry_run || $RM $removelist 37367a84e134Smrg exit $EXIT_FAILURE 37377a84e134Smrg fi 3738f353fbadSmrg func_append removelist " $output_obj" 3739994689c1Smrg $ECHO "$srcfile" > "$lockfile" 37407a84e134Smrg fi 37417a84e134Smrg 3742994689c1Smrg $opt_dry_run || $RM $removelist 3743f353fbadSmrg func_append removelist " $lockfile" 3744994689c1Smrg trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 3745994689c1Smrg 3746f353fbadSmrg func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 3747f353fbadSmrg srcfile=$func_to_tool_file_result 37485b16253fSmrg func_quote_arg pretty "$srcfile" 37495b16253fSmrg qsrcfile=$func_quote_arg_result 37507a84e134Smrg 37517a84e134Smrg # Only build a PIC object if we are building libtool libraries. 37525ec34c4cSmrg if test yes = "$build_libtool_libs"; then 37537a84e134Smrg # Without this assignment, base_compile gets emptied. 37547a84e134Smrg fbsd_hideous_sh_bug=$base_compile 37557a84e134Smrg 37565ec34c4cSmrg if test no != "$pic_mode"; then 37577a84e134Smrg command="$base_compile $qsrcfile $pic_flag" 37587a84e134Smrg else 37597a84e134Smrg # Don't build PIC code 37607a84e134Smrg command="$base_compile $qsrcfile" 37617a84e134Smrg fi 37627a84e134Smrg 3763994689c1Smrg func_mkdir_p "$xdir$objdir" 37647a84e134Smrg 37657a84e134Smrg if test -z "$output_obj"; then 37667a84e134Smrg # Place PIC objects in $objdir 3767f353fbadSmrg func_append command " -o $lobj" 37687a84e134Smrg fi 37697a84e134Smrg 3770994689c1Smrg func_show_eval_locale "$command" \ 3771994689c1Smrg 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' 37727a84e134Smrg 37735ec34c4cSmrg if test warn = "$need_locks" && 37747a84e134Smrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 3775994689c1Smrg $ECHO "\ 37767a84e134Smrg*** ERROR, $lockfile contains: 37777a84e134Smrg`cat $lockfile 2>/dev/null` 37787a84e134Smrg 37797a84e134Smrgbut it should contain: 37807a84e134Smrg$srcfile 37817a84e134Smrg 37827a84e134SmrgThis indicates that another process is trying to use the same 37837a84e134Smrgtemporary object file, and libtool could not work around it because 37845ec34c4cSmrgyour compiler does not support '-c' and '-o' together. If you 37857a84e134Smrgrepeat this compilation, it may succeed, by chance, but you had better 37867a84e134Smrgavoid parallel builds (make -j) in this platform, or get a better 37877a84e134Smrgcompiler." 37887a84e134Smrg 3789994689c1Smrg $opt_dry_run || $RM $removelist 37907a84e134Smrg exit $EXIT_FAILURE 37917a84e134Smrg fi 37927a84e134Smrg 37937a84e134Smrg # Just move the object if needed, then go on to compile the next one 37947a84e134Smrg if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then 3795994689c1Smrg func_show_eval '$MV "$output_obj" "$lobj"' \ 3796994689c1Smrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 37977a84e134Smrg fi 37987a84e134Smrg 37997a84e134Smrg # Allow error messages only from the first compilation. 38005ec34c4cSmrg if test yes = "$suppress_opt"; then 3801994689c1Smrg suppress_output=' >/dev/null 2>&1' 38027a84e134Smrg fi 38037a84e134Smrg fi 38047a84e134Smrg 38057a84e134Smrg # Only build a position-dependent object if we build old libraries. 38065ec34c4cSmrg if test yes = "$build_old_libs"; then 38075ec34c4cSmrg if test yes != "$pic_mode"; then 38087a84e134Smrg # Don't build PIC code 3809994689c1Smrg command="$base_compile $qsrcfile$pie_flag" 38107a84e134Smrg else 38117a84e134Smrg command="$base_compile $qsrcfile $pic_flag" 38127a84e134Smrg fi 38135ec34c4cSmrg if test yes = "$compiler_c_o"; then 3814f353fbadSmrg func_append command " -o $obj" 38157a84e134Smrg fi 38167a84e134Smrg 38177a84e134Smrg # Suppress compiler output if we already did a PIC compilation. 3818f353fbadSmrg func_append command "$suppress_output" 3819994689c1Smrg func_show_eval_locale "$command" \ 3820994689c1Smrg '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 38217a84e134Smrg 38225ec34c4cSmrg if test warn = "$need_locks" && 38237a84e134Smrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 3824994689c1Smrg $ECHO "\ 38257a84e134Smrg*** ERROR, $lockfile contains: 38267a84e134Smrg`cat $lockfile 2>/dev/null` 38277a84e134Smrg 38287a84e134Smrgbut it should contain: 38297a84e134Smrg$srcfile 38307a84e134Smrg 38317a84e134SmrgThis indicates that another process is trying to use the same 38327a84e134Smrgtemporary object file, and libtool could not work around it because 38335ec34c4cSmrgyour compiler does not support '-c' and '-o' together. If you 38347a84e134Smrgrepeat this compilation, it may succeed, by chance, but you had better 38357a84e134Smrgavoid parallel builds (make -j) in this platform, or get a better 38367a84e134Smrgcompiler." 38377a84e134Smrg 3838994689c1Smrg $opt_dry_run || $RM $removelist 38397a84e134Smrg exit $EXIT_FAILURE 38407a84e134Smrg fi 38417a84e134Smrg 38427a84e134Smrg # Just move the object if needed 38437a84e134Smrg if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then 3844994689c1Smrg func_show_eval '$MV "$output_obj" "$obj"' \ 3845994689c1Smrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 38467a84e134Smrg fi 38477a84e134Smrg fi 38487a84e134Smrg 3849994689c1Smrg $opt_dry_run || { 3850994689c1Smrg func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" 38517a84e134Smrg 3852994689c1Smrg # Unlock the critical section if it was locked 38535ec34c4cSmrg if test no != "$need_locks"; then 3854994689c1Smrg removelist=$lockfile 3855994689c1Smrg $RM "$lockfile" 3856994689c1Smrg fi 3857994689c1Smrg } 38587a84e134Smrg 38597a84e134Smrg exit $EXIT_SUCCESS 3860994689c1Smrg} 38617a84e134Smrg 3862994689c1Smrg$opt_help || { 38635ec34c4cSmrg test compile = "$opt_mode" && func_mode_compile ${1+"$@"} 3864994689c1Smrg} 38657a84e134Smrg 3866994689c1Smrgfunc_mode_help () 3867994689c1Smrg{ 3868994689c1Smrg # We need to display help for each of the modes. 3869f353fbadSmrg case $opt_mode in 3870994689c1Smrg "") 3871994689c1Smrg # Generic help is extracted from the usage comments 3872994689c1Smrg # at the start of this file. 3873994689c1Smrg func_help 3874994689c1Smrg ;; 38757a84e134Smrg 3876994689c1Smrg clean) 3877994689c1Smrg $ECHO \ 3878994689c1Smrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... 38797a84e134Smrg 3880994689c1SmrgRemove files from the build directory. 38817a84e134Smrg 3882994689c1SmrgRM is the name of the program to use to delete files associated with each FILE 38835ec34c4cSmrg(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 3884994689c1Smrgto RM. 38857a84e134Smrg 3886994689c1SmrgIf FILE is a libtool library, object or program, all the files associated 3887994689c1Smrgwith it are deleted. Otherwise, only FILE itself is deleted using RM." 3888994689c1Smrg ;; 38897a84e134Smrg 3890994689c1Smrg compile) 3891994689c1Smrg $ECHO \ 3892994689c1Smrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE 38937a84e134Smrg 3894994689c1SmrgCompile a source file into a libtool library object. 38957a84e134Smrg 3896994689c1SmrgThis mode accepts the following additional options: 38977a84e134Smrg 3898994689c1Smrg -o OUTPUT-FILE set the output file name to OUTPUT-FILE 3899994689c1Smrg -no-suppress do not suppress compiler output for multiple passes 3900994689c1Smrg -prefer-pic try to build PIC objects only 3901994689c1Smrg -prefer-non-pic try to build non-PIC objects only 39025ec34c4cSmrg -shared do not build a '.o' file suitable for static linking 39035ec34c4cSmrg -static only build a '.o' file suitable for static linking 39045b16253fSmrg -Wc,FLAG 39055b16253fSmrg -Xcompiler FLAG pass FLAG directly to the compiler 39067a84e134Smrg 39075ec34c4cSmrgCOMPILE-COMMAND is a command to be used in creating a 'standard' object file 3908994689c1Smrgfrom the given SOURCEFILE. 39097a84e134Smrg 3910994689c1SmrgThe output file name is determined by removing the directory component from 39115ec34c4cSmrgSOURCEFILE, then substituting the C source code suffix '.c' with the 39125ec34c4cSmrglibrary object suffix, '.lo'." 3913994689c1Smrg ;; 39147a84e134Smrg 3915994689c1Smrg execute) 3916994689c1Smrg $ECHO \ 3917994689c1Smrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... 39187a84e134Smrg 3919994689c1SmrgAutomatically set library path, then run a program. 39207a84e134Smrg 3921994689c1SmrgThis mode accepts the following additional options: 39227a84e134Smrg 3923994689c1Smrg -dlopen FILE add the directory containing FILE to the library path 39247a84e134Smrg 39255ec34c4cSmrgThis mode sets the library path environment variable according to '-dlopen' 3926994689c1Smrgflags. 39277a84e134Smrg 3928994689c1SmrgIf any of the ARGS are libtool executable wrappers, then they are translated 3929994689c1Smrginto their corresponding uninstalled binary, and any of their required library 3930994689c1Smrgdirectories are added to the library path. 39317a84e134Smrg 3932994689c1SmrgThen, COMMAND is executed, with ARGS as arguments." 3933994689c1Smrg ;; 39347a84e134Smrg 3935994689c1Smrg finish) 3936994689c1Smrg $ECHO \ 3937994689c1Smrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]... 39387a84e134Smrg 3939994689c1SmrgComplete the installation of libtool libraries. 39407a84e134Smrg 3941994689c1SmrgEach LIBDIR is a directory that contains libtool libraries. 39427a84e134Smrg 3943994689c1SmrgThe commands that this mode executes may require superuser privileges. Use 39445ec34c4cSmrgthe '--dry-run' option if you just want to see what would be executed." 3945994689c1Smrg ;; 39467a84e134Smrg 3947994689c1Smrg install) 3948994689c1Smrg $ECHO \ 3949994689c1Smrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... 39507a84e134Smrg 3951994689c1SmrgInstall executables or libraries. 39527a84e134Smrg 3953994689c1SmrgINSTALL-COMMAND is the installation command. The first component should be 39545ec34c4cSmrgeither the 'install' or 'cp' program. 39557a84e134Smrg 3956994689c1SmrgThe following components of INSTALL-COMMAND are treated specially: 39577a84e134Smrg 3958994689c1Smrg -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation 39597a84e134Smrg 3960994689c1SmrgThe rest of the components are interpreted as arguments to that command (only 3961994689c1SmrgBSD-compatible install options are recognized)." 3962994689c1Smrg ;; 39637a84e134Smrg 3964994689c1Smrg link) 3965994689c1Smrg $ECHO \ 3966994689c1Smrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND... 39677a84e134Smrg 3968994689c1SmrgLink object files or libraries together to form another library, or to 3969994689c1Smrgcreate an executable program. 39707a84e134Smrg 3971994689c1SmrgLINK-COMMAND is a command using the C compiler that you would use to create 3972994689c1Smrga program from several object files. 39737a84e134Smrg 3974994689c1SmrgThe following components of LINK-COMMAND are treated specially: 39757a84e134Smrg 3976994689c1Smrg -all-static do not do any dynamic linking at all 3977994689c1Smrg -avoid-version do not add a version suffix if possible 3978994689c1Smrg -bindir BINDIR specify path to binaries directory (for systems where 3979994689c1Smrg libraries must be found in the PATH setting at runtime) 39805ec34c4cSmrg -dlopen FILE '-dlpreopen' FILE if it cannot be dlopened at runtime 3981994689c1Smrg -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols 3982994689c1Smrg -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) 3983994689c1Smrg -export-symbols SYMFILE 3984994689c1Smrg try to export only the symbols listed in SYMFILE 3985994689c1Smrg -export-symbols-regex REGEX 3986994689c1Smrg try to export only the symbols matching REGEX 3987994689c1Smrg -LLIBDIR search LIBDIR for required installed libraries 3988994689c1Smrg -lNAME OUTPUT-FILE requires the installed library libNAME 3989994689c1Smrg -module build a library that can dlopened 3990994689c1Smrg -no-fast-install disable the fast-install mode 3991994689c1Smrg -no-install link a not-installable executable 3992994689c1Smrg -no-undefined declare that a library does not refer to external symbols 3993994689c1Smrg -o OUTPUT-FILE create OUTPUT-FILE from the specified objects 39945ec34c4cSmrg -objectlist FILE use a list of object files found in FILE to specify objects 39955ec34c4cSmrg -os2dllname NAME force a short DLL name on OS/2 (no effect on other OSes) 3996994689c1Smrg -precious-files-regex REGEX 3997994689c1Smrg don't remove output files matching REGEX 3998994689c1Smrg -release RELEASE specify package release information 3999994689c1Smrg -rpath LIBDIR the created library will eventually be installed in LIBDIR 4000994689c1Smrg -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries 4001994689c1Smrg -shared only do dynamic linking of libtool libraries 4002994689c1Smrg -shrext SUFFIX override the standard shared library file extension 4003994689c1Smrg -static do not do any dynamic linking of uninstalled libtool libraries 4004994689c1Smrg -static-libtool-libs 4005994689c1Smrg do not do any dynamic linking of libtool libraries 4006994689c1Smrg -version-info CURRENT[:REVISION[:AGE]] 4007994689c1Smrg specify library version info [each variable defaults to 0] 4008994689c1Smrg -weak LIBNAME declare that the target provides the LIBNAME interface 4009994689c1Smrg -Wc,FLAG 4010994689c1Smrg -Xcompiler FLAG pass linker-specific FLAG directly to the compiler 40115b16253fSmrg -Wa,FLAG 40125b16253fSmrg -Xassembler FLAG pass linker-specific FLAG directly to the assembler 4013994689c1Smrg -Wl,FLAG 4014994689c1Smrg -Xlinker FLAG pass linker-specific FLAG directly to the linker 4015994689c1Smrg -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) 40167a84e134Smrg 40175ec34c4cSmrgAll other options (arguments beginning with '-') are ignored. 40187a84e134Smrg 40195ec34c4cSmrgEvery other argument is treated as a filename. Files ending in '.la' are 4020994689c1Smrgtreated as uninstalled libtool libraries, other files are standard or library 4021994689c1Smrgobject files. 40227a84e134Smrg 40235ec34c4cSmrgIf the OUTPUT-FILE ends in '.la', then a libtool library is created, 40245ec34c4cSmrgonly library objects ('.lo' files) may be specified, and '-rpath' is 4025994689c1Smrgrequired, except when creating a convenience library. 40267a84e134Smrg 40275ec34c4cSmrgIf OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created 40285ec34c4cSmrgusing 'ar' and 'ranlib', or on Windows using 'lib'. 40297a84e134Smrg 40305ec34c4cSmrgIf OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file 4031994689c1Smrgis created, otherwise an executable program is created." 4032994689c1Smrg ;; 40337a84e134Smrg 4034994689c1Smrg uninstall) 4035994689c1Smrg $ECHO \ 4036994689c1Smrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... 40377a84e134Smrg 4038994689c1SmrgRemove libraries from an installation directory. 40397a84e134Smrg 4040994689c1SmrgRM is the name of the program to use to delete files associated with each FILE 40415ec34c4cSmrg(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 4042994689c1Smrgto RM. 40437a84e134Smrg 4044994689c1SmrgIf FILE is a libtool library, all the files associated with it are deleted. 4045994689c1SmrgOtherwise, only FILE itself is deleted using RM." 4046994689c1Smrg ;; 40477a84e134Smrg 4048994689c1Smrg *) 40495ec34c4cSmrg func_fatal_help "invalid operation mode '$opt_mode'" 4050994689c1Smrg ;; 4051994689c1Smrg esac 40527a84e134Smrg 4053994689c1Smrg echo 40545ec34c4cSmrg $ECHO "Try '$progname --help' for more information about other modes." 4055994689c1Smrg} 4056775e7de9Smrg 4057994689c1Smrg# Now that we've collected a possible --mode arg, show help if necessary 4058994689c1Smrgif $opt_help; then 40595ec34c4cSmrg if test : = "$opt_help"; then 4060994689c1Smrg func_mode_help 4061994689c1Smrg else 4062994689c1Smrg { 4063994689c1Smrg func_help noexit 4064f353fbadSmrg for opt_mode in compile link execute install finish uninstall clean; do 4065994689c1Smrg func_mode_help 4066994689c1Smrg done 40675ec34c4cSmrg } | $SED -n '1p; 2,$s/^Usage:/ or: /p' 4068994689c1Smrg { 4069994689c1Smrg func_help noexit 4070f353fbadSmrg for opt_mode in compile link execute install finish uninstall clean; do 4071994689c1Smrg echo 4072994689c1Smrg func_mode_help 4073994689c1Smrg done 4074994689c1Smrg } | 40755ec34c4cSmrg $SED '1d 4076994689c1Smrg /^When reporting/,/^Report/{ 4077994689c1Smrg H 4078994689c1Smrg d 4079994689c1Smrg } 4080994689c1Smrg $x 4081994689c1Smrg /information about other modes/d 4082994689c1Smrg /more detailed .*MODE/d 4083994689c1Smrg s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' 4084994689c1Smrg fi 4085994689c1Smrg exit $? 4086994689c1Smrgfi 40877a84e134Smrg 40887a84e134Smrg 4089994689c1Smrg# func_mode_execute arg... 4090994689c1Smrgfunc_mode_execute () 4091994689c1Smrg{ 40925ec34c4cSmrg $debug_cmd 40935ec34c4cSmrg 4094994689c1Smrg # The first argument is the command name. 40955ec34c4cSmrg cmd=$nonopt 4096994689c1Smrg test -z "$cmd" && \ 4097994689c1Smrg func_fatal_help "you must specify a COMMAND" 4098ab902922Smrg 4099994689c1Smrg # Handle -dlopen flags immediately. 4100f353fbadSmrg for file in $opt_dlopen; do 4101994689c1Smrg test -f "$file" \ 41025ec34c4cSmrg || func_fatal_help "'$file' is not a file" 41037a84e134Smrg 4104994689c1Smrg dir= 4105994689c1Smrg case $file in 4106994689c1Smrg *.la) 4107f353fbadSmrg func_resolve_sysroot "$file" 4108f353fbadSmrg file=$func_resolve_sysroot_result 4109f353fbadSmrg 4110994689c1Smrg # Check to see that this really is a libtool archive. 4111994689c1Smrg func_lalib_unsafe_p "$file" \ 41125ec34c4cSmrg || func_fatal_help "'$lib' is not a valid libtool archive" 41137a84e134Smrg 4114994689c1Smrg # Read the libtool library. 4115994689c1Smrg dlname= 4116994689c1Smrg library_names= 4117994689c1Smrg func_source "$file" 41187a84e134Smrg 4119994689c1Smrg # Skip this library if it cannot be dlopened. 4120994689c1Smrg if test -z "$dlname"; then 4121994689c1Smrg # Warn if it was a shared library. 4122994689c1Smrg test -n "$library_names" && \ 41235ec34c4cSmrg func_warning "'$file' was not linked with '-export-dynamic'" 4124994689c1Smrg continue 4125994689c1Smrg fi 4126e1e1713cSmrg 4127994689c1Smrg func_dirname "$file" "" "." 41285ec34c4cSmrg dir=$func_dirname_result 4129e1e1713cSmrg 4130994689c1Smrg if test -f "$dir/$objdir/$dlname"; then 4131f353fbadSmrg func_append dir "/$objdir" 4132994689c1Smrg else 4133994689c1Smrg if test ! -f "$dir/$dlname"; then 41345ec34c4cSmrg func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'" 4135994689c1Smrg fi 4136994689c1Smrg fi 4137775e7de9Smrg ;; 4138e1e1713cSmrg 4139994689c1Smrg *.lo) 4140994689c1Smrg # Just add the directory containing the .lo file. 4141994689c1Smrg func_dirname "$file" "" "." 41425ec34c4cSmrg dir=$func_dirname_result 4143775e7de9Smrg ;; 4144994689c1Smrg 4145994689c1Smrg *) 41465ec34c4cSmrg func_warning "'-dlopen' is ignored for non-libtool libraries and objects" 4147e1e1713cSmrg continue 4148775e7de9Smrg ;; 4149994689c1Smrg esac 4150775e7de9Smrg 4151994689c1Smrg # Get the absolute pathname. 4152994689c1Smrg absdir=`cd "$dir" && pwd` 41535ec34c4cSmrg test -n "$absdir" && dir=$absdir 4154775e7de9Smrg 4155994689c1Smrg # Now add the directory to shlibpath_var. 4156994689c1Smrg if eval "test -z \"\$$shlibpath_var\""; then 4157994689c1Smrg eval "$shlibpath_var=\"\$dir\"" 4158994689c1Smrg else 4159994689c1Smrg eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" 4160994689c1Smrg fi 4161994689c1Smrg done 4162775e7de9Smrg 4163994689c1Smrg # This variable tells wrapper scripts just to set shlibpath_var 4164994689c1Smrg # rather than running their programs. 41655ec34c4cSmrg libtool_execute_magic=$magic 41667a84e134Smrg 4167994689c1Smrg # Check if any of the arguments is a wrapper script. 4168994689c1Smrg args= 4169994689c1Smrg for file 4170994689c1Smrg do 4171994689c1Smrg case $file in 4172994689c1Smrg -* | *.la | *.lo ) ;; 4173994689c1Smrg *) 4174994689c1Smrg # Do a test to see if this is really a libtool program. 4175994689c1Smrg if func_ltwrapper_script_p "$file"; then 4176994689c1Smrg func_source "$file" 4177994689c1Smrg # Transform arg to wrapped name. 41785ec34c4cSmrg file=$progdir/$program 4179994689c1Smrg elif func_ltwrapper_executable_p "$file"; then 4180994689c1Smrg func_ltwrapper_scriptname "$file" 4181994689c1Smrg func_source "$func_ltwrapper_scriptname_result" 4182994689c1Smrg # Transform arg to wrapped name. 41835ec34c4cSmrg file=$progdir/$program 4184994689c1Smrg fi 4185e1e1713cSmrg ;; 4186994689c1Smrg esac 4187994689c1Smrg # Quote arguments (to preserve shell metacharacters). 4188f353fbadSmrg func_append_quoted args "$file" 4189994689c1Smrg done 41907a84e134Smrg 41915ec34c4cSmrg if $opt_dry_run; then 41925ec34c4cSmrg # Display what would be done. 41935ec34c4cSmrg if test -n "$shlibpath_var"; then 41945ec34c4cSmrg eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" 41955ec34c4cSmrg echo "export $shlibpath_var" 41965ec34c4cSmrg fi 41975ec34c4cSmrg $ECHO "$cmd$args" 41985ec34c4cSmrg exit $EXIT_SUCCESS 41995ec34c4cSmrg else 4200994689c1Smrg if test -n "$shlibpath_var"; then 4201994689c1Smrg # Export the shlibpath_var. 4202994689c1Smrg eval "export $shlibpath_var" 4203994689c1Smrg fi 4204775e7de9Smrg 4205994689c1Smrg # Restore saved environment variables 4206994689c1Smrg for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 4207994689c1Smrg do 4208994689c1Smrg eval "if test \"\${save_$lt_var+set}\" = set; then 4209994689c1Smrg $lt_var=\$save_$lt_var; export $lt_var 4210994689c1Smrg else 4211994689c1Smrg $lt_unset $lt_var 4212994689c1Smrg fi" 4213994689c1Smrg done 42147a84e134Smrg 4215994689c1Smrg # Now prepare to actually exec the command. 42165ec34c4cSmrg exec_cmd=\$cmd$args 4217994689c1Smrg fi 4218994689c1Smrg} 4219775e7de9Smrg 42205ec34c4cSmrgtest execute = "$opt_mode" && func_mode_execute ${1+"$@"} 4221775e7de9Smrg 4222775e7de9Smrg 4223994689c1Smrg# func_mode_finish arg... 4224994689c1Smrgfunc_mode_finish () 4225994689c1Smrg{ 42265ec34c4cSmrg $debug_cmd 42275ec34c4cSmrg 4228f353fbadSmrg libs= 4229f353fbadSmrg libdirs= 4230994689c1Smrg admincmds= 4231775e7de9Smrg 4232f353fbadSmrg for opt in "$nonopt" ${1+"$@"} 4233f353fbadSmrg do 4234f353fbadSmrg if test -d "$opt"; then 4235f353fbadSmrg func_append libdirs " $opt" 4236f353fbadSmrg 4237f353fbadSmrg elif test -f "$opt"; then 4238f353fbadSmrg if func_lalib_unsafe_p "$opt"; then 4239f353fbadSmrg func_append libs " $opt" 4240f353fbadSmrg else 42415ec34c4cSmrg func_warning "'$opt' is not a valid libtool archive" 4242f353fbadSmrg fi 4243f353fbadSmrg 4244f353fbadSmrg else 42455ec34c4cSmrg func_fatal_error "invalid argument '$opt'" 4246f353fbadSmrg fi 4247f353fbadSmrg done 4248f353fbadSmrg 4249f353fbadSmrg if test -n "$libs"; then 4250f353fbadSmrg if test -n "$lt_sysroot"; then 4251f353fbadSmrg sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` 4252f353fbadSmrg sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" 4253f353fbadSmrg else 4254f353fbadSmrg sysroot_cmd= 4255f353fbadSmrg fi 4256f353fbadSmrg 4257f353fbadSmrg # Remove sysroot references 4258f353fbadSmrg if $opt_dry_run; then 4259f353fbadSmrg for lib in $libs; do 42605ec34c4cSmrg echo "removing references to $lt_sysroot and '=' prefixes from $lib" 4261f353fbadSmrg done 4262f353fbadSmrg else 4263f353fbadSmrg tmpdir=`func_mktempdir` 4264f353fbadSmrg for lib in $libs; do 42655ec34c4cSmrg $SED -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ 4266f353fbadSmrg > $tmpdir/tmp-la 4267f353fbadSmrg mv -f $tmpdir/tmp-la $lib 4268f353fbadSmrg done 4269f353fbadSmrg ${RM}r "$tmpdir" 4270f353fbadSmrg fi 4271f353fbadSmrg fi 4272775e7de9Smrg 4273f353fbadSmrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 4274994689c1Smrg for libdir in $libdirs; do 4275994689c1Smrg if test -n "$finish_cmds"; then 4276994689c1Smrg # Do each command in the finish commands. 4277994689c1Smrg func_execute_cmds "$finish_cmds" 'admincmds="$admincmds 4278994689c1Smrg'"$cmd"'"' 4279994689c1Smrg fi 4280994689c1Smrg if test -n "$finish_eval"; then 4281994689c1Smrg # Do the single finish_eval. 4282994689c1Smrg eval cmds=\"$finish_eval\" 4283f353fbadSmrg $opt_dry_run || eval "$cmds" || func_append admincmds " 4284994689c1Smrg $cmds" 4285994689c1Smrg fi 4286994689c1Smrg done 4287994689c1Smrg fi 4288775e7de9Smrg 4289994689c1Smrg # Exit here if they wanted silent mode. 42905ec34c4cSmrg $opt_quiet && exit $EXIT_SUCCESS 4291775e7de9Smrg 4292f353fbadSmrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 4293f353fbadSmrg echo "----------------------------------------------------------------------" 4294f353fbadSmrg echo "Libraries have been installed in:" 4295f353fbadSmrg for libdir in $libdirs; do 4296f353fbadSmrg $ECHO " $libdir" 4297f353fbadSmrg done 4298f353fbadSmrg echo 4299f353fbadSmrg echo "If you ever happen to want to link against installed libraries" 4300f353fbadSmrg echo "in a given directory, LIBDIR, you must either use libtool, and" 43015ec34c4cSmrg echo "specify the full pathname of the library, or use the '-LLIBDIR'" 4302f353fbadSmrg echo "flag during linking and do at least one of the following:" 4303f353fbadSmrg if test -n "$shlibpath_var"; then 43045ec34c4cSmrg echo " - add LIBDIR to the '$shlibpath_var' environment variable" 4305f353fbadSmrg echo " during execution" 4306f353fbadSmrg fi 4307f353fbadSmrg if test -n "$runpath_var"; then 43085ec34c4cSmrg echo " - add LIBDIR to the '$runpath_var' environment variable" 4309f353fbadSmrg echo " during linking" 4310f353fbadSmrg fi 4311f353fbadSmrg if test -n "$hardcode_libdir_flag_spec"; then 4312f353fbadSmrg libdir=LIBDIR 4313f353fbadSmrg eval flag=\"$hardcode_libdir_flag_spec\" 4314775e7de9Smrg 43155ec34c4cSmrg $ECHO " - use the '$flag' linker flag" 4316f353fbadSmrg fi 4317f353fbadSmrg if test -n "$admincmds"; then 4318f353fbadSmrg $ECHO " - have your system administrator run these commands:$admincmds" 4319f353fbadSmrg fi 4320f353fbadSmrg if test -f /etc/ld.so.conf; then 43215ec34c4cSmrg echo " - have your system administrator add LIBDIR to '/etc/ld.so.conf'" 4322f353fbadSmrg fi 4323f353fbadSmrg echo 4324775e7de9Smrg 4325f353fbadSmrg echo "See any operating system documentation about shared libraries for" 4326f353fbadSmrg case $host in 4327f353fbadSmrg solaris2.[6789]|solaris2.1[0-9]) 4328f353fbadSmrg echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" 4329f353fbadSmrg echo "pages." 4330f353fbadSmrg ;; 4331f353fbadSmrg *) 4332f353fbadSmrg echo "more information, such as the ld(1) and ld.so(8) manual pages." 4333f353fbadSmrg ;; 4334f353fbadSmrg esac 4335f353fbadSmrg echo "----------------------------------------------------------------------" 4336f353fbadSmrg fi 4337994689c1Smrg exit $EXIT_SUCCESS 4338994689c1Smrg} 4339775e7de9Smrg 43405ec34c4cSmrgtest finish = "$opt_mode" && func_mode_finish ${1+"$@"} 4341e1e1713cSmrg 43427a84e134Smrg 4343994689c1Smrg# func_mode_install arg... 4344994689c1Smrgfunc_mode_install () 4345994689c1Smrg{ 43465ec34c4cSmrg $debug_cmd 43475ec34c4cSmrg 4348994689c1Smrg # There may be an optional sh(1) argument at the beginning of 4349994689c1Smrg # install_prog (especially on Windows NT). 43505ec34c4cSmrg if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" || 4351994689c1Smrg # Allow the use of GNU shtool's install command. 43525ec34c4cSmrg case $nonopt in *shtool*) :;; *) false;; esac 43535ec34c4cSmrg then 4354994689c1Smrg # Aesthetically quote it. 43555b16253fSmrg func_quote_arg pretty "$nonopt" 43565b16253fSmrg install_prog="$func_quote_arg_result " 4357994689c1Smrg arg=$1 4358994689c1Smrg shift 4359994689c1Smrg else 4360994689c1Smrg install_prog= 4361994689c1Smrg arg=$nonopt 4362994689c1Smrg fi 43637a84e134Smrg 4364994689c1Smrg # The real first argument should be the name of the installation program. 4365994689c1Smrg # Aesthetically quote it. 43665b16253fSmrg func_quote_arg pretty "$arg" 43675b16253fSmrg func_append install_prog "$func_quote_arg_result" 4368994689c1Smrg install_shared_prog=$install_prog 4369994689c1Smrg case " $install_prog " in 4370994689c1Smrg *[\\\ /]cp\ *) install_cp=: ;; 4371994689c1Smrg *) install_cp=false ;; 4372994689c1Smrg esac 43737a84e134Smrg 4374994689c1Smrg # We need to accept at least all the BSD install flags. 4375994689c1Smrg dest= 4376994689c1Smrg files= 4377994689c1Smrg opts= 4378994689c1Smrg prev= 4379994689c1Smrg install_type= 43805ec34c4cSmrg isdir=false 4381994689c1Smrg stripme= 4382994689c1Smrg no_mode=: 4383994689c1Smrg for arg 4384994689c1Smrg do 4385994689c1Smrg arg2= 4386994689c1Smrg if test -n "$dest"; then 4387f353fbadSmrg func_append files " $dest" 4388994689c1Smrg dest=$arg 4389e1e1713cSmrg continue 4390994689c1Smrg fi 43917a84e134Smrg 4392994689c1Smrg case $arg in 43935ec34c4cSmrg -d) isdir=: ;; 4394994689c1Smrg -f) 4395994689c1Smrg if $install_cp; then :; else 4396994689c1Smrg prev=$arg 4397775e7de9Smrg fi 4398994689c1Smrg ;; 4399994689c1Smrg -g | -m | -o) 4400994689c1Smrg prev=$arg 4401994689c1Smrg ;; 4402994689c1Smrg -s) 4403994689c1Smrg stripme=" -s" 4404e1e1713cSmrg continue 4405e1e1713cSmrg ;; 4406994689c1Smrg -*) 4407994689c1Smrg ;; 4408e1e1713cSmrg *) 4409994689c1Smrg # If the previous option needed an argument, then skip it. 4410994689c1Smrg if test -n "$prev"; then 44115ec34c4cSmrg if test X-m = "X$prev" && test -n "$install_override_mode"; then 4412994689c1Smrg arg2=$install_override_mode 4413994689c1Smrg no_mode=false 4414994689c1Smrg fi 4415994689c1Smrg prev= 4416994689c1Smrg else 4417994689c1Smrg dest=$arg 4418994689c1Smrg continue 4419994689c1Smrg fi 4420775e7de9Smrg ;; 4421994689c1Smrg esac 44227a84e134Smrg 4423994689c1Smrg # Aesthetically quote the argument. 44245b16253fSmrg func_quote_arg pretty "$arg" 44255b16253fSmrg func_append install_prog " $func_quote_arg_result" 4426994689c1Smrg if test -n "$arg2"; then 44275b16253fSmrg func_quote_arg pretty "$arg2" 4428e1e1713cSmrg fi 44295b16253fSmrg func_append install_shared_prog " $func_quote_arg_result" 4430994689c1Smrg done 44317a84e134Smrg 4432994689c1Smrg test -z "$install_prog" && \ 4433994689c1Smrg func_fatal_help "you must specify an install program" 44347a84e134Smrg 4435994689c1Smrg test -n "$prev" && \ 44365ec34c4cSmrg func_fatal_help "the '$prev' option requires an argument" 4437775e7de9Smrg 4438994689c1Smrg if test -n "$install_override_mode" && $no_mode; then 4439994689c1Smrg if $install_cp; then :; else 44405b16253fSmrg func_quote_arg pretty "$install_override_mode" 44415b16253fSmrg func_append install_shared_prog " -m $func_quote_arg_result" 4442994689c1Smrg fi 4443e1e1713cSmrg fi 4444775e7de9Smrg 4445994689c1Smrg if test -z "$files"; then 4446994689c1Smrg if test -z "$dest"; then 4447994689c1Smrg func_fatal_help "no file or destination specified" 4448994689c1Smrg else 4449994689c1Smrg func_fatal_help "you must specify a destination" 4450775e7de9Smrg fi 4451775e7de9Smrg fi 4452775e7de9Smrg 4453994689c1Smrg # Strip any trailing slash from the destination. 4454994689c1Smrg func_stripname '' '/' "$dest" 4455994689c1Smrg dest=$func_stripname_result 44567a84e134Smrg 4457994689c1Smrg # Check to see that the destination is a directory. 44585ec34c4cSmrg test -d "$dest" && isdir=: 44595ec34c4cSmrg if $isdir; then 44605ec34c4cSmrg destdir=$dest 4461994689c1Smrg destname= 4462994689c1Smrg else 4463994689c1Smrg func_dirname_and_basename "$dest" "" "." 44645ec34c4cSmrg destdir=$func_dirname_result 44655ec34c4cSmrg destname=$func_basename_result 4466994689c1Smrg 4467994689c1Smrg # Not a directory, so check to see that there is only one file specified. 4468994689c1Smrg set dummy $files; shift 4469994689c1Smrg test "$#" -gt 1 && \ 44705ec34c4cSmrg func_fatal_help "'$dest' is not a directory" 4471994689c1Smrg fi 4472994689c1Smrg case $destdir in 4473994689c1Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 4474e1e1713cSmrg *) 4475994689c1Smrg for file in $files; do 4476994689c1Smrg case $file in 4477994689c1Smrg *.lo) ;; 4478994689c1Smrg *) 44795ec34c4cSmrg func_fatal_help "'$destdir' must be an absolute directory name" 4480994689c1Smrg ;; 4481994689c1Smrg esac 4482994689c1Smrg done 4483e1e1713cSmrg ;; 4484e1e1713cSmrg esac 44857a84e134Smrg 4486994689c1Smrg # This variable tells wrapper scripts just to set variables rather 4487994689c1Smrg # than running their programs. 44885ec34c4cSmrg libtool_install_magic=$magic 44897a84e134Smrg 4490994689c1Smrg staticlibs= 4491994689c1Smrg future_libdirs= 4492994689c1Smrg current_libdirs= 4493994689c1Smrg for file in $files; do 44947a84e134Smrg 4495994689c1Smrg # Do each installation. 4496994689c1Smrg case $file in 4497994689c1Smrg *.$libext) 4498994689c1Smrg # Do the static libraries later. 4499f353fbadSmrg func_append staticlibs " $file" 4500994689c1Smrg ;; 4501994689c1Smrg 4502994689c1Smrg *.la) 4503f353fbadSmrg func_resolve_sysroot "$file" 4504f353fbadSmrg file=$func_resolve_sysroot_result 4505f353fbadSmrg 4506994689c1Smrg # Check to see that this really is a libtool archive. 4507994689c1Smrg func_lalib_unsafe_p "$file" \ 45085ec34c4cSmrg || func_fatal_help "'$file' is not a valid libtool archive" 4509994689c1Smrg 4510994689c1Smrg library_names= 4511994689c1Smrg old_library= 4512994689c1Smrg relink_command= 4513994689c1Smrg func_source "$file" 4514994689c1Smrg 4515994689c1Smrg # Add the libdir to current_libdirs if it is the destination. 4516994689c1Smrg if test "X$destdir" = "X$libdir"; then 4517994689c1Smrg case "$current_libdirs " in 4518994689c1Smrg *" $libdir "*) ;; 4519f353fbadSmrg *) func_append current_libdirs " $libdir" ;; 4520775e7de9Smrg esac 4521994689c1Smrg else 4522994689c1Smrg # Note the libdir as a future libdir. 4523994689c1Smrg case "$future_libdirs " in 4524994689c1Smrg *" $libdir "*) ;; 4525f353fbadSmrg *) func_append future_libdirs " $libdir" ;; 4526994689c1Smrg esac 4527994689c1Smrg fi 4528775e7de9Smrg 4529994689c1Smrg func_dirname "$file" "/" "" 45305ec34c4cSmrg dir=$func_dirname_result 4531f353fbadSmrg func_append dir "$objdir" 4532994689c1Smrg 4533994689c1Smrg if test -n "$relink_command"; then 4534994689c1Smrg # Determine the prefix the user has applied to our future dir. 4535994689c1Smrg inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` 4536994689c1Smrg 4537994689c1Smrg # Don't allow the user to place us outside of our expected 4538994689c1Smrg # location b/c this prevents finding dependent libraries that 4539994689c1Smrg # are installed to the same prefix. 4540994689c1Smrg # At present, this check doesn't affect windows .dll's that 4541994689c1Smrg # are installed into $libdir/../bin (currently, that works fine) 4542994689c1Smrg # but it's something to keep an eye on. 4543994689c1Smrg test "$inst_prefix_dir" = "$destdir" && \ 45445ec34c4cSmrg func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir" 4545994689c1Smrg 4546994689c1Smrg if test -n "$inst_prefix_dir"; then 4547994689c1Smrg # Stick the inst_prefix_dir data into the link command. 4548994689c1Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` 4549994689c1Smrg else 4550994689c1Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` 4551994689c1Smrg fi 4552994689c1Smrg 45535ec34c4cSmrg func_warning "relinking '$file'" 4554994689c1Smrg func_show_eval "$relink_command" \ 45555ec34c4cSmrg 'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"' 4556994689c1Smrg fi 4557994689c1Smrg 4558994689c1Smrg # See the names of the shared library. 4559994689c1Smrg set dummy $library_names; shift 4560994689c1Smrg if test -n "$1"; then 45615ec34c4cSmrg realname=$1 4562994689c1Smrg shift 4563994689c1Smrg 45645ec34c4cSmrg srcname=$realname 45655ec34c4cSmrg test -n "$relink_command" && srcname=${realname}T 4566994689c1Smrg 4567994689c1Smrg # Install the shared library and build the symlinks. 4568994689c1Smrg func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ 4569994689c1Smrg 'exit $?' 45705ec34c4cSmrg tstripme=$stripme 4571994689c1Smrg case $host_os in 4572994689c1Smrg cygwin* | mingw* | pw32* | cegcc*) 4573994689c1Smrg case $realname in 4574994689c1Smrg *.dll.a) 45755ec34c4cSmrg tstripme= 45765ec34c4cSmrg ;; 45775ec34c4cSmrg esac 45785ec34c4cSmrg ;; 45795ec34c4cSmrg os2*) 45805ec34c4cSmrg case $realname in 45815ec34c4cSmrg *_dll.a) 45825ec34c4cSmrg tstripme= 4583994689c1Smrg ;; 4584994689c1Smrg esac 4585775e7de9Smrg ;; 4586775e7de9Smrg esac 4587994689c1Smrg if test -n "$tstripme" && test -n "$striplib"; then 4588994689c1Smrg func_show_eval "$striplib $destdir/$realname" 'exit $?' 4589994689c1Smrg fi 4590994689c1Smrg 4591994689c1Smrg if test "$#" -gt 0; then 4592994689c1Smrg # Delete the old symlinks, and create new ones. 45935ec34c4cSmrg # Try 'ln -sf' first, because the 'ln' binary might depend on 4594994689c1Smrg # the symlink we replace! Solaris /bin/ln does not understand -f, 4595994689c1Smrg # so we also need to try rm && ln -s. 4596994689c1Smrg for linkname 4597994689c1Smrg do 4598994689c1Smrg test "$linkname" != "$realname" \ 4599994689c1Smrg && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" 4600994689c1Smrg done 4601994689c1Smrg fi 4602994689c1Smrg 4603994689c1Smrg # Do each command in the postinstall commands. 46045ec34c4cSmrg lib=$destdir/$realname 4605994689c1Smrg func_execute_cmds "$postinstall_cmds" 'exit $?' 4606994689c1Smrg fi 4607994689c1Smrg 4608994689c1Smrg # Install the pseudo-library for information purposes. 4609994689c1Smrg func_basename "$file" 46105ec34c4cSmrg name=$func_basename_result 46115ec34c4cSmrg instname=$dir/${name}i 4612994689c1Smrg func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' 4613994689c1Smrg 4614994689c1Smrg # Maybe install the static library, too. 4615f353fbadSmrg test -n "$old_library" && func_append staticlibs " $dir/$old_library" 4616775e7de9Smrg ;; 4617994689c1Smrg 4618994689c1Smrg *.lo) 4619994689c1Smrg # Install (i.e. copy) a libtool object. 4620994689c1Smrg 4621994689c1Smrg # Figure out destination file name, if it wasn't already specified. 4622994689c1Smrg if test -n "$destname"; then 46235ec34c4cSmrg destfile=$destdir/$destname 4624994689c1Smrg else 4625994689c1Smrg func_basename "$file" 46265ec34c4cSmrg destfile=$func_basename_result 46275ec34c4cSmrg destfile=$destdir/$destfile 4628994689c1Smrg fi 4629994689c1Smrg 4630994689c1Smrg # Deduce the name of the destination old-style object file. 4631994689c1Smrg case $destfile in 4632994689c1Smrg *.lo) 4633994689c1Smrg func_lo2o "$destfile" 4634994689c1Smrg staticdest=$func_lo2o_result 4635e1e1713cSmrg ;; 4636994689c1Smrg *.$objext) 46375ec34c4cSmrg staticdest=$destfile 4638994689c1Smrg destfile= 4639e1e1713cSmrg ;; 4640994689c1Smrg *) 46415ec34c4cSmrg func_fatal_help "cannot copy a libtool object to '$destfile'" 4642e1e1713cSmrg ;; 4643994689c1Smrg esac 4644994689c1Smrg 4645994689c1Smrg # Install the libtool object if requested. 4646994689c1Smrg test -n "$destfile" && \ 4647994689c1Smrg func_show_eval "$install_prog $file $destfile" 'exit $?' 4648994689c1Smrg 4649994689c1Smrg # Install the old object if enabled. 46505ec34c4cSmrg if test yes = "$build_old_libs"; then 4651994689c1Smrg # Deduce the name of the old-style object file. 4652994689c1Smrg func_lo2o "$file" 4653994689c1Smrg staticobj=$func_lo2o_result 4654994689c1Smrg func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' 4655e1e1713cSmrg fi 4656994689c1Smrg exit $EXIT_SUCCESS 4657994689c1Smrg ;; 46587a84e134Smrg 4659994689c1Smrg *) 4660994689c1Smrg # Figure out destination file name, if it wasn't already specified. 4661994689c1Smrg if test -n "$destname"; then 46625ec34c4cSmrg destfile=$destdir/$destname 4663e1e1713cSmrg else 4664994689c1Smrg func_basename "$file" 46655ec34c4cSmrg destfile=$func_basename_result 46665ec34c4cSmrg destfile=$destdir/$destfile 4667e1e1713cSmrg fi 46687a84e134Smrg 4669994689c1Smrg # If the file is missing, and there is a .exe on the end, strip it 4670994689c1Smrg # because it is most likely a libtool script we actually want to 4671994689c1Smrg # install 46725ec34c4cSmrg stripped_ext= 4673994689c1Smrg case $file in 4674994689c1Smrg *.exe) 4675994689c1Smrg if test ! -f "$file"; then 4676994689c1Smrg func_stripname '' '.exe' "$file" 4677994689c1Smrg file=$func_stripname_result 46785ec34c4cSmrg stripped_ext=.exe 4679994689c1Smrg fi 4680994689c1Smrg ;; 4681994689c1Smrg esac 46827a84e134Smrg 4683994689c1Smrg # Do a test to see if this is really a libtool program. 4684994689c1Smrg case $host in 4685994689c1Smrg *cygwin* | *mingw*) 4686994689c1Smrg if func_ltwrapper_executable_p "$file"; then 4687994689c1Smrg func_ltwrapper_scriptname "$file" 4688994689c1Smrg wrapper=$func_ltwrapper_scriptname_result 4689994689c1Smrg else 4690994689c1Smrg func_stripname '' '.exe' "$file" 4691994689c1Smrg wrapper=$func_stripname_result 4692994689c1Smrg fi 4693994689c1Smrg ;; 4694994689c1Smrg *) 4695994689c1Smrg wrapper=$file 4696994689c1Smrg ;; 4697994689c1Smrg esac 4698994689c1Smrg if func_ltwrapper_script_p "$wrapper"; then 4699994689c1Smrg notinst_deplibs= 4700994689c1Smrg relink_command= 47017a84e134Smrg 4702994689c1Smrg func_source "$wrapper" 47037a84e134Smrg 4704994689c1Smrg # Check the variables that should have been set. 4705994689c1Smrg test -z "$generated_by_libtool_version" && \ 47065ec34c4cSmrg func_fatal_error "invalid libtool wrapper script '$wrapper'" 47077a84e134Smrg 47085ec34c4cSmrg finalize=: 4709994689c1Smrg for lib in $notinst_deplibs; do 4710994689c1Smrg # Check to see that each library is installed. 4711994689c1Smrg libdir= 4712994689c1Smrg if test -f "$lib"; then 4713994689c1Smrg func_source "$lib" 4714e1e1713cSmrg fi 47155ec34c4cSmrg libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'` 4716994689c1Smrg if test -n "$libdir" && test ! -f "$libfile"; then 47175ec34c4cSmrg func_warning "'$lib' has not been installed in '$libdir'" 47185ec34c4cSmrg finalize=false 4719994689c1Smrg fi 4720994689c1Smrg done 47217a84e134Smrg 4722994689c1Smrg relink_command= 4723994689c1Smrg func_source "$wrapper" 47247a84e134Smrg 4725994689c1Smrg outputname= 47265ec34c4cSmrg if test no = "$fast_install" && test -n "$relink_command"; then 4727994689c1Smrg $opt_dry_run || { 47285ec34c4cSmrg if $finalize; then 4729994689c1Smrg tmpdir=`func_mktempdir` 4730994689c1Smrg func_basename "$file$stripped_ext" 47315ec34c4cSmrg file=$func_basename_result 47325ec34c4cSmrg outputname=$tmpdir/$file 4733994689c1Smrg # Replace the output file specification. 4734994689c1Smrg relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` 4735994689c1Smrg 47365ec34c4cSmrg $opt_quiet || { 47375b16253fSmrg func_quote_arg expand,pretty "$relink_command" 47385b16253fSmrg eval "func_echo $func_quote_arg_result" 4739994689c1Smrg } 4740994689c1Smrg if eval "$relink_command"; then : 4741994689c1Smrg else 47425ec34c4cSmrg func_error "error: relink '$file' with the above command before installing it" 4743994689c1Smrg $opt_dry_run || ${RM}r "$tmpdir" 4744994689c1Smrg continue 4745994689c1Smrg fi 47465ec34c4cSmrg file=$outputname 4747994689c1Smrg else 47485ec34c4cSmrg func_warning "cannot relink '$file'" 4749994689c1Smrg fi 4750994689c1Smrg } 4751e1e1713cSmrg else 4752994689c1Smrg # Install the binary that we compiled earlier. 4753994689c1Smrg file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` 4754e1e1713cSmrg fi 4755994689c1Smrg fi 47567a84e134Smrg 4757994689c1Smrg # remove .exe since cygwin /usr/bin/install will append another 4758994689c1Smrg # one anyway 4759994689c1Smrg case $install_prog,$host in 4760994689c1Smrg */usr/bin/install*,*cygwin*) 4761994689c1Smrg case $file:$destfile in 4762994689c1Smrg *.exe:*.exe) 4763994689c1Smrg # this is ok 4764994689c1Smrg ;; 4765994689c1Smrg *.exe:*) 4766994689c1Smrg destfile=$destfile.exe 4767994689c1Smrg ;; 4768994689c1Smrg *:*.exe) 4769994689c1Smrg func_stripname '' '.exe' "$destfile" 4770994689c1Smrg destfile=$func_stripname_result 4771994689c1Smrg ;; 4772994689c1Smrg esac 4773e1e1713cSmrg ;; 4774e1e1713cSmrg esac 4775994689c1Smrg func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' 4776994689c1Smrg $opt_dry_run || if test -n "$outputname"; then 4777994689c1Smrg ${RM}r "$tmpdir" 4778994689c1Smrg fi 4779994689c1Smrg ;; 4780994689c1Smrg esac 4781994689c1Smrg done 47827a84e134Smrg 4783994689c1Smrg for file in $staticlibs; do 4784994689c1Smrg func_basename "$file" 47855ec34c4cSmrg name=$func_basename_result 4786994689c1Smrg 4787994689c1Smrg # Set up the ranlib parameters. 47885ec34c4cSmrg oldlib=$destdir/$name 4789421c997bSmrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 4790421c997bSmrg tool_oldlib=$func_to_tool_file_result 4791994689c1Smrg 4792994689c1Smrg func_show_eval "$install_prog \$file \$oldlib" 'exit $?' 4793994689c1Smrg 4794994689c1Smrg if test -n "$stripme" && test -n "$old_striplib"; then 4795421c997bSmrg func_show_eval "$old_striplib $tool_oldlib" 'exit $?' 4796994689c1Smrg fi 4797994689c1Smrg 4798994689c1Smrg # Do each command in the postinstall commands. 4799994689c1Smrg func_execute_cmds "$old_postinstall_cmds" 'exit $?' 4800994689c1Smrg done 4801994689c1Smrg 4802994689c1Smrg test -n "$future_libdirs" && \ 48035ec34c4cSmrg func_warning "remember to run '$progname --finish$future_libdirs'" 4804994689c1Smrg 4805994689c1Smrg if test -n "$current_libdirs"; then 4806994689c1Smrg # Maybe just do a dry run. 4807994689c1Smrg $opt_dry_run && current_libdirs=" -n$current_libdirs" 48085ec34c4cSmrg exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs' 4809994689c1Smrg else 4810994689c1Smrg exit $EXIT_SUCCESS 4811994689c1Smrg fi 4812994689c1Smrg} 4813994689c1Smrg 48145ec34c4cSmrgtest install = "$opt_mode" && func_mode_install ${1+"$@"} 4815994689c1Smrg 4816994689c1Smrg 4817994689c1Smrg# func_generate_dlsyms outputname originator pic_p 4818994689c1Smrg# Extract symbols from dlprefiles and create ${outputname}S.o with 4819994689c1Smrg# a dlpreopen symbol table. 4820994689c1Smrgfunc_generate_dlsyms () 4821994689c1Smrg{ 48225ec34c4cSmrg $debug_cmd 48235ec34c4cSmrg 48245ec34c4cSmrg my_outputname=$1 48255ec34c4cSmrg my_originator=$2 48265ec34c4cSmrg my_pic_p=${3-false} 48275ec34c4cSmrg my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'` 4828994689c1Smrg my_dlsyms= 4829994689c1Smrg 48305ec34c4cSmrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 4831994689c1Smrg if test -n "$NM" && test -n "$global_symbol_pipe"; then 48325ec34c4cSmrg my_dlsyms=${my_outputname}S.c 4833994689c1Smrg else 4834994689c1Smrg func_error "not configured to extract global symbols from dlpreopened files" 4835994689c1Smrg fi 4836994689c1Smrg fi 4837994689c1Smrg 4838994689c1Smrg if test -n "$my_dlsyms"; then 4839994689c1Smrg case $my_dlsyms in 4840994689c1Smrg "") ;; 4841994689c1Smrg *.c) 4842994689c1Smrg # Discover the nlist of each of the dlfiles. 48435ec34c4cSmrg nlist=$output_objdir/$my_outputname.nm 4844994689c1Smrg 4845994689c1Smrg func_show_eval "$RM $nlist ${nlist}S ${nlist}T" 4846994689c1Smrg 4847994689c1Smrg # Parse the name list into a source file. 4848994689c1Smrg func_verbose "creating $output_objdir/$my_dlsyms" 4849994689c1Smrg 4850994689c1Smrg $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ 48515ec34c4cSmrg/* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */ 48525ec34c4cSmrg/* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */ 4853994689c1Smrg 4854994689c1Smrg#ifdef __cplusplus 4855994689c1Smrgextern \"C\" { 4856994689c1Smrg#endif 4857994689c1Smrg 48585ec34c4cSmrg#if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) 4859994689c1Smrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\" 4860994689c1Smrg#endif 4861994689c1Smrg 4862f353fbadSmrg/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ 48635ec34c4cSmrg#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE 48645ec34c4cSmrg/* DATA imports from DLLs on WIN32 can't be const, because runtime 4865f353fbadSmrg relocations are performed -- see ld's documentation on pseudo-relocs. */ 4866f353fbadSmrg# define LT_DLSYM_CONST 48675ec34c4cSmrg#elif defined __osf__ 4868f353fbadSmrg/* This system does not cope well with relocations in const data. */ 4869f353fbadSmrg# define LT_DLSYM_CONST 4870f353fbadSmrg#else 4871f353fbadSmrg# define LT_DLSYM_CONST const 4872f353fbadSmrg#endif 4873f353fbadSmrg 48745ec34c4cSmrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 48755ec34c4cSmrg 4876994689c1Smrg/* External symbol declarations for the compiler. */\ 4877994689c1Smrg" 4878994689c1Smrg 48795ec34c4cSmrg if test yes = "$dlself"; then 48805ec34c4cSmrg func_verbose "generating symbol list for '$output'" 4881994689c1Smrg 4882994689c1Smrg $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" 4883994689c1Smrg 4884994689c1Smrg # Add our own program objects to the symbol list. 4885994689c1Smrg progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` 4886994689c1Smrg for progfile in $progfiles; do 4887f353fbadSmrg func_to_tool_file "$progfile" func_convert_file_msys_to_w32 48885ec34c4cSmrg func_verbose "extracting global C symbols from '$func_to_tool_file_result'" 4889f353fbadSmrg $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" 4890994689c1Smrg done 4891994689c1Smrg 4892994689c1Smrg if test -n "$exclude_expsyms"; then 4893994689c1Smrg $opt_dry_run || { 4894994689c1Smrg eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' 4895994689c1Smrg eval '$MV "$nlist"T "$nlist"' 4896994689c1Smrg } 4897e1e1713cSmrg fi 4898994689c1Smrg 4899994689c1Smrg if test -n "$export_symbols_regex"; then 4900994689c1Smrg $opt_dry_run || { 4901994689c1Smrg eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' 4902994689c1Smrg eval '$MV "$nlist"T "$nlist"' 4903994689c1Smrg } 4904994689c1Smrg fi 4905994689c1Smrg 4906994689c1Smrg # Prepare the list of exported symbols 4907994689c1Smrg if test -z "$export_symbols"; then 49085ec34c4cSmrg export_symbols=$output_objdir/$outputname.exp 4909994689c1Smrg $opt_dry_run || { 4910994689c1Smrg $RM $export_symbols 49115ec34c4cSmrg eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' 4912994689c1Smrg case $host in 4913994689c1Smrg *cygwin* | *mingw* | *cegcc* ) 4914994689c1Smrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 4915994689c1Smrg eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' 4916994689c1Smrg ;; 4917994689c1Smrg esac 4918994689c1Smrg } 4919e1e1713cSmrg else 4920994689c1Smrg $opt_dry_run || { 49215ec34c4cSmrg eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' 4922994689c1Smrg eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' 4923994689c1Smrg eval '$MV "$nlist"T "$nlist"' 4924994689c1Smrg case $host in 4925994689c1Smrg *cygwin* | *mingw* | *cegcc* ) 4926994689c1Smrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 4927994689c1Smrg eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' 4928994689c1Smrg ;; 4929994689c1Smrg esac 4930994689c1Smrg } 4931e1e1713cSmrg fi 4932994689c1Smrg fi 49337a84e134Smrg 4934994689c1Smrg for dlprefile in $dlprefiles; do 49355ec34c4cSmrg func_verbose "extracting global C symbols from '$dlprefile'" 4936994689c1Smrg func_basename "$dlprefile" 49375ec34c4cSmrg name=$func_basename_result 4938f353fbadSmrg case $host in 4939f353fbadSmrg *cygwin* | *mingw* | *cegcc* ) 4940f353fbadSmrg # if an import library, we need to obtain dlname 4941f353fbadSmrg if func_win32_import_lib_p "$dlprefile"; then 4942f353fbadSmrg func_tr_sh "$dlprefile" 4943f353fbadSmrg eval "curr_lafile=\$libfile_$func_tr_sh_result" 49445ec34c4cSmrg dlprefile_dlbasename= 4945f353fbadSmrg if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then 4946f353fbadSmrg # Use subshell, to avoid clobbering current variable values 4947f353fbadSmrg dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` 49485ec34c4cSmrg if test -n "$dlprefile_dlname"; then 4949f353fbadSmrg func_basename "$dlprefile_dlname" 49505ec34c4cSmrg dlprefile_dlbasename=$func_basename_result 4951f353fbadSmrg else 4952f353fbadSmrg # no lafile. user explicitly requested -dlpreopen <import library>. 4953f353fbadSmrg $sharedlib_from_linklib_cmd "$dlprefile" 4954f353fbadSmrg dlprefile_dlbasename=$sharedlib_from_linklib_result 4955f353fbadSmrg fi 4956f353fbadSmrg fi 4957f353fbadSmrg $opt_dry_run || { 49585ec34c4cSmrg if test -n "$dlprefile_dlbasename"; then 4959f353fbadSmrg eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' 4960f353fbadSmrg else 4961f353fbadSmrg func_warning "Could not compute DLL name from $name" 4962f353fbadSmrg eval '$ECHO ": $name " >> "$nlist"' 4963f353fbadSmrg fi 4964f353fbadSmrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 4965f353fbadSmrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | 4966f353fbadSmrg $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" 4967f353fbadSmrg } 4968f353fbadSmrg else # not an import lib 4969f353fbadSmrg $opt_dry_run || { 4970f353fbadSmrg eval '$ECHO ": $name " >> "$nlist"' 4971f353fbadSmrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 4972f353fbadSmrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 4973f353fbadSmrg } 4974f353fbadSmrg fi 4975f353fbadSmrg ;; 4976f353fbadSmrg *) 4977f353fbadSmrg $opt_dry_run || { 4978f353fbadSmrg eval '$ECHO ": $name " >> "$nlist"' 4979f353fbadSmrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 4980f353fbadSmrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 4981f353fbadSmrg } 4982f353fbadSmrg ;; 4983f353fbadSmrg esac 4984994689c1Smrg done 4985994689c1Smrg 4986994689c1Smrg $opt_dry_run || { 4987994689c1Smrg # Make sure we have at least an empty file. 4988994689c1Smrg test -f "$nlist" || : > "$nlist" 4989994689c1Smrg 4990994689c1Smrg if test -n "$exclude_expsyms"; then 4991994689c1Smrg $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T 4992994689c1Smrg $MV "$nlist"T "$nlist" 4993e1e1713cSmrg fi 4994994689c1Smrg 4995994689c1Smrg # Try sorting and uniquifying the output. 4996994689c1Smrg if $GREP -v "^: " < "$nlist" | 4997994689c1Smrg if sort -k 3 </dev/null >/dev/null 2>&1; then 4998994689c1Smrg sort -k 3 4999994689c1Smrg else 5000994689c1Smrg sort +2 5001994689c1Smrg fi | 5002994689c1Smrg uniq > "$nlist"S; then 5003994689c1Smrg : 5004e1e1713cSmrg else 5005994689c1Smrg $GREP -v "^: " < "$nlist" > "$nlist"S 5006e1e1713cSmrg fi 50077a84e134Smrg 5008994689c1Smrg if test -f "$nlist"S; then 5009994689c1Smrg eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' 5010e1e1713cSmrg else 5011994689c1Smrg echo '/* NONE */' >> "$output_objdir/$my_dlsyms" 5012e1e1713cSmrg fi 50137a84e134Smrg 50145ec34c4cSmrg func_show_eval '$RM "${nlist}I"' 50155ec34c4cSmrg if test -n "$global_symbol_to_import"; then 50165ec34c4cSmrg eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I' 50175ec34c4cSmrg fi 50185ec34c4cSmrg 5019994689c1Smrg echo >> "$output_objdir/$my_dlsyms" "\ 50207a84e134Smrg 5021994689c1Smrg/* The mapping between symbol names and symbols. */ 5022994689c1Smrgtypedef struct { 5023994689c1Smrg const char *name; 5024994689c1Smrg void *address; 5025994689c1Smrg} lt_dlsymlist; 5026f353fbadSmrgextern LT_DLSYM_CONST lt_dlsymlist 50275ec34c4cSmrglt_${my_prefix}_LTX_preloaded_symbols[];\ 50285ec34c4cSmrg" 50295ec34c4cSmrg 50305ec34c4cSmrg if test -s "$nlist"I; then 50315ec34c4cSmrg echo >> "$output_objdir/$my_dlsyms" "\ 50325ec34c4cSmrgstatic void lt_syminit(void) 50335ec34c4cSmrg{ 50345ec34c4cSmrg LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols; 50355ec34c4cSmrg for (; symbol->name; ++symbol) 50365ec34c4cSmrg {" 50375ec34c4cSmrg $SED 's/.*/ if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms" 50385ec34c4cSmrg echo >> "$output_objdir/$my_dlsyms" "\ 50395ec34c4cSmrg } 50405ec34c4cSmrg}" 50415ec34c4cSmrg fi 50425ec34c4cSmrg echo >> "$output_objdir/$my_dlsyms" "\ 5043f353fbadSmrgLT_DLSYM_CONST lt_dlsymlist 5044994689c1Smrglt_${my_prefix}_LTX_preloaded_symbols[] = 50455ec34c4cSmrg{ {\"$my_originator\", (void *) 0}," 50465ec34c4cSmrg 50475ec34c4cSmrg if test -s "$nlist"I; then 50485ec34c4cSmrg echo >> "$output_objdir/$my_dlsyms" "\ 50495ec34c4cSmrg {\"@INIT@\", (void *) <_syminit}," 50505ec34c4cSmrg fi 50517a84e134Smrg 5052994689c1Smrg case $need_lib_prefix in 5053994689c1Smrg no) 5054994689c1Smrg eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" 5055994689c1Smrg ;; 5056994689c1Smrg *) 5057994689c1Smrg eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" 5058994689c1Smrg ;; 5059994689c1Smrg esac 5060994689c1Smrg echo >> "$output_objdir/$my_dlsyms" "\ 5061994689c1Smrg {0, (void *) 0} 5062994689c1Smrg}; 50637a84e134Smrg 5064994689c1Smrg/* This works around a problem in FreeBSD linker */ 5065994689c1Smrg#ifdef FREEBSD_WORKAROUND 5066994689c1Smrgstatic const void *lt_preloaded_setup() { 5067994689c1Smrg return lt_${my_prefix}_LTX_preloaded_symbols; 5068994689c1Smrg} 5069994689c1Smrg#endif 50707a84e134Smrg 5071994689c1Smrg#ifdef __cplusplus 5072994689c1Smrg} 5073994689c1Smrg#endif\ 5074994689c1Smrg" 5075994689c1Smrg } # !$opt_dry_run 5076775e7de9Smrg 5077994689c1Smrg pic_flag_for_symtable= 5078994689c1Smrg case "$compile_command " in 5079994689c1Smrg *" -static "*) ;; 5080994689c1Smrg *) 5081994689c1Smrg case $host in 5082994689c1Smrg # compiling the symbol table file with pic_flag works around 5083994689c1Smrg # a FreeBSD bug that causes programs to crash when -lm is 5084994689c1Smrg # linked before any other PIC object. But we must not use 5085994689c1Smrg # pic_flag when linking with -static. The problem exists in 5086994689c1Smrg # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. 5087421c997bSmrg *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) 5088994689c1Smrg pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; 5089994689c1Smrg *-*-hpux*) 5090994689c1Smrg pic_flag_for_symtable=" $pic_flag" ;; 5091994689c1Smrg *) 50925ec34c4cSmrg $my_pic_p && pic_flag_for_symtable=" $pic_flag" 5093994689c1Smrg ;; 5094994689c1Smrg esac 5095994689c1Smrg ;; 5096994689c1Smrg esac 5097994689c1Smrg symtab_cflags= 5098994689c1Smrg for arg in $LTCFLAGS; do 5099994689c1Smrg case $arg in 5100994689c1Smrg -pie | -fpie | -fPIE) ;; 5101f353fbadSmrg *) func_append symtab_cflags " $arg" ;; 5102994689c1Smrg esac 5103994689c1Smrg done 51047a84e134Smrg 5105994689c1Smrg # Now compile the dynamic symbol file. 5106994689c1Smrg func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' 51077a84e134Smrg 5108994689c1Smrg # Clean up the generated files. 51095ec34c4cSmrg func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"' 5110775e7de9Smrg 5111994689c1Smrg # Transform the symbol file into the correct name. 51125ec34c4cSmrg symfileobj=$output_objdir/${my_outputname}S.$objext 5113994689c1Smrg case $host in 5114994689c1Smrg *cygwin* | *mingw* | *cegcc* ) 5115994689c1Smrg if test -f "$output_objdir/$my_outputname.def"; then 5116994689c1Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 5117994689c1Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 5118994689c1Smrg else 5119994689c1Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 5120994689c1Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 5121994689c1Smrg fi 5122994689c1Smrg ;; 5123994689c1Smrg *) 5124994689c1Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 5125994689c1Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 5126994689c1Smrg ;; 5127994689c1Smrg esac 5128994689c1Smrg ;; 5129994689c1Smrg *) 51305ec34c4cSmrg func_fatal_error "unknown suffix for '$my_dlsyms'" 5131994689c1Smrg ;; 5132994689c1Smrg esac 5133994689c1Smrg else 5134994689c1Smrg # We keep going just in case the user didn't refer to 5135994689c1Smrg # lt_preloaded_symbols. The linker will fail if global_symbol_pipe 5136994689c1Smrg # really was required. 5137775e7de9Smrg 5138994689c1Smrg # Nullify the symbol file. 5139994689c1Smrg compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` 5140994689c1Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` 5141994689c1Smrg fi 5142994689c1Smrg} 5143775e7de9Smrg 51445ec34c4cSmrg# func_cygming_gnu_implib_p ARG 51455ec34c4cSmrg# This predicate returns with zero status (TRUE) if 51465ec34c4cSmrg# ARG is a GNU/binutils-style import library. Returns 51475ec34c4cSmrg# with nonzero status (FALSE) otherwise. 51485ec34c4cSmrgfunc_cygming_gnu_implib_p () 51495ec34c4cSmrg{ 51505ec34c4cSmrg $debug_cmd 51515ec34c4cSmrg 51525ec34c4cSmrg func_to_tool_file "$1" func_convert_file_msys_to_w32 51535ec34c4cSmrg 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)$'` 51545ec34c4cSmrg test -n "$func_cygming_gnu_implib_tmp" 51555ec34c4cSmrg} 51565ec34c4cSmrg 51575ec34c4cSmrg# func_cygming_ms_implib_p ARG 51585ec34c4cSmrg# This predicate returns with zero status (TRUE) if 51595ec34c4cSmrg# ARG is an MS-style import library. Returns 51605ec34c4cSmrg# with nonzero status (FALSE) otherwise. 51615ec34c4cSmrgfunc_cygming_ms_implib_p () 51625ec34c4cSmrg{ 51635ec34c4cSmrg $debug_cmd 51645ec34c4cSmrg 51655ec34c4cSmrg func_to_tool_file "$1" func_convert_file_msys_to_w32 51665ec34c4cSmrg func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` 51675ec34c4cSmrg test -n "$func_cygming_ms_implib_tmp" 51685ec34c4cSmrg} 51695ec34c4cSmrg 5170994689c1Smrg# func_win32_libid arg 5171994689c1Smrg# return the library type of file 'arg' 5172994689c1Smrg# 5173994689c1Smrg# Need a lot of goo to handle *both* DLLs and import libs 5174994689c1Smrg# Has to be a shell function in order to 'eat' the argument 5175994689c1Smrg# that is supplied when $file_magic_command is called. 5176994689c1Smrg# Despite the name, also deal with 64 bit binaries. 5177994689c1Smrgfunc_win32_libid () 5178994689c1Smrg{ 51795ec34c4cSmrg $debug_cmd 51805ec34c4cSmrg 51815ec34c4cSmrg win32_libid_type=unknown 5182994689c1Smrg win32_fileres=`file -L $1 2>/dev/null` 5183994689c1Smrg case $win32_fileres in 5184994689c1Smrg *ar\ archive\ import\ library*) # definitely import 5185994689c1Smrg win32_libid_type="x86 archive import" 5186994689c1Smrg ;; 5187994689c1Smrg *ar\ archive*) # could be an import, or static 5188994689c1Smrg # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. 5189994689c1Smrg if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | 5190994689c1Smrg $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then 51915ec34c4cSmrg case $nm_interface in 51925ec34c4cSmrg "MS dumpbin") 51935ec34c4cSmrg if func_cygming_ms_implib_p "$1" || 51945ec34c4cSmrg func_cygming_gnu_implib_p "$1" 51955ec34c4cSmrg then 51965ec34c4cSmrg win32_nmres=import 51975ec34c4cSmrg else 51985ec34c4cSmrg win32_nmres= 51995ec34c4cSmrg fi 52005ec34c4cSmrg ;; 52015ec34c4cSmrg *) 52025ec34c4cSmrg func_to_tool_file "$1" func_convert_file_msys_to_w32 52035ec34c4cSmrg win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | 52045ec34c4cSmrg $SED -n -e ' 5205994689c1Smrg 1,100{ 5206994689c1Smrg / I /{ 52075ec34c4cSmrg s|.*|import| 5208994689c1Smrg p 5209994689c1Smrg q 5210994689c1Smrg } 5211994689c1Smrg }'` 52125ec34c4cSmrg ;; 52135ec34c4cSmrg esac 5214994689c1Smrg case $win32_nmres in 5215994689c1Smrg import*) win32_libid_type="x86 archive import";; 5216994689c1Smrg *) win32_libid_type="x86 archive static";; 5217994689c1Smrg esac 5218994689c1Smrg fi 5219994689c1Smrg ;; 5220994689c1Smrg *DLL*) 5221994689c1Smrg win32_libid_type="x86 DLL" 5222994689c1Smrg ;; 5223994689c1Smrg *executable*) # but shell scripts are "executable" too... 5224994689c1Smrg case $win32_fileres in 5225994689c1Smrg *MS\ Windows\ PE\ Intel*) 5226994689c1Smrg win32_libid_type="x86 DLL" 5227994689c1Smrg ;; 5228994689c1Smrg esac 5229994689c1Smrg ;; 5230994689c1Smrg esac 5231994689c1Smrg $ECHO "$win32_libid_type" 5232994689c1Smrg} 5233775e7de9Smrg 5234f353fbadSmrg# func_cygming_dll_for_implib ARG 5235f353fbadSmrg# 5236f353fbadSmrg# Platform-specific function to extract the 5237f353fbadSmrg# name of the DLL associated with the specified 5238f353fbadSmrg# import library ARG. 5239f353fbadSmrg# Invoked by eval'ing the libtool variable 5240f353fbadSmrg# $sharedlib_from_linklib_cmd 5241f353fbadSmrg# Result is available in the variable 5242f353fbadSmrg# $sharedlib_from_linklib_result 5243f353fbadSmrgfunc_cygming_dll_for_implib () 5244f353fbadSmrg{ 52455ec34c4cSmrg $debug_cmd 52465ec34c4cSmrg 5247f353fbadSmrg sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` 5248f353fbadSmrg} 5249f353fbadSmrg 5250f353fbadSmrg# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs 5251f353fbadSmrg# 5252f353fbadSmrg# The is the core of a fallback implementation of a 5253f353fbadSmrg# platform-specific function to extract the name of the 5254f353fbadSmrg# DLL associated with the specified import library LIBNAME. 5255f353fbadSmrg# 5256f353fbadSmrg# SECTION_NAME is either .idata$6 or .idata$7, depending 5257f353fbadSmrg# on the platform and compiler that created the implib. 5258f353fbadSmrg# 5259f353fbadSmrg# Echos the name of the DLL associated with the 5260f353fbadSmrg# specified import library. 5261f353fbadSmrgfunc_cygming_dll_for_implib_fallback_core () 5262f353fbadSmrg{ 52635ec34c4cSmrg $debug_cmd 52645ec34c4cSmrg 5265f353fbadSmrg match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` 5266f353fbadSmrg $OBJDUMP -s --section "$1" "$2" 2>/dev/null | 5267f353fbadSmrg $SED '/^Contents of section '"$match_literal"':/{ 5268f353fbadSmrg # Place marker at beginning of archive member dllname section 5269f353fbadSmrg s/.*/====MARK====/ 5270f353fbadSmrg p 5271f353fbadSmrg d 5272f353fbadSmrg } 5273f353fbadSmrg # These lines can sometimes be longer than 43 characters, but 5274f353fbadSmrg # are always uninteresting 5275f353fbadSmrg /:[ ]*file format pe[i]\{,1\}-/d 5276f353fbadSmrg /^In archive [^:]*:/d 5277f353fbadSmrg # Ensure marker is printed 5278f353fbadSmrg /^====MARK====/p 5279f353fbadSmrg # Remove all lines with less than 43 characters 5280f353fbadSmrg /^.\{43\}/!d 5281f353fbadSmrg # From remaining lines, remove first 43 characters 5282f353fbadSmrg s/^.\{43\}//' | 5283f353fbadSmrg $SED -n ' 5284f353fbadSmrg # Join marker and all lines until next marker into a single line 5285f353fbadSmrg /^====MARK====/ b para 5286f353fbadSmrg H 5287f353fbadSmrg $ b para 5288f353fbadSmrg b 5289f353fbadSmrg :para 5290f353fbadSmrg x 5291f353fbadSmrg s/\n//g 5292f353fbadSmrg # Remove the marker 5293f353fbadSmrg s/^====MARK====// 5294f353fbadSmrg # Remove trailing dots and whitespace 5295f353fbadSmrg s/[\. \t]*$// 5296f353fbadSmrg # Print 5297f353fbadSmrg /./p' | 5298f353fbadSmrg # we now have a list, one entry per line, of the stringified 5299f353fbadSmrg # contents of the appropriate section of all members of the 53005ec34c4cSmrg # archive that possess that section. Heuristic: eliminate 53015ec34c4cSmrg # all those that have a first or second character that is 5302f353fbadSmrg # a '.' (that is, objdump's representation of an unprintable 5303f353fbadSmrg # character.) This should work for all archives with less than 5304f353fbadSmrg # 0x302f exports -- but will fail for DLLs whose name actually 5305f353fbadSmrg # begins with a literal '.' or a single character followed by 5306f353fbadSmrg # a '.'. 5307f353fbadSmrg # 5308f353fbadSmrg # Of those that remain, print the first one. 5309f353fbadSmrg $SED -e '/^\./d;/^.\./d;q' 5310f353fbadSmrg} 5311f353fbadSmrg 5312f353fbadSmrg# func_cygming_dll_for_implib_fallback ARG 5313f353fbadSmrg# Platform-specific function to extract the 5314f353fbadSmrg# name of the DLL associated with the specified 5315f353fbadSmrg# import library ARG. 5316f353fbadSmrg# 5317f353fbadSmrg# This fallback implementation is for use when $DLLTOOL 5318f353fbadSmrg# does not support the --identify-strict option. 5319f353fbadSmrg# Invoked by eval'ing the libtool variable 5320f353fbadSmrg# $sharedlib_from_linklib_cmd 5321f353fbadSmrg# Result is available in the variable 5322f353fbadSmrg# $sharedlib_from_linklib_result 5323f353fbadSmrgfunc_cygming_dll_for_implib_fallback () 5324f353fbadSmrg{ 53255ec34c4cSmrg $debug_cmd 53265ec34c4cSmrg 53275ec34c4cSmrg if func_cygming_gnu_implib_p "$1"; then 5328f353fbadSmrg # binutils import library 5329f353fbadSmrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` 53305ec34c4cSmrg elif func_cygming_ms_implib_p "$1"; then 5331f353fbadSmrg # ms-generated import library 5332f353fbadSmrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` 5333f353fbadSmrg else 5334f353fbadSmrg # unknown 53355ec34c4cSmrg sharedlib_from_linklib_result= 5336f353fbadSmrg fi 5337f353fbadSmrg} 53387a84e134Smrg 53397a84e134Smrg 5340994689c1Smrg# func_extract_an_archive dir oldlib 5341994689c1Smrgfunc_extract_an_archive () 5342994689c1Smrg{ 53435ec34c4cSmrg $debug_cmd 53445ec34c4cSmrg 53455ec34c4cSmrg f_ex_an_ar_dir=$1; shift 53465ec34c4cSmrg f_ex_an_ar_oldlib=$1 53475ec34c4cSmrg if test yes = "$lock_old_archive_extraction"; then 5348994689c1Smrg lockfile=$f_ex_an_ar_oldlib.lock 5349994689c1Smrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 5350994689c1Smrg func_echo "Waiting for $lockfile to be removed" 5351994689c1Smrg sleep 2 5352994689c1Smrg done 5353994689c1Smrg fi 5354994689c1Smrg func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ 5355994689c1Smrg 'stat=$?; rm -f "$lockfile"; exit $stat' 53565ec34c4cSmrg if test yes = "$lock_old_archive_extraction"; then 5357994689c1Smrg $opt_dry_run || rm -f "$lockfile" 5358994689c1Smrg fi 5359994689c1Smrg if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then 5360994689c1Smrg : 5361994689c1Smrg else 5362994689c1Smrg func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 5363994689c1Smrg fi 5364994689c1Smrg} 53657a84e134Smrg 53667a84e134Smrg 5367994689c1Smrg# func_extract_archives gentop oldlib ... 5368994689c1Smrgfunc_extract_archives () 5369994689c1Smrg{ 53705ec34c4cSmrg $debug_cmd 53715ec34c4cSmrg 53725ec34c4cSmrg my_gentop=$1; shift 5373994689c1Smrg my_oldlibs=${1+"$@"} 53745ec34c4cSmrg my_oldobjs= 53755ec34c4cSmrg my_xlib= 53765ec34c4cSmrg my_xabs= 53775ec34c4cSmrg my_xdir= 53787a84e134Smrg 5379994689c1Smrg for my_xlib in $my_oldlibs; do 5380994689c1Smrg # Extract the objects. 5381994689c1Smrg case $my_xlib in 53825ec34c4cSmrg [\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;; 5383994689c1Smrg *) my_xabs=`pwd`"/$my_xlib" ;; 5384994689c1Smrg esac 5385994689c1Smrg func_basename "$my_xlib" 53865ec34c4cSmrg my_xlib=$func_basename_result 5387994689c1Smrg my_xlib_u=$my_xlib 5388994689c1Smrg while :; do 5389994689c1Smrg case " $extracted_archives " in 5390994689c1Smrg *" $my_xlib_u "*) 5391994689c1Smrg func_arith $extracted_serial + 1 5392994689c1Smrg extracted_serial=$func_arith_result 5393994689c1Smrg my_xlib_u=lt$extracted_serial-$my_xlib ;; 5394994689c1Smrg *) break ;; 5395994689c1Smrg esac 5396994689c1Smrg done 5397994689c1Smrg extracted_archives="$extracted_archives $my_xlib_u" 53985ec34c4cSmrg my_xdir=$my_gentop/$my_xlib_u 5399775e7de9Smrg 5400994689c1Smrg func_mkdir_p "$my_xdir" 5401994689c1Smrg 5402994689c1Smrg case $host in 5403994689c1Smrg *-darwin*) 5404994689c1Smrg func_verbose "Extracting $my_xabs" 5405994689c1Smrg # Do not bother doing anything if just a dry run 5406994689c1Smrg $opt_dry_run || { 5407994689c1Smrg darwin_orig_dir=`pwd` 5408994689c1Smrg cd $my_xdir || exit $? 5409994689c1Smrg darwin_archive=$my_xabs 5410994689c1Smrg darwin_curdir=`pwd` 54115ec34c4cSmrg func_basename "$darwin_archive" 54125ec34c4cSmrg darwin_base_archive=$func_basename_result 5413994689c1Smrg darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` 5414994689c1Smrg if test -n "$darwin_arches"; then 5415994689c1Smrg darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` 5416994689c1Smrg darwin_arch= 5417994689c1Smrg func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" 54185ec34c4cSmrg for darwin_arch in $darwin_arches; do 54195ec34c4cSmrg func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch" 54205ec34c4cSmrg $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive" 54215ec34c4cSmrg cd "unfat-$$/$darwin_base_archive-$darwin_arch" 54225ec34c4cSmrg func_extract_an_archive "`pwd`" "$darwin_base_archive" 5423994689c1Smrg cd "$darwin_curdir" 54245ec34c4cSmrg $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" 5425994689c1Smrg done # $darwin_arches 5426994689c1Smrg ## Okay now we've a bunch of thin objects, gotta fatten them up :) 54275ec34c4cSmrg darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$sed_basename" | sort -u` 5428994689c1Smrg darwin_file= 5429994689c1Smrg darwin_files= 5430994689c1Smrg for darwin_file in $darwin_filelist; do 5431994689c1Smrg darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` 5432994689c1Smrg $LIPO -create -output "$darwin_file" $darwin_files 5433994689c1Smrg done # $darwin_filelist 5434994689c1Smrg $RM -rf unfat-$$ 5435994689c1Smrg cd "$darwin_orig_dir" 5436e1e1713cSmrg else 5437994689c1Smrg cd $darwin_orig_dir 5438994689c1Smrg func_extract_an_archive "$my_xdir" "$my_xabs" 5439994689c1Smrg fi # $darwin_arches 5440994689c1Smrg } # !$opt_dry_run 5441994689c1Smrg ;; 5442994689c1Smrg *) 5443994689c1Smrg func_extract_an_archive "$my_xdir" "$my_xabs" 5444994689c1Smrg ;; 5445994689c1Smrg esac 5446994689c1Smrg my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` 5447994689c1Smrg done 54487a84e134Smrg 54495ec34c4cSmrg func_extract_archives_result=$my_oldobjs 5450994689c1Smrg} 54517a84e134Smrg 54527a84e134Smrg 5453994689c1Smrg# func_emit_wrapper [arg=no] 5454994689c1Smrg# 5455994689c1Smrg# Emit a libtool wrapper script on stdout. 5456994689c1Smrg# Don't directly open a file because we may want to 5457994689c1Smrg# incorporate the script contents within a cygwin/mingw 5458994689c1Smrg# wrapper executable. Must ONLY be called from within 5459994689c1Smrg# func_mode_link because it depends on a number of variables 5460994689c1Smrg# set therein. 5461994689c1Smrg# 5462994689c1Smrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR 5463994689c1Smrg# variable will take. If 'yes', then the emitted script 54645ec34c4cSmrg# will assume that the directory where it is stored is 5465994689c1Smrg# the $objdir directory. This is a cygwin/mingw-specific 5466994689c1Smrg# behavior. 5467994689c1Smrgfunc_emit_wrapper () 5468994689c1Smrg{ 5469994689c1Smrg func_emit_wrapper_arg1=${1-no} 5470e1e1713cSmrg 5471994689c1Smrg $ECHO "\ 5472994689c1Smrg#! $SHELL 54737a84e134Smrg 5474994689c1Smrg# $output - temporary wrapper script for $objdir/$outputname 54755ec34c4cSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 5476994689c1Smrg# 5477994689c1Smrg# The $output program cannot be directly executed until all the libtool 5478994689c1Smrg# libraries that it depends on are installed. 5479994689c1Smrg# 5480994689c1Smrg# This wrapper script should never be moved out of the build directory. 5481994689c1Smrg# If it is, it will not operate correctly. 54827a84e134Smrg 5483994689c1Smrg# Sed substitution that helps us do robust quoting. It backslashifies 5484994689c1Smrg# metacharacters that are still active within double-quoted strings. 5485994689c1Smrgsed_quote_subst='$sed_quote_subst' 54867a84e134Smrg 5487994689c1Smrg# Be Bourne compatible 5488994689c1Smrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then 5489994689c1Smrg emulate sh 5490994689c1Smrg NULLCMD=: 5491994689c1Smrg # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which 5492994689c1Smrg # is contrary to our usage. Disable this feature. 5493994689c1Smrg alias -g '\${1+\"\$@\"}'='\"\$@\"' 5494994689c1Smrg setopt NO_GLOB_SUBST 5495994689c1Smrgelse 5496994689c1Smrg case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac 5497994689c1Smrgfi 5498994689c1SmrgBIN_SH=xpg4; export BIN_SH # for Tru64 5499994689c1SmrgDUALCASE=1; export DUALCASE # for MKS sh 55007a84e134Smrg 5501994689c1Smrg# The HP-UX ksh and POSIX shell print the target directory to stdout 5502994689c1Smrg# if CDPATH is set. 5503994689c1Smrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 55047a84e134Smrg 5505994689c1Smrgrelink_command=\"$relink_command\" 55067a84e134Smrg 5507994689c1Smrg# This environment variable determines our operation mode. 5508994689c1Smrgif test \"\$libtool_install_magic\" = \"$magic\"; then 5509994689c1Smrg # install mode needs the following variables: 5510994689c1Smrg generated_by_libtool_version='$macro_version' 5511994689c1Smrg notinst_deplibs='$notinst_deplibs' 5512994689c1Smrgelse 5513994689c1Smrg # When we are sourced in execute mode, \$file and \$ECHO are already set. 5514994689c1Smrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 5515994689c1Smrg file=\"\$0\"" 55167a84e134Smrg 55175b16253fSmrg func_quote_arg pretty "$ECHO" 55185b16253fSmrg qECHO=$func_quote_arg_result 5519994689c1Smrg $ECHO "\ 55207a84e134Smrg 5521994689c1Smrg# A function that is used when there is no print builtin or printf. 5522994689c1Smrgfunc_fallback_echo () 5523994689c1Smrg{ 5524994689c1Smrg eval 'cat <<_LTECHO_EOF 5525994689c1Smrg\$1 5526994689c1Smrg_LTECHO_EOF' 5527994689c1Smrg} 55285b16253fSmrg ECHO=$qECHO 5529994689c1Smrg fi 5530994689c1Smrg 5531994689c1Smrg# Very basic option parsing. These options are (a) specific to 5532994689c1Smrg# the libtool wrapper, (b) are identical between the wrapper 55335ec34c4cSmrg# /script/ and the wrapper /executable/ that is used only on 5534994689c1Smrg# windows platforms, and (c) all begin with the string "--lt-" 55355ec34c4cSmrg# (application programs are unlikely to have options that match 5536994689c1Smrg# this pattern). 5537994689c1Smrg# 5538994689c1Smrg# There are only two supported options: --lt-debug and 5539994689c1Smrg# --lt-dump-script. There is, deliberately, no --lt-help. 5540994689c1Smrg# 5541994689c1Smrg# The first argument to this parsing function should be the 5542994689c1Smrg# script's $0 value, followed by "$@". 5543994689c1Smrglt_option_debug= 5544994689c1Smrgfunc_parse_lt_options () 5545994689c1Smrg{ 5546994689c1Smrg lt_script_arg0=\$0 5547994689c1Smrg shift 5548994689c1Smrg for lt_opt 5549994689c1Smrg do 5550994689c1Smrg case \"\$lt_opt\" in 5551994689c1Smrg --lt-debug) lt_option_debug=1 ;; 5552994689c1Smrg --lt-dump-script) 5553994689c1Smrg lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` 5554994689c1Smrg test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. 5555994689c1Smrg lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` 5556994689c1Smrg cat \"\$lt_dump_D/\$lt_dump_F\" 5557994689c1Smrg exit 0 5558994689c1Smrg ;; 5559994689c1Smrg --lt-*) 5560994689c1Smrg \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 5561994689c1Smrg exit 1 5562e1e1713cSmrg ;; 5563994689c1Smrg esac 5564994689c1Smrg done 55657a84e134Smrg 5566994689c1Smrg # Print the debug banner immediately: 5567994689c1Smrg if test -n \"\$lt_option_debug\"; then 55685ec34c4cSmrg echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2 5569994689c1Smrg fi 5570994689c1Smrg} 55717a84e134Smrg 5572994689c1Smrg# Used when --lt-debug. Prints its arguments to stdout 5573994689c1Smrg# (redirection is the responsibility of the caller) 5574994689c1Smrgfunc_lt_dump_args () 5575994689c1Smrg{ 5576994689c1Smrg lt_dump_args_N=1; 5577994689c1Smrg for lt_arg 5578994689c1Smrg do 55795ec34c4cSmrg \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\" 5580994689c1Smrg lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` 5581994689c1Smrg done 5582994689c1Smrg} 55837a84e134Smrg 5584994689c1Smrg# Core function for launching the target application 5585994689c1Smrgfunc_exec_program_core () 5586994689c1Smrg{ 5587994689c1Smrg" 5588994689c1Smrg case $host in 5589994689c1Smrg # Backslashes separate directories on plain windows 5590994689c1Smrg *-*-mingw | *-*-os2* | *-cegcc*) 5591994689c1Smrg $ECHO "\ 5592994689c1Smrg if test -n \"\$lt_option_debug\"; then 55935ec34c4cSmrg \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2 5594994689c1Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 5595e1e1713cSmrg fi 5596994689c1Smrg exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} 5597994689c1Smrg" 5598994689c1Smrg ;; 55997a84e134Smrg 5600994689c1Smrg *) 5601994689c1Smrg $ECHO "\ 5602994689c1Smrg if test -n \"\$lt_option_debug\"; then 56035ec34c4cSmrg \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2 5604994689c1Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 5605e1e1713cSmrg fi 5606994689c1Smrg exec \"\$progdir/\$program\" \${1+\"\$@\"} 5607994689c1Smrg" 5608994689c1Smrg ;; 5609994689c1Smrg esac 5610994689c1Smrg $ECHO "\ 5611994689c1Smrg \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 5612994689c1Smrg exit 1 5613994689c1Smrg} 56147a84e134Smrg 5615994689c1Smrg# A function to encapsulate launching the target application 5616994689c1Smrg# Strips options in the --lt-* namespace from \$@ and 5617994689c1Smrg# launches target application with the remaining arguments. 5618994689c1Smrgfunc_exec_program () 5619994689c1Smrg{ 5620421c997bSmrg case \" \$* \" in 5621421c997bSmrg *\\ --lt-*) 5622421c997bSmrg for lt_wr_arg 5623421c997bSmrg do 5624421c997bSmrg case \$lt_wr_arg in 5625421c997bSmrg --lt-*) ;; 5626421c997bSmrg *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; 5627421c997bSmrg esac 5628421c997bSmrg shift 5629421c997bSmrg done ;; 5630421c997bSmrg esac 5631994689c1Smrg func_exec_program_core \${1+\"\$@\"} 5632994689c1Smrg} 56337a84e134Smrg 5634994689c1Smrg # Parse options 5635994689c1Smrg func_parse_lt_options \"\$0\" \${1+\"\$@\"} 56367a84e134Smrg 5637994689c1Smrg # Find the directory that this script lives in. 5638994689c1Smrg thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` 5639994689c1Smrg test \"x\$thisdir\" = \"x\$file\" && thisdir=. 56407a84e134Smrg 5641994689c1Smrg # Follow symbolic links until we get to the real thisdir. 5642994689c1Smrg file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` 5643994689c1Smrg while test -n \"\$file\"; do 5644994689c1Smrg destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` 56457a84e134Smrg 5646994689c1Smrg # If there was a directory component, then change thisdir. 5647994689c1Smrg if test \"x\$destdir\" != \"x\$file\"; then 5648994689c1Smrg case \"\$destdir\" in 5649994689c1Smrg [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; 5650994689c1Smrg *) thisdir=\"\$thisdir/\$destdir\" ;; 5651994689c1Smrg esac 5652994689c1Smrg fi 56537a84e134Smrg 5654994689c1Smrg file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` 5655994689c1Smrg file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` 5656994689c1Smrg done 56577a84e134Smrg 5658994689c1Smrg # Usually 'no', except on cygwin/mingw when embedded into 5659994689c1Smrg # the cwrapper. 5660994689c1Smrg WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 5661994689c1Smrg if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then 5662994689c1Smrg # special case for '.' 5663994689c1Smrg if test \"\$thisdir\" = \".\"; then 5664994689c1Smrg thisdir=\`pwd\` 5665994689c1Smrg fi 5666994689c1Smrg # remove .libs from thisdir 5667994689c1Smrg case \"\$thisdir\" in 5668994689c1Smrg *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; 5669994689c1Smrg $objdir ) thisdir=. ;; 5670994689c1Smrg esac 5671994689c1Smrg fi 56727a84e134Smrg 5673994689c1Smrg # Try to get the absolute directory name. 5674994689c1Smrg absdir=\`cd \"\$thisdir\" && pwd\` 5675994689c1Smrg test -n \"\$absdir\" && thisdir=\"\$absdir\" 5676994689c1Smrg" 56777a84e134Smrg 56785ec34c4cSmrg if test yes = "$fast_install"; then 5679994689c1Smrg $ECHO "\ 5680994689c1Smrg program=lt-'$outputname'$exeext 5681994689c1Smrg progdir=\"\$thisdir/$objdir\" 56827a84e134Smrg 5683994689c1Smrg if test ! -f \"\$progdir/\$program\" || 56845ec34c4cSmrg { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\ 5685994689c1Smrg test \"X\$file\" != \"X\$progdir/\$program\"; }; then 56867a84e134Smrg 5687994689c1Smrg file=\"\$\$-\$program\" 56887a84e134Smrg 5689994689c1Smrg if test ! -d \"\$progdir\"; then 5690994689c1Smrg $MKDIR \"\$progdir\" 5691994689c1Smrg else 5692994689c1Smrg $RM \"\$progdir/\$file\" 5693994689c1Smrg fi" 56947a84e134Smrg 5695994689c1Smrg $ECHO "\ 56967a84e134Smrg 5697994689c1Smrg # relink executable if necessary 5698994689c1Smrg if test -n \"\$relink_command\"; then 5699994689c1Smrg if relink_command_output=\`eval \$relink_command 2>&1\`; then : 5700994689c1Smrg else 57015ec34c4cSmrg \$ECHO \"\$relink_command_output\" >&2 5702994689c1Smrg $RM \"\$progdir/\$file\" 5703994689c1Smrg exit 1 5704994689c1Smrg fi 5705994689c1Smrg fi 57067a84e134Smrg 5707994689c1Smrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || 5708994689c1Smrg { $RM \"\$progdir/\$program\"; 5709994689c1Smrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } 5710994689c1Smrg $RM \"\$progdir/\$file\" 5711994689c1Smrg fi" 5712994689c1Smrg else 5713994689c1Smrg $ECHO "\ 5714994689c1Smrg program='$outputname' 5715994689c1Smrg progdir=\"\$thisdir/$objdir\" 5716994689c1Smrg" 5717994689c1Smrg fi 5718775e7de9Smrg 5719994689c1Smrg $ECHO "\ 57207a84e134Smrg 5721994689c1Smrg if test -f \"\$progdir/\$program\"; then" 57227a84e134Smrg 5723f353fbadSmrg # fixup the dll searchpath if we need to. 5724f353fbadSmrg # 5725f353fbadSmrg # Fix the DLL searchpath if we need to. Do this before prepending 5726f353fbadSmrg # to shlibpath, because on Windows, both are PATH and uninstalled 5727f353fbadSmrg # libraries must come first. 5728f353fbadSmrg if test -n "$dllsearchpath"; then 5729f353fbadSmrg $ECHO "\ 5730f353fbadSmrg # Add the dll search path components to the executable PATH 5731f353fbadSmrg PATH=$dllsearchpath:\$PATH 5732f353fbadSmrg" 5733f353fbadSmrg fi 5734f353fbadSmrg 5735994689c1Smrg # Export our shlibpath_var if we have one. 57365ec34c4cSmrg if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 5737994689c1Smrg $ECHO "\ 5738994689c1Smrg # Add our own library path to $shlibpath_var 5739994689c1Smrg $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" 57407a84e134Smrg 5741994689c1Smrg # Some systems cannot cope with colon-terminated $shlibpath_var 5742994689c1Smrg # The second colon is a workaround for a bug in BeOS R4 sed 5743994689c1Smrg $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` 57447a84e134Smrg 5745994689c1Smrg export $shlibpath_var 5746994689c1Smrg" 5747994689c1Smrg fi 57487a84e134Smrg 5749994689c1Smrg $ECHO "\ 5750994689c1Smrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 5751994689c1Smrg # Run the actual program with our arguments. 5752994689c1Smrg func_exec_program \${1+\"\$@\"} 5753994689c1Smrg fi 5754994689c1Smrg else 5755994689c1Smrg # The program doesn't exist. 57565ec34c4cSmrg \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2 5757994689c1Smrg \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 5758994689c1Smrg \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 5759994689c1Smrg exit 1 5760994689c1Smrg fi 5761994689c1Smrgfi\ 5762994689c1Smrg" 5763994689c1Smrg} 57647a84e134Smrg 57657a84e134Smrg 5766994689c1Smrg# func_emit_cwrapperexe_src 5767994689c1Smrg# emit the source code for a wrapper executable on stdout 5768994689c1Smrg# Must ONLY be called from within func_mode_link because 5769994689c1Smrg# it depends on a number of variable set therein. 5770994689c1Smrgfunc_emit_cwrapperexe_src () 5771994689c1Smrg{ 5772994689c1Smrg cat <<EOF 57737a84e134Smrg 5774994689c1Smrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname 57755ec34c4cSmrg Generated by $PROGRAM (GNU $PACKAGE) $VERSION 57767a84e134Smrg 5777994689c1Smrg The $output program cannot be directly executed until all the libtool 5778994689c1Smrg libraries that it depends on are installed. 57797a84e134Smrg 5780994689c1Smrg This wrapper executable should never be moved out of the build directory. 5781994689c1Smrg If it is, it will not operate correctly. 5782994689c1Smrg*/ 5783994689c1SmrgEOF 5784994689c1Smrg cat <<"EOF" 5785994689c1Smrg#ifdef _MSC_VER 5786994689c1Smrg# define _CRT_SECURE_NO_DEPRECATE 1 5787994689c1Smrg#endif 5788994689c1Smrg#include <stdio.h> 5789994689c1Smrg#include <stdlib.h> 5790994689c1Smrg#ifdef _MSC_VER 5791994689c1Smrg# include <direct.h> 5792994689c1Smrg# include <process.h> 5793994689c1Smrg# include <io.h> 5794994689c1Smrg#else 5795994689c1Smrg# include <unistd.h> 5796994689c1Smrg# include <stdint.h> 5797994689c1Smrg# ifdef __CYGWIN__ 5798994689c1Smrg# include <io.h> 5799994689c1Smrg# endif 5800994689c1Smrg#endif 5801994689c1Smrg#include <malloc.h> 5802994689c1Smrg#include <stdarg.h> 5803994689c1Smrg#include <assert.h> 5804994689c1Smrg#include <string.h> 5805994689c1Smrg#include <ctype.h> 5806994689c1Smrg#include <errno.h> 5807994689c1Smrg#include <fcntl.h> 5808994689c1Smrg#include <sys/stat.h> 58097a84e134Smrg 58105ec34c4cSmrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 58115ec34c4cSmrg 5812994689c1Smrg/* declarations of non-ANSI functions */ 58135ec34c4cSmrg#if defined __MINGW32__ 5814994689c1Smrg# ifdef __STRICT_ANSI__ 5815994689c1Smrgint _putenv (const char *); 5816994689c1Smrg# endif 58175ec34c4cSmrg#elif defined __CYGWIN__ 5818994689c1Smrg# ifdef __STRICT_ANSI__ 5819994689c1Smrgchar *realpath (const char *, char *); 5820994689c1Smrgint putenv (char *); 5821994689c1Smrgint setenv (const char *, const char *, int); 5822994689c1Smrg# endif 58235ec34c4cSmrg/* #elif defined other_platform || defined ... */ 5824994689c1Smrg#endif 58257a84e134Smrg 5826994689c1Smrg/* portability defines, excluding path handling macros */ 58275ec34c4cSmrg#if defined _MSC_VER 5828994689c1Smrg# define setmode _setmode 5829994689c1Smrg# define stat _stat 5830994689c1Smrg# define chmod _chmod 5831994689c1Smrg# define getcwd _getcwd 5832994689c1Smrg# define putenv _putenv 5833994689c1Smrg# define S_IXUSR _S_IEXEC 58345ec34c4cSmrg#elif defined __MINGW32__ 5835994689c1Smrg# define setmode _setmode 5836994689c1Smrg# define stat _stat 5837994689c1Smrg# define chmod _chmod 5838994689c1Smrg# define getcwd _getcwd 5839994689c1Smrg# define putenv _putenv 58405ec34c4cSmrg#elif defined __CYGWIN__ 5841994689c1Smrg# define HAVE_SETENV 5842994689c1Smrg# define FOPEN_WB "wb" 58435ec34c4cSmrg/* #elif defined other platforms ... */ 5844994689c1Smrg#endif 58457a84e134Smrg 58465ec34c4cSmrg#if defined PATH_MAX 5847994689c1Smrg# define LT_PATHMAX PATH_MAX 58485ec34c4cSmrg#elif defined MAXPATHLEN 5849994689c1Smrg# define LT_PATHMAX MAXPATHLEN 5850994689c1Smrg#else 5851994689c1Smrg# define LT_PATHMAX 1024 5852994689c1Smrg#endif 58537a84e134Smrg 5854994689c1Smrg#ifndef S_IXOTH 5855994689c1Smrg# define S_IXOTH 0 5856994689c1Smrg#endif 5857994689c1Smrg#ifndef S_IXGRP 5858994689c1Smrg# define S_IXGRP 0 5859994689c1Smrg#endif 58607a84e134Smrg 5861994689c1Smrg/* path handling portability macros */ 5862994689c1Smrg#ifndef DIR_SEPARATOR 5863994689c1Smrg# define DIR_SEPARATOR '/' 5864994689c1Smrg# define PATH_SEPARATOR ':' 5865994689c1Smrg#endif 58667a84e134Smrg 58675ec34c4cSmrg#if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \ 58685ec34c4cSmrg defined __OS2__ 5869994689c1Smrg# define HAVE_DOS_BASED_FILE_SYSTEM 5870994689c1Smrg# define FOPEN_WB "wb" 5871994689c1Smrg# ifndef DIR_SEPARATOR_2 5872994689c1Smrg# define DIR_SEPARATOR_2 '\\' 5873994689c1Smrg# endif 5874994689c1Smrg# ifndef PATH_SEPARATOR_2 5875994689c1Smrg# define PATH_SEPARATOR_2 ';' 5876994689c1Smrg# endif 5877994689c1Smrg#endif 58787a84e134Smrg 5879994689c1Smrg#ifndef DIR_SEPARATOR_2 5880994689c1Smrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) 5881994689c1Smrg#else /* DIR_SEPARATOR_2 */ 5882994689c1Smrg# define IS_DIR_SEPARATOR(ch) \ 5883994689c1Smrg (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) 5884994689c1Smrg#endif /* DIR_SEPARATOR_2 */ 58857a84e134Smrg 5886994689c1Smrg#ifndef PATH_SEPARATOR_2 5887994689c1Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) 5888994689c1Smrg#else /* PATH_SEPARATOR_2 */ 5889994689c1Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) 5890994689c1Smrg#endif /* PATH_SEPARATOR_2 */ 5891994689c1Smrg 5892994689c1Smrg#ifndef FOPEN_WB 5893994689c1Smrg# define FOPEN_WB "w" 5894994689c1Smrg#endif 5895994689c1Smrg#ifndef _O_BINARY 5896994689c1Smrg# define _O_BINARY 0 5897994689c1Smrg#endif 5898994689c1Smrg 5899994689c1Smrg#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) 5900994689c1Smrg#define XFREE(stale) do { \ 59015ec34c4cSmrg if (stale) { free (stale); stale = 0; } \ 5902994689c1Smrg} while (0) 5903994689c1Smrg 59045ec34c4cSmrg#if defined LT_DEBUGWRAPPER 5905994689c1Smrgstatic int lt_debug = 1; 5906994689c1Smrg#else 5907994689c1Smrgstatic int lt_debug = 0; 5908994689c1Smrg#endif 5909994689c1Smrg 5910994689c1Smrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ 5911994689c1Smrg 5912994689c1Smrgvoid *xmalloc (size_t num); 5913994689c1Smrgchar *xstrdup (const char *string); 5914994689c1Smrgconst char *base_name (const char *name); 5915994689c1Smrgchar *find_executable (const char *wrapper); 5916994689c1Smrgchar *chase_symlinks (const char *pathspec); 5917994689c1Smrgint make_executable (const char *path); 5918994689c1Smrgint check_executable (const char *path); 5919994689c1Smrgchar *strendzap (char *str, const char *pat); 5920994689c1Smrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...); 5921994689c1Smrgvoid lt_fatal (const char *file, int line, const char *message, ...); 5922994689c1Smrgstatic const char *nonnull (const char *s); 5923994689c1Smrgstatic const char *nonempty (const char *s); 5924994689c1Smrgvoid lt_setenv (const char *name, const char *value); 5925994689c1Smrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end); 5926994689c1Smrgvoid lt_update_exe_path (const char *name, const char *value); 5927994689c1Smrgvoid lt_update_lib_path (const char *name, const char *value); 5928994689c1Smrgchar **prepare_spawn (char **argv); 5929994689c1Smrgvoid lt_dump_script (FILE *f); 5930994689c1SmrgEOF 5931994689c1Smrg 5932994689c1Smrg cat <<EOF 59335ec34c4cSmrg#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5) 59345ec34c4cSmrg# define externally_visible volatile 59355ec34c4cSmrg#else 59365ec34c4cSmrg# define externally_visible __attribute__((externally_visible)) volatile 59375ec34c4cSmrg#endif 59385ec34c4cSmrgexternally_visible const char * MAGIC_EXE = "$magic_exe"; 5939994689c1Smrgconst char * LIB_PATH_VARNAME = "$shlibpath_var"; 5940994689c1SmrgEOF 5941994689c1Smrg 59425ec34c4cSmrg if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 5943f353fbadSmrg func_to_host_path "$temp_rpath" 5944994689c1Smrg cat <<EOF 5945f353fbadSmrgconst char * LIB_PATH_VALUE = "$func_to_host_path_result"; 5946e1e1713cSmrgEOF 5947e1e1713cSmrg else 5948994689c1Smrg cat <<"EOF" 5949994689c1Smrgconst char * LIB_PATH_VALUE = ""; 5950994689c1SmrgEOF 5951e1e1713cSmrg fi 5952994689c1Smrg 5953994689c1Smrg if test -n "$dllsearchpath"; then 5954f353fbadSmrg func_to_host_path "$dllsearchpath:" 5955994689c1Smrg cat <<EOF 5956994689c1Smrgconst char * EXE_PATH_VARNAME = "PATH"; 5957f353fbadSmrgconst char * EXE_PATH_VALUE = "$func_to_host_path_result"; 5958994689c1SmrgEOF 5959e1e1713cSmrg else 5960994689c1Smrg cat <<"EOF" 5961994689c1Smrgconst char * EXE_PATH_VARNAME = ""; 5962994689c1Smrgconst char * EXE_PATH_VALUE = ""; 5963994689c1SmrgEOF 5964e1e1713cSmrg fi 5965994689c1Smrg 59665ec34c4cSmrg if test yes = "$fast_install"; then 5967994689c1Smrg cat <<EOF 5968994689c1Smrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */ 5969994689c1SmrgEOF 5970e1e1713cSmrg else 5971994689c1Smrg cat <<EOF 5972994689c1Smrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */ 5973994689c1SmrgEOF 5974e1e1713cSmrg fi 59757a84e134Smrg 59767a84e134Smrg 5977994689c1Smrg cat <<"EOF" 59787a84e134Smrg 5979994689c1Smrg#define LTWRAPPER_OPTION_PREFIX "--lt-" 59807a84e134Smrg 5981994689c1Smrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX; 5982994689c1Smrgstatic const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script"; 5983994689c1Smrgstatic const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug"; 59847a84e134Smrg 5985994689c1Smrgint 5986994689c1Smrgmain (int argc, char *argv[]) 5987994689c1Smrg{ 5988994689c1Smrg char **newargz; 5989994689c1Smrg int newargc; 5990994689c1Smrg char *tmp_pathspec; 5991994689c1Smrg char *actual_cwrapper_path; 5992994689c1Smrg char *actual_cwrapper_name; 5993994689c1Smrg char *target_name; 5994994689c1Smrg char *lt_argv_zero; 59955ec34c4cSmrg int rval = 127; 59967a84e134Smrg 5997994689c1Smrg int i; 59987a84e134Smrg 5999994689c1Smrg program_name = (char *) xstrdup (base_name (argv[0])); 60005ec34c4cSmrg newargz = XMALLOC (char *, (size_t) argc + 1); 60017a84e134Smrg 6002994689c1Smrg /* very simple arg parsing; don't want to rely on getopt 6003994689c1Smrg * also, copy all non cwrapper options to newargz, except 6004994689c1Smrg * argz[0], which is handled differently 6005994689c1Smrg */ 6006994689c1Smrg newargc=0; 6007994689c1Smrg for (i = 1; i < argc; i++) 6008994689c1Smrg { 60095ec34c4cSmrg if (STREQ (argv[i], dumpscript_opt)) 6010994689c1Smrg { 6011994689c1SmrgEOF 60125ec34c4cSmrg case $host in 6013994689c1Smrg *mingw* | *cygwin* ) 6014994689c1Smrg # make stdout use "unix" line endings 6015994689c1Smrg echo " setmode(1,_O_BINARY);" 6016994689c1Smrg ;; 6017e1e1713cSmrg esac 60187a84e134Smrg 6019994689c1Smrg cat <<"EOF" 6020994689c1Smrg lt_dump_script (stdout); 6021994689c1Smrg return 0; 6022994689c1Smrg } 60235ec34c4cSmrg if (STREQ (argv[i], debug_opt)) 6024994689c1Smrg { 6025994689c1Smrg lt_debug = 1; 6026994689c1Smrg continue; 6027994689c1Smrg } 60285ec34c4cSmrg if (STREQ (argv[i], ltwrapper_option_prefix)) 6029994689c1Smrg { 6030994689c1Smrg /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX 6031994689c1Smrg namespace, but it is not one of the ones we know about and 6032994689c1Smrg have already dealt with, above (inluding dump-script), then 6033994689c1Smrg report an error. Otherwise, targets might begin to believe 6034994689c1Smrg they are allowed to use options in the LTWRAPPER_OPTION_PREFIX 6035994689c1Smrg namespace. The first time any user complains about this, we'll 6036994689c1Smrg need to make LTWRAPPER_OPTION_PREFIX a configure-time option 6037994689c1Smrg or a configure.ac-settable value. 6038994689c1Smrg */ 6039994689c1Smrg lt_fatal (__FILE__, __LINE__, 6040994689c1Smrg "unrecognized %s option: '%s'", 6041994689c1Smrg ltwrapper_option_prefix, argv[i]); 6042994689c1Smrg } 6043994689c1Smrg /* otherwise ... */ 6044994689c1Smrg newargz[++newargc] = xstrdup (argv[i]); 6045994689c1Smrg } 6046994689c1Smrg newargz[++newargc] = NULL; 60477a84e134Smrg 6048994689c1SmrgEOF 6049994689c1Smrg cat <<EOF 6050994689c1Smrg /* The GNU banner must be the first non-error debug message */ 60515ec34c4cSmrg lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE) $VERSION\n"); 6052994689c1SmrgEOF 6053994689c1Smrg cat <<"EOF" 6054994689c1Smrg lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]); 6055994689c1Smrg lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name); 6056994689c1Smrg 6057994689c1Smrg tmp_pathspec = find_executable (argv[0]); 6058994689c1Smrg if (tmp_pathspec == NULL) 6059994689c1Smrg lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]); 6060994689c1Smrg lt_debugprintf (__FILE__, __LINE__, 6061994689c1Smrg "(main) found exe (before symlink chase) at: %s\n", 6062994689c1Smrg tmp_pathspec); 6063994689c1Smrg 6064994689c1Smrg actual_cwrapper_path = chase_symlinks (tmp_pathspec); 6065994689c1Smrg lt_debugprintf (__FILE__, __LINE__, 6066994689c1Smrg "(main) found exe (after symlink chase) at: %s\n", 6067994689c1Smrg actual_cwrapper_path); 6068994689c1Smrg XFREE (tmp_pathspec); 6069994689c1Smrg 6070994689c1Smrg actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path)); 6071994689c1Smrg strendzap (actual_cwrapper_path, actual_cwrapper_name); 6072994689c1Smrg 6073994689c1Smrg /* wrapper name transforms */ 6074994689c1Smrg strendzap (actual_cwrapper_name, ".exe"); 6075994689c1Smrg tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1); 6076994689c1Smrg XFREE (actual_cwrapper_name); 6077994689c1Smrg actual_cwrapper_name = tmp_pathspec; 6078994689c1Smrg tmp_pathspec = 0; 6079994689c1Smrg 6080994689c1Smrg /* target_name transforms -- use actual target program name; might have lt- prefix */ 6081994689c1Smrg target_name = xstrdup (base_name (TARGET_PROGRAM_NAME)); 6082994689c1Smrg strendzap (target_name, ".exe"); 6083994689c1Smrg tmp_pathspec = lt_extend_str (target_name, ".exe", 1); 6084994689c1Smrg XFREE (target_name); 6085994689c1Smrg target_name = tmp_pathspec; 6086994689c1Smrg tmp_pathspec = 0; 6087994689c1Smrg 6088994689c1Smrg lt_debugprintf (__FILE__, __LINE__, 6089994689c1Smrg "(main) libtool target name: %s\n", 6090994689c1Smrg target_name); 6091994689c1SmrgEOF 60927a84e134Smrg 6093994689c1Smrg cat <<EOF 6094994689c1Smrg newargz[0] = 6095994689c1Smrg XMALLOC (char, (strlen (actual_cwrapper_path) + 6096994689c1Smrg strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1)); 6097994689c1Smrg strcpy (newargz[0], actual_cwrapper_path); 6098994689c1Smrg strcat (newargz[0], "$objdir"); 6099994689c1Smrg strcat (newargz[0], "/"); 6100994689c1SmrgEOF 61017a84e134Smrg 6102994689c1Smrg cat <<"EOF" 6103994689c1Smrg /* stop here, and copy so we don't have to do this twice */ 6104994689c1Smrg tmp_pathspec = xstrdup (newargz[0]); 61057a84e134Smrg 6106994689c1Smrg /* do NOT want the lt- prefix here, so use actual_cwrapper_name */ 6107994689c1Smrg strcat (newargz[0], actual_cwrapper_name); 61087a84e134Smrg 6109994689c1Smrg /* DO want the lt- prefix here if it exists, so use target_name */ 6110994689c1Smrg lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1); 6111994689c1Smrg XFREE (tmp_pathspec); 6112994689c1Smrg tmp_pathspec = NULL; 6113994689c1SmrgEOF 61147a84e134Smrg 6115994689c1Smrg case $host_os in 6116994689c1Smrg mingw*) 6117994689c1Smrg cat <<"EOF" 6118994689c1Smrg { 6119994689c1Smrg char* p; 6120994689c1Smrg while ((p = strchr (newargz[0], '\\')) != NULL) 6121994689c1Smrg { 6122994689c1Smrg *p = '/'; 6123994689c1Smrg } 6124994689c1Smrg while ((p = strchr (lt_argv_zero, '\\')) != NULL) 6125994689c1Smrg { 6126994689c1Smrg *p = '/'; 6127994689c1Smrg } 6128994689c1Smrg } 6129994689c1SmrgEOF 6130994689c1Smrg ;; 6131994689c1Smrg esac 61327a84e134Smrg 6133994689c1Smrg cat <<"EOF" 6134994689c1Smrg XFREE (target_name); 6135994689c1Smrg XFREE (actual_cwrapper_path); 6136994689c1Smrg XFREE (actual_cwrapper_name); 61377a84e134Smrg 6138994689c1Smrg lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */ 6139994689c1Smrg lt_setenv ("DUALCASE", "1"); /* for MSK sh */ 6140f353fbadSmrg /* Update the DLL searchpath. EXE_PATH_VALUE ($dllsearchpath) must 6141f353fbadSmrg be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath) 6142f353fbadSmrg because on Windows, both *_VARNAMEs are PATH but uninstalled 6143f353fbadSmrg libraries must come first. */ 6144994689c1Smrg lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE); 6145f353fbadSmrg lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE); 61467a84e134Smrg 6147994689c1Smrg lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n", 6148994689c1Smrg nonnull (lt_argv_zero)); 6149994689c1Smrg for (i = 0; i < newargc; i++) 6150994689c1Smrg { 6151994689c1Smrg lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n", 6152994689c1Smrg i, nonnull (newargz[i])); 6153994689c1Smrg } 61547a84e134Smrg 6155994689c1SmrgEOF 61567a84e134Smrg 6157994689c1Smrg case $host_os in 6158994689c1Smrg mingw*) 6159994689c1Smrg cat <<"EOF" 6160994689c1Smrg /* execv doesn't actually work on mingw as expected on unix */ 6161994689c1Smrg newargz = prepare_spawn (newargz); 61625ec34c4cSmrg rval = (int) _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz); 6163994689c1Smrg if (rval == -1) 6164994689c1Smrg { 6165994689c1Smrg /* failed to start process */ 6166994689c1Smrg lt_debugprintf (__FILE__, __LINE__, 6167994689c1Smrg "(main) failed to launch target \"%s\": %s\n", 6168994689c1Smrg lt_argv_zero, nonnull (strerror (errno))); 6169994689c1Smrg return 127; 6170994689c1Smrg } 6171994689c1Smrg return rval; 6172994689c1SmrgEOF 6173994689c1Smrg ;; 6174994689c1Smrg *) 6175994689c1Smrg cat <<"EOF" 6176994689c1Smrg execv (lt_argv_zero, newargz); 6177994689c1Smrg return rval; /* =127, but avoids unused variable warning */ 6178994689c1SmrgEOF 6179994689c1Smrg ;; 6180994689c1Smrg esac 61817a84e134Smrg 6182994689c1Smrg cat <<"EOF" 6183994689c1Smrg} 61847a84e134Smrg 6185994689c1Smrgvoid * 6186994689c1Smrgxmalloc (size_t num) 6187994689c1Smrg{ 6188994689c1Smrg void *p = (void *) malloc (num); 6189994689c1Smrg if (!p) 6190994689c1Smrg lt_fatal (__FILE__, __LINE__, "memory exhausted"); 61917a84e134Smrg 6192994689c1Smrg return p; 6193994689c1Smrg} 61947a84e134Smrg 6195994689c1Smrgchar * 6196994689c1Smrgxstrdup (const char *string) 6197994689c1Smrg{ 6198994689c1Smrg return string ? strcpy ((char *) xmalloc (strlen (string) + 1), 6199994689c1Smrg string) : NULL; 6200994689c1Smrg} 62017a84e134Smrg 6202994689c1Smrgconst char * 6203994689c1Smrgbase_name (const char *name) 6204994689c1Smrg{ 6205994689c1Smrg const char *base; 62067a84e134Smrg 62075ec34c4cSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 6208994689c1Smrg /* Skip over the disk name in MSDOS pathnames. */ 6209994689c1Smrg if (isalpha ((unsigned char) name[0]) && name[1] == ':') 6210994689c1Smrg name += 2; 6211994689c1Smrg#endif 62127a84e134Smrg 6213994689c1Smrg for (base = name; *name; name++) 6214994689c1Smrg if (IS_DIR_SEPARATOR (*name)) 6215994689c1Smrg base = name + 1; 6216994689c1Smrg return base; 6217994689c1Smrg} 62187a84e134Smrg 6219994689c1Smrgint 6220994689c1Smrgcheck_executable (const char *path) 6221994689c1Smrg{ 6222994689c1Smrg struct stat st; 62237a84e134Smrg 6224994689c1Smrg lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n", 6225994689c1Smrg nonempty (path)); 6226994689c1Smrg if ((!path) || (!*path)) 6227994689c1Smrg return 0; 62287a84e134Smrg 6229994689c1Smrg if ((stat (path, &st) >= 0) 6230994689c1Smrg && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) 6231994689c1Smrg return 1; 6232994689c1Smrg else 6233994689c1Smrg return 0; 6234994689c1Smrg} 62357a84e134Smrg 6236994689c1Smrgint 6237994689c1Smrgmake_executable (const char *path) 6238994689c1Smrg{ 6239994689c1Smrg int rval = 0; 6240994689c1Smrg struct stat st; 6241e1e1713cSmrg 6242994689c1Smrg lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", 6243994689c1Smrg nonempty (path)); 6244994689c1Smrg if ((!path) || (!*path)) 6245994689c1Smrg return 0; 6246e1e1713cSmrg 6247994689c1Smrg if (stat (path, &st) >= 0) 6248994689c1Smrg { 6249994689c1Smrg rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); 6250994689c1Smrg } 6251994689c1Smrg return rval; 6252994689c1Smrg} 6253e1e1713cSmrg 6254994689c1Smrg/* Searches for the full path of the wrapper. Returns 6255994689c1Smrg newly allocated full path name if found, NULL otherwise 6256994689c1Smrg Does not chase symlinks, even on platforms that support them. 6257994689c1Smrg*/ 6258994689c1Smrgchar * 6259994689c1Smrgfind_executable (const char *wrapper) 6260994689c1Smrg{ 6261994689c1Smrg int has_slash = 0; 6262994689c1Smrg const char *p; 6263994689c1Smrg const char *p_next; 6264994689c1Smrg /* static buffer for getcwd */ 6265994689c1Smrg char tmp[LT_PATHMAX + 1]; 62665ec34c4cSmrg size_t tmp_len; 6267994689c1Smrg char *concat_name; 6268e1e1713cSmrg 6269994689c1Smrg lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", 6270994689c1Smrg nonempty (wrapper)); 6271e1e1713cSmrg 6272994689c1Smrg if ((wrapper == NULL) || (*wrapper == '\0')) 6273994689c1Smrg return NULL; 62747a84e134Smrg 6275994689c1Smrg /* Absolute path? */ 62765ec34c4cSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 6277994689c1Smrg if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') 6278994689c1Smrg { 6279994689c1Smrg concat_name = xstrdup (wrapper); 6280994689c1Smrg if (check_executable (concat_name)) 6281994689c1Smrg return concat_name; 6282994689c1Smrg XFREE (concat_name); 6283994689c1Smrg } 6284994689c1Smrg else 6285994689c1Smrg { 6286994689c1Smrg#endif 6287994689c1Smrg if (IS_DIR_SEPARATOR (wrapper[0])) 6288994689c1Smrg { 6289994689c1Smrg concat_name = xstrdup (wrapper); 6290994689c1Smrg if (check_executable (concat_name)) 6291994689c1Smrg return concat_name; 6292994689c1Smrg XFREE (concat_name); 6293994689c1Smrg } 62945ec34c4cSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 6295994689c1Smrg } 6296994689c1Smrg#endif 62977a84e134Smrg 6298994689c1Smrg for (p = wrapper; *p; p++) 6299994689c1Smrg if (*p == '/') 6300994689c1Smrg { 6301994689c1Smrg has_slash = 1; 6302994689c1Smrg break; 6303994689c1Smrg } 6304994689c1Smrg if (!has_slash) 6305994689c1Smrg { 6306994689c1Smrg /* no slashes; search PATH */ 6307994689c1Smrg const char *path = getenv ("PATH"); 6308994689c1Smrg if (path != NULL) 6309994689c1Smrg { 6310994689c1Smrg for (p = path; *p; p = p_next) 6311994689c1Smrg { 6312994689c1Smrg const char *q; 6313994689c1Smrg size_t p_len; 6314994689c1Smrg for (q = p; *q; q++) 6315994689c1Smrg if (IS_PATH_SEPARATOR (*q)) 6316994689c1Smrg break; 63175ec34c4cSmrg p_len = (size_t) (q - p); 6318994689c1Smrg p_next = (*q == '\0' ? q : q + 1); 6319994689c1Smrg if (p_len == 0) 6320994689c1Smrg { 6321994689c1Smrg /* empty path: current directory */ 6322994689c1Smrg if (getcwd (tmp, LT_PATHMAX) == NULL) 6323994689c1Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 6324994689c1Smrg nonnull (strerror (errno))); 6325994689c1Smrg tmp_len = strlen (tmp); 6326994689c1Smrg concat_name = 6327994689c1Smrg XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 6328994689c1Smrg memcpy (concat_name, tmp, tmp_len); 6329994689c1Smrg concat_name[tmp_len] = '/'; 6330994689c1Smrg strcpy (concat_name + tmp_len + 1, wrapper); 6331994689c1Smrg } 6332994689c1Smrg else 6333994689c1Smrg { 6334994689c1Smrg concat_name = 6335994689c1Smrg XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); 6336994689c1Smrg memcpy (concat_name, p, p_len); 6337994689c1Smrg concat_name[p_len] = '/'; 6338994689c1Smrg strcpy (concat_name + p_len + 1, wrapper); 6339994689c1Smrg } 6340994689c1Smrg if (check_executable (concat_name)) 6341994689c1Smrg return concat_name; 6342994689c1Smrg XFREE (concat_name); 6343994689c1Smrg } 6344994689c1Smrg } 6345994689c1Smrg /* not found in PATH; assume curdir */ 6346994689c1Smrg } 6347994689c1Smrg /* Relative path | not found in path: prepend cwd */ 6348994689c1Smrg if (getcwd (tmp, LT_PATHMAX) == NULL) 6349994689c1Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 6350994689c1Smrg nonnull (strerror (errno))); 6351994689c1Smrg tmp_len = strlen (tmp); 6352994689c1Smrg concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 6353994689c1Smrg memcpy (concat_name, tmp, tmp_len); 6354994689c1Smrg concat_name[tmp_len] = '/'; 6355994689c1Smrg strcpy (concat_name + tmp_len + 1, wrapper); 63567a84e134Smrg 6357994689c1Smrg if (check_executable (concat_name)) 6358994689c1Smrg return concat_name; 6359994689c1Smrg XFREE (concat_name); 6360994689c1Smrg return NULL; 6361994689c1Smrg} 6362e1e1713cSmrg 6363994689c1Smrgchar * 6364994689c1Smrgchase_symlinks (const char *pathspec) 6365994689c1Smrg{ 6366994689c1Smrg#ifndef S_ISLNK 6367994689c1Smrg return xstrdup (pathspec); 6368994689c1Smrg#else 6369994689c1Smrg char buf[LT_PATHMAX]; 6370994689c1Smrg struct stat s; 6371994689c1Smrg char *tmp_pathspec = xstrdup (pathspec); 6372994689c1Smrg char *p; 6373994689c1Smrg int has_symlinks = 0; 6374994689c1Smrg while (strlen (tmp_pathspec) && !has_symlinks) 6375994689c1Smrg { 6376994689c1Smrg lt_debugprintf (__FILE__, __LINE__, 6377994689c1Smrg "checking path component for symlinks: %s\n", 6378994689c1Smrg tmp_pathspec); 6379994689c1Smrg if (lstat (tmp_pathspec, &s) == 0) 6380994689c1Smrg { 6381994689c1Smrg if (S_ISLNK (s.st_mode) != 0) 6382994689c1Smrg { 6383994689c1Smrg has_symlinks = 1; 6384994689c1Smrg break; 6385994689c1Smrg } 6386e1e1713cSmrg 6387994689c1Smrg /* search backwards for last DIR_SEPARATOR */ 6388994689c1Smrg p = tmp_pathspec + strlen (tmp_pathspec) - 1; 6389994689c1Smrg while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 6390994689c1Smrg p--; 6391994689c1Smrg if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 6392994689c1Smrg { 6393994689c1Smrg /* no more DIR_SEPARATORS left */ 6394994689c1Smrg break; 6395994689c1Smrg } 6396994689c1Smrg *p = '\0'; 6397994689c1Smrg } 6398994689c1Smrg else 6399994689c1Smrg { 6400994689c1Smrg lt_fatal (__FILE__, __LINE__, 6401994689c1Smrg "error accessing file \"%s\": %s", 6402994689c1Smrg tmp_pathspec, nonnull (strerror (errno))); 6403994689c1Smrg } 6404994689c1Smrg } 6405994689c1Smrg XFREE (tmp_pathspec); 6406e1e1713cSmrg 6407994689c1Smrg if (!has_symlinks) 6408994689c1Smrg { 6409994689c1Smrg return xstrdup (pathspec); 6410994689c1Smrg } 6411e1e1713cSmrg 6412994689c1Smrg tmp_pathspec = realpath (pathspec, buf); 6413994689c1Smrg if (tmp_pathspec == 0) 6414994689c1Smrg { 6415994689c1Smrg lt_fatal (__FILE__, __LINE__, 6416994689c1Smrg "could not follow symlinks for %s", pathspec); 6417994689c1Smrg } 6418994689c1Smrg return xstrdup (tmp_pathspec); 6419994689c1Smrg#endif 6420994689c1Smrg} 64217a84e134Smrg 6422994689c1Smrgchar * 6423994689c1Smrgstrendzap (char *str, const char *pat) 6424994689c1Smrg{ 6425994689c1Smrg size_t len, patlen; 64267a84e134Smrg 6427994689c1Smrg assert (str != NULL); 6428994689c1Smrg assert (pat != NULL); 64297a84e134Smrg 6430994689c1Smrg len = strlen (str); 6431994689c1Smrg patlen = strlen (pat); 64327a84e134Smrg 6433994689c1Smrg if (patlen <= len) 6434994689c1Smrg { 6435994689c1Smrg str += len - patlen; 64365ec34c4cSmrg if (STREQ (str, pat)) 6437994689c1Smrg *str = '\0'; 6438994689c1Smrg } 6439994689c1Smrg return str; 6440994689c1Smrg} 64417a84e134Smrg 6442994689c1Smrgvoid 6443994689c1Smrglt_debugprintf (const char *file, int line, const char *fmt, ...) 6444994689c1Smrg{ 6445994689c1Smrg va_list args; 6446994689c1Smrg if (lt_debug) 6447994689c1Smrg { 6448994689c1Smrg (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); 6449994689c1Smrg va_start (args, fmt); 6450994689c1Smrg (void) vfprintf (stderr, fmt, args); 6451994689c1Smrg va_end (args); 6452994689c1Smrg } 6453994689c1Smrg} 64547a84e134Smrg 6455994689c1Smrgstatic void 6456994689c1Smrglt_error_core (int exit_status, const char *file, 6457994689c1Smrg int line, const char *mode, 6458994689c1Smrg const char *message, va_list ap) 6459994689c1Smrg{ 6460994689c1Smrg fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); 6461994689c1Smrg vfprintf (stderr, message, ap); 6462994689c1Smrg fprintf (stderr, ".\n"); 64637a84e134Smrg 6464994689c1Smrg if (exit_status >= 0) 6465994689c1Smrg exit (exit_status); 6466994689c1Smrg} 64677a84e134Smrg 6468994689c1Smrgvoid 6469994689c1Smrglt_fatal (const char *file, int line, const char *message, ...) 6470994689c1Smrg{ 6471994689c1Smrg va_list ap; 6472994689c1Smrg va_start (ap, message); 6473994689c1Smrg lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); 6474994689c1Smrg va_end (ap); 6475994689c1Smrg} 64767a84e134Smrg 6477994689c1Smrgstatic const char * 6478994689c1Smrgnonnull (const char *s) 6479994689c1Smrg{ 6480994689c1Smrg return s ? s : "(null)"; 6481994689c1Smrg} 64827a84e134Smrg 6483994689c1Smrgstatic const char * 6484994689c1Smrgnonempty (const char *s) 6485994689c1Smrg{ 6486994689c1Smrg return (s && !*s) ? "(empty)" : nonnull (s); 6487994689c1Smrg} 6488775e7de9Smrg 6489994689c1Smrgvoid 6490994689c1Smrglt_setenv (const char *name, const char *value) 6491994689c1Smrg{ 6492994689c1Smrg lt_debugprintf (__FILE__, __LINE__, 6493994689c1Smrg "(lt_setenv) setting '%s' to '%s'\n", 6494994689c1Smrg nonnull (name), nonnull (value)); 6495994689c1Smrg { 6496994689c1Smrg#ifdef HAVE_SETENV 6497994689c1Smrg /* always make a copy, for consistency with !HAVE_SETENV */ 6498994689c1Smrg char *str = xstrdup (value); 6499994689c1Smrg setenv (name, str, 1); 6500994689c1Smrg#else 65015ec34c4cSmrg size_t len = strlen (name) + 1 + strlen (value) + 1; 6502994689c1Smrg char *str = XMALLOC (char, len); 6503994689c1Smrg sprintf (str, "%s=%s", name, value); 6504994689c1Smrg if (putenv (str) != EXIT_SUCCESS) 6505994689c1Smrg { 6506994689c1Smrg XFREE (str); 6507994689c1Smrg } 6508994689c1Smrg#endif 6509994689c1Smrg } 6510994689c1Smrg} 65117a84e134Smrg 6512994689c1Smrgchar * 6513994689c1Smrglt_extend_str (const char *orig_value, const char *add, int to_end) 6514994689c1Smrg{ 6515994689c1Smrg char *new_value; 6516994689c1Smrg if (orig_value && *orig_value) 6517994689c1Smrg { 65185ec34c4cSmrg size_t orig_value_len = strlen (orig_value); 65195ec34c4cSmrg size_t add_len = strlen (add); 6520994689c1Smrg new_value = XMALLOC (char, add_len + orig_value_len + 1); 6521994689c1Smrg if (to_end) 6522994689c1Smrg { 6523994689c1Smrg strcpy (new_value, orig_value); 6524994689c1Smrg strcpy (new_value + orig_value_len, add); 6525994689c1Smrg } 6526994689c1Smrg else 6527994689c1Smrg { 6528994689c1Smrg strcpy (new_value, add); 6529994689c1Smrg strcpy (new_value + add_len, orig_value); 6530994689c1Smrg } 6531994689c1Smrg } 6532994689c1Smrg else 6533994689c1Smrg { 6534994689c1Smrg new_value = xstrdup (add); 6535994689c1Smrg } 6536994689c1Smrg return new_value; 6537994689c1Smrg} 65387a84e134Smrg 6539994689c1Smrgvoid 6540994689c1Smrglt_update_exe_path (const char *name, const char *value) 6541994689c1Smrg{ 6542994689c1Smrg lt_debugprintf (__FILE__, __LINE__, 6543994689c1Smrg "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", 6544994689c1Smrg nonnull (name), nonnull (value)); 65457a84e134Smrg 6546994689c1Smrg if (name && *name && value && *value) 6547994689c1Smrg { 6548994689c1Smrg char *new_value = lt_extend_str (getenv (name), value, 0); 6549994689c1Smrg /* some systems can't cope with a ':'-terminated path #' */ 65505ec34c4cSmrg size_t len = strlen (new_value); 65515ec34c4cSmrg while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1])) 6552994689c1Smrg { 65535ec34c4cSmrg new_value[--len] = '\0'; 6554994689c1Smrg } 6555994689c1Smrg lt_setenv (name, new_value); 6556994689c1Smrg XFREE (new_value); 6557994689c1Smrg } 6558994689c1Smrg} 65597a84e134Smrg 6560994689c1Smrgvoid 6561994689c1Smrglt_update_lib_path (const char *name, const char *value) 6562994689c1Smrg{ 6563994689c1Smrg lt_debugprintf (__FILE__, __LINE__, 6564994689c1Smrg "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", 6565994689c1Smrg nonnull (name), nonnull (value)); 65667a84e134Smrg 6567994689c1Smrg if (name && *name && value && *value) 6568994689c1Smrg { 6569994689c1Smrg char *new_value = lt_extend_str (getenv (name), value, 0); 6570994689c1Smrg lt_setenv (name, new_value); 6571994689c1Smrg XFREE (new_value); 6572994689c1Smrg } 6573994689c1Smrg} 65747a84e134Smrg 6575994689c1SmrgEOF 6576994689c1Smrg case $host_os in 6577994689c1Smrg mingw*) 6578994689c1Smrg cat <<"EOF" 6579994689c1Smrg 6580994689c1Smrg/* Prepares an argument vector before calling spawn(). 6581994689c1Smrg Note that spawn() does not by itself call the command interpreter 6582994689c1Smrg (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : 6583994689c1Smrg ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); 6584994689c1Smrg GetVersionEx(&v); 6585994689c1Smrg v.dwPlatformId == VER_PLATFORM_WIN32_NT; 6586994689c1Smrg }) ? "cmd.exe" : "command.com"). 6587994689c1Smrg Instead it simply concatenates the arguments, separated by ' ', and calls 6588994689c1Smrg CreateProcess(). We must quote the arguments since Win32 CreateProcess() 6589994689c1Smrg interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a 6590994689c1Smrg special way: 6591994689c1Smrg - Space and tab are interpreted as delimiters. They are not treated as 6592994689c1Smrg delimiters if they are surrounded by double quotes: "...". 6593994689c1Smrg - Unescaped double quotes are removed from the input. Their only effect is 6594994689c1Smrg that within double quotes, space and tab are treated like normal 6595994689c1Smrg characters. 6596994689c1Smrg - Backslashes not followed by double quotes are not special. 6597994689c1Smrg - But 2*n+1 backslashes followed by a double quote become 6598994689c1Smrg n backslashes followed by a double quote (n >= 0): 6599994689c1Smrg \" -> " 6600994689c1Smrg \\\" -> \" 6601994689c1Smrg \\\\\" -> \\" 6602994689c1Smrg */ 6603994689c1Smrg#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" 6604994689c1Smrg#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" 6605994689c1Smrgchar ** 6606994689c1Smrgprepare_spawn (char **argv) 6607994689c1Smrg{ 6608994689c1Smrg size_t argc; 6609994689c1Smrg char **new_argv; 6610994689c1Smrg size_t i; 66117a84e134Smrg 6612994689c1Smrg /* Count number of arguments. */ 6613994689c1Smrg for (argc = 0; argv[argc] != NULL; argc++) 6614994689c1Smrg ; 66157a84e134Smrg 6616994689c1Smrg /* Allocate new argument vector. */ 6617994689c1Smrg new_argv = XMALLOC (char *, argc + 1); 66187a84e134Smrg 6619994689c1Smrg /* Put quoted arguments into the new argument vector. */ 6620994689c1Smrg for (i = 0; i < argc; i++) 6621994689c1Smrg { 6622994689c1Smrg const char *string = argv[i]; 6623994689c1Smrg 6624994689c1Smrg if (string[0] == '\0') 6625994689c1Smrg new_argv[i] = xstrdup ("\"\""); 6626994689c1Smrg else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) 6627994689c1Smrg { 6628994689c1Smrg int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); 6629994689c1Smrg size_t length; 6630994689c1Smrg unsigned int backslashes; 6631994689c1Smrg const char *s; 6632994689c1Smrg char *quoted_string; 6633994689c1Smrg char *p; 6634994689c1Smrg 6635994689c1Smrg length = 0; 6636994689c1Smrg backslashes = 0; 6637994689c1Smrg if (quote_around) 6638994689c1Smrg length++; 6639994689c1Smrg for (s = string; *s != '\0'; s++) 6640994689c1Smrg { 6641994689c1Smrg char c = *s; 6642994689c1Smrg if (c == '"') 6643994689c1Smrg length += backslashes + 1; 6644994689c1Smrg length++; 6645994689c1Smrg if (c == '\\') 6646994689c1Smrg backslashes++; 6647994689c1Smrg else 6648994689c1Smrg backslashes = 0; 6649994689c1Smrg } 6650994689c1Smrg if (quote_around) 6651994689c1Smrg length += backslashes + 1; 6652994689c1Smrg 6653994689c1Smrg quoted_string = XMALLOC (char, length + 1); 6654994689c1Smrg 6655994689c1Smrg p = quoted_string; 6656994689c1Smrg backslashes = 0; 6657994689c1Smrg if (quote_around) 6658994689c1Smrg *p++ = '"'; 6659994689c1Smrg for (s = string; *s != '\0'; s++) 6660994689c1Smrg { 6661994689c1Smrg char c = *s; 6662994689c1Smrg if (c == '"') 6663994689c1Smrg { 6664994689c1Smrg unsigned int j; 6665994689c1Smrg for (j = backslashes + 1; j > 0; j--) 6666994689c1Smrg *p++ = '\\'; 6667994689c1Smrg } 6668994689c1Smrg *p++ = c; 6669994689c1Smrg if (c == '\\') 6670994689c1Smrg backslashes++; 6671994689c1Smrg else 6672994689c1Smrg backslashes = 0; 6673994689c1Smrg } 6674994689c1Smrg if (quote_around) 6675994689c1Smrg { 6676994689c1Smrg unsigned int j; 6677994689c1Smrg for (j = backslashes; j > 0; j--) 6678994689c1Smrg *p++ = '\\'; 6679994689c1Smrg *p++ = '"'; 6680994689c1Smrg } 6681994689c1Smrg *p = '\0'; 66827a84e134Smrg 6683994689c1Smrg new_argv[i] = quoted_string; 6684994689c1Smrg } 6685994689c1Smrg else 6686994689c1Smrg new_argv[i] = (char *) string; 6687994689c1Smrg } 6688994689c1Smrg new_argv[argc] = NULL; 66897a84e134Smrg 6690994689c1Smrg return new_argv; 6691994689c1Smrg} 6692994689c1SmrgEOF 6693e1e1713cSmrg ;; 6694994689c1Smrg esac 66957a84e134Smrg 6696994689c1Smrg cat <<"EOF" 6697994689c1Smrgvoid lt_dump_script (FILE* f) 6698994689c1Smrg{ 6699994689c1SmrgEOF 6700994689c1Smrg func_emit_wrapper yes | 6701421c997bSmrg $SED -n -e ' 6702421c997bSmrgs/^\(.\{79\}\)\(..*\)/\1\ 6703421c997bSmrg\2/ 6704421c997bSmrgh 6705421c997bSmrgs/\([\\"]\)/\\\1/g 6706421c997bSmrgs/$/\\n/ 6707421c997bSmrgs/\([^\n]*\).*/ fputs ("\1", f);/p 6708421c997bSmrgg 6709421c997bSmrgD' 6710994689c1Smrg cat <<"EOF" 6711994689c1Smrg} 6712994689c1SmrgEOF 6713994689c1Smrg} 6714994689c1Smrg# end: func_emit_cwrapperexe_src 67157a84e134Smrg 6716994689c1Smrg# func_win32_import_lib_p ARG 6717994689c1Smrg# True if ARG is an import lib, as indicated by $file_magic_cmd 6718994689c1Smrgfunc_win32_import_lib_p () 6719994689c1Smrg{ 67205ec34c4cSmrg $debug_cmd 67215ec34c4cSmrg 6722994689c1Smrg case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in 6723994689c1Smrg *import*) : ;; 6724994689c1Smrg *) false ;; 6725994689c1Smrg esac 6726994689c1Smrg} 67277a84e134Smrg 67285ec34c4cSmrg# func_suncc_cstd_abi 67295ec34c4cSmrg# !!ONLY CALL THIS FOR SUN CC AFTER $compile_command IS FULLY EXPANDED!! 67305ec34c4cSmrg# Several compiler flags select an ABI that is incompatible with the 67315ec34c4cSmrg# Cstd library. Avoid specifying it if any are in CXXFLAGS. 67325ec34c4cSmrgfunc_suncc_cstd_abi () 67335ec34c4cSmrg{ 67345ec34c4cSmrg $debug_cmd 67355ec34c4cSmrg 67365ec34c4cSmrg case " $compile_command " in 67375ec34c4cSmrg *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*) 67385ec34c4cSmrg suncc_use_cstd_abi=no 67395ec34c4cSmrg ;; 67405ec34c4cSmrg *) 67415ec34c4cSmrg suncc_use_cstd_abi=yes 67425ec34c4cSmrg ;; 67435ec34c4cSmrg esac 67445ec34c4cSmrg} 67455ec34c4cSmrg 6746994689c1Smrg# func_mode_link arg... 6747994689c1Smrgfunc_mode_link () 6748994689c1Smrg{ 67495ec34c4cSmrg $debug_cmd 67505ec34c4cSmrg 6751994689c1Smrg case $host in 6752994689c1Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 6753994689c1Smrg # It is impossible to link a dll without this setting, and 6754994689c1Smrg # we shouldn't force the makefile maintainer to figure out 67555ec34c4cSmrg # what system we are compiling for in order to pass an extra 6756994689c1Smrg # flag for every libtool invocation. 6757994689c1Smrg # allow_undefined=no 67587a84e134Smrg 6759994689c1Smrg # FIXME: Unfortunately, there are problems with the above when trying 67605ec34c4cSmrg # to make a dll that has undefined symbols, in which case not 6761994689c1Smrg # even a static library is built. For now, we need to specify 6762994689c1Smrg # -no-undefined on the libtool link line when we can be certain 6763994689c1Smrg # that all symbols are satisfied, otherwise we get a static library. 6764994689c1Smrg allow_undefined=yes 6765994689c1Smrg ;; 6766994689c1Smrg *) 6767994689c1Smrg allow_undefined=yes 6768994689c1Smrg ;; 6769994689c1Smrg esac 6770994689c1Smrg libtool_args=$nonopt 6771994689c1Smrg base_compile="$nonopt $@" 6772994689c1Smrg compile_command=$nonopt 6773994689c1Smrg finalize_command=$nonopt 67747a84e134Smrg 6775994689c1Smrg compile_rpath= 6776994689c1Smrg finalize_rpath= 6777994689c1Smrg compile_shlibpath= 6778994689c1Smrg finalize_shlibpath= 6779994689c1Smrg convenience= 6780994689c1Smrg old_convenience= 6781994689c1Smrg deplibs= 6782994689c1Smrg old_deplibs= 6783994689c1Smrg compiler_flags= 6784994689c1Smrg linker_flags= 6785994689c1Smrg dllsearchpath= 6786994689c1Smrg lib_search_path=`pwd` 6787994689c1Smrg inst_prefix_dir= 6788994689c1Smrg new_inherited_linker_flags= 67897a84e134Smrg 6790994689c1Smrg avoid_version=no 6791994689c1Smrg bindir= 6792994689c1Smrg dlfiles= 6793994689c1Smrg dlprefiles= 6794994689c1Smrg dlself=no 6795994689c1Smrg export_dynamic=no 6796994689c1Smrg export_symbols= 6797994689c1Smrg export_symbols_regex= 6798994689c1Smrg generated= 6799994689c1Smrg libobjs= 6800994689c1Smrg ltlibs= 6801994689c1Smrg module=no 6802994689c1Smrg no_install=no 6803994689c1Smrg objs= 68045ec34c4cSmrg os2dllname= 6805994689c1Smrg non_pic_objects= 6806994689c1Smrg precious_files_regex= 6807994689c1Smrg prefer_static_libs=no 68085ec34c4cSmrg preload=false 6809994689c1Smrg prev= 6810994689c1Smrg prevarg= 6811994689c1Smrg release= 6812994689c1Smrg rpath= 6813994689c1Smrg xrpath= 6814994689c1Smrg perm_rpath= 6815994689c1Smrg temp_rpath= 6816994689c1Smrg thread_safe=no 6817994689c1Smrg vinfo= 6818994689c1Smrg vinfo_number=no 6819994689c1Smrg weak_libs= 68205ec34c4cSmrg single_module=$wl-single_module 6821994689c1Smrg func_infer_tag $base_compile 68227a84e134Smrg 6823994689c1Smrg # We need to know -static, to get the right output filenames. 6824994689c1Smrg for arg 6825994689c1Smrg do 6826994689c1Smrg case $arg in 6827994689c1Smrg -shared) 68285ec34c4cSmrg test yes != "$build_libtool_libs" \ 68295ec34c4cSmrg && func_fatal_configuration "cannot build a shared library" 6830994689c1Smrg build_old_libs=no 6831994689c1Smrg break 6832994689c1Smrg ;; 6833994689c1Smrg -all-static | -static | -static-libtool-libs) 6834994689c1Smrg case $arg in 6835994689c1Smrg -all-static) 68365ec34c4cSmrg if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then 6837994689c1Smrg func_warning "complete static linking is impossible in this configuration" 6838994689c1Smrg fi 6839994689c1Smrg if test -n "$link_static_flag"; then 6840994689c1Smrg dlopen_self=$dlopen_self_static 6841994689c1Smrg fi 6842994689c1Smrg prefer_static_libs=yes 6843994689c1Smrg ;; 6844994689c1Smrg -static) 6845994689c1Smrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 6846994689c1Smrg dlopen_self=$dlopen_self_static 6847994689c1Smrg fi 6848994689c1Smrg prefer_static_libs=built 6849994689c1Smrg ;; 6850994689c1Smrg -static-libtool-libs) 6851994689c1Smrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 6852994689c1Smrg dlopen_self=$dlopen_self_static 6853994689c1Smrg fi 6854994689c1Smrg prefer_static_libs=yes 6855994689c1Smrg ;; 6856994689c1Smrg esac 6857994689c1Smrg build_libtool_libs=no 6858994689c1Smrg build_old_libs=yes 6859994689c1Smrg break 6860994689c1Smrg ;; 6861994689c1Smrg esac 6862994689c1Smrg done 68637a84e134Smrg 6864994689c1Smrg # See if our shared archives depend on static archives. 6865994689c1Smrg test -n "$old_archive_from_new_cmds" && build_old_libs=yes 68667a84e134Smrg 6867994689c1Smrg # Go through the arguments, transforming them on the way. 6868994689c1Smrg while test "$#" -gt 0; do 68695ec34c4cSmrg arg=$1 6870994689c1Smrg shift 68715b16253fSmrg func_quote_arg pretty,unquoted "$arg" 68725b16253fSmrg qarg=$func_quote_arg_unquoted_result 68735b16253fSmrg func_append libtool_args " $func_quote_arg_result" 68747a84e134Smrg 6875994689c1Smrg # If the previous option needs an argument, assign it. 6876994689c1Smrg if test -n "$prev"; then 6877994689c1Smrg case $prev in 6878994689c1Smrg output) 6879994689c1Smrg func_append compile_command " @OUTPUT@" 6880994689c1Smrg func_append finalize_command " @OUTPUT@" 6881994689c1Smrg ;; 6882994689c1Smrg esac 68837a84e134Smrg 6884994689c1Smrg case $prev in 6885994689c1Smrg bindir) 68865ec34c4cSmrg bindir=$arg 6887994689c1Smrg prev= 6888994689c1Smrg continue 6889994689c1Smrg ;; 6890994689c1Smrg dlfiles|dlprefiles) 68915ec34c4cSmrg $preload || { 6892994689c1Smrg # Add the symbol object into the linking commands. 6893994689c1Smrg func_append compile_command " @SYMFILE@" 6894994689c1Smrg func_append finalize_command " @SYMFILE@" 68955ec34c4cSmrg preload=: 68965ec34c4cSmrg } 6897994689c1Smrg case $arg in 6898994689c1Smrg *.la | *.lo) ;; # We handle these cases below. 6899994689c1Smrg force) 69005ec34c4cSmrg if test no = "$dlself"; then 6901994689c1Smrg dlself=needless 6902994689c1Smrg export_dynamic=yes 6903e1e1713cSmrg fi 6904994689c1Smrg prev= 6905994689c1Smrg continue 6906994689c1Smrg ;; 6907994689c1Smrg self) 69085ec34c4cSmrg if test dlprefiles = "$prev"; then 6909994689c1Smrg dlself=yes 69105ec34c4cSmrg elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then 6911994689c1Smrg dlself=yes 6912e1e1713cSmrg else 6913994689c1Smrg dlself=needless 6914994689c1Smrg export_dynamic=yes 6915e1e1713cSmrg fi 6916994689c1Smrg prev= 6917994689c1Smrg continue 6918994689c1Smrg ;; 6919994689c1Smrg *) 69205ec34c4cSmrg if test dlfiles = "$prev"; then 6921f353fbadSmrg func_append dlfiles " $arg" 6922e1e1713cSmrg else 6923f353fbadSmrg func_append dlprefiles " $arg" 6924e1e1713cSmrg fi 6925994689c1Smrg prev= 6926994689c1Smrg continue 6927994689c1Smrg ;; 6928994689c1Smrg esac 6929994689c1Smrg ;; 6930994689c1Smrg expsyms) 69315ec34c4cSmrg export_symbols=$arg 6932994689c1Smrg test -f "$arg" \ 69335ec34c4cSmrg || func_fatal_error "symbol file '$arg' does not exist" 6934994689c1Smrg prev= 6935994689c1Smrg continue 6936994689c1Smrg ;; 6937994689c1Smrg expsyms_regex) 69385ec34c4cSmrg export_symbols_regex=$arg 6939994689c1Smrg prev= 6940994689c1Smrg continue 6941994689c1Smrg ;; 6942994689c1Smrg framework) 6943e1e1713cSmrg case $host in 6944994689c1Smrg *-*-darwin*) 6945994689c1Smrg case "$deplibs " in 6946994689c1Smrg *" $qarg.ltframework "*) ;; 6947f353fbadSmrg *) func_append deplibs " $qarg.ltframework" # this is fixed later 6948994689c1Smrg ;; 6949994689c1Smrg esac 6950994689c1Smrg ;; 6951e1e1713cSmrg esac 6952994689c1Smrg prev= 6953994689c1Smrg continue 6954e1e1713cSmrg ;; 6955994689c1Smrg inst_prefix) 69565ec34c4cSmrg inst_prefix_dir=$arg 69575ec34c4cSmrg prev= 69585ec34c4cSmrg continue 69595ec34c4cSmrg ;; 69605ec34c4cSmrg mllvm) 69615ec34c4cSmrg # Clang does not use LLVM to link, so we can simply discard any 69625ec34c4cSmrg # '-mllvm $arg' options when doing the link step. 6963994689c1Smrg prev= 6964994689c1Smrg continue 6965e1e1713cSmrg ;; 6966994689c1Smrg objectlist) 6967994689c1Smrg if test -f "$arg"; then 6968994689c1Smrg save_arg=$arg 6969994689c1Smrg moreargs= 6970994689c1Smrg for fil in `cat "$save_arg"` 6971994689c1Smrg do 6972f353fbadSmrg# func_append moreargs " $fil" 6973994689c1Smrg arg=$fil 6974994689c1Smrg # A libtool-controlled object. 69757a84e134Smrg 6976994689c1Smrg # Check to see that this really is a libtool object. 6977994689c1Smrg if func_lalib_unsafe_p "$arg"; then 6978994689c1Smrg pic_object= 6979994689c1Smrg non_pic_object= 6980775e7de9Smrg 6981994689c1Smrg # Read the .lo file 6982994689c1Smrg func_source "$arg" 6983775e7de9Smrg 6984994689c1Smrg if test -z "$pic_object" || 6985994689c1Smrg test -z "$non_pic_object" || 69865ec34c4cSmrg test none = "$pic_object" && 69875ec34c4cSmrg test none = "$non_pic_object"; then 69885ec34c4cSmrg func_fatal_error "cannot find name of object for '$arg'" 6989994689c1Smrg fi 6990775e7de9Smrg 6991994689c1Smrg # Extract subdirectory from the argument. 6992994689c1Smrg func_dirname "$arg" "/" "" 69935ec34c4cSmrg xdir=$func_dirname_result 6994775e7de9Smrg 69955ec34c4cSmrg if test none != "$pic_object"; then 6996994689c1Smrg # Prepend the subdirectory the object is found in. 69975ec34c4cSmrg pic_object=$xdir$pic_object 6998775e7de9Smrg 69995ec34c4cSmrg if test dlfiles = "$prev"; then 70005ec34c4cSmrg if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 7001f353fbadSmrg func_append dlfiles " $pic_object" 7002994689c1Smrg prev= 7003994689c1Smrg continue 7004994689c1Smrg else 7005994689c1Smrg # If libtool objects are unsupported, then we need to preload. 7006994689c1Smrg prev=dlprefiles 7007994689c1Smrg fi 7008994689c1Smrg fi 7009775e7de9Smrg 7010994689c1Smrg # CHECK ME: I think I busted this. -Ossama 70115ec34c4cSmrg if test dlprefiles = "$prev"; then 7012994689c1Smrg # Preload the old-style object. 7013f353fbadSmrg func_append dlprefiles " $pic_object" 7014994689c1Smrg prev= 7015994689c1Smrg fi 7016775e7de9Smrg 7017994689c1Smrg # A PIC object. 7018994689c1Smrg func_append libobjs " $pic_object" 70195ec34c4cSmrg arg=$pic_object 7020994689c1Smrg fi 7021775e7de9Smrg 7022994689c1Smrg # Non-PIC object. 70235ec34c4cSmrg if test none != "$non_pic_object"; then 7024994689c1Smrg # Prepend the subdirectory the object is found in. 70255ec34c4cSmrg non_pic_object=$xdir$non_pic_object 7026775e7de9Smrg 7027994689c1Smrg # A standard non-PIC object 7028994689c1Smrg func_append non_pic_objects " $non_pic_object" 70295ec34c4cSmrg if test -z "$pic_object" || test none = "$pic_object"; then 70305ec34c4cSmrg arg=$non_pic_object 7031994689c1Smrg fi 7032994689c1Smrg else 7033994689c1Smrg # If the PIC object exists, use it instead. 7034994689c1Smrg # $xdir was prepended to $pic_object above. 70355ec34c4cSmrg non_pic_object=$pic_object 7036994689c1Smrg func_append non_pic_objects " $non_pic_object" 7037994689c1Smrg fi 7038994689c1Smrg else 7039994689c1Smrg # Only an error if not doing a dry-run. 7040994689c1Smrg if $opt_dry_run; then 7041994689c1Smrg # Extract subdirectory from the argument. 7042994689c1Smrg func_dirname "$arg" "/" "" 70435ec34c4cSmrg xdir=$func_dirname_result 7044994689c1Smrg 7045994689c1Smrg func_lo2o "$arg" 7046994689c1Smrg pic_object=$xdir$objdir/$func_lo2o_result 7047994689c1Smrg non_pic_object=$xdir$func_lo2o_result 7048994689c1Smrg func_append libobjs " $pic_object" 7049994689c1Smrg func_append non_pic_objects " $non_pic_object" 7050994689c1Smrg else 70515ec34c4cSmrg func_fatal_error "'$arg' is not a valid libtool object" 7052994689c1Smrg fi 7053994689c1Smrg fi 7054994689c1Smrg done 7055e1e1713cSmrg else 70565ec34c4cSmrg func_fatal_error "link input file '$arg' does not exist" 7057e1e1713cSmrg fi 7058994689c1Smrg arg=$save_arg 7059994689c1Smrg prev= 7060994689c1Smrg continue 7061994689c1Smrg ;; 70625ec34c4cSmrg os2dllname) 70635ec34c4cSmrg os2dllname=$arg 70645ec34c4cSmrg prev= 70655ec34c4cSmrg continue 70665ec34c4cSmrg ;; 7067994689c1Smrg precious_regex) 70685ec34c4cSmrg precious_files_regex=$arg 7069994689c1Smrg prev= 7070994689c1Smrg continue 7071994689c1Smrg ;; 7072994689c1Smrg release) 70735ec34c4cSmrg release=-$arg 7074994689c1Smrg prev= 7075994689c1Smrg continue 7076994689c1Smrg ;; 7077994689c1Smrg rpath | xrpath) 7078994689c1Smrg # We need an absolute path. 7079994689c1Smrg case $arg in 7080994689c1Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 7081994689c1Smrg *) 7082994689c1Smrg func_fatal_error "only absolute run-paths are allowed" 7083994689c1Smrg ;; 7084994689c1Smrg esac 70855ec34c4cSmrg if test rpath = "$prev"; then 7086994689c1Smrg case "$rpath " in 7087994689c1Smrg *" $arg "*) ;; 7088f353fbadSmrg *) func_append rpath " $arg" ;; 7089994689c1Smrg esac 7090e1e1713cSmrg else 7091994689c1Smrg case "$xrpath " in 7092994689c1Smrg *" $arg "*) ;; 7093f353fbadSmrg *) func_append xrpath " $arg" ;; 7094994689c1Smrg esac 7095e1e1713cSmrg fi 7096994689c1Smrg prev= 7097994689c1Smrg continue 7098994689c1Smrg ;; 7099994689c1Smrg shrext) 71005ec34c4cSmrg shrext_cmds=$arg 7101994689c1Smrg prev= 7102994689c1Smrg continue 7103994689c1Smrg ;; 7104994689c1Smrg weak) 7105f353fbadSmrg func_append weak_libs " $arg" 7106994689c1Smrg prev= 7107994689c1Smrg continue 7108994689c1Smrg ;; 71095b16253fSmrg xassembler) 71105b16253fSmrg func_append compiler_flags " -Xassembler $qarg" 71115b16253fSmrg prev= 71125b16253fSmrg func_append compile_command " -Xassembler $qarg" 71135b16253fSmrg func_append finalize_command " -Xassembler $qarg" 71145b16253fSmrg continue 71155b16253fSmrg ;; 7116994689c1Smrg xcclinker) 7117f353fbadSmrg func_append linker_flags " $qarg" 7118f353fbadSmrg func_append compiler_flags " $qarg" 7119994689c1Smrg prev= 7120994689c1Smrg func_append compile_command " $qarg" 7121994689c1Smrg func_append finalize_command " $qarg" 7122994689c1Smrg continue 7123994689c1Smrg ;; 7124994689c1Smrg xcompiler) 7125f353fbadSmrg func_append compiler_flags " $qarg" 7126994689c1Smrg prev= 7127994689c1Smrg func_append compile_command " $qarg" 7128994689c1Smrg func_append finalize_command " $qarg" 7129994689c1Smrg continue 7130994689c1Smrg ;; 7131994689c1Smrg xlinker) 7132f353fbadSmrg func_append linker_flags " $qarg" 7133f353fbadSmrg func_append compiler_flags " $wl$qarg" 7134994689c1Smrg prev= 7135994689c1Smrg func_append compile_command " $wl$qarg" 7136994689c1Smrg func_append finalize_command " $wl$qarg" 7137994689c1Smrg continue 7138994689c1Smrg ;; 7139994689c1Smrg *) 7140994689c1Smrg eval "$prev=\"\$arg\"" 7141994689c1Smrg prev= 7142994689c1Smrg continue 7143994689c1Smrg ;; 7144775e7de9Smrg esac 7145994689c1Smrg fi # test -n "$prev" 7146775e7de9Smrg 71475ec34c4cSmrg prevarg=$arg 7148775e7de9Smrg 7149994689c1Smrg case $arg in 7150994689c1Smrg -all-static) 7151994689c1Smrg if test -n "$link_static_flag"; then 7152994689c1Smrg # See comment for -static flag below, for more details. 7153994689c1Smrg func_append compile_command " $link_static_flag" 7154994689c1Smrg func_append finalize_command " $link_static_flag" 7155994689c1Smrg fi 7156994689c1Smrg continue 7157994689c1Smrg ;; 7158775e7de9Smrg 7159994689c1Smrg -allow-undefined) 7160994689c1Smrg # FIXME: remove this flag sometime in the future. 71615ec34c4cSmrg func_fatal_error "'-allow-undefined' must not be used because it is the default" 7162994689c1Smrg ;; 7163775e7de9Smrg 7164994689c1Smrg -avoid-version) 7165994689c1Smrg avoid_version=yes 7166994689c1Smrg continue 7167994689c1Smrg ;; 7168775e7de9Smrg 7169994689c1Smrg -bindir) 7170994689c1Smrg prev=bindir 7171994689c1Smrg continue 7172994689c1Smrg ;; 7173775e7de9Smrg 7174994689c1Smrg -dlopen) 7175994689c1Smrg prev=dlfiles 7176994689c1Smrg continue 7177994689c1Smrg ;; 7178775e7de9Smrg 7179994689c1Smrg -dlpreopen) 7180994689c1Smrg prev=dlprefiles 7181994689c1Smrg continue 7182994689c1Smrg ;; 7183775e7de9Smrg 7184994689c1Smrg -export-dynamic) 7185994689c1Smrg export_dynamic=yes 7186994689c1Smrg continue 7187994689c1Smrg ;; 7188775e7de9Smrg 7189994689c1Smrg -export-symbols | -export-symbols-regex) 7190994689c1Smrg if test -n "$export_symbols" || test -n "$export_symbols_regex"; then 7191994689c1Smrg func_fatal_error "more than one -exported-symbols argument is not allowed" 7192994689c1Smrg fi 71935ec34c4cSmrg if test X-export-symbols = "X$arg"; then 7194994689c1Smrg prev=expsyms 7195994689c1Smrg else 7196994689c1Smrg prev=expsyms_regex 7197994689c1Smrg fi 7198994689c1Smrg continue 7199994689c1Smrg ;; 7200775e7de9Smrg 7201994689c1Smrg -framework) 7202994689c1Smrg prev=framework 7203994689c1Smrg continue 7204994689c1Smrg ;; 7205775e7de9Smrg 7206994689c1Smrg -inst-prefix-dir) 7207994689c1Smrg prev=inst_prefix 7208994689c1Smrg continue 7209994689c1Smrg ;; 7210775e7de9Smrg 7211994689c1Smrg # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* 7212994689c1Smrg # so, if we see these flags be careful not to treat them like -L 7213994689c1Smrg -L[A-Z][A-Z]*:*) 7214994689c1Smrg case $with_gcc/$host in 7215994689c1Smrg no/*-*-irix* | /*-*-irix*) 7216994689c1Smrg func_append compile_command " $arg" 7217994689c1Smrg func_append finalize_command " $arg" 7218994689c1Smrg ;; 7219994689c1Smrg esac 7220994689c1Smrg continue 7221994689c1Smrg ;; 7222775e7de9Smrg 7223994689c1Smrg -L*) 7224f353fbadSmrg func_stripname "-L" '' "$arg" 7225f353fbadSmrg if test -z "$func_stripname_result"; then 7226994689c1Smrg if test "$#" -gt 0; then 72275ec34c4cSmrg func_fatal_error "require no space between '-L' and '$1'" 7228994689c1Smrg else 72295ec34c4cSmrg func_fatal_error "need path for '-L' option" 7230994689c1Smrg fi 7231994689c1Smrg fi 7232f353fbadSmrg func_resolve_sysroot "$func_stripname_result" 7233f353fbadSmrg dir=$func_resolve_sysroot_result 7234994689c1Smrg # We need an absolute path. 7235994689c1Smrg case $dir in 7236994689c1Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 7237994689c1Smrg *) 7238994689c1Smrg absdir=`cd "$dir" && pwd` 7239994689c1Smrg test -z "$absdir" && \ 72405ec34c4cSmrg func_fatal_error "cannot determine absolute directory name of '$dir'" 72415ec34c4cSmrg dir=$absdir 7242994689c1Smrg ;; 7243994689c1Smrg esac 7244994689c1Smrg case "$deplibs " in 7245f353fbadSmrg *" -L$dir "* | *" $arg "*) 7246f353fbadSmrg # Will only happen for absolute or sysroot arguments 7247f353fbadSmrg ;; 7248994689c1Smrg *) 7249f353fbadSmrg # Preserve sysroot, but never include relative directories 7250f353fbadSmrg case $dir in 7251f353fbadSmrg [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; 7252f353fbadSmrg *) func_append deplibs " -L$dir" ;; 7253f353fbadSmrg esac 7254f353fbadSmrg func_append lib_search_path " $dir" 7255994689c1Smrg ;; 7256994689c1Smrg esac 7257994689c1Smrg case $host in 7258994689c1Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 7259994689c1Smrg testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` 7260994689c1Smrg case :$dllsearchpath: in 7261994689c1Smrg *":$dir:"*) ;; 7262994689c1Smrg ::) dllsearchpath=$dir;; 7263f353fbadSmrg *) func_append dllsearchpath ":$dir";; 7264994689c1Smrg esac 7265994689c1Smrg case :$dllsearchpath: in 7266994689c1Smrg *":$testbindir:"*) ;; 7267994689c1Smrg ::) dllsearchpath=$testbindir;; 7268f353fbadSmrg *) func_append dllsearchpath ":$testbindir";; 7269994689c1Smrg esac 7270994689c1Smrg ;; 7271994689c1Smrg esac 7272994689c1Smrg continue 7273994689c1Smrg ;; 7274775e7de9Smrg 7275994689c1Smrg -l*) 72765ec34c4cSmrg if test X-lc = "X$arg" || test X-lm = "X$arg"; then 7277994689c1Smrg case $host in 7278994689c1Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) 7279994689c1Smrg # These systems don't actually have a C or math library (as such) 7280994689c1Smrg continue 7281994689c1Smrg ;; 7282994689c1Smrg *-*-os2*) 7283994689c1Smrg # These systems don't actually have a C library (as such) 72845ec34c4cSmrg test X-lc = "X$arg" && continue 7285994689c1Smrg ;; 72865b16253fSmrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig* | *-*-midnightbsd*) 7287994689c1Smrg # Do not include libc due to us having libc/libc_r. 72885ec34c4cSmrg test X-lc = "X$arg" && continue 7289994689c1Smrg ;; 7290994689c1Smrg *-*-rhapsody* | *-*-darwin1.[012]) 7291994689c1Smrg # Rhapsody C and math libraries are in the System framework 7292f353fbadSmrg func_append deplibs " System.ltframework" 7293994689c1Smrg continue 7294994689c1Smrg ;; 7295994689c1Smrg *-*-sco3.2v5* | *-*-sco5v6*) 7296994689c1Smrg # Causes problems with __ctype 72975ec34c4cSmrg test X-lc = "X$arg" && continue 7298994689c1Smrg ;; 7299994689c1Smrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 7300994689c1Smrg # Compiler inserts libc in the correct place for threads to work 73015ec34c4cSmrg test X-lc = "X$arg" && continue 7302994689c1Smrg ;; 7303994689c1Smrg esac 73045ec34c4cSmrg elif test X-lc_r = "X$arg"; then 7305994689c1Smrg case $host in 73065b16253fSmrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig* | *-*-midnightbsd*) 7307994689c1Smrg # Do not include libc_r directly, use -pthread flag. 7308994689c1Smrg continue 7309994689c1Smrg ;; 7310994689c1Smrg esac 7311994689c1Smrg fi 7312f353fbadSmrg func_append deplibs " $arg" 7313994689c1Smrg continue 7314994689c1Smrg ;; 7315775e7de9Smrg 73165ec34c4cSmrg -mllvm) 73175ec34c4cSmrg prev=mllvm 73185ec34c4cSmrg continue 73195ec34c4cSmrg ;; 73205ec34c4cSmrg 7321994689c1Smrg -module) 7322994689c1Smrg module=yes 7323994689c1Smrg continue 7324994689c1Smrg ;; 7325775e7de9Smrg 7326994689c1Smrg # Tru64 UNIX uses -model [arg] to determine the layout of C++ 7327994689c1Smrg # classes, name mangling, and exception handling. 7328994689c1Smrg # Darwin uses the -arch flag to determine output architecture. 7329f353fbadSmrg -model|-arch|-isysroot|--sysroot) 7330f353fbadSmrg func_append compiler_flags " $arg" 7331994689c1Smrg func_append compile_command " $arg" 7332994689c1Smrg func_append finalize_command " $arg" 7333994689c1Smrg prev=xcompiler 7334994689c1Smrg continue 7335994689c1Smrg ;; 73365b16253fSmrg # Solaris ld rejects as of 11.4. Refer to Oracle bug 22985199. 73375b16253fSmrg -pthread) 73385b16253fSmrg case $host in 73395b16253fSmrg *solaris2*) ;; 73405b16253fSmrg *) 73415b16253fSmrg case "$new_inherited_linker_flags " in 73425b16253fSmrg *" $arg "*) ;; 73435b16253fSmrg * ) func_append new_inherited_linker_flags " $arg" ;; 73445b16253fSmrg esac 73455b16253fSmrg ;; 73465b16253fSmrg esac 73475b16253fSmrg continue 73485b16253fSmrg ;; 73495b16253fSmrg -mt|-mthreads|-kthread|-Kthread|-pthreads|--thread-safe \ 7350421c997bSmrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 7351f353fbadSmrg func_append compiler_flags " $arg" 7352994689c1Smrg func_append compile_command " $arg" 7353994689c1Smrg func_append finalize_command " $arg" 7354994689c1Smrg case "$new_inherited_linker_flags " in 7355994689c1Smrg *" $arg "*) ;; 7356f353fbadSmrg * ) func_append new_inherited_linker_flags " $arg" ;; 7357994689c1Smrg esac 7358994689c1Smrg continue 7359994689c1Smrg ;; 7360775e7de9Smrg 7361994689c1Smrg -multi_module) 73625ec34c4cSmrg single_module=$wl-multi_module 7363994689c1Smrg continue 7364994689c1Smrg ;; 7365775e7de9Smrg 7366994689c1Smrg -no-fast-install) 7367994689c1Smrg fast_install=no 7368994689c1Smrg continue 7369994689c1Smrg ;; 7370775e7de9Smrg 7371994689c1Smrg -no-install) 7372994689c1Smrg case $host in 7373994689c1Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) 7374994689c1Smrg # The PATH hackery in wrapper scripts is required on Windows 7375994689c1Smrg # and Darwin in order for the loader to find any dlls it needs. 73765ec34c4cSmrg func_warning "'-no-install' is ignored for $host" 73775ec34c4cSmrg func_warning "assuming '-no-fast-install' instead" 7378994689c1Smrg fast_install=no 7379994689c1Smrg ;; 7380994689c1Smrg *) no_install=yes ;; 7381994689c1Smrg esac 7382994689c1Smrg continue 7383994689c1Smrg ;; 7384775e7de9Smrg 7385994689c1Smrg -no-undefined) 7386994689c1Smrg allow_undefined=no 7387994689c1Smrg continue 7388994689c1Smrg ;; 7389775e7de9Smrg 7390994689c1Smrg -objectlist) 7391994689c1Smrg prev=objectlist 7392994689c1Smrg continue 7393994689c1Smrg ;; 7394775e7de9Smrg 73955ec34c4cSmrg -os2dllname) 73965ec34c4cSmrg prev=os2dllname 73975ec34c4cSmrg continue 73985ec34c4cSmrg ;; 73995ec34c4cSmrg 7400994689c1Smrg -o) prev=output ;; 7401775e7de9Smrg 7402994689c1Smrg -precious-files-regex) 7403994689c1Smrg prev=precious_regex 7404994689c1Smrg continue 7405994689c1Smrg ;; 7406775e7de9Smrg 7407994689c1Smrg -release) 7408994689c1Smrg prev=release 7409994689c1Smrg continue 7410994689c1Smrg ;; 7411775e7de9Smrg 7412994689c1Smrg -rpath) 7413994689c1Smrg prev=rpath 7414994689c1Smrg continue 7415994689c1Smrg ;; 7416775e7de9Smrg 7417994689c1Smrg -R) 7418994689c1Smrg prev=xrpath 7419994689c1Smrg continue 7420994689c1Smrg ;; 7421775e7de9Smrg 7422994689c1Smrg -R*) 7423994689c1Smrg func_stripname '-R' '' "$arg" 7424994689c1Smrg dir=$func_stripname_result 7425994689c1Smrg # We need an absolute path. 7426994689c1Smrg case $dir in 7427994689c1Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 7428f353fbadSmrg =*) 7429f353fbadSmrg func_stripname '=' '' "$dir" 7430f353fbadSmrg dir=$lt_sysroot$func_stripname_result 7431f353fbadSmrg ;; 7432994689c1Smrg *) 7433994689c1Smrg func_fatal_error "only absolute run-paths are allowed" 7434994689c1Smrg ;; 7435994689c1Smrg esac 7436994689c1Smrg case "$xrpath " in 7437994689c1Smrg *" $dir "*) ;; 7438f353fbadSmrg *) func_append xrpath " $dir" ;; 7439994689c1Smrg esac 7440994689c1Smrg continue 7441994689c1Smrg ;; 7442775e7de9Smrg 7443994689c1Smrg -shared) 7444994689c1Smrg # The effects of -shared are defined in a previous loop. 7445994689c1Smrg continue 7446994689c1Smrg ;; 7447775e7de9Smrg 7448994689c1Smrg -shrext) 7449994689c1Smrg prev=shrext 7450994689c1Smrg continue 7451994689c1Smrg ;; 7452775e7de9Smrg 7453994689c1Smrg -static | -static-libtool-libs) 7454994689c1Smrg # The effects of -static are defined in a previous loop. 7455994689c1Smrg # We used to do the same as -all-static on platforms that 7456994689c1Smrg # didn't have a PIC flag, but the assumption that the effects 7457994689c1Smrg # would be equivalent was wrong. It would break on at least 7458994689c1Smrg # Digital Unix and AIX. 7459994689c1Smrg continue 7460994689c1Smrg ;; 7461775e7de9Smrg 7462994689c1Smrg -thread-safe) 7463994689c1Smrg thread_safe=yes 7464994689c1Smrg continue 7465994689c1Smrg ;; 7466775e7de9Smrg 7467994689c1Smrg -version-info) 7468994689c1Smrg prev=vinfo 7469994689c1Smrg continue 7470994689c1Smrg ;; 7471775e7de9Smrg 7472994689c1Smrg -version-number) 7473994689c1Smrg prev=vinfo 7474994689c1Smrg vinfo_number=yes 7475994689c1Smrg continue 7476994689c1Smrg ;; 74777a84e134Smrg 7478994689c1Smrg -weak) 7479994689c1Smrg prev=weak 7480994689c1Smrg continue 7481994689c1Smrg ;; 7482e1e1713cSmrg 7483994689c1Smrg -Wc,*) 7484994689c1Smrg func_stripname '-Wc,' '' "$arg" 7485994689c1Smrg args=$func_stripname_result 7486994689c1Smrg arg= 74875ec34c4cSmrg save_ifs=$IFS; IFS=, 7488994689c1Smrg for flag in $args; do 74895ec34c4cSmrg IFS=$save_ifs 74905b16253fSmrg func_quote_arg pretty "$flag" 74915b16253fSmrg func_append arg " $func_quote_arg_result" 74925b16253fSmrg func_append compiler_flags " $func_quote_arg_result" 7493994689c1Smrg done 74945ec34c4cSmrg IFS=$save_ifs 7495994689c1Smrg func_stripname ' ' '' "$arg" 7496994689c1Smrg arg=$func_stripname_result 7497994689c1Smrg ;; 7498e1e1713cSmrg 7499994689c1Smrg -Wl,*) 7500994689c1Smrg func_stripname '-Wl,' '' "$arg" 7501994689c1Smrg args=$func_stripname_result 7502994689c1Smrg arg= 75035ec34c4cSmrg save_ifs=$IFS; IFS=, 7504994689c1Smrg for flag in $args; do 75055ec34c4cSmrg IFS=$save_ifs 75065b16253fSmrg func_quote_arg pretty "$flag" 75075b16253fSmrg func_append arg " $wl$func_quote_arg_result" 75085b16253fSmrg func_append compiler_flags " $wl$func_quote_arg_result" 75095b16253fSmrg func_append linker_flags " $func_quote_arg_result" 7510994689c1Smrg done 75115ec34c4cSmrg IFS=$save_ifs 7512994689c1Smrg func_stripname ' ' '' "$arg" 7513994689c1Smrg arg=$func_stripname_result 7514994689c1Smrg ;; 7515e1e1713cSmrg 75165b16253fSmrg -Xassembler) 75175b16253fSmrg prev=xassembler 75185b16253fSmrg continue 75195b16253fSmrg ;; 75205b16253fSmrg 7521994689c1Smrg -Xcompiler) 7522994689c1Smrg prev=xcompiler 7523994689c1Smrg continue 7524994689c1Smrg ;; 7525e1e1713cSmrg 7526994689c1Smrg -Xlinker) 7527994689c1Smrg prev=xlinker 7528994689c1Smrg continue 7529994689c1Smrg ;; 7530e1e1713cSmrg 7531994689c1Smrg -XCClinker) 7532994689c1Smrg prev=xcclinker 7533994689c1Smrg continue 7534994689c1Smrg ;; 7535e1e1713cSmrg 7536994689c1Smrg # -msg_* for osf cc 7537994689c1Smrg -msg_*) 75385b16253fSmrg func_quote_arg pretty "$arg" 75395b16253fSmrg arg=$func_quote_arg_result 7540994689c1Smrg ;; 7541e1e1713cSmrg 7542994689c1Smrg # Flags to be passed through unchanged, with rationale: 7543994689c1Smrg # -64, -mips[0-9] enable 64-bit mode for the SGI compiler 7544994689c1Smrg # -r[0-9][0-9]* specify processor for the SGI compiler 7545994689c1Smrg # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler 7546994689c1Smrg # +DA*, +DD* enable 64-bit mode for the HP compiler 7547994689c1Smrg # -q* compiler args for the IBM compiler 7548994689c1Smrg # -m*, -t[45]*, -txscale* architecture-specific flags for GCC 7549994689c1Smrg # -F/path path to uninstalled frameworks, gcc on darwin 7550994689c1Smrg # -p, -pg, --coverage, -fprofile-* profiling flags for GCC 75515ec34c4cSmrg # -fstack-protector* stack protector flags for GCC 7552994689c1Smrg # @file GCC response files 7553994689c1Smrg # -tp=* Portland pgcc target processor selection 7554f353fbadSmrg # --sysroot=* for sysroot support 75555ec34c4cSmrg # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization 75565ec34c4cSmrg # -specs=* GCC specs files 75575ec34c4cSmrg # -stdlib=* select c++ std lib with clang 75585ec34c4cSmrg # -fsanitize=* Clang/GCC memory and address sanitizer 75595ec34c4cSmrg # -fuse-ld=* Linker select flags for GCC 75605b16253fSmrg # -Wa,* Pass flags directly to the assembler 7561994689c1Smrg -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ 7562f353fbadSmrg -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ 75635ec34c4cSmrg -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*| \ 75645b16253fSmrg -specs=*|-fsanitize=*|-fuse-ld=*|-Wa,*) 75655b16253fSmrg func_quote_arg pretty "$arg" 75665b16253fSmrg arg=$func_quote_arg_result 7567994689c1Smrg func_append compile_command " $arg" 7568994689c1Smrg func_append finalize_command " $arg" 7569f353fbadSmrg func_append compiler_flags " $arg" 7570994689c1Smrg continue 7571994689c1Smrg ;; 7572e1e1713cSmrg 75735ec34c4cSmrg -Z*) 75745ec34c4cSmrg if test os2 = "`expr $host : '.*\(os2\)'`"; then 75755ec34c4cSmrg # OS/2 uses -Zxxx to specify OS/2-specific options 75765ec34c4cSmrg compiler_flags="$compiler_flags $arg" 75775ec34c4cSmrg func_append compile_command " $arg" 75785ec34c4cSmrg func_append finalize_command " $arg" 75795ec34c4cSmrg case $arg in 75805ec34c4cSmrg -Zlinker | -Zstack) 75815ec34c4cSmrg prev=xcompiler 75825ec34c4cSmrg ;; 75835ec34c4cSmrg esac 75845ec34c4cSmrg continue 75855ec34c4cSmrg else 75865ec34c4cSmrg # Otherwise treat like 'Some other compiler flag' below 75875b16253fSmrg func_quote_arg pretty "$arg" 75885b16253fSmrg arg=$func_quote_arg_result 75895ec34c4cSmrg fi 75905ec34c4cSmrg ;; 75915ec34c4cSmrg 7592994689c1Smrg # Some other compiler flag. 7593994689c1Smrg -* | +*) 75945b16253fSmrg func_quote_arg pretty "$arg" 75955b16253fSmrg arg=$func_quote_arg_result 7596994689c1Smrg ;; 7597e1e1713cSmrg 7598994689c1Smrg *.$objext) 7599994689c1Smrg # A standard object. 7600f353fbadSmrg func_append objs " $arg" 7601994689c1Smrg ;; 7602e1e1713cSmrg 7603994689c1Smrg *.lo) 7604994689c1Smrg # A libtool-controlled object. 7605e1e1713cSmrg 7606994689c1Smrg # Check to see that this really is a libtool object. 7607994689c1Smrg if func_lalib_unsafe_p "$arg"; then 7608994689c1Smrg pic_object= 7609994689c1Smrg non_pic_object= 7610e1e1713cSmrg 7611994689c1Smrg # Read the .lo file 7612994689c1Smrg func_source "$arg" 7613e1e1713cSmrg 7614994689c1Smrg if test -z "$pic_object" || 7615994689c1Smrg test -z "$non_pic_object" || 76165ec34c4cSmrg test none = "$pic_object" && 76175ec34c4cSmrg test none = "$non_pic_object"; then 76185ec34c4cSmrg func_fatal_error "cannot find name of object for '$arg'" 7619994689c1Smrg fi 7620e1e1713cSmrg 7621994689c1Smrg # Extract subdirectory from the argument. 7622994689c1Smrg func_dirname "$arg" "/" "" 76235ec34c4cSmrg xdir=$func_dirname_result 7624e1e1713cSmrg 76255ec34c4cSmrg test none = "$pic_object" || { 7626994689c1Smrg # Prepend the subdirectory the object is found in. 76275ec34c4cSmrg pic_object=$xdir$pic_object 7628e1e1713cSmrg 76295ec34c4cSmrg if test dlfiles = "$prev"; then 76305ec34c4cSmrg if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 7631f353fbadSmrg func_append dlfiles " $pic_object" 7632994689c1Smrg prev= 7633994689c1Smrg continue 7634994689c1Smrg else 7635994689c1Smrg # If libtool objects are unsupported, then we need to preload. 7636994689c1Smrg prev=dlprefiles 7637994689c1Smrg fi 7638994689c1Smrg fi 7639994689c1Smrg 7640994689c1Smrg # CHECK ME: I think I busted this. -Ossama 76415ec34c4cSmrg if test dlprefiles = "$prev"; then 7642994689c1Smrg # Preload the old-style object. 7643f353fbadSmrg func_append dlprefiles " $pic_object" 7644994689c1Smrg prev= 7645994689c1Smrg fi 7646994689c1Smrg 7647994689c1Smrg # A PIC object. 7648994689c1Smrg func_append libobjs " $pic_object" 76495ec34c4cSmrg arg=$pic_object 76505ec34c4cSmrg } 7651994689c1Smrg 7652994689c1Smrg # Non-PIC object. 76535ec34c4cSmrg if test none != "$non_pic_object"; then 7654994689c1Smrg # Prepend the subdirectory the object is found in. 76555ec34c4cSmrg non_pic_object=$xdir$non_pic_object 7656994689c1Smrg 7657994689c1Smrg # A standard non-PIC object 7658994689c1Smrg func_append non_pic_objects " $non_pic_object" 76595ec34c4cSmrg if test -z "$pic_object" || test none = "$pic_object"; then 76605ec34c4cSmrg arg=$non_pic_object 7661994689c1Smrg fi 7662994689c1Smrg else 7663994689c1Smrg # If the PIC object exists, use it instead. 7664994689c1Smrg # $xdir was prepended to $pic_object above. 76655ec34c4cSmrg non_pic_object=$pic_object 7666994689c1Smrg func_append non_pic_objects " $non_pic_object" 7667994689c1Smrg fi 7668994689c1Smrg else 7669994689c1Smrg # Only an error if not doing a dry-run. 7670994689c1Smrg if $opt_dry_run; then 7671994689c1Smrg # Extract subdirectory from the argument. 7672994689c1Smrg func_dirname "$arg" "/" "" 76735ec34c4cSmrg xdir=$func_dirname_result 7674994689c1Smrg 7675994689c1Smrg func_lo2o "$arg" 7676994689c1Smrg pic_object=$xdir$objdir/$func_lo2o_result 7677994689c1Smrg non_pic_object=$xdir$func_lo2o_result 7678994689c1Smrg func_append libobjs " $pic_object" 7679994689c1Smrg func_append non_pic_objects " $non_pic_object" 7680994689c1Smrg else 76815ec34c4cSmrg func_fatal_error "'$arg' is not a valid libtool object" 7682994689c1Smrg fi 7683994689c1Smrg fi 7684994689c1Smrg ;; 7685994689c1Smrg 7686994689c1Smrg *.$libext) 7687994689c1Smrg # An archive. 7688f353fbadSmrg func_append deplibs " $arg" 7689f353fbadSmrg func_append old_deplibs " $arg" 7690994689c1Smrg continue 7691994689c1Smrg ;; 7692994689c1Smrg 7693994689c1Smrg *.la) 7694994689c1Smrg # A libtool-controlled library. 7695994689c1Smrg 7696f353fbadSmrg func_resolve_sysroot "$arg" 76975ec34c4cSmrg if test dlfiles = "$prev"; then 7698994689c1Smrg # This library was specified with -dlopen. 7699f353fbadSmrg func_append dlfiles " $func_resolve_sysroot_result" 7700994689c1Smrg prev= 77015ec34c4cSmrg elif test dlprefiles = "$prev"; then 7702994689c1Smrg # The library was specified with -dlpreopen. 7703f353fbadSmrg func_append dlprefiles " $func_resolve_sysroot_result" 7704994689c1Smrg prev= 7705994689c1Smrg else 7706f353fbadSmrg func_append deplibs " $func_resolve_sysroot_result" 7707994689c1Smrg fi 7708994689c1Smrg continue 7709994689c1Smrg ;; 7710994689c1Smrg 7711994689c1Smrg # Some other compiler argument. 7712994689c1Smrg *) 7713994689c1Smrg # Unknown arguments in both finalize_command and compile_command need 7714994689c1Smrg # to be aesthetically quoted because they are evaled later. 77155b16253fSmrg func_quote_arg pretty "$arg" 77165b16253fSmrg arg=$func_quote_arg_result 7717994689c1Smrg ;; 7718994689c1Smrg esac # arg 7719994689c1Smrg 7720994689c1Smrg # Now actually substitute the argument into the commands. 7721994689c1Smrg if test -n "$arg"; then 7722994689c1Smrg func_append compile_command " $arg" 7723994689c1Smrg func_append finalize_command " $arg" 7724994689c1Smrg fi 7725994689c1Smrg done # argument parsing loop 7726994689c1Smrg 7727994689c1Smrg test -n "$prev" && \ 77285ec34c4cSmrg func_fatal_help "the '$prevarg' option requires an argument" 7729994689c1Smrg 77305ec34c4cSmrg if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then 7731994689c1Smrg eval arg=\"$export_dynamic_flag_spec\" 7732994689c1Smrg func_append compile_command " $arg" 7733994689c1Smrg func_append finalize_command " $arg" 7734994689c1Smrg fi 7735994689c1Smrg 7736994689c1Smrg oldlibs= 7737994689c1Smrg # calculate the name of the file, without its directory 7738994689c1Smrg func_basename "$output" 77395ec34c4cSmrg outputname=$func_basename_result 77405ec34c4cSmrg libobjs_save=$libobjs 7741994689c1Smrg 7742994689c1Smrg if test -n "$shlibpath_var"; then 7743994689c1Smrg # get the directories listed in $shlibpath_var 77445ec34c4cSmrg eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\` 7745e1e1713cSmrg else 7746994689c1Smrg shlib_search_path= 7747e1e1713cSmrg fi 7748994689c1Smrg eval sys_lib_search_path=\"$sys_lib_search_path_spec\" 7749994689c1Smrg eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" 77507a84e134Smrg 77515ec34c4cSmrg # Definition is injected by LT_CONFIG during libtool generation. 77525ec34c4cSmrg func_munge_path_list sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH" 77535ec34c4cSmrg 7754994689c1Smrg func_dirname "$output" "/" "" 77555ec34c4cSmrg output_objdir=$func_dirname_result$objdir 7756f353fbadSmrg func_to_tool_file "$output_objdir/" 7757f353fbadSmrg tool_output_objdir=$func_to_tool_file_result 7758994689c1Smrg # Create the object directory. 7759994689c1Smrg func_mkdir_p "$output_objdir" 77607a84e134Smrg 7761994689c1Smrg # Determine the type of output 7762994689c1Smrg case $output in 7763994689c1Smrg "") 7764994689c1Smrg func_fatal_help "you must specify an output file" 7765994689c1Smrg ;; 7766994689c1Smrg *.$libext) linkmode=oldlib ;; 7767994689c1Smrg *.lo | *.$objext) linkmode=obj ;; 7768994689c1Smrg *.la) linkmode=lib ;; 7769994689c1Smrg *) linkmode=prog ;; # Anything else should be a program. 7770994689c1Smrg esac 7771994689c1Smrg 7772994689c1Smrg specialdeplibs= 7773994689c1Smrg 7774994689c1Smrg libs= 7775994689c1Smrg # Find all interdependent deplibs by searching for libraries 7776994689c1Smrg # that are linked more than once (e.g. -la -lb -la) 7777994689c1Smrg for deplib in $deplibs; do 77785ec34c4cSmrg if $opt_preserve_dup_deps; then 7779994689c1Smrg case "$libs " in 7780f353fbadSmrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 7781994689c1Smrg esac 7782994689c1Smrg fi 7783f353fbadSmrg func_append libs " $deplib" 7784994689c1Smrg done 7785994689c1Smrg 77865ec34c4cSmrg if test lib = "$linkmode"; then 7787994689c1Smrg libs="$predeps $libs $compiler_lib_search_path $postdeps" 7788994689c1Smrg 7789994689c1Smrg # Compute libraries that are listed more than once in $predeps 7790994689c1Smrg # $postdeps and mark them as special (i.e., whose duplicates are 7791994689c1Smrg # not to be eliminated). 7792994689c1Smrg pre_post_deps= 7793994689c1Smrg if $opt_duplicate_compiler_generated_deps; then 7794994689c1Smrg for pre_post_dep in $predeps $postdeps; do 7795994689c1Smrg case "$pre_post_deps " in 7796f353fbadSmrg *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; 7797994689c1Smrg esac 7798f353fbadSmrg func_append pre_post_deps " $pre_post_dep" 7799994689c1Smrg done 7800994689c1Smrg fi 7801994689c1Smrg pre_post_deps= 7802994689c1Smrg fi 7803994689c1Smrg 7804994689c1Smrg deplibs= 7805994689c1Smrg newdependency_libs= 7806994689c1Smrg newlib_search_path= 7807994689c1Smrg need_relink=no # whether we're linking any uninstalled libtool libraries 7808994689c1Smrg notinst_deplibs= # not-installed libtool libraries 7809994689c1Smrg notinst_path= # paths that contain not-installed libtool libraries 7810994689c1Smrg 7811994689c1Smrg case $linkmode in 7812994689c1Smrg lib) 7813994689c1Smrg passes="conv dlpreopen link" 7814994689c1Smrg for file in $dlfiles $dlprefiles; do 7815994689c1Smrg case $file in 7816994689c1Smrg *.la) ;; 7817994689c1Smrg *) 78185ec34c4cSmrg func_fatal_help "libraries can '-dlopen' only libtool libraries: $file" 7819994689c1Smrg ;; 7820994689c1Smrg esac 7821994689c1Smrg done 7822994689c1Smrg ;; 7823994689c1Smrg prog) 7824994689c1Smrg compile_deplibs= 7825994689c1Smrg finalize_deplibs= 78265ec34c4cSmrg alldeplibs=false 7827994689c1Smrg newdlfiles= 7828994689c1Smrg newdlprefiles= 7829994689c1Smrg passes="conv scan dlopen dlpreopen link" 7830994689c1Smrg ;; 7831994689c1Smrg *) passes="conv" 7832994689c1Smrg ;; 7833994689c1Smrg esac 7834994689c1Smrg 7835994689c1Smrg for pass in $passes; do 7836994689c1Smrg # The preopen pass in lib mode reverses $deplibs; put it back here 7837994689c1Smrg # so that -L comes before libs that need it for instance... 78385ec34c4cSmrg if test lib,link = "$linkmode,$pass"; then 7839994689c1Smrg ## FIXME: Find the place where the list is rebuilt in the wrong 7840994689c1Smrg ## order, and fix it there properly 7841994689c1Smrg tmp_deplibs= 7842994689c1Smrg for deplib in $deplibs; do 7843994689c1Smrg tmp_deplibs="$deplib $tmp_deplibs" 7844994689c1Smrg done 78455ec34c4cSmrg deplibs=$tmp_deplibs 7846994689c1Smrg fi 7847994689c1Smrg 78485ec34c4cSmrg if test lib,link = "$linkmode,$pass" || 78495ec34c4cSmrg test prog,scan = "$linkmode,$pass"; then 78505ec34c4cSmrg libs=$deplibs 7851994689c1Smrg deplibs= 7852994689c1Smrg fi 78535ec34c4cSmrg if test prog = "$linkmode"; then 7854994689c1Smrg case $pass in 78555ec34c4cSmrg dlopen) libs=$dlfiles ;; 78565ec34c4cSmrg dlpreopen) libs=$dlprefiles ;; 7857994689c1Smrg link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; 7858994689c1Smrg esac 7859994689c1Smrg fi 78605ec34c4cSmrg if test lib,dlpreopen = "$linkmode,$pass"; then 7861994689c1Smrg # Collect and forward deplibs of preopened libtool libs 7862994689c1Smrg for lib in $dlprefiles; do 7863994689c1Smrg # Ignore non-libtool-libs 7864994689c1Smrg dependency_libs= 7865f353fbadSmrg func_resolve_sysroot "$lib" 7866994689c1Smrg case $lib in 7867f353fbadSmrg *.la) func_source "$func_resolve_sysroot_result" ;; 7868994689c1Smrg esac 7869994689c1Smrg 7870994689c1Smrg # Collect preopened libtool deplibs, except any this library 7871994689c1Smrg # has declared as weak libs 7872994689c1Smrg for deplib in $dependency_libs; do 7873994689c1Smrg func_basename "$deplib" 7874994689c1Smrg deplib_base=$func_basename_result 7875994689c1Smrg case " $weak_libs " in 7876994689c1Smrg *" $deplib_base "*) ;; 7877f353fbadSmrg *) func_append deplibs " $deplib" ;; 7878994689c1Smrg esac 7879994689c1Smrg done 7880994689c1Smrg done 78815ec34c4cSmrg libs=$dlprefiles 7882994689c1Smrg fi 78835ec34c4cSmrg if test dlopen = "$pass"; then 7884994689c1Smrg # Collect dlpreopened libraries 78855ec34c4cSmrg save_deplibs=$deplibs 7886994689c1Smrg deplibs= 7887994689c1Smrg fi 7888994689c1Smrg 7889994689c1Smrg for deplib in $libs; do 7890994689c1Smrg lib= 78915ec34c4cSmrg found=false 7892994689c1Smrg case $deplib in 7893421c997bSmrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 7894421c997bSmrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 78955ec34c4cSmrg if test prog,link = "$linkmode,$pass"; then 7896994689c1Smrg compile_deplibs="$deplib $compile_deplibs" 7897994689c1Smrg finalize_deplibs="$deplib $finalize_deplibs" 7898994689c1Smrg else 7899f353fbadSmrg func_append compiler_flags " $deplib" 79005ec34c4cSmrg if test lib = "$linkmode"; then 7901994689c1Smrg case "$new_inherited_linker_flags " in 7902994689c1Smrg *" $deplib "*) ;; 7903f353fbadSmrg * ) func_append new_inherited_linker_flags " $deplib" ;; 7904994689c1Smrg esac 7905994689c1Smrg fi 7906994689c1Smrg fi 7907994689c1Smrg continue 7908994689c1Smrg ;; 7909994689c1Smrg -l*) 79105ec34c4cSmrg if test lib != "$linkmode" && test prog != "$linkmode"; then 79115ec34c4cSmrg func_warning "'-l' is ignored for archives/objects" 7912994689c1Smrg continue 7913994689c1Smrg fi 7914994689c1Smrg func_stripname '-l' '' "$deplib" 7915994689c1Smrg name=$func_stripname_result 79165ec34c4cSmrg if test lib = "$linkmode"; then 7917994689c1Smrg searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" 7918994689c1Smrg else 7919994689c1Smrg searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" 7920994689c1Smrg fi 7921994689c1Smrg for searchdir in $searchdirs; do 7922994689c1Smrg for search_ext in .la $std_shrext .so .a; do 7923994689c1Smrg # Search the libtool library 79245ec34c4cSmrg lib=$searchdir/lib$name$search_ext 7925994689c1Smrg if test -f "$lib"; then 79265ec34c4cSmrg if test .la = "$search_ext"; then 79275ec34c4cSmrg found=: 7928994689c1Smrg else 79295ec34c4cSmrg found=false 7930994689c1Smrg fi 7931994689c1Smrg break 2 7932994689c1Smrg fi 7933994689c1Smrg done 7934994689c1Smrg done 79355ec34c4cSmrg if $found; then 79365ec34c4cSmrg # deplib is a libtool library 7937994689c1Smrg # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, 7938994689c1Smrg # We need to do some special things here, and not later. 79395ec34c4cSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 7940994689c1Smrg case " $predeps $postdeps " in 7941994689c1Smrg *" $deplib "*) 7942994689c1Smrg if func_lalib_p "$lib"; then 7943994689c1Smrg library_names= 7944994689c1Smrg old_library= 7945994689c1Smrg func_source "$lib" 7946994689c1Smrg for l in $old_library $library_names; do 79475ec34c4cSmrg ll=$l 7948994689c1Smrg done 79495ec34c4cSmrg if test "X$ll" = "X$old_library"; then # only static version available 79505ec34c4cSmrg found=false 7951994689c1Smrg func_dirname "$lib" "" "." 79525ec34c4cSmrg ladir=$func_dirname_result 7953994689c1Smrg lib=$ladir/$old_library 79545ec34c4cSmrg if test prog,link = "$linkmode,$pass"; then 7955994689c1Smrg compile_deplibs="$deplib $compile_deplibs" 7956994689c1Smrg finalize_deplibs="$deplib $finalize_deplibs" 7957994689c1Smrg else 7958994689c1Smrg deplibs="$deplib $deplibs" 79595ec34c4cSmrg test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 7960994689c1Smrg fi 7961994689c1Smrg continue 7962994689c1Smrg fi 7963994689c1Smrg fi 7964994689c1Smrg ;; 7965994689c1Smrg *) ;; 7966994689c1Smrg esac 7967994689c1Smrg fi 79685ec34c4cSmrg else 79695ec34c4cSmrg # deplib doesn't seem to be a libtool library 79705ec34c4cSmrg if test prog,link = "$linkmode,$pass"; then 79715ec34c4cSmrg compile_deplibs="$deplib $compile_deplibs" 79725ec34c4cSmrg finalize_deplibs="$deplib $finalize_deplibs" 79735ec34c4cSmrg else 79745ec34c4cSmrg deplibs="$deplib $deplibs" 79755ec34c4cSmrg test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 79765ec34c4cSmrg fi 79775ec34c4cSmrg continue 7978994689c1Smrg fi 7979994689c1Smrg ;; # -l 7980994689c1Smrg *.ltframework) 79815ec34c4cSmrg if test prog,link = "$linkmode,$pass"; then 7982994689c1Smrg compile_deplibs="$deplib $compile_deplibs" 7983994689c1Smrg finalize_deplibs="$deplib $finalize_deplibs" 7984994689c1Smrg else 7985994689c1Smrg deplibs="$deplib $deplibs" 79865ec34c4cSmrg if test lib = "$linkmode"; then 7987994689c1Smrg case "$new_inherited_linker_flags " in 7988994689c1Smrg *" $deplib "*) ;; 7989f353fbadSmrg * ) func_append new_inherited_linker_flags " $deplib" ;; 7990994689c1Smrg esac 7991994689c1Smrg fi 7992994689c1Smrg fi 7993994689c1Smrg continue 7994994689c1Smrg ;; 7995994689c1Smrg -L*) 7996994689c1Smrg case $linkmode in 7997994689c1Smrg lib) 7998994689c1Smrg deplibs="$deplib $deplibs" 79995ec34c4cSmrg test conv = "$pass" && continue 8000994689c1Smrg newdependency_libs="$deplib $newdependency_libs" 8001994689c1Smrg func_stripname '-L' '' "$deplib" 8002f353fbadSmrg func_resolve_sysroot "$func_stripname_result" 8003f353fbadSmrg func_append newlib_search_path " $func_resolve_sysroot_result" 8004994689c1Smrg ;; 8005994689c1Smrg prog) 80065ec34c4cSmrg if test conv = "$pass"; then 8007994689c1Smrg deplibs="$deplib $deplibs" 8008994689c1Smrg continue 8009994689c1Smrg fi 80105ec34c4cSmrg if test scan = "$pass"; then 8011994689c1Smrg deplibs="$deplib $deplibs" 8012994689c1Smrg else 8013994689c1Smrg compile_deplibs="$deplib $compile_deplibs" 8014994689c1Smrg finalize_deplibs="$deplib $finalize_deplibs" 8015994689c1Smrg fi 8016994689c1Smrg func_stripname '-L' '' "$deplib" 8017f353fbadSmrg func_resolve_sysroot "$func_stripname_result" 8018f353fbadSmrg func_append newlib_search_path " $func_resolve_sysroot_result" 8019994689c1Smrg ;; 8020994689c1Smrg *) 80215ec34c4cSmrg func_warning "'-L' is ignored for archives/objects" 8022994689c1Smrg ;; 8023994689c1Smrg esac # linkmode 8024994689c1Smrg continue 8025994689c1Smrg ;; # -L 8026994689c1Smrg -R*) 80275ec34c4cSmrg if test link = "$pass"; then 8028994689c1Smrg func_stripname '-R' '' "$deplib" 8029f353fbadSmrg func_resolve_sysroot "$func_stripname_result" 8030f353fbadSmrg dir=$func_resolve_sysroot_result 8031994689c1Smrg # Make sure the xrpath contains only unique directories. 8032994689c1Smrg case "$xrpath " in 8033994689c1Smrg *" $dir "*) ;; 8034f353fbadSmrg *) func_append xrpath " $dir" ;; 8035994689c1Smrg esac 8036994689c1Smrg fi 8037994689c1Smrg deplibs="$deplib $deplibs" 8038994689c1Smrg continue 8039994689c1Smrg ;; 8040f353fbadSmrg *.la) 8041f353fbadSmrg func_resolve_sysroot "$deplib" 8042f353fbadSmrg lib=$func_resolve_sysroot_result 8043f353fbadSmrg ;; 8044994689c1Smrg *.$libext) 80455ec34c4cSmrg if test conv = "$pass"; then 8046994689c1Smrg deplibs="$deplib $deplibs" 8047994689c1Smrg continue 8048994689c1Smrg fi 8049994689c1Smrg case $linkmode in 8050994689c1Smrg lib) 8051994689c1Smrg # Linking convenience modules into shared libraries is allowed, 8052994689c1Smrg # but linking other static libraries is non-portable. 8053994689c1Smrg case " $dlpreconveniencelibs " in 8054994689c1Smrg *" $deplib "*) ;; 8055994689c1Smrg *) 80565ec34c4cSmrg valid_a_lib=false 8057994689c1Smrg case $deplibs_check_method in 8058994689c1Smrg match_pattern*) 8059994689c1Smrg set dummy $deplibs_check_method; shift 8060994689c1Smrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 8061994689c1Smrg if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ 8062994689c1Smrg | $EGREP "$match_pattern_regex" > /dev/null; then 80635ec34c4cSmrg valid_a_lib=: 8064994689c1Smrg fi 8065994689c1Smrg ;; 8066994689c1Smrg pass_all) 80675ec34c4cSmrg valid_a_lib=: 8068994689c1Smrg ;; 8069994689c1Smrg esac 80705ec34c4cSmrg if $valid_a_lib; then 80715ec34c4cSmrg echo 80725ec34c4cSmrg $ECHO "*** Warning: Linking the shared library $output against the" 80735ec34c4cSmrg $ECHO "*** static library $deplib is not portable!" 80745ec34c4cSmrg deplibs="$deplib $deplibs" 80755ec34c4cSmrg else 8076994689c1Smrg echo 8077994689c1Smrg $ECHO "*** Warning: Trying to link with static lib archive $deplib." 8078994689c1Smrg echo "*** I have the capability to make that library automatically link in when" 8079994689c1Smrg echo "*** you link to this library. But I can only do this if you have a" 8080994689c1Smrg echo "*** shared version of the library, which you do not appear to have" 8081994689c1Smrg echo "*** because the file extensions .$libext of this argument makes me believe" 8082994689c1Smrg echo "*** that it is just a static archive that I should not use here." 8083994689c1Smrg fi 8084994689c1Smrg ;; 8085994689c1Smrg esac 8086994689c1Smrg continue 8087994689c1Smrg ;; 8088994689c1Smrg prog) 80895ec34c4cSmrg if test link != "$pass"; then 8090994689c1Smrg deplibs="$deplib $deplibs" 8091994689c1Smrg else 8092994689c1Smrg compile_deplibs="$deplib $compile_deplibs" 8093994689c1Smrg finalize_deplibs="$deplib $finalize_deplibs" 8094994689c1Smrg fi 8095994689c1Smrg continue 8096994689c1Smrg ;; 8097994689c1Smrg esac # linkmode 8098994689c1Smrg ;; # *.$libext 8099994689c1Smrg *.lo | *.$objext) 81005ec34c4cSmrg if test conv = "$pass"; then 8101994689c1Smrg deplibs="$deplib $deplibs" 81025ec34c4cSmrg elif test prog = "$linkmode"; then 81035ec34c4cSmrg if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then 8104994689c1Smrg # If there is no dlopen support or we're linking statically, 8105994689c1Smrg # we need to preload. 8106f353fbadSmrg func_append newdlprefiles " $deplib" 8107994689c1Smrg compile_deplibs="$deplib $compile_deplibs" 8108994689c1Smrg finalize_deplibs="$deplib $finalize_deplibs" 8109994689c1Smrg else 8110f353fbadSmrg func_append newdlfiles " $deplib" 8111994689c1Smrg fi 8112994689c1Smrg fi 8113994689c1Smrg continue 8114994689c1Smrg ;; 8115994689c1Smrg %DEPLIBS%) 81165ec34c4cSmrg alldeplibs=: 8117994689c1Smrg continue 8118994689c1Smrg ;; 8119994689c1Smrg esac # case $deplib 8120994689c1Smrg 81215ec34c4cSmrg $found || test -f "$lib" \ 81225ec34c4cSmrg || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'" 8123994689c1Smrg 8124994689c1Smrg # Check to see that this really is a libtool archive. 8125994689c1Smrg func_lalib_unsafe_p "$lib" \ 81265ec34c4cSmrg || func_fatal_error "'$lib' is not a valid libtool archive" 8127994689c1Smrg 8128994689c1Smrg func_dirname "$lib" "" "." 81295ec34c4cSmrg ladir=$func_dirname_result 8130994689c1Smrg 8131994689c1Smrg dlname= 8132994689c1Smrg dlopen= 8133994689c1Smrg dlpreopen= 8134994689c1Smrg libdir= 8135994689c1Smrg library_names= 8136994689c1Smrg old_library= 8137994689c1Smrg inherited_linker_flags= 8138994689c1Smrg # If the library was installed with an old release of libtool, 8139994689c1Smrg # it will not redefine variables installed, or shouldnotlink 8140994689c1Smrg installed=yes 8141994689c1Smrg shouldnotlink=no 8142994689c1Smrg avoidtemprpath= 8143994689c1Smrg 8144994689c1Smrg 8145994689c1Smrg # Read the .la file 8146994689c1Smrg func_source "$lib" 8147994689c1Smrg 8148994689c1Smrg # Convert "-framework foo" to "foo.ltframework" 8149994689c1Smrg if test -n "$inherited_linker_flags"; then 8150994689c1Smrg tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` 8151994689c1Smrg for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do 8152994689c1Smrg case " $new_inherited_linker_flags " in 8153994689c1Smrg *" $tmp_inherited_linker_flag "*) ;; 8154f353fbadSmrg *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; 8155994689c1Smrg esac 8156994689c1Smrg done 8157994689c1Smrg fi 8158994689c1Smrg dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 81595ec34c4cSmrg if test lib,link = "$linkmode,$pass" || 81605ec34c4cSmrg test prog,scan = "$linkmode,$pass" || 81615ec34c4cSmrg { test prog != "$linkmode" && test lib != "$linkmode"; }; then 8162f353fbadSmrg test -n "$dlopen" && func_append dlfiles " $dlopen" 8163f353fbadSmrg test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" 8164994689c1Smrg fi 8165994689c1Smrg 81665ec34c4cSmrg if test conv = "$pass"; then 8167994689c1Smrg # Only check for convenience libraries 8168994689c1Smrg deplibs="$lib $deplibs" 8169994689c1Smrg if test -z "$libdir"; then 8170994689c1Smrg if test -z "$old_library"; then 81715ec34c4cSmrg func_fatal_error "cannot find name of link library for '$lib'" 8172994689c1Smrg fi 8173994689c1Smrg # It is a libtool convenience library, so add in its objects. 8174f353fbadSmrg func_append convenience " $ladir/$objdir/$old_library" 8175f353fbadSmrg func_append old_convenience " $ladir/$objdir/$old_library" 81765ec34c4cSmrg elif test prog != "$linkmode" && test lib != "$linkmode"; then 81775ec34c4cSmrg func_fatal_error "'$lib' is not a convenience library" 8178994689c1Smrg fi 8179994689c1Smrg tmp_libs= 8180994689c1Smrg for deplib in $dependency_libs; do 8181994689c1Smrg deplibs="$deplib $deplibs" 81825ec34c4cSmrg if $opt_preserve_dup_deps; then 8183994689c1Smrg case "$tmp_libs " in 8184f353fbadSmrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 8185994689c1Smrg esac 8186994689c1Smrg fi 8187f353fbadSmrg func_append tmp_libs " $deplib" 8188994689c1Smrg done 8189994689c1Smrg continue 8190994689c1Smrg fi # $pass = conv 8191994689c1Smrg 8192994689c1Smrg 8193994689c1Smrg # Get the name of the library we link against. 8194994689c1Smrg linklib= 8195f353fbadSmrg if test -n "$old_library" && 81965ec34c4cSmrg { test yes = "$prefer_static_libs" || 81975ec34c4cSmrg test built,no = "$prefer_static_libs,$installed"; }; then 8198f353fbadSmrg linklib=$old_library 8199f353fbadSmrg else 8200f353fbadSmrg for l in $old_library $library_names; do 82015ec34c4cSmrg linklib=$l 8202f353fbadSmrg done 8203f353fbadSmrg fi 8204994689c1Smrg if test -z "$linklib"; then 82055ec34c4cSmrg func_fatal_error "cannot find name of link library for '$lib'" 8206994689c1Smrg fi 8207994689c1Smrg 8208994689c1Smrg # This library was specified with -dlopen. 82095ec34c4cSmrg if test dlopen = "$pass"; then 82105ec34c4cSmrg test -z "$libdir" \ 82115ec34c4cSmrg && func_fatal_error "cannot -dlopen a convenience library: '$lib'" 8212994689c1Smrg if test -z "$dlname" || 82135ec34c4cSmrg test yes != "$dlopen_support" || 82145ec34c4cSmrg test no = "$build_libtool_libs" 82155ec34c4cSmrg then 8216994689c1Smrg # If there is no dlname, no dlopen support or we're linking 8217994689c1Smrg # statically, we need to preload. We also need to preload any 8218994689c1Smrg # dependent libraries so libltdl's deplib preloader doesn't 8219994689c1Smrg # bomb out in the load deplibs phase. 8220f353fbadSmrg func_append dlprefiles " $lib $dependency_libs" 8221994689c1Smrg else 8222f353fbadSmrg func_append newdlfiles " $lib" 8223994689c1Smrg fi 8224994689c1Smrg continue 8225994689c1Smrg fi # $pass = dlopen 8226994689c1Smrg 8227994689c1Smrg # We need an absolute path. 8228994689c1Smrg case $ladir in 82295ec34c4cSmrg [\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;; 8230994689c1Smrg *) 8231994689c1Smrg abs_ladir=`cd "$ladir" && pwd` 8232994689c1Smrg if test -z "$abs_ladir"; then 82335ec34c4cSmrg func_warning "cannot determine absolute directory name of '$ladir'" 8234994689c1Smrg func_warning "passing it literally to the linker, although it might fail" 82355ec34c4cSmrg abs_ladir=$ladir 8236994689c1Smrg fi 8237994689c1Smrg ;; 8238994689c1Smrg esac 8239994689c1Smrg func_basename "$lib" 82405ec34c4cSmrg laname=$func_basename_result 8241994689c1Smrg 8242994689c1Smrg # Find the relevant object directory and library name. 82435ec34c4cSmrg if test yes = "$installed"; then 8244f353fbadSmrg if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then 82455ec34c4cSmrg func_warning "library '$lib' was moved." 82465ec34c4cSmrg dir=$ladir 82475ec34c4cSmrg absdir=$abs_ladir 82485ec34c4cSmrg libdir=$abs_ladir 8249994689c1Smrg else 82505ec34c4cSmrg dir=$lt_sysroot$libdir 82515ec34c4cSmrg absdir=$lt_sysroot$libdir 8252994689c1Smrg fi 82535ec34c4cSmrg test yes = "$hardcode_automatic" && avoidtemprpath=yes 8254994689c1Smrg else 8255994689c1Smrg if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then 82565ec34c4cSmrg dir=$ladir 82575ec34c4cSmrg absdir=$abs_ladir 8258994689c1Smrg # Remove this search path later 8259f353fbadSmrg func_append notinst_path " $abs_ladir" 8260994689c1Smrg else 82615ec34c4cSmrg dir=$ladir/$objdir 82625ec34c4cSmrg absdir=$abs_ladir/$objdir 8263994689c1Smrg # Remove this search path later 8264f353fbadSmrg func_append notinst_path " $abs_ladir" 8265994689c1Smrg fi 8266994689c1Smrg fi # $installed = yes 8267994689c1Smrg func_stripname 'lib' '.la' "$laname" 8268994689c1Smrg name=$func_stripname_result 8269994689c1Smrg 8270994689c1Smrg # This library was specified with -dlpreopen. 82715ec34c4cSmrg if test dlpreopen = "$pass"; then 82725ec34c4cSmrg if test -z "$libdir" && test prog = "$linkmode"; then 82735ec34c4cSmrg func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'" 8274994689c1Smrg fi 82755ec34c4cSmrg case $host in 8276f353fbadSmrg # special handling for platforms with PE-DLLs. 8277f353fbadSmrg *cygwin* | *mingw* | *cegcc* ) 8278f353fbadSmrg # Linker will automatically link against shared library if both 8279f353fbadSmrg # static and shared are present. Therefore, ensure we extract 8280f353fbadSmrg # symbols from the import library if a shared library is present 8281f353fbadSmrg # (otherwise, the dlopen module name will be incorrect). We do 8282f353fbadSmrg # this by putting the import library name into $newdlprefiles. 8283f353fbadSmrg # We recover the dlopen module name by 'saving' the la file 8284f353fbadSmrg # name in a special purpose variable, and (later) extracting the 8285f353fbadSmrg # dlname from the la file. 8286f353fbadSmrg if test -n "$dlname"; then 8287f353fbadSmrg func_tr_sh "$dir/$linklib" 8288f353fbadSmrg eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" 8289f353fbadSmrg func_append newdlprefiles " $dir/$linklib" 8290f353fbadSmrg else 8291f353fbadSmrg func_append newdlprefiles " $dir/$old_library" 8292f353fbadSmrg # Keep a list of preopened convenience libraries to check 8293f353fbadSmrg # that they are being used correctly in the link pass. 8294f353fbadSmrg test -z "$libdir" && \ 8295f353fbadSmrg func_append dlpreconveniencelibs " $dir/$old_library" 8296f353fbadSmrg fi 8297f353fbadSmrg ;; 8298f353fbadSmrg * ) 8299f353fbadSmrg # Prefer using a static library (so that no silly _DYNAMIC symbols 8300f353fbadSmrg # are required to link). 8301f353fbadSmrg if test -n "$old_library"; then 8302f353fbadSmrg func_append newdlprefiles " $dir/$old_library" 8303f353fbadSmrg # Keep a list of preopened convenience libraries to check 8304f353fbadSmrg # that they are being used correctly in the link pass. 8305f353fbadSmrg test -z "$libdir" && \ 8306f353fbadSmrg func_append dlpreconveniencelibs " $dir/$old_library" 8307f353fbadSmrg # Otherwise, use the dlname, so that lt_dlopen finds it. 8308f353fbadSmrg elif test -n "$dlname"; then 8309f353fbadSmrg func_append newdlprefiles " $dir/$dlname" 8310f353fbadSmrg else 8311f353fbadSmrg func_append newdlprefiles " $dir/$linklib" 8312f353fbadSmrg fi 8313f353fbadSmrg ;; 8314f353fbadSmrg esac 8315994689c1Smrg fi # $pass = dlpreopen 8316994689c1Smrg 8317994689c1Smrg if test -z "$libdir"; then 8318994689c1Smrg # Link the convenience library 83195ec34c4cSmrg if test lib = "$linkmode"; then 8320994689c1Smrg deplibs="$dir/$old_library $deplibs" 83215ec34c4cSmrg elif test prog,link = "$linkmode,$pass"; then 8322994689c1Smrg compile_deplibs="$dir/$old_library $compile_deplibs" 8323994689c1Smrg finalize_deplibs="$dir/$old_library $finalize_deplibs" 8324994689c1Smrg else 8325994689c1Smrg deplibs="$lib $deplibs" # used for prog,scan pass 8326994689c1Smrg fi 8327994689c1Smrg continue 8328994689c1Smrg fi 8329994689c1Smrg 8330994689c1Smrg 83315ec34c4cSmrg if test prog = "$linkmode" && test link != "$pass"; then 8332f353fbadSmrg func_append newlib_search_path " $ladir" 8333994689c1Smrg deplibs="$lib $deplibs" 8334994689c1Smrg 83355ec34c4cSmrg linkalldeplibs=false 83365ec34c4cSmrg if test no != "$link_all_deplibs" || test -z "$library_names" || 83375ec34c4cSmrg test no = "$build_libtool_libs"; then 83385ec34c4cSmrg linkalldeplibs=: 8339994689c1Smrg fi 8340994689c1Smrg 8341994689c1Smrg tmp_libs= 8342994689c1Smrg for deplib in $dependency_libs; do 8343994689c1Smrg case $deplib in 8344994689c1Smrg -L*) func_stripname '-L' '' "$deplib" 8345f353fbadSmrg func_resolve_sysroot "$func_stripname_result" 8346f353fbadSmrg func_append newlib_search_path " $func_resolve_sysroot_result" 8347994689c1Smrg ;; 8348994689c1Smrg esac 8349994689c1Smrg # Need to link against all dependency_libs? 83505ec34c4cSmrg if $linkalldeplibs; then 8351994689c1Smrg deplibs="$deplib $deplibs" 8352994689c1Smrg else 8353994689c1Smrg # Need to hardcode shared library paths 8354994689c1Smrg # or/and link against static libraries 8355994689c1Smrg newdependency_libs="$deplib $newdependency_libs" 8356994689c1Smrg fi 83575ec34c4cSmrg if $opt_preserve_dup_deps; then 8358994689c1Smrg case "$tmp_libs " in 8359f353fbadSmrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 8360994689c1Smrg esac 8361994689c1Smrg fi 8362f353fbadSmrg func_append tmp_libs " $deplib" 8363994689c1Smrg done # for deplib 8364994689c1Smrg continue 8365994689c1Smrg fi # $linkmode = prog... 8366994689c1Smrg 83675ec34c4cSmrg if test prog,link = "$linkmode,$pass"; then 8368994689c1Smrg if test -n "$library_names" && 83695ec34c4cSmrg { { test no = "$prefer_static_libs" || 83705ec34c4cSmrg test built,yes = "$prefer_static_libs,$installed"; } || 8371994689c1Smrg test -z "$old_library"; }; then 8372994689c1Smrg # We need to hardcode the library path 83735ec34c4cSmrg if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then 8374994689c1Smrg # Make sure the rpath contains only unique directories. 83755ec34c4cSmrg case $temp_rpath: in 8376994689c1Smrg *"$absdir:"*) ;; 8377f353fbadSmrg *) func_append temp_rpath "$absdir:" ;; 8378994689c1Smrg esac 8379994689c1Smrg fi 8380994689c1Smrg 8381994689c1Smrg # Hardcode the library path. 8382994689c1Smrg # Skip directories that are in the system default run-time 8383994689c1Smrg # search path. 8384994689c1Smrg case " $sys_lib_dlsearch_path " in 8385994689c1Smrg *" $absdir "*) ;; 8386994689c1Smrg *) 8387994689c1Smrg case "$compile_rpath " in 8388994689c1Smrg *" $absdir "*) ;; 8389f353fbadSmrg *) func_append compile_rpath " $absdir" ;; 8390994689c1Smrg esac 8391994689c1Smrg ;; 8392994689c1Smrg esac 8393994689c1Smrg case " $sys_lib_dlsearch_path " in 8394994689c1Smrg *" $libdir "*) ;; 8395994689c1Smrg *) 8396994689c1Smrg case "$finalize_rpath " in 8397994689c1Smrg *" $libdir "*) ;; 8398f353fbadSmrg *) func_append finalize_rpath " $libdir" ;; 8399994689c1Smrg esac 8400994689c1Smrg ;; 8401994689c1Smrg esac 8402994689c1Smrg fi # $linkmode,$pass = prog,link... 8403994689c1Smrg 84045ec34c4cSmrg if $alldeplibs && 84055ec34c4cSmrg { test pass_all = "$deplibs_check_method" || 84065ec34c4cSmrg { test yes = "$build_libtool_libs" && 8407994689c1Smrg test -n "$library_names"; }; }; then 8408994689c1Smrg # We only need to search for static libraries 8409994689c1Smrg continue 8410994689c1Smrg fi 8411994689c1Smrg fi 8412994689c1Smrg 8413994689c1Smrg link_static=no # Whether the deplib will be linked statically 8414994689c1Smrg use_static_libs=$prefer_static_libs 84155ec34c4cSmrg if test built = "$use_static_libs" && test yes = "$installed"; then 8416994689c1Smrg use_static_libs=no 8417994689c1Smrg fi 8418994689c1Smrg if test -n "$library_names" && 84195ec34c4cSmrg { test no = "$use_static_libs" || test -z "$old_library"; }; then 8420994689c1Smrg case $host in 84215ec34c4cSmrg *cygwin* | *mingw* | *cegcc* | *os2*) 8422994689c1Smrg # No point in relinking DLLs because paths are not encoded 8423f353fbadSmrg func_append notinst_deplibs " $lib" 8424994689c1Smrg need_relink=no 8425994689c1Smrg ;; 8426994689c1Smrg *) 84275ec34c4cSmrg if test no = "$installed"; then 8428f353fbadSmrg func_append notinst_deplibs " $lib" 8429994689c1Smrg need_relink=yes 8430994689c1Smrg fi 8431994689c1Smrg ;; 8432994689c1Smrg esac 8433994689c1Smrg # This is a shared library 8434994689c1Smrg 8435994689c1Smrg # Warn about portability, can't link against -module's on some 8436994689c1Smrg # systems (darwin). Don't bleat about dlopened modules though! 84375ec34c4cSmrg dlopenmodule= 8438994689c1Smrg for dlpremoduletest in $dlprefiles; do 8439994689c1Smrg if test "X$dlpremoduletest" = "X$lib"; then 84405ec34c4cSmrg dlopenmodule=$dlpremoduletest 8441994689c1Smrg break 8442994689c1Smrg fi 8443994689c1Smrg done 84445ec34c4cSmrg if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then 8445994689c1Smrg echo 84465ec34c4cSmrg if test prog = "$linkmode"; then 8447994689c1Smrg $ECHO "*** Warning: Linking the executable $output against the loadable module" 8448994689c1Smrg else 8449994689c1Smrg $ECHO "*** Warning: Linking the shared library $output against the loadable module" 8450994689c1Smrg fi 8451994689c1Smrg $ECHO "*** $linklib is not portable!" 8452994689c1Smrg fi 84535ec34c4cSmrg if test lib = "$linkmode" && 84545ec34c4cSmrg test yes = "$hardcode_into_libs"; then 8455994689c1Smrg # Hardcode the library path. 8456994689c1Smrg # Skip directories that are in the system default run-time 8457994689c1Smrg # search path. 8458994689c1Smrg case " $sys_lib_dlsearch_path " in 8459994689c1Smrg *" $absdir "*) ;; 8460994689c1Smrg *) 8461994689c1Smrg case "$compile_rpath " in 8462994689c1Smrg *" $absdir "*) ;; 8463f353fbadSmrg *) func_append compile_rpath " $absdir" ;; 8464994689c1Smrg esac 8465994689c1Smrg ;; 8466994689c1Smrg esac 8467994689c1Smrg case " $sys_lib_dlsearch_path " in 8468994689c1Smrg *" $libdir "*) ;; 8469994689c1Smrg *) 8470994689c1Smrg case "$finalize_rpath " in 8471994689c1Smrg *" $libdir "*) ;; 8472f353fbadSmrg *) func_append finalize_rpath " $libdir" ;; 8473994689c1Smrg esac 8474994689c1Smrg ;; 8475994689c1Smrg esac 8476994689c1Smrg fi 8477994689c1Smrg 8478994689c1Smrg if test -n "$old_archive_from_expsyms_cmds"; then 8479994689c1Smrg # figure out the soname 8480994689c1Smrg set dummy $library_names 8481994689c1Smrg shift 84825ec34c4cSmrg realname=$1 8483994689c1Smrg shift 8484994689c1Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 8485994689c1Smrg # use dlname if we got it. it's perfectly good, no? 8486994689c1Smrg if test -n "$dlname"; then 84875ec34c4cSmrg soname=$dlname 8488994689c1Smrg elif test -n "$soname_spec"; then 8489994689c1Smrg # bleh windows 8490994689c1Smrg case $host in 84915ec34c4cSmrg *cygwin* | mingw* | *cegcc* | *os2*) 8492994689c1Smrg func_arith $current - $age 8493994689c1Smrg major=$func_arith_result 84945ec34c4cSmrg versuffix=-$major 8495994689c1Smrg ;; 8496994689c1Smrg esac 8497994689c1Smrg eval soname=\"$soname_spec\" 8498994689c1Smrg else 84995ec34c4cSmrg soname=$realname 8500994689c1Smrg fi 8501994689c1Smrg 8502994689c1Smrg # Make a new name for the extract_expsyms_cmds to use 85035ec34c4cSmrg soroot=$soname 8504994689c1Smrg func_basename "$soroot" 85055ec34c4cSmrg soname=$func_basename_result 8506994689c1Smrg func_stripname 'lib' '.dll' "$soname" 8507994689c1Smrg newlib=libimp-$func_stripname_result.a 8508994689c1Smrg 8509994689c1Smrg # If the library has no export list, then create one now 8510994689c1Smrg if test -f "$output_objdir/$soname-def"; then : 8511994689c1Smrg else 85125ec34c4cSmrg func_verbose "extracting exported symbol list from '$soname'" 8513994689c1Smrg func_execute_cmds "$extract_expsyms_cmds" 'exit $?' 8514994689c1Smrg fi 8515994689c1Smrg 8516994689c1Smrg # Create $newlib 8517994689c1Smrg if test -f "$output_objdir/$newlib"; then :; else 85185ec34c4cSmrg func_verbose "generating import library for '$soname'" 8519994689c1Smrg func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' 8520994689c1Smrg fi 8521994689c1Smrg # make sure the library variables are pointing to the new library 8522994689c1Smrg dir=$output_objdir 8523994689c1Smrg linklib=$newlib 8524994689c1Smrg fi # test -n "$old_archive_from_expsyms_cmds" 8525994689c1Smrg 85265ec34c4cSmrg if test prog = "$linkmode" || test relink != "$opt_mode"; then 8527994689c1Smrg add_shlibpath= 8528994689c1Smrg add_dir= 8529994689c1Smrg add= 8530994689c1Smrg lib_linked=yes 8531994689c1Smrg case $hardcode_action in 8532994689c1Smrg immediate | unsupported) 85335ec34c4cSmrg if test no = "$hardcode_direct"; then 85345ec34c4cSmrg add=$dir/$linklib 8535994689c1Smrg case $host in 85365ec34c4cSmrg *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;; 85375ec34c4cSmrg *-*-sysv4*uw2*) add_dir=-L$dir ;; 8538994689c1Smrg *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ 85395ec34c4cSmrg *-*-unixware7*) add_dir=-L$dir ;; 8540994689c1Smrg *-*-darwin* ) 85415ec34c4cSmrg # if the lib is a (non-dlopened) module then we cannot 8542994689c1Smrg # link against it, someone is ignoring the earlier warnings 8543994689c1Smrg if /usr/bin/file -L $add 2> /dev/null | 85445ec34c4cSmrg $GREP ": [^:]* bundle" >/dev/null; then 8545994689c1Smrg if test "X$dlopenmodule" != "X$lib"; then 8546994689c1Smrg $ECHO "*** Warning: lib $linklib is a module, not a shared library" 85475ec34c4cSmrg if test -z "$old_library"; then 8548994689c1Smrg echo 8549994689c1Smrg echo "*** And there doesn't seem to be a static archive available" 8550994689c1Smrg echo "*** The link will probably fail, sorry" 8551994689c1Smrg else 85525ec34c4cSmrg add=$dir/$old_library 8553994689c1Smrg fi 8554994689c1Smrg elif test -n "$old_library"; then 85555ec34c4cSmrg add=$dir/$old_library 8556994689c1Smrg fi 8557994689c1Smrg fi 8558994689c1Smrg esac 85595ec34c4cSmrg elif test no = "$hardcode_minus_L"; then 8560994689c1Smrg case $host in 85615ec34c4cSmrg *-*-sunos*) add_shlibpath=$dir ;; 8562994689c1Smrg esac 85635ec34c4cSmrg add_dir=-L$dir 85645ec34c4cSmrg add=-l$name 85655ec34c4cSmrg elif test no = "$hardcode_shlibpath_var"; then 85665ec34c4cSmrg add_shlibpath=$dir 85675ec34c4cSmrg add=-l$name 8568994689c1Smrg else 8569994689c1Smrg lib_linked=no 8570994689c1Smrg fi 8571994689c1Smrg ;; 8572994689c1Smrg relink) 85735ec34c4cSmrg if test yes = "$hardcode_direct" && 85745ec34c4cSmrg test no = "$hardcode_direct_absolute"; then 85755ec34c4cSmrg add=$dir/$linklib 85765ec34c4cSmrg elif test yes = "$hardcode_minus_L"; then 85775ec34c4cSmrg add_dir=-L$absdir 8578994689c1Smrg # Try looking first in the location we're being installed to. 8579994689c1Smrg if test -n "$inst_prefix_dir"; then 8580994689c1Smrg case $libdir in 8581994689c1Smrg [\\/]*) 8582f353fbadSmrg func_append add_dir " -L$inst_prefix_dir$libdir" 8583994689c1Smrg ;; 8584994689c1Smrg esac 8585994689c1Smrg fi 85865ec34c4cSmrg add=-l$name 85875ec34c4cSmrg elif test yes = "$hardcode_shlibpath_var"; then 85885ec34c4cSmrg add_shlibpath=$dir 85895ec34c4cSmrg add=-l$name 8590994689c1Smrg else 8591994689c1Smrg lib_linked=no 8592994689c1Smrg fi 8593994689c1Smrg ;; 8594994689c1Smrg *) lib_linked=no ;; 8595994689c1Smrg esac 8596994689c1Smrg 85975ec34c4cSmrg if test yes != "$lib_linked"; then 8598994689c1Smrg func_fatal_configuration "unsupported hardcode properties" 8599994689c1Smrg fi 8600994689c1Smrg 8601994689c1Smrg if test -n "$add_shlibpath"; then 8602994689c1Smrg case :$compile_shlibpath: in 8603994689c1Smrg *":$add_shlibpath:"*) ;; 8604f353fbadSmrg *) func_append compile_shlibpath "$add_shlibpath:" ;; 8605994689c1Smrg esac 8606994689c1Smrg fi 86075ec34c4cSmrg if test prog = "$linkmode"; then 8608994689c1Smrg test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" 8609994689c1Smrg test -n "$add" && compile_deplibs="$add $compile_deplibs" 8610994689c1Smrg else 8611994689c1Smrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 8612994689c1Smrg test -n "$add" && deplibs="$add $deplibs" 86135ec34c4cSmrg if test yes != "$hardcode_direct" && 86145ec34c4cSmrg test yes != "$hardcode_minus_L" && 86155ec34c4cSmrg test yes = "$hardcode_shlibpath_var"; then 8616994689c1Smrg case :$finalize_shlibpath: in 8617994689c1Smrg *":$libdir:"*) ;; 8618f353fbadSmrg *) func_append finalize_shlibpath "$libdir:" ;; 8619994689c1Smrg esac 8620994689c1Smrg fi 8621994689c1Smrg fi 8622994689c1Smrg fi 8623994689c1Smrg 86245ec34c4cSmrg if test prog = "$linkmode" || test relink = "$opt_mode"; then 8625994689c1Smrg add_shlibpath= 8626994689c1Smrg add_dir= 8627994689c1Smrg add= 8628994689c1Smrg # Finalize command for both is simple: just hardcode it. 86295ec34c4cSmrg if test yes = "$hardcode_direct" && 86305ec34c4cSmrg test no = "$hardcode_direct_absolute"; then 86315ec34c4cSmrg add=$libdir/$linklib 86325ec34c4cSmrg elif test yes = "$hardcode_minus_L"; then 86335ec34c4cSmrg add_dir=-L$libdir 86345ec34c4cSmrg add=-l$name 86355ec34c4cSmrg elif test yes = "$hardcode_shlibpath_var"; then 8636994689c1Smrg case :$finalize_shlibpath: in 8637994689c1Smrg *":$libdir:"*) ;; 8638f353fbadSmrg *) func_append finalize_shlibpath "$libdir:" ;; 8639994689c1Smrg esac 86405ec34c4cSmrg add=-l$name 86415ec34c4cSmrg elif test yes = "$hardcode_automatic"; then 8642994689c1Smrg if test -n "$inst_prefix_dir" && 86435ec34c4cSmrg test -f "$inst_prefix_dir$libdir/$linklib"; then 86445ec34c4cSmrg add=$inst_prefix_dir$libdir/$linklib 8645994689c1Smrg else 86465ec34c4cSmrg add=$libdir/$linklib 8647994689c1Smrg fi 8648994689c1Smrg else 8649994689c1Smrg # We cannot seem to hardcode it, guess we'll fake it. 86505ec34c4cSmrg add_dir=-L$libdir 8651994689c1Smrg # Try looking first in the location we're being installed to. 8652994689c1Smrg if test -n "$inst_prefix_dir"; then 8653994689c1Smrg case $libdir in 8654994689c1Smrg [\\/]*) 8655f353fbadSmrg func_append add_dir " -L$inst_prefix_dir$libdir" 8656994689c1Smrg ;; 8657994689c1Smrg esac 8658994689c1Smrg fi 86595ec34c4cSmrg add=-l$name 8660994689c1Smrg fi 8661994689c1Smrg 86625ec34c4cSmrg if test prog = "$linkmode"; then 8663994689c1Smrg test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" 8664994689c1Smrg test -n "$add" && finalize_deplibs="$add $finalize_deplibs" 8665994689c1Smrg else 8666994689c1Smrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 8667994689c1Smrg test -n "$add" && deplibs="$add $deplibs" 8668994689c1Smrg fi 8669994689c1Smrg fi 86705ec34c4cSmrg elif test prog = "$linkmode"; then 8671994689c1Smrg # Here we assume that one of hardcode_direct or hardcode_minus_L 8672994689c1Smrg # is not unsupported. This is valid on all known static and 8673994689c1Smrg # shared platforms. 86745ec34c4cSmrg if test unsupported != "$hardcode_direct"; then 86755ec34c4cSmrg test -n "$old_library" && linklib=$old_library 8676994689c1Smrg compile_deplibs="$dir/$linklib $compile_deplibs" 8677994689c1Smrg finalize_deplibs="$dir/$linklib $finalize_deplibs" 8678994689c1Smrg else 8679994689c1Smrg compile_deplibs="-l$name -L$dir $compile_deplibs" 8680994689c1Smrg finalize_deplibs="-l$name -L$dir $finalize_deplibs" 8681994689c1Smrg fi 86825ec34c4cSmrg elif test yes = "$build_libtool_libs"; then 8683994689c1Smrg # Not a shared library 86845ec34c4cSmrg if test pass_all != "$deplibs_check_method"; then 8685994689c1Smrg # We're trying link a shared library against a static one 8686994689c1Smrg # but the system doesn't support it. 8687994689c1Smrg 8688994689c1Smrg # Just print a warning and add the library to dependency_libs so 8689994689c1Smrg # that the program can be linked against the static library. 8690994689c1Smrg echo 86915ec34c4cSmrg $ECHO "*** Warning: This system cannot link to static lib archive $lib." 8692994689c1Smrg echo "*** I have the capability to make that library automatically link in when" 8693994689c1Smrg echo "*** you link to this library. But I can only do this if you have a" 8694994689c1Smrg echo "*** shared version of the library, which you do not appear to have." 86955ec34c4cSmrg if test yes = "$module"; then 8696994689c1Smrg echo "*** But as you try to build a module library, libtool will still create " 8697994689c1Smrg echo "*** a static module, that should work as long as the dlopening application" 8698994689c1Smrg echo "*** is linked with the -dlopen flag to resolve symbols at runtime." 8699994689c1Smrg if test -z "$global_symbol_pipe"; then 8700994689c1Smrg echo 8701994689c1Smrg echo "*** However, this would only work if libtool was able to extract symbol" 87025ec34c4cSmrg echo "*** lists from a program, using 'nm' or equivalent, but libtool could" 8703994689c1Smrg echo "*** not find such a program. So, this module is probably useless." 87045ec34c4cSmrg echo "*** 'nm' from GNU binutils and a full rebuild may help." 8705994689c1Smrg fi 87065ec34c4cSmrg if test no = "$build_old_libs"; then 8707994689c1Smrg build_libtool_libs=module 8708994689c1Smrg build_old_libs=yes 8709994689c1Smrg else 8710994689c1Smrg build_libtool_libs=no 8711994689c1Smrg fi 8712994689c1Smrg fi 8713994689c1Smrg else 8714994689c1Smrg deplibs="$dir/$old_library $deplibs" 8715994689c1Smrg link_static=yes 8716994689c1Smrg fi 8717994689c1Smrg fi # link shared/static library? 8718994689c1Smrg 87195ec34c4cSmrg if test lib = "$linkmode"; then 8720994689c1Smrg if test -n "$dependency_libs" && 87215ec34c4cSmrg { test yes != "$hardcode_into_libs" || 87225ec34c4cSmrg test yes = "$build_old_libs" || 87235ec34c4cSmrg test yes = "$link_static"; }; then 8724994689c1Smrg # Extract -R from dependency_libs 8725994689c1Smrg temp_deplibs= 8726994689c1Smrg for libdir in $dependency_libs; do 8727994689c1Smrg case $libdir in 8728994689c1Smrg -R*) func_stripname '-R' '' "$libdir" 8729994689c1Smrg temp_xrpath=$func_stripname_result 8730994689c1Smrg case " $xrpath " in 8731994689c1Smrg *" $temp_xrpath "*) ;; 8732f353fbadSmrg *) func_append xrpath " $temp_xrpath";; 8733994689c1Smrg esac;; 8734f353fbadSmrg *) func_append temp_deplibs " $libdir";; 8735994689c1Smrg esac 8736994689c1Smrg done 87375ec34c4cSmrg dependency_libs=$temp_deplibs 8738994689c1Smrg fi 8739994689c1Smrg 8740f353fbadSmrg func_append newlib_search_path " $absdir" 8741994689c1Smrg # Link against this library 87425ec34c4cSmrg test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs" 8743994689c1Smrg # ... and its dependency_libs 8744994689c1Smrg tmp_libs= 8745994689c1Smrg for deplib in $dependency_libs; do 8746994689c1Smrg newdependency_libs="$deplib $newdependency_libs" 8747f353fbadSmrg case $deplib in 8748f353fbadSmrg -L*) func_stripname '-L' '' "$deplib" 8749f353fbadSmrg func_resolve_sysroot "$func_stripname_result";; 8750f353fbadSmrg *) func_resolve_sysroot "$deplib" ;; 8751f353fbadSmrg esac 87525ec34c4cSmrg if $opt_preserve_dup_deps; then 8753994689c1Smrg case "$tmp_libs " in 8754f353fbadSmrg *" $func_resolve_sysroot_result "*) 8755f353fbadSmrg func_append specialdeplibs " $func_resolve_sysroot_result" ;; 8756994689c1Smrg esac 8757994689c1Smrg fi 8758f353fbadSmrg func_append tmp_libs " $func_resolve_sysroot_result" 8759994689c1Smrg done 8760994689c1Smrg 87615ec34c4cSmrg if test no != "$link_all_deplibs"; then 8762994689c1Smrg # Add the search paths of all dependency libraries 8763994689c1Smrg for deplib in $dependency_libs; do 8764994689c1Smrg path= 8765994689c1Smrg case $deplib in 87665ec34c4cSmrg -L*) path=$deplib ;; 8767994689c1Smrg *.la) 8768f353fbadSmrg func_resolve_sysroot "$deplib" 8769f353fbadSmrg deplib=$func_resolve_sysroot_result 8770994689c1Smrg func_dirname "$deplib" "" "." 8771f353fbadSmrg dir=$func_dirname_result 8772994689c1Smrg # We need an absolute path. 8773994689c1Smrg case $dir in 87745ec34c4cSmrg [\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;; 8775994689c1Smrg *) 8776994689c1Smrg absdir=`cd "$dir" && pwd` 8777994689c1Smrg if test -z "$absdir"; then 87785ec34c4cSmrg func_warning "cannot determine absolute directory name of '$dir'" 87795ec34c4cSmrg absdir=$dir 8780994689c1Smrg fi 8781994689c1Smrg ;; 8782994689c1Smrg esac 8783994689c1Smrg if $GREP "^installed=no" $deplib > /dev/null; then 8784994689c1Smrg case $host in 8785994689c1Smrg *-*-darwin*) 8786994689c1Smrg depdepl= 87875ec34c4cSmrg eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` 87885ec34c4cSmrg if test -n "$deplibrary_names"; then 87895ec34c4cSmrg for tmp in $deplibrary_names; do 8790994689c1Smrg depdepl=$tmp 8791994689c1Smrg done 87925ec34c4cSmrg if test -f "$absdir/$objdir/$depdepl"; then 87935ec34c4cSmrg depdepl=$absdir/$objdir/$depdepl 87945ec34c4cSmrg darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 8795994689c1Smrg if test -z "$darwin_install_name"; then 87965ec34c4cSmrg darwin_install_name=`$OTOOL64 -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 8797994689c1Smrg fi 87985ec34c4cSmrg func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl" 87995ec34c4cSmrg func_append linker_flags " -dylib_file $darwin_install_name:$depdepl" 8800994689c1Smrg path= 8801994689c1Smrg fi 8802994689c1Smrg fi 8803994689c1Smrg ;; 8804994689c1Smrg *) 88055ec34c4cSmrg path=-L$absdir/$objdir 8806994689c1Smrg ;; 8807994689c1Smrg esac 8808994689c1Smrg else 88095ec34c4cSmrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` 8810994689c1Smrg test -z "$libdir" && \ 88115ec34c4cSmrg func_fatal_error "'$deplib' is not a valid libtool archive" 8812994689c1Smrg test "$absdir" != "$libdir" && \ 88135ec34c4cSmrg func_warning "'$deplib' seems to be moved" 8814994689c1Smrg 88155ec34c4cSmrg path=-L$absdir 8816994689c1Smrg fi 8817994689c1Smrg ;; 8818994689c1Smrg esac 8819994689c1Smrg case " $deplibs " in 8820994689c1Smrg *" $path "*) ;; 8821994689c1Smrg *) deplibs="$path $deplibs" ;; 8822994689c1Smrg esac 8823994689c1Smrg done 8824994689c1Smrg fi # link_all_deplibs != no 8825994689c1Smrg fi # linkmode = lib 8826994689c1Smrg done # for deplib in $libs 88275ec34c4cSmrg if test link = "$pass"; then 88285ec34c4cSmrg if test prog = "$linkmode"; then 8829994689c1Smrg compile_deplibs="$new_inherited_linker_flags $compile_deplibs" 8830994689c1Smrg finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" 8831994689c1Smrg else 8832994689c1Smrg compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 8833994689c1Smrg fi 8834994689c1Smrg fi 88355ec34c4cSmrg dependency_libs=$newdependency_libs 88365ec34c4cSmrg if test dlpreopen = "$pass"; then 8837994689c1Smrg # Link the dlpreopened libraries before other libraries 8838994689c1Smrg for deplib in $save_deplibs; do 8839994689c1Smrg deplibs="$deplib $deplibs" 8840994689c1Smrg done 8841994689c1Smrg fi 88425ec34c4cSmrg if test dlopen != "$pass"; then 88435ec34c4cSmrg test conv = "$pass" || { 8844994689c1Smrg # Make sure lib_search_path contains only unique directories. 8845994689c1Smrg lib_search_path= 8846994689c1Smrg for dir in $newlib_search_path; do 8847994689c1Smrg case "$lib_search_path " in 8848994689c1Smrg *" $dir "*) ;; 8849f353fbadSmrg *) func_append lib_search_path " $dir" ;; 8850994689c1Smrg esac 8851994689c1Smrg done 8852994689c1Smrg newlib_search_path= 88535ec34c4cSmrg } 8854994689c1Smrg 88555ec34c4cSmrg if test prog,link = "$linkmode,$pass"; then 8856994689c1Smrg vars="compile_deplibs finalize_deplibs" 88575ec34c4cSmrg else 88585ec34c4cSmrg vars=deplibs 8859994689c1Smrg fi 8860994689c1Smrg for var in $vars dependency_libs; do 8861994689c1Smrg # Add libraries to $var in reverse order 8862994689c1Smrg eval tmp_libs=\"\$$var\" 8863994689c1Smrg new_libs= 8864994689c1Smrg for deplib in $tmp_libs; do 8865994689c1Smrg # FIXME: Pedantically, this is the right thing to do, so 8866994689c1Smrg # that some nasty dependency loop isn't accidentally 8867994689c1Smrg # broken: 8868994689c1Smrg #new_libs="$deplib $new_libs" 8869994689c1Smrg # Pragmatically, this seems to cause very few problems in 8870994689c1Smrg # practice: 8871994689c1Smrg case $deplib in 8872994689c1Smrg -L*) new_libs="$deplib $new_libs" ;; 8873994689c1Smrg -R*) ;; 8874994689c1Smrg *) 8875994689c1Smrg # And here is the reason: when a library appears more 8876994689c1Smrg # than once as an explicit dependence of a library, or 8877994689c1Smrg # is implicitly linked in more than once by the 8878994689c1Smrg # compiler, it is considered special, and multiple 8879994689c1Smrg # occurrences thereof are not removed. Compare this 8880994689c1Smrg # with having the same library being listed as a 8881994689c1Smrg # dependency of multiple other libraries: in this case, 8882994689c1Smrg # we know (pedantically, we assume) the library does not 8883994689c1Smrg # need to be listed more than once, so we keep only the 8884994689c1Smrg # last copy. This is not always right, but it is rare 8885994689c1Smrg # enough that we require users that really mean to play 8886994689c1Smrg # such unportable linking tricks to link the library 8887994689c1Smrg # using -Wl,-lname, so that libtool does not consider it 8888994689c1Smrg # for duplicate removal. 8889994689c1Smrg case " $specialdeplibs " in 8890994689c1Smrg *" $deplib "*) new_libs="$deplib $new_libs" ;; 8891994689c1Smrg *) 8892994689c1Smrg case " $new_libs " in 8893994689c1Smrg *" $deplib "*) ;; 8894994689c1Smrg *) new_libs="$deplib $new_libs" ;; 8895994689c1Smrg esac 8896994689c1Smrg ;; 8897994689c1Smrg esac 8898994689c1Smrg ;; 8899994689c1Smrg esac 8900994689c1Smrg done 8901994689c1Smrg tmp_libs= 8902994689c1Smrg for deplib in $new_libs; do 8903994689c1Smrg case $deplib in 8904994689c1Smrg -L*) 8905994689c1Smrg case " $tmp_libs " in 8906994689c1Smrg *" $deplib "*) ;; 8907f353fbadSmrg *) func_append tmp_libs " $deplib" ;; 8908994689c1Smrg esac 8909994689c1Smrg ;; 8910f353fbadSmrg *) func_append tmp_libs " $deplib" ;; 8911994689c1Smrg esac 8912994689c1Smrg done 8913994689c1Smrg eval $var=\"$tmp_libs\" 8914994689c1Smrg done # for var 8915994689c1Smrg fi 89165ec34c4cSmrg 89175ec34c4cSmrg # Add Sun CC postdeps if required: 89185ec34c4cSmrg test CXX = "$tagname" && { 89195ec34c4cSmrg case $host_os in 89205ec34c4cSmrg linux*) 89215b16253fSmrg case `$CC -V 2>&1 | $SED 5q` in 89225ec34c4cSmrg *Sun\ C*) # Sun C++ 5.9 89235ec34c4cSmrg func_suncc_cstd_abi 89245ec34c4cSmrg 89255ec34c4cSmrg if test no != "$suncc_use_cstd_abi"; then 89265ec34c4cSmrg func_append postdeps ' -library=Cstd -library=Crun' 89275ec34c4cSmrg fi 89285ec34c4cSmrg ;; 89295ec34c4cSmrg esac 89305ec34c4cSmrg ;; 89315ec34c4cSmrg 89325ec34c4cSmrg solaris*) 89335ec34c4cSmrg func_cc_basename "$CC" 89345ec34c4cSmrg case $func_cc_basename_result in 89355ec34c4cSmrg CC* | sunCC*) 89365ec34c4cSmrg func_suncc_cstd_abi 89375ec34c4cSmrg 89385ec34c4cSmrg if test no != "$suncc_use_cstd_abi"; then 89395ec34c4cSmrg func_append postdeps ' -library=Cstd -library=Crun' 89405ec34c4cSmrg fi 89415ec34c4cSmrg ;; 89425ec34c4cSmrg esac 89435ec34c4cSmrg ;; 89445ec34c4cSmrg esac 89455ec34c4cSmrg } 89465ec34c4cSmrg 8947994689c1Smrg # Last step: remove runtime libs from dependency_libs 8948994689c1Smrg # (they stay in deplibs) 8949994689c1Smrg tmp_libs= 89505ec34c4cSmrg for i in $dependency_libs; do 8951994689c1Smrg case " $predeps $postdeps $compiler_lib_search_path " in 8952994689c1Smrg *" $i "*) 89535ec34c4cSmrg i= 8954994689c1Smrg ;; 8955994689c1Smrg esac 89565ec34c4cSmrg if test -n "$i"; then 8957f353fbadSmrg func_append tmp_libs " $i" 8958994689c1Smrg fi 8959994689c1Smrg done 8960994689c1Smrg dependency_libs=$tmp_libs 8961994689c1Smrg done # for pass 89625ec34c4cSmrg if test prog = "$linkmode"; then 89635ec34c4cSmrg dlfiles=$newdlfiles 8964994689c1Smrg fi 89655ec34c4cSmrg if test prog = "$linkmode" || test lib = "$linkmode"; then 89665ec34c4cSmrg dlprefiles=$newdlprefiles 8967994689c1Smrg fi 8968994689c1Smrg 8969994689c1Smrg case $linkmode in 8970994689c1Smrg oldlib) 89715ec34c4cSmrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 89725ec34c4cSmrg func_warning "'-dlopen' is ignored for archives" 8973994689c1Smrg fi 8974994689c1Smrg 8975994689c1Smrg case " $deplibs" in 8976994689c1Smrg *\ -l* | *\ -L*) 89775ec34c4cSmrg func_warning "'-l' and '-L' are ignored for archives" ;; 8978994689c1Smrg esac 8979994689c1Smrg 8980994689c1Smrg test -n "$rpath" && \ 89815ec34c4cSmrg func_warning "'-rpath' is ignored for archives" 8982994689c1Smrg 8983994689c1Smrg test -n "$xrpath" && \ 89845ec34c4cSmrg func_warning "'-R' is ignored for archives" 8985994689c1Smrg 8986994689c1Smrg test -n "$vinfo" && \ 89875ec34c4cSmrg func_warning "'-version-info/-version-number' is ignored for archives" 8988994689c1Smrg 8989994689c1Smrg test -n "$release" && \ 89905ec34c4cSmrg func_warning "'-release' is ignored for archives" 8991994689c1Smrg 8992994689c1Smrg test -n "$export_symbols$export_symbols_regex" && \ 89935ec34c4cSmrg func_warning "'-export-symbols' is ignored for archives" 8994994689c1Smrg 8995994689c1Smrg # Now set the variables for building old libraries. 8996994689c1Smrg build_libtool_libs=no 89975ec34c4cSmrg oldlibs=$output 8998f353fbadSmrg func_append objs "$old_deplibs" 8999994689c1Smrg ;; 9000994689c1Smrg 9001994689c1Smrg lib) 90025ec34c4cSmrg # Make sure we only generate libraries of the form 'libNAME.la'. 9003994689c1Smrg case $outputname in 9004994689c1Smrg lib*) 9005994689c1Smrg func_stripname 'lib' '.la' "$outputname" 9006994689c1Smrg name=$func_stripname_result 9007994689c1Smrg eval shared_ext=\"$shrext_cmds\" 9008994689c1Smrg eval libname=\"$libname_spec\" 9009994689c1Smrg ;; 9010994689c1Smrg *) 90115ec34c4cSmrg test no = "$module" \ 90125ec34c4cSmrg && func_fatal_help "libtool library '$output' must begin with 'lib'" 9013994689c1Smrg 90145ec34c4cSmrg if test no != "$need_lib_prefix"; then 9015994689c1Smrg # Add the "lib" prefix for modules if required 9016994689c1Smrg func_stripname '' '.la' "$outputname" 9017994689c1Smrg name=$func_stripname_result 9018994689c1Smrg eval shared_ext=\"$shrext_cmds\" 9019994689c1Smrg eval libname=\"$libname_spec\" 9020994689c1Smrg else 9021994689c1Smrg func_stripname '' '.la' "$outputname" 9022994689c1Smrg libname=$func_stripname_result 9023994689c1Smrg fi 9024994689c1Smrg ;; 9025994689c1Smrg esac 9026994689c1Smrg 9027994689c1Smrg if test -n "$objs"; then 90285ec34c4cSmrg if test pass_all != "$deplibs_check_method"; then 90295ec34c4cSmrg func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs" 9030994689c1Smrg else 9031994689c1Smrg echo 9032994689c1Smrg $ECHO "*** Warning: Linking the shared library $output against the non-libtool" 9033994689c1Smrg $ECHO "*** objects $objs is not portable!" 9034f353fbadSmrg func_append libobjs " $objs" 9035994689c1Smrg fi 9036994689c1Smrg fi 9037994689c1Smrg 90385ec34c4cSmrg test no = "$dlself" \ 90395ec34c4cSmrg || func_warning "'-dlopen self' is ignored for libtool libraries" 9040994689c1Smrg 9041994689c1Smrg set dummy $rpath 9042994689c1Smrg shift 90435ec34c4cSmrg test 1 -lt "$#" \ 90445ec34c4cSmrg && func_warning "ignoring multiple '-rpath's for a libtool library" 9045994689c1Smrg 90465ec34c4cSmrg install_libdir=$1 9047994689c1Smrg 9048994689c1Smrg oldlibs= 9049994689c1Smrg if test -z "$rpath"; then 90505ec34c4cSmrg if test yes = "$build_libtool_libs"; then 9051994689c1Smrg # Building a libtool convenience library. 90525ec34c4cSmrg # Some compilers have problems with a '.al' extension so 9053994689c1Smrg # convenience libraries should have the same extension an 9054994689c1Smrg # archive normally would. 9055994689c1Smrg oldlibs="$output_objdir/$libname.$libext $oldlibs" 9056994689c1Smrg build_libtool_libs=convenience 9057994689c1Smrg build_old_libs=yes 9058994689c1Smrg fi 9059994689c1Smrg 9060994689c1Smrg test -n "$vinfo" && \ 90615ec34c4cSmrg func_warning "'-version-info/-version-number' is ignored for convenience libraries" 9062994689c1Smrg 9063994689c1Smrg test -n "$release" && \ 90645ec34c4cSmrg func_warning "'-release' is ignored for convenience libraries" 9065994689c1Smrg else 9066994689c1Smrg 9067994689c1Smrg # Parse the version information argument. 90685ec34c4cSmrg save_ifs=$IFS; IFS=: 9069994689c1Smrg set dummy $vinfo 0 0 0 9070994689c1Smrg shift 90715ec34c4cSmrg IFS=$save_ifs 9072994689c1Smrg 9073994689c1Smrg test -n "$7" && \ 90745ec34c4cSmrg func_fatal_help "too many parameters to '-version-info'" 9075994689c1Smrg 9076994689c1Smrg # convert absolute version numbers to libtool ages 9077994689c1Smrg # this retains compatibility with .la files and attempts 9078994689c1Smrg # to make the code below a bit more comprehensible 9079994689c1Smrg 9080994689c1Smrg case $vinfo_number in 9081994689c1Smrg yes) 90825ec34c4cSmrg number_major=$1 90835ec34c4cSmrg number_minor=$2 90845ec34c4cSmrg number_revision=$3 9085994689c1Smrg # 9086994689c1Smrg # There are really only two kinds -- those that 9087994689c1Smrg # use the current revision as the major version 9088994689c1Smrg # and those that subtract age and use age as 9089994689c1Smrg # a minor version. But, then there is irix 90905ec34c4cSmrg # that has an extra 1 added just for fun 9091994689c1Smrg # 9092994689c1Smrg case $version_type in 9093421c997bSmrg # correct linux to gnu/linux during the next big refactor 90945b16253fSmrg darwin|freebsd-elf|linux|midnightbsd-elf|osf|windows|none) 9095994689c1Smrg func_arith $number_major + $number_minor 9096994689c1Smrg current=$func_arith_result 90975ec34c4cSmrg age=$number_minor 90985ec34c4cSmrg revision=$number_revision 9099994689c1Smrg ;; 91005ec34c4cSmrg freebsd-aout|qnx|sunos) 91015ec34c4cSmrg current=$number_major 91025ec34c4cSmrg revision=$number_minor 91035ec34c4cSmrg age=0 9104994689c1Smrg ;; 9105994689c1Smrg irix|nonstopux) 9106994689c1Smrg func_arith $number_major + $number_minor 9107994689c1Smrg current=$func_arith_result 91085ec34c4cSmrg age=$number_minor 91095ec34c4cSmrg revision=$number_minor 9110994689c1Smrg lt_irix_increment=no 9111994689c1Smrg ;; 9112994689c1Smrg esac 9113994689c1Smrg ;; 9114994689c1Smrg no) 91155ec34c4cSmrg current=$1 91165ec34c4cSmrg revision=$2 91175ec34c4cSmrg age=$3 9118994689c1Smrg ;; 9119994689c1Smrg esac 9120994689c1Smrg 9121994689c1Smrg # Check that each of the things are valid numbers. 9122994689c1Smrg case $current in 9123994689c1Smrg 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]) ;; 9124994689c1Smrg *) 91255ec34c4cSmrg func_error "CURRENT '$current' must be a nonnegative integer" 91265ec34c4cSmrg func_fatal_error "'$vinfo' is not valid version information" 9127994689c1Smrg ;; 9128994689c1Smrg esac 9129994689c1Smrg 9130994689c1Smrg case $revision in 9131994689c1Smrg 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]) ;; 9132994689c1Smrg *) 91335ec34c4cSmrg func_error "REVISION '$revision' must be a nonnegative integer" 91345ec34c4cSmrg func_fatal_error "'$vinfo' is not valid version information" 9135994689c1Smrg ;; 9136994689c1Smrg esac 9137994689c1Smrg 9138994689c1Smrg case $age in 9139994689c1Smrg 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]) ;; 9140994689c1Smrg *) 91415ec34c4cSmrg func_error "AGE '$age' must be a nonnegative integer" 91425ec34c4cSmrg func_fatal_error "'$vinfo' is not valid version information" 9143994689c1Smrg ;; 9144994689c1Smrg esac 9145994689c1Smrg 9146994689c1Smrg if test "$age" -gt "$current"; then 91475ec34c4cSmrg func_error "AGE '$age' is greater than the current interface number '$current'" 91485ec34c4cSmrg func_fatal_error "'$vinfo' is not valid version information" 9149994689c1Smrg fi 9150994689c1Smrg 9151994689c1Smrg # Calculate the version variables. 9152994689c1Smrg major= 9153994689c1Smrg versuffix= 9154994689c1Smrg verstring= 9155994689c1Smrg case $version_type in 9156994689c1Smrg none) ;; 9157994689c1Smrg 9158994689c1Smrg darwin) 9159994689c1Smrg # Like Linux, but with the current version available in 9160994689c1Smrg # verstring for coding it into the library header 9161994689c1Smrg func_arith $current - $age 9162994689c1Smrg major=.$func_arith_result 91635ec34c4cSmrg versuffix=$major.$age.$revision 9164994689c1Smrg # Darwin ld doesn't like 0 for these options... 9165994689c1Smrg func_arith $current + 1 9166994689c1Smrg minor_current=$func_arith_result 91675ec34c4cSmrg xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" 9168994689c1Smrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 91695ec34c4cSmrg # On Darwin other compilers 91705ec34c4cSmrg case $CC in 91715ec34c4cSmrg nagfor*) 91725ec34c4cSmrg verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" 91735ec34c4cSmrg ;; 91745ec34c4cSmrg *) 91755ec34c4cSmrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 91765ec34c4cSmrg ;; 91775ec34c4cSmrg esac 9178994689c1Smrg ;; 9179994689c1Smrg 9180994689c1Smrg freebsd-aout) 91815ec34c4cSmrg major=.$current 91825ec34c4cSmrg versuffix=.$current.$revision 9183994689c1Smrg ;; 9184994689c1Smrg 91855b16253fSmrg freebsd-elf | midnightbsd-elf) 91865ec34c4cSmrg func_arith $current - $age 91875ec34c4cSmrg major=.$func_arith_result 91885ec34c4cSmrg versuffix=$major.$age.$revision 9189994689c1Smrg ;; 9190994689c1Smrg 9191994689c1Smrg irix | nonstopux) 91925ec34c4cSmrg if test no = "$lt_irix_increment"; then 9193994689c1Smrg func_arith $current - $age 9194994689c1Smrg else 9195994689c1Smrg func_arith $current - $age + 1 9196994689c1Smrg fi 9197994689c1Smrg major=$func_arith_result 9198994689c1Smrg 9199994689c1Smrg case $version_type in 9200994689c1Smrg nonstopux) verstring_prefix=nonstopux ;; 9201994689c1Smrg *) verstring_prefix=sgi ;; 9202994689c1Smrg esac 92035ec34c4cSmrg verstring=$verstring_prefix$major.$revision 9204994689c1Smrg 9205994689c1Smrg # Add in all the interfaces that we are compatible with. 9206994689c1Smrg loop=$revision 92075ec34c4cSmrg while test 0 -ne "$loop"; do 9208994689c1Smrg func_arith $revision - $loop 9209994689c1Smrg iface=$func_arith_result 9210994689c1Smrg func_arith $loop - 1 9211994689c1Smrg loop=$func_arith_result 92125ec34c4cSmrg verstring=$verstring_prefix$major.$iface:$verstring 9213994689c1Smrg done 9214994689c1Smrg 92155ec34c4cSmrg # Before this point, $major must not contain '.'. 9216994689c1Smrg major=.$major 92175ec34c4cSmrg versuffix=$major.$revision 9218994689c1Smrg ;; 9219994689c1Smrg 9220421c997bSmrg linux) # correct to gnu/linux during the next big refactor 9221994689c1Smrg func_arith $current - $age 9222994689c1Smrg major=.$func_arith_result 92235ec34c4cSmrg versuffix=$major.$age.$revision 9224994689c1Smrg ;; 9225994689c1Smrg 9226994689c1Smrg osf) 9227994689c1Smrg func_arith $current - $age 9228994689c1Smrg major=.$func_arith_result 92295ec34c4cSmrg versuffix=.$current.$age.$revision 92305ec34c4cSmrg verstring=$current.$age.$revision 9231994689c1Smrg 9232994689c1Smrg # Add in all the interfaces that we are compatible with. 9233994689c1Smrg loop=$age 92345ec34c4cSmrg while test 0 -ne "$loop"; do 9235994689c1Smrg func_arith $current - $loop 9236994689c1Smrg iface=$func_arith_result 9237994689c1Smrg func_arith $loop - 1 9238994689c1Smrg loop=$func_arith_result 92395ec34c4cSmrg verstring=$verstring:$iface.0 9240994689c1Smrg done 9241994689c1Smrg 9242994689c1Smrg # Make executables depend on our current version. 92435ec34c4cSmrg func_append verstring ":$current.0" 9244994689c1Smrg ;; 9245994689c1Smrg 9246994689c1Smrg qnx) 92475ec34c4cSmrg major=.$current 92485ec34c4cSmrg versuffix=.$current 92495ec34c4cSmrg ;; 92505ec34c4cSmrg 92515ec34c4cSmrg sco) 92525ec34c4cSmrg major=.$current 92535ec34c4cSmrg versuffix=.$current 9254994689c1Smrg ;; 9255994689c1Smrg 9256994689c1Smrg sunos) 92575ec34c4cSmrg major=.$current 92585ec34c4cSmrg versuffix=.$current.$revision 9259994689c1Smrg ;; 9260994689c1Smrg 9261994689c1Smrg windows) 9262994689c1Smrg # Use '-' rather than '.', since we only want one 92635ec34c4cSmrg # extension on DOS 8.3 file systems. 9264994689c1Smrg func_arith $current - $age 9265994689c1Smrg major=$func_arith_result 92665ec34c4cSmrg versuffix=-$major 9267994689c1Smrg ;; 9268994689c1Smrg 9269994689c1Smrg *) 92705ec34c4cSmrg func_fatal_configuration "unknown library version type '$version_type'" 9271994689c1Smrg ;; 9272994689c1Smrg esac 9273994689c1Smrg 9274994689c1Smrg # Clear the version info if we defaulted, and they specified a release. 9275994689c1Smrg if test -z "$vinfo" && test -n "$release"; then 9276994689c1Smrg major= 9277994689c1Smrg case $version_type in 9278994689c1Smrg darwin) 9279994689c1Smrg # we can't check for "0.0" in archive_cmds due to quoting 9280994689c1Smrg # problems, so we reset it completely 9281994689c1Smrg verstring= 9282994689c1Smrg ;; 9283994689c1Smrg *) 92845ec34c4cSmrg verstring=0.0 9285994689c1Smrg ;; 9286994689c1Smrg esac 92875ec34c4cSmrg if test no = "$need_version"; then 9288994689c1Smrg versuffix= 9289994689c1Smrg else 92905ec34c4cSmrg versuffix=.0.0 9291994689c1Smrg fi 9292994689c1Smrg fi 9293994689c1Smrg 9294994689c1Smrg # Remove version info from name if versioning should be avoided 92955ec34c4cSmrg if test yes,no = "$avoid_version,$need_version"; then 9296994689c1Smrg major= 9297994689c1Smrg versuffix= 92985ec34c4cSmrg verstring= 9299994689c1Smrg fi 9300994689c1Smrg 9301994689c1Smrg # Check to see if the archive will have undefined symbols. 93025ec34c4cSmrg if test yes = "$allow_undefined"; then 93035ec34c4cSmrg if test unsupported = "$allow_undefined_flag"; then 93045ec34c4cSmrg if test yes = "$build_old_libs"; then 93055ec34c4cSmrg func_warning "undefined symbols not allowed in $host shared libraries; building static only" 93065ec34c4cSmrg build_libtool_libs=no 93075ec34c4cSmrg else 93085ec34c4cSmrg func_fatal_error "can't build $host shared library unless -no-undefined is specified" 93095ec34c4cSmrg fi 9310994689c1Smrg fi 9311994689c1Smrg else 9312994689c1Smrg # Don't allow undefined symbols. 93135ec34c4cSmrg allow_undefined_flag=$no_undefined_flag 9314994689c1Smrg fi 9315994689c1Smrg 9316994689c1Smrg fi 9317994689c1Smrg 93185ec34c4cSmrg func_generate_dlsyms "$libname" "$libname" : 9319f353fbadSmrg func_append libobjs " $symfileobj" 93205ec34c4cSmrg test " " = "$libobjs" && libobjs= 9321994689c1Smrg 93225ec34c4cSmrg if test relink != "$opt_mode"; then 9323994689c1Smrg # Remove our outputs, but don't remove object files since they 9324994689c1Smrg # may have been created when compiling PIC objects. 9325994689c1Smrg removelist= 9326994689c1Smrg tempremovelist=`$ECHO "$output_objdir/*"` 9327994689c1Smrg for p in $tempremovelist; do 9328994689c1Smrg case $p in 9329994689c1Smrg *.$objext | *.gcno) 9330994689c1Smrg ;; 93315ec34c4cSmrg $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/$libname$release.*) 93325ec34c4cSmrg if test -n "$precious_files_regex"; then 9333994689c1Smrg if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 9334994689c1Smrg then 9335994689c1Smrg continue 9336994689c1Smrg fi 9337994689c1Smrg fi 9338f353fbadSmrg func_append removelist " $p" 9339994689c1Smrg ;; 9340994689c1Smrg *) ;; 9341994689c1Smrg esac 9342994689c1Smrg done 9343994689c1Smrg test -n "$removelist" && \ 9344994689c1Smrg func_show_eval "${RM}r \$removelist" 9345994689c1Smrg fi 9346994689c1Smrg 9347994689c1Smrg # Now set the variables for building old libraries. 93485ec34c4cSmrg if test yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; then 9349f353fbadSmrg func_append oldlibs " $output_objdir/$libname.$libext" 9350994689c1Smrg 9351994689c1Smrg # Transform .lo files to .o files. 93525ec34c4cSmrg oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; $lo2o" | $NL2SP` 9353994689c1Smrg fi 9354994689c1Smrg 9355994689c1Smrg # Eliminate all temporary directories. 9356994689c1Smrg #for path in $notinst_path; do 9357994689c1Smrg # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` 9358994689c1Smrg # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` 9359994689c1Smrg # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` 9360994689c1Smrg #done 9361994689c1Smrg 9362994689c1Smrg if test -n "$xrpath"; then 9363994689c1Smrg # If the user specified any rpath flags, then add them. 9364994689c1Smrg temp_xrpath= 9365994689c1Smrg for libdir in $xrpath; do 9366f353fbadSmrg func_replace_sysroot "$libdir" 9367f353fbadSmrg func_append temp_xrpath " -R$func_replace_sysroot_result" 9368994689c1Smrg case "$finalize_rpath " in 9369994689c1Smrg *" $libdir "*) ;; 9370f353fbadSmrg *) func_append finalize_rpath " $libdir" ;; 9371994689c1Smrg esac 9372994689c1Smrg done 93735ec34c4cSmrg if test yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; then 9374994689c1Smrg dependency_libs="$temp_xrpath $dependency_libs" 9375994689c1Smrg fi 9376994689c1Smrg fi 9377994689c1Smrg 9378994689c1Smrg # Make sure dlfiles contains only unique files that won't be dlpreopened 93795ec34c4cSmrg old_dlfiles=$dlfiles 9380994689c1Smrg dlfiles= 9381994689c1Smrg for lib in $old_dlfiles; do 9382994689c1Smrg case " $dlprefiles $dlfiles " in 9383994689c1Smrg *" $lib "*) ;; 9384f353fbadSmrg *) func_append dlfiles " $lib" ;; 9385994689c1Smrg esac 9386994689c1Smrg done 9387994689c1Smrg 9388994689c1Smrg # Make sure dlprefiles contains only unique files 93895ec34c4cSmrg old_dlprefiles=$dlprefiles 9390994689c1Smrg dlprefiles= 9391994689c1Smrg for lib in $old_dlprefiles; do 9392994689c1Smrg case "$dlprefiles " in 9393994689c1Smrg *" $lib "*) ;; 9394f353fbadSmrg *) func_append dlprefiles " $lib" ;; 9395994689c1Smrg esac 9396994689c1Smrg done 9397994689c1Smrg 93985ec34c4cSmrg if test yes = "$build_libtool_libs"; then 9399994689c1Smrg if test -n "$rpath"; then 9400994689c1Smrg case $host in 9401994689c1Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) 9402994689c1Smrg # these systems don't actually have a c library (as such)! 9403994689c1Smrg ;; 9404994689c1Smrg *-*-rhapsody* | *-*-darwin1.[012]) 9405994689c1Smrg # Rhapsody C library is in the System framework 9406f353fbadSmrg func_append deplibs " System.ltframework" 9407994689c1Smrg ;; 9408994689c1Smrg *-*-netbsd*) 9409994689c1Smrg # Don't link with libc until the a.out ld.so is fixed. 9410994689c1Smrg ;; 94115b16253fSmrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-midnightbsd*) 9412994689c1Smrg # Do not include libc due to us having libc/libc_r. 9413994689c1Smrg ;; 9414994689c1Smrg *-*-sco3.2v5* | *-*-sco5v6*) 9415994689c1Smrg # Causes problems with __ctype 9416994689c1Smrg ;; 9417994689c1Smrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 9418994689c1Smrg # Compiler inserts libc in the correct place for threads to work 9419994689c1Smrg ;; 9420994689c1Smrg *) 9421994689c1Smrg # Add libc to deplibs on all other systems if necessary. 94225ec34c4cSmrg if test yes = "$build_libtool_need_lc"; then 9423f353fbadSmrg func_append deplibs " -lc" 9424994689c1Smrg fi 9425994689c1Smrg ;; 9426994689c1Smrg esac 9427994689c1Smrg fi 9428994689c1Smrg 9429994689c1Smrg # Transform deplibs into only deplibs that can be linked in shared. 9430994689c1Smrg name_save=$name 9431994689c1Smrg libname_save=$libname 9432994689c1Smrg release_save=$release 9433994689c1Smrg versuffix_save=$versuffix 9434994689c1Smrg major_save=$major 9435994689c1Smrg # I'm not sure if I'm treating the release correctly. I think 9436994689c1Smrg # release should show up in the -l (ie -lgmp5) so we don't want to 9437994689c1Smrg # add it in twice. Is that correct? 94385ec34c4cSmrg release= 94395ec34c4cSmrg versuffix= 94405ec34c4cSmrg major= 9441994689c1Smrg newdeplibs= 9442994689c1Smrg droppeddeps=no 9443994689c1Smrg case $deplibs_check_method in 9444994689c1Smrg pass_all) 9445994689c1Smrg # Don't check for shared/static. Everything works. 9446994689c1Smrg # This might be a little naive. We might want to check 9447994689c1Smrg # whether the library exists or not. But this is on 9448994689c1Smrg # osf3 & osf4 and I'm not really sure... Just 9449994689c1Smrg # implementing what was already the behavior. 9450994689c1Smrg newdeplibs=$deplibs 9451994689c1Smrg ;; 9452994689c1Smrg test_compile) 9453994689c1Smrg # This code stresses the "libraries are programs" paradigm to its 9454994689c1Smrg # limits. Maybe even breaks it. We compile a program, linking it 9455994689c1Smrg # against the deplibs as a proxy for the library. Then we can check 9456994689c1Smrg # whether they linked in statically or dynamically with ldd. 9457994689c1Smrg $opt_dry_run || $RM conftest.c 9458994689c1Smrg cat > conftest.c <<EOF 9459994689c1Smrg int main() { return 0; } 9460994689c1SmrgEOF 9461994689c1Smrg $opt_dry_run || $RM conftest 9462994689c1Smrg if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then 9463994689c1Smrg ldd_output=`ldd conftest` 9464994689c1Smrg for i in $deplibs; do 9465994689c1Smrg case $i in 9466994689c1Smrg -l*) 9467994689c1Smrg func_stripname -l '' "$i" 9468994689c1Smrg name=$func_stripname_result 94695ec34c4cSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9470994689c1Smrg case " $predeps $postdeps " in 9471994689c1Smrg *" $i "*) 9472f353fbadSmrg func_append newdeplibs " $i" 94735ec34c4cSmrg i= 9474994689c1Smrg ;; 9475994689c1Smrg esac 9476994689c1Smrg fi 94775ec34c4cSmrg if test -n "$i"; then 9478994689c1Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 9479994689c1Smrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 9480994689c1Smrg set dummy $deplib_matches; shift 9481994689c1Smrg deplib_match=$1 94825ec34c4cSmrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then 9483f353fbadSmrg func_append newdeplibs " $i" 9484994689c1Smrg else 9485994689c1Smrg droppeddeps=yes 9486994689c1Smrg echo 9487994689c1Smrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 9488994689c1Smrg echo "*** I have the capability to make that library automatically link in when" 9489994689c1Smrg echo "*** you link to this library. But I can only do this if you have a" 9490994689c1Smrg echo "*** shared version of the library, which I believe you do not have" 9491994689c1Smrg echo "*** because a test_compile did reveal that the linker did not use it for" 9492994689c1Smrg echo "*** its dynamic dependency list that programs get resolved with at runtime." 9493994689c1Smrg fi 9494994689c1Smrg fi 9495994689c1Smrg ;; 9496994689c1Smrg *) 9497f353fbadSmrg func_append newdeplibs " $i" 9498994689c1Smrg ;; 9499994689c1Smrg esac 9500994689c1Smrg done 9501994689c1Smrg else 9502994689c1Smrg # Error occurred in the first compile. Let's try to salvage 9503994689c1Smrg # the situation: Compile a separate program for each library. 9504994689c1Smrg for i in $deplibs; do 9505994689c1Smrg case $i in 9506994689c1Smrg -l*) 9507994689c1Smrg func_stripname -l '' "$i" 9508994689c1Smrg name=$func_stripname_result 9509994689c1Smrg $opt_dry_run || $RM conftest 9510994689c1Smrg if $LTCC $LTCFLAGS -o conftest conftest.c $i; then 9511994689c1Smrg ldd_output=`ldd conftest` 95125ec34c4cSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9513994689c1Smrg case " $predeps $postdeps " in 9514994689c1Smrg *" $i "*) 9515f353fbadSmrg func_append newdeplibs " $i" 95165ec34c4cSmrg i= 9517994689c1Smrg ;; 9518994689c1Smrg esac 9519994689c1Smrg fi 95205ec34c4cSmrg if test -n "$i"; then 9521994689c1Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 9522994689c1Smrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 9523994689c1Smrg set dummy $deplib_matches; shift 9524994689c1Smrg deplib_match=$1 95255ec34c4cSmrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then 9526f353fbadSmrg func_append newdeplibs " $i" 9527994689c1Smrg else 9528994689c1Smrg droppeddeps=yes 9529994689c1Smrg echo 9530994689c1Smrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 9531994689c1Smrg echo "*** I have the capability to make that library automatically link in when" 9532994689c1Smrg echo "*** you link to this library. But I can only do this if you have a" 9533994689c1Smrg echo "*** shared version of the library, which you do not appear to have" 9534994689c1Smrg echo "*** because a test_compile did reveal that the linker did not use this one" 9535994689c1Smrg echo "*** as a dynamic dependency that programs can get resolved with at runtime." 9536994689c1Smrg fi 9537994689c1Smrg fi 9538994689c1Smrg else 9539994689c1Smrg droppeddeps=yes 9540994689c1Smrg echo 9541994689c1Smrg $ECHO "*** Warning! Library $i is needed by this library but I was not able to" 9542994689c1Smrg echo "*** make it link in! You will probably need to install it or some" 9543994689c1Smrg echo "*** library that it depends on before this library will be fully" 9544994689c1Smrg echo "*** functional. Installing it before continuing would be even better." 9545994689c1Smrg fi 9546994689c1Smrg ;; 9547994689c1Smrg *) 9548f353fbadSmrg func_append newdeplibs " $i" 9549994689c1Smrg ;; 9550994689c1Smrg esac 9551994689c1Smrg done 9552994689c1Smrg fi 9553994689c1Smrg ;; 9554994689c1Smrg file_magic*) 9555994689c1Smrg set dummy $deplibs_check_method; shift 9556994689c1Smrg file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 9557994689c1Smrg for a_deplib in $deplibs; do 9558994689c1Smrg case $a_deplib in 9559994689c1Smrg -l*) 9560994689c1Smrg func_stripname -l '' "$a_deplib" 9561994689c1Smrg name=$func_stripname_result 95625ec34c4cSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9563994689c1Smrg case " $predeps $postdeps " in 9564994689c1Smrg *" $a_deplib "*) 9565f353fbadSmrg func_append newdeplibs " $a_deplib" 95665ec34c4cSmrg a_deplib= 9567994689c1Smrg ;; 9568994689c1Smrg esac 9569994689c1Smrg fi 95705ec34c4cSmrg if test -n "$a_deplib"; then 9571994689c1Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 9572f353fbadSmrg if test -n "$file_magic_glob"; then 9573f353fbadSmrg libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob` 9574f353fbadSmrg else 9575f353fbadSmrg libnameglob=$libname 9576f353fbadSmrg fi 95775ec34c4cSmrg test yes = "$want_nocaseglob" && nocaseglob=`shopt -p nocaseglob` 9578994689c1Smrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 95795ec34c4cSmrg if test yes = "$want_nocaseglob"; then 9580f353fbadSmrg shopt -s nocaseglob 9581f353fbadSmrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 9582f353fbadSmrg $nocaseglob 9583f353fbadSmrg else 9584f353fbadSmrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 9585f353fbadSmrg fi 9586994689c1Smrg for potent_lib in $potential_libs; do 9587994689c1Smrg # Follow soft links. 9588994689c1Smrg if ls -lLd "$potent_lib" 2>/dev/null | 9589994689c1Smrg $GREP " -> " >/dev/null; then 9590994689c1Smrg continue 9591994689c1Smrg fi 9592994689c1Smrg # The statement above tries to avoid entering an 9593994689c1Smrg # endless loop below, in case of cyclic links. 9594994689c1Smrg # We might still enter an endless loop, since a link 9595994689c1Smrg # loop can be closed while we follow links, 9596994689c1Smrg # but so what? 95975ec34c4cSmrg potlib=$potent_lib 9598994689c1Smrg while test -h "$potlib" 2>/dev/null; do 95995ec34c4cSmrg potliblink=`ls -ld $potlib | $SED 's/.* -> //'` 9600994689c1Smrg case $potliblink in 96015ec34c4cSmrg [\\/]* | [A-Za-z]:[\\/]*) potlib=$potliblink;; 96025ec34c4cSmrg *) potlib=`$ECHO "$potlib" | $SED 's|[^/]*$||'`"$potliblink";; 9603994689c1Smrg esac 9604994689c1Smrg done 9605994689c1Smrg if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | 9606994689c1Smrg $SED -e 10q | 9607994689c1Smrg $EGREP "$file_magic_regex" > /dev/null; then 9608f353fbadSmrg func_append newdeplibs " $a_deplib" 96095ec34c4cSmrg a_deplib= 9610994689c1Smrg break 2 9611994689c1Smrg fi 9612994689c1Smrg done 9613994689c1Smrg done 9614994689c1Smrg fi 96155ec34c4cSmrg if test -n "$a_deplib"; then 9616994689c1Smrg droppeddeps=yes 9617994689c1Smrg echo 9618994689c1Smrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 9619994689c1Smrg echo "*** I have the capability to make that library automatically link in when" 9620994689c1Smrg echo "*** you link to this library. But I can only do this if you have a" 9621994689c1Smrg echo "*** shared version of the library, which you do not appear to have" 9622994689c1Smrg echo "*** because I did check the linker path looking for a file starting" 96235ec34c4cSmrg if test -z "$potlib"; then 9624994689c1Smrg $ECHO "*** with $libname but no candidates were found. (...for file magic test)" 9625994689c1Smrg else 9626994689c1Smrg $ECHO "*** with $libname and none of the candidates passed a file format test" 9627994689c1Smrg $ECHO "*** using a file magic. Last file checked: $potlib" 9628994689c1Smrg fi 9629994689c1Smrg fi 9630994689c1Smrg ;; 9631994689c1Smrg *) 9632994689c1Smrg # Add a -L argument. 9633f353fbadSmrg func_append newdeplibs " $a_deplib" 9634994689c1Smrg ;; 9635994689c1Smrg esac 9636994689c1Smrg done # Gone through all deplibs. 9637994689c1Smrg ;; 9638994689c1Smrg match_pattern*) 9639994689c1Smrg set dummy $deplibs_check_method; shift 9640994689c1Smrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 9641994689c1Smrg for a_deplib in $deplibs; do 9642994689c1Smrg case $a_deplib in 9643994689c1Smrg -l*) 9644994689c1Smrg func_stripname -l '' "$a_deplib" 9645994689c1Smrg name=$func_stripname_result 96465ec34c4cSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9647994689c1Smrg case " $predeps $postdeps " in 9648994689c1Smrg *" $a_deplib "*) 9649f353fbadSmrg func_append newdeplibs " $a_deplib" 96505ec34c4cSmrg a_deplib= 9651994689c1Smrg ;; 9652994689c1Smrg esac 9653994689c1Smrg fi 96545ec34c4cSmrg if test -n "$a_deplib"; then 9655994689c1Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 9656994689c1Smrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 9657994689c1Smrg potential_libs=`ls $i/$libname[.-]* 2>/dev/null` 9658994689c1Smrg for potent_lib in $potential_libs; do 96595ec34c4cSmrg potlib=$potent_lib # see symlink-check above in file_magic test 9660994689c1Smrg if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ 9661994689c1Smrg $EGREP "$match_pattern_regex" > /dev/null; then 9662f353fbadSmrg func_append newdeplibs " $a_deplib" 96635ec34c4cSmrg a_deplib= 9664994689c1Smrg break 2 9665994689c1Smrg fi 9666994689c1Smrg done 9667994689c1Smrg done 9668994689c1Smrg fi 96695ec34c4cSmrg if test -n "$a_deplib"; then 9670994689c1Smrg droppeddeps=yes 9671994689c1Smrg echo 9672994689c1Smrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 9673994689c1Smrg echo "*** I have the capability to make that library automatically link in when" 9674994689c1Smrg echo "*** you link to this library. But I can only do this if you have a" 9675994689c1Smrg echo "*** shared version of the library, which you do not appear to have" 9676994689c1Smrg echo "*** because I did check the linker path looking for a file starting" 96775ec34c4cSmrg if test -z "$potlib"; then 9678994689c1Smrg $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" 9679994689c1Smrg else 9680994689c1Smrg $ECHO "*** with $libname and none of the candidates passed a file format test" 9681994689c1Smrg $ECHO "*** using a regex pattern. Last file checked: $potlib" 9682994689c1Smrg fi 9683994689c1Smrg fi 9684994689c1Smrg ;; 9685994689c1Smrg *) 9686994689c1Smrg # Add a -L argument. 9687f353fbadSmrg func_append newdeplibs " $a_deplib" 9688994689c1Smrg ;; 9689994689c1Smrg esac 9690994689c1Smrg done # Gone through all deplibs. 9691994689c1Smrg ;; 9692994689c1Smrg none | unknown | *) 96935ec34c4cSmrg newdeplibs= 9694994689c1Smrg tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` 96955ec34c4cSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 96965ec34c4cSmrg for i in $predeps $postdeps; do 9697994689c1Smrg # can't use Xsed below, because $i might contain '/' 96985ec34c4cSmrg tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s|$i||"` 9699994689c1Smrg done 9700994689c1Smrg fi 9701994689c1Smrg case $tmp_deplibs in 9702994689c1Smrg *[!\ \ ]*) 9703994689c1Smrg echo 97045ec34c4cSmrg if test none = "$deplibs_check_method"; then 9705994689c1Smrg echo "*** Warning: inter-library dependencies are not supported in this platform." 9706994689c1Smrg else 9707994689c1Smrg echo "*** Warning: inter-library dependencies are not known to be supported." 9708994689c1Smrg fi 9709994689c1Smrg echo "*** All declared inter-library dependencies are being dropped." 9710994689c1Smrg droppeddeps=yes 9711994689c1Smrg ;; 9712994689c1Smrg esac 9713994689c1Smrg ;; 9714994689c1Smrg esac 9715994689c1Smrg versuffix=$versuffix_save 9716994689c1Smrg major=$major_save 9717994689c1Smrg release=$release_save 9718994689c1Smrg libname=$libname_save 9719994689c1Smrg name=$name_save 9720994689c1Smrg 9721994689c1Smrg case $host in 9722994689c1Smrg *-*-rhapsody* | *-*-darwin1.[012]) 9723994689c1Smrg # On Rhapsody replace the C library with the System framework 9724994689c1Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` 9725994689c1Smrg ;; 9726994689c1Smrg esac 9727994689c1Smrg 97285ec34c4cSmrg if test yes = "$droppeddeps"; then 97295ec34c4cSmrg if test yes = "$module"; then 9730994689c1Smrg echo 9731994689c1Smrg echo "*** Warning: libtool could not satisfy all declared inter-library" 9732994689c1Smrg $ECHO "*** dependencies of module $libname. Therefore, libtool will create" 9733994689c1Smrg echo "*** a static module, that should work as long as the dlopening" 9734994689c1Smrg echo "*** application is linked with the -dlopen flag." 9735994689c1Smrg if test -z "$global_symbol_pipe"; then 9736994689c1Smrg echo 9737994689c1Smrg echo "*** However, this would only work if libtool was able to extract symbol" 97385ec34c4cSmrg echo "*** lists from a program, using 'nm' or equivalent, but libtool could" 9739994689c1Smrg echo "*** not find such a program. So, this module is probably useless." 97405ec34c4cSmrg echo "*** 'nm' from GNU binutils and a full rebuild may help." 9741994689c1Smrg fi 97425ec34c4cSmrg if test no = "$build_old_libs"; then 97435ec34c4cSmrg oldlibs=$output_objdir/$libname.$libext 9744994689c1Smrg build_libtool_libs=module 9745994689c1Smrg build_old_libs=yes 9746994689c1Smrg else 9747994689c1Smrg build_libtool_libs=no 9748994689c1Smrg fi 9749994689c1Smrg else 9750994689c1Smrg echo "*** The inter-library dependencies that have been dropped here will be" 9751994689c1Smrg echo "*** automatically added whenever a program is linked with this library" 9752994689c1Smrg echo "*** or is declared to -dlopen it." 9753994689c1Smrg 97545ec34c4cSmrg if test no = "$allow_undefined"; then 9755994689c1Smrg echo 9756994689c1Smrg echo "*** Since this library must not contain undefined symbols," 9757994689c1Smrg echo "*** because either the platform does not support them or" 9758994689c1Smrg echo "*** it was explicitly requested with -no-undefined," 9759994689c1Smrg echo "*** libtool will only create a static version of it." 97605ec34c4cSmrg if test no = "$build_old_libs"; then 97615ec34c4cSmrg oldlibs=$output_objdir/$libname.$libext 9762994689c1Smrg build_libtool_libs=module 9763994689c1Smrg build_old_libs=yes 9764994689c1Smrg else 9765994689c1Smrg build_libtool_libs=no 9766994689c1Smrg fi 9767994689c1Smrg fi 9768994689c1Smrg fi 9769994689c1Smrg fi 9770994689c1Smrg # Done checking deplibs! 9771994689c1Smrg deplibs=$newdeplibs 9772994689c1Smrg fi 9773994689c1Smrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 9774994689c1Smrg case $host in 9775994689c1Smrg *-*-darwin*) 9776994689c1Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 9777994689c1Smrg new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 9778994689c1Smrg deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 9779994689c1Smrg ;; 9780994689c1Smrg esac 9781994689c1Smrg 9782994689c1Smrg # move library search paths that coincide with paths to not yet 9783994689c1Smrg # installed libraries to the beginning of the library search list 9784994689c1Smrg new_libs= 9785994689c1Smrg for path in $notinst_path; do 9786994689c1Smrg case " $new_libs " in 9787994689c1Smrg *" -L$path/$objdir "*) ;; 9788994689c1Smrg *) 9789994689c1Smrg case " $deplibs " in 9790994689c1Smrg *" -L$path/$objdir "*) 9791f353fbadSmrg func_append new_libs " -L$path/$objdir" ;; 9792994689c1Smrg esac 9793994689c1Smrg ;; 9794994689c1Smrg esac 9795994689c1Smrg done 9796994689c1Smrg for deplib in $deplibs; do 9797994689c1Smrg case $deplib in 9798994689c1Smrg -L*) 9799994689c1Smrg case " $new_libs " in 9800994689c1Smrg *" $deplib "*) ;; 9801f353fbadSmrg *) func_append new_libs " $deplib" ;; 9802994689c1Smrg esac 9803994689c1Smrg ;; 9804f353fbadSmrg *) func_append new_libs " $deplib" ;; 9805994689c1Smrg esac 9806994689c1Smrg done 98075ec34c4cSmrg deplibs=$new_libs 9808994689c1Smrg 9809994689c1Smrg # All the library-specific variables (install_libdir is set above). 9810994689c1Smrg library_names= 9811994689c1Smrg old_library= 9812994689c1Smrg dlname= 9813994689c1Smrg 9814994689c1Smrg # Test again, we may have decided not to build it any more 98155ec34c4cSmrg if test yes = "$build_libtool_libs"; then 98165ec34c4cSmrg # Remove $wl instances when linking with ld. 9817421c997bSmrg # FIXME: should test the right _cmds variable. 9818421c997bSmrg case $archive_cmds in 9819421c997bSmrg *\$LD\ *) wl= ;; 9820421c997bSmrg esac 98215ec34c4cSmrg if test yes = "$hardcode_into_libs"; then 9822994689c1Smrg # Hardcode the library paths 9823994689c1Smrg hardcode_libdirs= 9824994689c1Smrg dep_rpath= 98255ec34c4cSmrg rpath=$finalize_rpath 98265ec34c4cSmrg test relink = "$opt_mode" || rpath=$compile_rpath$rpath 9827994689c1Smrg for libdir in $rpath; do 9828994689c1Smrg if test -n "$hardcode_libdir_flag_spec"; then 9829994689c1Smrg if test -n "$hardcode_libdir_separator"; then 9830f353fbadSmrg func_replace_sysroot "$libdir" 9831f353fbadSmrg libdir=$func_replace_sysroot_result 9832994689c1Smrg if test -z "$hardcode_libdirs"; then 98335ec34c4cSmrg hardcode_libdirs=$libdir 9834994689c1Smrg else 9835994689c1Smrg # Just accumulate the unique libdirs. 9836994689c1Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 9837994689c1Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 9838994689c1Smrg ;; 9839994689c1Smrg *) 9840f353fbadSmrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 9841994689c1Smrg ;; 9842994689c1Smrg esac 9843994689c1Smrg fi 9844994689c1Smrg else 9845994689c1Smrg eval flag=\"$hardcode_libdir_flag_spec\" 9846f353fbadSmrg func_append dep_rpath " $flag" 9847994689c1Smrg fi 9848994689c1Smrg elif test -n "$runpath_var"; then 9849994689c1Smrg case "$perm_rpath " in 9850994689c1Smrg *" $libdir "*) ;; 9851421c997bSmrg *) func_append perm_rpath " $libdir" ;; 9852994689c1Smrg esac 9853994689c1Smrg fi 9854994689c1Smrg done 9855994689c1Smrg # Substitute the hardcoded libdirs into the rpath. 9856994689c1Smrg if test -n "$hardcode_libdir_separator" && 9857994689c1Smrg test -n "$hardcode_libdirs"; then 98585ec34c4cSmrg libdir=$hardcode_libdirs 9859421c997bSmrg eval "dep_rpath=\"$hardcode_libdir_flag_spec\"" 9860994689c1Smrg fi 9861994689c1Smrg if test -n "$runpath_var" && test -n "$perm_rpath"; then 9862994689c1Smrg # We should set the runpath_var. 9863994689c1Smrg rpath= 9864994689c1Smrg for dir in $perm_rpath; do 9865f353fbadSmrg func_append rpath "$dir:" 9866994689c1Smrg done 9867994689c1Smrg eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" 9868994689c1Smrg fi 9869994689c1Smrg test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" 9870994689c1Smrg fi 98717a84e134Smrg 98725ec34c4cSmrg shlibpath=$finalize_shlibpath 98735ec34c4cSmrg test relink = "$opt_mode" || shlibpath=$compile_shlibpath$shlibpath 9874994689c1Smrg if test -n "$shlibpath"; then 9875994689c1Smrg eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" 9876994689c1Smrg fi 98777a84e134Smrg 9878994689c1Smrg # Get the real and link names of the library. 9879994689c1Smrg eval shared_ext=\"$shrext_cmds\" 9880994689c1Smrg eval library_names=\"$library_names_spec\" 9881994689c1Smrg set dummy $library_names 9882994689c1Smrg shift 98835ec34c4cSmrg realname=$1 9884994689c1Smrg shift 98857a84e134Smrg 9886994689c1Smrg if test -n "$soname_spec"; then 9887994689c1Smrg eval soname=\"$soname_spec\" 9888994689c1Smrg else 98895ec34c4cSmrg soname=$realname 9890994689c1Smrg fi 9891994689c1Smrg if test -z "$dlname"; then 9892994689c1Smrg dlname=$soname 9893994689c1Smrg fi 98947a84e134Smrg 98955ec34c4cSmrg lib=$output_objdir/$realname 9896994689c1Smrg linknames= 9897994689c1Smrg for link 9898994689c1Smrg do 9899f353fbadSmrg func_append linknames " $link" 9900994689c1Smrg done 99017a84e134Smrg 9902994689c1Smrg # Use standard objects if they are pic 9903994689c1Smrg test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` 9904994689c1Smrg test "X$libobjs" = "X " && libobjs= 99057a84e134Smrg 9906994689c1Smrg delfiles= 9907994689c1Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 9908994689c1Smrg $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" 99095ec34c4cSmrg export_symbols=$output_objdir/$libname.uexp 9910f353fbadSmrg func_append delfiles " $export_symbols" 9911994689c1Smrg fi 99127a84e134Smrg 9913994689c1Smrg orig_export_symbols= 9914994689c1Smrg case $host_os in 9915994689c1Smrg cygwin* | mingw* | cegcc*) 9916994689c1Smrg if test -n "$export_symbols" && test -z "$export_symbols_regex"; then 9917994689c1Smrg # exporting using user supplied symfile 99185ec34c4cSmrg func_dll_def_p "$export_symbols" || { 9919994689c1Smrg # and it's NOT already a .def file. Must figure out 9920994689c1Smrg # which of the given symbols are data symbols and tag 9921994689c1Smrg # them as such. So, trigger use of export_symbols_cmds. 9922994689c1Smrg # export_symbols gets reassigned inside the "prepare 9923994689c1Smrg # the list of exported symbols" if statement, so the 9924994689c1Smrg # include_expsyms logic still works. 99255ec34c4cSmrg orig_export_symbols=$export_symbols 9926994689c1Smrg export_symbols= 9927994689c1Smrg always_export_symbols=yes 99285ec34c4cSmrg } 9929994689c1Smrg fi 9930994689c1Smrg ;; 9931994689c1Smrg esac 99327a84e134Smrg 9933994689c1Smrg # Prepare the list of exported symbols 9934994689c1Smrg if test -z "$export_symbols"; then 99355ec34c4cSmrg if test yes = "$always_export_symbols" || test -n "$export_symbols_regex"; then 99365ec34c4cSmrg func_verbose "generating symbol list for '$libname.la'" 99375ec34c4cSmrg export_symbols=$output_objdir/$libname.exp 9938994689c1Smrg $opt_dry_run || $RM $export_symbols 9939994689c1Smrg cmds=$export_symbols_cmds 99405ec34c4cSmrg save_ifs=$IFS; IFS='~' 9941f353fbadSmrg for cmd1 in $cmds; do 99425ec34c4cSmrg IFS=$save_ifs 9943f353fbadSmrg # Take the normal branch if the nm_file_list_spec branch 9944f353fbadSmrg # doesn't work or if tool conversion is not needed. 9945f353fbadSmrg case $nm_file_list_spec~$to_tool_file_cmd in 9946f353fbadSmrg *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) 9947f353fbadSmrg try_normal_branch=yes 9948f353fbadSmrg eval cmd=\"$cmd1\" 9949f353fbadSmrg func_len " $cmd" 9950f353fbadSmrg len=$func_len_result 9951f353fbadSmrg ;; 9952f353fbadSmrg *) 9953f353fbadSmrg try_normal_branch=no 9954f353fbadSmrg ;; 9955f353fbadSmrg esac 99565ec34c4cSmrg if test yes = "$try_normal_branch" \ 9957f353fbadSmrg && { test "$len" -lt "$max_cmd_len" \ 9958f353fbadSmrg || test "$max_cmd_len" -le -1; } 9959f353fbadSmrg then 9960f353fbadSmrg func_show_eval "$cmd" 'exit $?' 9961f353fbadSmrg skipped_export=false 9962f353fbadSmrg elif test -n "$nm_file_list_spec"; then 9963f353fbadSmrg func_basename "$output" 9964f353fbadSmrg output_la=$func_basename_result 9965f353fbadSmrg save_libobjs=$libobjs 9966f353fbadSmrg save_output=$output 99675ec34c4cSmrg output=$output_objdir/$output_la.nm 9968f353fbadSmrg func_to_tool_file "$output" 9969f353fbadSmrg libobjs=$nm_file_list_spec$func_to_tool_file_result 9970f353fbadSmrg func_append delfiles " $output" 9971f353fbadSmrg func_verbose "creating $NM input file list: $output" 9972f353fbadSmrg for obj in $save_libobjs; do 9973f353fbadSmrg func_to_tool_file "$obj" 9974f353fbadSmrg $ECHO "$func_to_tool_file_result" 9975f353fbadSmrg done > "$output" 9976f353fbadSmrg eval cmd=\"$cmd1\" 9977994689c1Smrg func_show_eval "$cmd" 'exit $?' 9978f353fbadSmrg output=$save_output 9979f353fbadSmrg libobjs=$save_libobjs 9980994689c1Smrg skipped_export=false 9981994689c1Smrg else 9982994689c1Smrg # The command line is too long to execute in one step. 9983994689c1Smrg func_verbose "using reloadable object file for export list..." 9984994689c1Smrg skipped_export=: 9985994689c1Smrg # Break out early, otherwise skipped_export may be 9986994689c1Smrg # set to false by a later but shorter cmd. 9987994689c1Smrg break 9988994689c1Smrg fi 9989994689c1Smrg done 99905ec34c4cSmrg IFS=$save_ifs 99915ec34c4cSmrg if test -n "$export_symbols_regex" && test : != "$skipped_export"; then 9992994689c1Smrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 9993994689c1Smrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 9994994689c1Smrg fi 9995994689c1Smrg fi 9996994689c1Smrg fi 99977a84e134Smrg 9998994689c1Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 99995ec34c4cSmrg tmp_export_symbols=$export_symbols 100005ec34c4cSmrg test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols 10001994689c1Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 10002994689c1Smrg fi 100037a84e134Smrg 100045ec34c4cSmrg if test : != "$skipped_export" && test -n "$orig_export_symbols"; then 10005994689c1Smrg # The given exports_symbols file has to be filtered, so filter it. 100065ec34c4cSmrg func_verbose "filter symbol list for '$libname.la' to tag DATA exports" 10007994689c1Smrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 100085ec34c4cSmrg # 's' commands, which not all seds can handle. GNU sed should be fine 10009994689c1Smrg # though. Also, the filter scales superlinearly with the number of 10010994689c1Smrg # global variables. join(1) would be nice here, but unfortunately 10011994689c1Smrg # isn't a blessed tool. 10012994689c1Smrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 10013f353fbadSmrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 10014994689c1Smrg export_symbols=$output_objdir/$libname.def 10015994689c1Smrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 100167a84e134Smrg fi 100177a84e134Smrg 10018994689c1Smrg tmp_deplibs= 10019994689c1Smrg for test_deplib in $deplibs; do 10020994689c1Smrg case " $convenience " in 10021994689c1Smrg *" $test_deplib "*) ;; 10022994689c1Smrg *) 10023f353fbadSmrg func_append tmp_deplibs " $test_deplib" 10024994689c1Smrg ;; 10025994689c1Smrg esac 10026994689c1Smrg done 100275ec34c4cSmrg deplibs=$tmp_deplibs 100287a84e134Smrg 10029994689c1Smrg if test -n "$convenience"; then 10030994689c1Smrg if test -n "$whole_archive_flag_spec" && 100315ec34c4cSmrg test yes = "$compiler_needs_object" && 10032994689c1Smrg test -z "$libobjs"; then 10033994689c1Smrg # extract the archives, so we have objects to list. 10034994689c1Smrg # TODO: could optimize this to just extract one archive. 10035994689c1Smrg whole_archive_flag_spec= 10036994689c1Smrg fi 10037994689c1Smrg if test -n "$whole_archive_flag_spec"; then 10038994689c1Smrg save_libobjs=$libobjs 10039994689c1Smrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 10040994689c1Smrg test "X$libobjs" = "X " && libobjs= 10041994689c1Smrg else 100425ec34c4cSmrg gentop=$output_objdir/${outputname}x 10043f353fbadSmrg func_append generated " $gentop" 100447a84e134Smrg 10045994689c1Smrg func_extract_archives $gentop $convenience 10046f353fbadSmrg func_append libobjs " $func_extract_archives_result" 10047994689c1Smrg test "X$libobjs" = "X " && libobjs= 10048994689c1Smrg fi 10049994689c1Smrg fi 100507a84e134Smrg 100515ec34c4cSmrg if test yes = "$thread_safe" && test -n "$thread_safe_flag_spec"; then 10052994689c1Smrg eval flag=\"$thread_safe_flag_spec\" 10053f353fbadSmrg func_append linker_flags " $flag" 10054994689c1Smrg fi 100557a84e134Smrg 10056994689c1Smrg # Make a backup of the uninstalled library when relinking 100575ec34c4cSmrg if test relink = "$opt_mode"; then 10058994689c1Smrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? 10059e1e1713cSmrg fi 100607a84e134Smrg 10061994689c1Smrg # Do each of the archive commands. 100625ec34c4cSmrg if test yes = "$module" && test -n "$module_cmds"; then 10063994689c1Smrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 10064994689c1Smrg eval test_cmds=\"$module_expsym_cmds\" 10065994689c1Smrg cmds=$module_expsym_cmds 10066994689c1Smrg else 10067994689c1Smrg eval test_cmds=\"$module_cmds\" 10068994689c1Smrg cmds=$module_cmds 10069994689c1Smrg fi 10070994689c1Smrg else 10071994689c1Smrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 10072994689c1Smrg eval test_cmds=\"$archive_expsym_cmds\" 10073994689c1Smrg cmds=$archive_expsym_cmds 10074994689c1Smrg else 10075994689c1Smrg eval test_cmds=\"$archive_cmds\" 10076994689c1Smrg cmds=$archive_cmds 10077994689c1Smrg fi 10078e1e1713cSmrg fi 10079775e7de9Smrg 100805ec34c4cSmrg if test : != "$skipped_export" && 10081994689c1Smrg func_len " $test_cmds" && 10082994689c1Smrg len=$func_len_result && 10083994689c1Smrg test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 10084994689c1Smrg : 10085994689c1Smrg else 10086994689c1Smrg # The command line is too long to link in one step, link piecewise 10087994689c1Smrg # or, if using GNU ld and skipped_export is not :, use a linker 10088994689c1Smrg # script. 100897a84e134Smrg 10090994689c1Smrg # Save the value of $output and $libobjs because we want to 10091994689c1Smrg # use them later. If we have whole_archive_flag_spec, we 10092994689c1Smrg # want to use save_libobjs as it was before 10093994689c1Smrg # whole_archive_flag_spec was expanded, because we can't 10094994689c1Smrg # assume the linker understands whole_archive_flag_spec. 10095994689c1Smrg # This may have to be revisited, in case too many 10096994689c1Smrg # convenience libraries get linked in and end up exceeding 10097994689c1Smrg # the spec. 10098994689c1Smrg if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then 10099994689c1Smrg save_libobjs=$libobjs 10100994689c1Smrg fi 10101994689c1Smrg save_output=$output 10102994689c1Smrg func_basename "$output" 10103994689c1Smrg output_la=$func_basename_result 101047a84e134Smrg 10105994689c1Smrg # Clear the reloadable object creation command queue and 10106994689c1Smrg # initialize k to one. 10107994689c1Smrg test_cmds= 10108994689c1Smrg concat_cmds= 10109994689c1Smrg objlist= 10110994689c1Smrg last_robj= 10111994689c1Smrg k=1 101127a84e134Smrg 101135ec34c4cSmrg if test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then 101145ec34c4cSmrg output=$output_objdir/$output_la.lnkscript 10115994689c1Smrg func_verbose "creating GNU ld script: $output" 10116994689c1Smrg echo 'INPUT (' > $output 10117994689c1Smrg for obj in $save_libobjs 10118994689c1Smrg do 10119f353fbadSmrg func_to_tool_file "$obj" 10120f353fbadSmrg $ECHO "$func_to_tool_file_result" >> $output 10121994689c1Smrg done 10122994689c1Smrg echo ')' >> $output 10123f353fbadSmrg func_append delfiles " $output" 10124f353fbadSmrg func_to_tool_file "$output" 10125f353fbadSmrg output=$func_to_tool_file_result 101265ec34c4cSmrg elif test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then 101275ec34c4cSmrg output=$output_objdir/$output_la.lnk 10128994689c1Smrg func_verbose "creating linker input file list: $output" 10129994689c1Smrg : > $output 10130994689c1Smrg set x $save_libobjs 10131994689c1Smrg shift 10132994689c1Smrg firstobj= 101335ec34c4cSmrg if test yes = "$compiler_needs_object"; then 10134994689c1Smrg firstobj="$1 " 10135994689c1Smrg shift 10136994689c1Smrg fi 10137994689c1Smrg for obj 10138994689c1Smrg do 10139f353fbadSmrg func_to_tool_file "$obj" 10140f353fbadSmrg $ECHO "$func_to_tool_file_result" >> $output 10141994689c1Smrg done 10142f353fbadSmrg func_append delfiles " $output" 10143f353fbadSmrg func_to_tool_file "$output" 10144f353fbadSmrg output=$firstobj\"$file_list_spec$func_to_tool_file_result\" 10145994689c1Smrg else 10146994689c1Smrg if test -n "$save_libobjs"; then 10147994689c1Smrg func_verbose "creating reloadable object files..." 101485ec34c4cSmrg output=$output_objdir/$output_la-$k.$objext 10149994689c1Smrg eval test_cmds=\"$reload_cmds\" 10150994689c1Smrg func_len " $test_cmds" 10151994689c1Smrg len0=$func_len_result 10152994689c1Smrg len=$len0 10153994689c1Smrg 10154994689c1Smrg # Loop over the list of objects to be linked. 10155994689c1Smrg for obj in $save_libobjs 10156994689c1Smrg do 10157994689c1Smrg func_len " $obj" 10158994689c1Smrg func_arith $len + $func_len_result 10159994689c1Smrg len=$func_arith_result 101605ec34c4cSmrg if test -z "$objlist" || 10161994689c1Smrg test "$len" -lt "$max_cmd_len"; then 10162994689c1Smrg func_append objlist " $obj" 10163994689c1Smrg else 10164994689c1Smrg # The command $test_cmds is almost too long, add a 10165994689c1Smrg # command to the queue. 101665ec34c4cSmrg if test 1 -eq "$k"; then 10167994689c1Smrg # The first file doesn't have a previous command to add. 10168994689c1Smrg reload_objs=$objlist 10169994689c1Smrg eval concat_cmds=\"$reload_cmds\" 10170994689c1Smrg else 10171994689c1Smrg # All subsequent reloadable object files will link in 10172994689c1Smrg # the last one created. 10173994689c1Smrg reload_objs="$objlist $last_robj" 10174994689c1Smrg eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" 10175994689c1Smrg fi 101765ec34c4cSmrg last_robj=$output_objdir/$output_la-$k.$objext 10177994689c1Smrg func_arith $k + 1 10178994689c1Smrg k=$func_arith_result 101795ec34c4cSmrg output=$output_objdir/$output_la-$k.$objext 10180994689c1Smrg objlist=" $obj" 10181994689c1Smrg func_len " $last_robj" 10182994689c1Smrg func_arith $len0 + $func_len_result 10183994689c1Smrg len=$func_arith_result 10184994689c1Smrg fi 10185994689c1Smrg done 10186994689c1Smrg # Handle the remaining objects by creating one last 10187994689c1Smrg # reloadable object file. All subsequent reloadable object 10188994689c1Smrg # files will link in the last one created. 10189994689c1Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 10190994689c1Smrg reload_objs="$objlist $last_robj" 101915ec34c4cSmrg eval concat_cmds=\"\$concat_cmds$reload_cmds\" 10192994689c1Smrg if test -n "$last_robj"; then 101935ec34c4cSmrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 10194994689c1Smrg fi 10195f353fbadSmrg func_append delfiles " $output" 10196994689c1Smrg 10197994689c1Smrg else 10198994689c1Smrg output= 10199994689c1Smrg fi 102007a84e134Smrg 102015ec34c4cSmrg ${skipped_export-false} && { 102025ec34c4cSmrg func_verbose "generating symbol list for '$libname.la'" 102035ec34c4cSmrg export_symbols=$output_objdir/$libname.exp 10204994689c1Smrg $opt_dry_run || $RM $export_symbols 10205994689c1Smrg libobjs=$output 10206994689c1Smrg # Append the command to create the export file. 10207994689c1Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 10208994689c1Smrg eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" 10209994689c1Smrg if test -n "$last_robj"; then 10210994689c1Smrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 10211994689c1Smrg fi 102125ec34c4cSmrg } 102137a84e134Smrg 10214994689c1Smrg test -n "$save_libobjs" && 10215994689c1Smrg func_verbose "creating a temporary reloadable object file: $output" 102167a84e134Smrg 10217994689c1Smrg # Loop through the commands generated above and execute them. 102185ec34c4cSmrg save_ifs=$IFS; IFS='~' 10219994689c1Smrg for cmd in $concat_cmds; do 102205ec34c4cSmrg IFS=$save_ifs 102215ec34c4cSmrg $opt_quiet || { 102225b16253fSmrg func_quote_arg expand,pretty "$cmd" 102235b16253fSmrg eval "func_echo $func_quote_arg_result" 10224994689c1Smrg } 10225994689c1Smrg $opt_dry_run || eval "$cmd" || { 10226994689c1Smrg lt_exit=$? 10227994689c1Smrg 10228994689c1Smrg # Restore the uninstalled library and exit 102295ec34c4cSmrg if test relink = "$opt_mode"; then 10230994689c1Smrg ( cd "$output_objdir" && \ 10231994689c1Smrg $RM "${realname}T" && \ 10232994689c1Smrg $MV "${realname}U" "$realname" ) 10233994689c1Smrg fi 102347a84e134Smrg 10235994689c1Smrg exit $lt_exit 10236994689c1Smrg } 10237994689c1Smrg done 102385ec34c4cSmrg IFS=$save_ifs 102397a84e134Smrg 10240994689c1Smrg if test -n "$export_symbols_regex" && ${skipped_export-false}; then 10241994689c1Smrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 10242994689c1Smrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 10243775e7de9Smrg fi 10244775e7de9Smrg fi 102457a84e134Smrg 102465ec34c4cSmrg ${skipped_export-false} && { 10247994689c1Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 102485ec34c4cSmrg tmp_export_symbols=$export_symbols 102495ec34c4cSmrg test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols 10250994689c1Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 10251994689c1Smrg fi 102527a84e134Smrg 10253994689c1Smrg if test -n "$orig_export_symbols"; then 10254994689c1Smrg # The given exports_symbols file has to be filtered, so filter it. 102555ec34c4cSmrg func_verbose "filter symbol list for '$libname.la' to tag DATA exports" 10256994689c1Smrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 102575ec34c4cSmrg # 's' commands, which not all seds can handle. GNU sed should be fine 10258994689c1Smrg # though. Also, the filter scales superlinearly with the number of 10259994689c1Smrg # global variables. join(1) would be nice here, but unfortunately 10260994689c1Smrg # isn't a blessed tool. 10261994689c1Smrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 10262f353fbadSmrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 10263994689c1Smrg export_symbols=$output_objdir/$libname.def 10264994689c1Smrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 10265994689c1Smrg fi 102665ec34c4cSmrg } 102677a84e134Smrg 10268994689c1Smrg libobjs=$output 10269994689c1Smrg # Restore the value of output. 10270994689c1Smrg output=$save_output 10271e1e1713cSmrg 10272994689c1Smrg if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then 10273994689c1Smrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 10274994689c1Smrg test "X$libobjs" = "X " && libobjs= 10275994689c1Smrg fi 10276994689c1Smrg # Expand the library linking commands again to reset the 10277994689c1Smrg # value of $libobjs for piecewise linking. 10278994689c1Smrg 10279994689c1Smrg # Do each of the archive commands. 102805ec34c4cSmrg if test yes = "$module" && test -n "$module_cmds"; then 10281994689c1Smrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 10282994689c1Smrg cmds=$module_expsym_cmds 10283775e7de9Smrg else 10284994689c1Smrg cmds=$module_cmds 102857a84e134Smrg fi 102867a84e134Smrg else 10287994689c1Smrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 10288994689c1Smrg cmds=$archive_expsym_cmds 10289994689c1Smrg else 10290994689c1Smrg cmds=$archive_cmds 10291994689c1Smrg fi 102927a84e134Smrg fi 10293775e7de9Smrg fi 102947a84e134Smrg 10295994689c1Smrg if test -n "$delfiles"; then 10296994689c1Smrg # Append the command to remove temporary files to $cmds. 10297994689c1Smrg eval cmds=\"\$cmds~\$RM $delfiles\" 10298994689c1Smrg fi 10299775e7de9Smrg 10300994689c1Smrg # Add any objects from preloaded convenience libraries 10301994689c1Smrg if test -n "$dlprefiles"; then 103025ec34c4cSmrg gentop=$output_objdir/${outputname}x 10303f353fbadSmrg func_append generated " $gentop" 103047a84e134Smrg 10305994689c1Smrg func_extract_archives $gentop $dlprefiles 10306f353fbadSmrg func_append libobjs " $func_extract_archives_result" 10307994689c1Smrg test "X$libobjs" = "X " && libobjs= 10308775e7de9Smrg fi 103097a84e134Smrg 103105ec34c4cSmrg save_ifs=$IFS; IFS='~' 10311994689c1Smrg for cmd in $cmds; do 103125ec34c4cSmrg IFS=$sp$nl 10313994689c1Smrg eval cmd=\"$cmd\" 103145ec34c4cSmrg IFS=$save_ifs 103155ec34c4cSmrg $opt_quiet || { 103165b16253fSmrg func_quote_arg expand,pretty "$cmd" 103175b16253fSmrg eval "func_echo $func_quote_arg_result" 10318994689c1Smrg } 10319994689c1Smrg $opt_dry_run || eval "$cmd" || { 10320994689c1Smrg lt_exit=$? 103217a84e134Smrg 10322994689c1Smrg # Restore the uninstalled library and exit 103235ec34c4cSmrg if test relink = "$opt_mode"; then 10324994689c1Smrg ( cd "$output_objdir" && \ 10325994689c1Smrg $RM "${realname}T" && \ 10326994689c1Smrg $MV "${realname}U" "$realname" ) 10327e1e1713cSmrg fi 103287a84e134Smrg 10329994689c1Smrg exit $lt_exit 10330994689c1Smrg } 10331994689c1Smrg done 103325ec34c4cSmrg IFS=$save_ifs 103337a84e134Smrg 10334994689c1Smrg # Restore the uninstalled library and exit 103355ec34c4cSmrg if test relink = "$opt_mode"; then 10336994689c1Smrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? 103377a84e134Smrg 10338994689c1Smrg if test -n "$convenience"; then 10339994689c1Smrg if test -z "$whole_archive_flag_spec"; then 10340994689c1Smrg func_show_eval '${RM}r "$gentop"' 10341994689c1Smrg fi 10342994689c1Smrg fi 103437a84e134Smrg 10344994689c1Smrg exit $EXIT_SUCCESS 10345994689c1Smrg fi 10346775e7de9Smrg 10347994689c1Smrg # Create links to the real library. 10348994689c1Smrg for linkname in $linknames; do 10349994689c1Smrg if test "$realname" != "$linkname"; then 10350994689c1Smrg func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' 10351994689c1Smrg fi 10352994689c1Smrg done 10353775e7de9Smrg 10354994689c1Smrg # If -module or -export-dynamic was specified, set the dlname. 103555ec34c4cSmrg if test yes = "$module" || test yes = "$export_dynamic"; then 10356994689c1Smrg # On all known operating systems, these are identical. 103575ec34c4cSmrg dlname=$soname 10358994689c1Smrg fi 10359994689c1Smrg fi 10360994689c1Smrg ;; 10361775e7de9Smrg 10362994689c1Smrg obj) 103635ec34c4cSmrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 103645ec34c4cSmrg func_warning "'-dlopen' is ignored for objects" 10365994689c1Smrg fi 10366775e7de9Smrg 10367994689c1Smrg case " $deplibs" in 10368994689c1Smrg *\ -l* | *\ -L*) 103695ec34c4cSmrg func_warning "'-l' and '-L' are ignored for objects" ;; 10370994689c1Smrg esac 10371775e7de9Smrg 10372994689c1Smrg test -n "$rpath" && \ 103735ec34c4cSmrg func_warning "'-rpath' is ignored for objects" 10374775e7de9Smrg 10375994689c1Smrg test -n "$xrpath" && \ 103765ec34c4cSmrg func_warning "'-R' is ignored for objects" 10377994689c1Smrg 10378994689c1Smrg test -n "$vinfo" && \ 103795ec34c4cSmrg func_warning "'-version-info' is ignored for objects" 103807a84e134Smrg 10381994689c1Smrg test -n "$release" && \ 103825ec34c4cSmrg func_warning "'-release' is ignored for objects" 10383e1e1713cSmrg 10384994689c1Smrg case $output in 10385994689c1Smrg *.lo) 10386994689c1Smrg test -n "$objs$old_deplibs" && \ 103875ec34c4cSmrg func_fatal_error "cannot build library object '$output' from non-libtool objects" 10388994689c1Smrg 10389994689c1Smrg libobj=$output 10390994689c1Smrg func_lo2o "$libobj" 10391994689c1Smrg obj=$func_lo2o_result 10392994689c1Smrg ;; 10393994689c1Smrg *) 10394994689c1Smrg libobj= 103955ec34c4cSmrg obj=$output 10396e1e1713cSmrg ;; 10397775e7de9Smrg esac 103987a84e134Smrg 10399994689c1Smrg # Delete the old objects. 10400994689c1Smrg $opt_dry_run || $RM $obj $libobj 104017a84e134Smrg 10402994689c1Smrg # Objects from convenience libraries. This assumes 10403994689c1Smrg # single-version convenience libraries. Whenever we create 10404994689c1Smrg # different ones for PIC/non-PIC, this we'll have to duplicate 10405994689c1Smrg # the extraction. 10406994689c1Smrg reload_conv_objs= 10407994689c1Smrg gentop= 104085ec34c4cSmrg # if reload_cmds runs $LD directly, get rid of -Wl from 104095ec34c4cSmrg # whole_archive_flag_spec and hope we can get by with turning comma 104105ec34c4cSmrg # into space. 104115ec34c4cSmrg case $reload_cmds in 104125ec34c4cSmrg *\$LD[\ \$]*) wl= ;; 104135ec34c4cSmrg esac 10414994689c1Smrg if test -n "$convenience"; then 10415994689c1Smrg if test -n "$whole_archive_flag_spec"; then 10416994689c1Smrg eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" 104175ec34c4cSmrg test -n "$wl" || tmp_whole_archive_flags=`$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` 104185ec34c4cSmrg reload_conv_objs=$reload_objs\ $tmp_whole_archive_flags 10419e1e1713cSmrg else 104205ec34c4cSmrg gentop=$output_objdir/${obj}x 10421f353fbadSmrg func_append generated " $gentop" 10422994689c1Smrg 10423994689c1Smrg func_extract_archives $gentop $convenience 10424994689c1Smrg reload_conv_objs="$reload_objs $func_extract_archives_result" 10425e1e1713cSmrg fi 10426994689c1Smrg fi 104277a84e134Smrg 10428f353fbadSmrg # If we're not building shared, we need to use non_pic_objs 104295ec34c4cSmrg test yes = "$build_libtool_libs" || libobjs=$non_pic_objects 10430f353fbadSmrg 10431994689c1Smrg # Create the old-style object. 104325ec34c4cSmrg reload_objs=$objs$old_deplibs' '`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; /\.lib$/d; $lo2o" | $NL2SP`' '$reload_conv_objs 104337a84e134Smrg 104345ec34c4cSmrg output=$obj 10435994689c1Smrg func_execute_cmds "$reload_cmds" 'exit $?' 104367a84e134Smrg 10437994689c1Smrg # Exit if we aren't doing a library object file. 10438994689c1Smrg if test -z "$libobj"; then 10439994689c1Smrg if test -n "$gentop"; then 10440994689c1Smrg func_show_eval '${RM}r "$gentop"' 10441994689c1Smrg fi 10442e1e1713cSmrg 10443994689c1Smrg exit $EXIT_SUCCESS 10444e1e1713cSmrg fi 10445e1e1713cSmrg 104465ec34c4cSmrg test yes = "$build_libtool_libs" || { 10447994689c1Smrg if test -n "$gentop"; then 10448994689c1Smrg func_show_eval '${RM}r "$gentop"' 10449994689c1Smrg fi 10450e1e1713cSmrg 10451994689c1Smrg # Create an invalid libtool object if no PIC, so that we don't 10452994689c1Smrg # accidentally link it into a program. 10453994689c1Smrg # $show "echo timestamp > $libobj" 10454994689c1Smrg # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? 10455994689c1Smrg exit $EXIT_SUCCESS 104565ec34c4cSmrg } 10457e1e1713cSmrg 104585ec34c4cSmrg if test -n "$pic_flag" || test default != "$pic_mode"; then 10459994689c1Smrg # Only do commands if we really have different PIC objects. 10460994689c1Smrg reload_objs="$libobjs $reload_conv_objs" 104615ec34c4cSmrg output=$libobj 10462994689c1Smrg func_execute_cmds "$reload_cmds" 'exit $?' 10463e1e1713cSmrg fi 10464994689c1Smrg 10465994689c1Smrg if test -n "$gentop"; then 10466994689c1Smrg func_show_eval '${RM}r "$gentop"' 10467994689c1Smrg fi 10468994689c1Smrg 10469994689c1Smrg exit $EXIT_SUCCESS 10470e1e1713cSmrg ;; 104717a84e134Smrg 10472994689c1Smrg prog) 10473994689c1Smrg case $host in 10474994689c1Smrg *cygwin*) func_stripname '' '.exe' "$output" 10475994689c1Smrg output=$func_stripname_result.exe;; 10476994689c1Smrg esac 10477994689c1Smrg test -n "$vinfo" && \ 104785ec34c4cSmrg func_warning "'-version-info' is ignored for programs" 104797a84e134Smrg 10480994689c1Smrg test -n "$release" && \ 104815ec34c4cSmrg func_warning "'-release' is ignored for programs" 104827a84e134Smrg 104835ec34c4cSmrg $preload \ 104845ec34c4cSmrg && test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \ 104855ec34c4cSmrg && func_warning "'LT_INIT([dlopen])' not used. Assuming no dlopen support." 10486994689c1Smrg 10487994689c1Smrg case $host in 10488994689c1Smrg *-*-rhapsody* | *-*-darwin1.[012]) 10489994689c1Smrg # On Rhapsody replace the C library is the System framework 10490994689c1Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` 10491994689c1Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` 10492e1e1713cSmrg ;; 10493994689c1Smrg esac 10494e1e1713cSmrg 10495994689c1Smrg case $host in 10496994689c1Smrg *-*-darwin*) 10497994689c1Smrg # Don't allow lazy linking, it breaks C++ global constructors 10498994689c1Smrg # But is supposedly fixed on 10.4 or later (yay!). 104995ec34c4cSmrg if test CXX = "$tagname"; then 10500994689c1Smrg case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 10501994689c1Smrg 10.[0123]) 105025ec34c4cSmrg func_append compile_command " $wl-bind_at_load" 105035ec34c4cSmrg func_append finalize_command " $wl-bind_at_load" 10504994689c1Smrg ;; 10505994689c1Smrg esac 10506e1e1713cSmrg fi 10507994689c1Smrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 10508994689c1Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 10509994689c1Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 10510994689c1Smrg ;; 10511994689c1Smrg esac 10512e1e1713cSmrg 10513e1e1713cSmrg 10514994689c1Smrg # move library search paths that coincide with paths to not yet 10515994689c1Smrg # installed libraries to the beginning of the library search list 10516994689c1Smrg new_libs= 10517994689c1Smrg for path in $notinst_path; do 10518994689c1Smrg case " $new_libs " in 10519994689c1Smrg *" -L$path/$objdir "*) ;; 10520994689c1Smrg *) 10521994689c1Smrg case " $compile_deplibs " in 10522994689c1Smrg *" -L$path/$objdir "*) 10523f353fbadSmrg func_append new_libs " -L$path/$objdir" ;; 10524775e7de9Smrg esac 10525994689c1Smrg ;; 10526994689c1Smrg esac 10527994689c1Smrg done 10528994689c1Smrg for deplib in $compile_deplibs; do 10529994689c1Smrg case $deplib in 10530994689c1Smrg -L*) 10531994689c1Smrg case " $new_libs " in 10532994689c1Smrg *" $deplib "*) ;; 10533f353fbadSmrg *) func_append new_libs " $deplib" ;; 10534775e7de9Smrg esac 10535994689c1Smrg ;; 10536f353fbadSmrg *) func_append new_libs " $deplib" ;; 10537994689c1Smrg esac 10538994689c1Smrg done 105395ec34c4cSmrg compile_deplibs=$new_libs 105407a84e134Smrg 10541e1e1713cSmrg 10542f353fbadSmrg func_append compile_command " $compile_deplibs" 10543f353fbadSmrg func_append finalize_command " $finalize_deplibs" 10544e1e1713cSmrg 10545994689c1Smrg if test -n "$rpath$xrpath"; then 10546994689c1Smrg # If the user specified any rpath flags, then add them. 10547994689c1Smrg for libdir in $rpath $xrpath; do 10548994689c1Smrg # This is the magic to use -rpath. 10549994689c1Smrg case "$finalize_rpath " in 10550994689c1Smrg *" $libdir "*) ;; 10551f353fbadSmrg *) func_append finalize_rpath " $libdir" ;; 10552994689c1Smrg esac 10553994689c1Smrg done 10554994689c1Smrg fi 10555e1e1713cSmrg 10556994689c1Smrg # Now hardcode the library paths 10557994689c1Smrg rpath= 10558994689c1Smrg hardcode_libdirs= 10559994689c1Smrg for libdir in $compile_rpath $finalize_rpath; do 10560994689c1Smrg if test -n "$hardcode_libdir_flag_spec"; then 10561994689c1Smrg if test -n "$hardcode_libdir_separator"; then 10562994689c1Smrg if test -z "$hardcode_libdirs"; then 105635ec34c4cSmrg hardcode_libdirs=$libdir 10564994689c1Smrg else 10565994689c1Smrg # Just accumulate the unique libdirs. 10566994689c1Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 10567994689c1Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 10568994689c1Smrg ;; 10569994689c1Smrg *) 10570f353fbadSmrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 10571994689c1Smrg ;; 10572994689c1Smrg esac 10573994689c1Smrg fi 10574e1e1713cSmrg else 10575994689c1Smrg eval flag=\"$hardcode_libdir_flag_spec\" 10576f353fbadSmrg func_append rpath " $flag" 10577e1e1713cSmrg fi 10578994689c1Smrg elif test -n "$runpath_var"; then 10579994689c1Smrg case "$perm_rpath " in 10580994689c1Smrg *" $libdir "*) ;; 10581f353fbadSmrg *) func_append perm_rpath " $libdir" ;; 10582994689c1Smrg esac 10583994689c1Smrg fi 10584994689c1Smrg case $host in 10585994689c1Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 105865ec34c4cSmrg testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'` 10587994689c1Smrg case :$dllsearchpath: in 10588994689c1Smrg *":$libdir:"*) ;; 10589994689c1Smrg ::) dllsearchpath=$libdir;; 10590f353fbadSmrg *) func_append dllsearchpath ":$libdir";; 10591994689c1Smrg esac 10592994689c1Smrg case :$dllsearchpath: in 10593994689c1Smrg *":$testbindir:"*) ;; 10594994689c1Smrg ::) dllsearchpath=$testbindir;; 10595f353fbadSmrg *) func_append dllsearchpath ":$testbindir";; 10596994689c1Smrg esac 10597994689c1Smrg ;; 10598994689c1Smrg esac 10599994689c1Smrg done 10600994689c1Smrg # Substitute the hardcoded libdirs into the rpath. 10601994689c1Smrg if test -n "$hardcode_libdir_separator" && 10602994689c1Smrg test -n "$hardcode_libdirs"; then 106035ec34c4cSmrg libdir=$hardcode_libdirs 10604994689c1Smrg eval rpath=\" $hardcode_libdir_flag_spec\" 10605994689c1Smrg fi 106065ec34c4cSmrg compile_rpath=$rpath 10607e1e1713cSmrg 10608994689c1Smrg rpath= 10609994689c1Smrg hardcode_libdirs= 10610994689c1Smrg for libdir in $finalize_rpath; do 10611994689c1Smrg if test -n "$hardcode_libdir_flag_spec"; then 10612994689c1Smrg if test -n "$hardcode_libdir_separator"; then 10613994689c1Smrg if test -z "$hardcode_libdirs"; then 106145ec34c4cSmrg hardcode_libdirs=$libdir 10615994689c1Smrg else 10616994689c1Smrg # Just accumulate the unique libdirs. 10617994689c1Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 10618994689c1Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 10619994689c1Smrg ;; 10620994689c1Smrg *) 10621f353fbadSmrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 10622994689c1Smrg ;; 10623994689c1Smrg esac 10624994689c1Smrg fi 106257a84e134Smrg else 10626994689c1Smrg eval flag=\"$hardcode_libdir_flag_spec\" 10627f353fbadSmrg func_append rpath " $flag" 106287a84e134Smrg fi 10629994689c1Smrg elif test -n "$runpath_var"; then 10630994689c1Smrg case "$finalize_perm_rpath " in 10631994689c1Smrg *" $libdir "*) ;; 10632f353fbadSmrg *) func_append finalize_perm_rpath " $libdir" ;; 10633994689c1Smrg esac 106347a84e134Smrg fi 10635994689c1Smrg done 10636994689c1Smrg # Substitute the hardcoded libdirs into the rpath. 10637994689c1Smrg if test -n "$hardcode_libdir_separator" && 10638994689c1Smrg test -n "$hardcode_libdirs"; then 106395ec34c4cSmrg libdir=$hardcode_libdirs 10640994689c1Smrg eval rpath=\" $hardcode_libdir_flag_spec\" 10641994689c1Smrg fi 106425ec34c4cSmrg finalize_rpath=$rpath 106437a84e134Smrg 106445ec34c4cSmrg if test -n "$libobjs" && test yes = "$build_old_libs"; then 10645994689c1Smrg # Transform all the library objects into standard objects. 10646994689c1Smrg compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 10647994689c1Smrg finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 10648994689c1Smrg fi 106497a84e134Smrg 106505ec34c4cSmrg func_generate_dlsyms "$outputname" "@PROGRAM@" false 106517a84e134Smrg 10652994689c1Smrg # template prelinking step 10653994689c1Smrg if test -n "$prelink_cmds"; then 10654994689c1Smrg func_execute_cmds "$prelink_cmds" 'exit $?' 10655994689c1Smrg fi 106567a84e134Smrg 106575ec34c4cSmrg wrappers_required=: 10658994689c1Smrg case $host in 10659994689c1Smrg *cegcc* | *mingw32ce*) 10660994689c1Smrg # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. 106615ec34c4cSmrg wrappers_required=false 10662994689c1Smrg ;; 10663994689c1Smrg *cygwin* | *mingw* ) 106645ec34c4cSmrg test yes = "$build_libtool_libs" || wrappers_required=false 10665994689c1Smrg ;; 10666994689c1Smrg *) 106675ec34c4cSmrg if test no = "$need_relink" || test yes != "$build_libtool_libs"; then 106685ec34c4cSmrg wrappers_required=false 10669994689c1Smrg fi 10670994689c1Smrg ;; 10671994689c1Smrg esac 106725ec34c4cSmrg $wrappers_required || { 10673994689c1Smrg # Replace the output file specification. 10674994689c1Smrg compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 106755ec34c4cSmrg link_command=$compile_command$compile_rpath 106767a84e134Smrg 10677994689c1Smrg # We have no uninstalled library dependencies, so finalize right now. 10678994689c1Smrg exit_status=0 10679994689c1Smrg func_show_eval "$link_command" 'exit_status=$?' 106807a84e134Smrg 10681f353fbadSmrg if test -n "$postlink_cmds"; then 10682f353fbadSmrg func_to_tool_file "$output" 10683f353fbadSmrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 10684f353fbadSmrg func_execute_cmds "$postlink_cmds" 'exit $?' 10685f353fbadSmrg fi 10686f353fbadSmrg 10687994689c1Smrg # Delete the generated files. 106885ec34c4cSmrg if test -f "$output_objdir/${outputname}S.$objext"; then 106895ec34c4cSmrg func_show_eval '$RM "$output_objdir/${outputname}S.$objext"' 106907a84e134Smrg fi 106917a84e134Smrg 10692994689c1Smrg exit $exit_status 106935ec34c4cSmrg } 106947a84e134Smrg 10695994689c1Smrg if test -n "$compile_shlibpath$finalize_shlibpath"; then 10696994689c1Smrg compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" 10697994689c1Smrg fi 10698994689c1Smrg if test -n "$finalize_shlibpath"; then 10699994689c1Smrg finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" 10700994689c1Smrg fi 10701e1e1713cSmrg 10702994689c1Smrg compile_var= 10703994689c1Smrg finalize_var= 10704994689c1Smrg if test -n "$runpath_var"; then 10705994689c1Smrg if test -n "$perm_rpath"; then 10706994689c1Smrg # We should set the runpath_var. 10707994689c1Smrg rpath= 10708994689c1Smrg for dir in $perm_rpath; do 10709f353fbadSmrg func_append rpath "$dir:" 10710994689c1Smrg done 10711994689c1Smrg compile_var="$runpath_var=\"$rpath\$$runpath_var\" " 107127a84e134Smrg fi 10713994689c1Smrg if test -n "$finalize_perm_rpath"; then 10714994689c1Smrg # We should set the runpath_var. 10715994689c1Smrg rpath= 10716994689c1Smrg for dir in $finalize_perm_rpath; do 10717f353fbadSmrg func_append rpath "$dir:" 10718994689c1Smrg done 10719994689c1Smrg finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " 107207a84e134Smrg fi 10721994689c1Smrg fi 107227a84e134Smrg 107235ec34c4cSmrg if test yes = "$no_install"; then 10724994689c1Smrg # We don't need to create a wrapper script. 107255ec34c4cSmrg link_command=$compile_var$compile_command$compile_rpath 10726994689c1Smrg # Replace the output file specification. 10727994689c1Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 10728994689c1Smrg # Delete the old output file. 10729994689c1Smrg $opt_dry_run || $RM $output 10730994689c1Smrg # Link the executable and exit 10731994689c1Smrg func_show_eval "$link_command" 'exit $?' 10732f353fbadSmrg 10733f353fbadSmrg if test -n "$postlink_cmds"; then 10734f353fbadSmrg func_to_tool_file "$output" 10735f353fbadSmrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 10736f353fbadSmrg func_execute_cmds "$postlink_cmds" 'exit $?' 10737f353fbadSmrg fi 10738f353fbadSmrg 10739e1e1713cSmrg exit $EXIT_SUCCESS 10740994689c1Smrg fi 10741775e7de9Smrg 107425ec34c4cSmrg case $hardcode_action,$fast_install in 107435ec34c4cSmrg relink,*) 107445ec34c4cSmrg # Fast installation is not supported 107455ec34c4cSmrg link_command=$compile_var$compile_command$compile_rpath 107465ec34c4cSmrg relink_command=$finalize_var$finalize_command$finalize_rpath 10747994689c1Smrg 107485ec34c4cSmrg func_warning "this platform does not like uninstalled shared libraries" 107495ec34c4cSmrg func_warning "'$output' will be relinked during installation" 107505ec34c4cSmrg ;; 107515ec34c4cSmrg *,yes) 107525ec34c4cSmrg link_command=$finalize_var$compile_command$finalize_rpath 107535ec34c4cSmrg relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` 107545ec34c4cSmrg ;; 107555ec34c4cSmrg *,no) 107565ec34c4cSmrg link_command=$compile_var$compile_command$compile_rpath 107575ec34c4cSmrg relink_command=$finalize_var$finalize_command$finalize_rpath 107585ec34c4cSmrg ;; 107595ec34c4cSmrg *,needless) 107605ec34c4cSmrg link_command=$finalize_var$compile_command$finalize_rpath 107615ec34c4cSmrg relink_command= 107625ec34c4cSmrg ;; 107635ec34c4cSmrg esac 107647a84e134Smrg 10765994689c1Smrg # Replace the output file specification. 10766994689c1Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` 107677a84e134Smrg 10768994689c1Smrg # Delete the old output files. 10769994689c1Smrg $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname 107707a84e134Smrg 10771994689c1Smrg func_show_eval "$link_command" 'exit $?' 10772e1e1713cSmrg 10773f353fbadSmrg if test -n "$postlink_cmds"; then 10774f353fbadSmrg func_to_tool_file "$output_objdir/$outputname" 10775f353fbadSmrg 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'` 10776f353fbadSmrg func_execute_cmds "$postlink_cmds" 'exit $?' 10777f353fbadSmrg fi 10778f353fbadSmrg 10779994689c1Smrg # Now create the wrapper script. 10780994689c1Smrg func_verbose "creating $output" 10781e1e1713cSmrg 10782994689c1Smrg # Quote the relink command for shipping. 10783994689c1Smrg if test -n "$relink_command"; then 10784994689c1Smrg # Preserve any variables that may affect compiler behavior 10785994689c1Smrg for var in $variables_saved_for_relink; do 10786994689c1Smrg if eval test -z \"\${$var+set}\"; then 10787994689c1Smrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 10788994689c1Smrg elif eval var_value=\$$var; test -z "$var_value"; then 10789994689c1Smrg relink_command="$var=; export $var; $relink_command" 107907a84e134Smrg else 107915b16253fSmrg func_quote_arg pretty "$var_value" 107925b16253fSmrg relink_command="$var=$func_quote_arg_result; export $var; $relink_command" 107937a84e134Smrg fi 10794994689c1Smrg done 107955b16253fSmrg func_quote eval cd "`pwd`" 107965b16253fSmrg func_quote_arg pretty,unquoted "($func_quote_result; $relink_command)" 107975b16253fSmrg relink_command=$func_quote_arg_unquoted_result 10798994689c1Smrg fi 10799775e7de9Smrg 10800994689c1Smrg # Only actually do things if not in dry run mode. 10801994689c1Smrg $opt_dry_run || { 10802994689c1Smrg # win32 will think the script is a binary if it has 10803994689c1Smrg # a .exe suffix, so we strip it off here. 10804994689c1Smrg case $output in 10805994689c1Smrg *.exe) func_stripname '' '.exe' "$output" 10806994689c1Smrg output=$func_stripname_result ;; 10807994689c1Smrg esac 10808994689c1Smrg # test for cygwin because mv fails w/o .exe extensions 10809994689c1Smrg case $host in 10810994689c1Smrg *cygwin*) 10811994689c1Smrg exeext=.exe 10812994689c1Smrg func_stripname '' '.exe' "$outputname" 10813994689c1Smrg outputname=$func_stripname_result ;; 10814994689c1Smrg *) exeext= ;; 108157a84e134Smrg esac 10816994689c1Smrg case $host in 10817994689c1Smrg *cygwin* | *mingw* ) 10818994689c1Smrg func_dirname_and_basename "$output" "" "." 10819994689c1Smrg output_name=$func_basename_result 10820994689c1Smrg output_path=$func_dirname_result 108215ec34c4cSmrg cwrappersource=$output_path/$objdir/lt-$output_name.c 108225ec34c4cSmrg cwrapper=$output_path/$output_name.exe 10823994689c1Smrg $RM $cwrappersource $cwrapper 10824994689c1Smrg trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 10825994689c1Smrg 10826994689c1Smrg func_emit_cwrapperexe_src > $cwrappersource 10827994689c1Smrg 10828994689c1Smrg # The wrapper executable is built using the $host compiler, 10829994689c1Smrg # because it contains $host paths and files. If cross- 10830994689c1Smrg # compiling, it, like the target executable, must be 10831994689c1Smrg # executed on the $host or under an emulation environment. 10832994689c1Smrg $opt_dry_run || { 10833994689c1Smrg $LTCC $LTCFLAGS -o $cwrapper $cwrappersource 10834994689c1Smrg $STRIP $cwrapper 10835994689c1Smrg } 108367a84e134Smrg 10837994689c1Smrg # Now, create the wrapper script for func_source use: 10838994689c1Smrg func_ltwrapper_scriptname $cwrapper 10839994689c1Smrg $RM $func_ltwrapper_scriptname_result 10840994689c1Smrg trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 10841994689c1Smrg $opt_dry_run || { 10842994689c1Smrg # note: this script will not be executed, so do not chmod. 108435ec34c4cSmrg if test "x$build" = "x$host"; then 10844994689c1Smrg $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result 10845994689c1Smrg else 10846994689c1Smrg func_emit_wrapper no > $func_ltwrapper_scriptname_result 10847994689c1Smrg fi 10848994689c1Smrg } 10849994689c1Smrg ;; 10850994689c1Smrg * ) 10851994689c1Smrg $RM $output 10852994689c1Smrg trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 108537a84e134Smrg 10854994689c1Smrg func_emit_wrapper no > $output 10855994689c1Smrg chmod +x $output 10856994689c1Smrg ;; 10857994689c1Smrg esac 10858994689c1Smrg } 10859994689c1Smrg exit $EXIT_SUCCESS 10860994689c1Smrg ;; 10861994689c1Smrg esac 108627a84e134Smrg 10863994689c1Smrg # See if we need to build an old-fashioned archive. 10864994689c1Smrg for oldlib in $oldlibs; do 108657a84e134Smrg 108665ec34c4cSmrg case $build_libtool_libs in 108675ec34c4cSmrg convenience) 108685ec34c4cSmrg oldobjs="$libobjs_save $symfileobj" 108695ec34c4cSmrg addlibs=$convenience 10870994689c1Smrg build_libtool_libs=no 108715ec34c4cSmrg ;; 108725ec34c4cSmrg module) 108735ec34c4cSmrg oldobjs=$libobjs_save 108745ec34c4cSmrg addlibs=$old_convenience 108755ec34c4cSmrg build_libtool_libs=no 108765ec34c4cSmrg ;; 108775ec34c4cSmrg *) 10878994689c1Smrg oldobjs="$old_deplibs $non_pic_objects" 108795ec34c4cSmrg $preload && test -f "$symfileobj" \ 108805ec34c4cSmrg && func_append oldobjs " $symfileobj" 108815ec34c4cSmrg addlibs=$old_convenience 108825ec34c4cSmrg ;; 108835ec34c4cSmrg esac 108847a84e134Smrg 10885994689c1Smrg if test -n "$addlibs"; then 108865ec34c4cSmrg gentop=$output_objdir/${outputname}x 10887f353fbadSmrg func_append generated " $gentop" 108887a84e134Smrg 10889994689c1Smrg func_extract_archives $gentop $addlibs 10890f353fbadSmrg func_append oldobjs " $func_extract_archives_result" 10891994689c1Smrg fi 108927a84e134Smrg 10893994689c1Smrg # Do each command in the archive commands. 108945ec34c4cSmrg if test -n "$old_archive_from_new_cmds" && test yes = "$build_libtool_libs"; then 10895994689c1Smrg cmds=$old_archive_from_new_cmds 10896994689c1Smrg else 108977a84e134Smrg 10898994689c1Smrg # Add any objects from preloaded convenience libraries 10899994689c1Smrg if test -n "$dlprefiles"; then 109005ec34c4cSmrg gentop=$output_objdir/${outputname}x 10901f353fbadSmrg func_append generated " $gentop" 109027a84e134Smrg 10903994689c1Smrg func_extract_archives $gentop $dlprefiles 10904f353fbadSmrg func_append oldobjs " $func_extract_archives_result" 10905994689c1Smrg fi 109067a84e134Smrg 10907994689c1Smrg # POSIX demands no paths to be encoded in archives. We have 10908994689c1Smrg # to avoid creating archives with duplicate basenames if we 10909994689c1Smrg # might have to extract them afterwards, e.g., when creating a 10910994689c1Smrg # static archive out of a convenience library, or when linking 10911994689c1Smrg # the entirety of a libtool archive into another (currently 10912994689c1Smrg # not supported by libtool). 10913994689c1Smrg if (for obj in $oldobjs 10914994689c1Smrg do 10915994689c1Smrg func_basename "$obj" 10916994689c1Smrg $ECHO "$func_basename_result" 10917994689c1Smrg done | sort | sort -uc >/dev/null 2>&1); then 10918994689c1Smrg : 10919994689c1Smrg else 10920994689c1Smrg echo "copying selected object files to avoid basename conflicts..." 109215ec34c4cSmrg gentop=$output_objdir/${outputname}x 10922f353fbadSmrg func_append generated " $gentop" 10923994689c1Smrg func_mkdir_p "$gentop" 10924994689c1Smrg save_oldobjs=$oldobjs 10925994689c1Smrg oldobjs= 10926994689c1Smrg counter=1 10927994689c1Smrg for obj in $save_oldobjs 10928994689c1Smrg do 10929994689c1Smrg func_basename "$obj" 109305ec34c4cSmrg objbase=$func_basename_result 10931994689c1Smrg case " $oldobjs " in 10932994689c1Smrg " ") oldobjs=$obj ;; 10933994689c1Smrg *[\ /]"$objbase "*) 10934994689c1Smrg while :; do 10935994689c1Smrg # Make sure we don't pick an alternate name that also 10936994689c1Smrg # overlaps. 10937994689c1Smrg newobj=lt$counter-$objbase 10938994689c1Smrg func_arith $counter + 1 10939994689c1Smrg counter=$func_arith_result 10940994689c1Smrg case " $oldobjs " in 10941994689c1Smrg *[\ /]"$newobj "*) ;; 10942994689c1Smrg *) if test ! -f "$gentop/$newobj"; then break; fi ;; 10943994689c1Smrg esac 10944994689c1Smrg done 10945994689c1Smrg func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" 10946f353fbadSmrg func_append oldobjs " $gentop/$newobj" 10947994689c1Smrg ;; 10948f353fbadSmrg *) func_append oldobjs " $obj" ;; 10949994689c1Smrg esac 109507a84e134Smrg done 10951775e7de9Smrg fi 10952421c997bSmrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 10953421c997bSmrg tool_oldlib=$func_to_tool_file_result 10954994689c1Smrg eval cmds=\"$old_archive_cmds\" 10955e1e1713cSmrg 10956994689c1Smrg func_len " $cmds" 10957994689c1Smrg len=$func_len_result 10958994689c1Smrg if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 10959994689c1Smrg cmds=$old_archive_cmds 10960f353fbadSmrg elif test -n "$archiver_list_spec"; then 10961f353fbadSmrg func_verbose "using command file archive linking..." 10962f353fbadSmrg for obj in $oldobjs 10963f353fbadSmrg do 10964f353fbadSmrg func_to_tool_file "$obj" 10965f353fbadSmrg $ECHO "$func_to_tool_file_result" 10966f353fbadSmrg done > $output_objdir/$libname.libcmd 10967f353fbadSmrg func_to_tool_file "$output_objdir/$libname.libcmd" 10968f353fbadSmrg oldobjs=" $archiver_list_spec$func_to_tool_file_result" 10969f353fbadSmrg cmds=$old_archive_cmds 10970994689c1Smrg else 10971994689c1Smrg # the command line is too long to link in one step, link in parts 10972994689c1Smrg func_verbose "using piecewise archive linking..." 10973994689c1Smrg save_RANLIB=$RANLIB 10974994689c1Smrg RANLIB=: 10975994689c1Smrg objlist= 10976994689c1Smrg concat_cmds= 10977994689c1Smrg save_oldobjs=$oldobjs 10978994689c1Smrg oldobjs= 10979994689c1Smrg # Is there a better way of finding the last object in the list? 10980994689c1Smrg for obj in $save_oldobjs 10981994689c1Smrg do 10982994689c1Smrg last_oldobj=$obj 10983994689c1Smrg done 10984994689c1Smrg eval test_cmds=\"$old_archive_cmds\" 10985994689c1Smrg func_len " $test_cmds" 10986994689c1Smrg len0=$func_len_result 10987994689c1Smrg len=$len0 10988994689c1Smrg for obj in $save_oldobjs 10989994689c1Smrg do 10990994689c1Smrg func_len " $obj" 10991994689c1Smrg func_arith $len + $func_len_result 10992994689c1Smrg len=$func_arith_result 10993994689c1Smrg func_append objlist " $obj" 10994994689c1Smrg if test "$len" -lt "$max_cmd_len"; then 10995994689c1Smrg : 10996994689c1Smrg else 10997994689c1Smrg # the above command should be used before it gets too long 10998994689c1Smrg oldobjs=$objlist 109995ec34c4cSmrg if test "$obj" = "$last_oldobj"; then 11000994689c1Smrg RANLIB=$save_RANLIB 11001994689c1Smrg fi 11002994689c1Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 110035ec34c4cSmrg eval concat_cmds=\"\$concat_cmds$old_archive_cmds\" 11004994689c1Smrg objlist= 11005994689c1Smrg len=$len0 11006994689c1Smrg fi 11007994689c1Smrg done 11008994689c1Smrg RANLIB=$save_RANLIB 11009994689c1Smrg oldobjs=$objlist 110105ec34c4cSmrg if test -z "$oldobjs"; then 11011994689c1Smrg eval cmds=\"\$concat_cmds\" 11012994689c1Smrg else 11013994689c1Smrg eval cmds=\"\$concat_cmds~\$old_archive_cmds\" 11014994689c1Smrg fi 11015994689c1Smrg fi 11016994689c1Smrg fi 11017994689c1Smrg func_execute_cmds "$cmds" 'exit $?' 110187a84e134Smrg done 110197a84e134Smrg 11020994689c1Smrg test -n "$generated" && \ 11021994689c1Smrg func_show_eval "${RM}r$generated" 110227a84e134Smrg 11023994689c1Smrg # Now create the libtool archive. 11024994689c1Smrg case $output in 11025994689c1Smrg *.la) 11026994689c1Smrg old_library= 110275ec34c4cSmrg test yes = "$build_old_libs" && old_library=$libname.$libext 11028994689c1Smrg func_verbose "creating $output" 11029775e7de9Smrg 11030994689c1Smrg # Preserve any variables that may affect compiler behavior 11031994689c1Smrg for var in $variables_saved_for_relink; do 11032994689c1Smrg if eval test -z \"\${$var+set}\"; then 11033994689c1Smrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 11034994689c1Smrg elif eval var_value=\$$var; test -z "$var_value"; then 11035994689c1Smrg relink_command="$var=; export $var; $relink_command" 11036e1e1713cSmrg else 110375b16253fSmrg func_quote_arg pretty,unquoted "$var_value" 110385b16253fSmrg relink_command="$var=$func_quote_arg_unquoted_result; export $var; $relink_command" 11039e1e1713cSmrg fi 11040994689c1Smrg done 11041994689c1Smrg # Quote the link command for shipping. 110425b16253fSmrg func_quote eval cd "`pwd`" 110435b16253fSmrg relink_command="($func_quote_result; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" 110445b16253fSmrg func_quote_arg pretty,unquoted "$relink_command" 110455b16253fSmrg relink_command=$func_quote_arg_unquoted_result 110465ec34c4cSmrg if test yes = "$hardcode_automatic"; then 11047994689c1Smrg relink_command= 11048994689c1Smrg fi 110497a84e134Smrg 11050994689c1Smrg # Only create the output if not a dry run. 11051994689c1Smrg $opt_dry_run || { 11052994689c1Smrg for installed in no yes; do 110535ec34c4cSmrg if test yes = "$installed"; then 11054994689c1Smrg if test -z "$install_libdir"; then 11055994689c1Smrg break 11056994689c1Smrg fi 110575ec34c4cSmrg output=$output_objdir/${outputname}i 11058994689c1Smrg # Replace all uninstalled libtool libraries with the installed ones 11059994689c1Smrg newdependency_libs= 11060994689c1Smrg for deplib in $dependency_libs; do 11061994689c1Smrg case $deplib in 11062994689c1Smrg *.la) 11063994689c1Smrg func_basename "$deplib" 110645ec34c4cSmrg name=$func_basename_result 11065421c997bSmrg func_resolve_sysroot "$deplib" 110665ec34c4cSmrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` 11067994689c1Smrg test -z "$libdir" && \ 110685ec34c4cSmrg func_fatal_error "'$deplib' is not a valid libtool archive" 11069f353fbadSmrg func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" 11070f353fbadSmrg ;; 11071f353fbadSmrg -L*) 11072f353fbadSmrg func_stripname -L '' "$deplib" 11073f353fbadSmrg func_replace_sysroot "$func_stripname_result" 11074f353fbadSmrg func_append newdependency_libs " -L$func_replace_sysroot_result" 11075f353fbadSmrg ;; 11076f353fbadSmrg -R*) 11077f353fbadSmrg func_stripname -R '' "$deplib" 11078f353fbadSmrg func_replace_sysroot "$func_stripname_result" 11079f353fbadSmrg func_append newdependency_libs " -R$func_replace_sysroot_result" 11080994689c1Smrg ;; 11081f353fbadSmrg *) func_append newdependency_libs " $deplib" ;; 11082994689c1Smrg esac 11083994689c1Smrg done 110845ec34c4cSmrg dependency_libs=$newdependency_libs 11085994689c1Smrg newdlfiles= 11086994689c1Smrg 11087994689c1Smrg for lib in $dlfiles; do 11088994689c1Smrg case $lib in 11089994689c1Smrg *.la) 11090994689c1Smrg func_basename "$lib" 110915ec34c4cSmrg name=$func_basename_result 110925ec34c4cSmrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 11093994689c1Smrg test -z "$libdir" && \ 110945ec34c4cSmrg func_fatal_error "'$lib' is not a valid libtool archive" 11095f353fbadSmrg func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" 11096994689c1Smrg ;; 11097f353fbadSmrg *) func_append newdlfiles " $lib" ;; 11098994689c1Smrg esac 11099994689c1Smrg done 111005ec34c4cSmrg dlfiles=$newdlfiles 11101994689c1Smrg newdlprefiles= 11102994689c1Smrg for lib in $dlprefiles; do 11103994689c1Smrg case $lib in 11104994689c1Smrg *.la) 11105994689c1Smrg # Only pass preopened files to the pseudo-archive (for 11106994689c1Smrg # eventual linking with the app. that links it) if we 11107994689c1Smrg # didn't already link the preopened objects directly into 11108994689c1Smrg # the library: 11109994689c1Smrg func_basename "$lib" 111105ec34c4cSmrg name=$func_basename_result 111115ec34c4cSmrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 11112994689c1Smrg test -z "$libdir" && \ 111135ec34c4cSmrg func_fatal_error "'$lib' is not a valid libtool archive" 11114f353fbadSmrg func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" 11115994689c1Smrg ;; 11116994689c1Smrg esac 11117994689c1Smrg done 111185ec34c4cSmrg dlprefiles=$newdlprefiles 11119994689c1Smrg else 11120994689c1Smrg newdlfiles= 11121994689c1Smrg for lib in $dlfiles; do 11122994689c1Smrg case $lib in 111235ec34c4cSmrg [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; 11124994689c1Smrg *) abs=`pwd`"/$lib" ;; 11125994689c1Smrg esac 11126f353fbadSmrg func_append newdlfiles " $abs" 11127994689c1Smrg done 111285ec34c4cSmrg dlfiles=$newdlfiles 11129994689c1Smrg newdlprefiles= 11130994689c1Smrg for lib in $dlprefiles; do 11131994689c1Smrg case $lib in 111325ec34c4cSmrg [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; 11133994689c1Smrg *) abs=`pwd`"/$lib" ;; 11134994689c1Smrg esac 11135f353fbadSmrg func_append newdlprefiles " $abs" 11136994689c1Smrg done 111375ec34c4cSmrg dlprefiles=$newdlprefiles 11138994689c1Smrg fi 11139994689c1Smrg $RM $output 11140994689c1Smrg # place dlname in correct position for cygwin 11141994689c1Smrg # In fact, it would be nice if we could use this code for all target 11142994689c1Smrg # systems that can't hard-code library paths into their executables 11143994689c1Smrg # and that have no shared library path variable independent of PATH, 11144994689c1Smrg # but it turns out we can't easily determine that from inspecting 11145994689c1Smrg # libtool variables, so we have to hard-code the OSs to which it 11146994689c1Smrg # applies here; at the moment, that means platforms that use the PE 11147994689c1Smrg # object format with DLL files. See the long comment at the top of 11148994689c1Smrg # tests/bindir.at for full details. 11149994689c1Smrg tdlname=$dlname 11150994689c1Smrg case $host,$output,$installed,$module,$dlname in 11151994689c1Smrg *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) 11152994689c1Smrg # If a -bindir argument was supplied, place the dll there. 111535ec34c4cSmrg if test -n "$bindir"; then 11154994689c1Smrg func_relative_path "$install_libdir" "$bindir" 111555ec34c4cSmrg tdlname=$func_relative_path_result/$dlname 11156994689c1Smrg else 11157994689c1Smrg # Otherwise fall back on heuristic. 11158994689c1Smrg tdlname=../bin/$dlname 11159994689c1Smrg fi 11160994689c1Smrg ;; 11161994689c1Smrg esac 11162994689c1Smrg $ECHO > $output "\ 11163994689c1Smrg# $outputname - a libtool library file 111645ec34c4cSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 11165994689c1Smrg# 11166994689c1Smrg# Please DO NOT delete this file! 11167994689c1Smrg# It is necessary for linking the library. 111687a84e134Smrg 11169994689c1Smrg# The name that we can dlopen(3). 11170994689c1Smrgdlname='$tdlname' 111717a84e134Smrg 11172994689c1Smrg# Names of this library. 11173994689c1Smrglibrary_names='$library_names' 111747a84e134Smrg 11175994689c1Smrg# The name of the static archive. 11176994689c1Smrgold_library='$old_library' 111777a84e134Smrg 111785ec34c4cSmrg# Linker flags that cannot go in dependency_libs. 11179994689c1Smrginherited_linker_flags='$new_inherited_linker_flags' 111807a84e134Smrg 11181994689c1Smrg# Libraries that this one depends upon. 11182994689c1Smrgdependency_libs='$dependency_libs' 111837a84e134Smrg 11184994689c1Smrg# Names of additional weak libraries provided by this library 11185994689c1Smrgweak_library_names='$weak_libs' 111867a84e134Smrg 11187994689c1Smrg# Version information for $libname. 11188994689c1Smrgcurrent=$current 11189994689c1Smrgage=$age 11190994689c1Smrgrevision=$revision 111917a84e134Smrg 11192994689c1Smrg# Is this an already installed library? 11193994689c1Smrginstalled=$installed 111947a84e134Smrg 11195994689c1Smrg# Should we warn about portability when linking against -modules? 11196994689c1Smrgshouldnotlink=$module 111977a84e134Smrg 11198994689c1Smrg# Files to dlopen/dlpreopen 11199994689c1Smrgdlopen='$dlfiles' 11200994689c1Smrgdlpreopen='$dlprefiles' 112017a84e134Smrg 11202994689c1Smrg# Directory that this library needs to be installed in: 11203994689c1Smrglibdir='$install_libdir'" 112045ec34c4cSmrg if test no,yes = "$installed,$need_relink"; then 11205994689c1Smrg $ECHO >> $output "\ 11206994689c1Smrgrelink_command=\"$relink_command\"" 11207994689c1Smrg fi 11208994689c1Smrg done 11209994689c1Smrg } 112107a84e134Smrg 11211994689c1Smrg # Do a symbolic link so that the libtool archive can be found in 11212994689c1Smrg # LD_LIBRARY_PATH before the program is installed. 11213994689c1Smrg func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' 11214994689c1Smrg ;; 11215994689c1Smrg esac 11216994689c1Smrg exit $EXIT_SUCCESS 11217994689c1Smrg} 11218e1e1713cSmrg 112195ec34c4cSmrgif test link = "$opt_mode" || test relink = "$opt_mode"; then 112205ec34c4cSmrg func_mode_link ${1+"$@"} 112215ec34c4cSmrgfi 112227a84e134Smrg 112237a84e134Smrg 11224994689c1Smrg# func_mode_uninstall arg... 11225994689c1Smrgfunc_mode_uninstall () 11226994689c1Smrg{ 112275ec34c4cSmrg $debug_cmd 112285ec34c4cSmrg 112295ec34c4cSmrg RM=$nonopt 112307a84e134Smrg files= 112315ec34c4cSmrg rmforce=false 112327a84e134Smrg exit_status=0 112337a84e134Smrg 112347a84e134Smrg # This variable tells wrapper scripts just to set variables rather 112357a84e134Smrg # than running their programs. 112365ec34c4cSmrg libtool_install_magic=$magic 112377a84e134Smrg 112387a84e134Smrg for arg 112397a84e134Smrg do 112407a84e134Smrg case $arg in 112415ec34c4cSmrg -f) func_append RM " $arg"; rmforce=: ;; 11242f353fbadSmrg -*) func_append RM " $arg" ;; 11243f353fbadSmrg *) func_append files " $arg" ;; 112447a84e134Smrg esac 112457a84e134Smrg done 112467a84e134Smrg 11247994689c1Smrg test -z "$RM" && \ 11248994689c1Smrg func_fatal_help "you must specify an RM program" 112497a84e134Smrg 112507a84e134Smrg rmdirs= 112517a84e134Smrg 112527a84e134Smrg for file in $files; do 11253994689c1Smrg func_dirname "$file" "" "." 112545ec34c4cSmrg dir=$func_dirname_result 112555ec34c4cSmrg if test . = "$dir"; then 112565ec34c4cSmrg odir=$objdir 112577a84e134Smrg else 112585ec34c4cSmrg odir=$dir/$objdir 112597a84e134Smrg fi 11260994689c1Smrg func_basename "$file" 112615ec34c4cSmrg name=$func_basename_result 112625ec34c4cSmrg test uninstall = "$opt_mode" && odir=$dir 112637a84e134Smrg 11264f353fbadSmrg # Remember odir for removal later, being careful to avoid duplicates 112655ec34c4cSmrg if test clean = "$opt_mode"; then 112667a84e134Smrg case " $rmdirs " in 11267f353fbadSmrg *" $odir "*) ;; 11268f353fbadSmrg *) func_append rmdirs " $odir" ;; 112697a84e134Smrg esac 112707a84e134Smrg fi 112717a84e134Smrg 112727a84e134Smrg # Don't error if the file doesn't exist and rm -f was used. 11273994689c1Smrg if { test -L "$file"; } >/dev/null 2>&1 || 11274994689c1Smrg { test -h "$file"; } >/dev/null 2>&1 || 11275994689c1Smrg test -f "$file"; then 112767a84e134Smrg : 112777a84e134Smrg elif test -d "$file"; then 112787a84e134Smrg exit_status=1 112797a84e134Smrg continue 112805ec34c4cSmrg elif $rmforce; then 112817a84e134Smrg continue 112827a84e134Smrg fi 112837a84e134Smrg 112845ec34c4cSmrg rmfiles=$file 112857a84e134Smrg 112867a84e134Smrg case $name in 112877a84e134Smrg *.la) 112887a84e134Smrg # Possibly a libtool archive, so verify it. 11289994689c1Smrg if func_lalib_p "$file"; then 11290994689c1Smrg func_source $dir/$name 112917a84e134Smrg 112927a84e134Smrg # Delete the libtool libraries and symlinks. 112937a84e134Smrg for n in $library_names; do 11294f353fbadSmrg func_append rmfiles " $odir/$n" 112957a84e134Smrg done 11296f353fbadSmrg test -n "$old_library" && func_append rmfiles " $odir/$old_library" 112977a84e134Smrg 112985ec34c4cSmrg case $opt_mode in 112997a84e134Smrg clean) 11300f353fbadSmrg case " $library_names " in 113017a84e134Smrg *" $dlname "*) ;; 11302f353fbadSmrg *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; 113037a84e134Smrg esac 11304f353fbadSmrg test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" 113057a84e134Smrg ;; 113067a84e134Smrg uninstall) 113077a84e134Smrg if test -n "$library_names"; then 113087a84e134Smrg # Do each command in the postuninstall commands. 113095ec34c4cSmrg func_execute_cmds "$postuninstall_cmds" '$rmforce || exit_status=1' 113107a84e134Smrg fi 113117a84e134Smrg 113127a84e134Smrg if test -n "$old_library"; then 113137a84e134Smrg # Do each command in the old_postuninstall commands. 113145ec34c4cSmrg func_execute_cmds "$old_postuninstall_cmds" '$rmforce || exit_status=1' 113157a84e134Smrg fi 113167a84e134Smrg # FIXME: should reinstall the best remaining shared library. 113177a84e134Smrg ;; 113187a84e134Smrg esac 113197a84e134Smrg fi 113207a84e134Smrg ;; 113217a84e134Smrg 113227a84e134Smrg *.lo) 113237a84e134Smrg # Possibly a libtool object, so verify it. 11324994689c1Smrg if func_lalib_p "$file"; then 113257a84e134Smrg 113267a84e134Smrg # Read the .lo file 11327994689c1Smrg func_source $dir/$name 113287a84e134Smrg 113297a84e134Smrg # Add PIC object to the list of files to remove. 113305ec34c4cSmrg if test -n "$pic_object" && test none != "$pic_object"; then 11331f353fbadSmrg func_append rmfiles " $dir/$pic_object" 113327a84e134Smrg fi 113337a84e134Smrg 113347a84e134Smrg # Add non-PIC object to the list of files to remove. 113355ec34c4cSmrg if test -n "$non_pic_object" && test none != "$non_pic_object"; then 11336f353fbadSmrg func_append rmfiles " $dir/$non_pic_object" 113377a84e134Smrg fi 113387a84e134Smrg fi 113397a84e134Smrg ;; 113407a84e134Smrg 113417a84e134Smrg *) 113425ec34c4cSmrg if test clean = "$opt_mode"; then 113437a84e134Smrg noexename=$name 113447a84e134Smrg case $file in 113457a84e134Smrg *.exe) 11346994689c1Smrg func_stripname '' '.exe' "$file" 11347994689c1Smrg file=$func_stripname_result 11348994689c1Smrg func_stripname '' '.exe' "$name" 11349994689c1Smrg noexename=$func_stripname_result 113507a84e134Smrg # $file with .exe has already been added to rmfiles, 113517a84e134Smrg # add $file without .exe 11352f353fbadSmrg func_append rmfiles " $file" 113537a84e134Smrg ;; 113547a84e134Smrg esac 113557a84e134Smrg # Do a test to see if this is a libtool program. 11356994689c1Smrg if func_ltwrapper_p "$file"; then 11357994689c1Smrg if func_ltwrapper_executable_p "$file"; then 11358994689c1Smrg func_ltwrapper_scriptname "$file" 11359994689c1Smrg relink_command= 11360994689c1Smrg func_source $func_ltwrapper_scriptname_result 11361f353fbadSmrg func_append rmfiles " $func_ltwrapper_scriptname_result" 11362994689c1Smrg else 11363994689c1Smrg relink_command= 11364994689c1Smrg func_source $dir/$noexename 11365994689c1Smrg fi 113667a84e134Smrg 113677a84e134Smrg # note $name still contains .exe if it was in $file originally 113687a84e134Smrg # as does the version of $file that was added into $rmfiles 113695ec34c4cSmrg func_append rmfiles " $odir/$name $odir/${name}S.$objext" 113705ec34c4cSmrg if test yes = "$fast_install" && test -n "$relink_command"; then 11371f353fbadSmrg func_append rmfiles " $odir/lt-$name" 113727a84e134Smrg fi 113735ec34c4cSmrg if test "X$noexename" != "X$name"; then 113745ec34c4cSmrg func_append rmfiles " $odir/lt-$noexename.c" 113757a84e134Smrg fi 113767a84e134Smrg fi 113777a84e134Smrg fi 113787a84e134Smrg ;; 113797a84e134Smrg esac 11380994689c1Smrg func_show_eval "$RM $rmfiles" 'exit_status=1' 113817a84e134Smrg done 113827a84e134Smrg 113835ec34c4cSmrg # Try to remove the $objdir's in the directories where we deleted files 113847a84e134Smrg for dir in $rmdirs; do 113857a84e134Smrg if test -d "$dir"; then 11386994689c1Smrg func_show_eval "rmdir $dir >/dev/null 2>&1" 113877a84e134Smrg fi 113887a84e134Smrg done 113897a84e134Smrg 113907a84e134Smrg exit $exit_status 11391994689c1Smrg} 113927a84e134Smrg 113935ec34c4cSmrgif test uninstall = "$opt_mode" || test clean = "$opt_mode"; then 113945ec34c4cSmrg func_mode_uninstall ${1+"$@"} 113955ec34c4cSmrgfi 11396775e7de9Smrg 11397f353fbadSmrgtest -z "$opt_mode" && { 113985ec34c4cSmrg help=$generic_help 11399994689c1Smrg func_fatal_help "you must specify a MODE" 11400994689c1Smrg} 11401994689c1Smrg 11402994689c1Smrgtest -z "$exec_cmd" && \ 114035ec34c4cSmrg func_fatal_help "invalid operation mode '$opt_mode'" 114047a84e134Smrg 114057a84e134Smrgif test -n "$exec_cmd"; then 11406994689c1Smrg eval exec "$exec_cmd" 114077a84e134Smrg exit $EXIT_FAILURE 114087a84e134Smrgfi 114097a84e134Smrg 11410994689c1Smrgexit $exit_status 11411e1e1713cSmrg 114127a84e134Smrg 114137a84e134Smrg# The TAGs below are defined such that we never get into a situation 114145ec34c4cSmrg# where we disable both kinds of libraries. Given conflicting 114157a84e134Smrg# choices, we go for a static library, that is the most portable, 114167a84e134Smrg# since we can't tell whether shared libraries were disabled because 114177a84e134Smrg# the user asked for that or because the platform doesn't support 114187a84e134Smrg# them. This is particularly important on AIX, because we don't 114197a84e134Smrg# support having both static and shared libraries enabled at the same 114207a84e134Smrg# time on that platform, so we default to a shared-only configuration. 114217a84e134Smrg# If a disable-shared tag is given, we'll fallback to a static-only 114227a84e134Smrg# configuration. But we'll never go from static-only to shared-only. 114237a84e134Smrg 114247a84e134Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared 11425994689c1Smrgbuild_libtool_libs=no 11426994689c1Smrgbuild_old_libs=yes 114277a84e134Smrg# ### END LIBTOOL TAG CONFIG: disable-shared 114287a84e134Smrg 114297a84e134Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static 11430994689c1Smrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` 114317a84e134Smrg# ### END LIBTOOL TAG CONFIG: disable-static 114327a84e134Smrg 114337a84e134Smrg# Local Variables: 114347a84e134Smrg# mode:shell-script 114357a84e134Smrg# sh-indentation:2 114367a84e134Smrg# End: 11437