10b0ce0bfSmrg#! /usr/bin/env sh 20b0ce0bfSmrg## DO NOT EDIT - This file generated from ./build-aux/ltmain.in 30b0ce0bfSmrg## by inline-source v2019-02-19.15 41b12faf6Smrg 50b0ce0bfSmrg# libtool (GNU libtool) 2.4.7 60b0ce0bfSmrg# Provide generalized library-building support services. 71b12faf6Smrg# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 81b12faf6Smrg 90b0ce0bfSmrg# Copyright (C) 1996-2019, 2021-2022 Free Software Foundation, Inc. 101b12faf6Smrg# This is free software; see the source for copying conditions. There is NO 111b12faf6Smrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 121b12faf6Smrg 131b12faf6Smrg# GNU Libtool is free software; you can redistribute it and/or modify 1432b578d3Smrg# it under the terms of the GNU General Public License as published by 1532b578d3Smrg# the Free Software Foundation; either version 2 of the License, or 1632b578d3Smrg# (at your option) any later version. 1732b578d3Smrg# 181b12faf6Smrg# As a special exception to the GNU General Public License, 191b12faf6Smrg# if you distribute this file as part of a program or library that 201b12faf6Smrg# is built using GNU Libtool, you may include this file under the 211b12faf6Smrg# same distribution terms that you use for the rest of that program. 221b12faf6Smrg# 231b12faf6Smrg# GNU Libtool is distributed in the hope that it will be useful, but 2432b578d3Smrg# WITHOUT ANY WARRANTY; without even the implied warranty of 2532b578d3Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 2632b578d3Smrg# General Public License for more details. 2732b578d3Smrg# 2832b578d3Smrg# You should have received a copy of the GNU General Public License 290b0ce0bfSmrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 3032b578d3Smrg 310b0ce0bfSmrg 320b0ce0bfSmrgPROGRAM=libtool 330b0ce0bfSmrgPACKAGE=libtool 340b0ce0bfSmrgVERSION=2.4.7 350b0ce0bfSmrgpackage_revision=2.4.7 360b0ce0bfSmrg 370b0ce0bfSmrg 380b0ce0bfSmrg## ------ ## 390b0ce0bfSmrg## Usage. ## 400b0ce0bfSmrg## ------ ## 410b0ce0bfSmrg 420b0ce0bfSmrg# Run './libtool --help' for help with using this script from the 430b0ce0bfSmrg# command line. 440b0ce0bfSmrg 450b0ce0bfSmrg 460b0ce0bfSmrg## ------------------------------- ## 470b0ce0bfSmrg## User overridable command paths. ## 480b0ce0bfSmrg## ------------------------------- ## 490b0ce0bfSmrg 500b0ce0bfSmrg# After configure completes, it has a better idea of some of the 510b0ce0bfSmrg# shell tools we need than the defaults used by the functions shared 520b0ce0bfSmrg# with bootstrap, so set those here where they can still be over- 530b0ce0bfSmrg# ridden by the user, but otherwise take precedence. 540b0ce0bfSmrg 550b0ce0bfSmrg: ${AUTOCONF="autoconf"} 560b0ce0bfSmrg: ${AUTOMAKE="automake"} 570b0ce0bfSmrg 580b0ce0bfSmrg 590b0ce0bfSmrg## -------------------------- ## 600b0ce0bfSmrg## Source external libraries. ## 610b0ce0bfSmrg## -------------------------- ## 620b0ce0bfSmrg 630b0ce0bfSmrg# Much of our low-level functionality needs to be sourced from external 640b0ce0bfSmrg# libraries, which are installed to $pkgauxdir. 650b0ce0bfSmrg 660b0ce0bfSmrg# Set a version string for this script. 670b0ce0bfSmrgscriptversion=2019-02-19.15; # UTC 680b0ce0bfSmrg 690b0ce0bfSmrg# General shell script boiler plate, and helper functions. 700b0ce0bfSmrg# Written by Gary V. Vaughan, 2004 710b0ce0bfSmrg 720b0ce0bfSmrg# This is free software. There is NO warranty; not even for 730b0ce0bfSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 741b12faf6Smrg# 750b0ce0bfSmrg# Copyright (C) 2004-2019, 2021 Bootstrap Authors 761b12faf6Smrg# 770b0ce0bfSmrg# This file is dual licensed under the terms of the MIT license 780b0ce0bfSmrg# <https://opensource.org/license/MIT>, and GPL version 2 or later 790b0ce0bfSmrg# <http://www.gnu.org/licenses/gpl-2.0.html>. You must apply one of 800b0ce0bfSmrg# these licenses when using or redistributing this software or any of 810b0ce0bfSmrg# the files within it. See the URLs above, or the file `LICENSE` 820b0ce0bfSmrg# included in the Bootstrap distribution for the full license texts. 830b0ce0bfSmrg 840b0ce0bfSmrg# Please report bugs or propose patches to: 850b0ce0bfSmrg# <https://github.com/gnulib-modules/bootstrap/issues> 860b0ce0bfSmrg 870b0ce0bfSmrg 880b0ce0bfSmrg## ------ ## 890b0ce0bfSmrg## Usage. ## 900b0ce0bfSmrg## ------ ## 910b0ce0bfSmrg 920b0ce0bfSmrg# Evaluate this file near the top of your script to gain access to 930b0ce0bfSmrg# the functions and variables defined here: 941b12faf6Smrg# 950b0ce0bfSmrg# . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh 961b12faf6Smrg# 970b0ce0bfSmrg# If you need to override any of the default environment variable 980b0ce0bfSmrg# settings, do that before evaluating this file. 9932b578d3Smrg 1002a51b5beSmrg 1010b0ce0bfSmrg## -------------------- ## 1020b0ce0bfSmrg## Shell normalisation. ## 1030b0ce0bfSmrg## -------------------- ## 1040b0ce0bfSmrg 1050b0ce0bfSmrg# Some shells need a little help to be as Bourne compatible as possible. 1060b0ce0bfSmrg# Before doing anything else, make sure all that help has been provided! 1070b0ce0bfSmrg 1080b0ce0bfSmrgDUALCASE=1; export DUALCASE # for MKS sh 1090b0ce0bfSmrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : 1102a51b5beSmrg emulate sh 1112a51b5beSmrg NULLCMD=: 1120b0ce0bfSmrg # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which 1132a51b5beSmrg # is contrary to our usage. Disable this feature. 1142a51b5beSmrg alias -g '${1+"$@"}'='"$@"' 11532b578d3Smrg setopt NO_GLOB_SUBST 1162a51b5beSmrgelse 1170b0ce0bfSmrg case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac 11832b578d3Smrgfi 119e35d4d8eSmrg 1200b0ce0bfSmrg# NLS nuisances: We save the old values in case they are required later. 1210b0ce0bfSmrg_G_user_locale= 1220b0ce0bfSmrg_G_safe_locale= 1230b0ce0bfSmrgfor _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 1242a51b5beSmrgdo 1250b0ce0bfSmrg eval "if test set = \"\${$_G_var+set}\"; then 1260b0ce0bfSmrg save_$_G_var=\$$_G_var 1270b0ce0bfSmrg $_G_var=C 1280b0ce0bfSmrg export $_G_var 1290b0ce0bfSmrg _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\" 1300b0ce0bfSmrg _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\" 1312a51b5beSmrg fi" 1322a51b5beSmrgdone 1330b0ce0bfSmrg# These NLS vars are set unconditionally (bootstrap issue #24). Unset those 1340b0ce0bfSmrg# in case the environment reset is needed later and the $save_* variant is not 1350b0ce0bfSmrg# defined (see the code above). 136e35d4d8eSmrgLC_ALL=C 137e35d4d8eSmrgLANGUAGE=C 138e35d4d8eSmrgexport LANGUAGE LC_ALL 1392a51b5beSmrg 1400b0ce0bfSmrg# Make sure IFS has a sensible default 1410b0ce0bfSmrgsp=' ' 1420b0ce0bfSmrgnl=' 1430b0ce0bfSmrg' 1440b0ce0bfSmrgIFS="$sp $nl" 1450b0ce0bfSmrg 1460b0ce0bfSmrg# There are apparently some retarded systems that use ';' as a PATH separator! 1470b0ce0bfSmrgif test "${PATH_SEPARATOR+set}" != set; then 1480b0ce0bfSmrg PATH_SEPARATOR=: 1490b0ce0bfSmrg (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { 1500b0ce0bfSmrg (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || 1510b0ce0bfSmrg PATH_SEPARATOR=';' 1520b0ce0bfSmrg } 1530b0ce0bfSmrgfi 1541b12faf6Smrg 1551b12faf6Smrg 1560b0ce0bfSmrg# func_unset VAR 1570b0ce0bfSmrg# -------------- 1580b0ce0bfSmrg# Portably unset VAR. 1590b0ce0bfSmrg# In some shells, an 'unset VAR' statement leaves a non-zero return 1600b0ce0bfSmrg# status if VAR is already unset, which might be problematic if the 1610b0ce0bfSmrg# statement is used at the end of a function (thus poisoning its return 1620b0ce0bfSmrg# value) or when 'set -e' is active (causing even a spurious abort of 1630b0ce0bfSmrg# the script in this case). 1640b0ce0bfSmrgfunc_unset () 1650b0ce0bfSmrg{ 1660b0ce0bfSmrg { eval $1=; (eval unset $1) >/dev/null 2>&1 && eval unset $1 || : ; } 1670b0ce0bfSmrg} 1681b12faf6Smrg 1691b12faf6Smrg 1700b0ce0bfSmrg# Make sure CDPATH doesn't cause `cd` commands to output the target dir. 1710b0ce0bfSmrgfunc_unset CDPATH 1721b12faf6Smrg 1730b0ce0bfSmrg# Make sure ${,E,F}GREP behave sanely. 1740b0ce0bfSmrgfunc_unset GREP_OPTIONS 1751b12faf6Smrg 17632b578d3Smrg 1770b0ce0bfSmrg## ------------------------- ## 1780b0ce0bfSmrg## Locate command utilities. ## 1790b0ce0bfSmrg## ------------------------- ## 18032b578d3Smrg 1811b12faf6Smrg 1820b0ce0bfSmrg# func_executable_p FILE 1830b0ce0bfSmrg# ---------------------- 1840b0ce0bfSmrg# Check that FILE is an executable regular file. 1850b0ce0bfSmrgfunc_executable_p () 186e35d4d8eSmrg{ 1870b0ce0bfSmrg test -f "$1" && test -x "$1" 1880b0ce0bfSmrg} 189e35d4d8eSmrg 190e35d4d8eSmrg 1910b0ce0bfSmrg# func_path_progs PROGS_LIST CHECK_FUNC [PATH] 1920b0ce0bfSmrg# -------------------------------------------- 1930b0ce0bfSmrg# Search for either a program that responds to --version with output 1940b0ce0bfSmrg# containing "GNU", or else returned by CHECK_FUNC otherwise, by 1950b0ce0bfSmrg# trying all the directories in PATH with each of the elements of 1960b0ce0bfSmrg# PROGS_LIST. 1970b0ce0bfSmrg# 1980b0ce0bfSmrg# CHECK_FUNC should accept the path to a candidate program, and 1990b0ce0bfSmrg# set $func_check_prog_result if it truncates its output less than 2000b0ce0bfSmrg# $_G_path_prog_max characters. 2010b0ce0bfSmrgfunc_path_progs () 202e35d4d8eSmrg{ 2030b0ce0bfSmrg _G_progs_list=$1 2040b0ce0bfSmrg _G_check_func=$2 2050b0ce0bfSmrg _G_PATH=${3-"$PATH"} 2060b0ce0bfSmrg 2070b0ce0bfSmrg _G_path_prog_max=0 2080b0ce0bfSmrg _G_path_prog_found=false 2090b0ce0bfSmrg _G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:} 2100b0ce0bfSmrg for _G_dir in $_G_PATH; do 2110b0ce0bfSmrg IFS=$_G_save_IFS 2120b0ce0bfSmrg test -z "$_G_dir" && _G_dir=. 2130b0ce0bfSmrg for _G_prog_name in $_G_progs_list; do 2140b0ce0bfSmrg for _exeext in '' .EXE; do 2150b0ce0bfSmrg _G_path_prog=$_G_dir/$_G_prog_name$_exeext 2160b0ce0bfSmrg func_executable_p "$_G_path_prog" || continue 2170b0ce0bfSmrg case `"$_G_path_prog" --version 2>&1` in 2180b0ce0bfSmrg *GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;; 2190b0ce0bfSmrg *) $_G_check_func $_G_path_prog 2200b0ce0bfSmrg func_path_progs_result=$func_check_prog_result 2210b0ce0bfSmrg ;; 2220b0ce0bfSmrg esac 2230b0ce0bfSmrg $_G_path_prog_found && break 3 2240b0ce0bfSmrg done 2250b0ce0bfSmrg done 2260b0ce0bfSmrg done 2270b0ce0bfSmrg IFS=$_G_save_IFS 2280b0ce0bfSmrg test -z "$func_path_progs_result" && { 2290b0ce0bfSmrg echo "no acceptable sed could be found in \$PATH" >&2 2300b0ce0bfSmrg exit 1 2310b0ce0bfSmrg } 2320b0ce0bfSmrg} 233e35d4d8eSmrg 234e35d4d8eSmrg 2350b0ce0bfSmrg# We want to be able to use the functions in this file before configure 2360b0ce0bfSmrg# has figured out where the best binaries are kept, which means we have 2370b0ce0bfSmrg# to search for them ourselves - except when the results are already set 2380b0ce0bfSmrg# where we skip the searches. 239e35d4d8eSmrg 2400b0ce0bfSmrg# Unless the user overrides by setting SED, search the path for either GNU 2410b0ce0bfSmrg# sed, or the sed that truncates its output the least. 2420b0ce0bfSmrgtest -z "$SED" && { 2430b0ce0bfSmrg _G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ 2440b0ce0bfSmrg for _G_i in 1 2 3 4 5 6 7; do 2450b0ce0bfSmrg _G_sed_script=$_G_sed_script$nl$_G_sed_script 2460b0ce0bfSmrg done 2470b0ce0bfSmrg echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed 2480b0ce0bfSmrg _G_sed_script= 249e35d4d8eSmrg 2500b0ce0bfSmrg func_check_prog_sed () 2510b0ce0bfSmrg { 2520b0ce0bfSmrg _G_path_prog=$1 253e35d4d8eSmrg 2540b0ce0bfSmrg _G_count=0 2550b0ce0bfSmrg printf 0123456789 >conftest.in 2560b0ce0bfSmrg while : 2570b0ce0bfSmrg do 2580b0ce0bfSmrg cat conftest.in conftest.in >conftest.tmp 2590b0ce0bfSmrg mv conftest.tmp conftest.in 2600b0ce0bfSmrg cp conftest.in conftest.nl 2610b0ce0bfSmrg echo '' >> conftest.nl 2620b0ce0bfSmrg "$_G_path_prog" -f conftest.sed <conftest.nl >conftest.out 2>/dev/null || break 2630b0ce0bfSmrg diff conftest.out conftest.nl >/dev/null 2>&1 || break 2640b0ce0bfSmrg _G_count=`expr $_G_count + 1` 2650b0ce0bfSmrg if test "$_G_count" -gt "$_G_path_prog_max"; then 2660b0ce0bfSmrg # Best one so far, save it but keep looking for a better one 2670b0ce0bfSmrg func_check_prog_result=$_G_path_prog 2680b0ce0bfSmrg _G_path_prog_max=$_G_count 2690b0ce0bfSmrg fi 2700b0ce0bfSmrg # 10*(2^10) chars as input seems more than enough 2710b0ce0bfSmrg test 10 -lt "$_G_count" && break 2720b0ce0bfSmrg done 2730b0ce0bfSmrg rm -f conftest.in conftest.tmp conftest.nl conftest.out 2740b0ce0bfSmrg } 275e35d4d8eSmrg 2760b0ce0bfSmrg func_path_progs "sed gsed" func_check_prog_sed "$PATH:/usr/xpg4/bin" 2770b0ce0bfSmrg rm -f conftest.sed 2780b0ce0bfSmrg SED=$func_path_progs_result 2790b0ce0bfSmrg} 280e35d4d8eSmrg 2810b0ce0bfSmrg 2820b0ce0bfSmrg# Unless the user overrides by setting GREP, search the path for either GNU 2830b0ce0bfSmrg# grep, or the grep that truncates its output the least. 2840b0ce0bfSmrgtest -z "$GREP" && { 2850b0ce0bfSmrg func_check_prog_grep () 2860b0ce0bfSmrg { 2870b0ce0bfSmrg _G_path_prog=$1 2880b0ce0bfSmrg 2890b0ce0bfSmrg _G_count=0 2900b0ce0bfSmrg _G_path_prog_max=0 2910b0ce0bfSmrg printf 0123456789 >conftest.in 2920b0ce0bfSmrg while : 2930b0ce0bfSmrg do 2940b0ce0bfSmrg cat conftest.in conftest.in >conftest.tmp 2950b0ce0bfSmrg mv conftest.tmp conftest.in 2960b0ce0bfSmrg cp conftest.in conftest.nl 2970b0ce0bfSmrg echo 'GREP' >> conftest.nl 2980b0ce0bfSmrg "$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' <conftest.nl >conftest.out 2>/dev/null || break 2990b0ce0bfSmrg diff conftest.out conftest.nl >/dev/null 2>&1 || break 3000b0ce0bfSmrg _G_count=`expr $_G_count + 1` 3010b0ce0bfSmrg if test "$_G_count" -gt "$_G_path_prog_max"; then 3020b0ce0bfSmrg # Best one so far, save it but keep looking for a better one 3030b0ce0bfSmrg func_check_prog_result=$_G_path_prog 3040b0ce0bfSmrg _G_path_prog_max=$_G_count 3050b0ce0bfSmrg fi 3060b0ce0bfSmrg # 10*(2^10) chars as input seems more than enough 3070b0ce0bfSmrg test 10 -lt "$_G_count" && break 3080b0ce0bfSmrg done 3090b0ce0bfSmrg rm -f conftest.in conftest.tmp conftest.nl conftest.out 3100b0ce0bfSmrg } 3110b0ce0bfSmrg 3120b0ce0bfSmrg func_path_progs "grep ggrep" func_check_prog_grep "$PATH:/usr/xpg4/bin" 3130b0ce0bfSmrg GREP=$func_path_progs_result 3140b0ce0bfSmrg} 3150b0ce0bfSmrg 3160b0ce0bfSmrg 3170b0ce0bfSmrg## ------------------------------- ## 3180b0ce0bfSmrg## User overridable command paths. ## 3190b0ce0bfSmrg## ------------------------------- ## 3200b0ce0bfSmrg 3210b0ce0bfSmrg# All uppercase variable names are used for environment variables. These 3220b0ce0bfSmrg# variables can be overridden by the user before calling a script that 3230b0ce0bfSmrg# uses them if a suitable command of that name is not already available 3240b0ce0bfSmrg# in the command search PATH. 3250b0ce0bfSmrg 3260b0ce0bfSmrg: ${CP="cp -f"} 3270b0ce0bfSmrg: ${ECHO="printf %s\n"} 3280b0ce0bfSmrg: ${EGREP="$GREP -E"} 3290b0ce0bfSmrg: ${FGREP="$GREP -F"} 3300b0ce0bfSmrg: ${LN_S="ln -s"} 3310b0ce0bfSmrg: ${MAKE="make"} 3320b0ce0bfSmrg: ${MKDIR="mkdir"} 3330b0ce0bfSmrg: ${MV="mv -f"} 3340b0ce0bfSmrg: ${RM="rm -f"} 3350b0ce0bfSmrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"} 3360b0ce0bfSmrg 3370b0ce0bfSmrg 3380b0ce0bfSmrg## -------------------- ## 3390b0ce0bfSmrg## Useful sed snippets. ## 3400b0ce0bfSmrg## -------------------- ## 3410b0ce0bfSmrg 3420b0ce0bfSmrgsed_dirname='s|/[^/]*$||' 3430b0ce0bfSmrgsed_basename='s|^.*/||' 3440b0ce0bfSmrg 3450b0ce0bfSmrg# Sed substitution that helps us do robust quoting. It backslashifies 3460b0ce0bfSmrg# metacharacters that are still active within double-quoted strings. 3470b0ce0bfSmrgsed_quote_subst='s|\([`"$\\]\)|\\\1|g' 3480b0ce0bfSmrg 3490b0ce0bfSmrg# Same as above, but do not quote variable references. 3500b0ce0bfSmrgsed_double_quote_subst='s/\(["`\\]\)/\\\1/g' 3510b0ce0bfSmrg 3520b0ce0bfSmrg# Sed substitution that turns a string into a regex matching for the 3530b0ce0bfSmrg# string literally. 3540b0ce0bfSmrgsed_make_literal_regex='s|[].[^$\\*\/]|\\&|g' 3550b0ce0bfSmrg 3560b0ce0bfSmrg# Sed substitution that converts a w32 file name or path 3570b0ce0bfSmrg# that contains forward slashes, into one that contains 3580b0ce0bfSmrg# (escaped) backslashes. A very naive implementation. 3590b0ce0bfSmrgsed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' 3600b0ce0bfSmrg 3610b0ce0bfSmrg# Re-'\' parameter expansions in output of sed_double_quote_subst that 3620b0ce0bfSmrg# were '\'-ed in input to the same. If an odd number of '\' preceded a 3630b0ce0bfSmrg# '$' in input to sed_double_quote_subst, that '$' was protected from 3640b0ce0bfSmrg# expansion. Since each input '\' is now two '\'s, look for any number 3650b0ce0bfSmrg# of runs of four '\'s followed by two '\'s and then a '$'. '\' that '$'. 3660b0ce0bfSmrg_G_bs='\\' 3670b0ce0bfSmrg_G_bs2='\\\\' 3680b0ce0bfSmrg_G_bs4='\\\\\\\\' 3690b0ce0bfSmrg_G_dollar='\$' 3700b0ce0bfSmrgsed_double_backslash="\ 3710b0ce0bfSmrg s/$_G_bs4/&\\ 3720b0ce0bfSmrg/g 3730b0ce0bfSmrg s/^$_G_bs2$_G_dollar/$_G_bs&/ 3740b0ce0bfSmrg s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g 3750b0ce0bfSmrg s/\n//g" 3760b0ce0bfSmrg 3770b0ce0bfSmrg# require_check_ifs_backslash 3780b0ce0bfSmrg# --------------------------- 3790b0ce0bfSmrg# Check if we can use backslash as IFS='\' separator, and set 3800b0ce0bfSmrg# $check_ifs_backshlash_broken to ':' or 'false'. 3810b0ce0bfSmrgrequire_check_ifs_backslash=func_require_check_ifs_backslash 3820b0ce0bfSmrgfunc_require_check_ifs_backslash () 383e35d4d8eSmrg{ 3840b0ce0bfSmrg _G_save_IFS=$IFS 3850b0ce0bfSmrg IFS='\' 3860b0ce0bfSmrg _G_check_ifs_backshlash='a\\b' 3870b0ce0bfSmrg for _G_i in $_G_check_ifs_backshlash 3880b0ce0bfSmrg do 3890b0ce0bfSmrg case $_G_i in 3900b0ce0bfSmrg a) 3910b0ce0bfSmrg check_ifs_backshlash_broken=false 392e35d4d8eSmrg ;; 3930b0ce0bfSmrg '') 3940b0ce0bfSmrg break 395e35d4d8eSmrg ;; 3960b0ce0bfSmrg *) 3970b0ce0bfSmrg check_ifs_backshlash_broken=: 3980b0ce0bfSmrg break 399e35d4d8eSmrg ;; 400e35d4d8eSmrg esac 401e35d4d8eSmrg done 4020b0ce0bfSmrg IFS=$_G_save_IFS 4030b0ce0bfSmrg require_check_ifs_backslash=: 4041b12faf6Smrg} 40532b578d3Smrg 4061b12faf6Smrg 4070b0ce0bfSmrg## ----------------- ## 4080b0ce0bfSmrg## Global variables. ## 4090b0ce0bfSmrg## ----------------- ## 410e35d4d8eSmrg 4110b0ce0bfSmrg# Except for the global variables explicitly listed below, the following 4120b0ce0bfSmrg# functions in the '^func_' namespace, and the '^require_' namespace 4130b0ce0bfSmrg# variables initialised in the 'Resource management' section, sourcing 4140b0ce0bfSmrg# this file will not pollute your global namespace with anything 4150b0ce0bfSmrg# else. There's no portable way to scope variables in Bourne shell 4160b0ce0bfSmrg# though, so actually running these functions will sometimes place 4170b0ce0bfSmrg# results into a variable named after the function, and often use 4180b0ce0bfSmrg# temporary variables in the '^_G_' namespace. If you are careful to 4190b0ce0bfSmrg# avoid using those namespaces casually in your sourcing script, things 4200b0ce0bfSmrg# should continue to work as you expect. And, of course, you can freely 4210b0ce0bfSmrg# overwrite any of the functions or variables defined here before 4220b0ce0bfSmrg# calling anything to customize them. 4230b0ce0bfSmrg 4240b0ce0bfSmrgEXIT_SUCCESS=0 4250b0ce0bfSmrgEXIT_FAILURE=1 4260b0ce0bfSmrgEXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. 4270b0ce0bfSmrgEXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. 4280b0ce0bfSmrg 4290b0ce0bfSmrg# Allow overriding, eg assuming that you follow the convention of 4300b0ce0bfSmrg# putting '$debug_cmd' at the start of all your functions, you can get 4310b0ce0bfSmrg# bash to show function call trace with: 4320b0ce0bfSmrg# 4330b0ce0bfSmrg# debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name 4340b0ce0bfSmrgdebug_cmd=${debug_cmd-":"} 4350b0ce0bfSmrgexit_cmd=: 4360b0ce0bfSmrg 4370b0ce0bfSmrg# By convention, finish your script with: 4380b0ce0bfSmrg# 4390b0ce0bfSmrg# exit $exit_status 4400b0ce0bfSmrg# 4410b0ce0bfSmrg# so that you can set exit_status to non-zero if you want to indicate 4420b0ce0bfSmrg# something went wrong during execution without actually bailing out at 4430b0ce0bfSmrg# the point of failure. 4440b0ce0bfSmrgexit_status=$EXIT_SUCCESS 4451b12faf6Smrg 4460b0ce0bfSmrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh 4470b0ce0bfSmrg# is ksh but when the shell is invoked as "sh" and the current value of 4480b0ce0bfSmrg# the _XPG environment variable is not equal to 1 (one), the special 4490b0ce0bfSmrg# positional parameter $0, within a function call, is the name of the 4500b0ce0bfSmrg# function. 4510b0ce0bfSmrgprogpath=$0 4520b0ce0bfSmrg 4530b0ce0bfSmrg# The name of this program. 4540b0ce0bfSmrgprogname=`$ECHO "$progpath" |$SED "$sed_basename"` 4551b12faf6Smrg 4560b0ce0bfSmrg# Make sure we have an absolute progpath for reexecution: 4571b12faf6Smrgcase $progpath in 4581b12faf6Smrg [\\/]*|[A-Za-z]:\\*) ;; 4591b12faf6Smrg *[\\/]*) 4600b0ce0bfSmrg progdir=`$ECHO "$progpath" |$SED "$sed_dirname"` 4611b12faf6Smrg progdir=`cd "$progdir" && pwd` 4620b0ce0bfSmrg progpath=$progdir/$progname 4631b12faf6Smrg ;; 4641b12faf6Smrg *) 4650b0ce0bfSmrg _G_IFS=$IFS 466e35d4d8eSmrg IFS=${PATH_SEPARATOR-:} 4671b12faf6Smrg for progdir in $PATH; do 4680b0ce0bfSmrg IFS=$_G_IFS 4691b12faf6Smrg test -x "$progdir/$progname" && break 4701b12faf6Smrg done 4710b0ce0bfSmrg IFS=$_G_IFS 4721b12faf6Smrg test -n "$progdir" || progdir=`pwd` 4730b0ce0bfSmrg progpath=$progdir/$progname 4741b12faf6Smrg ;; 4751b12faf6Smrgesac 4761b12faf6Smrg 4771b12faf6Smrg 4780b0ce0bfSmrg## ----------------- ## 4790b0ce0bfSmrg## Standard options. ## 4800b0ce0bfSmrg## ----------------- ## 481e35d4d8eSmrg 4820b0ce0bfSmrg# The following options affect the operation of the functions defined 4830b0ce0bfSmrg# below, and should be set appropriately depending on run-time para- 4840b0ce0bfSmrg# meters passed on the command line. 4851b12faf6Smrg 4861b12faf6Smrgopt_dry_run=false 4871b12faf6Smrgopt_quiet=false 4881b12faf6Smrgopt_verbose=false 4891b12faf6Smrg 4900b0ce0bfSmrg# Categories 'all' and 'none' are always available. Append any others 4910b0ce0bfSmrg# you will pass as the first argument to func_warning from your own 4920b0ce0bfSmrg# code. 4930b0ce0bfSmrgwarning_categories= 4941b12faf6Smrg 4950b0ce0bfSmrg# By default, display warnings according to 'opt_warning_types'. Set 4960b0ce0bfSmrg# 'warning_func' to ':' to elide all warnings, or func_fatal_error to 4970b0ce0bfSmrg# treat the next displayed warning as a fatal error. 4980b0ce0bfSmrgwarning_func=func_warn_and_continue 4991b12faf6Smrg 5000b0ce0bfSmrg# Set to 'all' to display all warnings, 'none' to suppress all 5010b0ce0bfSmrg# warnings, or a space delimited list of some subset of 5020b0ce0bfSmrg# 'warning_categories' to display only the listed warnings. 5030b0ce0bfSmrgopt_warning_types=all 5041b12faf6Smrg 505e35d4d8eSmrg 5060b0ce0bfSmrg## -------------------- ## 5070b0ce0bfSmrg## Resource management. ## 5080b0ce0bfSmrg## -------------------- ## 5091b12faf6Smrg 5100b0ce0bfSmrg# This section contains definitions for functions that each ensure a 5110b0ce0bfSmrg# particular resource (a file, or a non-empty configuration variable for 5120b0ce0bfSmrg# example) is available, and if appropriate to extract default values 5130b0ce0bfSmrg# from pertinent package files. Call them using their associated 5140b0ce0bfSmrg# 'require_*' variable to ensure that they are executed, at most, once. 5150b0ce0bfSmrg# 5160b0ce0bfSmrg# It's entirely deliberate that calling these functions can set 5170b0ce0bfSmrg# variables that don't obey the namespace limitations obeyed by the rest 5180b0ce0bfSmrg# of this file, in order that that they be as useful as possible to 5190b0ce0bfSmrg# callers. 5201b12faf6Smrg 5211b12faf6Smrg 5220b0ce0bfSmrg# require_term_colors 5230b0ce0bfSmrg# ------------------- 5240b0ce0bfSmrg# Allow display of bold text on terminals that support it. 5250b0ce0bfSmrgrequire_term_colors=func_require_term_colors 5260b0ce0bfSmrgfunc_require_term_colors () 5271b12faf6Smrg{ 5280b0ce0bfSmrg $debug_cmd 5290b0ce0bfSmrg 5300b0ce0bfSmrg test -t 1 && { 5310b0ce0bfSmrg # COLORTERM and USE_ANSI_COLORS environment variables take 5320b0ce0bfSmrg # precedence, because most terminfo databases neglect to describe 5330b0ce0bfSmrg # whether color sequences are supported. 5340b0ce0bfSmrg test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"} 5350b0ce0bfSmrg 5360b0ce0bfSmrg if test 1 = "$USE_ANSI_COLORS"; then 5370b0ce0bfSmrg # Standard ANSI escape sequences 5380b0ce0bfSmrg tc_reset='[0m' 5390b0ce0bfSmrg tc_bold='[1m'; tc_standout='[7m' 5400b0ce0bfSmrg tc_red='[31m'; tc_green='[32m' 5410b0ce0bfSmrg tc_blue='[34m'; tc_cyan='[36m' 5420b0ce0bfSmrg else 5430b0ce0bfSmrg # Otherwise trust the terminfo database after all. 5440b0ce0bfSmrg test -n "`tput sgr0 2>/dev/null`" && { 5450b0ce0bfSmrg tc_reset=`tput sgr0` 5460b0ce0bfSmrg test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold` 5470b0ce0bfSmrg tc_standout=$tc_bold 5480b0ce0bfSmrg test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso` 5490b0ce0bfSmrg test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1` 5500b0ce0bfSmrg test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2` 5510b0ce0bfSmrg test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4` 5520b0ce0bfSmrg test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5` 5530b0ce0bfSmrg } 5540b0ce0bfSmrg fi 5550b0ce0bfSmrg } 5561b12faf6Smrg 5570b0ce0bfSmrg require_term_colors=: 5581b12faf6Smrg} 5591b12faf6Smrg 5601b12faf6Smrg 5610b0ce0bfSmrg## ----------------- ## 5620b0ce0bfSmrg## Function library. ## 5630b0ce0bfSmrg## ----------------- ## 5641b12faf6Smrg 5650b0ce0bfSmrg# This section contains a variety of useful functions to call in your 5660b0ce0bfSmrg# scripts. Take note of the portable wrappers for features provided by 5670b0ce0bfSmrg# some modern shells, which will fall back to slower equivalents on 5680b0ce0bfSmrg# less featureful shells. 5691b12faf6Smrg 5700b0ce0bfSmrg 5710b0ce0bfSmrg# func_append VAR VALUE 5720b0ce0bfSmrg# --------------------- 5730b0ce0bfSmrg# Append VALUE onto the existing contents of VAR. 5740b0ce0bfSmrg 5750b0ce0bfSmrg # We should try to minimise forks, especially on Windows where they are 5760b0ce0bfSmrg # unreasonably slow, so skip the feature probes when bash or zsh are 5770b0ce0bfSmrg # being used: 5780b0ce0bfSmrg if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then 5790b0ce0bfSmrg : ${_G_HAVE_ARITH_OP="yes"} 5800b0ce0bfSmrg : ${_G_HAVE_XSI_OPS="yes"} 5810b0ce0bfSmrg # The += operator was introduced in bash 3.1 5820b0ce0bfSmrg case $BASH_VERSION in 5830b0ce0bfSmrg [12].* | 3.0 | 3.0*) ;; 5840b0ce0bfSmrg *) 5850b0ce0bfSmrg : ${_G_HAVE_PLUSEQ_OP="yes"} 5860b0ce0bfSmrg ;; 5870b0ce0bfSmrg esac 5880b0ce0bfSmrg fi 5890b0ce0bfSmrg 5900b0ce0bfSmrg # _G_HAVE_PLUSEQ_OP 5910b0ce0bfSmrg # Can be empty, in which case the shell is probed, "yes" if += is 5920b0ce0bfSmrg # useable or anything else if it does not work. 5930b0ce0bfSmrg test -z "$_G_HAVE_PLUSEQ_OP" \ 5940b0ce0bfSmrg && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \ 5950b0ce0bfSmrg && _G_HAVE_PLUSEQ_OP=yes 5960b0ce0bfSmrg 5970b0ce0bfSmrgif test yes = "$_G_HAVE_PLUSEQ_OP" 5980b0ce0bfSmrgthen 5990b0ce0bfSmrg # This is an XSI compatible shell, allowing a faster implementation... 6000b0ce0bfSmrg eval 'func_append () 6010b0ce0bfSmrg { 6020b0ce0bfSmrg $debug_cmd 6030b0ce0bfSmrg 6040b0ce0bfSmrg eval "$1+=\$2" 6050b0ce0bfSmrg }' 6060b0ce0bfSmrgelse 6070b0ce0bfSmrg # ...otherwise fall back to using expr, which is often a shell builtin. 6080b0ce0bfSmrg func_append () 6090b0ce0bfSmrg { 6100b0ce0bfSmrg $debug_cmd 6110b0ce0bfSmrg 6120b0ce0bfSmrg eval "$1=\$$1\$2" 6130b0ce0bfSmrg } 6140b0ce0bfSmrgfi 6150b0ce0bfSmrg 6160b0ce0bfSmrg 6170b0ce0bfSmrg# func_append_quoted VAR VALUE 6180b0ce0bfSmrg# ---------------------------- 6190b0ce0bfSmrg# Quote VALUE and append to the end of shell variable VAR, separated 6200b0ce0bfSmrg# by a space. 6210b0ce0bfSmrgif test yes = "$_G_HAVE_PLUSEQ_OP"; then 6220b0ce0bfSmrg eval 'func_append_quoted () 6230b0ce0bfSmrg { 6240b0ce0bfSmrg $debug_cmd 6250b0ce0bfSmrg 6260b0ce0bfSmrg func_quote_arg pretty "$2" 6270b0ce0bfSmrg eval "$1+=\\ \$func_quote_arg_result" 6280b0ce0bfSmrg }' 6290b0ce0bfSmrgelse 6300b0ce0bfSmrg func_append_quoted () 6310b0ce0bfSmrg { 6320b0ce0bfSmrg $debug_cmd 6330b0ce0bfSmrg 6340b0ce0bfSmrg func_quote_arg pretty "$2" 6350b0ce0bfSmrg eval "$1=\$$1\\ \$func_quote_arg_result" 6360b0ce0bfSmrg } 6370b0ce0bfSmrgfi 6380b0ce0bfSmrg 6390b0ce0bfSmrg 6400b0ce0bfSmrg# func_append_uniq VAR VALUE 6410b0ce0bfSmrg# -------------------------- 6420b0ce0bfSmrg# Append unique VALUE onto the existing contents of VAR, assuming 6430b0ce0bfSmrg# entries are delimited by the first character of VALUE. For example: 6440b0ce0bfSmrg# 6450b0ce0bfSmrg# func_append_uniq options " --another-option option-argument" 6460b0ce0bfSmrg# 6470b0ce0bfSmrg# will only append to $options if " --another-option option-argument " 6480b0ce0bfSmrg# is not already present somewhere in $options already (note spaces at 6490b0ce0bfSmrg# each end implied by leading space in second argument). 6500b0ce0bfSmrgfunc_append_uniq () 6510b0ce0bfSmrg{ 6520b0ce0bfSmrg $debug_cmd 6530b0ce0bfSmrg 6540b0ce0bfSmrg eval _G_current_value='`$ECHO $'$1'`' 6550b0ce0bfSmrg _G_delim=`expr "$2" : '\(.\)'` 6560b0ce0bfSmrg 6570b0ce0bfSmrg case $_G_delim$_G_current_value$_G_delim in 6580b0ce0bfSmrg *"$2$_G_delim"*) ;; 6590b0ce0bfSmrg *) func_append "$@" ;; 6600b0ce0bfSmrg esac 6610b0ce0bfSmrg} 6620b0ce0bfSmrg 6630b0ce0bfSmrg 6640b0ce0bfSmrg# func_arith TERM... 6650b0ce0bfSmrg# ------------------ 6660b0ce0bfSmrg# Set func_arith_result to the result of evaluating TERMs. 6670b0ce0bfSmrg test -z "$_G_HAVE_ARITH_OP" \ 6680b0ce0bfSmrg && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \ 6690b0ce0bfSmrg && _G_HAVE_ARITH_OP=yes 6700b0ce0bfSmrg 6710b0ce0bfSmrgif test yes = "$_G_HAVE_ARITH_OP"; then 6720b0ce0bfSmrg eval 'func_arith () 6730b0ce0bfSmrg { 6740b0ce0bfSmrg $debug_cmd 6750b0ce0bfSmrg 6760b0ce0bfSmrg func_arith_result=$(( $* )) 6770b0ce0bfSmrg }' 6780b0ce0bfSmrgelse 6790b0ce0bfSmrg func_arith () 6800b0ce0bfSmrg { 6810b0ce0bfSmrg $debug_cmd 6820b0ce0bfSmrg 6830b0ce0bfSmrg func_arith_result=`expr "$@"` 6840b0ce0bfSmrg } 6850b0ce0bfSmrgfi 6860b0ce0bfSmrg 6870b0ce0bfSmrg 6880b0ce0bfSmrg# func_basename FILE 6890b0ce0bfSmrg# ------------------ 6900b0ce0bfSmrg# Set func_basename_result to FILE with everything up to and including 6910b0ce0bfSmrg# the last / stripped. 6920b0ce0bfSmrgif test yes = "$_G_HAVE_XSI_OPS"; then 6930b0ce0bfSmrg # If this shell supports suffix pattern removal, then use it to avoid 6940b0ce0bfSmrg # forking. Hide the definitions single quotes in case the shell chokes 6950b0ce0bfSmrg # on unsupported syntax... 6960b0ce0bfSmrg _b='func_basename_result=${1##*/}' 6970b0ce0bfSmrg _d='case $1 in 6980b0ce0bfSmrg */*) func_dirname_result=${1%/*}$2 ;; 6990b0ce0bfSmrg * ) func_dirname_result=$3 ;; 7000b0ce0bfSmrg esac' 7010b0ce0bfSmrg 7020b0ce0bfSmrgelse 7030b0ce0bfSmrg # ...otherwise fall back to using sed. 7040b0ce0bfSmrg _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`' 7050b0ce0bfSmrg _d='func_dirname_result=`$ECHO "$1" |$SED "$sed_dirname"` 7060b0ce0bfSmrg if test "X$func_dirname_result" = "X$1"; then 7070b0ce0bfSmrg func_dirname_result=$3 7080b0ce0bfSmrg else 7090b0ce0bfSmrg func_append func_dirname_result "$2" 7100b0ce0bfSmrg fi' 7110b0ce0bfSmrgfi 7120b0ce0bfSmrg 7130b0ce0bfSmrgeval 'func_basename () 7141b12faf6Smrg{ 7150b0ce0bfSmrg $debug_cmd 7160b0ce0bfSmrg 7170b0ce0bfSmrg '"$_b"' 7180b0ce0bfSmrg}' 7191b12faf6Smrg 7201b12faf6Smrg 7210b0ce0bfSmrg# func_dirname FILE APPEND NONDIR_REPLACEMENT 7220b0ce0bfSmrg# ------------------------------------------- 7230b0ce0bfSmrg# Compute the dirname of FILE. If nonempty, add APPEND to the result, 7240b0ce0bfSmrg# otherwise set result to NONDIR_REPLACEMENT. 7250b0ce0bfSmrgeval 'func_dirname () 7260b0ce0bfSmrg{ 7270b0ce0bfSmrg $debug_cmd 7280b0ce0bfSmrg 7290b0ce0bfSmrg '"$_d"' 7300b0ce0bfSmrg}' 7310b0ce0bfSmrg 7320b0ce0bfSmrg 7330b0ce0bfSmrg# func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT 7340b0ce0bfSmrg# -------------------------------------------------------- 7350b0ce0bfSmrg# Perform func_basename and func_dirname in a single function 7360b0ce0bfSmrg# call: 7370b0ce0bfSmrg# dirname: Compute the dirname of FILE. If nonempty, 7380b0ce0bfSmrg# add APPEND to the result, otherwise set result 7390b0ce0bfSmrg# to NONDIR_REPLACEMENT. 7400b0ce0bfSmrg# value returned in "$func_dirname_result" 7410b0ce0bfSmrg# basename: Compute filename of FILE. 7420b0ce0bfSmrg# value retuned in "$func_basename_result" 7430b0ce0bfSmrg# For efficiency, we do not delegate to the functions above but instead 7440b0ce0bfSmrg# duplicate the functionality here. 7450b0ce0bfSmrgeval 'func_dirname_and_basename () 7460b0ce0bfSmrg{ 7470b0ce0bfSmrg $debug_cmd 7480b0ce0bfSmrg 7490b0ce0bfSmrg '"$_b"' 7500b0ce0bfSmrg '"$_d"' 7510b0ce0bfSmrg}' 7520b0ce0bfSmrg 7530b0ce0bfSmrg 7540b0ce0bfSmrg# func_echo ARG... 7550b0ce0bfSmrg# ---------------- 7560b0ce0bfSmrg# Echo program name prefixed message. 7570b0ce0bfSmrgfunc_echo () 7580b0ce0bfSmrg{ 7590b0ce0bfSmrg $debug_cmd 7600b0ce0bfSmrg 7610b0ce0bfSmrg _G_message=$* 7620b0ce0bfSmrg 7630b0ce0bfSmrg func_echo_IFS=$IFS 7640b0ce0bfSmrg IFS=$nl 7650b0ce0bfSmrg for _G_line in $_G_message; do 7660b0ce0bfSmrg IFS=$func_echo_IFS 7670b0ce0bfSmrg $ECHO "$progname: $_G_line" 7680b0ce0bfSmrg done 7690b0ce0bfSmrg IFS=$func_echo_IFS 7700b0ce0bfSmrg} 7710b0ce0bfSmrg 7720b0ce0bfSmrg 7730b0ce0bfSmrg# func_echo_all ARG... 7740b0ce0bfSmrg# -------------------- 7750b0ce0bfSmrg# Invoke $ECHO with all args, space-separated. 7760b0ce0bfSmrgfunc_echo_all () 7770b0ce0bfSmrg{ 7780b0ce0bfSmrg $ECHO "$*" 7790b0ce0bfSmrg} 7800b0ce0bfSmrg 7810b0ce0bfSmrg 7820b0ce0bfSmrg# func_echo_infix_1 INFIX ARG... 7830b0ce0bfSmrg# ------------------------------ 7840b0ce0bfSmrg# Echo program name, followed by INFIX on the first line, with any 7850b0ce0bfSmrg# additional lines not showing INFIX. 7860b0ce0bfSmrgfunc_echo_infix_1 () 7870b0ce0bfSmrg{ 7880b0ce0bfSmrg $debug_cmd 7890b0ce0bfSmrg 7900b0ce0bfSmrg $require_term_colors 7910b0ce0bfSmrg 7920b0ce0bfSmrg _G_infix=$1; shift 7930b0ce0bfSmrg _G_indent=$_G_infix 7940b0ce0bfSmrg _G_prefix="$progname: $_G_infix: " 7950b0ce0bfSmrg _G_message=$* 7960b0ce0bfSmrg 7970b0ce0bfSmrg # Strip color escape sequences before counting printable length 7980b0ce0bfSmrg for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan" 7990b0ce0bfSmrg do 8000b0ce0bfSmrg test -n "$_G_tc" && { 8010b0ce0bfSmrg _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"` 8020b0ce0bfSmrg _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"` 8030b0ce0bfSmrg } 8040b0ce0bfSmrg done 8050b0ce0bfSmrg _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`" " ## exclude from sc_prohibit_nested_quotes 8060b0ce0bfSmrg 8070b0ce0bfSmrg func_echo_infix_1_IFS=$IFS 8080b0ce0bfSmrg IFS=$nl 8090b0ce0bfSmrg for _G_line in $_G_message; do 8100b0ce0bfSmrg IFS=$func_echo_infix_1_IFS 8110b0ce0bfSmrg $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2 8120b0ce0bfSmrg _G_prefix=$_G_indent 8130b0ce0bfSmrg done 8140b0ce0bfSmrg IFS=$func_echo_infix_1_IFS 8150b0ce0bfSmrg} 8160b0ce0bfSmrg 8170b0ce0bfSmrg 8180b0ce0bfSmrg# func_error ARG... 8190b0ce0bfSmrg# ----------------- 8200b0ce0bfSmrg# Echo program name prefixed message to standard error. 8210b0ce0bfSmrgfunc_error () 8220b0ce0bfSmrg{ 8230b0ce0bfSmrg $debug_cmd 8240b0ce0bfSmrg 8250b0ce0bfSmrg $require_term_colors 8260b0ce0bfSmrg 8270b0ce0bfSmrg func_echo_infix_1 " $tc_standout${tc_red}error$tc_reset" "$*" >&2 8280b0ce0bfSmrg} 8290b0ce0bfSmrg 8300b0ce0bfSmrg 8310b0ce0bfSmrg# func_fatal_error ARG... 8320b0ce0bfSmrg# ----------------------- 8330b0ce0bfSmrg# Echo program name prefixed message to standard error, and exit. 8340b0ce0bfSmrgfunc_fatal_error () 8350b0ce0bfSmrg{ 8360b0ce0bfSmrg $debug_cmd 8370b0ce0bfSmrg 8380b0ce0bfSmrg func_error "$*" 8390b0ce0bfSmrg exit $EXIT_FAILURE 8400b0ce0bfSmrg} 8410b0ce0bfSmrg 8420b0ce0bfSmrg 8430b0ce0bfSmrg# func_grep EXPRESSION FILENAME 8440b0ce0bfSmrg# ----------------------------- 8450b0ce0bfSmrg# Check whether EXPRESSION matches any line of FILENAME, without output. 8460b0ce0bfSmrgfunc_grep () 8470b0ce0bfSmrg{ 8480b0ce0bfSmrg $debug_cmd 8490b0ce0bfSmrg 8500b0ce0bfSmrg $GREP "$1" "$2" >/dev/null 2>&1 8510b0ce0bfSmrg} 8520b0ce0bfSmrg 8530b0ce0bfSmrg 8540b0ce0bfSmrg# func_len STRING 8550b0ce0bfSmrg# --------------- 8560b0ce0bfSmrg# Set func_len_result to the length of STRING. STRING may not 8570b0ce0bfSmrg# start with a hyphen. 8580b0ce0bfSmrg test -z "$_G_HAVE_XSI_OPS" \ 8590b0ce0bfSmrg && (eval 'x=a/b/c; 8600b0ce0bfSmrg test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ 8610b0ce0bfSmrg && _G_HAVE_XSI_OPS=yes 8620b0ce0bfSmrg 8630b0ce0bfSmrgif test yes = "$_G_HAVE_XSI_OPS"; then 8640b0ce0bfSmrg eval 'func_len () 8650b0ce0bfSmrg { 8660b0ce0bfSmrg $debug_cmd 8670b0ce0bfSmrg 8680b0ce0bfSmrg func_len_result=${#1} 8690b0ce0bfSmrg }' 8700b0ce0bfSmrgelse 8710b0ce0bfSmrg func_len () 8720b0ce0bfSmrg { 8730b0ce0bfSmrg $debug_cmd 8740b0ce0bfSmrg 8750b0ce0bfSmrg func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len` 8760b0ce0bfSmrg } 8770b0ce0bfSmrgfi 8780b0ce0bfSmrg 8790b0ce0bfSmrg 8800b0ce0bfSmrg# func_mkdir_p DIRECTORY-PATH 8810b0ce0bfSmrg# --------------------------- 8820b0ce0bfSmrg# Make sure the entire path to DIRECTORY-PATH is available. 8830b0ce0bfSmrgfunc_mkdir_p () 8840b0ce0bfSmrg{ 8850b0ce0bfSmrg $debug_cmd 8860b0ce0bfSmrg 8870b0ce0bfSmrg _G_directory_path=$1 8880b0ce0bfSmrg _G_dir_list= 8890b0ce0bfSmrg 8900b0ce0bfSmrg if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then 8910b0ce0bfSmrg 8920b0ce0bfSmrg # Protect directory names starting with '-' 8930b0ce0bfSmrg case $_G_directory_path in 8940b0ce0bfSmrg -*) _G_directory_path=./$_G_directory_path ;; 8951b12faf6Smrg esac 8961b12faf6Smrg 8971b12faf6Smrg # While some portion of DIR does not yet exist... 8980b0ce0bfSmrg while test ! -d "$_G_directory_path"; do 8991b12faf6Smrg # ...make a list in topmost first order. Use a colon delimited 9001b12faf6Smrg # list incase some portion of path contains whitespace. 9010b0ce0bfSmrg _G_dir_list=$_G_directory_path:$_G_dir_list 9021b12faf6Smrg 9031b12faf6Smrg # If the last portion added has no slash in it, the list is done 9040b0ce0bfSmrg case $_G_directory_path in */*) ;; *) break ;; esac 9051b12faf6Smrg 9061b12faf6Smrg # ...otherwise throw away the child directory and loop 9070b0ce0bfSmrg _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"` 9081b12faf6Smrg done 9090b0ce0bfSmrg _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'` 9101b12faf6Smrg 9110b0ce0bfSmrg func_mkdir_p_IFS=$IFS; IFS=: 9120b0ce0bfSmrg for _G_dir in $_G_dir_list; do 9130b0ce0bfSmrg IFS=$func_mkdir_p_IFS 9140b0ce0bfSmrg # mkdir can fail with a 'File exist' error if two processes 9151b12faf6Smrg # try to create one of the directories concurrently. Don't 9161b12faf6Smrg # stop in that case! 9170b0ce0bfSmrg $MKDIR "$_G_dir" 2>/dev/null || : 9181b12faf6Smrg done 9190b0ce0bfSmrg IFS=$func_mkdir_p_IFS 9201b12faf6Smrg 9211b12faf6Smrg # Bail out if we (or some other process) failed to create a directory. 9220b0ce0bfSmrg test -d "$_G_directory_path" || \ 9230b0ce0bfSmrg func_fatal_error "Failed to create '$1'" 9241b12faf6Smrg fi 9251b12faf6Smrg} 92632b578d3Smrg 92732b578d3Smrg 9280b0ce0bfSmrg# func_mktempdir [BASENAME] 9290b0ce0bfSmrg# ------------------------- 93032b578d3Smrg# Make a temporary directory that won't clash with other running 93132b578d3Smrg# libtool processes, and avoids race conditions if possible. If 9320b0ce0bfSmrg# given, BASENAME is the basename for that directory. 93332b578d3Smrgfunc_mktempdir () 93432b578d3Smrg{ 9350b0ce0bfSmrg $debug_cmd 93632b578d3Smrg 9370b0ce0bfSmrg _G_template=${TMPDIR-/tmp}/${1-$progname} 9380b0ce0bfSmrg 9390b0ce0bfSmrg if test : = "$opt_dry_run"; then 94032b578d3Smrg # Return a directory name, but don't create it in dry-run mode 9410b0ce0bfSmrg _G_tmpdir=$_G_template-$$ 94232b578d3Smrg else 94332b578d3Smrg 94432b578d3Smrg # If mktemp works, use that first and foremost 9450b0ce0bfSmrg _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null` 94632b578d3Smrg 9470b0ce0bfSmrg if test ! -d "$_G_tmpdir"; then 9481b12faf6Smrg # Failing that, at least try and use $RANDOM to avoid a race 9490b0ce0bfSmrg _G_tmpdir=$_G_template-${RANDOM-0}$$ 95032b578d3Smrg 9510b0ce0bfSmrg func_mktempdir_umask=`umask` 9521b12faf6Smrg umask 0077 9530b0ce0bfSmrg $MKDIR "$_G_tmpdir" 9540b0ce0bfSmrg umask $func_mktempdir_umask 95532b578d3Smrg fi 95632b578d3Smrg 95732b578d3Smrg # If we're not in dry-run mode, bomb out on failure 9580b0ce0bfSmrg test -d "$_G_tmpdir" || \ 9590b0ce0bfSmrg func_fatal_error "cannot create temporary directory '$_G_tmpdir'" 96032b578d3Smrg fi 96132b578d3Smrg 9620b0ce0bfSmrg $ECHO "$_G_tmpdir" 96332b578d3Smrg} 96432b578d3Smrg 96532b578d3Smrg 9660b0ce0bfSmrg# func_normal_abspath PATH 9670b0ce0bfSmrg# ------------------------ 9680b0ce0bfSmrg# Remove doubled-up and trailing slashes, "." path components, 9690b0ce0bfSmrg# and cancel out any ".." path components in PATH after making 9700b0ce0bfSmrg# it an absolute path. 9710b0ce0bfSmrgfunc_normal_abspath () 97232b578d3Smrg{ 9730b0ce0bfSmrg $debug_cmd 9740b0ce0bfSmrg 9750b0ce0bfSmrg # These SED scripts presuppose an absolute path with a trailing slash. 9760b0ce0bfSmrg _G_pathcar='s|^/\([^/]*\).*$|\1|' 9770b0ce0bfSmrg _G_pathcdr='s|^/[^/]*||' 9780b0ce0bfSmrg _G_removedotparts=':dotsl 9790b0ce0bfSmrg s|/\./|/|g 9800b0ce0bfSmrg t dotsl 9810b0ce0bfSmrg s|/\.$|/|' 9820b0ce0bfSmrg _G_collapseslashes='s|/\{1,\}|/|g' 9830b0ce0bfSmrg _G_finalslash='s|/*$|/|' 9840b0ce0bfSmrg 9850b0ce0bfSmrg # Start from root dir and reassemble the path. 9860b0ce0bfSmrg func_normal_abspath_result= 9870b0ce0bfSmrg func_normal_abspath_tpath=$1 9880b0ce0bfSmrg func_normal_abspath_altnamespace= 9890b0ce0bfSmrg case $func_normal_abspath_tpath in 9900b0ce0bfSmrg "") 9910b0ce0bfSmrg # Empty path, that just means $cwd. 9920b0ce0bfSmrg func_stripname '' '/' "`pwd`" 9930b0ce0bfSmrg func_normal_abspath_result=$func_stripname_result 9940b0ce0bfSmrg return 9950b0ce0bfSmrg ;; 9960b0ce0bfSmrg # The next three entries are used to spot a run of precisely 9970b0ce0bfSmrg # two leading slashes without using negated character classes; 9980b0ce0bfSmrg # we take advantage of case's first-match behaviour. 9990b0ce0bfSmrg ///*) 10000b0ce0bfSmrg # Unusual form of absolute path, do nothing. 10010b0ce0bfSmrg ;; 10020b0ce0bfSmrg //*) 10030b0ce0bfSmrg # Not necessarily an ordinary path; POSIX reserves leading '//' 10040b0ce0bfSmrg # and for example Cygwin uses it to access remote file shares 10050b0ce0bfSmrg # over CIFS/SMB, so we conserve a leading double slash if found. 10060b0ce0bfSmrg func_normal_abspath_altnamespace=/ 10070b0ce0bfSmrg ;; 10080b0ce0bfSmrg /*) 10090b0ce0bfSmrg # Absolute path, do nothing. 10100b0ce0bfSmrg ;; 10111b12faf6Smrg *) 10120b0ce0bfSmrg # Relative path, prepend $cwd. 10130b0ce0bfSmrg func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath 10140b0ce0bfSmrg ;; 10151b12faf6Smrg esac 10161b12faf6Smrg 10170b0ce0bfSmrg # Cancel out all the simple stuff to save iterations. We also want 10180b0ce0bfSmrg # the path to end with a slash for ease of parsing, so make sure 10190b0ce0bfSmrg # there is one (and only one) here. 10200b0ce0bfSmrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 10210b0ce0bfSmrg -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"` 10220b0ce0bfSmrg while :; do 10230b0ce0bfSmrg # Processed it all yet? 10240b0ce0bfSmrg if test / = "$func_normal_abspath_tpath"; then 10250b0ce0bfSmrg # If we ascended to the root using ".." the result may be empty now. 10260b0ce0bfSmrg if test -z "$func_normal_abspath_result"; then 10270b0ce0bfSmrg func_normal_abspath_result=/ 10280b0ce0bfSmrg fi 10290b0ce0bfSmrg break 10300b0ce0bfSmrg fi 10310b0ce0bfSmrg func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ 10320b0ce0bfSmrg -e "$_G_pathcar"` 10330b0ce0bfSmrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 10340b0ce0bfSmrg -e "$_G_pathcdr"` 10350b0ce0bfSmrg # Figure out what to do with it 10360b0ce0bfSmrg case $func_normal_abspath_tcomponent in 10370b0ce0bfSmrg "") 10380b0ce0bfSmrg # Trailing empty path component, ignore it. 10390b0ce0bfSmrg ;; 10400b0ce0bfSmrg ..) 10410b0ce0bfSmrg # Parent dir; strip last assembled component from result. 10420b0ce0bfSmrg func_dirname "$func_normal_abspath_result" 10430b0ce0bfSmrg func_normal_abspath_result=$func_dirname_result 10440b0ce0bfSmrg ;; 10450b0ce0bfSmrg *) 10460b0ce0bfSmrg # Actual path component, append it. 10470b0ce0bfSmrg func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent" 10480b0ce0bfSmrg ;; 10490b0ce0bfSmrg esac 10500b0ce0bfSmrg done 10510b0ce0bfSmrg # Restore leading double-slash if one was found on entry. 10520b0ce0bfSmrg func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result 10530b0ce0bfSmrg} 10540b0ce0bfSmrg 10550b0ce0bfSmrg 10560b0ce0bfSmrg# func_notquiet ARG... 10570b0ce0bfSmrg# -------------------- 10580b0ce0bfSmrg# Echo program name prefixed message only when not in quiet mode. 10590b0ce0bfSmrgfunc_notquiet () 10600b0ce0bfSmrg{ 10610b0ce0bfSmrg $debug_cmd 10620b0ce0bfSmrg 10630b0ce0bfSmrg $opt_quiet || func_echo ${1+"$@"} 10640b0ce0bfSmrg 10650b0ce0bfSmrg # A bug in bash halts the script if the last line of a function 10660b0ce0bfSmrg # fails when set -e is in force, so we need another command to 10670b0ce0bfSmrg # work around that: 10680b0ce0bfSmrg : 10690b0ce0bfSmrg} 10700b0ce0bfSmrg 10710b0ce0bfSmrg 10720b0ce0bfSmrg# func_relative_path SRCDIR DSTDIR 10730b0ce0bfSmrg# -------------------------------- 10740b0ce0bfSmrg# Set func_relative_path_result to the relative path from SRCDIR to DSTDIR. 10750b0ce0bfSmrgfunc_relative_path () 10760b0ce0bfSmrg{ 10770b0ce0bfSmrg $debug_cmd 10780b0ce0bfSmrg 10790b0ce0bfSmrg func_relative_path_result= 10800b0ce0bfSmrg func_normal_abspath "$1" 10810b0ce0bfSmrg func_relative_path_tlibdir=$func_normal_abspath_result 10820b0ce0bfSmrg func_normal_abspath "$2" 10830b0ce0bfSmrg func_relative_path_tbindir=$func_normal_abspath_result 10840b0ce0bfSmrg 10850b0ce0bfSmrg # Ascend the tree starting from libdir 10860b0ce0bfSmrg while :; do 10870b0ce0bfSmrg # check if we have found a prefix of bindir 10880b0ce0bfSmrg case $func_relative_path_tbindir in 10890b0ce0bfSmrg $func_relative_path_tlibdir) 10900b0ce0bfSmrg # found an exact match 10910b0ce0bfSmrg func_relative_path_tcancelled= 10920b0ce0bfSmrg break 10930b0ce0bfSmrg ;; 10940b0ce0bfSmrg $func_relative_path_tlibdir*) 10950b0ce0bfSmrg # found a matching prefix 10960b0ce0bfSmrg func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" 10970b0ce0bfSmrg func_relative_path_tcancelled=$func_stripname_result 10980b0ce0bfSmrg if test -z "$func_relative_path_result"; then 10990b0ce0bfSmrg func_relative_path_result=. 11000b0ce0bfSmrg fi 11010b0ce0bfSmrg break 11020b0ce0bfSmrg ;; 11030b0ce0bfSmrg *) 11040b0ce0bfSmrg func_dirname $func_relative_path_tlibdir 11050b0ce0bfSmrg func_relative_path_tlibdir=$func_dirname_result 11060b0ce0bfSmrg if test -z "$func_relative_path_tlibdir"; then 11070b0ce0bfSmrg # Have to descend all the way to the root! 11080b0ce0bfSmrg func_relative_path_result=../$func_relative_path_result 11090b0ce0bfSmrg func_relative_path_tcancelled=$func_relative_path_tbindir 11100b0ce0bfSmrg break 11110b0ce0bfSmrg fi 11120b0ce0bfSmrg func_relative_path_result=../$func_relative_path_result 11130b0ce0bfSmrg ;; 11140b0ce0bfSmrg esac 11150b0ce0bfSmrg done 11160b0ce0bfSmrg 11170b0ce0bfSmrg # Now calculate path; take care to avoid doubling-up slashes. 11180b0ce0bfSmrg func_stripname '' '/' "$func_relative_path_result" 11190b0ce0bfSmrg func_relative_path_result=$func_stripname_result 11200b0ce0bfSmrg func_stripname '/' '/' "$func_relative_path_tcancelled" 11210b0ce0bfSmrg if test -n "$func_stripname_result"; then 11220b0ce0bfSmrg func_append func_relative_path_result "/$func_stripname_result" 11230b0ce0bfSmrg fi 11240b0ce0bfSmrg 11250b0ce0bfSmrg # Normalisation. If bindir is libdir, return '.' else relative path. 11260b0ce0bfSmrg if test -n "$func_relative_path_result"; then 11270b0ce0bfSmrg func_stripname './' '' "$func_relative_path_result" 11280b0ce0bfSmrg func_relative_path_result=$func_stripname_result 11290b0ce0bfSmrg fi 11300b0ce0bfSmrg 11310b0ce0bfSmrg test -n "$func_relative_path_result" || func_relative_path_result=. 11320b0ce0bfSmrg 11330b0ce0bfSmrg : 11340b0ce0bfSmrg} 11350b0ce0bfSmrg 11360b0ce0bfSmrg 11370b0ce0bfSmrg# func_quote_portable EVAL ARG 11380b0ce0bfSmrg# ---------------------------- 11390b0ce0bfSmrg# Internal function to portably implement func_quote_arg. Note that we still 11400b0ce0bfSmrg# keep attention to performance here so we as much as possible try to avoid 11410b0ce0bfSmrg# calling sed binary (so far O(N) complexity as long as func_append is O(1)). 11420b0ce0bfSmrgfunc_quote_portable () 11430b0ce0bfSmrg{ 11440b0ce0bfSmrg $debug_cmd 11450b0ce0bfSmrg 11460b0ce0bfSmrg $require_check_ifs_backslash 11470b0ce0bfSmrg 11480b0ce0bfSmrg func_quote_portable_result=$2 11490b0ce0bfSmrg 11500b0ce0bfSmrg # one-time-loop (easy break) 11510b0ce0bfSmrg while true 11520b0ce0bfSmrg do 11530b0ce0bfSmrg if $1; then 11540b0ce0bfSmrg func_quote_portable_result=`$ECHO "$2" | $SED \ 11550b0ce0bfSmrg -e "$sed_double_quote_subst" -e "$sed_double_backslash"` 11560b0ce0bfSmrg break 11570b0ce0bfSmrg fi 11580b0ce0bfSmrg 11590b0ce0bfSmrg # Quote for eval. 11600b0ce0bfSmrg case $func_quote_portable_result in 11610b0ce0bfSmrg *[\\\`\"\$]*) 11620b0ce0bfSmrg # Fallback to sed for $func_check_bs_ifs_broken=:, or when the string 11630b0ce0bfSmrg # contains the shell wildcard characters. 11640b0ce0bfSmrg case $check_ifs_backshlash_broken$func_quote_portable_result in 11650b0ce0bfSmrg :*|*[\[\*\?]*) 11660b0ce0bfSmrg func_quote_portable_result=`$ECHO "$func_quote_portable_result" \ 11670b0ce0bfSmrg | $SED "$sed_quote_subst"` 11680b0ce0bfSmrg break 11690b0ce0bfSmrg ;; 11700b0ce0bfSmrg esac 11710b0ce0bfSmrg 11720b0ce0bfSmrg func_quote_portable_old_IFS=$IFS 11730b0ce0bfSmrg for _G_char in '\' '`' '"' '$' 11740b0ce0bfSmrg do 11750b0ce0bfSmrg # STATE($1) PREV($2) SEPARATOR($3) 11760b0ce0bfSmrg set start "" "" 11770b0ce0bfSmrg func_quote_portable_result=dummy"$_G_char$func_quote_portable_result$_G_char"dummy 11780b0ce0bfSmrg IFS=$_G_char 11790b0ce0bfSmrg for _G_part in $func_quote_portable_result 11800b0ce0bfSmrg do 11810b0ce0bfSmrg case $1 in 11820b0ce0bfSmrg quote) 11830b0ce0bfSmrg func_append func_quote_portable_result "$3$2" 11840b0ce0bfSmrg set quote "$_G_part" "\\$_G_char" 11850b0ce0bfSmrg ;; 11860b0ce0bfSmrg start) 11870b0ce0bfSmrg set first "" "" 11880b0ce0bfSmrg func_quote_portable_result= 11890b0ce0bfSmrg ;; 11900b0ce0bfSmrg first) 11910b0ce0bfSmrg set quote "$_G_part" "" 11920b0ce0bfSmrg ;; 11930b0ce0bfSmrg esac 11940b0ce0bfSmrg done 11950b0ce0bfSmrg done 11960b0ce0bfSmrg IFS=$func_quote_portable_old_IFS 11970b0ce0bfSmrg ;; 11980b0ce0bfSmrg *) ;; 11990b0ce0bfSmrg esac 12000b0ce0bfSmrg break 12010b0ce0bfSmrg done 12020b0ce0bfSmrg 12030b0ce0bfSmrg func_quote_portable_unquoted_result=$func_quote_portable_result 12040b0ce0bfSmrg case $func_quote_portable_result in 12050b0ce0bfSmrg # double-quote args containing shell metacharacters to delay 12060b0ce0bfSmrg # word splitting, command substitution and variable expansion 12070b0ce0bfSmrg # for a subsequent eval. 12080b0ce0bfSmrg # many bourne shells cannot handle close brackets correctly 12091b12faf6Smrg # in scan sets, so we specify it separately. 12101b12faf6Smrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 12110b0ce0bfSmrg func_quote_portable_result=\"$func_quote_portable_result\" 12120b0ce0bfSmrg ;; 12130b0ce0bfSmrg esac 12140b0ce0bfSmrg} 12150b0ce0bfSmrg 12160b0ce0bfSmrg 12170b0ce0bfSmrg# func_quotefast_eval ARG 12180b0ce0bfSmrg# ----------------------- 12190b0ce0bfSmrg# Quote one ARG (internal). This is equivalent to 'func_quote_arg eval ARG', 12200b0ce0bfSmrg# but optimized for speed. Result is stored in $func_quotefast_eval. 12210b0ce0bfSmrgif test xyes = `(x=; printf -v x %q yes; echo x"$x") 2>/dev/null`; then 12220b0ce0bfSmrg printf -v _GL_test_printf_tilde %q '~' 12230b0ce0bfSmrg if test '\~' = "$_GL_test_printf_tilde"; then 12240b0ce0bfSmrg func_quotefast_eval () 12250b0ce0bfSmrg { 12260b0ce0bfSmrg printf -v func_quotefast_eval_result %q "$1" 12270b0ce0bfSmrg } 12280b0ce0bfSmrg else 12290b0ce0bfSmrg # Broken older Bash implementations. Make those faster too if possible. 12300b0ce0bfSmrg func_quotefast_eval () 12310b0ce0bfSmrg { 12320b0ce0bfSmrg case $1 in 12330b0ce0bfSmrg '~'*) 12340b0ce0bfSmrg func_quote_portable false "$1" 12350b0ce0bfSmrg func_quotefast_eval_result=$func_quote_portable_result 12360b0ce0bfSmrg ;; 12370b0ce0bfSmrg *) 12380b0ce0bfSmrg printf -v func_quotefast_eval_result %q "$1" 12390b0ce0bfSmrg ;; 12400b0ce0bfSmrg esac 12410b0ce0bfSmrg } 12420b0ce0bfSmrg fi 12430b0ce0bfSmrgelse 12440b0ce0bfSmrg func_quotefast_eval () 12450b0ce0bfSmrg { 12460b0ce0bfSmrg func_quote_portable false "$1" 12470b0ce0bfSmrg func_quotefast_eval_result=$func_quote_portable_result 12480b0ce0bfSmrg } 12490b0ce0bfSmrgfi 12500b0ce0bfSmrg 12510b0ce0bfSmrg 12520b0ce0bfSmrg# func_quote_arg MODEs ARG 12530b0ce0bfSmrg# ------------------------ 12540b0ce0bfSmrg# Quote one ARG to be evaled later. MODEs argument may contain zero or more 12550b0ce0bfSmrg# specifiers listed below separated by ',' character. This function returns two 12560b0ce0bfSmrg# values: 12570b0ce0bfSmrg# i) func_quote_arg_result 12580b0ce0bfSmrg# double-quoted (when needed), suitable for a subsequent eval 12590b0ce0bfSmrg# ii) func_quote_arg_unquoted_result 12600b0ce0bfSmrg# has all characters that are still active within double 12610b0ce0bfSmrg# quotes backslashified. Available only if 'unquoted' is specified. 12620b0ce0bfSmrg# 12630b0ce0bfSmrg# Available modes: 12640b0ce0bfSmrg# ---------------- 12650b0ce0bfSmrg# 'eval' (default) 12660b0ce0bfSmrg# - escape shell special characters 12670b0ce0bfSmrg# 'expand' 12680b0ce0bfSmrg# - the same as 'eval'; but do not quote variable references 12690b0ce0bfSmrg# 'pretty' 12700b0ce0bfSmrg# - request aesthetic output, i.e. '"a b"' instead of 'a\ b'. This might 12710b0ce0bfSmrg# be used later in func_quote to get output like: 'echo "a b"' instead 12720b0ce0bfSmrg# of 'echo a\ b'. This is slower than default on some shells. 12730b0ce0bfSmrg# 'unquoted' 12740b0ce0bfSmrg# - produce also $func_quote_arg_unquoted_result which does not contain 12750b0ce0bfSmrg# wrapping double-quotes. 12760b0ce0bfSmrg# 12770b0ce0bfSmrg# Examples for 'func_quote_arg pretty,unquoted string': 12780b0ce0bfSmrg# 12790b0ce0bfSmrg# string | *_result | *_unquoted_result 12800b0ce0bfSmrg# ------------+-----------------------+------------------- 12810b0ce0bfSmrg# " | \" | \" 12820b0ce0bfSmrg# a b | "a b" | a b 12830b0ce0bfSmrg# "a b" | "\"a b\"" | \"a b\" 12840b0ce0bfSmrg# * | "*" | * 12850b0ce0bfSmrg# z="${x-$y}" | "z=\"\${x-\$y}\"" | z=\"\${x-\$y}\" 12860b0ce0bfSmrg# 12870b0ce0bfSmrg# Examples for 'func_quote_arg pretty,unquoted,expand string': 12880b0ce0bfSmrg# 12890b0ce0bfSmrg# string | *_result | *_unquoted_result 12900b0ce0bfSmrg# --------------+---------------------+-------------------- 12910b0ce0bfSmrg# z="${x-$y}" | "z=\"${x-$y}\"" | z=\"${x-$y}\" 12920b0ce0bfSmrgfunc_quote_arg () 12930b0ce0bfSmrg{ 12940b0ce0bfSmrg _G_quote_expand=false 12950b0ce0bfSmrg case ,$1, in 12960b0ce0bfSmrg *,expand,*) 12970b0ce0bfSmrg _G_quote_expand=: 12980b0ce0bfSmrg ;; 12990b0ce0bfSmrg esac 13000b0ce0bfSmrg 13010b0ce0bfSmrg case ,$1, in 13020b0ce0bfSmrg *,pretty,*|*,expand,*|*,unquoted,*) 13030b0ce0bfSmrg func_quote_portable $_G_quote_expand "$2" 13040b0ce0bfSmrg func_quote_arg_result=$func_quote_portable_result 13050b0ce0bfSmrg func_quote_arg_unquoted_result=$func_quote_portable_unquoted_result 13061b12faf6Smrg ;; 13071b12faf6Smrg *) 13080b0ce0bfSmrg # Faster quote-for-eval for some shells. 13090b0ce0bfSmrg func_quotefast_eval "$2" 13100b0ce0bfSmrg func_quote_arg_result=$func_quotefast_eval_result 13110b0ce0bfSmrg ;; 13120b0ce0bfSmrg esac 13130b0ce0bfSmrg} 13140b0ce0bfSmrg 13150b0ce0bfSmrg 13160b0ce0bfSmrg# func_quote MODEs ARGs... 13170b0ce0bfSmrg# ------------------------ 13180b0ce0bfSmrg# Quote all ARGs to be evaled later and join them into single command. See 13190b0ce0bfSmrg# func_quote_arg's description for more info. 13200b0ce0bfSmrgfunc_quote () 13210b0ce0bfSmrg{ 13220b0ce0bfSmrg $debug_cmd 13230b0ce0bfSmrg _G_func_quote_mode=$1 ; shift 13240b0ce0bfSmrg func_quote_result= 13250b0ce0bfSmrg while test 0 -lt $#; do 13260b0ce0bfSmrg func_quote_arg "$_G_func_quote_mode" "$1" 13270b0ce0bfSmrg if test -n "$func_quote_result"; then 13280b0ce0bfSmrg func_append func_quote_result " $func_quote_arg_result" 13290b0ce0bfSmrg else 13300b0ce0bfSmrg func_append func_quote_result "$func_quote_arg_result" 13310b0ce0bfSmrg fi 13320b0ce0bfSmrg shift 13330b0ce0bfSmrg done 13340b0ce0bfSmrg} 13350b0ce0bfSmrg 13360b0ce0bfSmrg 13370b0ce0bfSmrg# func_stripname PREFIX SUFFIX NAME 13380b0ce0bfSmrg# --------------------------------- 13390b0ce0bfSmrg# strip PREFIX and SUFFIX from NAME, and store in func_stripname_result. 13400b0ce0bfSmrg# PREFIX and SUFFIX must not contain globbing or regex special 13410b0ce0bfSmrg# characters, hashes, percent signs, but SUFFIX may contain a leading 13420b0ce0bfSmrg# dot (in which case that matches only a dot). 13430b0ce0bfSmrgif test yes = "$_G_HAVE_XSI_OPS"; then 13440b0ce0bfSmrg eval 'func_stripname () 13450b0ce0bfSmrg { 13460b0ce0bfSmrg $debug_cmd 13470b0ce0bfSmrg 13480b0ce0bfSmrg # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are 13490b0ce0bfSmrg # positional parameters, so assign one to ordinary variable first. 13500b0ce0bfSmrg func_stripname_result=$3 13510b0ce0bfSmrg func_stripname_result=${func_stripname_result#"$1"} 13520b0ce0bfSmrg func_stripname_result=${func_stripname_result%"$2"} 13530b0ce0bfSmrg }' 13540b0ce0bfSmrgelse 13550b0ce0bfSmrg func_stripname () 13560b0ce0bfSmrg { 13570b0ce0bfSmrg $debug_cmd 13580b0ce0bfSmrg 13590b0ce0bfSmrg case $2 in 13600b0ce0bfSmrg .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;; 13610b0ce0bfSmrg *) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;; 13620b0ce0bfSmrg esac 13630b0ce0bfSmrg } 13640b0ce0bfSmrgfi 13650b0ce0bfSmrg 13660b0ce0bfSmrg 13670b0ce0bfSmrg# func_show_eval CMD [FAIL_EXP] 13680b0ce0bfSmrg# ----------------------------- 13690b0ce0bfSmrg# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is 13700b0ce0bfSmrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 13710b0ce0bfSmrg# is given, then evaluate it. 13720b0ce0bfSmrgfunc_show_eval () 13730b0ce0bfSmrg{ 13740b0ce0bfSmrg $debug_cmd 13750b0ce0bfSmrg 13760b0ce0bfSmrg _G_cmd=$1 13770b0ce0bfSmrg _G_fail_exp=${2-':'} 13780b0ce0bfSmrg 13790b0ce0bfSmrg func_quote_arg pretty,expand "$_G_cmd" 13800b0ce0bfSmrg eval "func_notquiet $func_quote_arg_result" 13810b0ce0bfSmrg 13820b0ce0bfSmrg $opt_dry_run || { 13830b0ce0bfSmrg eval "$_G_cmd" 13840b0ce0bfSmrg _G_status=$? 13850b0ce0bfSmrg if test 0 -ne "$_G_status"; then 13860b0ce0bfSmrg eval "(exit $_G_status); $_G_fail_exp" 13870b0ce0bfSmrg fi 13880b0ce0bfSmrg } 13890b0ce0bfSmrg} 13900b0ce0bfSmrg 13910b0ce0bfSmrg 13920b0ce0bfSmrg# func_show_eval_locale CMD [FAIL_EXP] 13930b0ce0bfSmrg# ------------------------------------ 13940b0ce0bfSmrg# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is 13950b0ce0bfSmrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 13960b0ce0bfSmrg# is given, then evaluate it. Use the saved locale for evaluation. 13970b0ce0bfSmrgfunc_show_eval_locale () 13980b0ce0bfSmrg{ 13990b0ce0bfSmrg $debug_cmd 14000b0ce0bfSmrg 14010b0ce0bfSmrg _G_cmd=$1 14020b0ce0bfSmrg _G_fail_exp=${2-':'} 14030b0ce0bfSmrg 14040b0ce0bfSmrg $opt_quiet || { 14050b0ce0bfSmrg func_quote_arg expand,pretty "$_G_cmd" 14060b0ce0bfSmrg eval "func_echo $func_quote_arg_result" 14070b0ce0bfSmrg } 14080b0ce0bfSmrg 14090b0ce0bfSmrg $opt_dry_run || { 14100b0ce0bfSmrg eval "$_G_user_locale 14110b0ce0bfSmrg $_G_cmd" 14120b0ce0bfSmrg _G_status=$? 14130b0ce0bfSmrg eval "$_G_safe_locale" 14140b0ce0bfSmrg if test 0 -ne "$_G_status"; then 14150b0ce0bfSmrg eval "(exit $_G_status); $_G_fail_exp" 14160b0ce0bfSmrg fi 14170b0ce0bfSmrg } 14180b0ce0bfSmrg} 14190b0ce0bfSmrg 14200b0ce0bfSmrg 14210b0ce0bfSmrg# func_tr_sh 14220b0ce0bfSmrg# ---------- 14230b0ce0bfSmrg# Turn $1 into a string suitable for a shell variable name. 14240b0ce0bfSmrg# Result is stored in $func_tr_sh_result. All characters 14250b0ce0bfSmrg# not in the set a-zA-Z0-9_ are replaced with '_'. Further, 14260b0ce0bfSmrg# if $1 begins with a digit, a '_' is prepended as well. 14270b0ce0bfSmrgfunc_tr_sh () 14280b0ce0bfSmrg{ 14290b0ce0bfSmrg $debug_cmd 14300b0ce0bfSmrg 14310b0ce0bfSmrg case $1 in 14320b0ce0bfSmrg [0-9]* | *[!a-zA-Z0-9_]*) 14330b0ce0bfSmrg func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'` 14340b0ce0bfSmrg ;; 14350b0ce0bfSmrg * ) 14360b0ce0bfSmrg func_tr_sh_result=$1 14370b0ce0bfSmrg ;; 14380b0ce0bfSmrg esac 14390b0ce0bfSmrg} 14400b0ce0bfSmrg 14410b0ce0bfSmrg 14420b0ce0bfSmrg# func_verbose ARG... 14430b0ce0bfSmrg# ------------------- 14440b0ce0bfSmrg# Echo program name prefixed message in verbose mode only. 14450b0ce0bfSmrgfunc_verbose () 14460b0ce0bfSmrg{ 14470b0ce0bfSmrg $debug_cmd 14480b0ce0bfSmrg 14490b0ce0bfSmrg $opt_verbose && func_echo "$*" 14500b0ce0bfSmrg 14510b0ce0bfSmrg : 14520b0ce0bfSmrg} 14530b0ce0bfSmrg 14540b0ce0bfSmrg 14550b0ce0bfSmrg# func_warn_and_continue ARG... 14560b0ce0bfSmrg# ----------------------------- 14570b0ce0bfSmrg# Echo program name prefixed warning message to standard error. 14580b0ce0bfSmrgfunc_warn_and_continue () 14590b0ce0bfSmrg{ 14600b0ce0bfSmrg $debug_cmd 14610b0ce0bfSmrg 14620b0ce0bfSmrg $require_term_colors 14630b0ce0bfSmrg 14640b0ce0bfSmrg func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2 14650b0ce0bfSmrg} 14660b0ce0bfSmrg 14670b0ce0bfSmrg 14680b0ce0bfSmrg# func_warning CATEGORY ARG... 14690b0ce0bfSmrg# ---------------------------- 14700b0ce0bfSmrg# Echo program name prefixed warning message to standard error. Warning 14710b0ce0bfSmrg# messages can be filtered according to CATEGORY, where this function 14720b0ce0bfSmrg# elides messages where CATEGORY is not listed in the global variable 14730b0ce0bfSmrg# 'opt_warning_types'. 14740b0ce0bfSmrgfunc_warning () 14750b0ce0bfSmrg{ 14760b0ce0bfSmrg $debug_cmd 14770b0ce0bfSmrg 14780b0ce0bfSmrg # CATEGORY must be in the warning_categories list! 14790b0ce0bfSmrg case " $warning_categories " in 14800b0ce0bfSmrg *" $1 "*) ;; 14810b0ce0bfSmrg *) func_internal_error "invalid warning category '$1'" ;; 14820b0ce0bfSmrg esac 14830b0ce0bfSmrg 14840b0ce0bfSmrg _G_category=$1 14850b0ce0bfSmrg shift 14860b0ce0bfSmrg 14870b0ce0bfSmrg case " $opt_warning_types " in 14880b0ce0bfSmrg *" $_G_category "*) $warning_func ${1+"$@"} ;; 14890b0ce0bfSmrg esac 14900b0ce0bfSmrg} 14910b0ce0bfSmrg 14920b0ce0bfSmrg 14930b0ce0bfSmrg# func_sort_ver VER1 VER2 14940b0ce0bfSmrg# ----------------------- 14950b0ce0bfSmrg# 'sort -V' is not generally available. 14960b0ce0bfSmrg# Note this deviates from the version comparison in automake 14970b0ce0bfSmrg# in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a 14980b0ce0bfSmrg# but this should suffice as we won't be specifying old 14990b0ce0bfSmrg# version formats or redundant trailing .0 in bootstrap.conf. 15000b0ce0bfSmrg# If we did want full compatibility then we should probably 15010b0ce0bfSmrg# use m4_version_compare from autoconf. 15020b0ce0bfSmrgfunc_sort_ver () 15030b0ce0bfSmrg{ 15040b0ce0bfSmrg $debug_cmd 15050b0ce0bfSmrg 15060b0ce0bfSmrg printf '%s\n%s\n' "$1" "$2" \ 15070b0ce0bfSmrg | 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 15080b0ce0bfSmrg} 15090b0ce0bfSmrg 15100b0ce0bfSmrg# func_lt_ver PREV CURR 15110b0ce0bfSmrg# --------------------- 15120b0ce0bfSmrg# Return true if PREV and CURR are in the correct order according to 15130b0ce0bfSmrg# func_sort_ver, otherwise false. Use it like this: 15140b0ce0bfSmrg# 15150b0ce0bfSmrg# func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..." 15160b0ce0bfSmrgfunc_lt_ver () 15170b0ce0bfSmrg{ 15180b0ce0bfSmrg $debug_cmd 15190b0ce0bfSmrg 15200b0ce0bfSmrg test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q` 15210b0ce0bfSmrg} 15220b0ce0bfSmrg 15230b0ce0bfSmrg 15240b0ce0bfSmrg# Local variables: 15250b0ce0bfSmrg# mode: shell-script 15260b0ce0bfSmrg# sh-indentation: 2 15270b0ce0bfSmrg# eval: (add-hook 'before-save-hook 'time-stamp) 15280b0ce0bfSmrg# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" 15290b0ce0bfSmrg# time-stamp-time-zone: "UTC" 15300b0ce0bfSmrg# End: 15310b0ce0bfSmrg#! /bin/sh 15320b0ce0bfSmrg 15330b0ce0bfSmrg# A portable, pluggable option parser for Bourne shell. 15340b0ce0bfSmrg# Written by Gary V. Vaughan, 2010 15350b0ce0bfSmrg 15360b0ce0bfSmrg# This is free software. There is NO warranty; not even for 15370b0ce0bfSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 15380b0ce0bfSmrg# 15390b0ce0bfSmrg# Copyright (C) 2010-2019, 2021 Bootstrap Authors 15400b0ce0bfSmrg# 15410b0ce0bfSmrg# This file is dual licensed under the terms of the MIT license 15420b0ce0bfSmrg# <https://opensource.org/license/MIT>, and GPL version 2 or later 15430b0ce0bfSmrg# <http://www.gnu.org/licenses/gpl-2.0.html>. You must apply one of 15440b0ce0bfSmrg# these licenses when using or redistributing this software or any of 15450b0ce0bfSmrg# the files within it. See the URLs above, or the file `LICENSE` 15460b0ce0bfSmrg# included in the Bootstrap distribution for the full license texts. 15470b0ce0bfSmrg 15480b0ce0bfSmrg# Please report bugs or propose patches to: 15490b0ce0bfSmrg# <https://github.com/gnulib-modules/bootstrap/issues> 15500b0ce0bfSmrg 15510b0ce0bfSmrg# Set a version string for this script. 15520b0ce0bfSmrgscriptversion=2019-02-19.15; # UTC 15530b0ce0bfSmrg 15540b0ce0bfSmrg 15550b0ce0bfSmrg## ------ ## 15560b0ce0bfSmrg## Usage. ## 15570b0ce0bfSmrg## ------ ## 15580b0ce0bfSmrg 15590b0ce0bfSmrg# This file is a library for parsing options in your shell scripts along 15600b0ce0bfSmrg# with assorted other useful supporting features that you can make use 15610b0ce0bfSmrg# of too. 15620b0ce0bfSmrg# 15630b0ce0bfSmrg# For the simplest scripts you might need only: 15640b0ce0bfSmrg# 15650b0ce0bfSmrg# #!/bin/sh 15660b0ce0bfSmrg# . relative/path/to/funclib.sh 15670b0ce0bfSmrg# . relative/path/to/options-parser 15680b0ce0bfSmrg# scriptversion=1.0 15690b0ce0bfSmrg# func_options ${1+"$@"} 15700b0ce0bfSmrg# eval set dummy "$func_options_result"; shift 15710b0ce0bfSmrg# ...rest of your script... 15720b0ce0bfSmrg# 15730b0ce0bfSmrg# In order for the '--version' option to work, you will need to have a 15740b0ce0bfSmrg# suitably formatted comment like the one at the top of this file 15750b0ce0bfSmrg# starting with '# Written by ' and ending with '# Copyright'. 15760b0ce0bfSmrg# 15770b0ce0bfSmrg# For '-h' and '--help' to work, you will also need a one line 15780b0ce0bfSmrg# description of your script's purpose in a comment directly above the 15790b0ce0bfSmrg# '# Written by ' line, like the one at the top of this file. 15800b0ce0bfSmrg# 15810b0ce0bfSmrg# The default options also support '--debug', which will turn on shell 15820b0ce0bfSmrg# execution tracing (see the comment above debug_cmd below for another 15830b0ce0bfSmrg# use), and '--verbose' and the func_verbose function to allow your script 15840b0ce0bfSmrg# to display verbose messages only when your user has specified 15850b0ce0bfSmrg# '--verbose'. 15860b0ce0bfSmrg# 15870b0ce0bfSmrg# After sourcing this file, you can plug in processing for additional 15880b0ce0bfSmrg# options by amending the variables from the 'Configuration' section 15890b0ce0bfSmrg# below, and following the instructions in the 'Option parsing' 15900b0ce0bfSmrg# section further down. 15910b0ce0bfSmrg 15920b0ce0bfSmrg## -------------- ## 15930b0ce0bfSmrg## Configuration. ## 15940b0ce0bfSmrg## -------------- ## 15950b0ce0bfSmrg 15960b0ce0bfSmrg# You should override these variables in your script after sourcing this 15970b0ce0bfSmrg# file so that they reflect the customisations you have added to the 15980b0ce0bfSmrg# option parser. 15990b0ce0bfSmrg 16000b0ce0bfSmrg# The usage line for option parsing errors and the start of '-h' and 16010b0ce0bfSmrg# '--help' output messages. You can embed shell variables for delayed 16020b0ce0bfSmrg# expansion at the time the message is displayed, but you will need to 16030b0ce0bfSmrg# quote other shell meta-characters carefully to prevent them being 16040b0ce0bfSmrg# expanded when the contents are evaled. 16050b0ce0bfSmrgusage='$progpath [OPTION]...' 16060b0ce0bfSmrg 16070b0ce0bfSmrg# Short help message in response to '-h' and '--help'. Add to this or 16080b0ce0bfSmrg# override it after sourcing this library to reflect the full set of 16090b0ce0bfSmrg# options your script accepts. 16100b0ce0bfSmrgusage_message="\ 16110b0ce0bfSmrg --debug enable verbose shell tracing 16120b0ce0bfSmrg -W, --warnings=CATEGORY 16130b0ce0bfSmrg report the warnings falling in CATEGORY [all] 16140b0ce0bfSmrg -v, --verbose verbosely report processing 16150b0ce0bfSmrg --version print version information and exit 16160b0ce0bfSmrg -h, --help print short or long help message and exit 16170b0ce0bfSmrg" 16180b0ce0bfSmrg 16190b0ce0bfSmrg# Additional text appended to 'usage_message' in response to '--help'. 16200b0ce0bfSmrglong_help_message=" 16210b0ce0bfSmrgWarning categories include: 16220b0ce0bfSmrg 'all' show all warnings 16230b0ce0bfSmrg 'none' turn off all the warnings 16240b0ce0bfSmrg 'error' warnings are treated as fatal errors" 16250b0ce0bfSmrg 16260b0ce0bfSmrg# Help message printed before fatal option parsing errors. 16270b0ce0bfSmrgfatal_help="Try '\$progname --help' for more information." 16280b0ce0bfSmrg 16290b0ce0bfSmrg 16300b0ce0bfSmrg 16310b0ce0bfSmrg## ------------------------- ## 16320b0ce0bfSmrg## Hook function management. ## 16330b0ce0bfSmrg## ------------------------- ## 16340b0ce0bfSmrg 16350b0ce0bfSmrg# This section contains functions for adding, removing, and running hooks 16360b0ce0bfSmrg# in the main code. A hook is just a list of function names that can be 16370b0ce0bfSmrg# run in order later on. 16380b0ce0bfSmrg 16390b0ce0bfSmrg# func_hookable FUNC_NAME 16400b0ce0bfSmrg# ----------------------- 16410b0ce0bfSmrg# Declare that FUNC_NAME will run hooks added with 16420b0ce0bfSmrg# 'func_add_hook FUNC_NAME ...'. 16430b0ce0bfSmrgfunc_hookable () 16440b0ce0bfSmrg{ 16450b0ce0bfSmrg $debug_cmd 16460b0ce0bfSmrg 16470b0ce0bfSmrg func_append hookable_fns " $1" 16480b0ce0bfSmrg} 16490b0ce0bfSmrg 16500b0ce0bfSmrg 16510b0ce0bfSmrg# func_add_hook FUNC_NAME HOOK_FUNC 16520b0ce0bfSmrg# --------------------------------- 16530b0ce0bfSmrg# Request that FUNC_NAME call HOOK_FUNC before it returns. FUNC_NAME must 16540b0ce0bfSmrg# first have been declared "hookable" by a call to 'func_hookable'. 16550b0ce0bfSmrgfunc_add_hook () 16560b0ce0bfSmrg{ 16570b0ce0bfSmrg $debug_cmd 16580b0ce0bfSmrg 16590b0ce0bfSmrg case " $hookable_fns " in 16600b0ce0bfSmrg *" $1 "*) ;; 16610b0ce0bfSmrg *) func_fatal_error "'$1' does not accept hook functions." ;; 16620b0ce0bfSmrg esac 16630b0ce0bfSmrg 16640b0ce0bfSmrg eval func_append ${1}_hooks '" $2"' 16650b0ce0bfSmrg} 16660b0ce0bfSmrg 16670b0ce0bfSmrg 16680b0ce0bfSmrg# func_remove_hook FUNC_NAME HOOK_FUNC 16690b0ce0bfSmrg# ------------------------------------ 16700b0ce0bfSmrg# Remove HOOK_FUNC from the list of hook functions to be called by 16710b0ce0bfSmrg# FUNC_NAME. 16720b0ce0bfSmrgfunc_remove_hook () 16730b0ce0bfSmrg{ 16740b0ce0bfSmrg $debug_cmd 16750b0ce0bfSmrg 16760b0ce0bfSmrg eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`' 16770b0ce0bfSmrg} 16780b0ce0bfSmrg 16790b0ce0bfSmrg 16800b0ce0bfSmrg# func_propagate_result FUNC_NAME_A FUNC_NAME_B 16810b0ce0bfSmrg# --------------------------------------------- 16820b0ce0bfSmrg# If the *_result variable of FUNC_NAME_A _is set_, assign its value to 16830b0ce0bfSmrg# *_result variable of FUNC_NAME_B. 16840b0ce0bfSmrgfunc_propagate_result () 16850b0ce0bfSmrg{ 16860b0ce0bfSmrg $debug_cmd 16870b0ce0bfSmrg 16880b0ce0bfSmrg func_propagate_result_result=: 16890b0ce0bfSmrg if eval "test \"\${${1}_result+set}\" = set" 16900b0ce0bfSmrg then 16910b0ce0bfSmrg eval "${2}_result=\$${1}_result" 16920b0ce0bfSmrg else 16930b0ce0bfSmrg func_propagate_result_result=false 16940b0ce0bfSmrg fi 16950b0ce0bfSmrg} 16960b0ce0bfSmrg 16970b0ce0bfSmrg 16980b0ce0bfSmrg# func_run_hooks FUNC_NAME [ARG]... 16990b0ce0bfSmrg# --------------------------------- 17000b0ce0bfSmrg# Run all hook functions registered to FUNC_NAME. 17010b0ce0bfSmrg# It's assumed that the list of hook functions contains nothing more 17020b0ce0bfSmrg# than a whitespace-delimited list of legal shell function names, and 17030b0ce0bfSmrg# no effort is wasted trying to catch shell meta-characters or preserve 17040b0ce0bfSmrg# whitespace. 17050b0ce0bfSmrgfunc_run_hooks () 17060b0ce0bfSmrg{ 17070b0ce0bfSmrg $debug_cmd 17080b0ce0bfSmrg 17090b0ce0bfSmrg case " $hookable_fns " in 17100b0ce0bfSmrg *" $1 "*) ;; 17110b0ce0bfSmrg *) func_fatal_error "'$1' does not support hook functions." ;; 171232b578d3Smrg esac 17130b0ce0bfSmrg 17140b0ce0bfSmrg eval _G_hook_fns=\$$1_hooks; shift 17150b0ce0bfSmrg 17160b0ce0bfSmrg for _G_hook in $_G_hook_fns; do 17170b0ce0bfSmrg func_unset "${_G_hook}_result" 17180b0ce0bfSmrg eval $_G_hook '${1+"$@"}' 17190b0ce0bfSmrg func_propagate_result $_G_hook func_run_hooks 17200b0ce0bfSmrg if $func_propagate_result_result; then 17210b0ce0bfSmrg eval set dummy "$func_run_hooks_result"; shift 17220b0ce0bfSmrg fi 17230b0ce0bfSmrg done 17240b0ce0bfSmrg} 17250b0ce0bfSmrg 17260b0ce0bfSmrg 17270b0ce0bfSmrg 17280b0ce0bfSmrg## --------------- ## 17290b0ce0bfSmrg## Option parsing. ## 17300b0ce0bfSmrg## --------------- ## 17310b0ce0bfSmrg 17320b0ce0bfSmrg# In order to add your own option parsing hooks, you must accept the 17330b0ce0bfSmrg# full positional parameter list from your hook function. You may remove 17340b0ce0bfSmrg# or edit any options that you action, and then pass back the remaining 17350b0ce0bfSmrg# unprocessed options in '<hooked_function_name>_result', escaped 17360b0ce0bfSmrg# suitably for 'eval'. 17370b0ce0bfSmrg# 17380b0ce0bfSmrg# The '<hooked_function_name>_result' variable is automatically unset 17390b0ce0bfSmrg# before your hook gets called; for best performance, only set the 17400b0ce0bfSmrg# *_result variable when necessary (i.e. don't call the 'func_quote' 17410b0ce0bfSmrg# function unnecessarily because it can be an expensive operation on some 17420b0ce0bfSmrg# machines). 17430b0ce0bfSmrg# 17440b0ce0bfSmrg# Like this: 17450b0ce0bfSmrg# 17460b0ce0bfSmrg# my_options_prep () 17470b0ce0bfSmrg# { 17480b0ce0bfSmrg# $debug_cmd 17490b0ce0bfSmrg# 17500b0ce0bfSmrg# # Extend the existing usage message. 17510b0ce0bfSmrg# usage_message=$usage_message' 17520b0ce0bfSmrg# -s, --silent don'\''t print informational messages 17530b0ce0bfSmrg# ' 17540b0ce0bfSmrg# # No change in '$@' (ignored completely by this hook). Leave 17550b0ce0bfSmrg# # my_options_prep_result variable intact. 17560b0ce0bfSmrg# } 17570b0ce0bfSmrg# func_add_hook func_options_prep my_options_prep 17580b0ce0bfSmrg# 17590b0ce0bfSmrg# 17600b0ce0bfSmrg# my_silent_option () 17610b0ce0bfSmrg# { 17620b0ce0bfSmrg# $debug_cmd 17630b0ce0bfSmrg# 17640b0ce0bfSmrg# args_changed=false 17650b0ce0bfSmrg# 17660b0ce0bfSmrg# # Note that, for efficiency, we parse as many options as we can 17670b0ce0bfSmrg# # recognise in a loop before passing the remainder back to the 17680b0ce0bfSmrg# # caller on the first unrecognised argument we encounter. 17690b0ce0bfSmrg# while test $# -gt 0; do 17700b0ce0bfSmrg# opt=$1; shift 17710b0ce0bfSmrg# case $opt in 17720b0ce0bfSmrg# --silent|-s) opt_silent=: 17730b0ce0bfSmrg# args_changed=: 17740b0ce0bfSmrg# ;; 17750b0ce0bfSmrg# # Separate non-argument short options: 17760b0ce0bfSmrg# -s*) func_split_short_opt "$_G_opt" 17770b0ce0bfSmrg# set dummy "$func_split_short_opt_name" \ 17780b0ce0bfSmrg# "-$func_split_short_opt_arg" ${1+"$@"} 17790b0ce0bfSmrg# shift 17800b0ce0bfSmrg# args_changed=: 17810b0ce0bfSmrg# ;; 17820b0ce0bfSmrg# *) # Make sure the first unrecognised option "$_G_opt" 17830b0ce0bfSmrg# # is added back to "$@" in case we need it later, 17840b0ce0bfSmrg# # if $args_changed was set to 'true'. 17850b0ce0bfSmrg# set dummy "$_G_opt" ${1+"$@"}; shift; break ;; 17860b0ce0bfSmrg# esac 17870b0ce0bfSmrg# done 17880b0ce0bfSmrg# 17890b0ce0bfSmrg# # Only call 'func_quote' here if we processed at least one argument. 17900b0ce0bfSmrg# if $args_changed; then 17910b0ce0bfSmrg# func_quote eval ${1+"$@"} 17920b0ce0bfSmrg# my_silent_option_result=$func_quote_result 17930b0ce0bfSmrg# fi 17940b0ce0bfSmrg# } 17950b0ce0bfSmrg# func_add_hook func_parse_options my_silent_option 17960b0ce0bfSmrg# 17970b0ce0bfSmrg# 17980b0ce0bfSmrg# my_option_validation () 17990b0ce0bfSmrg# { 18000b0ce0bfSmrg# $debug_cmd 18010b0ce0bfSmrg# 18020b0ce0bfSmrg# $opt_silent && $opt_verbose && func_fatal_help "\ 18030b0ce0bfSmrg# '--silent' and '--verbose' options are mutually exclusive." 18040b0ce0bfSmrg# } 18050b0ce0bfSmrg# func_add_hook func_validate_options my_option_validation 18060b0ce0bfSmrg# 18070b0ce0bfSmrg# You'll also need to manually amend $usage_message to reflect the extra 18080b0ce0bfSmrg# options you parse. It's preferable to append if you can, so that 18090b0ce0bfSmrg# multiple option parsing hooks can be added safely. 18100b0ce0bfSmrg 18110b0ce0bfSmrg 18120b0ce0bfSmrg# func_options_finish [ARG]... 18130b0ce0bfSmrg# ---------------------------- 18140b0ce0bfSmrg# Finishing the option parse loop (call 'func_options' hooks ATM). 18150b0ce0bfSmrgfunc_options_finish () 18160b0ce0bfSmrg{ 18170b0ce0bfSmrg $debug_cmd 18180b0ce0bfSmrg 18190b0ce0bfSmrg func_run_hooks func_options ${1+"$@"} 18200b0ce0bfSmrg func_propagate_result func_run_hooks func_options_finish 18210b0ce0bfSmrg} 18220b0ce0bfSmrg 18230b0ce0bfSmrg 18240b0ce0bfSmrg# func_options [ARG]... 18250b0ce0bfSmrg# --------------------- 18260b0ce0bfSmrg# All the functions called inside func_options are hookable. See the 18270b0ce0bfSmrg# individual implementations for details. 18280b0ce0bfSmrgfunc_hookable func_options 18290b0ce0bfSmrgfunc_options () 18300b0ce0bfSmrg{ 18310b0ce0bfSmrg $debug_cmd 18320b0ce0bfSmrg 18330b0ce0bfSmrg _G_options_quoted=false 18340b0ce0bfSmrg 18350b0ce0bfSmrg for my_func in options_prep parse_options validate_options options_finish 18360b0ce0bfSmrg do 18370b0ce0bfSmrg func_unset func_${my_func}_result 18380b0ce0bfSmrg func_unset func_run_hooks_result 18390b0ce0bfSmrg eval func_$my_func '${1+"$@"}' 18400b0ce0bfSmrg func_propagate_result func_$my_func func_options 18410b0ce0bfSmrg if $func_propagate_result_result; then 18420b0ce0bfSmrg eval set dummy "$func_options_result"; shift 18430b0ce0bfSmrg _G_options_quoted=: 18440b0ce0bfSmrg fi 18450b0ce0bfSmrg done 18460b0ce0bfSmrg 18470b0ce0bfSmrg $_G_options_quoted || { 18480b0ce0bfSmrg # As we (func_options) are top-level options-parser function and 18490b0ce0bfSmrg # nobody quoted "$@" for us yet, we need to do it explicitly for 18500b0ce0bfSmrg # caller. 18510b0ce0bfSmrg func_quote eval ${1+"$@"} 18520b0ce0bfSmrg func_options_result=$func_quote_result 18530b0ce0bfSmrg } 185432b578d3Smrg} 185532b578d3Smrg 185632b578d3Smrg 18570b0ce0bfSmrg# func_options_prep [ARG]... 18580b0ce0bfSmrg# -------------------------- 18590b0ce0bfSmrg# All initialisations required before starting the option parse loop. 18600b0ce0bfSmrg# Note that when calling hook functions, we pass through the list of 18610b0ce0bfSmrg# positional parameters. If a hook function modifies that list, and 18620b0ce0bfSmrg# needs to propagate that back to rest of this script, then the complete 18630b0ce0bfSmrg# modified list must be put in 'func_run_hooks_result' before returning. 18640b0ce0bfSmrgfunc_hookable func_options_prep 18650b0ce0bfSmrgfunc_options_prep () 186632b578d3Smrg{ 18670b0ce0bfSmrg $debug_cmd 18681b12faf6Smrg 18690b0ce0bfSmrg # Option defaults: 18700b0ce0bfSmrg opt_verbose=false 18710b0ce0bfSmrg opt_warning_types= 18721b12faf6Smrg 18730b0ce0bfSmrg func_run_hooks func_options_prep ${1+"$@"} 18740b0ce0bfSmrg func_propagate_result func_run_hooks func_options_prep 187532b578d3Smrg} 187632b578d3Smrg 187732b578d3Smrg 18780b0ce0bfSmrg# func_parse_options [ARG]... 18790b0ce0bfSmrg# --------------------------- 18800b0ce0bfSmrg# The main option parsing loop. 18810b0ce0bfSmrgfunc_hookable func_parse_options 18820b0ce0bfSmrgfunc_parse_options () 188332b578d3Smrg{ 18840b0ce0bfSmrg $debug_cmd 18850b0ce0bfSmrg 18860b0ce0bfSmrg _G_parse_options_requote=false 18870b0ce0bfSmrg # this just eases exit handling 18880b0ce0bfSmrg while test $# -gt 0; do 18890b0ce0bfSmrg # Defer to hook functions for initial option parsing, so they 18900b0ce0bfSmrg # get priority in the event of reusing an option name. 18910b0ce0bfSmrg func_run_hooks func_parse_options ${1+"$@"} 18920b0ce0bfSmrg func_propagate_result func_run_hooks func_parse_options 18930b0ce0bfSmrg if $func_propagate_result_result; then 18940b0ce0bfSmrg eval set dummy "$func_parse_options_result"; shift 18950b0ce0bfSmrg # Even though we may have changed "$@", we passed the "$@" array 18960b0ce0bfSmrg # down into the hook and it quoted it for us (because we are in 18970b0ce0bfSmrg # this if-branch). No need to quote it again. 18980b0ce0bfSmrg _G_parse_options_requote=false 18990b0ce0bfSmrg fi 190032b578d3Smrg 19010b0ce0bfSmrg # Break out of the loop if we already parsed every option. 19020b0ce0bfSmrg test $# -gt 0 || break 19030b0ce0bfSmrg 19040b0ce0bfSmrg # We expect that one of the options parsed in this function matches 19050b0ce0bfSmrg # and thus we remove _G_opt from "$@" and need to re-quote. 19060b0ce0bfSmrg _G_match_parse_options=: 19070b0ce0bfSmrg _G_opt=$1 19080b0ce0bfSmrg shift 19090b0ce0bfSmrg case $_G_opt in 19100b0ce0bfSmrg --debug|-x) debug_cmd='set -x' 19110b0ce0bfSmrg func_echo "enabling shell trace mode" >&2 19120b0ce0bfSmrg $debug_cmd 19130b0ce0bfSmrg ;; 19140b0ce0bfSmrg 19150b0ce0bfSmrg --no-warnings|--no-warning|--no-warn) 19160b0ce0bfSmrg set dummy --warnings none ${1+"$@"} 19170b0ce0bfSmrg shift 19180b0ce0bfSmrg ;; 19190b0ce0bfSmrg 19200b0ce0bfSmrg --warnings|--warning|-W) 19210b0ce0bfSmrg if test $# = 0 && func_missing_arg $_G_opt; then 19220b0ce0bfSmrg _G_parse_options_requote=: 19230b0ce0bfSmrg break 19240b0ce0bfSmrg fi 19250b0ce0bfSmrg case " $warning_categories $1" in 19260b0ce0bfSmrg *" $1 "*) 19270b0ce0bfSmrg # trailing space prevents matching last $1 above 19280b0ce0bfSmrg func_append_uniq opt_warning_types " $1" 19290b0ce0bfSmrg ;; 19300b0ce0bfSmrg *all) 19310b0ce0bfSmrg opt_warning_types=$warning_categories 19320b0ce0bfSmrg ;; 19330b0ce0bfSmrg *none) 19340b0ce0bfSmrg opt_warning_types=none 19350b0ce0bfSmrg warning_func=: 19360b0ce0bfSmrg ;; 19370b0ce0bfSmrg *error) 19380b0ce0bfSmrg opt_warning_types=$warning_categories 19390b0ce0bfSmrg warning_func=func_fatal_error 19400b0ce0bfSmrg ;; 19410b0ce0bfSmrg *) 19420b0ce0bfSmrg func_fatal_error \ 19430b0ce0bfSmrg "unsupported warning category: '$1'" 19440b0ce0bfSmrg ;; 19450b0ce0bfSmrg esac 19460b0ce0bfSmrg shift 19470b0ce0bfSmrg ;; 19480b0ce0bfSmrg 19490b0ce0bfSmrg --verbose|-v) opt_verbose=: ;; 19500b0ce0bfSmrg --version) func_version ;; 19510b0ce0bfSmrg -\?|-h) func_usage ;; 19520b0ce0bfSmrg --help) func_help ;; 19530b0ce0bfSmrg 19540b0ce0bfSmrg # Separate optargs to long options (plugins may need this): 19550b0ce0bfSmrg --*=*) func_split_equals "$_G_opt" 19560b0ce0bfSmrg set dummy "$func_split_equals_lhs" \ 19570b0ce0bfSmrg "$func_split_equals_rhs" ${1+"$@"} 19580b0ce0bfSmrg shift 19590b0ce0bfSmrg ;; 19600b0ce0bfSmrg 19610b0ce0bfSmrg # Separate optargs to short options: 19620b0ce0bfSmrg -W*) 19630b0ce0bfSmrg func_split_short_opt "$_G_opt" 19640b0ce0bfSmrg set dummy "$func_split_short_opt_name" \ 19650b0ce0bfSmrg "$func_split_short_opt_arg" ${1+"$@"} 19660b0ce0bfSmrg shift 19670b0ce0bfSmrg ;; 19680b0ce0bfSmrg 19690b0ce0bfSmrg # Separate non-argument short options: 19700b0ce0bfSmrg -\?*|-h*|-v*|-x*) 19710b0ce0bfSmrg func_split_short_opt "$_G_opt" 19720b0ce0bfSmrg set dummy "$func_split_short_opt_name" \ 19730b0ce0bfSmrg "-$func_split_short_opt_arg" ${1+"$@"} 19740b0ce0bfSmrg shift 19750b0ce0bfSmrg ;; 19760b0ce0bfSmrg 19770b0ce0bfSmrg --) _G_parse_options_requote=: ; break ;; 19780b0ce0bfSmrg -*) func_fatal_help "unrecognised option: '$_G_opt'" ;; 19790b0ce0bfSmrg *) set dummy "$_G_opt" ${1+"$@"}; shift 19800b0ce0bfSmrg _G_match_parse_options=false 19810b0ce0bfSmrg break 19820b0ce0bfSmrg ;; 19830b0ce0bfSmrg esac 19841b12faf6Smrg 19850b0ce0bfSmrg if $_G_match_parse_options; then 19860b0ce0bfSmrg _G_parse_options_requote=: 19871b12faf6Smrg fi 19880b0ce0bfSmrg done 19890b0ce0bfSmrg 19900b0ce0bfSmrg if $_G_parse_options_requote; then 19910b0ce0bfSmrg # save modified positional parameters for caller 19920b0ce0bfSmrg func_quote eval ${1+"$@"} 19930b0ce0bfSmrg func_parse_options_result=$func_quote_result 199432b578d3Smrg fi 199532b578d3Smrg} 199632b578d3Smrg 19971b12faf6Smrg 19980b0ce0bfSmrg# func_validate_options [ARG]... 19990b0ce0bfSmrg# ------------------------------ 20000b0ce0bfSmrg# Perform any sanity checks on option settings and/or unconsumed 20010b0ce0bfSmrg# arguments. 20020b0ce0bfSmrgfunc_hookable func_validate_options 20030b0ce0bfSmrgfunc_validate_options () 200432b578d3Smrg{ 20050b0ce0bfSmrg $debug_cmd 20061b12faf6Smrg 20070b0ce0bfSmrg # Display all warnings if -W was not given. 20080b0ce0bfSmrg test -n "$opt_warning_types" || opt_warning_types=" $warning_categories" 20091b12faf6Smrg 20100b0ce0bfSmrg func_run_hooks func_validate_options ${1+"$@"} 20110b0ce0bfSmrg func_propagate_result func_run_hooks func_validate_options 201232b578d3Smrg 20130b0ce0bfSmrg # Bail if the options were screwed! 20140b0ce0bfSmrg $exit_cmd $EXIT_FAILURE 2015e35d4d8eSmrg} 20161b12faf6Smrg 20171b12faf6Smrg 2018e35d4d8eSmrg 20190b0ce0bfSmrg## ----------------- ## 20200b0ce0bfSmrg## Helper functions. ## 20210b0ce0bfSmrg## ----------------- ## 20221b12faf6Smrg 20230b0ce0bfSmrg# This section contains the helper functions used by the rest of the 20240b0ce0bfSmrg# hookable option parser framework in ascii-betical order. 20250b0ce0bfSmrg 20260b0ce0bfSmrg 20270b0ce0bfSmrg# func_fatal_help ARG... 20280b0ce0bfSmrg# ---------------------- 20290b0ce0bfSmrg# Echo program name prefixed message to standard error, followed by 20300b0ce0bfSmrg# a help hint, and exit. 20310b0ce0bfSmrgfunc_fatal_help () 20321b12faf6Smrg{ 20330b0ce0bfSmrg $debug_cmd 2034e35d4d8eSmrg 20350b0ce0bfSmrg eval \$ECHO \""Usage: $usage"\" 20360b0ce0bfSmrg eval \$ECHO \""$fatal_help"\" 20370b0ce0bfSmrg func_error ${1+"$@"} 20380b0ce0bfSmrg exit $EXIT_FAILURE 20391b12faf6Smrg} 20401b12faf6Smrg 20410b0ce0bfSmrg 20420b0ce0bfSmrg# func_help 20430b0ce0bfSmrg# --------- 20440b0ce0bfSmrg# Echo long help message to standard output and exit. 20451b12faf6Smrgfunc_help () 20461b12faf6Smrg{ 20470b0ce0bfSmrg $debug_cmd 20480b0ce0bfSmrg 20490b0ce0bfSmrg func_usage_message 20500b0ce0bfSmrg $ECHO "$long_help_message" 20510b0ce0bfSmrg exit 0 20521b12faf6Smrg} 20531b12faf6Smrg 20540b0ce0bfSmrg 20550b0ce0bfSmrg# func_missing_arg ARGNAME 20560b0ce0bfSmrg# ------------------------ 20571b12faf6Smrg# Echo program name prefixed message to standard error and set global 20581b12faf6Smrg# exit_cmd. 20591b12faf6Smrgfunc_missing_arg () 20601b12faf6Smrg{ 20610b0ce0bfSmrg $debug_cmd 2062e35d4d8eSmrg 20630b0ce0bfSmrg func_error "Missing argument for '$1'." 20641b12faf6Smrg exit_cmd=exit 206532b578d3Smrg} 206632b578d3Smrg 206732b578d3Smrg 20680b0ce0bfSmrg# func_split_equals STRING 20690b0ce0bfSmrg# ------------------------ 20700b0ce0bfSmrg# Set func_split_equals_lhs and func_split_equals_rhs shell variables 20710b0ce0bfSmrg# after splitting STRING at the '=' sign. 20720b0ce0bfSmrgtest -z "$_G_HAVE_XSI_OPS" \ 20730b0ce0bfSmrg && (eval 'x=a/b/c; 20740b0ce0bfSmrg test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ 20750b0ce0bfSmrg && _G_HAVE_XSI_OPS=yes 20760b0ce0bfSmrg 20770b0ce0bfSmrgif test yes = "$_G_HAVE_XSI_OPS" 20780b0ce0bfSmrgthen 20790b0ce0bfSmrg # This is an XSI compatible shell, allowing a faster implementation... 20800b0ce0bfSmrg eval 'func_split_equals () 20810b0ce0bfSmrg { 20820b0ce0bfSmrg $debug_cmd 20830b0ce0bfSmrg 20840b0ce0bfSmrg func_split_equals_lhs=${1%%=*} 20850b0ce0bfSmrg func_split_equals_rhs=${1#*=} 20860b0ce0bfSmrg if test "x$func_split_equals_lhs" = "x$1"; then 20870b0ce0bfSmrg func_split_equals_rhs= 20880b0ce0bfSmrg fi 20890b0ce0bfSmrg }' 20900b0ce0bfSmrgelse 20910b0ce0bfSmrg # ...otherwise fall back to using expr, which is often a shell builtin. 20920b0ce0bfSmrg func_split_equals () 20930b0ce0bfSmrg { 20940b0ce0bfSmrg $debug_cmd 20950b0ce0bfSmrg 20960b0ce0bfSmrg func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'` 20970b0ce0bfSmrg func_split_equals_rhs= 20980b0ce0bfSmrg test "x$func_split_equals_lhs=" = "x$1" \ 20990b0ce0bfSmrg || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'` 21000b0ce0bfSmrg } 21010b0ce0bfSmrgfi #func_split_equals 21020b0ce0bfSmrg 21030b0ce0bfSmrg 21040b0ce0bfSmrg# func_split_short_opt SHORTOPT 21050b0ce0bfSmrg# ----------------------------- 2106e35d4d8eSmrg# Set func_split_short_opt_name and func_split_short_opt_arg shell 2107e35d4d8eSmrg# variables after splitting SHORTOPT after the 2nd character. 21080b0ce0bfSmrgif test yes = "$_G_HAVE_XSI_OPS" 21090b0ce0bfSmrgthen 21100b0ce0bfSmrg # This is an XSI compatible shell, allowing a faster implementation... 21110b0ce0bfSmrg eval 'func_split_short_opt () 21120b0ce0bfSmrg { 21130b0ce0bfSmrg $debug_cmd 21140b0ce0bfSmrg 21150b0ce0bfSmrg func_split_short_opt_arg=${1#??} 21160b0ce0bfSmrg func_split_short_opt_name=${1%"$func_split_short_opt_arg"} 21170b0ce0bfSmrg }' 21180b0ce0bfSmrgelse 21190b0ce0bfSmrg # ...otherwise fall back to using expr, which is often a shell builtin. 21200b0ce0bfSmrg func_split_short_opt () 21210b0ce0bfSmrg { 21220b0ce0bfSmrg $debug_cmd 21230b0ce0bfSmrg 21240b0ce0bfSmrg func_split_short_opt_name=`expr "x$1" : 'x\(-.\)'` 21250b0ce0bfSmrg func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'` 21260b0ce0bfSmrg } 21270b0ce0bfSmrgfi #func_split_short_opt 21280b0ce0bfSmrg 21290b0ce0bfSmrg 21300b0ce0bfSmrg# func_usage 21310b0ce0bfSmrg# ---------- 21320b0ce0bfSmrg# Echo short help message to standard output and exit. 21330b0ce0bfSmrgfunc_usage () 2134e35d4d8eSmrg{ 21350b0ce0bfSmrg $debug_cmd 2136e35d4d8eSmrg 21370b0ce0bfSmrg func_usage_message 21380b0ce0bfSmrg $ECHO "Run '$progname --help |${PAGER-more}' for full usage" 21390b0ce0bfSmrg exit 0 21400b0ce0bfSmrg} 214132b578d3Smrg 21421b12faf6Smrg 21430b0ce0bfSmrg# func_usage_message 21440b0ce0bfSmrg# ------------------ 21450b0ce0bfSmrg# Echo short help message to standard output. 21460b0ce0bfSmrgfunc_usage_message () 2147e35d4d8eSmrg{ 21480b0ce0bfSmrg $debug_cmd 21490b0ce0bfSmrg 21500b0ce0bfSmrg eval \$ECHO \""Usage: $usage"\" 21510b0ce0bfSmrg echo 21520b0ce0bfSmrg $SED -n 's|^# || 21530b0ce0bfSmrg /^Written by/{ 21540b0ce0bfSmrg x;p;x 21550b0ce0bfSmrg } 21560b0ce0bfSmrg h 21570b0ce0bfSmrg /^Written by/q' < "$progpath" 21580b0ce0bfSmrg echo 21590b0ce0bfSmrg eval \$ECHO \""$usage_message"\" 21600b0ce0bfSmrg} 2161e35d4d8eSmrg 2162e35d4d8eSmrg 21630b0ce0bfSmrg# func_version 21640b0ce0bfSmrg# ------------ 21650b0ce0bfSmrg# Echo version message to standard output and exit. 21660b0ce0bfSmrg# The version message is extracted from the calling file's header 21670b0ce0bfSmrg# comments, with leading '# ' stripped: 21680b0ce0bfSmrg# 1. First display the progname and version 21690b0ce0bfSmrg# 2. Followed by the header comment line matching /^# Written by / 21700b0ce0bfSmrg# 3. Then a blank line followed by the first following line matching 21710b0ce0bfSmrg# /^# Copyright / 21720b0ce0bfSmrg# 4. Immediately followed by any lines between the previous matches, 21730b0ce0bfSmrg# except lines preceding the intervening completely blank line. 21740b0ce0bfSmrg# For example, see the header comments of this file. 21750b0ce0bfSmrgfunc_version () 21760b0ce0bfSmrg{ 21770b0ce0bfSmrg $debug_cmd 21780b0ce0bfSmrg 21790b0ce0bfSmrg printf '%s\n' "$progname $scriptversion" 21800b0ce0bfSmrg $SED -n ' 21810b0ce0bfSmrg /^# Written by /!b 21820b0ce0bfSmrg s|^# ||; p; n 2183e35d4d8eSmrg 21840b0ce0bfSmrg :fwd2blnk 21850b0ce0bfSmrg /./ { 21860b0ce0bfSmrg n 21870b0ce0bfSmrg b fwd2blnk 21880b0ce0bfSmrg } 21890b0ce0bfSmrg p; n 21900b0ce0bfSmrg 21910b0ce0bfSmrg :holdwrnt 21920b0ce0bfSmrg s|^# || 21930b0ce0bfSmrg s|^# *$|| 21940b0ce0bfSmrg /^Copyright /!{ 21950b0ce0bfSmrg /./H 21960b0ce0bfSmrg n 21970b0ce0bfSmrg b holdwrnt 21980b0ce0bfSmrg } 21991b12faf6Smrg 22000b0ce0bfSmrg s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2| 22010b0ce0bfSmrg G 22020b0ce0bfSmrg s|\(\n\)\n*|\1|g 22030b0ce0bfSmrg p; q' < "$progpath" 22041b12faf6Smrg 22050b0ce0bfSmrg exit $? 22060b0ce0bfSmrg} 220732b578d3Smrg 220832b578d3Smrg 22090b0ce0bfSmrg# Local variables: 22100b0ce0bfSmrg# mode: shell-script 22110b0ce0bfSmrg# sh-indentation: 2 22120b0ce0bfSmrg# eval: (add-hook 'before-save-hook 'time-stamp) 22130b0ce0bfSmrg# time-stamp-pattern: "30/scriptversion=%:y-%02m-%02d.%02H; # UTC" 22140b0ce0bfSmrg# time-stamp-time-zone: "UTC" 22150b0ce0bfSmrg# End: 221632b578d3Smrg 22170b0ce0bfSmrg# Set a version string. 22180b0ce0bfSmrgscriptversion='(GNU libtool) 2.4.7' 221932b578d3Smrg 22201b12faf6Smrg 22210b0ce0bfSmrg# func_echo ARG... 22220b0ce0bfSmrg# ---------------- 22230b0ce0bfSmrg# Libtool also displays the current mode in messages, so override 22240b0ce0bfSmrg# funclib.sh func_echo with this custom definition. 22250b0ce0bfSmrgfunc_echo () 2226e35d4d8eSmrg{ 22270b0ce0bfSmrg $debug_cmd 2228e35d4d8eSmrg 22290b0ce0bfSmrg _G_message=$* 22300b0ce0bfSmrg 22310b0ce0bfSmrg func_echo_IFS=$IFS 22320b0ce0bfSmrg IFS=$nl 22330b0ce0bfSmrg for _G_line in $_G_message; do 22340b0ce0bfSmrg IFS=$func_echo_IFS 22350b0ce0bfSmrg $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line" 22360b0ce0bfSmrg done 22370b0ce0bfSmrg IFS=$func_echo_IFS 22380b0ce0bfSmrg} 2239e35d4d8eSmrg 2240e35d4d8eSmrg 22410b0ce0bfSmrg# func_warning ARG... 22420b0ce0bfSmrg# ------------------- 22430b0ce0bfSmrg# Libtool warnings are not categorized, so override funclib.sh 22440b0ce0bfSmrg# func_warning with this simpler definition. 22450b0ce0bfSmrgfunc_warning () 2246e35d4d8eSmrg{ 22470b0ce0bfSmrg $debug_cmd 2248e35d4d8eSmrg 22490b0ce0bfSmrg $warning_func ${1+"$@"} 22500b0ce0bfSmrg} 2251e35d4d8eSmrg 2252e35d4d8eSmrg 22530b0ce0bfSmrg## ---------------- ## 22540b0ce0bfSmrg## Options parsing. ## 22550b0ce0bfSmrg## ---------------- ## 22560b0ce0bfSmrg 22570b0ce0bfSmrg# Hook in the functions to make sure our own options are parsed during 22580b0ce0bfSmrg# the option parsing loop. 22590b0ce0bfSmrg 22600b0ce0bfSmrgusage='$progpath [OPTION]... [MODE-ARG]...' 22610b0ce0bfSmrg 22620b0ce0bfSmrg# Short help message in response to '-h'. 22630b0ce0bfSmrgusage_message="Options: 22640b0ce0bfSmrg --config show all configuration variables 22650b0ce0bfSmrg --debug enable verbose shell tracing 22660b0ce0bfSmrg -n, --dry-run display commands without modifying any files 22670b0ce0bfSmrg --features display basic configuration information and exit 22680b0ce0bfSmrg --mode=MODE use operation mode MODE 22690b0ce0bfSmrg --no-warnings equivalent to '-Wnone' 22700b0ce0bfSmrg --preserve-dup-deps don't remove duplicate dependency libraries 22710b0ce0bfSmrg --quiet, --silent don't print informational messages 22720b0ce0bfSmrg --tag=TAG use configuration variables from tag TAG 22730b0ce0bfSmrg -v, --verbose print more informational messages than default 22740b0ce0bfSmrg --version print version information 22750b0ce0bfSmrg -W, --warnings=CATEGORY report the warnings falling in CATEGORY [all] 22760b0ce0bfSmrg -h, --help, --help-all print short, long, or detailed help message 22770b0ce0bfSmrg" 2278e35d4d8eSmrg 22790b0ce0bfSmrg# Additional text appended to 'usage_message' in response to '--help'. 22800b0ce0bfSmrgfunc_help () 2281e35d4d8eSmrg{ 22820b0ce0bfSmrg $debug_cmd 22830b0ce0bfSmrg 22840b0ce0bfSmrg func_usage_message 22850b0ce0bfSmrg $ECHO "$long_help_message 22860b0ce0bfSmrg 22870b0ce0bfSmrgMODE must be one of the following: 22880b0ce0bfSmrg 22890b0ce0bfSmrg clean remove files from the build directory 22900b0ce0bfSmrg compile compile a source file into a libtool object 22910b0ce0bfSmrg execute automatically set library path, then run a program 22920b0ce0bfSmrg finish complete the installation of libtool libraries 22930b0ce0bfSmrg install install libraries or executables 22940b0ce0bfSmrg link create a library or an executable 22950b0ce0bfSmrg uninstall remove libraries from an installed directory 22960b0ce0bfSmrg 22970b0ce0bfSmrgMODE-ARGS vary depending on the MODE. When passed as first option, 22980b0ce0bfSmrg'--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that. 22990b0ce0bfSmrgTry '$progname --help --mode=MODE' for a more detailed description of MODE. 23000b0ce0bfSmrg 23010b0ce0bfSmrgWhen reporting a bug, please describe a test case to reproduce it and 23020b0ce0bfSmrginclude the following information: 23030b0ce0bfSmrg 23040b0ce0bfSmrg host-triplet: $host 23050b0ce0bfSmrg shell: $SHELL 23060b0ce0bfSmrg compiler: $LTCC 23070b0ce0bfSmrg compiler flags: $LTCFLAGS 23080b0ce0bfSmrg linker: $LD (gnu? $with_gnu_ld) 23090b0ce0bfSmrg version: $progname (GNU libtool) 2.4.7 23100b0ce0bfSmrg automake: `($AUTOMAKE --version) 2>/dev/null |$SED 1q` 23110b0ce0bfSmrg autoconf: `($AUTOCONF --version) 2>/dev/null |$SED 1q` 23120b0ce0bfSmrg 23130b0ce0bfSmrgReport bugs to <bug-libtool@gnu.org>. 23140b0ce0bfSmrgGNU libtool home page: <http://www.gnu.org/software/libtool/>. 23150b0ce0bfSmrgGeneral help using GNU software: <http://www.gnu.org/gethelp/>." 23160b0ce0bfSmrg exit 0 23170b0ce0bfSmrg} 2318e35d4d8eSmrg 2319e35d4d8eSmrg 23200b0ce0bfSmrg# func_lo2o OBJECT-NAME 23210b0ce0bfSmrg# --------------------- 23220b0ce0bfSmrg# Transform OBJECT-NAME from a '.lo' suffix to the platform specific 23230b0ce0bfSmrg# object suffix. 23240b0ce0bfSmrg 23250b0ce0bfSmrglo2o=s/\\.lo\$/.$objext/ 23260b0ce0bfSmrgo2lo=s/\\.$objext\$/.lo/ 23270b0ce0bfSmrg 23280b0ce0bfSmrgif test yes = "$_G_HAVE_XSI_OPS"; then 23290b0ce0bfSmrg eval 'func_lo2o () 23300b0ce0bfSmrg { 23310b0ce0bfSmrg case $1 in 23320b0ce0bfSmrg *.lo) func_lo2o_result=${1%.lo}.$objext ;; 23330b0ce0bfSmrg * ) func_lo2o_result=$1 ;; 23340b0ce0bfSmrg esac 23350b0ce0bfSmrg }' 2336e35d4d8eSmrg 23370b0ce0bfSmrg # func_xform LIBOBJ-OR-SOURCE 23380b0ce0bfSmrg # --------------------------- 23390b0ce0bfSmrg # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise) 23400b0ce0bfSmrg # suffix to a '.lo' libtool-object suffix. 23410b0ce0bfSmrg eval 'func_xform () 23420b0ce0bfSmrg { 23430b0ce0bfSmrg func_xform_result=${1%.*}.lo 23440b0ce0bfSmrg }' 23450b0ce0bfSmrgelse 23460b0ce0bfSmrg # ...otherwise fall back to using sed. 23470b0ce0bfSmrg func_lo2o () 23480b0ce0bfSmrg { 23490b0ce0bfSmrg func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"` 23500b0ce0bfSmrg } 23510b0ce0bfSmrg 23520b0ce0bfSmrg func_xform () 23530b0ce0bfSmrg { 23540b0ce0bfSmrg func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'` 23550b0ce0bfSmrg } 23560b0ce0bfSmrgfi 2357e35d4d8eSmrg 23580b0ce0bfSmrg 23590b0ce0bfSmrg# func_fatal_configuration ARG... 23600b0ce0bfSmrg# ------------------------------- 23611b12faf6Smrg# Echo program name prefixed message to standard error, followed by 23621b12faf6Smrg# a configuration failure hint, and exit. 23631b12faf6Smrgfunc_fatal_configuration () 23641b12faf6Smrg{ 23650b0ce0bfSmrg func_fatal_error ${1+"$@"} \ 23660b0ce0bfSmrg "See the $PACKAGE documentation for more information." \ 23670b0ce0bfSmrg "Fatal configuration error." 23681b12faf6Smrg} 236932b578d3Smrg 23702a51b5beSmrg 23711b12faf6Smrg# func_config 23720b0ce0bfSmrg# ----------- 23731b12faf6Smrg# Display the configuration for all the tags in this script. 23741b12faf6Smrgfunc_config () 23751b12faf6Smrg{ 23761b12faf6Smrg re_begincf='^# ### BEGIN LIBTOOL' 23771b12faf6Smrg re_endcf='^# ### END LIBTOOL' 23781b12faf6Smrg 23791b12faf6Smrg # Default configuration. 23801b12faf6Smrg $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" 238132b578d3Smrg 238232b578d3Smrg # Now print the configurations for the tags. 238332b578d3Smrg for tagname in $taglist; do 23841b12faf6Smrg $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" 238532b578d3Smrg done 238632b578d3Smrg 23871b12faf6Smrg exit $? 23881b12faf6Smrg} 238932b578d3Smrg 23900b0ce0bfSmrg 23911b12faf6Smrg# func_features 23920b0ce0bfSmrg# ------------- 23931b12faf6Smrg# Display the features supported by this script. 23941b12faf6Smrgfunc_features () 23951b12faf6Smrg{ 2396e35d4d8eSmrg echo "host: $host" 23970b0ce0bfSmrg if test yes = "$build_libtool_libs"; then 2398e35d4d8eSmrg echo "enable shared libraries" 239932b578d3Smrg else 2400e35d4d8eSmrg echo "disable shared libraries" 240132b578d3Smrg fi 24020b0ce0bfSmrg if test yes = "$build_old_libs"; then 2403e35d4d8eSmrg echo "enable static libraries" 240432b578d3Smrg else 2405e35d4d8eSmrg echo "disable static libraries" 240632b578d3Smrg fi 24071b12faf6Smrg 240832b578d3Smrg exit $? 24091b12faf6Smrg} 241032b578d3Smrg 24110b0ce0bfSmrg 24120b0ce0bfSmrg# func_enable_tag TAGNAME 24130b0ce0bfSmrg# ----------------------- 24141b12faf6Smrg# Verify that TAGNAME is valid, and either flag an error and exit, or 24151b12faf6Smrg# enable the TAGNAME tag. We also add TAGNAME to the global $taglist 24161b12faf6Smrg# variable here. 24171b12faf6Smrgfunc_enable_tag () 24181b12faf6Smrg{ 24190b0ce0bfSmrg # Global variable: 24200b0ce0bfSmrg tagname=$1 242132b578d3Smrg 24220b0ce0bfSmrg re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" 24230b0ce0bfSmrg re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" 24240b0ce0bfSmrg sed_extractcf=/$re_begincf/,/$re_endcf/p 242532b578d3Smrg 24260b0ce0bfSmrg # Validate tagname. 24270b0ce0bfSmrg case $tagname in 24280b0ce0bfSmrg *[!-_A-Za-z0-9,/]*) 24290b0ce0bfSmrg func_fatal_error "invalid tag name: $tagname" 24300b0ce0bfSmrg ;; 24310b0ce0bfSmrg esac 243232b578d3Smrg 24330b0ce0bfSmrg # Don't test for the "default" C tag, as we know it's 24340b0ce0bfSmrg # there but not specially marked. 24350b0ce0bfSmrg case $tagname in 24360b0ce0bfSmrg CC) ;; 24371b12faf6Smrg *) 24380b0ce0bfSmrg if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then 24390b0ce0bfSmrg taglist="$taglist $tagname" 24400b0ce0bfSmrg 24410b0ce0bfSmrg # Evaluate the configuration. Be careful to quote the path 24420b0ce0bfSmrg # and the sed script, to avoid splitting on whitespace, but 24430b0ce0bfSmrg # also don't use non-portable quotes within backquotes within 24440b0ce0bfSmrg # quotes we have to do it in 2 steps: 24450b0ce0bfSmrg extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` 24460b0ce0bfSmrg eval "$extractedcf" 24470b0ce0bfSmrg else 24480b0ce0bfSmrg func_error "ignoring unknown tag $tagname" 24490b0ce0bfSmrg fi 24500b0ce0bfSmrg ;; 24510b0ce0bfSmrg esac 24521b12faf6Smrg} 24531b12faf6Smrg 24540b0ce0bfSmrg 2455e35d4d8eSmrg# func_check_version_match 24560b0ce0bfSmrg# ------------------------ 2457e35d4d8eSmrg# Ensure that we are using m4 macros, and libtool script from the same 2458e35d4d8eSmrg# release of libtool. 2459e35d4d8eSmrgfunc_check_version_match () 24601b12faf6Smrg{ 24610b0ce0bfSmrg if test "$package_revision" != "$macro_revision"; then 24620b0ce0bfSmrg if test "$VERSION" != "$macro_version"; then 24630b0ce0bfSmrg if test -z "$macro_version"; then 24640b0ce0bfSmrg cat >&2 <<_LT_EOF 2465e35d4d8eSmrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 2466e35d4d8eSmrg$progname: definition of this LT_INIT comes from an older release. 2467e35d4d8eSmrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 2468e35d4d8eSmrg$progname: and run autoconf again. 2469e35d4d8eSmrg_LT_EOF 24700b0ce0bfSmrg else 24710b0ce0bfSmrg cat >&2 <<_LT_EOF 2472e35d4d8eSmrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 2473e35d4d8eSmrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version. 2474e35d4d8eSmrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 2475e35d4d8eSmrg$progname: and run autoconf again. 2476e35d4d8eSmrg_LT_EOF 24770b0ce0bfSmrg fi 24780b0ce0bfSmrg else 24790b0ce0bfSmrg cat >&2 <<_LT_EOF 2480e35d4d8eSmrg$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, 2481e35d4d8eSmrg$progname: but the definition of this LT_INIT comes from revision $macro_revision. 2482e35d4d8eSmrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision 2483e35d4d8eSmrg$progname: of $PACKAGE $VERSION and run autoconf again. 2484e35d4d8eSmrg_LT_EOF 24850b0ce0bfSmrg fi 2486e35d4d8eSmrg 24870b0ce0bfSmrg exit $EXIT_MISMATCH 24880b0ce0bfSmrg fi 2489e35d4d8eSmrg} 2490e35d4d8eSmrg 2491e35d4d8eSmrg 24920b0ce0bfSmrg# libtool_options_prep [ARG]... 24930b0ce0bfSmrg# ----------------------------- 24940b0ce0bfSmrg# Preparation for options parsed by libtool. 24950b0ce0bfSmrglibtool_options_prep () 24960b0ce0bfSmrg{ 24970b0ce0bfSmrg $debug_mode 249832b578d3Smrg 24990b0ce0bfSmrg # Option defaults: 25000b0ce0bfSmrg opt_config=false 25010b0ce0bfSmrg opt_dlopen= 25020b0ce0bfSmrg opt_dry_run=false 25030b0ce0bfSmrg opt_help=false 25040b0ce0bfSmrg opt_mode= 25050b0ce0bfSmrg opt_preserve_dup_deps=false 25060b0ce0bfSmrg opt_quiet=false 2507e35d4d8eSmrg 25080b0ce0bfSmrg nonopt= 25090b0ce0bfSmrg preserve_args= 2510e35d4d8eSmrg 25110b0ce0bfSmrg _G_rc_lt_options_prep=: 2512e35d4d8eSmrg 25130b0ce0bfSmrg # Shorthand for --mode=foo, only valid as the first argument 25140b0ce0bfSmrg case $1 in 25150b0ce0bfSmrg clean|clea|cle|cl) 25160b0ce0bfSmrg shift; set dummy --mode clean ${1+"$@"}; shift 25170b0ce0bfSmrg ;; 25180b0ce0bfSmrg compile|compil|compi|comp|com|co|c) 25190b0ce0bfSmrg shift; set dummy --mode compile ${1+"$@"}; shift 25200b0ce0bfSmrg ;; 25210b0ce0bfSmrg execute|execut|execu|exec|exe|ex|e) 25220b0ce0bfSmrg shift; set dummy --mode execute ${1+"$@"}; shift 25230b0ce0bfSmrg ;; 25240b0ce0bfSmrg finish|finis|fini|fin|fi|f) 25250b0ce0bfSmrg shift; set dummy --mode finish ${1+"$@"}; shift 25260b0ce0bfSmrg ;; 25270b0ce0bfSmrg install|instal|insta|inst|ins|in|i) 25280b0ce0bfSmrg shift; set dummy --mode install ${1+"$@"}; shift 25290b0ce0bfSmrg ;; 25300b0ce0bfSmrg link|lin|li|l) 25310b0ce0bfSmrg shift; set dummy --mode link ${1+"$@"}; shift 25320b0ce0bfSmrg ;; 25330b0ce0bfSmrg uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) 25340b0ce0bfSmrg shift; set dummy --mode uninstall ${1+"$@"}; shift 25350b0ce0bfSmrg ;; 25360b0ce0bfSmrg *) 25370b0ce0bfSmrg _G_rc_lt_options_prep=false 25380b0ce0bfSmrg ;; 25391b12faf6Smrg esac 25401b12faf6Smrg 25410b0ce0bfSmrg if $_G_rc_lt_options_prep; then 25420b0ce0bfSmrg # Pass back the list of options. 25430b0ce0bfSmrg func_quote eval ${1+"$@"} 25440b0ce0bfSmrg libtool_options_prep_result=$func_quote_result 25450b0ce0bfSmrg fi 25460b0ce0bfSmrg} 25470b0ce0bfSmrgfunc_add_hook func_options_prep libtool_options_prep 2548e35d4d8eSmrg 2549e35d4d8eSmrg 25500b0ce0bfSmrg# libtool_parse_options [ARG]... 25510b0ce0bfSmrg# --------------------------------- 25520b0ce0bfSmrg# Provide handling for libtool specific options. 25530b0ce0bfSmrglibtool_parse_options () 25540b0ce0bfSmrg{ 25550b0ce0bfSmrg $debug_cmd 25561b12faf6Smrg 25570b0ce0bfSmrg _G_rc_lt_parse_options=false 255832b578d3Smrg 25590b0ce0bfSmrg # Perform our own loop to consume as many options as possible in 25600b0ce0bfSmrg # each iteration. 25610b0ce0bfSmrg while test $# -gt 0; do 25620b0ce0bfSmrg _G_match_lt_parse_options=: 25630b0ce0bfSmrg _G_opt=$1 25640b0ce0bfSmrg shift 25650b0ce0bfSmrg case $_G_opt in 25660b0ce0bfSmrg --dry-run|--dryrun|-n) 25670b0ce0bfSmrg opt_dry_run=: 25680b0ce0bfSmrg ;; 25690b0ce0bfSmrg 25700b0ce0bfSmrg --config) func_config ;; 25710b0ce0bfSmrg 25720b0ce0bfSmrg --dlopen|-dlopen) 25730b0ce0bfSmrg opt_dlopen="${opt_dlopen+$opt_dlopen 25740b0ce0bfSmrg}$1" 25750b0ce0bfSmrg shift 25760b0ce0bfSmrg ;; 25770b0ce0bfSmrg 25780b0ce0bfSmrg --preserve-dup-deps) 25790b0ce0bfSmrg opt_preserve_dup_deps=: ;; 25800b0ce0bfSmrg 25810b0ce0bfSmrg --features) func_features ;; 25820b0ce0bfSmrg 25830b0ce0bfSmrg --finish) set dummy --mode finish ${1+"$@"}; shift ;; 25840b0ce0bfSmrg 25850b0ce0bfSmrg --help) opt_help=: ;; 25860b0ce0bfSmrg 25870b0ce0bfSmrg --help-all) opt_help=': help-all' ;; 25880b0ce0bfSmrg 25890b0ce0bfSmrg --mode) test $# = 0 && func_missing_arg $_G_opt && break 25900b0ce0bfSmrg opt_mode=$1 25910b0ce0bfSmrg case $1 in 25920b0ce0bfSmrg # Valid mode arguments: 25930b0ce0bfSmrg clean|compile|execute|finish|install|link|relink|uninstall) ;; 25940b0ce0bfSmrg 25950b0ce0bfSmrg # Catch anything else as an error 25960b0ce0bfSmrg *) func_error "invalid argument for $_G_opt" 25970b0ce0bfSmrg exit_cmd=exit 25980b0ce0bfSmrg break 25990b0ce0bfSmrg ;; 26000b0ce0bfSmrg esac 26010b0ce0bfSmrg shift 26020b0ce0bfSmrg ;; 26030b0ce0bfSmrg 26040b0ce0bfSmrg --no-silent|--no-quiet) 26050b0ce0bfSmrg opt_quiet=false 26060b0ce0bfSmrg func_append preserve_args " $_G_opt" 26070b0ce0bfSmrg ;; 26080b0ce0bfSmrg 26090b0ce0bfSmrg --no-warnings|--no-warning|--no-warn) 26100b0ce0bfSmrg opt_warning=false 26110b0ce0bfSmrg func_append preserve_args " $_G_opt" 26120b0ce0bfSmrg ;; 26130b0ce0bfSmrg 26140b0ce0bfSmrg --no-verbose) 26150b0ce0bfSmrg opt_verbose=false 26160b0ce0bfSmrg func_append preserve_args " $_G_opt" 26170b0ce0bfSmrg ;; 26180b0ce0bfSmrg 26190b0ce0bfSmrg --silent|--quiet) 26200b0ce0bfSmrg opt_quiet=: 26210b0ce0bfSmrg opt_verbose=false 26220b0ce0bfSmrg func_append preserve_args " $_G_opt" 26230b0ce0bfSmrg ;; 26240b0ce0bfSmrg 26250b0ce0bfSmrg --tag) test $# = 0 && func_missing_arg $_G_opt && break 26260b0ce0bfSmrg opt_tag=$1 26270b0ce0bfSmrg func_append preserve_args " $_G_opt $1" 26280b0ce0bfSmrg func_enable_tag "$1" 26290b0ce0bfSmrg shift 26300b0ce0bfSmrg ;; 26310b0ce0bfSmrg 26320b0ce0bfSmrg --verbose|-v) opt_quiet=false 26330b0ce0bfSmrg opt_verbose=: 26340b0ce0bfSmrg func_append preserve_args " $_G_opt" 26350b0ce0bfSmrg ;; 26360b0ce0bfSmrg 26370b0ce0bfSmrg # An option not handled by this hook function: 26380b0ce0bfSmrg *) set dummy "$_G_opt" ${1+"$@"} ; shift 26390b0ce0bfSmrg _G_match_lt_parse_options=false 26400b0ce0bfSmrg break 26410b0ce0bfSmrg ;; 26420b0ce0bfSmrg esac 26430b0ce0bfSmrg $_G_match_lt_parse_options && _G_rc_lt_parse_options=: 26440b0ce0bfSmrg done 26451b12faf6Smrg 26460b0ce0bfSmrg if $_G_rc_lt_parse_options; then 26470b0ce0bfSmrg # save modified positional parameters for caller 26480b0ce0bfSmrg func_quote eval ${1+"$@"} 26490b0ce0bfSmrg libtool_parse_options_result=$func_quote_result 26501b12faf6Smrg fi 26510b0ce0bfSmrg} 26520b0ce0bfSmrgfunc_add_hook func_parse_options libtool_parse_options 26531b12faf6Smrg 26541b12faf6Smrg 26550b0ce0bfSmrg 26560b0ce0bfSmrg# libtool_validate_options [ARG]... 26570b0ce0bfSmrg# --------------------------------- 26580b0ce0bfSmrg# Perform any sanity checks on option settings and/or unconsumed 26590b0ce0bfSmrg# arguments. 26600b0ce0bfSmrglibtool_validate_options () 26610b0ce0bfSmrg{ 26620b0ce0bfSmrg # save first non-option argument 26630b0ce0bfSmrg if test 0 -lt $#; then 26640b0ce0bfSmrg nonopt=$1 26650b0ce0bfSmrg shift 2666e35d4d8eSmrg fi 266732b578d3Smrg 26680b0ce0bfSmrg # preserve --debug 26690b0ce0bfSmrg test : = "$debug_cmd" || func_append preserve_args " --debug" 26700b0ce0bfSmrg 26710b0ce0bfSmrg case $host in 26720b0ce0bfSmrg # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452 26730b0ce0bfSmrg # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788 26740b0ce0bfSmrg *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*) 26750b0ce0bfSmrg # don't eliminate duplications in $postdeps and $predeps 26760b0ce0bfSmrg opt_duplicate_compiler_generated_deps=: 26770b0ce0bfSmrg ;; 26780b0ce0bfSmrg *) 26790b0ce0bfSmrg opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps 26800b0ce0bfSmrg ;; 26810b0ce0bfSmrg esac 26820b0ce0bfSmrg 26830b0ce0bfSmrg $opt_help || { 26840b0ce0bfSmrg # Sanity checks first: 26850b0ce0bfSmrg func_check_version_match 26860b0ce0bfSmrg 26870b0ce0bfSmrg test yes != "$build_libtool_libs" \ 26880b0ce0bfSmrg && test yes != "$build_old_libs" \ 26890b0ce0bfSmrg && func_fatal_configuration "not configured to build any kind of library" 26901b12faf6Smrg 26910b0ce0bfSmrg # Darwin sucks 26920b0ce0bfSmrg eval std_shrext=\"$shrext_cmds\" 26930b0ce0bfSmrg 26940b0ce0bfSmrg # Only execute mode is allowed to have -dlopen flags. 26950b0ce0bfSmrg if test -n "$opt_dlopen" && test execute != "$opt_mode"; then 26960b0ce0bfSmrg func_error "unrecognized option '-dlopen'" 26970b0ce0bfSmrg $ECHO "$help" 1>&2 26980b0ce0bfSmrg exit $EXIT_FAILURE 26990b0ce0bfSmrg fi 27000b0ce0bfSmrg 27010b0ce0bfSmrg # Change the help message to a mode-specific one. 27020b0ce0bfSmrg generic_help=$help 27030b0ce0bfSmrg help="Try '$progname --help --mode=$opt_mode' for more information." 27040b0ce0bfSmrg } 27051b12faf6Smrg 27060b0ce0bfSmrg # Pass back the unparsed argument list 27070b0ce0bfSmrg func_quote eval ${1+"$@"} 27080b0ce0bfSmrg libtool_validate_options_result=$func_quote_result 2709e35d4d8eSmrg} 27100b0ce0bfSmrgfunc_add_hook func_validate_options libtool_validate_options 27111b12faf6Smrg 27121b12faf6Smrg 27130b0ce0bfSmrg# Process options as early as possible so that --help and --version 27140b0ce0bfSmrg# can return quickly. 27150b0ce0bfSmrgfunc_options ${1+"$@"} 27160b0ce0bfSmrgeval set dummy "$func_options_result"; shift 27170b0ce0bfSmrg 271832b578d3Smrg 271932b578d3Smrg 2720e35d4d8eSmrg## ----------- ## 2721e35d4d8eSmrg## Main. ## 2722e35d4d8eSmrg## ----------- ## 272332b578d3Smrg 27240b0ce0bfSmrgmagic='%%%MAGIC variable%%%' 27250b0ce0bfSmrgmagic_exe='%%%MAGIC EXE variable%%%' 27260b0ce0bfSmrg 27270b0ce0bfSmrg# Global variables. 27280b0ce0bfSmrgextracted_archives= 27290b0ce0bfSmrgextracted_serial=0 27300b0ce0bfSmrg 27310b0ce0bfSmrg# If this variable is set in any of the actions, the command in it 27320b0ce0bfSmrg# will be execed at the end. This prevents here-documents from being 27330b0ce0bfSmrg# left over by shells. 27340b0ce0bfSmrgexec_cmd= 27350b0ce0bfSmrg 27360b0ce0bfSmrg 27370b0ce0bfSmrg# A function that is used when there is no print builtin or printf. 27380b0ce0bfSmrgfunc_fallback_echo () 27390b0ce0bfSmrg{ 27400b0ce0bfSmrg eval 'cat <<_LTECHO_EOF 27410b0ce0bfSmrg$1 27420b0ce0bfSmrg_LTECHO_EOF' 27430b0ce0bfSmrg} 27440b0ce0bfSmrg 27450b0ce0bfSmrg# func_generated_by_libtool 27460b0ce0bfSmrg# True iff stdin has been generated by Libtool. This function is only 27470b0ce0bfSmrg# a basic sanity check; it will hardly flush out determined imposters. 27480b0ce0bfSmrgfunc_generated_by_libtool_p () 27490b0ce0bfSmrg{ 27500b0ce0bfSmrg $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 27510b0ce0bfSmrg} 27520b0ce0bfSmrg 27531b12faf6Smrg# func_lalib_p file 27540b0ce0bfSmrg# True iff FILE is a libtool '.la' library or '.lo' object file. 27551b12faf6Smrg# This function is only a basic sanity check; it will hardly flush out 27561b12faf6Smrg# determined imposters. 27571b12faf6Smrgfunc_lalib_p () 27581b12faf6Smrg{ 27591b12faf6Smrg test -f "$1" && 27600b0ce0bfSmrg $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p 27611b12faf6Smrg} 276232b578d3Smrg 27631b12faf6Smrg# func_lalib_unsafe_p file 27640b0ce0bfSmrg# True iff FILE is a libtool '.la' library or '.lo' object file. 27651b12faf6Smrg# This function implements the same check as func_lalib_p without 27661b12faf6Smrg# resorting to external programs. To this end, it redirects stdin and 27671b12faf6Smrg# closes it afterwards, without saving the original file descriptor. 27681b12faf6Smrg# As a safety measure, use it only where a negative result would be 27690b0ce0bfSmrg# fatal anyway. Works if 'file' does not exist. 27701b12faf6Smrgfunc_lalib_unsafe_p () 27711b12faf6Smrg{ 27721b12faf6Smrg lalib_p=no 27731b12faf6Smrg if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then 27741b12faf6Smrg for lalib_p_l in 1 2 3 4 27751b12faf6Smrg do 27761b12faf6Smrg read lalib_p_line 27770b0ce0bfSmrg case $lalib_p_line in 27781b12faf6Smrg \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; 27791b12faf6Smrg esac 27801b12faf6Smrg done 27811b12faf6Smrg exec 0<&5 5<&- 27821b12faf6Smrg fi 27830b0ce0bfSmrg test yes = "$lalib_p" 27841b12faf6Smrg} 278532b578d3Smrg 27861b12faf6Smrg# func_ltwrapper_script_p file 27871b12faf6Smrg# True iff FILE is a libtool wrapper script 27881b12faf6Smrg# This function is only a basic sanity check; it will hardly flush out 27891b12faf6Smrg# determined imposters. 27901b12faf6Smrgfunc_ltwrapper_script_p () 27911b12faf6Smrg{ 27920b0ce0bfSmrg test -f "$1" && 27930b0ce0bfSmrg $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p 27941b12faf6Smrg} 279532b578d3Smrg 27961b12faf6Smrg# func_ltwrapper_executable_p file 27971b12faf6Smrg# True iff FILE is a libtool wrapper executable 27981b12faf6Smrg# This function is only a basic sanity check; it will hardly flush out 27991b12faf6Smrg# determined imposters. 28001b12faf6Smrgfunc_ltwrapper_executable_p () 28011b12faf6Smrg{ 28021b12faf6Smrg func_ltwrapper_exec_suffix= 28031b12faf6Smrg case $1 in 28041b12faf6Smrg *.exe) ;; 28051b12faf6Smrg *) func_ltwrapper_exec_suffix=.exe ;; 28061b12faf6Smrg esac 28071b12faf6Smrg $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 28081b12faf6Smrg} 280932b578d3Smrg 28101b12faf6Smrg# func_ltwrapper_scriptname file 28111b12faf6Smrg# Assumes file is an ltwrapper_executable 28121b12faf6Smrg# uses $file to determine the appropriate filename for a 28131b12faf6Smrg# temporary ltwrapper_script. 28141b12faf6Smrgfunc_ltwrapper_scriptname () 28151b12faf6Smrg{ 2816e35d4d8eSmrg func_dirname_and_basename "$1" "" "." 2817e35d4d8eSmrg func_stripname '' '.exe' "$func_basename_result" 28180b0ce0bfSmrg func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper 28191b12faf6Smrg} 28201b12faf6Smrg 28211b12faf6Smrg# func_ltwrapper_p file 28221b12faf6Smrg# True iff FILE is a libtool wrapper script or wrapper executable 28231b12faf6Smrg# This function is only a basic sanity check; it will hardly flush out 28241b12faf6Smrg# determined imposters. 28251b12faf6Smrgfunc_ltwrapper_p () 28261b12faf6Smrg{ 28271b12faf6Smrg func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" 28281b12faf6Smrg} 28291b12faf6Smrg 28301b12faf6Smrg 28311b12faf6Smrg# func_execute_cmds commands fail_cmd 28321b12faf6Smrg# Execute tilde-delimited COMMANDS. 28331b12faf6Smrg# If FAIL_CMD is given, eval that upon failure. 28341b12faf6Smrg# FAIL_CMD may read-access the current command in variable CMD! 28351b12faf6Smrgfunc_execute_cmds () 28361b12faf6Smrg{ 28370b0ce0bfSmrg $debug_cmd 28380b0ce0bfSmrg 28391b12faf6Smrg save_ifs=$IFS; IFS='~' 28401b12faf6Smrg for cmd in $1; do 28410b0ce0bfSmrg IFS=$sp$nl 28421b12faf6Smrg eval cmd=\"$cmd\" 28430b0ce0bfSmrg IFS=$save_ifs 28441b12faf6Smrg func_show_eval "$cmd" "${2-:}" 28451b12faf6Smrg done 28461b12faf6Smrg IFS=$save_ifs 28471b12faf6Smrg} 28481b12faf6Smrg 28491b12faf6Smrg 28501b12faf6Smrg# func_source file 28511b12faf6Smrg# Source FILE, adding directory component if necessary. 28521b12faf6Smrg# Note that it is not necessary on cygwin/mingw to append a dot to 28531b12faf6Smrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe 28541b12faf6Smrg# behavior happens only for exec(3), not for open(2)! Also, sourcing 28550b0ce0bfSmrg# 'FILE.' does not work on cygwin managed mounts. 28561b12faf6Smrgfunc_source () 28571b12faf6Smrg{ 28580b0ce0bfSmrg $debug_cmd 28590b0ce0bfSmrg 28601b12faf6Smrg case $1 in 28611b12faf6Smrg */* | *\\*) . "$1" ;; 28621b12faf6Smrg *) . "./$1" ;; 28631b12faf6Smrg esac 28641b12faf6Smrg} 28651b12faf6Smrg 28661b12faf6Smrg 2867e35d4d8eSmrg# func_resolve_sysroot PATH 2868e35d4d8eSmrg# Replace a leading = in PATH with a sysroot. Store the result into 2869e35d4d8eSmrg# func_resolve_sysroot_result 2870e35d4d8eSmrgfunc_resolve_sysroot () 2871e35d4d8eSmrg{ 2872e35d4d8eSmrg func_resolve_sysroot_result=$1 2873e35d4d8eSmrg case $func_resolve_sysroot_result in 2874e35d4d8eSmrg =*) 2875e35d4d8eSmrg func_stripname '=' '' "$func_resolve_sysroot_result" 2876e35d4d8eSmrg func_resolve_sysroot_result=$lt_sysroot$func_stripname_result 2877e35d4d8eSmrg ;; 2878e35d4d8eSmrg esac 2879e35d4d8eSmrg} 2880e35d4d8eSmrg 2881e35d4d8eSmrg# func_replace_sysroot PATH 2882e35d4d8eSmrg# If PATH begins with the sysroot, replace it with = and 2883e35d4d8eSmrg# store the result into func_replace_sysroot_result. 2884e35d4d8eSmrgfunc_replace_sysroot () 2885e35d4d8eSmrg{ 28860b0ce0bfSmrg case $lt_sysroot:$1 in 2887e35d4d8eSmrg ?*:"$lt_sysroot"*) 2888e35d4d8eSmrg func_stripname "$lt_sysroot" '' "$1" 28890b0ce0bfSmrg func_replace_sysroot_result='='$func_stripname_result 2890e35d4d8eSmrg ;; 2891e35d4d8eSmrg *) 2892e35d4d8eSmrg # Including no sysroot. 2893e35d4d8eSmrg func_replace_sysroot_result=$1 2894e35d4d8eSmrg ;; 2895e35d4d8eSmrg esac 2896e35d4d8eSmrg} 2897e35d4d8eSmrg 28981b12faf6Smrg# func_infer_tag arg 28991b12faf6Smrg# Infer tagged configuration to use if any are available and 29001b12faf6Smrg# if one wasn't chosen via the "--tag" command line option. 29011b12faf6Smrg# Only attempt this if the compiler in the base compile 29021b12faf6Smrg# command doesn't match the default compiler. 29031b12faf6Smrg# arg is usually of the form 'gcc ...' 29041b12faf6Smrgfunc_infer_tag () 29051b12faf6Smrg{ 29060b0ce0bfSmrg $debug_cmd 29070b0ce0bfSmrg 29081b12faf6Smrg if test -n "$available_tags" && test -z "$tagname"; then 29091b12faf6Smrg CC_quoted= 29101b12faf6Smrg for arg in $CC; do 2911e35d4d8eSmrg func_append_quoted CC_quoted "$arg" 29121b12faf6Smrg done 2913e35d4d8eSmrg CC_expanded=`func_echo_all $CC` 2914e35d4d8eSmrg CC_quoted_expanded=`func_echo_all $CC_quoted` 29151b12faf6Smrg case $@ in 29161b12faf6Smrg # Blanks in the command may have been stripped by the calling shell, 29171b12faf6Smrg # but not from the CC environment variable when configure was run. 2918e35d4d8eSmrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 2919e35d4d8eSmrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; 29201b12faf6Smrg # Blanks at the start of $base_compile will cause this to fail 29211b12faf6Smrg # if we don't check for them as well. 29221b12faf6Smrg *) 29231b12faf6Smrg for z in $available_tags; do 29241b12faf6Smrg if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then 29251b12faf6Smrg # Evaluate the configuration. 29260b0ce0bfSmrg eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" 29271b12faf6Smrg CC_quoted= 29281b12faf6Smrg for arg in $CC; do 29291b12faf6Smrg # Double-quote args containing other shell metacharacters. 2930e35d4d8eSmrg func_append_quoted CC_quoted "$arg" 29311b12faf6Smrg done 2932e35d4d8eSmrg CC_expanded=`func_echo_all $CC` 2933e35d4d8eSmrg CC_quoted_expanded=`func_echo_all $CC_quoted` 29341b12faf6Smrg case "$@ " in 2935e35d4d8eSmrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 2936e35d4d8eSmrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) 29371b12faf6Smrg # The compiler in the base compile command matches 29381b12faf6Smrg # the one in the tagged configuration. 29391b12faf6Smrg # Assume this is the tagged configuration we want. 29401b12faf6Smrg tagname=$z 29411b12faf6Smrg break 29421b12faf6Smrg ;; 29431b12faf6Smrg esac 29441b12faf6Smrg fi 29451b12faf6Smrg done 29461b12faf6Smrg # If $tagname still isn't set, then no tagged configuration 29471b12faf6Smrg # was found and let the user know that the "--tag" command 29481b12faf6Smrg # line option must be used. 29491b12faf6Smrg if test -z "$tagname"; then 29501b12faf6Smrg func_echo "unable to infer tagged configuration" 29510b0ce0bfSmrg func_fatal_error "specify a tag with '--tag'" 29521b12faf6Smrg# else 29531b12faf6Smrg# func_verbose "using $tagname tagged configuration" 29541b12faf6Smrg fi 29551b12faf6Smrg ;; 29561b12faf6Smrg esac 29571b12faf6Smrg fi 29581b12faf6Smrg} 29591b12faf6Smrg 29601b12faf6Smrg 29611b12faf6Smrg 29621b12faf6Smrg# func_write_libtool_object output_name pic_name nonpic_name 29631b12faf6Smrg# Create a libtool object file (analogous to a ".la" file), 29641b12faf6Smrg# but don't create it if we're doing a dry run. 29651b12faf6Smrgfunc_write_libtool_object () 29661b12faf6Smrg{ 29670b0ce0bfSmrg write_libobj=$1 29680b0ce0bfSmrg if test yes = "$build_libtool_libs"; then 29690b0ce0bfSmrg write_lobj=\'$2\' 29701b12faf6Smrg else 29711b12faf6Smrg write_lobj=none 29721b12faf6Smrg fi 29731b12faf6Smrg 29740b0ce0bfSmrg if test yes = "$build_old_libs"; then 29750b0ce0bfSmrg write_oldobj=\'$3\' 29761b12faf6Smrg else 29771b12faf6Smrg write_oldobj=none 29781b12faf6Smrg fi 29791b12faf6Smrg 29801b12faf6Smrg $opt_dry_run || { 29811b12faf6Smrg cat >${write_libobj}T <<EOF 29821b12faf6Smrg# $write_libobj - a libtool object file 29830b0ce0bfSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 29841b12faf6Smrg# 29851b12faf6Smrg# Please DO NOT delete this file! 29861b12faf6Smrg# It is necessary for linking the library. 29871b12faf6Smrg 29881b12faf6Smrg# Name of the PIC object. 29891b12faf6Smrgpic_object=$write_lobj 29901b12faf6Smrg 29911b12faf6Smrg# Name of the non-PIC object 29921b12faf6Smrgnon_pic_object=$write_oldobj 29931b12faf6Smrg 29941b12faf6SmrgEOF 29950b0ce0bfSmrg $MV "${write_libobj}T" "$write_libobj" 29961b12faf6Smrg } 29971b12faf6Smrg} 29981b12faf6Smrg 2999e35d4d8eSmrg 3000e35d4d8eSmrg################################################## 3001e35d4d8eSmrg# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS # 3002e35d4d8eSmrg################################################## 3003e35d4d8eSmrg 3004e35d4d8eSmrg# func_convert_core_file_wine_to_w32 ARG 3005e35d4d8eSmrg# Helper function used by file name conversion functions when $build is *nix, 3006e35d4d8eSmrg# and $host is mingw, cygwin, or some other w32 environment. Relies on a 3007e35d4d8eSmrg# correctly configured wine environment available, with the winepath program 3008e35d4d8eSmrg# in $build's $PATH. 3009e35d4d8eSmrg# 3010e35d4d8eSmrg# ARG is the $build file name to be converted to w32 format. 3011e35d4d8eSmrg# Result is available in $func_convert_core_file_wine_to_w32_result, and will 3012e35d4d8eSmrg# be empty on error (or when ARG is empty) 3013e35d4d8eSmrgfunc_convert_core_file_wine_to_w32 () 3014e35d4d8eSmrg{ 30150b0ce0bfSmrg $debug_cmd 30160b0ce0bfSmrg 30170b0ce0bfSmrg func_convert_core_file_wine_to_w32_result=$1 3018e35d4d8eSmrg if test -n "$1"; then 3019e35d4d8eSmrg # Unfortunately, winepath does not exit with a non-zero error code, so we 3020e35d4d8eSmrg # are forced to check the contents of stdout. On the other hand, if the 3021e35d4d8eSmrg # command is not found, the shell will set an exit code of 127 and print 3022e35d4d8eSmrg # *an error message* to stdout. So we must check for both error code of 3023e35d4d8eSmrg # zero AND non-empty stdout, which explains the odd construction: 3024e35d4d8eSmrg func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null` 30250b0ce0bfSmrg if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then 3026e35d4d8eSmrg func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | 30270b0ce0bfSmrg $SED -e "$sed_naive_backslashify"` 3028e35d4d8eSmrg else 3029e35d4d8eSmrg func_convert_core_file_wine_to_w32_result= 3030e35d4d8eSmrg fi 3031e35d4d8eSmrg fi 3032e35d4d8eSmrg} 3033e35d4d8eSmrg# end: func_convert_core_file_wine_to_w32 3034e35d4d8eSmrg 3035e35d4d8eSmrg 3036e35d4d8eSmrg# func_convert_core_path_wine_to_w32 ARG 3037e35d4d8eSmrg# Helper function used by path conversion functions when $build is *nix, and 3038e35d4d8eSmrg# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly 3039e35d4d8eSmrg# configured wine environment available, with the winepath program in $build's 3040e35d4d8eSmrg# $PATH. Assumes ARG has no leading or trailing path separator characters. 3041e35d4d8eSmrg# 3042e35d4d8eSmrg# ARG is path to be converted from $build format to win32. 3043e35d4d8eSmrg# Result is available in $func_convert_core_path_wine_to_w32_result. 3044e35d4d8eSmrg# Unconvertible file (directory) names in ARG are skipped; if no directory names 3045e35d4d8eSmrg# are convertible, then the result may be empty. 3046e35d4d8eSmrgfunc_convert_core_path_wine_to_w32 () 3047e35d4d8eSmrg{ 30480b0ce0bfSmrg $debug_cmd 30490b0ce0bfSmrg 3050e35d4d8eSmrg # unfortunately, winepath doesn't convert paths, only file names 30510b0ce0bfSmrg func_convert_core_path_wine_to_w32_result= 3052e35d4d8eSmrg if test -n "$1"; then 3053e35d4d8eSmrg oldIFS=$IFS 3054e35d4d8eSmrg IFS=: 3055e35d4d8eSmrg for func_convert_core_path_wine_to_w32_f in $1; do 3056e35d4d8eSmrg IFS=$oldIFS 3057e35d4d8eSmrg func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" 30580b0ce0bfSmrg if test -n "$func_convert_core_file_wine_to_w32_result"; then 3059e35d4d8eSmrg if test -z "$func_convert_core_path_wine_to_w32_result"; then 30600b0ce0bfSmrg func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result 3061e35d4d8eSmrg else 3062e35d4d8eSmrg func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" 3063e35d4d8eSmrg fi 3064e35d4d8eSmrg fi 3065e35d4d8eSmrg done 3066e35d4d8eSmrg IFS=$oldIFS 3067e35d4d8eSmrg fi 3068e35d4d8eSmrg} 3069e35d4d8eSmrg# end: func_convert_core_path_wine_to_w32 3070e35d4d8eSmrg 3071e35d4d8eSmrg 3072e35d4d8eSmrg# func_cygpath ARGS... 3073e35d4d8eSmrg# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when 3074e35d4d8eSmrg# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) 3075e35d4d8eSmrg# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or 3076e35d4d8eSmrg# (2), returns the Cygwin file name or path in func_cygpath_result (input 3077e35d4d8eSmrg# file name or path is assumed to be in w32 format, as previously converted 3078e35d4d8eSmrg# from $build's *nix or MSYS format). In case (3), returns the w32 file name 3079e35d4d8eSmrg# or path in func_cygpath_result (input file name or path is assumed to be in 3080e35d4d8eSmrg# Cygwin format). Returns an empty string on error. 3081e35d4d8eSmrg# 3082e35d4d8eSmrg# ARGS are passed to cygpath, with the last one being the file name or path to 3083e35d4d8eSmrg# be converted. 3084e35d4d8eSmrg# 3085e35d4d8eSmrg# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH 3086e35d4d8eSmrg# environment variable; do not put it in $PATH. 3087e35d4d8eSmrgfunc_cygpath () 3088e35d4d8eSmrg{ 30890b0ce0bfSmrg $debug_cmd 30900b0ce0bfSmrg 3091e35d4d8eSmrg if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then 3092e35d4d8eSmrg func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` 3093e35d4d8eSmrg if test "$?" -ne 0; then 3094e35d4d8eSmrg # on failure, ensure result is empty 3095e35d4d8eSmrg func_cygpath_result= 3096e35d4d8eSmrg fi 3097e35d4d8eSmrg else 3098e35d4d8eSmrg func_cygpath_result= 30990b0ce0bfSmrg func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'" 3100e35d4d8eSmrg fi 3101e35d4d8eSmrg} 3102e35d4d8eSmrg#end: func_cygpath 3103e35d4d8eSmrg 3104e35d4d8eSmrg 3105e35d4d8eSmrg# func_convert_core_msys_to_w32 ARG 3106e35d4d8eSmrg# Convert file name or path ARG from MSYS format to w32 format. Return 3107e35d4d8eSmrg# result in func_convert_core_msys_to_w32_result. 3108e35d4d8eSmrgfunc_convert_core_msys_to_w32 () 3109e35d4d8eSmrg{ 31100b0ce0bfSmrg $debug_cmd 31110b0ce0bfSmrg 3112e35d4d8eSmrg # awkward: cmd appends spaces to result 3113e35d4d8eSmrg func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | 31140b0ce0bfSmrg $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"` 3115e35d4d8eSmrg} 3116e35d4d8eSmrg#end: func_convert_core_msys_to_w32 3117e35d4d8eSmrg 3118e35d4d8eSmrg 3119e35d4d8eSmrg# func_convert_file_check ARG1 ARG2 3120e35d4d8eSmrg# Verify that ARG1 (a file name in $build format) was converted to $host 3121e35d4d8eSmrg# format in ARG2. Otherwise, emit an error message, but continue (resetting 3122e35d4d8eSmrg# func_to_host_file_result to ARG1). 3123e35d4d8eSmrgfunc_convert_file_check () 3124e35d4d8eSmrg{ 31250b0ce0bfSmrg $debug_cmd 31260b0ce0bfSmrg 31270b0ce0bfSmrg if test -z "$2" && test -n "$1"; then 3128e35d4d8eSmrg func_error "Could not determine host file name corresponding to" 31290b0ce0bfSmrg func_error " '$1'" 3130e35d4d8eSmrg func_error "Continuing, but uninstalled executables may not work." 3131e35d4d8eSmrg # Fallback: 31320b0ce0bfSmrg func_to_host_file_result=$1 3133e35d4d8eSmrg fi 3134e35d4d8eSmrg} 3135e35d4d8eSmrg# end func_convert_file_check 3136e35d4d8eSmrg 3137e35d4d8eSmrg 3138e35d4d8eSmrg# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH 3139e35d4d8eSmrg# Verify that FROM_PATH (a path in $build format) was converted to $host 3140e35d4d8eSmrg# format in TO_PATH. Otherwise, emit an error message, but continue, resetting 3141e35d4d8eSmrg# func_to_host_file_result to a simplistic fallback value (see below). 3142e35d4d8eSmrgfunc_convert_path_check () 3143e35d4d8eSmrg{ 31440b0ce0bfSmrg $debug_cmd 31450b0ce0bfSmrg 3146e35d4d8eSmrg if test -z "$4" && test -n "$3"; then 3147e35d4d8eSmrg func_error "Could not determine the host path corresponding to" 31480b0ce0bfSmrg func_error " '$3'" 3149e35d4d8eSmrg func_error "Continuing, but uninstalled executables may not work." 3150e35d4d8eSmrg # Fallback. This is a deliberately simplistic "conversion" and 3151e35d4d8eSmrg # should not be "improved". See libtool.info. 3152e35d4d8eSmrg if test "x$1" != "x$2"; then 3153e35d4d8eSmrg lt_replace_pathsep_chars="s|$1|$2|g" 3154e35d4d8eSmrg func_to_host_path_result=`echo "$3" | 3155e35d4d8eSmrg $SED -e "$lt_replace_pathsep_chars"` 3156e35d4d8eSmrg else 31570b0ce0bfSmrg func_to_host_path_result=$3 3158e35d4d8eSmrg fi 3159e35d4d8eSmrg fi 3160e35d4d8eSmrg} 3161e35d4d8eSmrg# end func_convert_path_check 3162e35d4d8eSmrg 3163e35d4d8eSmrg 3164e35d4d8eSmrg# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG 3165e35d4d8eSmrg# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT 3166e35d4d8eSmrg# and appending REPL if ORIG matches BACKPAT. 3167e35d4d8eSmrgfunc_convert_path_front_back_pathsep () 3168e35d4d8eSmrg{ 31690b0ce0bfSmrg $debug_cmd 31700b0ce0bfSmrg 3171e35d4d8eSmrg case $4 in 31720b0ce0bfSmrg $1 ) func_to_host_path_result=$3$func_to_host_path_result 3173e35d4d8eSmrg ;; 3174e35d4d8eSmrg esac 3175e35d4d8eSmrg case $4 in 3176e35d4d8eSmrg $2 ) func_append func_to_host_path_result "$3" 3177e35d4d8eSmrg ;; 3178e35d4d8eSmrg esac 3179e35d4d8eSmrg} 3180e35d4d8eSmrg# end func_convert_path_front_back_pathsep 3181e35d4d8eSmrg 3182e35d4d8eSmrg 3183e35d4d8eSmrg################################################## 3184e35d4d8eSmrg# $build to $host FILE NAME CONVERSION FUNCTIONS # 3185e35d4d8eSmrg################################################## 31860b0ce0bfSmrg# invoked via '$to_host_file_cmd ARG' 3187e35d4d8eSmrg# 3188e35d4d8eSmrg# In each case, ARG is the path to be converted from $build to $host format. 3189e35d4d8eSmrg# Result will be available in $func_to_host_file_result. 3190e35d4d8eSmrg 3191e35d4d8eSmrg 3192e35d4d8eSmrg# func_to_host_file ARG 3193e35d4d8eSmrg# Converts the file name ARG from $build format to $host format. Return result 3194e35d4d8eSmrg# in func_to_host_file_result. 3195e35d4d8eSmrgfunc_to_host_file () 3196e35d4d8eSmrg{ 31970b0ce0bfSmrg $debug_cmd 31980b0ce0bfSmrg 3199e35d4d8eSmrg $to_host_file_cmd "$1" 3200e35d4d8eSmrg} 3201e35d4d8eSmrg# end func_to_host_file 3202e35d4d8eSmrg 3203e35d4d8eSmrg 3204e35d4d8eSmrg# func_to_tool_file ARG LAZY 3205e35d4d8eSmrg# converts the file name ARG from $build format to toolchain format. Return 3206e35d4d8eSmrg# result in func_to_tool_file_result. If the conversion in use is listed 3207e35d4d8eSmrg# in (the comma separated) LAZY, no conversion takes place. 3208e35d4d8eSmrgfunc_to_tool_file () 3209e35d4d8eSmrg{ 32100b0ce0bfSmrg $debug_cmd 32110b0ce0bfSmrg 3212e35d4d8eSmrg case ,$2, in 3213e35d4d8eSmrg *,"$to_tool_file_cmd",*) 3214e35d4d8eSmrg func_to_tool_file_result=$1 3215e35d4d8eSmrg ;; 3216e35d4d8eSmrg *) 3217e35d4d8eSmrg $to_tool_file_cmd "$1" 3218e35d4d8eSmrg func_to_tool_file_result=$func_to_host_file_result 3219e35d4d8eSmrg ;; 3220e35d4d8eSmrg esac 3221e35d4d8eSmrg} 3222e35d4d8eSmrg# end func_to_tool_file 3223e35d4d8eSmrg 3224e35d4d8eSmrg 3225e35d4d8eSmrg# func_convert_file_noop ARG 3226e35d4d8eSmrg# Copy ARG to func_to_host_file_result. 3227e35d4d8eSmrgfunc_convert_file_noop () 3228e35d4d8eSmrg{ 32290b0ce0bfSmrg func_to_host_file_result=$1 3230e35d4d8eSmrg} 3231e35d4d8eSmrg# end func_convert_file_noop 3232e35d4d8eSmrg 3233e35d4d8eSmrg 3234e35d4d8eSmrg# func_convert_file_msys_to_w32 ARG 3235e35d4d8eSmrg# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic 3236e35d4d8eSmrg# conversion to w32 is not available inside the cwrapper. Returns result in 3237e35d4d8eSmrg# func_to_host_file_result. 3238e35d4d8eSmrgfunc_convert_file_msys_to_w32 () 3239e35d4d8eSmrg{ 32400b0ce0bfSmrg $debug_cmd 32410b0ce0bfSmrg 32420b0ce0bfSmrg func_to_host_file_result=$1 3243e35d4d8eSmrg if test -n "$1"; then 3244e35d4d8eSmrg func_convert_core_msys_to_w32 "$1" 32450b0ce0bfSmrg func_to_host_file_result=$func_convert_core_msys_to_w32_result 3246e35d4d8eSmrg fi 3247e35d4d8eSmrg func_convert_file_check "$1" "$func_to_host_file_result" 3248e35d4d8eSmrg} 3249e35d4d8eSmrg# end func_convert_file_msys_to_w32 3250e35d4d8eSmrg 3251e35d4d8eSmrg 3252e35d4d8eSmrg# func_convert_file_cygwin_to_w32 ARG 3253e35d4d8eSmrg# Convert file name ARG from Cygwin to w32 format. Returns result in 3254e35d4d8eSmrg# func_to_host_file_result. 3255e35d4d8eSmrgfunc_convert_file_cygwin_to_w32 () 3256e35d4d8eSmrg{ 32570b0ce0bfSmrg $debug_cmd 32580b0ce0bfSmrg 32590b0ce0bfSmrg func_to_host_file_result=$1 3260e35d4d8eSmrg if test -n "$1"; then 3261e35d4d8eSmrg # because $build is cygwin, we call "the" cygpath in $PATH; no need to use 3262e35d4d8eSmrg # LT_CYGPATH in this case. 3263e35d4d8eSmrg func_to_host_file_result=`cygpath -m "$1"` 3264e35d4d8eSmrg fi 3265e35d4d8eSmrg func_convert_file_check "$1" "$func_to_host_file_result" 3266e35d4d8eSmrg} 3267e35d4d8eSmrg# end func_convert_file_cygwin_to_w32 3268e35d4d8eSmrg 3269e35d4d8eSmrg 3270e35d4d8eSmrg# func_convert_file_nix_to_w32 ARG 3271e35d4d8eSmrg# Convert file name ARG from *nix to w32 format. Requires a wine environment 3272e35d4d8eSmrg# and a working winepath. Returns result in func_to_host_file_result. 3273e35d4d8eSmrgfunc_convert_file_nix_to_w32 () 3274e35d4d8eSmrg{ 32750b0ce0bfSmrg $debug_cmd 32760b0ce0bfSmrg 32770b0ce0bfSmrg func_to_host_file_result=$1 3278e35d4d8eSmrg if test -n "$1"; then 3279e35d4d8eSmrg func_convert_core_file_wine_to_w32 "$1" 32800b0ce0bfSmrg func_to_host_file_result=$func_convert_core_file_wine_to_w32_result 3281e35d4d8eSmrg fi 3282e35d4d8eSmrg func_convert_file_check "$1" "$func_to_host_file_result" 3283e35d4d8eSmrg} 3284e35d4d8eSmrg# end func_convert_file_nix_to_w32 3285e35d4d8eSmrg 3286e35d4d8eSmrg 3287e35d4d8eSmrg# func_convert_file_msys_to_cygwin ARG 3288e35d4d8eSmrg# Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 3289e35d4d8eSmrg# Returns result in func_to_host_file_result. 3290e35d4d8eSmrgfunc_convert_file_msys_to_cygwin () 3291e35d4d8eSmrg{ 32920b0ce0bfSmrg $debug_cmd 32930b0ce0bfSmrg 32940b0ce0bfSmrg func_to_host_file_result=$1 3295e35d4d8eSmrg if test -n "$1"; then 3296e35d4d8eSmrg func_convert_core_msys_to_w32 "$1" 3297e35d4d8eSmrg func_cygpath -u "$func_convert_core_msys_to_w32_result" 32980b0ce0bfSmrg func_to_host_file_result=$func_cygpath_result 3299e35d4d8eSmrg fi 3300e35d4d8eSmrg func_convert_file_check "$1" "$func_to_host_file_result" 3301e35d4d8eSmrg} 3302e35d4d8eSmrg# end func_convert_file_msys_to_cygwin 3303e35d4d8eSmrg 3304e35d4d8eSmrg 3305e35d4d8eSmrg# func_convert_file_nix_to_cygwin ARG 3306e35d4d8eSmrg# Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed 3307e35d4d8eSmrg# in a wine environment, working winepath, and LT_CYGPATH set. Returns result 3308e35d4d8eSmrg# in func_to_host_file_result. 3309e35d4d8eSmrgfunc_convert_file_nix_to_cygwin () 3310e35d4d8eSmrg{ 33110b0ce0bfSmrg $debug_cmd 33120b0ce0bfSmrg 33130b0ce0bfSmrg func_to_host_file_result=$1 3314e35d4d8eSmrg if test -n "$1"; then 3315e35d4d8eSmrg # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. 3316e35d4d8eSmrg func_convert_core_file_wine_to_w32 "$1" 3317e35d4d8eSmrg func_cygpath -u "$func_convert_core_file_wine_to_w32_result" 33180b0ce0bfSmrg func_to_host_file_result=$func_cygpath_result 3319e35d4d8eSmrg fi 3320e35d4d8eSmrg func_convert_file_check "$1" "$func_to_host_file_result" 3321e35d4d8eSmrg} 3322e35d4d8eSmrg# end func_convert_file_nix_to_cygwin 3323e35d4d8eSmrg 3324e35d4d8eSmrg 3325e35d4d8eSmrg############################################# 3326e35d4d8eSmrg# $build to $host PATH CONVERSION FUNCTIONS # 3327e35d4d8eSmrg############################################# 33280b0ce0bfSmrg# invoked via '$to_host_path_cmd ARG' 3329e35d4d8eSmrg# 3330e35d4d8eSmrg# In each case, ARG is the path to be converted from $build to $host format. 3331e35d4d8eSmrg# The result will be available in $func_to_host_path_result. 3332e35d4d8eSmrg# 3333e35d4d8eSmrg# Path separators are also converted from $build format to $host format. If 3334e35d4d8eSmrg# ARG begins or ends with a path separator character, it is preserved (but 3335e35d4d8eSmrg# converted to $host format) on output. 3336e35d4d8eSmrg# 3337e35d4d8eSmrg# All path conversion functions are named using the following convention: 3338e35d4d8eSmrg# file name conversion function : func_convert_file_X_to_Y () 3339e35d4d8eSmrg# path conversion function : func_convert_path_X_to_Y () 3340e35d4d8eSmrg# where, for any given $build/$host combination the 'X_to_Y' value is the 3341e35d4d8eSmrg# same. If conversion functions are added for new $build/$host combinations, 3342e35d4d8eSmrg# the two new functions must follow this pattern, or func_init_to_host_path_cmd 3343e35d4d8eSmrg# will break. 3344e35d4d8eSmrg 3345e35d4d8eSmrg 3346e35d4d8eSmrg# func_init_to_host_path_cmd 3347e35d4d8eSmrg# Ensures that function "pointer" variable $to_host_path_cmd is set to the 3348e35d4d8eSmrg# appropriate value, based on the value of $to_host_file_cmd. 3349e35d4d8eSmrgto_host_path_cmd= 3350e35d4d8eSmrgfunc_init_to_host_path_cmd () 3351e35d4d8eSmrg{ 33520b0ce0bfSmrg $debug_cmd 33530b0ce0bfSmrg 3354e35d4d8eSmrg if test -z "$to_host_path_cmd"; then 3355e35d4d8eSmrg func_stripname 'func_convert_file_' '' "$to_host_file_cmd" 33560b0ce0bfSmrg to_host_path_cmd=func_convert_path_$func_stripname_result 3357e35d4d8eSmrg fi 3358e35d4d8eSmrg} 3359e35d4d8eSmrg 3360e35d4d8eSmrg 3361e35d4d8eSmrg# func_to_host_path ARG 3362e35d4d8eSmrg# Converts the path ARG from $build format to $host format. Return result 3363e35d4d8eSmrg# in func_to_host_path_result. 3364e35d4d8eSmrgfunc_to_host_path () 3365e35d4d8eSmrg{ 33660b0ce0bfSmrg $debug_cmd 33670b0ce0bfSmrg 3368e35d4d8eSmrg func_init_to_host_path_cmd 3369e35d4d8eSmrg $to_host_path_cmd "$1" 3370e35d4d8eSmrg} 3371e35d4d8eSmrg# end func_to_host_path 3372e35d4d8eSmrg 3373e35d4d8eSmrg 3374e35d4d8eSmrg# func_convert_path_noop ARG 3375e35d4d8eSmrg# Copy ARG to func_to_host_path_result. 3376e35d4d8eSmrgfunc_convert_path_noop () 3377e35d4d8eSmrg{ 33780b0ce0bfSmrg func_to_host_path_result=$1 3379e35d4d8eSmrg} 3380e35d4d8eSmrg# end func_convert_path_noop 3381e35d4d8eSmrg 3382e35d4d8eSmrg 3383e35d4d8eSmrg# func_convert_path_msys_to_w32 ARG 3384e35d4d8eSmrg# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic 3385e35d4d8eSmrg# conversion to w32 is not available inside the cwrapper. Returns result in 3386e35d4d8eSmrg# func_to_host_path_result. 3387e35d4d8eSmrgfunc_convert_path_msys_to_w32 () 3388e35d4d8eSmrg{ 33890b0ce0bfSmrg $debug_cmd 33900b0ce0bfSmrg 33910b0ce0bfSmrg func_to_host_path_result=$1 3392e35d4d8eSmrg if test -n "$1"; then 3393e35d4d8eSmrg # Remove leading and trailing path separator characters from ARG. MSYS 3394e35d4d8eSmrg # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; 3395e35d4d8eSmrg # and winepath ignores them completely. 3396e35d4d8eSmrg func_stripname : : "$1" 3397e35d4d8eSmrg func_to_host_path_tmp1=$func_stripname_result 3398e35d4d8eSmrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 33990b0ce0bfSmrg func_to_host_path_result=$func_convert_core_msys_to_w32_result 3400e35d4d8eSmrg func_convert_path_check : ";" \ 3401e35d4d8eSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3402e35d4d8eSmrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 3403e35d4d8eSmrg fi 3404e35d4d8eSmrg} 3405e35d4d8eSmrg# end func_convert_path_msys_to_w32 3406e35d4d8eSmrg 3407e35d4d8eSmrg 3408e35d4d8eSmrg# func_convert_path_cygwin_to_w32 ARG 3409e35d4d8eSmrg# Convert path ARG from Cygwin to w32 format. Returns result in 3410e35d4d8eSmrg# func_to_host_file_result. 3411e35d4d8eSmrgfunc_convert_path_cygwin_to_w32 () 3412e35d4d8eSmrg{ 34130b0ce0bfSmrg $debug_cmd 34140b0ce0bfSmrg 34150b0ce0bfSmrg func_to_host_path_result=$1 3416e35d4d8eSmrg if test -n "$1"; then 3417e35d4d8eSmrg # See func_convert_path_msys_to_w32: 3418e35d4d8eSmrg func_stripname : : "$1" 3419e35d4d8eSmrg func_to_host_path_tmp1=$func_stripname_result 3420e35d4d8eSmrg func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` 3421e35d4d8eSmrg func_convert_path_check : ";" \ 3422e35d4d8eSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3423e35d4d8eSmrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 3424e35d4d8eSmrg fi 3425e35d4d8eSmrg} 3426e35d4d8eSmrg# end func_convert_path_cygwin_to_w32 3427e35d4d8eSmrg 3428e35d4d8eSmrg 3429e35d4d8eSmrg# func_convert_path_nix_to_w32 ARG 3430e35d4d8eSmrg# Convert path ARG from *nix to w32 format. Requires a wine environment and 3431e35d4d8eSmrg# a working winepath. Returns result in func_to_host_file_result. 3432e35d4d8eSmrgfunc_convert_path_nix_to_w32 () 3433e35d4d8eSmrg{ 34340b0ce0bfSmrg $debug_cmd 34350b0ce0bfSmrg 34360b0ce0bfSmrg func_to_host_path_result=$1 3437e35d4d8eSmrg if test -n "$1"; then 3438e35d4d8eSmrg # See func_convert_path_msys_to_w32: 3439e35d4d8eSmrg func_stripname : : "$1" 3440e35d4d8eSmrg func_to_host_path_tmp1=$func_stripname_result 3441e35d4d8eSmrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 34420b0ce0bfSmrg func_to_host_path_result=$func_convert_core_path_wine_to_w32_result 3443e35d4d8eSmrg func_convert_path_check : ";" \ 3444e35d4d8eSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3445e35d4d8eSmrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 3446e35d4d8eSmrg fi 3447e35d4d8eSmrg} 3448e35d4d8eSmrg# end func_convert_path_nix_to_w32 3449e35d4d8eSmrg 3450e35d4d8eSmrg 3451e35d4d8eSmrg# func_convert_path_msys_to_cygwin ARG 3452e35d4d8eSmrg# Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 3453e35d4d8eSmrg# Returns result in func_to_host_file_result. 3454e35d4d8eSmrgfunc_convert_path_msys_to_cygwin () 3455e35d4d8eSmrg{ 34560b0ce0bfSmrg $debug_cmd 34570b0ce0bfSmrg 34580b0ce0bfSmrg func_to_host_path_result=$1 3459e35d4d8eSmrg if test -n "$1"; then 3460e35d4d8eSmrg # See func_convert_path_msys_to_w32: 3461e35d4d8eSmrg func_stripname : : "$1" 3462e35d4d8eSmrg func_to_host_path_tmp1=$func_stripname_result 3463e35d4d8eSmrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 3464e35d4d8eSmrg func_cygpath -u -p "$func_convert_core_msys_to_w32_result" 34650b0ce0bfSmrg func_to_host_path_result=$func_cygpath_result 3466e35d4d8eSmrg func_convert_path_check : : \ 3467e35d4d8eSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3468e35d4d8eSmrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 3469e35d4d8eSmrg fi 3470e35d4d8eSmrg} 3471e35d4d8eSmrg# end func_convert_path_msys_to_cygwin 3472e35d4d8eSmrg 3473e35d4d8eSmrg 3474e35d4d8eSmrg# func_convert_path_nix_to_cygwin ARG 3475e35d4d8eSmrg# Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a 3476e35d4d8eSmrg# a wine environment, working winepath, and LT_CYGPATH set. Returns result in 3477e35d4d8eSmrg# func_to_host_file_result. 3478e35d4d8eSmrgfunc_convert_path_nix_to_cygwin () 3479e35d4d8eSmrg{ 34800b0ce0bfSmrg $debug_cmd 34810b0ce0bfSmrg 34820b0ce0bfSmrg func_to_host_path_result=$1 3483e35d4d8eSmrg if test -n "$1"; then 3484e35d4d8eSmrg # Remove leading and trailing path separator characters from 3485e35d4d8eSmrg # ARG. msys behavior is inconsistent here, cygpath turns them 3486e35d4d8eSmrg # into '.;' and ';.', and winepath ignores them completely. 3487e35d4d8eSmrg func_stripname : : "$1" 3488e35d4d8eSmrg func_to_host_path_tmp1=$func_stripname_result 3489e35d4d8eSmrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 3490e35d4d8eSmrg func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" 34910b0ce0bfSmrg func_to_host_path_result=$func_cygpath_result 3492e35d4d8eSmrg func_convert_path_check : : \ 3493e35d4d8eSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3494e35d4d8eSmrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 3495e35d4d8eSmrg fi 3496e35d4d8eSmrg} 3497e35d4d8eSmrg# end func_convert_path_nix_to_cygwin 3498e35d4d8eSmrg 3499e35d4d8eSmrg 35000b0ce0bfSmrg# func_dll_def_p FILE 35010b0ce0bfSmrg# True iff FILE is a Windows DLL '.def' file. 35020b0ce0bfSmrg# Keep in sync with _LT_DLL_DEF_P in libtool.m4 35030b0ce0bfSmrgfunc_dll_def_p () 35040b0ce0bfSmrg{ 35050b0ce0bfSmrg $debug_cmd 35060b0ce0bfSmrg 35070b0ce0bfSmrg func_dll_def_p_tmp=`$SED -n \ 35080b0ce0bfSmrg -e 's/^[ ]*//' \ 35090b0ce0bfSmrg -e '/^\(;.*\)*$/d' \ 35100b0ce0bfSmrg -e 's/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p' \ 35110b0ce0bfSmrg -e q \ 35120b0ce0bfSmrg "$1"` 35130b0ce0bfSmrg test DEF = "$func_dll_def_p_tmp" 35140b0ce0bfSmrg} 35150b0ce0bfSmrg 35160b0ce0bfSmrg 35171b12faf6Smrg# func_mode_compile arg... 35181b12faf6Smrgfunc_mode_compile () 35191b12faf6Smrg{ 35200b0ce0bfSmrg $debug_cmd 35210b0ce0bfSmrg 35221b12faf6Smrg # Get the compilation command and the source file. 35231b12faf6Smrg base_compile= 35240b0ce0bfSmrg srcfile=$nonopt # always keep a non-empty value in "srcfile" 35251b12faf6Smrg suppress_opt=yes 35261b12faf6Smrg suppress_output= 35271b12faf6Smrg arg_mode=normal 35281b12faf6Smrg libobj= 35291b12faf6Smrg later= 35301b12faf6Smrg pie_flag= 35311b12faf6Smrg 35321b12faf6Smrg for arg 35331b12faf6Smrg do 35341b12faf6Smrg case $arg_mode in 35351b12faf6Smrg arg ) 35361b12faf6Smrg # do not "continue". Instead, add this to base_compile 35370b0ce0bfSmrg lastarg=$arg 35381b12faf6Smrg arg_mode=normal 35391b12faf6Smrg ;; 35401b12faf6Smrg 35411b12faf6Smrg target ) 35420b0ce0bfSmrg libobj=$arg 35431b12faf6Smrg arg_mode=normal 35441b12faf6Smrg continue 35451b12faf6Smrg ;; 35461b12faf6Smrg 35471b12faf6Smrg normal ) 35481b12faf6Smrg # Accept any command-line options. 35491b12faf6Smrg case $arg in 35501b12faf6Smrg -o) 35511b12faf6Smrg test -n "$libobj" && \ 35520b0ce0bfSmrg func_fatal_error "you cannot specify '-o' more than once" 35531b12faf6Smrg arg_mode=target 35541b12faf6Smrg continue 35551b12faf6Smrg ;; 35561b12faf6Smrg 35571b12faf6Smrg -pie | -fpie | -fPIE) 3558e35d4d8eSmrg func_append pie_flag " $arg" 35591b12faf6Smrg continue 35601b12faf6Smrg ;; 35611b12faf6Smrg 35621b12faf6Smrg -shared | -static | -prefer-pic | -prefer-non-pic) 3563e35d4d8eSmrg func_append later " $arg" 35641b12faf6Smrg continue 35651b12faf6Smrg ;; 35661b12faf6Smrg 35671b12faf6Smrg -no-suppress) 356832b578d3Smrg suppress_opt=no 356932b578d3Smrg continue 357032b578d3Smrg ;; 357132b578d3Smrg 357232b578d3Smrg -Xcompiler) 357332b578d3Smrg arg_mode=arg # the next one goes into the "base_compile" arg list 357432b578d3Smrg continue # The current "srcfile" will either be retained or 357532b578d3Smrg ;; # replaced later. I would guess that would be a bug. 357632b578d3Smrg 357732b578d3Smrg -Wc,*) 35781b12faf6Smrg func_stripname '-Wc,' '' "$arg" 35791b12faf6Smrg args=$func_stripname_result 358032b578d3Smrg lastarg= 35810b0ce0bfSmrg save_ifs=$IFS; IFS=, 35821b12faf6Smrg for arg in $args; do 35830b0ce0bfSmrg IFS=$save_ifs 3584e35d4d8eSmrg func_append_quoted lastarg "$arg" 358532b578d3Smrg done 35860b0ce0bfSmrg IFS=$save_ifs 35871b12faf6Smrg func_stripname ' ' '' "$lastarg" 35881b12faf6Smrg lastarg=$func_stripname_result 358932b578d3Smrg 359032b578d3Smrg # Add the arguments to base_compile. 3591e35d4d8eSmrg func_append base_compile " $lastarg" 359232b578d3Smrg continue 359332b578d3Smrg ;; 359432b578d3Smrg 35951b12faf6Smrg *) 359632b578d3Smrg # Accept the current argument as the source file. 359732b578d3Smrg # The previous "srcfile" becomes the current argument. 359832b578d3Smrg # 35990b0ce0bfSmrg lastarg=$srcfile 36000b0ce0bfSmrg srcfile=$arg 360132b578d3Smrg ;; 360232b578d3Smrg esac # case $arg 360332b578d3Smrg ;; 360432b578d3Smrg esac # case $arg_mode 360532b578d3Smrg 360632b578d3Smrg # Aesthetically quote the previous argument. 3607e35d4d8eSmrg func_append_quoted base_compile "$lastarg" 360832b578d3Smrg done # for arg 360932b578d3Smrg 361032b578d3Smrg case $arg_mode in 361132b578d3Smrg arg) 36121b12faf6Smrg func_fatal_error "you must specify an argument for -Xcompile" 361332b578d3Smrg ;; 361432b578d3Smrg target) 36150b0ce0bfSmrg func_fatal_error "you must specify a target with '-o'" 361632b578d3Smrg ;; 361732b578d3Smrg *) 361832b578d3Smrg # Get the name of the library object. 36191b12faf6Smrg test -z "$libobj" && { 36201b12faf6Smrg func_basename "$srcfile" 36210b0ce0bfSmrg libobj=$func_basename_result 36221b12faf6Smrg } 362332b578d3Smrg ;; 362432b578d3Smrg esac 362532b578d3Smrg 362632b578d3Smrg # Recognize several different file suffixes. 362732b578d3Smrg # If the user specifies -o file.o, it is replaced with file.lo 362832b578d3Smrg case $libobj in 36291b12faf6Smrg *.[cCFSifmso] | \ 36301b12faf6Smrg *.ada | *.adb | *.ads | *.asm | \ 36311b12faf6Smrg *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ 3632e35d4d8eSmrg *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup) 36331b12faf6Smrg func_xform "$libobj" 36341b12faf6Smrg libobj=$func_xform_result 36351b12faf6Smrg ;; 363632b578d3Smrg esac 363732b578d3Smrg 363832b578d3Smrg case $libobj in 36391b12faf6Smrg *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; 364032b578d3Smrg *) 36410b0ce0bfSmrg func_fatal_error "cannot determine name of library object from '$libobj'" 364232b578d3Smrg ;; 364332b578d3Smrg esac 364432b578d3Smrg 364532b578d3Smrg func_infer_tag $base_compile 364632b578d3Smrg 364732b578d3Smrg for arg in $later; do 364832b578d3Smrg case $arg in 36491b12faf6Smrg -shared) 36500b0ce0bfSmrg test yes = "$build_libtool_libs" \ 36510b0ce0bfSmrg || func_fatal_configuration "cannot build a shared library" 36521b12faf6Smrg build_old_libs=no 36531b12faf6Smrg continue 36541b12faf6Smrg ;; 36551b12faf6Smrg 365632b578d3Smrg -static) 36571b12faf6Smrg build_libtool_libs=no 365832b578d3Smrg build_old_libs=yes 365932b578d3Smrg continue 366032b578d3Smrg ;; 366132b578d3Smrg 366232b578d3Smrg -prefer-pic) 366332b578d3Smrg pic_mode=yes 366432b578d3Smrg continue 366532b578d3Smrg ;; 366632b578d3Smrg 366732b578d3Smrg -prefer-non-pic) 366832b578d3Smrg pic_mode=no 366932b578d3Smrg continue 367032b578d3Smrg ;; 367132b578d3Smrg esac 367232b578d3Smrg done 367332b578d3Smrg 36740b0ce0bfSmrg func_quote_arg pretty "$libobj" 36750b0ce0bfSmrg test "X$libobj" != "X$func_quote_arg_result" \ 36761b12faf6Smrg && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ 36770b0ce0bfSmrg && func_warning "libobj name '$libobj' may not contain shell special characters." 36781b12faf6Smrg func_dirname_and_basename "$obj" "/" "" 36790b0ce0bfSmrg objname=$func_basename_result 36800b0ce0bfSmrg xdir=$func_dirname_result 36810b0ce0bfSmrg lobj=$xdir$objdir/$objname 368232b578d3Smrg 36831b12faf6Smrg test -z "$base_compile" && \ 36841b12faf6Smrg func_fatal_help "you must specify a compilation command" 368532b578d3Smrg 368632b578d3Smrg # Delete any leftover library objects. 36870b0ce0bfSmrg if test yes = "$build_old_libs"; then 368832b578d3Smrg removelist="$obj $lobj $libobj ${libobj}T" 368932b578d3Smrg else 369032b578d3Smrg removelist="$lobj $libobj ${libobj}T" 369132b578d3Smrg fi 369232b578d3Smrg 369332b578d3Smrg # On Cygwin there's no "real" PIC flag so we must build both object types 369432b578d3Smrg case $host_os in 36951b12faf6Smrg cygwin* | mingw* | pw32* | os2* | cegcc*) 369632b578d3Smrg pic_mode=default 369732b578d3Smrg ;; 369832b578d3Smrg esac 36990b0ce0bfSmrg if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then 370032b578d3Smrg # non-PIC code in shared libraries is not supported 370132b578d3Smrg pic_mode=default 370232b578d3Smrg fi 370332b578d3Smrg 370432b578d3Smrg # Calculate the filename of the output object if compiler does 370532b578d3Smrg # not support -o with -c 37060b0ce0bfSmrg if test no = "$compiler_c_o"; then 37070b0ce0bfSmrg output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext 37080b0ce0bfSmrg lockfile=$output_obj.lock 370932b578d3Smrg else 371032b578d3Smrg output_obj= 371132b578d3Smrg need_locks=no 371232b578d3Smrg lockfile= 371332b578d3Smrg fi 371432b578d3Smrg 371532b578d3Smrg # Lock this critical section if it is needed 371632b578d3Smrg # We use this script file to make the link, it avoids creating a new file 37170b0ce0bfSmrg if test yes = "$need_locks"; then 37181b12faf6Smrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 37191b12faf6Smrg func_echo "Waiting for $lockfile to be removed" 372032b578d3Smrg sleep 2 372132b578d3Smrg done 37220b0ce0bfSmrg elif test warn = "$need_locks"; then 372332b578d3Smrg if test -f "$lockfile"; then 37241b12faf6Smrg $ECHO "\ 372532b578d3Smrg*** ERROR, $lockfile exists and contains: 372632b578d3Smrg`cat $lockfile 2>/dev/null` 372732b578d3Smrg 372832b578d3SmrgThis indicates that another process is trying to use the same 372932b578d3Smrgtemporary object file, and libtool could not work around it because 37300b0ce0bfSmrgyour compiler does not support '-c' and '-o' together. If you 373132b578d3Smrgrepeat this compilation, it may succeed, by chance, but you had better 373232b578d3Smrgavoid parallel builds (make -j) in this platform, or get a better 373332b578d3Smrgcompiler." 373432b578d3Smrg 37351b12faf6Smrg $opt_dry_run || $RM $removelist 373632b578d3Smrg exit $EXIT_FAILURE 373732b578d3Smrg fi 3738e35d4d8eSmrg func_append removelist " $output_obj" 37391b12faf6Smrg $ECHO "$srcfile" > "$lockfile" 374032b578d3Smrg fi 374132b578d3Smrg 37421b12faf6Smrg $opt_dry_run || $RM $removelist 3743e35d4d8eSmrg func_append removelist " $lockfile" 37441b12faf6Smrg trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 37451b12faf6Smrg 3746e35d4d8eSmrg func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 3747e35d4d8eSmrg srcfile=$func_to_tool_file_result 37480b0ce0bfSmrg func_quote_arg pretty "$srcfile" 37490b0ce0bfSmrg qsrcfile=$func_quote_arg_result 375032b578d3Smrg 375132b578d3Smrg # Only build a PIC object if we are building libtool libraries. 37520b0ce0bfSmrg if test yes = "$build_libtool_libs"; then 375332b578d3Smrg # Without this assignment, base_compile gets emptied. 375432b578d3Smrg fbsd_hideous_sh_bug=$base_compile 375532b578d3Smrg 37560b0ce0bfSmrg if test no != "$pic_mode"; then 375732b578d3Smrg command="$base_compile $qsrcfile $pic_flag" 375832b578d3Smrg else 375932b578d3Smrg # Don't build PIC code 376032b578d3Smrg command="$base_compile $qsrcfile" 376132b578d3Smrg fi 376232b578d3Smrg 37631b12faf6Smrg func_mkdir_p "$xdir$objdir" 376432b578d3Smrg 376532b578d3Smrg if test -z "$output_obj"; then 376632b578d3Smrg # Place PIC objects in $objdir 3767e35d4d8eSmrg func_append command " -o $lobj" 376832b578d3Smrg fi 376932b578d3Smrg 37701b12faf6Smrg func_show_eval_locale "$command" \ 37711b12faf6Smrg 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' 377232b578d3Smrg 37730b0ce0bfSmrg if test warn = "$need_locks" && 377432b578d3Smrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 37751b12faf6Smrg $ECHO "\ 377632b578d3Smrg*** ERROR, $lockfile contains: 377732b578d3Smrg`cat $lockfile 2>/dev/null` 377832b578d3Smrg 377932b578d3Smrgbut it should contain: 378032b578d3Smrg$srcfile 378132b578d3Smrg 378232b578d3SmrgThis indicates that another process is trying to use the same 378332b578d3Smrgtemporary object file, and libtool could not work around it because 37840b0ce0bfSmrgyour compiler does not support '-c' and '-o' together. If you 378532b578d3Smrgrepeat this compilation, it may succeed, by chance, but you had better 378632b578d3Smrgavoid parallel builds (make -j) in this platform, or get a better 378732b578d3Smrgcompiler." 378832b578d3Smrg 37891b12faf6Smrg $opt_dry_run || $RM $removelist 379032b578d3Smrg exit $EXIT_FAILURE 379132b578d3Smrg fi 379232b578d3Smrg 379332b578d3Smrg # Just move the object if needed, then go on to compile the next one 379432b578d3Smrg if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then 37951b12faf6Smrg func_show_eval '$MV "$output_obj" "$lobj"' \ 37961b12faf6Smrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 379732b578d3Smrg fi 379832b578d3Smrg 379932b578d3Smrg # Allow error messages only from the first compilation. 38000b0ce0bfSmrg if test yes = "$suppress_opt"; then 38011b12faf6Smrg suppress_output=' >/dev/null 2>&1' 380232b578d3Smrg fi 380332b578d3Smrg fi 380432b578d3Smrg 380532b578d3Smrg # Only build a position-dependent object if we build old libraries. 38060b0ce0bfSmrg if test yes = "$build_old_libs"; then 38070b0ce0bfSmrg if test yes != "$pic_mode"; then 380832b578d3Smrg # Don't build PIC code 38091b12faf6Smrg command="$base_compile $qsrcfile$pie_flag" 381032b578d3Smrg else 381132b578d3Smrg command="$base_compile $qsrcfile $pic_flag" 381232b578d3Smrg fi 38130b0ce0bfSmrg if test yes = "$compiler_c_o"; then 3814e35d4d8eSmrg func_append command " -o $obj" 381532b578d3Smrg fi 381632b578d3Smrg 381732b578d3Smrg # Suppress compiler output if we already did a PIC compilation. 3818e35d4d8eSmrg func_append command "$suppress_output" 38191b12faf6Smrg func_show_eval_locale "$command" \ 38201b12faf6Smrg '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 382132b578d3Smrg 38220b0ce0bfSmrg if test warn = "$need_locks" && 382332b578d3Smrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 38241b12faf6Smrg $ECHO "\ 382532b578d3Smrg*** ERROR, $lockfile contains: 382632b578d3Smrg`cat $lockfile 2>/dev/null` 382732b578d3Smrg 382832b578d3Smrgbut it should contain: 382932b578d3Smrg$srcfile 383032b578d3Smrg 383132b578d3SmrgThis indicates that another process is trying to use the same 383232b578d3Smrgtemporary object file, and libtool could not work around it because 38330b0ce0bfSmrgyour compiler does not support '-c' and '-o' together. If you 383432b578d3Smrgrepeat this compilation, it may succeed, by chance, but you had better 383532b578d3Smrgavoid parallel builds (make -j) in this platform, or get a better 383632b578d3Smrgcompiler." 383732b578d3Smrg 38381b12faf6Smrg $opt_dry_run || $RM $removelist 383932b578d3Smrg exit $EXIT_FAILURE 384032b578d3Smrg fi 384132b578d3Smrg 384232b578d3Smrg # Just move the object if needed 384332b578d3Smrg if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then 38441b12faf6Smrg func_show_eval '$MV "$output_obj" "$obj"' \ 38451b12faf6Smrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 384632b578d3Smrg fi 384732b578d3Smrg fi 384832b578d3Smrg 38491b12faf6Smrg $opt_dry_run || { 38501b12faf6Smrg func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" 385132b578d3Smrg 38521b12faf6Smrg # Unlock the critical section if it was locked 38530b0ce0bfSmrg if test no != "$need_locks"; then 38541b12faf6Smrg removelist=$lockfile 38551b12faf6Smrg $RM "$lockfile" 38561b12faf6Smrg fi 38571b12faf6Smrg } 385832b578d3Smrg 385932b578d3Smrg exit $EXIT_SUCCESS 38601b12faf6Smrg} 386132b578d3Smrg 38621b12faf6Smrg$opt_help || { 38630b0ce0bfSmrg test compile = "$opt_mode" && func_mode_compile ${1+"$@"} 38641b12faf6Smrg} 386532b578d3Smrg 38661b12faf6Smrgfunc_mode_help () 38671b12faf6Smrg{ 38681b12faf6Smrg # We need to display help for each of the modes. 3869e35d4d8eSmrg case $opt_mode in 38701b12faf6Smrg "") 38711b12faf6Smrg # Generic help is extracted from the usage comments 38721b12faf6Smrg # at the start of this file. 38731b12faf6Smrg func_help 38741b12faf6Smrg ;; 387532b578d3Smrg 38761b12faf6Smrg clean) 38771b12faf6Smrg $ECHO \ 38781b12faf6Smrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... 387932b578d3Smrg 38801b12faf6SmrgRemove files from the build directory. 388132b578d3Smrg 38821b12faf6SmrgRM is the name of the program to use to delete files associated with each FILE 38830b0ce0bfSmrg(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 38841b12faf6Smrgto RM. 388532b578d3Smrg 38861b12faf6SmrgIf FILE is a libtool library, object or program, all the files associated 38871b12faf6Smrgwith it are deleted. Otherwise, only FILE itself is deleted using RM." 38881b12faf6Smrg ;; 388932b578d3Smrg 38901b12faf6Smrg compile) 38911b12faf6Smrg $ECHO \ 38921b12faf6Smrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE 389332b578d3Smrg 38941b12faf6SmrgCompile a source file into a libtool library object. 389532b578d3Smrg 38961b12faf6SmrgThis mode accepts the following additional options: 389732b578d3Smrg 38981b12faf6Smrg -o OUTPUT-FILE set the output file name to OUTPUT-FILE 38991b12faf6Smrg -no-suppress do not suppress compiler output for multiple passes 3900e35d4d8eSmrg -prefer-pic try to build PIC objects only 3901e35d4d8eSmrg -prefer-non-pic try to build non-PIC objects only 39020b0ce0bfSmrg -shared do not build a '.o' file suitable for static linking 39030b0ce0bfSmrg -static only build a '.o' file suitable for static linking 39040b0ce0bfSmrg -Wc,FLAG 39050b0ce0bfSmrg -Xcompiler FLAG pass FLAG directly to the compiler 390632b578d3Smrg 39070b0ce0bfSmrgCOMPILE-COMMAND is a command to be used in creating a 'standard' object file 39081b12faf6Smrgfrom the given SOURCEFILE. 390932b578d3Smrg 39101b12faf6SmrgThe output file name is determined by removing the directory component from 39110b0ce0bfSmrgSOURCEFILE, then substituting the C source code suffix '.c' with the 39120b0ce0bfSmrglibrary object suffix, '.lo'." 39131b12faf6Smrg ;; 391432b578d3Smrg 39151b12faf6Smrg execute) 39161b12faf6Smrg $ECHO \ 39171b12faf6Smrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... 391832b578d3Smrg 39191b12faf6SmrgAutomatically set library path, then run a program. 392032b578d3Smrg 39211b12faf6SmrgThis mode accepts the following additional options: 392232b578d3Smrg 39231b12faf6Smrg -dlopen FILE add the directory containing FILE to the library path 392432b578d3Smrg 39250b0ce0bfSmrgThis mode sets the library path environment variable according to '-dlopen' 39261b12faf6Smrgflags. 392732b578d3Smrg 39281b12faf6SmrgIf any of the ARGS are libtool executable wrappers, then they are translated 39291b12faf6Smrginto their corresponding uninstalled binary, and any of their required library 39301b12faf6Smrgdirectories are added to the library path. 393132b578d3Smrg 39321b12faf6SmrgThen, COMMAND is executed, with ARGS as arguments." 39331b12faf6Smrg ;; 393432b578d3Smrg 39351b12faf6Smrg finish) 39361b12faf6Smrg $ECHO \ 39371b12faf6Smrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]... 393832b578d3Smrg 39391b12faf6SmrgComplete the installation of libtool libraries. 394032b578d3Smrg 39411b12faf6SmrgEach LIBDIR is a directory that contains libtool libraries. 394232b578d3Smrg 39431b12faf6SmrgThe commands that this mode executes may require superuser privileges. Use 39440b0ce0bfSmrgthe '--dry-run' option if you just want to see what would be executed." 39451b12faf6Smrg ;; 394632b578d3Smrg 39471b12faf6Smrg install) 39481b12faf6Smrg $ECHO \ 39491b12faf6Smrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... 395032b578d3Smrg 39511b12faf6SmrgInstall executables or libraries. 395232b578d3Smrg 39531b12faf6SmrgINSTALL-COMMAND is the installation command. The first component should be 39540b0ce0bfSmrgeither the 'install' or 'cp' program. 395532b578d3Smrg 39561b12faf6SmrgThe following components of INSTALL-COMMAND are treated specially: 395732b578d3Smrg 3958e35d4d8eSmrg -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation 395932b578d3Smrg 39601b12faf6SmrgThe rest of the components are interpreted as arguments to that command (only 39611b12faf6SmrgBSD-compatible install options are recognized)." 39621b12faf6Smrg ;; 396332b578d3Smrg 39641b12faf6Smrg link) 39651b12faf6Smrg $ECHO \ 39661b12faf6Smrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND... 396732b578d3Smrg 39681b12faf6SmrgLink object files or libraries together to form another library, or to 39691b12faf6Smrgcreate an executable program. 397032b578d3Smrg 39711b12faf6SmrgLINK-COMMAND is a command using the C compiler that you would use to create 39721b12faf6Smrga program from several object files. 397332b578d3Smrg 39741b12faf6SmrgThe following components of LINK-COMMAND are treated specially: 397532b578d3Smrg 39761b12faf6Smrg -all-static do not do any dynamic linking at all 39771b12faf6Smrg -avoid-version do not add a version suffix if possible 3978e35d4d8eSmrg -bindir BINDIR specify path to binaries directory (for systems where 3979e35d4d8eSmrg libraries must be found in the PATH setting at runtime) 39800b0ce0bfSmrg -dlopen FILE '-dlpreopen' FILE if it cannot be dlopened at runtime 39811b12faf6Smrg -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols 39821b12faf6Smrg -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) 39831b12faf6Smrg -export-symbols SYMFILE 39841b12faf6Smrg try to export only the symbols listed in SYMFILE 39851b12faf6Smrg -export-symbols-regex REGEX 39861b12faf6Smrg try to export only the symbols matching REGEX 39871b12faf6Smrg -LLIBDIR search LIBDIR for required installed libraries 39881b12faf6Smrg -lNAME OUTPUT-FILE requires the installed library libNAME 39891b12faf6Smrg -module build a library that can dlopened 39901b12faf6Smrg -no-fast-install disable the fast-install mode 39911b12faf6Smrg -no-install link a not-installable executable 39921b12faf6Smrg -no-undefined declare that a library does not refer to external symbols 39931b12faf6Smrg -o OUTPUT-FILE create OUTPUT-FILE from the specified objects 39940b0ce0bfSmrg -objectlist FILE use a list of object files found in FILE to specify objects 39950b0ce0bfSmrg -os2dllname NAME force a short DLL name on OS/2 (no effect on other OSes) 39961b12faf6Smrg -precious-files-regex REGEX 39971b12faf6Smrg don't remove output files matching REGEX 39981b12faf6Smrg -release RELEASE specify package release information 39991b12faf6Smrg -rpath LIBDIR the created library will eventually be installed in LIBDIR 40001b12faf6Smrg -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries 40011b12faf6Smrg -shared only do dynamic linking of libtool libraries 40021b12faf6Smrg -shrext SUFFIX override the standard shared library file extension 40031b12faf6Smrg -static do not do any dynamic linking of uninstalled libtool libraries 40041b12faf6Smrg -static-libtool-libs 40051b12faf6Smrg do not do any dynamic linking of libtool libraries 40061b12faf6Smrg -version-info CURRENT[:REVISION[:AGE]] 40071b12faf6Smrg specify library version info [each variable defaults to 0] 40081b12faf6Smrg -weak LIBNAME declare that the target provides the LIBNAME interface 4009e35d4d8eSmrg -Wc,FLAG 4010e35d4d8eSmrg -Xcompiler FLAG pass linker-specific FLAG directly to the compiler 40110b0ce0bfSmrg -Wa,FLAG 40120b0ce0bfSmrg -Xassembler FLAG pass linker-specific FLAG directly to the assembler 4013e35d4d8eSmrg -Wl,FLAG 4014e35d4d8eSmrg -Xlinker FLAG pass linker-specific FLAG directly to the linker 4015e35d4d8eSmrg -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) 401632b578d3Smrg 40170b0ce0bfSmrgAll other options (arguments beginning with '-') are ignored. 401832b578d3Smrg 40190b0ce0bfSmrgEvery other argument is treated as a filename. Files ending in '.la' are 40201b12faf6Smrgtreated as uninstalled libtool libraries, other files are standard or library 40211b12faf6Smrgobject files. 40222a51b5beSmrg 40230b0ce0bfSmrgIf the OUTPUT-FILE ends in '.la', then a libtool library is created, 40240b0ce0bfSmrgonly library objects ('.lo' files) may be specified, and '-rpath' is 40251b12faf6Smrgrequired, except when creating a convenience library. 402632b578d3Smrg 40270b0ce0bfSmrgIf OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created 40280b0ce0bfSmrgusing 'ar' and 'ranlib', or on Windows using 'lib'. 402932b578d3Smrg 40300b0ce0bfSmrgIf OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file 40311b12faf6Smrgis created, otherwise an executable program is created." 403232b578d3Smrg ;; 403332b578d3Smrg 40341b12faf6Smrg uninstall) 40351b12faf6Smrg $ECHO \ 40361b12faf6Smrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... 403732b578d3Smrg 40381b12faf6SmrgRemove libraries from an installation directory. 403932b578d3Smrg 40401b12faf6SmrgRM is the name of the program to use to delete files associated with each FILE 40410b0ce0bfSmrg(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 40421b12faf6Smrgto RM. 404332b578d3Smrg 40441b12faf6SmrgIf FILE is a libtool library, all the files associated with it are deleted. 40451b12faf6SmrgOtherwise, only FILE itself is deleted using RM." 40461b12faf6Smrg ;; 404732b578d3Smrg 40481b12faf6Smrg *) 40490b0ce0bfSmrg func_fatal_help "invalid operation mode '$opt_mode'" 40501b12faf6Smrg ;; 40511b12faf6Smrg esac 405232b578d3Smrg 4053e35d4d8eSmrg echo 40540b0ce0bfSmrg $ECHO "Try '$progname --help' for more information about other modes." 40551b12faf6Smrg} 405632b578d3Smrg 4057e35d4d8eSmrg# Now that we've collected a possible --mode arg, show help if necessary 4058e35d4d8eSmrgif $opt_help; then 40590b0ce0bfSmrg if test : = "$opt_help"; then 4060e35d4d8eSmrg func_mode_help 4061e35d4d8eSmrg else 4062e35d4d8eSmrg { 4063e35d4d8eSmrg func_help noexit 4064e35d4d8eSmrg for opt_mode in compile link execute install finish uninstall clean; do 4065e35d4d8eSmrg func_mode_help 4066e35d4d8eSmrg done 40670b0ce0bfSmrg } | $SED -n '1p; 2,$s/^Usage:/ or: /p' 4068e35d4d8eSmrg { 4069e35d4d8eSmrg func_help noexit 4070e35d4d8eSmrg for opt_mode in compile link execute install finish uninstall clean; do 4071e35d4d8eSmrg echo 4072e35d4d8eSmrg func_mode_help 4073e35d4d8eSmrg done 4074e35d4d8eSmrg } | 40750b0ce0bfSmrg $SED '1d 4076e35d4d8eSmrg /^When reporting/,/^Report/{ 4077e35d4d8eSmrg H 4078e35d4d8eSmrg d 4079e35d4d8eSmrg } 4080e35d4d8eSmrg $x 4081e35d4d8eSmrg /information about other modes/d 4082e35d4d8eSmrg /more detailed .*MODE/d 4083e35d4d8eSmrg s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' 4084e35d4d8eSmrg fi 4085e35d4d8eSmrg exit $? 4086e35d4d8eSmrgfi 408732b578d3Smrg 408832b578d3Smrg 40891b12faf6Smrg# func_mode_execute arg... 40901b12faf6Smrgfunc_mode_execute () 40911b12faf6Smrg{ 40920b0ce0bfSmrg $debug_cmd 40930b0ce0bfSmrg 40941b12faf6Smrg # The first argument is the command name. 40950b0ce0bfSmrg cmd=$nonopt 40961b12faf6Smrg test -z "$cmd" && \ 40971b12faf6Smrg func_fatal_help "you must specify a COMMAND" 409832b578d3Smrg 40991b12faf6Smrg # Handle -dlopen flags immediately. 4100e35d4d8eSmrg for file in $opt_dlopen; do 41011b12faf6Smrg test -f "$file" \ 41020b0ce0bfSmrg || func_fatal_help "'$file' is not a file" 410332b578d3Smrg 41041b12faf6Smrg dir= 41051b12faf6Smrg case $file in 41061b12faf6Smrg *.la) 4107e35d4d8eSmrg func_resolve_sysroot "$file" 4108e35d4d8eSmrg file=$func_resolve_sysroot_result 4109e35d4d8eSmrg 41101b12faf6Smrg # Check to see that this really is a libtool archive. 41111b12faf6Smrg func_lalib_unsafe_p "$file" \ 41120b0ce0bfSmrg || func_fatal_help "'$lib' is not a valid libtool archive" 411332b578d3Smrg 41141b12faf6Smrg # Read the libtool library. 41151b12faf6Smrg dlname= 41161b12faf6Smrg library_names= 41171b12faf6Smrg func_source "$file" 411832b578d3Smrg 41191b12faf6Smrg # Skip this library if it cannot be dlopened. 41201b12faf6Smrg if test -z "$dlname"; then 41211b12faf6Smrg # Warn if it was a shared library. 41221b12faf6Smrg test -n "$library_names" && \ 41230b0ce0bfSmrg func_warning "'$file' was not linked with '-export-dynamic'" 41241b12faf6Smrg continue 41251b12faf6Smrg fi 412632b578d3Smrg 41271b12faf6Smrg func_dirname "$file" "" "." 41280b0ce0bfSmrg dir=$func_dirname_result 412932b578d3Smrg 41301b12faf6Smrg if test -f "$dir/$objdir/$dlname"; then 4131e35d4d8eSmrg func_append dir "/$objdir" 41321b12faf6Smrg else 41331b12faf6Smrg if test ! -f "$dir/$dlname"; then 41340b0ce0bfSmrg func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'" 41351b12faf6Smrg fi 41361b12faf6Smrg fi 413732b578d3Smrg ;; 413832b578d3Smrg 41391b12faf6Smrg *.lo) 41401b12faf6Smrg # Just add the directory containing the .lo file. 41411b12faf6Smrg func_dirname "$file" "" "." 41420b0ce0bfSmrg dir=$func_dirname_result 414332b578d3Smrg ;; 414432b578d3Smrg 41451b12faf6Smrg *) 41460b0ce0bfSmrg func_warning "'-dlopen' is ignored for non-libtool libraries and objects" 414732b578d3Smrg continue 414832b578d3Smrg ;; 41491b12faf6Smrg esac 415032b578d3Smrg 41511b12faf6Smrg # Get the absolute pathname. 41521b12faf6Smrg absdir=`cd "$dir" && pwd` 41530b0ce0bfSmrg test -n "$absdir" && dir=$absdir 415432b578d3Smrg 41551b12faf6Smrg # Now add the directory to shlibpath_var. 41561b12faf6Smrg if eval "test -z \"\$$shlibpath_var\""; then 41571b12faf6Smrg eval "$shlibpath_var=\"\$dir\"" 41581b12faf6Smrg else 41591b12faf6Smrg eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" 41601b12faf6Smrg fi 41611b12faf6Smrg done 416232b578d3Smrg 41631b12faf6Smrg # This variable tells wrapper scripts just to set shlibpath_var 41641b12faf6Smrg # rather than running their programs. 41650b0ce0bfSmrg libtool_execute_magic=$magic 416632b578d3Smrg 41671b12faf6Smrg # Check if any of the arguments is a wrapper script. 41681b12faf6Smrg args= 41691b12faf6Smrg for file 41701b12faf6Smrg do 41711b12faf6Smrg case $file in 4172e35d4d8eSmrg -* | *.la | *.lo ) ;; 41731b12faf6Smrg *) 41741b12faf6Smrg # Do a test to see if this is really a libtool program. 41751b12faf6Smrg if func_ltwrapper_script_p "$file"; then 41761b12faf6Smrg func_source "$file" 41771b12faf6Smrg # Transform arg to wrapped name. 41780b0ce0bfSmrg file=$progdir/$program 41791b12faf6Smrg elif func_ltwrapper_executable_p "$file"; then 41801b12faf6Smrg func_ltwrapper_scriptname "$file" 41811b12faf6Smrg func_source "$func_ltwrapper_scriptname_result" 41821b12faf6Smrg # Transform arg to wrapped name. 41830b0ce0bfSmrg file=$progdir/$program 41841b12faf6Smrg fi 41851b12faf6Smrg ;; 41861b12faf6Smrg esac 41871b12faf6Smrg # Quote arguments (to preserve shell metacharacters). 4188e35d4d8eSmrg func_append_quoted args "$file" 41891b12faf6Smrg done 419032b578d3Smrg 41910b0ce0bfSmrg if $opt_dry_run; then 41920b0ce0bfSmrg # Display what would be done. 41930b0ce0bfSmrg if test -n "$shlibpath_var"; then 41940b0ce0bfSmrg eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" 41950b0ce0bfSmrg echo "export $shlibpath_var" 41960b0ce0bfSmrg fi 41970b0ce0bfSmrg $ECHO "$cmd$args" 41980b0ce0bfSmrg exit $EXIT_SUCCESS 41990b0ce0bfSmrg else 42001b12faf6Smrg if test -n "$shlibpath_var"; then 42011b12faf6Smrg # Export the shlibpath_var. 42021b12faf6Smrg eval "export $shlibpath_var" 42031b12faf6Smrg fi 420432b578d3Smrg 42051b12faf6Smrg # Restore saved environment variables 42061b12faf6Smrg for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 42071b12faf6Smrg do 42081b12faf6Smrg eval "if test \"\${save_$lt_var+set}\" = set; then 42091b12faf6Smrg $lt_var=\$save_$lt_var; export $lt_var 421032b578d3Smrg else 42111b12faf6Smrg $lt_unset $lt_var 42121b12faf6Smrg fi" 42131b12faf6Smrg done 421432b578d3Smrg 42151b12faf6Smrg # Now prepare to actually exec the command. 42160b0ce0bfSmrg exec_cmd=\$cmd$args 42171b12faf6Smrg fi 42181b12faf6Smrg} 421932b578d3Smrg 42200b0ce0bfSmrgtest execute = "$opt_mode" && func_mode_execute ${1+"$@"} 422132b578d3Smrg 422232b578d3Smrg 42231b12faf6Smrg# func_mode_finish arg... 42241b12faf6Smrgfunc_mode_finish () 42251b12faf6Smrg{ 42260b0ce0bfSmrg $debug_cmd 42270b0ce0bfSmrg 4228e35d4d8eSmrg libs= 4229e35d4d8eSmrg libdirs= 42301b12faf6Smrg admincmds= 423132b578d3Smrg 4232e35d4d8eSmrg for opt in "$nonopt" ${1+"$@"} 4233e35d4d8eSmrg do 4234e35d4d8eSmrg if test -d "$opt"; then 4235e35d4d8eSmrg func_append libdirs " $opt" 4236e35d4d8eSmrg 4237e35d4d8eSmrg elif test -f "$opt"; then 4238e35d4d8eSmrg if func_lalib_unsafe_p "$opt"; then 4239e35d4d8eSmrg func_append libs " $opt" 4240e35d4d8eSmrg else 42410b0ce0bfSmrg func_warning "'$opt' is not a valid libtool archive" 4242e35d4d8eSmrg fi 4243e35d4d8eSmrg 4244e35d4d8eSmrg else 42450b0ce0bfSmrg func_fatal_error "invalid argument '$opt'" 4246e35d4d8eSmrg fi 4247e35d4d8eSmrg done 4248e35d4d8eSmrg 4249e35d4d8eSmrg if test -n "$libs"; then 4250e35d4d8eSmrg if test -n "$lt_sysroot"; then 4251e35d4d8eSmrg sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` 4252e35d4d8eSmrg sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" 4253e35d4d8eSmrg else 4254e35d4d8eSmrg sysroot_cmd= 4255e35d4d8eSmrg fi 4256e35d4d8eSmrg 4257e35d4d8eSmrg # Remove sysroot references 4258e35d4d8eSmrg if $opt_dry_run; then 4259e35d4d8eSmrg for lib in $libs; do 42600b0ce0bfSmrg echo "removing references to $lt_sysroot and '=' prefixes from $lib" 4261e35d4d8eSmrg done 4262e35d4d8eSmrg else 4263e35d4d8eSmrg tmpdir=`func_mktempdir` 4264e35d4d8eSmrg for lib in $libs; do 42650b0ce0bfSmrg $SED -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ 4266e35d4d8eSmrg > $tmpdir/tmp-la 4267e35d4d8eSmrg mv -f $tmpdir/tmp-la $lib 4268e35d4d8eSmrg done 4269e35d4d8eSmrg ${RM}r "$tmpdir" 4270e35d4d8eSmrg fi 4271e35d4d8eSmrg fi 427232b578d3Smrg 4273e35d4d8eSmrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 42741b12faf6Smrg for libdir in $libdirs; do 42751b12faf6Smrg if test -n "$finish_cmds"; then 42761b12faf6Smrg # Do each command in the finish commands. 42771b12faf6Smrg func_execute_cmds "$finish_cmds" 'admincmds="$admincmds 42781b12faf6Smrg'"$cmd"'"' 427932b578d3Smrg fi 42801b12faf6Smrg if test -n "$finish_eval"; then 42811b12faf6Smrg # Do the single finish_eval. 42821b12faf6Smrg eval cmds=\"$finish_eval\" 4283e35d4d8eSmrg $opt_dry_run || eval "$cmds" || func_append admincmds " 42841b12faf6Smrg $cmds" 42851b12faf6Smrg fi 42861b12faf6Smrg done 42871b12faf6Smrg fi 428832b578d3Smrg 42891b12faf6Smrg # Exit here if they wanted silent mode. 42900b0ce0bfSmrg $opt_quiet && exit $EXIT_SUCCESS 429132b578d3Smrg 4292e35d4d8eSmrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 4293e35d4d8eSmrg echo "----------------------------------------------------------------------" 4294e35d4d8eSmrg echo "Libraries have been installed in:" 4295e35d4d8eSmrg for libdir in $libdirs; do 4296e35d4d8eSmrg $ECHO " $libdir" 4297e35d4d8eSmrg done 4298e35d4d8eSmrg echo 4299e35d4d8eSmrg echo "If you ever happen to want to link against installed libraries" 4300e35d4d8eSmrg echo "in a given directory, LIBDIR, you must either use libtool, and" 43010b0ce0bfSmrg echo "specify the full pathname of the library, or use the '-LLIBDIR'" 4302e35d4d8eSmrg echo "flag during linking and do at least one of the following:" 4303e35d4d8eSmrg if test -n "$shlibpath_var"; then 43040b0ce0bfSmrg echo " - add LIBDIR to the '$shlibpath_var' environment variable" 4305e35d4d8eSmrg echo " during execution" 4306e35d4d8eSmrg fi 4307e35d4d8eSmrg if test -n "$runpath_var"; then 43080b0ce0bfSmrg echo " - add LIBDIR to the '$runpath_var' environment variable" 4309e35d4d8eSmrg echo " during linking" 4310e35d4d8eSmrg fi 4311e35d4d8eSmrg if test -n "$hardcode_libdir_flag_spec"; then 4312e35d4d8eSmrg libdir=LIBDIR 4313e35d4d8eSmrg eval flag=\"$hardcode_libdir_flag_spec\" 4314e35d4d8eSmrg 43150b0ce0bfSmrg $ECHO " - use the '$flag' linker flag" 4316e35d4d8eSmrg fi 4317e35d4d8eSmrg if test -n "$admincmds"; then 4318e35d4d8eSmrg $ECHO " - have your system administrator run these commands:$admincmds" 4319e35d4d8eSmrg fi 4320e35d4d8eSmrg if test -f /etc/ld.so.conf; then 43210b0ce0bfSmrg echo " - have your system administrator add LIBDIR to '/etc/ld.so.conf'" 4322e35d4d8eSmrg fi 4323e35d4d8eSmrg echo 43241b12faf6Smrg 4325e35d4d8eSmrg echo "See any operating system documentation about shared libraries for" 4326e35d4d8eSmrg case $host in 4327e35d4d8eSmrg solaris2.[6789]|solaris2.1[0-9]) 4328e35d4d8eSmrg echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" 4329e35d4d8eSmrg echo "pages." 4330e35d4d8eSmrg ;; 4331e35d4d8eSmrg *) 4332e35d4d8eSmrg echo "more information, such as the ld(1) and ld.so(8) manual pages." 4333e35d4d8eSmrg ;; 4334e35d4d8eSmrg esac 4335e35d4d8eSmrg echo "----------------------------------------------------------------------" 43361b12faf6Smrg fi 43371b12faf6Smrg exit $EXIT_SUCCESS 43381b12faf6Smrg} 43391b12faf6Smrg 43400b0ce0bfSmrgtest finish = "$opt_mode" && func_mode_finish ${1+"$@"} 43411b12faf6Smrg 43421b12faf6Smrg 43431b12faf6Smrg# func_mode_install arg... 43441b12faf6Smrgfunc_mode_install () 43451b12faf6Smrg{ 43460b0ce0bfSmrg $debug_cmd 43470b0ce0bfSmrg 43481b12faf6Smrg # There may be an optional sh(1) argument at the beginning of 43491b12faf6Smrg # install_prog (especially on Windows NT). 43500b0ce0bfSmrg if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" || 43511b12faf6Smrg # Allow the use of GNU shtool's install command. 43520b0ce0bfSmrg case $nonopt in *shtool*) :;; *) false;; esac 43530b0ce0bfSmrg then 43541b12faf6Smrg # Aesthetically quote it. 43550b0ce0bfSmrg func_quote_arg pretty "$nonopt" 43560b0ce0bfSmrg install_prog="$func_quote_arg_result " 43571b12faf6Smrg arg=$1 43581b12faf6Smrg shift 43591b12faf6Smrg else 43601b12faf6Smrg install_prog= 43611b12faf6Smrg arg=$nonopt 43621b12faf6Smrg fi 43631b12faf6Smrg 43641b12faf6Smrg # The real first argument should be the name of the installation program. 43651b12faf6Smrg # Aesthetically quote it. 43660b0ce0bfSmrg func_quote_arg pretty "$arg" 43670b0ce0bfSmrg func_append install_prog "$func_quote_arg_result" 4368e35d4d8eSmrg install_shared_prog=$install_prog 4369e35d4d8eSmrg case " $install_prog " in 4370e35d4d8eSmrg *[\\\ /]cp\ *) install_cp=: ;; 4371e35d4d8eSmrg *) install_cp=false ;; 4372e35d4d8eSmrg esac 43731b12faf6Smrg 43741b12faf6Smrg # We need to accept at least all the BSD install flags. 43751b12faf6Smrg dest= 43761b12faf6Smrg files= 43771b12faf6Smrg opts= 43781b12faf6Smrg prev= 43791b12faf6Smrg install_type= 43800b0ce0bfSmrg isdir=false 43811b12faf6Smrg stripme= 4382e35d4d8eSmrg no_mode=: 43831b12faf6Smrg for arg 43841b12faf6Smrg do 4385e35d4d8eSmrg arg2= 43861b12faf6Smrg if test -n "$dest"; then 4387e35d4d8eSmrg func_append files " $dest" 43881b12faf6Smrg dest=$arg 43891b12faf6Smrg continue 43901b12faf6Smrg fi 43911b12faf6Smrg 43921b12faf6Smrg case $arg in 43930b0ce0bfSmrg -d) isdir=: ;; 43941b12faf6Smrg -f) 4395e35d4d8eSmrg if $install_cp; then :; else 4396e35d4d8eSmrg prev=$arg 4397e35d4d8eSmrg fi 43981b12faf6Smrg ;; 43991b12faf6Smrg -g | -m | -o) 44001b12faf6Smrg prev=$arg 44011b12faf6Smrg ;; 44021b12faf6Smrg -s) 44031b12faf6Smrg stripme=" -s" 44041b12faf6Smrg continue 44051b12faf6Smrg ;; 44061b12faf6Smrg -*) 44071b12faf6Smrg ;; 44081b12faf6Smrg *) 44091b12faf6Smrg # If the previous option needed an argument, then skip it. 44101b12faf6Smrg if test -n "$prev"; then 44110b0ce0bfSmrg if test X-m = "X$prev" && test -n "$install_override_mode"; then 4412e35d4d8eSmrg arg2=$install_override_mode 4413e35d4d8eSmrg no_mode=false 4414e35d4d8eSmrg fi 441532b578d3Smrg prev= 441632b578d3Smrg else 44171b12faf6Smrg dest=$arg 44181b12faf6Smrg continue 441932b578d3Smrg fi 442032b578d3Smrg ;; 44211b12faf6Smrg esac 442232b578d3Smrg 44231b12faf6Smrg # Aesthetically quote the argument. 44240b0ce0bfSmrg func_quote_arg pretty "$arg" 44250b0ce0bfSmrg func_append install_prog " $func_quote_arg_result" 4426e35d4d8eSmrg if test -n "$arg2"; then 44270b0ce0bfSmrg func_quote_arg pretty "$arg2" 4428e35d4d8eSmrg fi 44290b0ce0bfSmrg func_append install_shared_prog " $func_quote_arg_result" 44301b12faf6Smrg done 443132b578d3Smrg 44321b12faf6Smrg test -z "$install_prog" && \ 44331b12faf6Smrg func_fatal_help "you must specify an install program" 443432b578d3Smrg 44351b12faf6Smrg test -n "$prev" && \ 44360b0ce0bfSmrg func_fatal_help "the '$prev' option requires an argument" 443732b578d3Smrg 4438e35d4d8eSmrg if test -n "$install_override_mode" && $no_mode; then 4439e35d4d8eSmrg if $install_cp; then :; else 44400b0ce0bfSmrg func_quote_arg pretty "$install_override_mode" 44410b0ce0bfSmrg func_append install_shared_prog " -m $func_quote_arg_result" 4442e35d4d8eSmrg fi 4443e35d4d8eSmrg fi 4444e35d4d8eSmrg 44451b12faf6Smrg if test -z "$files"; then 44461b12faf6Smrg if test -z "$dest"; then 44471b12faf6Smrg func_fatal_help "no file or destination specified" 44481b12faf6Smrg else 44491b12faf6Smrg func_fatal_help "you must specify a destination" 44501b12faf6Smrg fi 445132b578d3Smrg fi 445232b578d3Smrg 44531b12faf6Smrg # Strip any trailing slash from the destination. 44541b12faf6Smrg func_stripname '' '/' "$dest" 44551b12faf6Smrg dest=$func_stripname_result 445632b578d3Smrg 44571b12faf6Smrg # Check to see that the destination is a directory. 44580b0ce0bfSmrg test -d "$dest" && isdir=: 44590b0ce0bfSmrg if $isdir; then 44600b0ce0bfSmrg destdir=$dest 44611b12faf6Smrg destname= 446232b578d3Smrg else 44631b12faf6Smrg func_dirname_and_basename "$dest" "" "." 44640b0ce0bfSmrg destdir=$func_dirname_result 44650b0ce0bfSmrg destname=$func_basename_result 446632b578d3Smrg 44671b12faf6Smrg # Not a directory, so check to see that there is only one file specified. 44681b12faf6Smrg set dummy $files; shift 44691b12faf6Smrg test "$#" -gt 1 && \ 44700b0ce0bfSmrg func_fatal_help "'$dest' is not a directory" 447132b578d3Smrg fi 44721b12faf6Smrg case $destdir in 44731b12faf6Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 447432b578d3Smrg *) 44751b12faf6Smrg for file in $files; do 44761b12faf6Smrg case $file in 44771b12faf6Smrg *.lo) ;; 44781b12faf6Smrg *) 44790b0ce0bfSmrg func_fatal_help "'$destdir' must be an absolute directory name" 44801b12faf6Smrg ;; 44811b12faf6Smrg esac 44821b12faf6Smrg done 448332b578d3Smrg ;; 448432b578d3Smrg esac 448532b578d3Smrg 44861b12faf6Smrg # This variable tells wrapper scripts just to set variables rather 44871b12faf6Smrg # than running their programs. 44880b0ce0bfSmrg libtool_install_magic=$magic 448932b578d3Smrg 44901b12faf6Smrg staticlibs= 44911b12faf6Smrg future_libdirs= 44921b12faf6Smrg current_libdirs= 44931b12faf6Smrg for file in $files; do 449432b578d3Smrg 44951b12faf6Smrg # Do each installation. 44961b12faf6Smrg case $file in 44971b12faf6Smrg *.$libext) 44981b12faf6Smrg # Do the static libraries later. 4499e35d4d8eSmrg func_append staticlibs " $file" 45001b12faf6Smrg ;; 45011b12faf6Smrg 45021b12faf6Smrg *.la) 4503e35d4d8eSmrg func_resolve_sysroot "$file" 4504e35d4d8eSmrg file=$func_resolve_sysroot_result 4505e35d4d8eSmrg 45061b12faf6Smrg # Check to see that this really is a libtool archive. 45071b12faf6Smrg func_lalib_unsafe_p "$file" \ 45080b0ce0bfSmrg || func_fatal_help "'$file' is not a valid libtool archive" 45091b12faf6Smrg 45101b12faf6Smrg library_names= 45111b12faf6Smrg old_library= 45121b12faf6Smrg relink_command= 45131b12faf6Smrg func_source "$file" 45141b12faf6Smrg 45151b12faf6Smrg # Add the libdir to current_libdirs if it is the destination. 45161b12faf6Smrg if test "X$destdir" = "X$libdir"; then 45171b12faf6Smrg case "$current_libdirs " in 45181b12faf6Smrg *" $libdir "*) ;; 4519e35d4d8eSmrg *) func_append current_libdirs " $libdir" ;; 452032b578d3Smrg esac 45211b12faf6Smrg else 45221b12faf6Smrg # Note the libdir as a future libdir. 45231b12faf6Smrg case "$future_libdirs " in 45241b12faf6Smrg *" $libdir "*) ;; 4525e35d4d8eSmrg *) func_append future_libdirs " $libdir" ;; 45261b12faf6Smrg esac 45271b12faf6Smrg fi 452832b578d3Smrg 45291b12faf6Smrg func_dirname "$file" "/" "" 45300b0ce0bfSmrg dir=$func_dirname_result 4531e35d4d8eSmrg func_append dir "$objdir" 45321b12faf6Smrg 45331b12faf6Smrg if test -n "$relink_command"; then 45341b12faf6Smrg # Determine the prefix the user has applied to our future dir. 4535e35d4d8eSmrg inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` 45361b12faf6Smrg 45371b12faf6Smrg # Don't allow the user to place us outside of our expected 45381b12faf6Smrg # location b/c this prevents finding dependent libraries that 45391b12faf6Smrg # are installed to the same prefix. 45401b12faf6Smrg # At present, this check doesn't affect windows .dll's that 45411b12faf6Smrg # are installed into $libdir/../bin (currently, that works fine) 45421b12faf6Smrg # but it's something to keep an eye on. 45431b12faf6Smrg test "$inst_prefix_dir" = "$destdir" && \ 45440b0ce0bfSmrg func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir" 45451b12faf6Smrg 45461b12faf6Smrg if test -n "$inst_prefix_dir"; then 45471b12faf6Smrg # Stick the inst_prefix_dir data into the link command. 4548e35d4d8eSmrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` 45491b12faf6Smrg else 4550e35d4d8eSmrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` 45511b12faf6Smrg fi 45521b12faf6Smrg 45530b0ce0bfSmrg func_warning "relinking '$file'" 45541b12faf6Smrg func_show_eval "$relink_command" \ 45550b0ce0bfSmrg 'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"' 45561b12faf6Smrg fi 45571b12faf6Smrg 45581b12faf6Smrg # See the names of the shared library. 45591b12faf6Smrg set dummy $library_names; shift 45601b12faf6Smrg if test -n "$1"; then 45610b0ce0bfSmrg realname=$1 45621b12faf6Smrg shift 45631b12faf6Smrg 45640b0ce0bfSmrg srcname=$realname 45650b0ce0bfSmrg test -n "$relink_command" && srcname=${realname}T 45661b12faf6Smrg 45671b12faf6Smrg # Install the shared library and build the symlinks. 4568e35d4d8eSmrg func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ 45691b12faf6Smrg 'exit $?' 45700b0ce0bfSmrg tstripme=$stripme 45711b12faf6Smrg case $host_os in 45721b12faf6Smrg cygwin* | mingw* | pw32* | cegcc*) 45731b12faf6Smrg case $realname in 45741b12faf6Smrg *.dll.a) 45750b0ce0bfSmrg tstripme= 45760b0ce0bfSmrg ;; 45770b0ce0bfSmrg esac 45780b0ce0bfSmrg ;; 45790b0ce0bfSmrg os2*) 45800b0ce0bfSmrg case $realname in 45810b0ce0bfSmrg *_dll.a) 45820b0ce0bfSmrg tstripme= 45831b12faf6Smrg ;; 45841b12faf6Smrg esac 458532b578d3Smrg ;; 458632b578d3Smrg esac 45871b12faf6Smrg if test -n "$tstripme" && test -n "$striplib"; then 45881b12faf6Smrg func_show_eval "$striplib $destdir/$realname" 'exit $?' 45892a51b5beSmrg fi 45901b12faf6Smrg 45911b12faf6Smrg if test "$#" -gt 0; then 45921b12faf6Smrg # Delete the old symlinks, and create new ones. 45930b0ce0bfSmrg # Try 'ln -sf' first, because the 'ln' binary might depend on 45941b12faf6Smrg # the symlink we replace! Solaris /bin/ln does not understand -f, 45951b12faf6Smrg # so we also need to try rm && ln -s. 45961b12faf6Smrg for linkname 45971b12faf6Smrg do 45981b12faf6Smrg test "$linkname" != "$realname" \ 45991b12faf6Smrg && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" 460032b578d3Smrg done 460132b578d3Smrg fi 460232b578d3Smrg 46031b12faf6Smrg # Do each command in the postinstall commands. 46040b0ce0bfSmrg lib=$destdir/$realname 46051b12faf6Smrg func_execute_cmds "$postinstall_cmds" 'exit $?' 460632b578d3Smrg fi 460732b578d3Smrg 46081b12faf6Smrg # Install the pseudo-library for information purposes. 46091b12faf6Smrg func_basename "$file" 46100b0ce0bfSmrg name=$func_basename_result 46110b0ce0bfSmrg instname=$dir/${name}i 46121b12faf6Smrg func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' 461332b578d3Smrg 46141b12faf6Smrg # Maybe install the static library, too. 4615e35d4d8eSmrg test -n "$old_library" && func_append staticlibs " $dir/$old_library" 46161b12faf6Smrg ;; 461732b578d3Smrg 46181b12faf6Smrg *.lo) 46191b12faf6Smrg # Install (i.e. copy) a libtool object. 462032b578d3Smrg 46211b12faf6Smrg # Figure out destination file name, if it wasn't already specified. 46221b12faf6Smrg if test -n "$destname"; then 46230b0ce0bfSmrg destfile=$destdir/$destname 46241b12faf6Smrg else 46251b12faf6Smrg func_basename "$file" 46260b0ce0bfSmrg destfile=$func_basename_result 46270b0ce0bfSmrg destfile=$destdir/$destfile 46281b12faf6Smrg fi 46291b12faf6Smrg 46301b12faf6Smrg # Deduce the name of the destination old-style object file. 46311b12faf6Smrg case $destfile in 46321b12faf6Smrg *.lo) 46331b12faf6Smrg func_lo2o "$destfile" 46341b12faf6Smrg staticdest=$func_lo2o_result 46351b12faf6Smrg ;; 46361b12faf6Smrg *.$objext) 46370b0ce0bfSmrg staticdest=$destfile 46381b12faf6Smrg destfile= 46391b12faf6Smrg ;; 46401b12faf6Smrg *) 46410b0ce0bfSmrg func_fatal_help "cannot copy a libtool object to '$destfile'" 46421b12faf6Smrg ;; 464332b578d3Smrg esac 464432b578d3Smrg 46451b12faf6Smrg # Install the libtool object if requested. 46461b12faf6Smrg test -n "$destfile" && \ 46471b12faf6Smrg func_show_eval "$install_prog $file $destfile" 'exit $?' 46481b12faf6Smrg 46491b12faf6Smrg # Install the old object if enabled. 46500b0ce0bfSmrg if test yes = "$build_old_libs"; then 46511b12faf6Smrg # Deduce the name of the old-style object file. 46521b12faf6Smrg func_lo2o "$file" 46531b12faf6Smrg staticobj=$func_lo2o_result 46541b12faf6Smrg func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' 465532b578d3Smrg fi 46561b12faf6Smrg exit $EXIT_SUCCESS 46571b12faf6Smrg ;; 465832b578d3Smrg 46591b12faf6Smrg *) 46601b12faf6Smrg # Figure out destination file name, if it wasn't already specified. 46611b12faf6Smrg if test -n "$destname"; then 46620b0ce0bfSmrg destfile=$destdir/$destname 46631b12faf6Smrg else 46641b12faf6Smrg func_basename "$file" 46650b0ce0bfSmrg destfile=$func_basename_result 46660b0ce0bfSmrg destfile=$destdir/$destfile 46671b12faf6Smrg fi 466832b578d3Smrg 46691b12faf6Smrg # If the file is missing, and there is a .exe on the end, strip it 46701b12faf6Smrg # because it is most likely a libtool script we actually want to 46711b12faf6Smrg # install 46720b0ce0bfSmrg stripped_ext= 46731b12faf6Smrg case $file in 46741b12faf6Smrg *.exe) 46751b12faf6Smrg if test ! -f "$file"; then 46761b12faf6Smrg func_stripname '' '.exe' "$file" 46771b12faf6Smrg file=$func_stripname_result 46780b0ce0bfSmrg stripped_ext=.exe 46791b12faf6Smrg fi 46801b12faf6Smrg ;; 46811b12faf6Smrg esac 468232b578d3Smrg 46831b12faf6Smrg # Do a test to see if this is really a libtool program. 46841b12faf6Smrg case $host in 46851b12faf6Smrg *cygwin* | *mingw*) 46861b12faf6Smrg if func_ltwrapper_executable_p "$file"; then 46871b12faf6Smrg func_ltwrapper_scriptname "$file" 46881b12faf6Smrg wrapper=$func_ltwrapper_scriptname_result 46891b12faf6Smrg else 46901b12faf6Smrg func_stripname '' '.exe' "$file" 46911b12faf6Smrg wrapper=$func_stripname_result 46921b12faf6Smrg fi 46931b12faf6Smrg ;; 46941b12faf6Smrg *) 46951b12faf6Smrg wrapper=$file 46961b12faf6Smrg ;; 46971b12faf6Smrg esac 46981b12faf6Smrg if func_ltwrapper_script_p "$wrapper"; then 46991b12faf6Smrg notinst_deplibs= 47001b12faf6Smrg relink_command= 470132b578d3Smrg 47021b12faf6Smrg func_source "$wrapper" 47031b12faf6Smrg 47041b12faf6Smrg # Check the variables that should have been set. 47051b12faf6Smrg test -z "$generated_by_libtool_version" && \ 47060b0ce0bfSmrg func_fatal_error "invalid libtool wrapper script '$wrapper'" 47071b12faf6Smrg 47080b0ce0bfSmrg finalize=: 47091b12faf6Smrg for lib in $notinst_deplibs; do 47101b12faf6Smrg # Check to see that each library is installed. 47111b12faf6Smrg libdir= 47121b12faf6Smrg if test -f "$lib"; then 47131b12faf6Smrg func_source "$lib" 47141b12faf6Smrg fi 47150b0ce0bfSmrg libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'` 47161b12faf6Smrg if test -n "$libdir" && test ! -f "$libfile"; then 47170b0ce0bfSmrg func_warning "'$lib' has not been installed in '$libdir'" 47180b0ce0bfSmrg finalize=false 47191b12faf6Smrg fi 47201b12faf6Smrg done 47211b12faf6Smrg 47221b12faf6Smrg relink_command= 47231b12faf6Smrg func_source "$wrapper" 47241b12faf6Smrg 47251b12faf6Smrg outputname= 47260b0ce0bfSmrg if test no = "$fast_install" && test -n "$relink_command"; then 47271b12faf6Smrg $opt_dry_run || { 47280b0ce0bfSmrg if $finalize; then 47291b12faf6Smrg tmpdir=`func_mktempdir` 47301b12faf6Smrg func_basename "$file$stripped_ext" 47310b0ce0bfSmrg file=$func_basename_result 47320b0ce0bfSmrg outputname=$tmpdir/$file 47331b12faf6Smrg # Replace the output file specification. 4734e35d4d8eSmrg relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` 47351b12faf6Smrg 47360b0ce0bfSmrg $opt_quiet || { 47370b0ce0bfSmrg func_quote_arg expand,pretty "$relink_command" 47380b0ce0bfSmrg eval "func_echo $func_quote_arg_result" 47391b12faf6Smrg } 47401b12faf6Smrg if eval "$relink_command"; then : 47411b12faf6Smrg else 47420b0ce0bfSmrg func_error "error: relink '$file' with the above command before installing it" 47431b12faf6Smrg $opt_dry_run || ${RM}r "$tmpdir" 47441b12faf6Smrg continue 47451b12faf6Smrg fi 47460b0ce0bfSmrg file=$outputname 47471b12faf6Smrg else 47480b0ce0bfSmrg func_warning "cannot relink '$file'" 47491b12faf6Smrg fi 47501b12faf6Smrg } 475132b578d3Smrg else 47521b12faf6Smrg # Install the binary that we compiled earlier. 4753e35d4d8eSmrg file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` 475432b578d3Smrg fi 47551b12faf6Smrg fi 475632b578d3Smrg 47571b12faf6Smrg # remove .exe since cygwin /usr/bin/install will append another 47581b12faf6Smrg # one anyway 47591b12faf6Smrg case $install_prog,$host in 47601b12faf6Smrg */usr/bin/install*,*cygwin*) 47611b12faf6Smrg case $file:$destfile in 47621b12faf6Smrg *.exe:*.exe) 47631b12faf6Smrg # this is ok 47641b12faf6Smrg ;; 47651b12faf6Smrg *.exe:*) 47661b12faf6Smrg destfile=$destfile.exe 47671b12faf6Smrg ;; 47681b12faf6Smrg *:*.exe) 47691b12faf6Smrg func_stripname '' '.exe' "$destfile" 47701b12faf6Smrg destfile=$func_stripname_result 47711b12faf6Smrg ;; 47721b12faf6Smrg esac 477332b578d3Smrg ;; 477432b578d3Smrg esac 47751b12faf6Smrg func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' 47761b12faf6Smrg $opt_dry_run || if test -n "$outputname"; then 47771b12faf6Smrg ${RM}r "$tmpdir" 47781b12faf6Smrg fi 47791b12faf6Smrg ;; 47801b12faf6Smrg esac 47811b12faf6Smrg done 478232b578d3Smrg 47831b12faf6Smrg for file in $staticlibs; do 47841b12faf6Smrg func_basename "$file" 47850b0ce0bfSmrg name=$func_basename_result 47861b12faf6Smrg 47871b12faf6Smrg # Set up the ranlib parameters. 47880b0ce0bfSmrg oldlib=$destdir/$name 4789e35d4d8eSmrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 4790e35d4d8eSmrg tool_oldlib=$func_to_tool_file_result 47911b12faf6Smrg 47921b12faf6Smrg func_show_eval "$install_prog \$file \$oldlib" 'exit $?' 47931b12faf6Smrg 47941b12faf6Smrg if test -n "$stripme" && test -n "$old_striplib"; then 4795e35d4d8eSmrg func_show_eval "$old_striplib $tool_oldlib" 'exit $?' 47961b12faf6Smrg fi 47971b12faf6Smrg 47981b12faf6Smrg # Do each command in the postinstall commands. 47991b12faf6Smrg func_execute_cmds "$old_postinstall_cmds" 'exit $?' 48001b12faf6Smrg done 48011b12faf6Smrg 48021b12faf6Smrg test -n "$future_libdirs" && \ 48030b0ce0bfSmrg func_warning "remember to run '$progname --finish$future_libdirs'" 48041b12faf6Smrg 48051b12faf6Smrg if test -n "$current_libdirs"; then 48061b12faf6Smrg # Maybe just do a dry run. 48071b12faf6Smrg $opt_dry_run && current_libdirs=" -n$current_libdirs" 48080b0ce0bfSmrg exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs' 48091b12faf6Smrg else 48101b12faf6Smrg exit $EXIT_SUCCESS 48111b12faf6Smrg fi 48121b12faf6Smrg} 48131b12faf6Smrg 48140b0ce0bfSmrgtest install = "$opt_mode" && func_mode_install ${1+"$@"} 48151b12faf6Smrg 48161b12faf6Smrg 48171b12faf6Smrg# func_generate_dlsyms outputname originator pic_p 48181b12faf6Smrg# Extract symbols from dlprefiles and create ${outputname}S.o with 48191b12faf6Smrg# a dlpreopen symbol table. 48201b12faf6Smrgfunc_generate_dlsyms () 48211b12faf6Smrg{ 48220b0ce0bfSmrg $debug_cmd 48230b0ce0bfSmrg 48240b0ce0bfSmrg my_outputname=$1 48250b0ce0bfSmrg my_originator=$2 48260b0ce0bfSmrg my_pic_p=${3-false} 48270b0ce0bfSmrg my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'` 48281b12faf6Smrg my_dlsyms= 48291b12faf6Smrg 48300b0ce0bfSmrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 48311b12faf6Smrg if test -n "$NM" && test -n "$global_symbol_pipe"; then 48320b0ce0bfSmrg my_dlsyms=${my_outputname}S.c 48331b12faf6Smrg else 48341b12faf6Smrg func_error "not configured to extract global symbols from dlpreopened files" 48351b12faf6Smrg fi 48361b12faf6Smrg fi 48371b12faf6Smrg 48381b12faf6Smrg if test -n "$my_dlsyms"; then 48391b12faf6Smrg case $my_dlsyms in 48401b12faf6Smrg "") ;; 48411b12faf6Smrg *.c) 48421b12faf6Smrg # Discover the nlist of each of the dlfiles. 48430b0ce0bfSmrg nlist=$output_objdir/$my_outputname.nm 48441b12faf6Smrg 48451b12faf6Smrg func_show_eval "$RM $nlist ${nlist}S ${nlist}T" 48461b12faf6Smrg 48471b12faf6Smrg # Parse the name list into a source file. 48481b12faf6Smrg func_verbose "creating $output_objdir/$my_dlsyms" 48491b12faf6Smrg 48501b12faf6Smrg $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ 48510b0ce0bfSmrg/* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */ 48520b0ce0bfSmrg/* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */ 48531b12faf6Smrg 48541b12faf6Smrg#ifdef __cplusplus 48551b12faf6Smrgextern \"C\" { 48561b12faf6Smrg#endif 48571b12faf6Smrg 48580b0ce0bfSmrg#if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) 4859e35d4d8eSmrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\" 4860e35d4d8eSmrg#endif 4861e35d4d8eSmrg 4862e35d4d8eSmrg/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ 48630b0ce0bfSmrg#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE 48640b0ce0bfSmrg/* DATA imports from DLLs on WIN32 can't be const, because runtime 4865e35d4d8eSmrg relocations are performed -- see ld's documentation on pseudo-relocs. */ 4866e35d4d8eSmrg# define LT_DLSYM_CONST 48670b0ce0bfSmrg#elif defined __osf__ 4868e35d4d8eSmrg/* This system does not cope well with relocations in const data. */ 4869e35d4d8eSmrg# define LT_DLSYM_CONST 4870e35d4d8eSmrg#else 4871e35d4d8eSmrg# define LT_DLSYM_CONST const 4872e35d4d8eSmrg#endif 4873e35d4d8eSmrg 48740b0ce0bfSmrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 48750b0ce0bfSmrg 48761b12faf6Smrg/* External symbol declarations for the compiler. */\ 48771b12faf6Smrg" 48781b12faf6Smrg 48790b0ce0bfSmrg if test yes = "$dlself"; then 48800b0ce0bfSmrg func_verbose "generating symbol list for '$output'" 48811b12faf6Smrg 48821b12faf6Smrg $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" 48831b12faf6Smrg 48841b12faf6Smrg # Add our own program objects to the symbol list. 4885e35d4d8eSmrg progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` 48861b12faf6Smrg for progfile in $progfiles; do 4887e35d4d8eSmrg func_to_tool_file "$progfile" func_convert_file_msys_to_w32 48880b0ce0bfSmrg func_verbose "extracting global C symbols from '$func_to_tool_file_result'" 4889e35d4d8eSmrg $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" 48901b12faf6Smrg done 48911b12faf6Smrg 48921b12faf6Smrg if test -n "$exclude_expsyms"; then 48931b12faf6Smrg $opt_dry_run || { 48941b12faf6Smrg eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' 48951b12faf6Smrg eval '$MV "$nlist"T "$nlist"' 48961b12faf6Smrg } 489732b578d3Smrg fi 48981b12faf6Smrg 48991b12faf6Smrg if test -n "$export_symbols_regex"; then 49001b12faf6Smrg $opt_dry_run || { 49011b12faf6Smrg eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' 49021b12faf6Smrg eval '$MV "$nlist"T "$nlist"' 49031b12faf6Smrg } 49041b12faf6Smrg fi 49051b12faf6Smrg 49061b12faf6Smrg # Prepare the list of exported symbols 49071b12faf6Smrg if test -z "$export_symbols"; then 49080b0ce0bfSmrg export_symbols=$output_objdir/$outputname.exp 49091b12faf6Smrg $opt_dry_run || { 49101b12faf6Smrg $RM $export_symbols 49110b0ce0bfSmrg eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' 49121b12faf6Smrg case $host in 49131b12faf6Smrg *cygwin* | *mingw* | *cegcc* ) 49141b12faf6Smrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 49151b12faf6Smrg eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' 49161b12faf6Smrg ;; 49171b12faf6Smrg esac 49181b12faf6Smrg } 491932b578d3Smrg else 49201b12faf6Smrg $opt_dry_run || { 49210b0ce0bfSmrg eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' 49221b12faf6Smrg eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' 49231b12faf6Smrg eval '$MV "$nlist"T "$nlist"' 49241b12faf6Smrg case $host in 4925e35d4d8eSmrg *cygwin* | *mingw* | *cegcc* ) 49261b12faf6Smrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 49271b12faf6Smrg eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' 49281b12faf6Smrg ;; 49291b12faf6Smrg esac 49301b12faf6Smrg } 493132b578d3Smrg fi 49321b12faf6Smrg fi 493332b578d3Smrg 49341b12faf6Smrg for dlprefile in $dlprefiles; do 49350b0ce0bfSmrg func_verbose "extracting global C symbols from '$dlprefile'" 49361b12faf6Smrg func_basename "$dlprefile" 49370b0ce0bfSmrg name=$func_basename_result 4938e35d4d8eSmrg case $host in 4939e35d4d8eSmrg *cygwin* | *mingw* | *cegcc* ) 4940e35d4d8eSmrg # if an import library, we need to obtain dlname 4941e35d4d8eSmrg if func_win32_import_lib_p "$dlprefile"; then 4942e35d4d8eSmrg func_tr_sh "$dlprefile" 4943e35d4d8eSmrg eval "curr_lafile=\$libfile_$func_tr_sh_result" 49440b0ce0bfSmrg dlprefile_dlbasename= 4945e35d4d8eSmrg if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then 4946e35d4d8eSmrg # Use subshell, to avoid clobbering current variable values 4947e35d4d8eSmrg dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` 49480b0ce0bfSmrg if test -n "$dlprefile_dlname"; then 4949e35d4d8eSmrg func_basename "$dlprefile_dlname" 49500b0ce0bfSmrg dlprefile_dlbasename=$func_basename_result 4951e35d4d8eSmrg else 4952e35d4d8eSmrg # no lafile. user explicitly requested -dlpreopen <import library>. 4953e35d4d8eSmrg $sharedlib_from_linklib_cmd "$dlprefile" 4954e35d4d8eSmrg dlprefile_dlbasename=$sharedlib_from_linklib_result 4955e35d4d8eSmrg fi 4956e35d4d8eSmrg fi 4957e35d4d8eSmrg $opt_dry_run || { 49580b0ce0bfSmrg if test -n "$dlprefile_dlbasename"; then 4959e35d4d8eSmrg eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' 4960e35d4d8eSmrg else 4961e35d4d8eSmrg func_warning "Could not compute DLL name from $name" 4962e35d4d8eSmrg eval '$ECHO ": $name " >> "$nlist"' 4963e35d4d8eSmrg fi 4964e35d4d8eSmrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 4965e35d4d8eSmrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | 4966e35d4d8eSmrg $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" 4967e35d4d8eSmrg } 4968e35d4d8eSmrg else # not an import lib 4969e35d4d8eSmrg $opt_dry_run || { 4970e35d4d8eSmrg eval '$ECHO ": $name " >> "$nlist"' 4971e35d4d8eSmrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 4972e35d4d8eSmrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 4973e35d4d8eSmrg } 4974e35d4d8eSmrg fi 4975e35d4d8eSmrg ;; 4976e35d4d8eSmrg *) 4977e35d4d8eSmrg $opt_dry_run || { 4978e35d4d8eSmrg eval '$ECHO ": $name " >> "$nlist"' 4979e35d4d8eSmrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 4980e35d4d8eSmrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 4981e35d4d8eSmrg } 4982e35d4d8eSmrg ;; 4983e35d4d8eSmrg esac 49841b12faf6Smrg done 49851b12faf6Smrg 49861b12faf6Smrg $opt_dry_run || { 49871b12faf6Smrg # Make sure we have at least an empty file. 49881b12faf6Smrg test -f "$nlist" || : > "$nlist" 49891b12faf6Smrg 49901b12faf6Smrg if test -n "$exclude_expsyms"; then 49911b12faf6Smrg $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T 49921b12faf6Smrg $MV "$nlist"T "$nlist" 499332b578d3Smrg fi 49941b12faf6Smrg 49951b12faf6Smrg # Try sorting and uniquifying the output. 49961b12faf6Smrg if $GREP -v "^: " < "$nlist" | 49971b12faf6Smrg if sort -k 3 </dev/null >/dev/null 2>&1; then 49981b12faf6Smrg sort -k 3 49991b12faf6Smrg else 50001b12faf6Smrg sort +2 50011b12faf6Smrg fi | 50021b12faf6Smrg uniq > "$nlist"S; then 50031b12faf6Smrg : 500432b578d3Smrg else 50051b12faf6Smrg $GREP -v "^: " < "$nlist" > "$nlist"S 500632b578d3Smrg fi 500732b578d3Smrg 50081b12faf6Smrg if test -f "$nlist"S; then 50091b12faf6Smrg eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' 501032b578d3Smrg else 5011e35d4d8eSmrg echo '/* NONE */' >> "$output_objdir/$my_dlsyms" 501232b578d3Smrg fi 501332b578d3Smrg 50140b0ce0bfSmrg func_show_eval '$RM "${nlist}I"' 50150b0ce0bfSmrg if test -n "$global_symbol_to_import"; then 50160b0ce0bfSmrg eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I' 50170b0ce0bfSmrg fi 50180b0ce0bfSmrg 5019e35d4d8eSmrg echo >> "$output_objdir/$my_dlsyms" "\ 502032b578d3Smrg 50211b12faf6Smrg/* The mapping between symbol names and symbols. */ 50221b12faf6Smrgtypedef struct { 50231b12faf6Smrg const char *name; 50241b12faf6Smrg void *address; 50251b12faf6Smrg} lt_dlsymlist; 5026e35d4d8eSmrgextern LT_DLSYM_CONST lt_dlsymlist 50270b0ce0bfSmrglt_${my_prefix}_LTX_preloaded_symbols[];\ 50280b0ce0bfSmrg" 50290b0ce0bfSmrg 50300b0ce0bfSmrg if test -s "$nlist"I; then 50310b0ce0bfSmrg echo >> "$output_objdir/$my_dlsyms" "\ 50320b0ce0bfSmrgstatic void lt_syminit(void) 50330b0ce0bfSmrg{ 50340b0ce0bfSmrg LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols; 50350b0ce0bfSmrg for (; symbol->name; ++symbol) 50360b0ce0bfSmrg {" 50370b0ce0bfSmrg $SED 's/.*/ if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms" 50380b0ce0bfSmrg echo >> "$output_objdir/$my_dlsyms" "\ 50390b0ce0bfSmrg } 50400b0ce0bfSmrg}" 50410b0ce0bfSmrg fi 50420b0ce0bfSmrg echo >> "$output_objdir/$my_dlsyms" "\ 5043e35d4d8eSmrgLT_DLSYM_CONST lt_dlsymlist 50441b12faf6Smrglt_${my_prefix}_LTX_preloaded_symbols[] = 50450b0ce0bfSmrg{ {\"$my_originator\", (void *) 0}," 50460b0ce0bfSmrg 50470b0ce0bfSmrg if test -s "$nlist"I; then 50480b0ce0bfSmrg echo >> "$output_objdir/$my_dlsyms" "\ 50490b0ce0bfSmrg {\"@INIT@\", (void *) <_syminit}," 50500b0ce0bfSmrg fi 505132b578d3Smrg 50521b12faf6Smrg case $need_lib_prefix in 50531b12faf6Smrg no) 50541b12faf6Smrg eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" 50551b12faf6Smrg ;; 50561b12faf6Smrg *) 50571b12faf6Smrg eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" 50581b12faf6Smrg ;; 50591b12faf6Smrg esac 5060e35d4d8eSmrg echo >> "$output_objdir/$my_dlsyms" "\ 50611b12faf6Smrg {0, (void *) 0} 50621b12faf6Smrg}; 506332b578d3Smrg 50641b12faf6Smrg/* This works around a problem in FreeBSD linker */ 50651b12faf6Smrg#ifdef FREEBSD_WORKAROUND 50661b12faf6Smrgstatic const void *lt_preloaded_setup() { 50671b12faf6Smrg return lt_${my_prefix}_LTX_preloaded_symbols; 50681b12faf6Smrg} 50691b12faf6Smrg#endif 50701b12faf6Smrg 50711b12faf6Smrg#ifdef __cplusplus 50721b12faf6Smrg} 50731b12faf6Smrg#endif\ 50741b12faf6Smrg" 50751b12faf6Smrg } # !$opt_dry_run 50761b12faf6Smrg 50771b12faf6Smrg pic_flag_for_symtable= 50781b12faf6Smrg case "$compile_command " in 50791b12faf6Smrg *" -static "*) ;; 50801b12faf6Smrg *) 50811b12faf6Smrg case $host in 50821b12faf6Smrg # compiling the symbol table file with pic_flag works around 50831b12faf6Smrg # a FreeBSD bug that causes programs to crash when -lm is 50841b12faf6Smrg # linked before any other PIC object. But we must not use 50851b12faf6Smrg # pic_flag when linking with -static. The problem exists in 50861b12faf6Smrg # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. 5087e35d4d8eSmrg *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) 50881b12faf6Smrg pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; 50891b12faf6Smrg *-*-hpux*) 50901b12faf6Smrg pic_flag_for_symtable=" $pic_flag" ;; 50911b12faf6Smrg *) 50920b0ce0bfSmrg $my_pic_p && pic_flag_for_symtable=" $pic_flag" 50931b12faf6Smrg ;; 50941b12faf6Smrg esac 50951b12faf6Smrg ;; 50961b12faf6Smrg esac 50971b12faf6Smrg symtab_cflags= 50981b12faf6Smrg for arg in $LTCFLAGS; do 50991b12faf6Smrg case $arg in 51001b12faf6Smrg -pie | -fpie | -fPIE) ;; 5101e35d4d8eSmrg *) func_append symtab_cflags " $arg" ;; 51021b12faf6Smrg esac 51031b12faf6Smrg done 510432b578d3Smrg 51051b12faf6Smrg # Now compile the dynamic symbol file. 51061b12faf6Smrg func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' 510732b578d3Smrg 51081b12faf6Smrg # Clean up the generated files. 51090b0ce0bfSmrg func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"' 511032b578d3Smrg 51111b12faf6Smrg # Transform the symbol file into the correct name. 51120b0ce0bfSmrg symfileobj=$output_objdir/${my_outputname}S.$objext 51131b12faf6Smrg case $host in 51141b12faf6Smrg *cygwin* | *mingw* | *cegcc* ) 51151b12faf6Smrg if test -f "$output_objdir/$my_outputname.def"; then 5116e35d4d8eSmrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 5117e35d4d8eSmrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 51181b12faf6Smrg else 5119e35d4d8eSmrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 5120e35d4d8eSmrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 512132b578d3Smrg fi 51221b12faf6Smrg ;; 51231b12faf6Smrg *) 5124e35d4d8eSmrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 5125e35d4d8eSmrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 51261b12faf6Smrg ;; 51271b12faf6Smrg esac 51281b12faf6Smrg ;; 51291b12faf6Smrg *) 51300b0ce0bfSmrg func_fatal_error "unknown suffix for '$my_dlsyms'" 51311b12faf6Smrg ;; 51321b12faf6Smrg esac 51331b12faf6Smrg else 51341b12faf6Smrg # We keep going just in case the user didn't refer to 51351b12faf6Smrg # lt_preloaded_symbols. The linker will fail if global_symbol_pipe 51361b12faf6Smrg # really was required. 513732b578d3Smrg 51381b12faf6Smrg # Nullify the symbol file. 5139e35d4d8eSmrg compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` 5140e35d4d8eSmrg finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` 51411b12faf6Smrg fi 51421b12faf6Smrg} 514332b578d3Smrg 51440b0ce0bfSmrg# func_cygming_gnu_implib_p ARG 51450b0ce0bfSmrg# This predicate returns with zero status (TRUE) if 51460b0ce0bfSmrg# ARG is a GNU/binutils-style import library. Returns 51470b0ce0bfSmrg# with nonzero status (FALSE) otherwise. 51480b0ce0bfSmrgfunc_cygming_gnu_implib_p () 51490b0ce0bfSmrg{ 51500b0ce0bfSmrg $debug_cmd 51510b0ce0bfSmrg 51520b0ce0bfSmrg func_to_tool_file "$1" func_convert_file_msys_to_w32 51530b0ce0bfSmrg 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)$'` 51540b0ce0bfSmrg test -n "$func_cygming_gnu_implib_tmp" 51550b0ce0bfSmrg} 51560b0ce0bfSmrg 51570b0ce0bfSmrg# func_cygming_ms_implib_p ARG 51580b0ce0bfSmrg# This predicate returns with zero status (TRUE) if 51590b0ce0bfSmrg# ARG is an MS-style import library. Returns 51600b0ce0bfSmrg# with nonzero status (FALSE) otherwise. 51610b0ce0bfSmrgfunc_cygming_ms_implib_p () 51620b0ce0bfSmrg{ 51630b0ce0bfSmrg $debug_cmd 51640b0ce0bfSmrg 51650b0ce0bfSmrg func_to_tool_file "$1" func_convert_file_msys_to_w32 51660b0ce0bfSmrg func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` 51670b0ce0bfSmrg test -n "$func_cygming_ms_implib_tmp" 51680b0ce0bfSmrg} 51690b0ce0bfSmrg 51701b12faf6Smrg# func_win32_libid arg 51711b12faf6Smrg# return the library type of file 'arg' 51721b12faf6Smrg# 51731b12faf6Smrg# Need a lot of goo to handle *both* DLLs and import libs 51741b12faf6Smrg# Has to be a shell function in order to 'eat' the argument 51751b12faf6Smrg# that is supplied when $file_magic_command is called. 5176e35d4d8eSmrg# Despite the name, also deal with 64 bit binaries. 51771b12faf6Smrgfunc_win32_libid () 51781b12faf6Smrg{ 51790b0ce0bfSmrg $debug_cmd 51800b0ce0bfSmrg 51810b0ce0bfSmrg win32_libid_type=unknown 51821b12faf6Smrg win32_fileres=`file -L $1 2>/dev/null` 51831b12faf6Smrg case $win32_fileres in 51841b12faf6Smrg *ar\ archive\ import\ library*) # definitely import 51851b12faf6Smrg win32_libid_type="x86 archive import" 51861b12faf6Smrg ;; 51871b12faf6Smrg *ar\ archive*) # could be an import, or static 5188e35d4d8eSmrg # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. 51891b12faf6Smrg if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | 5190e35d4d8eSmrg $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then 51910b0ce0bfSmrg case $nm_interface in 51920b0ce0bfSmrg "MS dumpbin") 51930b0ce0bfSmrg if func_cygming_ms_implib_p "$1" || 51940b0ce0bfSmrg func_cygming_gnu_implib_p "$1" 51950b0ce0bfSmrg then 51960b0ce0bfSmrg win32_nmres=import 51970b0ce0bfSmrg else 51980b0ce0bfSmrg win32_nmres= 51990b0ce0bfSmrg fi 52000b0ce0bfSmrg ;; 52010b0ce0bfSmrg *) 52020b0ce0bfSmrg func_to_tool_file "$1" func_convert_file_msys_to_w32 52030b0ce0bfSmrg win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | 52040b0ce0bfSmrg $SED -n -e ' 52051b12faf6Smrg 1,100{ 52061b12faf6Smrg / I /{ 52070b0ce0bfSmrg s|.*|import| 52081b12faf6Smrg p 52091b12faf6Smrg q 52101b12faf6Smrg } 52111b12faf6Smrg }'` 52120b0ce0bfSmrg ;; 52130b0ce0bfSmrg esac 52141b12faf6Smrg case $win32_nmres in 52151b12faf6Smrg import*) win32_libid_type="x86 archive import";; 52161b12faf6Smrg *) win32_libid_type="x86 archive static";; 52171b12faf6Smrg esac 52181b12faf6Smrg fi 52191b12faf6Smrg ;; 52201b12faf6Smrg *DLL*) 52211b12faf6Smrg win32_libid_type="x86 DLL" 52221b12faf6Smrg ;; 52231b12faf6Smrg *executable*) # but shell scripts are "executable" too... 52241b12faf6Smrg case $win32_fileres in 52251b12faf6Smrg *MS\ Windows\ PE\ Intel*) 52261b12faf6Smrg win32_libid_type="x86 DLL" 52271b12faf6Smrg ;; 52281b12faf6Smrg esac 52291b12faf6Smrg ;; 52301b12faf6Smrg esac 52311b12faf6Smrg $ECHO "$win32_libid_type" 52321b12faf6Smrg} 523332b578d3Smrg 5234e35d4d8eSmrg# func_cygming_dll_for_implib ARG 5235e35d4d8eSmrg# 5236e35d4d8eSmrg# Platform-specific function to extract the 5237e35d4d8eSmrg# name of the DLL associated with the specified 5238e35d4d8eSmrg# import library ARG. 5239e35d4d8eSmrg# Invoked by eval'ing the libtool variable 5240e35d4d8eSmrg# $sharedlib_from_linklib_cmd 5241e35d4d8eSmrg# Result is available in the variable 5242e35d4d8eSmrg# $sharedlib_from_linklib_result 5243e35d4d8eSmrgfunc_cygming_dll_for_implib () 5244e35d4d8eSmrg{ 52450b0ce0bfSmrg $debug_cmd 52460b0ce0bfSmrg 5247e35d4d8eSmrg sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` 5248e35d4d8eSmrg} 5249e35d4d8eSmrg 5250e35d4d8eSmrg# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs 5251e35d4d8eSmrg# 5252e35d4d8eSmrg# The is the core of a fallback implementation of a 5253e35d4d8eSmrg# platform-specific function to extract the name of the 5254e35d4d8eSmrg# DLL associated with the specified import library LIBNAME. 5255e35d4d8eSmrg# 5256e35d4d8eSmrg# SECTION_NAME is either .idata$6 or .idata$7, depending 5257e35d4d8eSmrg# on the platform and compiler that created the implib. 5258e35d4d8eSmrg# 5259e35d4d8eSmrg# Echos the name of the DLL associated with the 5260e35d4d8eSmrg# specified import library. 5261e35d4d8eSmrgfunc_cygming_dll_for_implib_fallback_core () 5262e35d4d8eSmrg{ 52630b0ce0bfSmrg $debug_cmd 52640b0ce0bfSmrg 5265e35d4d8eSmrg match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` 5266e35d4d8eSmrg $OBJDUMP -s --section "$1" "$2" 2>/dev/null | 5267e35d4d8eSmrg $SED '/^Contents of section '"$match_literal"':/{ 5268e35d4d8eSmrg # Place marker at beginning of archive member dllname section 5269e35d4d8eSmrg s/.*/====MARK====/ 5270e35d4d8eSmrg p 5271e35d4d8eSmrg d 5272e35d4d8eSmrg } 5273e35d4d8eSmrg # These lines can sometimes be longer than 43 characters, but 5274e35d4d8eSmrg # are always uninteresting 5275e35d4d8eSmrg /:[ ]*file format pe[i]\{,1\}-/d 5276e35d4d8eSmrg /^In archive [^:]*:/d 5277e35d4d8eSmrg # Ensure marker is printed 5278e35d4d8eSmrg /^====MARK====/p 5279e35d4d8eSmrg # Remove all lines with less than 43 characters 5280e35d4d8eSmrg /^.\{43\}/!d 5281e35d4d8eSmrg # From remaining lines, remove first 43 characters 5282e35d4d8eSmrg s/^.\{43\}//' | 5283e35d4d8eSmrg $SED -n ' 5284e35d4d8eSmrg # Join marker and all lines until next marker into a single line 5285e35d4d8eSmrg /^====MARK====/ b para 5286e35d4d8eSmrg H 5287e35d4d8eSmrg $ b para 5288e35d4d8eSmrg b 5289e35d4d8eSmrg :para 5290e35d4d8eSmrg x 5291e35d4d8eSmrg s/\n//g 5292e35d4d8eSmrg # Remove the marker 5293e35d4d8eSmrg s/^====MARK====// 5294e35d4d8eSmrg # Remove trailing dots and whitespace 5295e35d4d8eSmrg s/[\. \t]*$// 5296e35d4d8eSmrg # Print 5297e35d4d8eSmrg /./p' | 5298e35d4d8eSmrg # we now have a list, one entry per line, of the stringified 5299e35d4d8eSmrg # contents of the appropriate section of all members of the 53000b0ce0bfSmrg # archive that possess that section. Heuristic: eliminate 53010b0ce0bfSmrg # all those that have a first or second character that is 5302e35d4d8eSmrg # a '.' (that is, objdump's representation of an unprintable 5303e35d4d8eSmrg # character.) This should work for all archives with less than 5304e35d4d8eSmrg # 0x302f exports -- but will fail for DLLs whose name actually 5305e35d4d8eSmrg # begins with a literal '.' or a single character followed by 5306e35d4d8eSmrg # a '.'. 5307e35d4d8eSmrg # 5308e35d4d8eSmrg # Of those that remain, print the first one. 5309e35d4d8eSmrg $SED -e '/^\./d;/^.\./d;q' 5310e35d4d8eSmrg} 5311e35d4d8eSmrg 5312e35d4d8eSmrg# func_cygming_dll_for_implib_fallback ARG 5313e35d4d8eSmrg# Platform-specific function to extract the 5314e35d4d8eSmrg# name of the DLL associated with the specified 5315e35d4d8eSmrg# import library ARG. 5316e35d4d8eSmrg# 5317e35d4d8eSmrg# This fallback implementation is for use when $DLLTOOL 5318e35d4d8eSmrg# does not support the --identify-strict option. 5319e35d4d8eSmrg# Invoked by eval'ing the libtool variable 5320e35d4d8eSmrg# $sharedlib_from_linklib_cmd 5321e35d4d8eSmrg# Result is available in the variable 5322e35d4d8eSmrg# $sharedlib_from_linklib_result 5323e35d4d8eSmrgfunc_cygming_dll_for_implib_fallback () 5324e35d4d8eSmrg{ 53250b0ce0bfSmrg $debug_cmd 53260b0ce0bfSmrg 53270b0ce0bfSmrg if func_cygming_gnu_implib_p "$1"; then 5328e35d4d8eSmrg # binutils import library 5329e35d4d8eSmrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` 53300b0ce0bfSmrg elif func_cygming_ms_implib_p "$1"; then 5331e35d4d8eSmrg # ms-generated import library 5332e35d4d8eSmrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` 5333e35d4d8eSmrg else 5334e35d4d8eSmrg # unknown 53350b0ce0bfSmrg sharedlib_from_linklib_result= 5336e35d4d8eSmrg fi 5337e35d4d8eSmrg} 533832b578d3Smrg 533932b578d3Smrg 53401b12faf6Smrg# func_extract_an_archive dir oldlib 53411b12faf6Smrgfunc_extract_an_archive () 53421b12faf6Smrg{ 53430b0ce0bfSmrg $debug_cmd 53440b0ce0bfSmrg 53450b0ce0bfSmrg f_ex_an_ar_dir=$1; shift 53460b0ce0bfSmrg f_ex_an_ar_oldlib=$1 53470b0ce0bfSmrg if test yes = "$lock_old_archive_extraction"; then 5348e35d4d8eSmrg lockfile=$f_ex_an_ar_oldlib.lock 5349e35d4d8eSmrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 5350e35d4d8eSmrg func_echo "Waiting for $lockfile to be removed" 5351e35d4d8eSmrg sleep 2 5352e35d4d8eSmrg done 5353e35d4d8eSmrg fi 5354e35d4d8eSmrg func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ 5355e35d4d8eSmrg 'stat=$?; rm -f "$lockfile"; exit $stat' 53560b0ce0bfSmrg if test yes = "$lock_old_archive_extraction"; then 5357e35d4d8eSmrg $opt_dry_run || rm -f "$lockfile" 5358e35d4d8eSmrg fi 53591b12faf6Smrg if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then 53601b12faf6Smrg : 53611b12faf6Smrg else 53621b12faf6Smrg func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 53631b12faf6Smrg fi 53641b12faf6Smrg} 536532b578d3Smrg 536632b578d3Smrg 53671b12faf6Smrg# func_extract_archives gentop oldlib ... 53681b12faf6Smrgfunc_extract_archives () 53691b12faf6Smrg{ 53700b0ce0bfSmrg $debug_cmd 53710b0ce0bfSmrg 53720b0ce0bfSmrg my_gentop=$1; shift 53731b12faf6Smrg my_oldlibs=${1+"$@"} 53740b0ce0bfSmrg my_oldobjs= 53750b0ce0bfSmrg my_xlib= 53760b0ce0bfSmrg my_xabs= 53770b0ce0bfSmrg my_xdir= 537832b578d3Smrg 53791b12faf6Smrg for my_xlib in $my_oldlibs; do 53801b12faf6Smrg # Extract the objects. 53811b12faf6Smrg case $my_xlib in 53820b0ce0bfSmrg [\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;; 53831b12faf6Smrg *) my_xabs=`pwd`"/$my_xlib" ;; 53841b12faf6Smrg esac 53851b12faf6Smrg func_basename "$my_xlib" 53860b0ce0bfSmrg my_xlib=$func_basename_result 53871b12faf6Smrg my_xlib_u=$my_xlib 53881b12faf6Smrg while :; do 53891b12faf6Smrg case " $extracted_archives " in 53901b12faf6Smrg *" $my_xlib_u "*) 53911b12faf6Smrg func_arith $extracted_serial + 1 53921b12faf6Smrg extracted_serial=$func_arith_result 53931b12faf6Smrg my_xlib_u=lt$extracted_serial-$my_xlib ;; 53941b12faf6Smrg *) break ;; 53951b12faf6Smrg esac 53961b12faf6Smrg done 53971b12faf6Smrg extracted_archives="$extracted_archives $my_xlib_u" 53980b0ce0bfSmrg my_xdir=$my_gentop/$my_xlib_u 539932b578d3Smrg 54001b12faf6Smrg func_mkdir_p "$my_xdir" 540132b578d3Smrg 54021b12faf6Smrg case $host in 54031b12faf6Smrg *-darwin*) 54041b12faf6Smrg func_verbose "Extracting $my_xabs" 54051b12faf6Smrg # Do not bother doing anything if just a dry run 54061b12faf6Smrg $opt_dry_run || { 54071b12faf6Smrg darwin_orig_dir=`pwd` 54081b12faf6Smrg cd $my_xdir || exit $? 54091b12faf6Smrg darwin_archive=$my_xabs 54101b12faf6Smrg darwin_curdir=`pwd` 54110b0ce0bfSmrg func_basename "$darwin_archive" 54120b0ce0bfSmrg darwin_base_archive=$func_basename_result 54131b12faf6Smrg darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` 54141b12faf6Smrg if test -n "$darwin_arches"; then 54151b12faf6Smrg darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` 54161b12faf6Smrg darwin_arch= 54171b12faf6Smrg func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" 54180b0ce0bfSmrg for darwin_arch in $darwin_arches; do 54190b0ce0bfSmrg func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch" 54200b0ce0bfSmrg $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive" 54210b0ce0bfSmrg cd "unfat-$$/$darwin_base_archive-$darwin_arch" 54220b0ce0bfSmrg func_extract_an_archive "`pwd`" "$darwin_base_archive" 54231b12faf6Smrg cd "$darwin_curdir" 54240b0ce0bfSmrg $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" 54251b12faf6Smrg done # $darwin_arches 54261b12faf6Smrg ## Okay now we've a bunch of thin objects, gotta fatten them up :) 54270b0ce0bfSmrg darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$sed_basename" | sort -u` 54281b12faf6Smrg darwin_file= 54291b12faf6Smrg darwin_files= 54301b12faf6Smrg for darwin_file in $darwin_filelist; do 5431e35d4d8eSmrg darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` 54321b12faf6Smrg $LIPO -create -output "$darwin_file" $darwin_files 54331b12faf6Smrg done # $darwin_filelist 54341b12faf6Smrg $RM -rf unfat-$$ 54351b12faf6Smrg cd "$darwin_orig_dir" 543632b578d3Smrg else 54371b12faf6Smrg cd $darwin_orig_dir 54381b12faf6Smrg func_extract_an_archive "$my_xdir" "$my_xabs" 54391b12faf6Smrg fi # $darwin_arches 54401b12faf6Smrg } # !$opt_dry_run 54411b12faf6Smrg ;; 54421b12faf6Smrg *) 54431b12faf6Smrg func_extract_an_archive "$my_xdir" "$my_xabs" 54441b12faf6Smrg ;; 54451b12faf6Smrg esac 5446e35d4d8eSmrg my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` 54471b12faf6Smrg done 544832b578d3Smrg 54490b0ce0bfSmrg func_extract_archives_result=$my_oldobjs 54501b12faf6Smrg} 545132b578d3Smrg 545232b578d3Smrg 5453e35d4d8eSmrg# func_emit_wrapper [arg=no] 5454e35d4d8eSmrg# 5455e35d4d8eSmrg# Emit a libtool wrapper script on stdout. 5456e35d4d8eSmrg# Don't directly open a file because we may want to 5457e35d4d8eSmrg# incorporate the script contents within a cygwin/mingw 5458e35d4d8eSmrg# wrapper executable. Must ONLY be called from within 5459e35d4d8eSmrg# func_mode_link because it depends on a number of variables 5460e35d4d8eSmrg# set therein. 54611b12faf6Smrg# 5462e35d4d8eSmrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR 5463e35d4d8eSmrg# variable will take. If 'yes', then the emitted script 54640b0ce0bfSmrg# will assume that the directory where it is stored is 5465e35d4d8eSmrg# the $objdir directory. This is a cygwin/mingw-specific 5466e35d4d8eSmrg# behavior. 5467e35d4d8eSmrgfunc_emit_wrapper () 54681b12faf6Smrg{ 5469e35d4d8eSmrg func_emit_wrapper_arg1=${1-no} 547032b578d3Smrg 54711b12faf6Smrg $ECHO "\ 54721b12faf6Smrg#! $SHELL 547332b578d3Smrg 54741b12faf6Smrg# $output - temporary wrapper script for $objdir/$outputname 54750b0ce0bfSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 54761b12faf6Smrg# 54771b12faf6Smrg# The $output program cannot be directly executed until all the libtool 54781b12faf6Smrg# libraries that it depends on are installed. 54791b12faf6Smrg# 54801b12faf6Smrg# This wrapper script should never be moved out of the build directory. 54811b12faf6Smrg# If it is, it will not operate correctly. 548232b578d3Smrg 54831b12faf6Smrg# Sed substitution that helps us do robust quoting. It backslashifies 54841b12faf6Smrg# metacharacters that are still active within double-quoted strings. 54851b12faf6Smrgsed_quote_subst='$sed_quote_subst' 548632b578d3Smrg 54871b12faf6Smrg# Be Bourne compatible 54881b12faf6Smrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then 54891b12faf6Smrg emulate sh 54901b12faf6Smrg NULLCMD=: 54911b12faf6Smrg # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which 54921b12faf6Smrg # is contrary to our usage. Disable this feature. 54931b12faf6Smrg alias -g '\${1+\"\$@\"}'='\"\$@\"' 54941b12faf6Smrg setopt NO_GLOB_SUBST 54951b12faf6Smrgelse 54961b12faf6Smrg case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac 54971b12faf6Smrgfi 54981b12faf6SmrgBIN_SH=xpg4; export BIN_SH # for Tru64 54991b12faf6SmrgDUALCASE=1; export DUALCASE # for MKS sh 550032b578d3Smrg 55011b12faf6Smrg# The HP-UX ksh and POSIX shell print the target directory to stdout 55021b12faf6Smrg# if CDPATH is set. 55031b12faf6Smrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 550432b578d3Smrg 55051b12faf6Smrgrelink_command=\"$relink_command\" 550632b578d3Smrg 55071b12faf6Smrg# This environment variable determines our operation mode. 55081b12faf6Smrgif test \"\$libtool_install_magic\" = \"$magic\"; then 55091b12faf6Smrg # install mode needs the following variables: 55101b12faf6Smrg generated_by_libtool_version='$macro_version' 55111b12faf6Smrg notinst_deplibs='$notinst_deplibs' 55121b12faf6Smrgelse 55131b12faf6Smrg # When we are sourced in execute mode, \$file and \$ECHO are already set. 55141b12faf6Smrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 5515e35d4d8eSmrg file=\"\$0\"" 5516e35d4d8eSmrg 55170b0ce0bfSmrg func_quote_arg pretty "$ECHO" 55180b0ce0bfSmrg qECHO=$func_quote_arg_result 5519e35d4d8eSmrg $ECHO "\ 5520e35d4d8eSmrg 5521e35d4d8eSmrg# A function that is used when there is no print builtin or printf. 5522e35d4d8eSmrgfunc_fallback_echo () 5523e35d4d8eSmrg{ 5524e35d4d8eSmrg eval 'cat <<_LTECHO_EOF 5525e35d4d8eSmrg\$1 5526e35d4d8eSmrg_LTECHO_EOF' 5527e35d4d8eSmrg} 55280b0ce0bfSmrg ECHO=$qECHO 5529e35d4d8eSmrg fi 5530e35d4d8eSmrg 5531e35d4d8eSmrg# Very basic option parsing. These options are (a) specific to 5532e35d4d8eSmrg# the libtool wrapper, (b) are identical between the wrapper 55330b0ce0bfSmrg# /script/ and the wrapper /executable/ that is used only on 5534e35d4d8eSmrg# windows platforms, and (c) all begin with the string "--lt-" 55350b0ce0bfSmrg# (application programs are unlikely to have options that match 5536e35d4d8eSmrg# this pattern). 5537e35d4d8eSmrg# 5538e35d4d8eSmrg# There are only two supported options: --lt-debug and 5539e35d4d8eSmrg# --lt-dump-script. There is, deliberately, no --lt-help. 5540e35d4d8eSmrg# 5541e35d4d8eSmrg# The first argument to this parsing function should be the 5542e35d4d8eSmrg# script's $0 value, followed by "$@". 5543e35d4d8eSmrglt_option_debug= 5544e35d4d8eSmrgfunc_parse_lt_options () 5545e35d4d8eSmrg{ 5546e35d4d8eSmrg lt_script_arg0=\$0 5547e35d4d8eSmrg shift 5548e35d4d8eSmrg for lt_opt 5549e35d4d8eSmrg do 5550e35d4d8eSmrg case \"\$lt_opt\" in 5551e35d4d8eSmrg --lt-debug) lt_option_debug=1 ;; 5552e35d4d8eSmrg --lt-dump-script) 5553e35d4d8eSmrg lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` 5554e35d4d8eSmrg test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. 5555e35d4d8eSmrg lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` 5556e35d4d8eSmrg cat \"\$lt_dump_D/\$lt_dump_F\" 5557e35d4d8eSmrg exit 0 5558e35d4d8eSmrg ;; 5559e35d4d8eSmrg --lt-*) 5560e35d4d8eSmrg \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 5561e35d4d8eSmrg exit 1 5562e35d4d8eSmrg ;; 5563e35d4d8eSmrg esac 5564e35d4d8eSmrg done 5565e35d4d8eSmrg 5566e35d4d8eSmrg # Print the debug banner immediately: 5567e35d4d8eSmrg if test -n \"\$lt_option_debug\"; then 55680b0ce0bfSmrg echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2 5569e35d4d8eSmrg fi 5570e35d4d8eSmrg} 5571e35d4d8eSmrg 5572e35d4d8eSmrg# Used when --lt-debug. Prints its arguments to stdout 5573e35d4d8eSmrg# (redirection is the responsibility of the caller) 5574e35d4d8eSmrgfunc_lt_dump_args () 5575e35d4d8eSmrg{ 5576e35d4d8eSmrg lt_dump_args_N=1; 5577e35d4d8eSmrg for lt_arg 5578e35d4d8eSmrg do 55790b0ce0bfSmrg \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\" 5580e35d4d8eSmrg lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` 5581e35d4d8eSmrg done 5582e35d4d8eSmrg} 5583e35d4d8eSmrg 5584e35d4d8eSmrg# Core function for launching the target application 5585e35d4d8eSmrgfunc_exec_program_core () 5586e35d4d8eSmrg{ 55871b12faf6Smrg" 5588e35d4d8eSmrg case $host in 5589e35d4d8eSmrg # Backslashes separate directories on plain windows 5590e35d4d8eSmrg *-*-mingw | *-*-os2* | *-cegcc*) 5591e35d4d8eSmrg $ECHO "\ 5592e35d4d8eSmrg if test -n \"\$lt_option_debug\"; then 55930b0ce0bfSmrg \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2 5594e35d4d8eSmrg func_lt_dump_args \${1+\"\$@\"} 1>&2 5595e35d4d8eSmrg fi 5596e35d4d8eSmrg exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} 5597e35d4d8eSmrg" 5598e35d4d8eSmrg ;; 5599e35d4d8eSmrg 5600e35d4d8eSmrg *) 5601e35d4d8eSmrg $ECHO "\ 5602e35d4d8eSmrg if test -n \"\$lt_option_debug\"; then 56030b0ce0bfSmrg \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2 5604e35d4d8eSmrg func_lt_dump_args \${1+\"\$@\"} 1>&2 5605e35d4d8eSmrg fi 5606e35d4d8eSmrg exec \"\$progdir/\$program\" \${1+\"\$@\"} 5607e35d4d8eSmrg" 5608e35d4d8eSmrg ;; 5609e35d4d8eSmrg esac 5610e35d4d8eSmrg $ECHO "\ 5611e35d4d8eSmrg \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 5612e35d4d8eSmrg exit 1 5613e35d4d8eSmrg} 5614e35d4d8eSmrg 5615e35d4d8eSmrg# A function to encapsulate launching the target application 5616e35d4d8eSmrg# Strips options in the --lt-* namespace from \$@ and 5617e35d4d8eSmrg# launches target application with the remaining arguments. 5618e35d4d8eSmrgfunc_exec_program () 5619e35d4d8eSmrg{ 5620e35d4d8eSmrg case \" \$* \" in 5621e35d4d8eSmrg *\\ --lt-*) 5622e35d4d8eSmrg for lt_wr_arg 5623e35d4d8eSmrg do 5624e35d4d8eSmrg case \$lt_wr_arg in 5625e35d4d8eSmrg --lt-*) ;; 5626e35d4d8eSmrg *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; 5627e35d4d8eSmrg esac 5628e35d4d8eSmrg shift 5629e35d4d8eSmrg done ;; 5630e35d4d8eSmrg esac 5631e35d4d8eSmrg func_exec_program_core \${1+\"\$@\"} 5632e35d4d8eSmrg} 5633e35d4d8eSmrg 5634e35d4d8eSmrg # Parse options 5635e35d4d8eSmrg func_parse_lt_options \"\$0\" \${1+\"\$@\"} 563632b578d3Smrg 56371b12faf6Smrg # Find the directory that this script lives in. 5638e35d4d8eSmrg thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` 56391b12faf6Smrg test \"x\$thisdir\" = \"x\$file\" && thisdir=. 564032b578d3Smrg 56411b12faf6Smrg # Follow symbolic links until we get to the real thisdir. 5642e35d4d8eSmrg file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` 56431b12faf6Smrg while test -n \"\$file\"; do 5644e35d4d8eSmrg destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` 564532b578d3Smrg 56461b12faf6Smrg # If there was a directory component, then change thisdir. 56471b12faf6Smrg if test \"x\$destdir\" != \"x\$file\"; then 56481b12faf6Smrg case \"\$destdir\" in 56491b12faf6Smrg [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; 56501b12faf6Smrg *) thisdir=\"\$thisdir/\$destdir\" ;; 565132b578d3Smrg esac 56521b12faf6Smrg fi 565332b578d3Smrg 5654e35d4d8eSmrg file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` 5655e35d4d8eSmrg file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` 56561b12faf6Smrg done 565732b578d3Smrg 56581b12faf6Smrg # Usually 'no', except on cygwin/mingw when embedded into 56591b12faf6Smrg # the cwrapper. 5660e35d4d8eSmrg WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 56611b12faf6Smrg if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then 56621b12faf6Smrg # special case for '.' 56631b12faf6Smrg if test \"\$thisdir\" = \".\"; then 56641b12faf6Smrg thisdir=\`pwd\` 56651b12faf6Smrg fi 56661b12faf6Smrg # remove .libs from thisdir 56671b12faf6Smrg case \"\$thisdir\" in 5668e35d4d8eSmrg *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; 56691b12faf6Smrg $objdir ) thisdir=. ;; 56701b12faf6Smrg esac 56711b12faf6Smrg fi 56721b12faf6Smrg 56731b12faf6Smrg # Try to get the absolute directory name. 56741b12faf6Smrg absdir=\`cd \"\$thisdir\" && pwd\` 56751b12faf6Smrg test -n \"\$absdir\" && thisdir=\"\$absdir\" 56761b12faf6Smrg" 56771b12faf6Smrg 56780b0ce0bfSmrg if test yes = "$fast_install"; then 56791b12faf6Smrg $ECHO "\ 56801b12faf6Smrg program=lt-'$outputname'$exeext 56811b12faf6Smrg progdir=\"\$thisdir/$objdir\" 56821b12faf6Smrg 56831b12faf6Smrg if test ! -f \"\$progdir/\$program\" || 56840b0ce0bfSmrg { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\ 56851b12faf6Smrg test \"X\$file\" != \"X\$progdir/\$program\"; }; then 56861b12faf6Smrg 56871b12faf6Smrg file=\"\$\$-\$program\" 56881b12faf6Smrg 56891b12faf6Smrg if test ! -d \"\$progdir\"; then 56901b12faf6Smrg $MKDIR \"\$progdir\" 56911b12faf6Smrg else 56921b12faf6Smrg $RM \"\$progdir/\$file\" 56931b12faf6Smrg fi" 56941b12faf6Smrg 56951b12faf6Smrg $ECHO "\ 56961b12faf6Smrg 56971b12faf6Smrg # relink executable if necessary 56981b12faf6Smrg if test -n \"\$relink_command\"; then 56991b12faf6Smrg if relink_command_output=\`eval \$relink_command 2>&1\`; then : 57001b12faf6Smrg else 57010b0ce0bfSmrg \$ECHO \"\$relink_command_output\" >&2 57021b12faf6Smrg $RM \"\$progdir/\$file\" 57031b12faf6Smrg exit 1 570432b578d3Smrg fi 57051b12faf6Smrg fi 570632b578d3Smrg 57071b12faf6Smrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || 57081b12faf6Smrg { $RM \"\$progdir/\$program\"; 57091b12faf6Smrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } 57101b12faf6Smrg $RM \"\$progdir/\$file\" 57111b12faf6Smrg fi" 57121b12faf6Smrg else 57131b12faf6Smrg $ECHO "\ 57141b12faf6Smrg program='$outputname' 57151b12faf6Smrg progdir=\"\$thisdir/$objdir\" 57161b12faf6Smrg" 571732b578d3Smrg fi 571832b578d3Smrg 57191b12faf6Smrg $ECHO "\ 572032b578d3Smrg 57211b12faf6Smrg if test -f \"\$progdir/\$program\"; then" 572232b578d3Smrg 5723e35d4d8eSmrg # fixup the dll searchpath if we need to. 5724e35d4d8eSmrg # 5725e35d4d8eSmrg # Fix the DLL searchpath if we need to. Do this before prepending 5726e35d4d8eSmrg # to shlibpath, because on Windows, both are PATH and uninstalled 5727e35d4d8eSmrg # libraries must come first. 5728e35d4d8eSmrg if test -n "$dllsearchpath"; then 5729e35d4d8eSmrg $ECHO "\ 5730e35d4d8eSmrg # Add the dll search path components to the executable PATH 5731e35d4d8eSmrg PATH=$dllsearchpath:\$PATH 5732e35d4d8eSmrg" 5733e35d4d8eSmrg fi 5734e35d4d8eSmrg 57351b12faf6Smrg # Export our shlibpath_var if we have one. 57360b0ce0bfSmrg if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 57371b12faf6Smrg $ECHO "\ 57381b12faf6Smrg # Add our own library path to $shlibpath_var 57391b12faf6Smrg $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" 574032b578d3Smrg 57411b12faf6Smrg # Some systems cannot cope with colon-terminated $shlibpath_var 57421b12faf6Smrg # The second colon is a workaround for a bug in BeOS R4 sed 5743e35d4d8eSmrg $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` 57441b12faf6Smrg 57451b12faf6Smrg export $shlibpath_var 57461b12faf6Smrg" 574732b578d3Smrg fi 574832b578d3Smrg 57491b12faf6Smrg $ECHO "\ 57501b12faf6Smrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 57511b12faf6Smrg # Run the actual program with our arguments. 5752e35d4d8eSmrg func_exec_program \${1+\"\$@\"} 57531b12faf6Smrg fi 57541b12faf6Smrg else 57551b12faf6Smrg # The program doesn't exist. 57560b0ce0bfSmrg \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2 57571b12faf6Smrg \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 5758e35d4d8eSmrg \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 57591b12faf6Smrg exit 1 57601b12faf6Smrg fi 57611b12faf6Smrgfi\ 57621b12faf6Smrg" 57631b12faf6Smrg} 576432b578d3Smrg 576532b578d3Smrg 57661b12faf6Smrg# func_emit_cwrapperexe_src 57671b12faf6Smrg# emit the source code for a wrapper executable on stdout 57681b12faf6Smrg# Must ONLY be called from within func_mode_link because 57691b12faf6Smrg# it depends on a number of variable set therein. 57701b12faf6Smrgfunc_emit_cwrapperexe_src () 57711b12faf6Smrg{ 57721b12faf6Smrg cat <<EOF 577332b578d3Smrg 57741b12faf6Smrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname 57750b0ce0bfSmrg Generated by $PROGRAM (GNU $PACKAGE) $VERSION 577632b578d3Smrg 57771b12faf6Smrg The $output program cannot be directly executed until all the libtool 57781b12faf6Smrg libraries that it depends on are installed. 577932b578d3Smrg 57801b12faf6Smrg This wrapper executable should never be moved out of the build directory. 57811b12faf6Smrg If it is, it will not operate correctly. 57821b12faf6Smrg*/ 57831b12faf6SmrgEOF 57841b12faf6Smrg cat <<"EOF" 5785e35d4d8eSmrg#ifdef _MSC_VER 5786e35d4d8eSmrg# define _CRT_SECURE_NO_DEPRECATE 1 5787e35d4d8eSmrg#endif 57881b12faf6Smrg#include <stdio.h> 57891b12faf6Smrg#include <stdlib.h> 57901b12faf6Smrg#ifdef _MSC_VER 57911b12faf6Smrg# include <direct.h> 57921b12faf6Smrg# include <process.h> 57931b12faf6Smrg# include <io.h> 57941b12faf6Smrg#else 57951b12faf6Smrg# include <unistd.h> 57961b12faf6Smrg# include <stdint.h> 57971b12faf6Smrg# ifdef __CYGWIN__ 57981b12faf6Smrg# include <io.h> 57991b12faf6Smrg# endif 58001b12faf6Smrg#endif 58011b12faf6Smrg#include <malloc.h> 58021b12faf6Smrg#include <stdarg.h> 58031b12faf6Smrg#include <assert.h> 58041b12faf6Smrg#include <string.h> 58051b12faf6Smrg#include <ctype.h> 58061b12faf6Smrg#include <errno.h> 58071b12faf6Smrg#include <fcntl.h> 58081b12faf6Smrg#include <sys/stat.h> 580932b578d3Smrg 58100b0ce0bfSmrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 58110b0ce0bfSmrg 5812e35d4d8eSmrg/* declarations of non-ANSI functions */ 58130b0ce0bfSmrg#if defined __MINGW32__ 5814e35d4d8eSmrg# ifdef __STRICT_ANSI__ 5815e35d4d8eSmrgint _putenv (const char *); 5816e35d4d8eSmrg# endif 58170b0ce0bfSmrg#elif defined __CYGWIN__ 5818e35d4d8eSmrg# ifdef __STRICT_ANSI__ 5819e35d4d8eSmrgchar *realpath (const char *, char *); 5820e35d4d8eSmrgint putenv (char *); 5821e35d4d8eSmrgint setenv (const char *, const char *, int); 5822e35d4d8eSmrg# endif 58230b0ce0bfSmrg/* #elif defined other_platform || defined ... */ 5824e35d4d8eSmrg#endif 5825e35d4d8eSmrg 5826e35d4d8eSmrg/* portability defines, excluding path handling macros */ 58270b0ce0bfSmrg#if defined _MSC_VER 5828e35d4d8eSmrg# define setmode _setmode 5829e35d4d8eSmrg# define stat _stat 5830e35d4d8eSmrg# define chmod _chmod 5831e35d4d8eSmrg# define getcwd _getcwd 5832e35d4d8eSmrg# define putenv _putenv 5833e35d4d8eSmrg# define S_IXUSR _S_IEXEC 58340b0ce0bfSmrg#elif defined __MINGW32__ 5835e35d4d8eSmrg# define setmode _setmode 5836e35d4d8eSmrg# define stat _stat 5837e35d4d8eSmrg# define chmod _chmod 5838e35d4d8eSmrg# define getcwd _getcwd 5839e35d4d8eSmrg# define putenv _putenv 58400b0ce0bfSmrg#elif defined __CYGWIN__ 5841e35d4d8eSmrg# define HAVE_SETENV 5842e35d4d8eSmrg# define FOPEN_WB "wb" 58430b0ce0bfSmrg/* #elif defined other platforms ... */ 5844e35d4d8eSmrg#endif 5845e35d4d8eSmrg 58460b0ce0bfSmrg#if defined PATH_MAX 58471b12faf6Smrg# define LT_PATHMAX PATH_MAX 58480b0ce0bfSmrg#elif defined MAXPATHLEN 58491b12faf6Smrg# define LT_PATHMAX MAXPATHLEN 58501b12faf6Smrg#else 58511b12faf6Smrg# define LT_PATHMAX 1024 58521b12faf6Smrg#endif 585332b578d3Smrg 58541b12faf6Smrg#ifndef S_IXOTH 58551b12faf6Smrg# define S_IXOTH 0 58561b12faf6Smrg#endif 58571b12faf6Smrg#ifndef S_IXGRP 58581b12faf6Smrg# define S_IXGRP 0 58591b12faf6Smrg#endif 586032b578d3Smrg 5861e35d4d8eSmrg/* path handling portability macros */ 58621b12faf6Smrg#ifndef DIR_SEPARATOR 58631b12faf6Smrg# define DIR_SEPARATOR '/' 58641b12faf6Smrg# define PATH_SEPARATOR ':' 58651b12faf6Smrg#endif 586632b578d3Smrg 58670b0ce0bfSmrg#if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \ 58680b0ce0bfSmrg defined __OS2__ 58691b12faf6Smrg# define HAVE_DOS_BASED_FILE_SYSTEM 58701b12faf6Smrg# define FOPEN_WB "wb" 58711b12faf6Smrg# ifndef DIR_SEPARATOR_2 58721b12faf6Smrg# define DIR_SEPARATOR_2 '\\' 58731b12faf6Smrg# endif 58741b12faf6Smrg# ifndef PATH_SEPARATOR_2 58751b12faf6Smrg# define PATH_SEPARATOR_2 ';' 58761b12faf6Smrg# endif 58771b12faf6Smrg#endif 587832b578d3Smrg 58791b12faf6Smrg#ifndef DIR_SEPARATOR_2 58801b12faf6Smrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) 58811b12faf6Smrg#else /* DIR_SEPARATOR_2 */ 58821b12faf6Smrg# define IS_DIR_SEPARATOR(ch) \ 58831b12faf6Smrg (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) 58841b12faf6Smrg#endif /* DIR_SEPARATOR_2 */ 588532b578d3Smrg 58861b12faf6Smrg#ifndef PATH_SEPARATOR_2 58871b12faf6Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) 58881b12faf6Smrg#else /* PATH_SEPARATOR_2 */ 58891b12faf6Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) 58901b12faf6Smrg#endif /* PATH_SEPARATOR_2 */ 589132b578d3Smrg 58921b12faf6Smrg#ifndef FOPEN_WB 58931b12faf6Smrg# define FOPEN_WB "w" 58941b12faf6Smrg#endif 58951b12faf6Smrg#ifndef _O_BINARY 58961b12faf6Smrg# define _O_BINARY 0 58971b12faf6Smrg#endif 589832b578d3Smrg 58991b12faf6Smrg#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) 59001b12faf6Smrg#define XFREE(stale) do { \ 59010b0ce0bfSmrg if (stale) { free (stale); stale = 0; } \ 59021b12faf6Smrg} while (0) 590332b578d3Smrg 59040b0ce0bfSmrg#if defined LT_DEBUGWRAPPER 5905e35d4d8eSmrgstatic int lt_debug = 1; 59061b12faf6Smrg#else 5907e35d4d8eSmrgstatic int lt_debug = 0; 59081b12faf6Smrg#endif 590932b578d3Smrg 5910e35d4d8eSmrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ 591132b578d3Smrg 59121b12faf6Smrgvoid *xmalloc (size_t num); 59131b12faf6Smrgchar *xstrdup (const char *string); 59141b12faf6Smrgconst char *base_name (const char *name); 59151b12faf6Smrgchar *find_executable (const char *wrapper); 59161b12faf6Smrgchar *chase_symlinks (const char *pathspec); 59171b12faf6Smrgint make_executable (const char *path); 59181b12faf6Smrgint check_executable (const char *path); 59191b12faf6Smrgchar *strendzap (char *str, const char *pat); 5920e35d4d8eSmrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...); 5921e35d4d8eSmrgvoid lt_fatal (const char *file, int line, const char *message, ...); 5922e35d4d8eSmrgstatic const char *nonnull (const char *s); 5923e35d4d8eSmrgstatic const char *nonempty (const char *s); 59241b12faf6Smrgvoid lt_setenv (const char *name, const char *value); 59251b12faf6Smrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end); 59261b12faf6Smrgvoid lt_update_exe_path (const char *name, const char *value); 59271b12faf6Smrgvoid lt_update_lib_path (const char *name, const char *value); 5928e35d4d8eSmrgchar **prepare_spawn (char **argv); 5929e35d4d8eSmrgvoid lt_dump_script (FILE *f); 59301b12faf6SmrgEOF 59311b12faf6Smrg 59321b12faf6Smrg cat <<EOF 59330b0ce0bfSmrg#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5) 59340b0ce0bfSmrg# define externally_visible volatile 59350b0ce0bfSmrg#else 59360b0ce0bfSmrg# define externally_visible __attribute__((externally_visible)) volatile 59370b0ce0bfSmrg#endif 59380b0ce0bfSmrgexternally_visible const char * MAGIC_EXE = "$magic_exe"; 59391b12faf6Smrgconst char * LIB_PATH_VARNAME = "$shlibpath_var"; 59401b12faf6SmrgEOF 594132b578d3Smrg 59420b0ce0bfSmrg if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 5943e35d4d8eSmrg func_to_host_path "$temp_rpath" 59441b12faf6Smrg cat <<EOF 5945e35d4d8eSmrgconst char * LIB_PATH_VALUE = "$func_to_host_path_result"; 59461b12faf6SmrgEOF 59471b12faf6Smrg else 59481b12faf6Smrg cat <<"EOF" 59491b12faf6Smrgconst char * LIB_PATH_VALUE = ""; 59501b12faf6SmrgEOF 595132b578d3Smrg fi 595232b578d3Smrg 59531b12faf6Smrg if test -n "$dllsearchpath"; then 5954e35d4d8eSmrg func_to_host_path "$dllsearchpath:" 59551b12faf6Smrg cat <<EOF 59561b12faf6Smrgconst char * EXE_PATH_VARNAME = "PATH"; 5957e35d4d8eSmrgconst char * EXE_PATH_VALUE = "$func_to_host_path_result"; 595832b578d3SmrgEOF 595932b578d3Smrg else 59601b12faf6Smrg cat <<"EOF" 59611b12faf6Smrgconst char * EXE_PATH_VARNAME = ""; 59621b12faf6Smrgconst char * EXE_PATH_VALUE = ""; 59631b12faf6SmrgEOF 596432b578d3Smrg fi 59651b12faf6Smrg 59660b0ce0bfSmrg if test yes = "$fast_install"; then 59671b12faf6Smrg cat <<EOF 59681b12faf6Smrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */ 59691b12faf6SmrgEOF 597032b578d3Smrg else 59711b12faf6Smrg cat <<EOF 59721b12faf6Smrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */ 59731b12faf6SmrgEOF 597432b578d3Smrg fi 597532b578d3Smrg 597632b578d3Smrg 59771b12faf6Smrg cat <<"EOF" 597832b578d3Smrg 59791b12faf6Smrg#define LTWRAPPER_OPTION_PREFIX "--lt-" 598032b578d3Smrg 59811b12faf6Smrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX; 59821b12faf6Smrgstatic const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script"; 5983e35d4d8eSmrgstatic const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug"; 598432b578d3Smrg 59851b12faf6Smrgint 59861b12faf6Smrgmain (int argc, char *argv[]) 59871b12faf6Smrg{ 59881b12faf6Smrg char **newargz; 59891b12faf6Smrg int newargc; 59901b12faf6Smrg char *tmp_pathspec; 59911b12faf6Smrg char *actual_cwrapper_path; 59921b12faf6Smrg char *actual_cwrapper_name; 59931b12faf6Smrg char *target_name; 59941b12faf6Smrg char *lt_argv_zero; 59950b0ce0bfSmrg int rval = 127; 599632b578d3Smrg 59971b12faf6Smrg int i; 599832b578d3Smrg 59991b12faf6Smrg program_name = (char *) xstrdup (base_name (argv[0])); 60000b0ce0bfSmrg newargz = XMALLOC (char *, (size_t) argc + 1); 600132b578d3Smrg 6002e35d4d8eSmrg /* very simple arg parsing; don't want to rely on getopt 6003e35d4d8eSmrg * also, copy all non cwrapper options to newargz, except 6004e35d4d8eSmrg * argz[0], which is handled differently 6005e35d4d8eSmrg */ 6006e35d4d8eSmrg newargc=0; 60071b12faf6Smrg for (i = 1; i < argc; i++) 60081b12faf6Smrg { 60090b0ce0bfSmrg if (STREQ (argv[i], dumpscript_opt)) 60101b12faf6Smrg { 60111b12faf6SmrgEOF 60120b0ce0bfSmrg case $host in 60131b12faf6Smrg *mingw* | *cygwin* ) 60141b12faf6Smrg # make stdout use "unix" line endings 60151b12faf6Smrg echo " setmode(1,_O_BINARY);" 60161b12faf6Smrg ;; 60171b12faf6Smrg esac 601832b578d3Smrg 60191b12faf6Smrg cat <<"EOF" 6020e35d4d8eSmrg lt_dump_script (stdout); 60211b12faf6Smrg return 0; 60221b12faf6Smrg } 60230b0ce0bfSmrg if (STREQ (argv[i], debug_opt)) 6024e35d4d8eSmrg { 6025e35d4d8eSmrg lt_debug = 1; 6026e35d4d8eSmrg continue; 6027e35d4d8eSmrg } 60280b0ce0bfSmrg if (STREQ (argv[i], ltwrapper_option_prefix)) 6029e35d4d8eSmrg { 6030e35d4d8eSmrg /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX 6031e35d4d8eSmrg namespace, but it is not one of the ones we know about and 6032e35d4d8eSmrg have already dealt with, above (inluding dump-script), then 6033e35d4d8eSmrg report an error. Otherwise, targets might begin to believe 6034e35d4d8eSmrg they are allowed to use options in the LTWRAPPER_OPTION_PREFIX 6035e35d4d8eSmrg namespace. The first time any user complains about this, we'll 6036e35d4d8eSmrg need to make LTWRAPPER_OPTION_PREFIX a configure-time option 6037e35d4d8eSmrg or a configure.ac-settable value. 6038e35d4d8eSmrg */ 6039e35d4d8eSmrg lt_fatal (__FILE__, __LINE__, 6040e35d4d8eSmrg "unrecognized %s option: '%s'", 6041e35d4d8eSmrg ltwrapper_option_prefix, argv[i]); 6042e35d4d8eSmrg } 6043e35d4d8eSmrg /* otherwise ... */ 6044e35d4d8eSmrg newargz[++newargc] = xstrdup (argv[i]); 60451b12faf6Smrg } 6046e35d4d8eSmrg newargz[++newargc] = NULL; 6047e35d4d8eSmrg 6048e35d4d8eSmrgEOF 6049e35d4d8eSmrg cat <<EOF 6050e35d4d8eSmrg /* The GNU banner must be the first non-error debug message */ 60510b0ce0bfSmrg lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE) $VERSION\n"); 6052e35d4d8eSmrgEOF 6053e35d4d8eSmrg cat <<"EOF" 6054e35d4d8eSmrg lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]); 6055e35d4d8eSmrg lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name); 605632b578d3Smrg 60571b12faf6Smrg tmp_pathspec = find_executable (argv[0]); 60581b12faf6Smrg if (tmp_pathspec == NULL) 6059e35d4d8eSmrg lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]); 6060e35d4d8eSmrg lt_debugprintf (__FILE__, __LINE__, 6061e35d4d8eSmrg "(main) found exe (before symlink chase) at: %s\n", 6062e35d4d8eSmrg tmp_pathspec); 60631b12faf6Smrg 60641b12faf6Smrg actual_cwrapper_path = chase_symlinks (tmp_pathspec); 6065e35d4d8eSmrg lt_debugprintf (__FILE__, __LINE__, 6066e35d4d8eSmrg "(main) found exe (after symlink chase) at: %s\n", 6067e35d4d8eSmrg actual_cwrapper_path); 60681b12faf6Smrg XFREE (tmp_pathspec); 60691b12faf6Smrg 6070e35d4d8eSmrg actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path)); 60711b12faf6Smrg strendzap (actual_cwrapper_path, actual_cwrapper_name); 60721b12faf6Smrg 60731b12faf6Smrg /* wrapper name transforms */ 60741b12faf6Smrg strendzap (actual_cwrapper_name, ".exe"); 60751b12faf6Smrg tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1); 60761b12faf6Smrg XFREE (actual_cwrapper_name); 60771b12faf6Smrg actual_cwrapper_name = tmp_pathspec; 60781b12faf6Smrg tmp_pathspec = 0; 60791b12faf6Smrg 60801b12faf6Smrg /* target_name transforms -- use actual target program name; might have lt- prefix */ 60811b12faf6Smrg target_name = xstrdup (base_name (TARGET_PROGRAM_NAME)); 60821b12faf6Smrg strendzap (target_name, ".exe"); 60831b12faf6Smrg tmp_pathspec = lt_extend_str (target_name, ".exe", 1); 60841b12faf6Smrg XFREE (target_name); 60851b12faf6Smrg target_name = tmp_pathspec; 60861b12faf6Smrg tmp_pathspec = 0; 60871b12faf6Smrg 6088e35d4d8eSmrg lt_debugprintf (__FILE__, __LINE__, 6089e35d4d8eSmrg "(main) libtool target name: %s\n", 6090e35d4d8eSmrg target_name); 60911b12faf6SmrgEOF 609232b578d3Smrg 60931b12faf6Smrg cat <<EOF 60941b12faf6Smrg newargz[0] = 60951b12faf6Smrg XMALLOC (char, (strlen (actual_cwrapper_path) + 60961b12faf6Smrg strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1)); 60971b12faf6Smrg strcpy (newargz[0], actual_cwrapper_path); 60981b12faf6Smrg strcat (newargz[0], "$objdir"); 60991b12faf6Smrg strcat (newargz[0], "/"); 61001b12faf6SmrgEOF 610132b578d3Smrg 61021b12faf6Smrg cat <<"EOF" 61031b12faf6Smrg /* stop here, and copy so we don't have to do this twice */ 61041b12faf6Smrg tmp_pathspec = xstrdup (newargz[0]); 610532b578d3Smrg 61061b12faf6Smrg /* do NOT want the lt- prefix here, so use actual_cwrapper_name */ 61071b12faf6Smrg strcat (newargz[0], actual_cwrapper_name); 610832b578d3Smrg 61091b12faf6Smrg /* DO want the lt- prefix here if it exists, so use target_name */ 61101b12faf6Smrg lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1); 61111b12faf6Smrg XFREE (tmp_pathspec); 61121b12faf6Smrg tmp_pathspec = NULL; 61131b12faf6SmrgEOF 611432b578d3Smrg 61151b12faf6Smrg case $host_os in 61161b12faf6Smrg mingw*) 61171b12faf6Smrg cat <<"EOF" 61181b12faf6Smrg { 61191b12faf6Smrg char* p; 61201b12faf6Smrg while ((p = strchr (newargz[0], '\\')) != NULL) 61211b12faf6Smrg { 61221b12faf6Smrg *p = '/'; 61231b12faf6Smrg } 61241b12faf6Smrg while ((p = strchr (lt_argv_zero, '\\')) != NULL) 61251b12faf6Smrg { 61261b12faf6Smrg *p = '/'; 61271b12faf6Smrg } 61281b12faf6Smrg } 61291b12faf6SmrgEOF 61301b12faf6Smrg ;; 61311b12faf6Smrg esac 613232b578d3Smrg 61331b12faf6Smrg cat <<"EOF" 61341b12faf6Smrg XFREE (target_name); 61351b12faf6Smrg XFREE (actual_cwrapper_path); 61361b12faf6Smrg XFREE (actual_cwrapper_name); 613732b578d3Smrg 61381b12faf6Smrg lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */ 61391b12faf6Smrg lt_setenv ("DUALCASE", "1"); /* for MSK sh */ 6140e35d4d8eSmrg /* Update the DLL searchpath. EXE_PATH_VALUE ($dllsearchpath) must 6141e35d4d8eSmrg be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath) 6142e35d4d8eSmrg because on Windows, both *_VARNAMEs are PATH but uninstalled 6143e35d4d8eSmrg libraries must come first. */ 61441b12faf6Smrg lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE); 6145e35d4d8eSmrg lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE); 614632b578d3Smrg 6147e35d4d8eSmrg lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n", 6148e35d4d8eSmrg nonnull (lt_argv_zero)); 61491b12faf6Smrg for (i = 0; i < newargc; i++) 61501b12faf6Smrg { 6151e35d4d8eSmrg lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n", 6152e35d4d8eSmrg i, nonnull (newargz[i])); 61531b12faf6Smrg } 615432b578d3Smrg 61551b12faf6SmrgEOF 615632b578d3Smrg 61571b12faf6Smrg case $host_os in 61581b12faf6Smrg mingw*) 61591b12faf6Smrg cat <<"EOF" 61601b12faf6Smrg /* execv doesn't actually work on mingw as expected on unix */ 6161e35d4d8eSmrg newargz = prepare_spawn (newargz); 61620b0ce0bfSmrg rval = (int) _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz); 61631b12faf6Smrg if (rval == -1) 61641b12faf6Smrg { 61651b12faf6Smrg /* failed to start process */ 6166e35d4d8eSmrg lt_debugprintf (__FILE__, __LINE__, 6167e35d4d8eSmrg "(main) failed to launch target \"%s\": %s\n", 6168e35d4d8eSmrg lt_argv_zero, nonnull (strerror (errno))); 61691b12faf6Smrg return 127; 61701b12faf6Smrg } 61711b12faf6Smrg return rval; 61721b12faf6SmrgEOF 61731b12faf6Smrg ;; 61741b12faf6Smrg *) 61751b12faf6Smrg cat <<"EOF" 61761b12faf6Smrg execv (lt_argv_zero, newargz); 61771b12faf6Smrg return rval; /* =127, but avoids unused variable warning */ 61781b12faf6SmrgEOF 61791b12faf6Smrg ;; 61801b12faf6Smrg esac 618132b578d3Smrg 61821b12faf6Smrg cat <<"EOF" 61831b12faf6Smrg} 618432b578d3Smrg 61851b12faf6Smrgvoid * 61861b12faf6Smrgxmalloc (size_t num) 61871b12faf6Smrg{ 61881b12faf6Smrg void *p = (void *) malloc (num); 61891b12faf6Smrg if (!p) 6190e35d4d8eSmrg lt_fatal (__FILE__, __LINE__, "memory exhausted"); 619132b578d3Smrg 61921b12faf6Smrg return p; 61931b12faf6Smrg} 619432b578d3Smrg 61951b12faf6Smrgchar * 61961b12faf6Smrgxstrdup (const char *string) 61971b12faf6Smrg{ 61981b12faf6Smrg return string ? strcpy ((char *) xmalloc (strlen (string) + 1), 61991b12faf6Smrg string) : NULL; 62001b12faf6Smrg} 620132b578d3Smrg 62021b12faf6Smrgconst char * 62031b12faf6Smrgbase_name (const char *name) 62041b12faf6Smrg{ 62051b12faf6Smrg const char *base; 620632b578d3Smrg 62070b0ce0bfSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 62081b12faf6Smrg /* Skip over the disk name in MSDOS pathnames. */ 62091b12faf6Smrg if (isalpha ((unsigned char) name[0]) && name[1] == ':') 62101b12faf6Smrg name += 2; 62111b12faf6Smrg#endif 621232b578d3Smrg 62131b12faf6Smrg for (base = name; *name; name++) 62141b12faf6Smrg if (IS_DIR_SEPARATOR (*name)) 62151b12faf6Smrg base = name + 1; 62161b12faf6Smrg return base; 62171b12faf6Smrg} 621832b578d3Smrg 62191b12faf6Smrgint 62201b12faf6Smrgcheck_executable (const char *path) 62211b12faf6Smrg{ 62221b12faf6Smrg struct stat st; 622332b578d3Smrg 6224e35d4d8eSmrg lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n", 6225e35d4d8eSmrg nonempty (path)); 62261b12faf6Smrg if ((!path) || (!*path)) 62271b12faf6Smrg return 0; 622832b578d3Smrg 62291b12faf6Smrg if ((stat (path, &st) >= 0) 62301b12faf6Smrg && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) 62311b12faf6Smrg return 1; 62321b12faf6Smrg else 62331b12faf6Smrg return 0; 62341b12faf6Smrg} 623532b578d3Smrg 62361b12faf6Smrgint 62371b12faf6Smrgmake_executable (const char *path) 62381b12faf6Smrg{ 62391b12faf6Smrg int rval = 0; 62401b12faf6Smrg struct stat st; 624132b578d3Smrg 6242e35d4d8eSmrg lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", 6243e35d4d8eSmrg nonempty (path)); 62441b12faf6Smrg if ((!path) || (!*path)) 62451b12faf6Smrg return 0; 624632b578d3Smrg 62471b12faf6Smrg if (stat (path, &st) >= 0) 62481b12faf6Smrg { 62491b12faf6Smrg rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); 62501b12faf6Smrg } 62511b12faf6Smrg return rval; 62521b12faf6Smrg} 625332b578d3Smrg 62541b12faf6Smrg/* Searches for the full path of the wrapper. Returns 62551b12faf6Smrg newly allocated full path name if found, NULL otherwise 62561b12faf6Smrg Does not chase symlinks, even on platforms that support them. 62571b12faf6Smrg*/ 62581b12faf6Smrgchar * 62591b12faf6Smrgfind_executable (const char *wrapper) 62601b12faf6Smrg{ 62611b12faf6Smrg int has_slash = 0; 62621b12faf6Smrg const char *p; 62631b12faf6Smrg const char *p_next; 62641b12faf6Smrg /* static buffer for getcwd */ 62651b12faf6Smrg char tmp[LT_PATHMAX + 1]; 62660b0ce0bfSmrg size_t tmp_len; 62671b12faf6Smrg char *concat_name; 626832b578d3Smrg 6269e35d4d8eSmrg lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", 6270e35d4d8eSmrg nonempty (wrapper)); 627132b578d3Smrg 62721b12faf6Smrg if ((wrapper == NULL) || (*wrapper == '\0')) 62731b12faf6Smrg return NULL; 627432b578d3Smrg 62751b12faf6Smrg /* Absolute path? */ 62760b0ce0bfSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 62771b12faf6Smrg if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') 62781b12faf6Smrg { 62791b12faf6Smrg concat_name = xstrdup (wrapper); 62801b12faf6Smrg if (check_executable (concat_name)) 62811b12faf6Smrg return concat_name; 62821b12faf6Smrg XFREE (concat_name); 62831b12faf6Smrg } 62841b12faf6Smrg else 62851b12faf6Smrg { 62861b12faf6Smrg#endif 62871b12faf6Smrg if (IS_DIR_SEPARATOR (wrapper[0])) 62881b12faf6Smrg { 62891b12faf6Smrg concat_name = xstrdup (wrapper); 62901b12faf6Smrg if (check_executable (concat_name)) 62911b12faf6Smrg return concat_name; 62921b12faf6Smrg XFREE (concat_name); 62931b12faf6Smrg } 62940b0ce0bfSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 62951b12faf6Smrg } 62961b12faf6Smrg#endif 629732b578d3Smrg 62981b12faf6Smrg for (p = wrapper; *p; p++) 62991b12faf6Smrg if (*p == '/') 63001b12faf6Smrg { 63011b12faf6Smrg has_slash = 1; 63021b12faf6Smrg break; 63031b12faf6Smrg } 63041b12faf6Smrg if (!has_slash) 63051b12faf6Smrg { 63061b12faf6Smrg /* no slashes; search PATH */ 63071b12faf6Smrg const char *path = getenv ("PATH"); 63081b12faf6Smrg if (path != NULL) 63091b12faf6Smrg { 63101b12faf6Smrg for (p = path; *p; p = p_next) 63111b12faf6Smrg { 63121b12faf6Smrg const char *q; 63131b12faf6Smrg size_t p_len; 63141b12faf6Smrg for (q = p; *q; q++) 63151b12faf6Smrg if (IS_PATH_SEPARATOR (*q)) 63161b12faf6Smrg break; 63170b0ce0bfSmrg p_len = (size_t) (q - p); 63181b12faf6Smrg p_next = (*q == '\0' ? q : q + 1); 63191b12faf6Smrg if (p_len == 0) 63201b12faf6Smrg { 63211b12faf6Smrg /* empty path: current directory */ 63221b12faf6Smrg if (getcwd (tmp, LT_PATHMAX) == NULL) 6323e35d4d8eSmrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 6324e35d4d8eSmrg nonnull (strerror (errno))); 63251b12faf6Smrg tmp_len = strlen (tmp); 63261b12faf6Smrg concat_name = 63271b12faf6Smrg XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 63281b12faf6Smrg memcpy (concat_name, tmp, tmp_len); 63291b12faf6Smrg concat_name[tmp_len] = '/'; 63301b12faf6Smrg strcpy (concat_name + tmp_len + 1, wrapper); 63311b12faf6Smrg } 63321b12faf6Smrg else 63331b12faf6Smrg { 63341b12faf6Smrg concat_name = 63351b12faf6Smrg XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); 63361b12faf6Smrg memcpy (concat_name, p, p_len); 63371b12faf6Smrg concat_name[p_len] = '/'; 63381b12faf6Smrg strcpy (concat_name + p_len + 1, wrapper); 63391b12faf6Smrg } 63401b12faf6Smrg if (check_executable (concat_name)) 63411b12faf6Smrg return concat_name; 63421b12faf6Smrg XFREE (concat_name); 63431b12faf6Smrg } 63441b12faf6Smrg } 63451b12faf6Smrg /* not found in PATH; assume curdir */ 63461b12faf6Smrg } 63471b12faf6Smrg /* Relative path | not found in path: prepend cwd */ 63481b12faf6Smrg if (getcwd (tmp, LT_PATHMAX) == NULL) 6349e35d4d8eSmrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 6350e35d4d8eSmrg nonnull (strerror (errno))); 63511b12faf6Smrg tmp_len = strlen (tmp); 63521b12faf6Smrg concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 63531b12faf6Smrg memcpy (concat_name, tmp, tmp_len); 63541b12faf6Smrg concat_name[tmp_len] = '/'; 63551b12faf6Smrg strcpy (concat_name + tmp_len + 1, wrapper); 635632b578d3Smrg 63571b12faf6Smrg if (check_executable (concat_name)) 63581b12faf6Smrg return concat_name; 63591b12faf6Smrg XFREE (concat_name); 63601b12faf6Smrg return NULL; 63611b12faf6Smrg} 636232b578d3Smrg 63631b12faf6Smrgchar * 63641b12faf6Smrgchase_symlinks (const char *pathspec) 63651b12faf6Smrg{ 63661b12faf6Smrg#ifndef S_ISLNK 63671b12faf6Smrg return xstrdup (pathspec); 63681b12faf6Smrg#else 63691b12faf6Smrg char buf[LT_PATHMAX]; 63701b12faf6Smrg struct stat s; 63711b12faf6Smrg char *tmp_pathspec = xstrdup (pathspec); 63721b12faf6Smrg char *p; 63731b12faf6Smrg int has_symlinks = 0; 63741b12faf6Smrg while (strlen (tmp_pathspec) && !has_symlinks) 63751b12faf6Smrg { 6376e35d4d8eSmrg lt_debugprintf (__FILE__, __LINE__, 6377e35d4d8eSmrg "checking path component for symlinks: %s\n", 6378e35d4d8eSmrg tmp_pathspec); 63791b12faf6Smrg if (lstat (tmp_pathspec, &s) == 0) 63801b12faf6Smrg { 63811b12faf6Smrg if (S_ISLNK (s.st_mode) != 0) 63821b12faf6Smrg { 63831b12faf6Smrg has_symlinks = 1; 63841b12faf6Smrg break; 63851b12faf6Smrg } 638632b578d3Smrg 63871b12faf6Smrg /* search backwards for last DIR_SEPARATOR */ 63881b12faf6Smrg p = tmp_pathspec + strlen (tmp_pathspec) - 1; 63891b12faf6Smrg while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 63901b12faf6Smrg p--; 63911b12faf6Smrg if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 63921b12faf6Smrg { 63931b12faf6Smrg /* no more DIR_SEPARATORS left */ 63941b12faf6Smrg break; 63951b12faf6Smrg } 63961b12faf6Smrg *p = '\0'; 63971b12faf6Smrg } 63981b12faf6Smrg else 63991b12faf6Smrg { 6400e35d4d8eSmrg lt_fatal (__FILE__, __LINE__, 6401e35d4d8eSmrg "error accessing file \"%s\": %s", 6402e35d4d8eSmrg tmp_pathspec, nonnull (strerror (errno))); 64031b12faf6Smrg } 64041b12faf6Smrg } 64051b12faf6Smrg XFREE (tmp_pathspec); 640632b578d3Smrg 64071b12faf6Smrg if (!has_symlinks) 64081b12faf6Smrg { 64091b12faf6Smrg return xstrdup (pathspec); 64101b12faf6Smrg } 641132b578d3Smrg 64121b12faf6Smrg tmp_pathspec = realpath (pathspec, buf); 64131b12faf6Smrg if (tmp_pathspec == 0) 64141b12faf6Smrg { 6415e35d4d8eSmrg lt_fatal (__FILE__, __LINE__, 6416e35d4d8eSmrg "could not follow symlinks for %s", pathspec); 64171b12faf6Smrg } 64181b12faf6Smrg return xstrdup (tmp_pathspec); 64191b12faf6Smrg#endif 64201b12faf6Smrg} 642132b578d3Smrg 64221b12faf6Smrgchar * 64231b12faf6Smrgstrendzap (char *str, const char *pat) 64241b12faf6Smrg{ 64251b12faf6Smrg size_t len, patlen; 642632b578d3Smrg 64271b12faf6Smrg assert (str != NULL); 64281b12faf6Smrg assert (pat != NULL); 642932b578d3Smrg 64301b12faf6Smrg len = strlen (str); 64311b12faf6Smrg patlen = strlen (pat); 643232b578d3Smrg 64331b12faf6Smrg if (patlen <= len) 64341b12faf6Smrg { 64351b12faf6Smrg str += len - patlen; 64360b0ce0bfSmrg if (STREQ (str, pat)) 64371b12faf6Smrg *str = '\0'; 64381b12faf6Smrg } 64391b12faf6Smrg return str; 64401b12faf6Smrg} 644132b578d3Smrg 6442e35d4d8eSmrgvoid 6443e35d4d8eSmrglt_debugprintf (const char *file, int line, const char *fmt, ...) 6444e35d4d8eSmrg{ 6445e35d4d8eSmrg va_list args; 6446e35d4d8eSmrg if (lt_debug) 6447e35d4d8eSmrg { 6448e35d4d8eSmrg (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); 6449e35d4d8eSmrg va_start (args, fmt); 6450e35d4d8eSmrg (void) vfprintf (stderr, fmt, args); 6451e35d4d8eSmrg va_end (args); 6452e35d4d8eSmrg } 6453e35d4d8eSmrg} 6454e35d4d8eSmrg 64551b12faf6Smrgstatic void 6456e35d4d8eSmrglt_error_core (int exit_status, const char *file, 6457e35d4d8eSmrg int line, const char *mode, 64581b12faf6Smrg const char *message, va_list ap) 64591b12faf6Smrg{ 6460e35d4d8eSmrg fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); 64611b12faf6Smrg vfprintf (stderr, message, ap); 64621b12faf6Smrg fprintf (stderr, ".\n"); 646332b578d3Smrg 64641b12faf6Smrg if (exit_status >= 0) 64651b12faf6Smrg exit (exit_status); 64661b12faf6Smrg} 646732b578d3Smrg 64681b12faf6Smrgvoid 6469e35d4d8eSmrglt_fatal (const char *file, int line, const char *message, ...) 64701b12faf6Smrg{ 64711b12faf6Smrg va_list ap; 64721b12faf6Smrg va_start (ap, message); 6473e35d4d8eSmrg lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); 64741b12faf6Smrg va_end (ap); 64751b12faf6Smrg} 647632b578d3Smrg 6477e35d4d8eSmrgstatic const char * 6478e35d4d8eSmrgnonnull (const char *s) 6479e35d4d8eSmrg{ 6480e35d4d8eSmrg return s ? s : "(null)"; 6481e35d4d8eSmrg} 6482e35d4d8eSmrg 6483e35d4d8eSmrgstatic const char * 6484e35d4d8eSmrgnonempty (const char *s) 6485e35d4d8eSmrg{ 6486e35d4d8eSmrg return (s && !*s) ? "(empty)" : nonnull (s); 6487e35d4d8eSmrg} 6488e35d4d8eSmrg 64891b12faf6Smrgvoid 64901b12faf6Smrglt_setenv (const char *name, const char *value) 64911b12faf6Smrg{ 6492e35d4d8eSmrg lt_debugprintf (__FILE__, __LINE__, 6493e35d4d8eSmrg "(lt_setenv) setting '%s' to '%s'\n", 6494e35d4d8eSmrg nonnull (name), nonnull (value)); 64951b12faf6Smrg { 64961b12faf6Smrg#ifdef HAVE_SETENV 64971b12faf6Smrg /* always make a copy, for consistency with !HAVE_SETENV */ 64981b12faf6Smrg char *str = xstrdup (value); 64991b12faf6Smrg setenv (name, str, 1); 65001b12faf6Smrg#else 65010b0ce0bfSmrg size_t len = strlen (name) + 1 + strlen (value) + 1; 65021b12faf6Smrg char *str = XMALLOC (char, len); 65031b12faf6Smrg sprintf (str, "%s=%s", name, value); 65041b12faf6Smrg if (putenv (str) != EXIT_SUCCESS) 65051b12faf6Smrg { 65061b12faf6Smrg XFREE (str); 65071b12faf6Smrg } 65081b12faf6Smrg#endif 65091b12faf6Smrg } 65101b12faf6Smrg} 651132b578d3Smrg 65121b12faf6Smrgchar * 65131b12faf6Smrglt_extend_str (const char *orig_value, const char *add, int to_end) 65141b12faf6Smrg{ 65151b12faf6Smrg char *new_value; 65161b12faf6Smrg if (orig_value && *orig_value) 65171b12faf6Smrg { 65180b0ce0bfSmrg size_t orig_value_len = strlen (orig_value); 65190b0ce0bfSmrg size_t add_len = strlen (add); 65201b12faf6Smrg new_value = XMALLOC (char, add_len + orig_value_len + 1); 65211b12faf6Smrg if (to_end) 65221b12faf6Smrg { 65231b12faf6Smrg strcpy (new_value, orig_value); 65241b12faf6Smrg strcpy (new_value + orig_value_len, add); 65251b12faf6Smrg } 65261b12faf6Smrg else 65271b12faf6Smrg { 65281b12faf6Smrg strcpy (new_value, add); 65291b12faf6Smrg strcpy (new_value + add_len, orig_value); 65301b12faf6Smrg } 65311b12faf6Smrg } 65321b12faf6Smrg else 65331b12faf6Smrg { 65341b12faf6Smrg new_value = xstrdup (add); 65351b12faf6Smrg } 65361b12faf6Smrg return new_value; 65371b12faf6Smrg} 653832b578d3Smrg 65391b12faf6Smrgvoid 65401b12faf6Smrglt_update_exe_path (const char *name, const char *value) 65411b12faf6Smrg{ 6542e35d4d8eSmrg lt_debugprintf (__FILE__, __LINE__, 6543e35d4d8eSmrg "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", 6544e35d4d8eSmrg nonnull (name), nonnull (value)); 654532b578d3Smrg 65461b12faf6Smrg if (name && *name && value && *value) 65471b12faf6Smrg { 65481b12faf6Smrg char *new_value = lt_extend_str (getenv (name), value, 0); 65491b12faf6Smrg /* some systems can't cope with a ':'-terminated path #' */ 65500b0ce0bfSmrg size_t len = strlen (new_value); 65510b0ce0bfSmrg while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1])) 65521b12faf6Smrg { 65530b0ce0bfSmrg new_value[--len] = '\0'; 65541b12faf6Smrg } 65551b12faf6Smrg lt_setenv (name, new_value); 65561b12faf6Smrg XFREE (new_value); 65571b12faf6Smrg } 65581b12faf6Smrg} 655932b578d3Smrg 65601b12faf6Smrgvoid 65611b12faf6Smrglt_update_lib_path (const char *name, const char *value) 65621b12faf6Smrg{ 6563e35d4d8eSmrg lt_debugprintf (__FILE__, __LINE__, 6564e35d4d8eSmrg "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", 6565e35d4d8eSmrg nonnull (name), nonnull (value)); 656632b578d3Smrg 65671b12faf6Smrg if (name && *name && value && *value) 65681b12faf6Smrg { 65691b12faf6Smrg char *new_value = lt_extend_str (getenv (name), value, 0); 65701b12faf6Smrg lt_setenv (name, new_value); 65711b12faf6Smrg XFREE (new_value); 65721b12faf6Smrg } 65731b12faf6Smrg} 657432b578d3Smrg 6575e35d4d8eSmrgEOF 6576e35d4d8eSmrg case $host_os in 6577e35d4d8eSmrg mingw*) 6578e35d4d8eSmrg cat <<"EOF" 6579e35d4d8eSmrg 6580e35d4d8eSmrg/* Prepares an argument vector before calling spawn(). 6581e35d4d8eSmrg Note that spawn() does not by itself call the command interpreter 6582e35d4d8eSmrg (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : 6583e35d4d8eSmrg ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); 6584e35d4d8eSmrg GetVersionEx(&v); 6585e35d4d8eSmrg v.dwPlatformId == VER_PLATFORM_WIN32_NT; 6586e35d4d8eSmrg }) ? "cmd.exe" : "command.com"). 6587e35d4d8eSmrg Instead it simply concatenates the arguments, separated by ' ', and calls 6588e35d4d8eSmrg CreateProcess(). We must quote the arguments since Win32 CreateProcess() 6589e35d4d8eSmrg interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a 6590e35d4d8eSmrg special way: 6591e35d4d8eSmrg - Space and tab are interpreted as delimiters. They are not treated as 6592e35d4d8eSmrg delimiters if they are surrounded by double quotes: "...". 6593e35d4d8eSmrg - Unescaped double quotes are removed from the input. Their only effect is 6594e35d4d8eSmrg that within double quotes, space and tab are treated like normal 6595e35d4d8eSmrg characters. 6596e35d4d8eSmrg - Backslashes not followed by double quotes are not special. 6597e35d4d8eSmrg - But 2*n+1 backslashes followed by a double quote become 6598e35d4d8eSmrg n backslashes followed by a double quote (n >= 0): 6599e35d4d8eSmrg \" -> " 6600e35d4d8eSmrg \\\" -> \" 6601e35d4d8eSmrg \\\\\" -> \\" 6602e35d4d8eSmrg */ 6603e35d4d8eSmrg#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" 6604e35d4d8eSmrg#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" 6605e35d4d8eSmrgchar ** 6606e35d4d8eSmrgprepare_spawn (char **argv) 6607e35d4d8eSmrg{ 6608e35d4d8eSmrg size_t argc; 6609e35d4d8eSmrg char **new_argv; 6610e35d4d8eSmrg size_t i; 6611e35d4d8eSmrg 6612e35d4d8eSmrg /* Count number of arguments. */ 6613e35d4d8eSmrg for (argc = 0; argv[argc] != NULL; argc++) 6614e35d4d8eSmrg ; 6615e35d4d8eSmrg 6616e35d4d8eSmrg /* Allocate new argument vector. */ 6617e35d4d8eSmrg new_argv = XMALLOC (char *, argc + 1); 6618e35d4d8eSmrg 6619e35d4d8eSmrg /* Put quoted arguments into the new argument vector. */ 6620e35d4d8eSmrg for (i = 0; i < argc; i++) 6621e35d4d8eSmrg { 6622e35d4d8eSmrg const char *string = argv[i]; 6623e35d4d8eSmrg 6624e35d4d8eSmrg if (string[0] == '\0') 6625e35d4d8eSmrg new_argv[i] = xstrdup ("\"\""); 6626e35d4d8eSmrg else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) 6627e35d4d8eSmrg { 6628e35d4d8eSmrg int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); 6629e35d4d8eSmrg size_t length; 6630e35d4d8eSmrg unsigned int backslashes; 6631e35d4d8eSmrg const char *s; 6632e35d4d8eSmrg char *quoted_string; 6633e35d4d8eSmrg char *p; 6634e35d4d8eSmrg 6635e35d4d8eSmrg length = 0; 6636e35d4d8eSmrg backslashes = 0; 6637e35d4d8eSmrg if (quote_around) 6638e35d4d8eSmrg length++; 6639e35d4d8eSmrg for (s = string; *s != '\0'; s++) 6640e35d4d8eSmrg { 6641e35d4d8eSmrg char c = *s; 6642e35d4d8eSmrg if (c == '"') 6643e35d4d8eSmrg length += backslashes + 1; 6644e35d4d8eSmrg length++; 6645e35d4d8eSmrg if (c == '\\') 6646e35d4d8eSmrg backslashes++; 6647e35d4d8eSmrg else 6648e35d4d8eSmrg backslashes = 0; 6649e35d4d8eSmrg } 6650e35d4d8eSmrg if (quote_around) 6651e35d4d8eSmrg length += backslashes + 1; 6652e35d4d8eSmrg 6653e35d4d8eSmrg quoted_string = XMALLOC (char, length + 1); 6654e35d4d8eSmrg 6655e35d4d8eSmrg p = quoted_string; 6656e35d4d8eSmrg backslashes = 0; 6657e35d4d8eSmrg if (quote_around) 6658e35d4d8eSmrg *p++ = '"'; 6659e35d4d8eSmrg for (s = string; *s != '\0'; s++) 6660e35d4d8eSmrg { 6661e35d4d8eSmrg char c = *s; 6662e35d4d8eSmrg if (c == '"') 6663e35d4d8eSmrg { 6664e35d4d8eSmrg unsigned int j; 6665e35d4d8eSmrg for (j = backslashes + 1; j > 0; j--) 6666e35d4d8eSmrg *p++ = '\\'; 6667e35d4d8eSmrg } 6668e35d4d8eSmrg *p++ = c; 6669e35d4d8eSmrg if (c == '\\') 6670e35d4d8eSmrg backslashes++; 6671e35d4d8eSmrg else 6672e35d4d8eSmrg backslashes = 0; 6673e35d4d8eSmrg } 6674e35d4d8eSmrg if (quote_around) 6675e35d4d8eSmrg { 6676e35d4d8eSmrg unsigned int j; 6677e35d4d8eSmrg for (j = backslashes; j > 0; j--) 6678e35d4d8eSmrg *p++ = '\\'; 6679e35d4d8eSmrg *p++ = '"'; 6680e35d4d8eSmrg } 6681e35d4d8eSmrg *p = '\0'; 6682e35d4d8eSmrg 6683e35d4d8eSmrg new_argv[i] = quoted_string; 6684e35d4d8eSmrg } 6685e35d4d8eSmrg else 6686e35d4d8eSmrg new_argv[i] = (char *) string; 6687e35d4d8eSmrg } 6688e35d4d8eSmrg new_argv[argc] = NULL; 6689e35d4d8eSmrg 6690e35d4d8eSmrg return new_argv; 6691e35d4d8eSmrg} 6692e35d4d8eSmrgEOF 6693e35d4d8eSmrg ;; 6694e35d4d8eSmrg esac 669532b578d3Smrg 6696e35d4d8eSmrg cat <<"EOF" 6697e35d4d8eSmrgvoid lt_dump_script (FILE* f) 6698e35d4d8eSmrg{ 6699e35d4d8eSmrgEOF 6700e35d4d8eSmrg func_emit_wrapper yes | 6701e35d4d8eSmrg $SED -n -e ' 6702e35d4d8eSmrgs/^\(.\{79\}\)\(..*\)/\1\ 6703e35d4d8eSmrg\2/ 6704e35d4d8eSmrgh 6705e35d4d8eSmrgs/\([\\"]\)/\\\1/g 6706e35d4d8eSmrgs/$/\\n/ 6707e35d4d8eSmrgs/\([^\n]*\).*/ fputs ("\1", f);/p 6708e35d4d8eSmrgg 6709e35d4d8eSmrgD' 6710e35d4d8eSmrg cat <<"EOF" 6711e35d4d8eSmrg} 67121b12faf6SmrgEOF 67131b12faf6Smrg} 67141b12faf6Smrg# end: func_emit_cwrapperexe_src 671532b578d3Smrg 6716e35d4d8eSmrg# func_win32_import_lib_p ARG 6717e35d4d8eSmrg# True if ARG is an import lib, as indicated by $file_magic_cmd 6718e35d4d8eSmrgfunc_win32_import_lib_p () 6719e35d4d8eSmrg{ 67200b0ce0bfSmrg $debug_cmd 67210b0ce0bfSmrg 6722e35d4d8eSmrg case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in 6723e35d4d8eSmrg *import*) : ;; 6724e35d4d8eSmrg *) false ;; 6725e35d4d8eSmrg esac 6726e35d4d8eSmrg} 6727e35d4d8eSmrg 67280b0ce0bfSmrg# func_suncc_cstd_abi 67290b0ce0bfSmrg# !!ONLY CALL THIS FOR SUN CC AFTER $compile_command IS FULLY EXPANDED!! 67300b0ce0bfSmrg# Several compiler flags select an ABI that is incompatible with the 67310b0ce0bfSmrg# Cstd library. Avoid specifying it if any are in CXXFLAGS. 67320b0ce0bfSmrgfunc_suncc_cstd_abi () 67330b0ce0bfSmrg{ 67340b0ce0bfSmrg $debug_cmd 67350b0ce0bfSmrg 67360b0ce0bfSmrg case " $compile_command " in 67370b0ce0bfSmrg *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*) 67380b0ce0bfSmrg suncc_use_cstd_abi=no 67390b0ce0bfSmrg ;; 67400b0ce0bfSmrg *) 67410b0ce0bfSmrg suncc_use_cstd_abi=yes 67420b0ce0bfSmrg ;; 67430b0ce0bfSmrg esac 67440b0ce0bfSmrg} 67450b0ce0bfSmrg 67461b12faf6Smrg# func_mode_link arg... 67471b12faf6Smrgfunc_mode_link () 67481b12faf6Smrg{ 67490b0ce0bfSmrg $debug_cmd 67500b0ce0bfSmrg 67511b12faf6Smrg case $host in 67521b12faf6Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 67531b12faf6Smrg # It is impossible to link a dll without this setting, and 67541b12faf6Smrg # we shouldn't force the makefile maintainer to figure out 67550b0ce0bfSmrg # what system we are compiling for in order to pass an extra 67561b12faf6Smrg # flag for every libtool invocation. 67571b12faf6Smrg # allow_undefined=no 675832b578d3Smrg 67591b12faf6Smrg # FIXME: Unfortunately, there are problems with the above when trying 67600b0ce0bfSmrg # to make a dll that has undefined symbols, in which case not 67611b12faf6Smrg # even a static library is built. For now, we need to specify 67621b12faf6Smrg # -no-undefined on the libtool link line when we can be certain 67631b12faf6Smrg # that all symbols are satisfied, otherwise we get a static library. 67641b12faf6Smrg allow_undefined=yes 67651b12faf6Smrg ;; 67661b12faf6Smrg *) 67671b12faf6Smrg allow_undefined=yes 67681b12faf6Smrg ;; 67691b12faf6Smrg esac 67701b12faf6Smrg libtool_args=$nonopt 67711b12faf6Smrg base_compile="$nonopt $@" 67721b12faf6Smrg compile_command=$nonopt 67731b12faf6Smrg finalize_command=$nonopt 677432b578d3Smrg 67751b12faf6Smrg compile_rpath= 67761b12faf6Smrg finalize_rpath= 67771b12faf6Smrg compile_shlibpath= 67781b12faf6Smrg finalize_shlibpath= 67791b12faf6Smrg convenience= 67801b12faf6Smrg old_convenience= 67811b12faf6Smrg deplibs= 67821b12faf6Smrg old_deplibs= 67831b12faf6Smrg compiler_flags= 67841b12faf6Smrg linker_flags= 67851b12faf6Smrg dllsearchpath= 67861b12faf6Smrg lib_search_path=`pwd` 67871b12faf6Smrg inst_prefix_dir= 67881b12faf6Smrg new_inherited_linker_flags= 678932b578d3Smrg 67901b12faf6Smrg avoid_version=no 6791e35d4d8eSmrg bindir= 67921b12faf6Smrg dlfiles= 67931b12faf6Smrg dlprefiles= 67941b12faf6Smrg dlself=no 67951b12faf6Smrg export_dynamic=no 67961b12faf6Smrg export_symbols= 67971b12faf6Smrg export_symbols_regex= 67981b12faf6Smrg generated= 67991b12faf6Smrg libobjs= 68001b12faf6Smrg ltlibs= 68011b12faf6Smrg module=no 68021b12faf6Smrg no_install=no 68031b12faf6Smrg objs= 68040b0ce0bfSmrg os2dllname= 68051b12faf6Smrg non_pic_objects= 68061b12faf6Smrg precious_files_regex= 68071b12faf6Smrg prefer_static_libs=no 68080b0ce0bfSmrg preload=false 68091b12faf6Smrg prev= 68101b12faf6Smrg prevarg= 68111b12faf6Smrg release= 68121b12faf6Smrg rpath= 68131b12faf6Smrg xrpath= 68141b12faf6Smrg perm_rpath= 68151b12faf6Smrg temp_rpath= 68161b12faf6Smrg thread_safe=no 68171b12faf6Smrg vinfo= 68181b12faf6Smrg vinfo_number=no 68191b12faf6Smrg weak_libs= 68200b0ce0bfSmrg single_module=$wl-single_module 68211b12faf6Smrg func_infer_tag $base_compile 68221b12faf6Smrg 68231b12faf6Smrg # We need to know -static, to get the right output filenames. 68241b12faf6Smrg for arg 68251b12faf6Smrg do 68261b12faf6Smrg case $arg in 68271b12faf6Smrg -shared) 68280b0ce0bfSmrg test yes != "$build_libtool_libs" \ 68290b0ce0bfSmrg && func_fatal_configuration "cannot build a shared library" 68301b12faf6Smrg build_old_libs=no 68311b12faf6Smrg break 68321b12faf6Smrg ;; 68331b12faf6Smrg -all-static | -static | -static-libtool-libs) 68341b12faf6Smrg case $arg in 68351b12faf6Smrg -all-static) 68360b0ce0bfSmrg if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then 68371b12faf6Smrg func_warning "complete static linking is impossible in this configuration" 68381b12faf6Smrg fi 68391b12faf6Smrg if test -n "$link_static_flag"; then 68401b12faf6Smrg dlopen_self=$dlopen_self_static 68411b12faf6Smrg fi 68421b12faf6Smrg prefer_static_libs=yes 68431b12faf6Smrg ;; 68441b12faf6Smrg -static) 68451b12faf6Smrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 68461b12faf6Smrg dlopen_self=$dlopen_self_static 684732b578d3Smrg fi 68481b12faf6Smrg prefer_static_libs=built 68491b12faf6Smrg ;; 68501b12faf6Smrg -static-libtool-libs) 68511b12faf6Smrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 68521b12faf6Smrg dlopen_self=$dlopen_self_static 68531b12faf6Smrg fi 68541b12faf6Smrg prefer_static_libs=yes 68551b12faf6Smrg ;; 68561b12faf6Smrg esac 68571b12faf6Smrg build_libtool_libs=no 68581b12faf6Smrg build_old_libs=yes 68591b12faf6Smrg break 68601b12faf6Smrg ;; 68611b12faf6Smrg esac 68621b12faf6Smrg done 686332b578d3Smrg 68641b12faf6Smrg # See if our shared archives depend on static archives. 68651b12faf6Smrg test -n "$old_archive_from_new_cmds" && build_old_libs=yes 686632b578d3Smrg 68671b12faf6Smrg # Go through the arguments, transforming them on the way. 68681b12faf6Smrg while test "$#" -gt 0; do 68690b0ce0bfSmrg arg=$1 68701b12faf6Smrg shift 68710b0ce0bfSmrg func_quote_arg pretty,unquoted "$arg" 68720b0ce0bfSmrg qarg=$func_quote_arg_unquoted_result 68730b0ce0bfSmrg func_append libtool_args " $func_quote_arg_result" 687432b578d3Smrg 68751b12faf6Smrg # If the previous option needs an argument, assign it. 68761b12faf6Smrg if test -n "$prev"; then 68771b12faf6Smrg case $prev in 68781b12faf6Smrg output) 68791b12faf6Smrg func_append compile_command " @OUTPUT@" 68801b12faf6Smrg func_append finalize_command " @OUTPUT@" 68811b12faf6Smrg ;; 68821b12faf6Smrg esac 688332b578d3Smrg 68841b12faf6Smrg case $prev in 6885e35d4d8eSmrg bindir) 68860b0ce0bfSmrg bindir=$arg 6887e35d4d8eSmrg prev= 6888e35d4d8eSmrg continue 6889e35d4d8eSmrg ;; 68901b12faf6Smrg dlfiles|dlprefiles) 68910b0ce0bfSmrg $preload || { 68921b12faf6Smrg # Add the symbol object into the linking commands. 68931b12faf6Smrg func_append compile_command " @SYMFILE@" 68941b12faf6Smrg func_append finalize_command " @SYMFILE@" 68950b0ce0bfSmrg preload=: 68960b0ce0bfSmrg } 68971b12faf6Smrg case $arg in 68981b12faf6Smrg *.la | *.lo) ;; # We handle these cases below. 68991b12faf6Smrg force) 69000b0ce0bfSmrg if test no = "$dlself"; then 69011b12faf6Smrg dlself=needless 69021b12faf6Smrg export_dynamic=yes 69031b12faf6Smrg fi 69041b12faf6Smrg prev= 69051b12faf6Smrg continue 69061b12faf6Smrg ;; 69071b12faf6Smrg self) 69080b0ce0bfSmrg if test dlprefiles = "$prev"; then 69091b12faf6Smrg dlself=yes 69100b0ce0bfSmrg elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then 69111b12faf6Smrg dlself=yes 691232b578d3Smrg else 69131b12faf6Smrg dlself=needless 69141b12faf6Smrg export_dynamic=yes 691532b578d3Smrg fi 69161b12faf6Smrg prev= 69171b12faf6Smrg continue 69181b12faf6Smrg ;; 69191b12faf6Smrg *) 69200b0ce0bfSmrg if test dlfiles = "$prev"; then 6921e35d4d8eSmrg func_append dlfiles " $arg" 692232b578d3Smrg else 6923e35d4d8eSmrg func_append dlprefiles " $arg" 692432b578d3Smrg fi 69251b12faf6Smrg prev= 69261b12faf6Smrg continue 69271b12faf6Smrg ;; 69281b12faf6Smrg esac 69291b12faf6Smrg ;; 69301b12faf6Smrg expsyms) 69310b0ce0bfSmrg export_symbols=$arg 69321b12faf6Smrg test -f "$arg" \ 69330b0ce0bfSmrg || func_fatal_error "symbol file '$arg' does not exist" 69341b12faf6Smrg prev= 69351b12faf6Smrg continue 69361b12faf6Smrg ;; 69371b12faf6Smrg expsyms_regex) 69380b0ce0bfSmrg export_symbols_regex=$arg 69391b12faf6Smrg prev= 69401b12faf6Smrg continue 69411b12faf6Smrg ;; 69421b12faf6Smrg framework) 69431b12faf6Smrg case $host in 69441b12faf6Smrg *-*-darwin*) 69451b12faf6Smrg case "$deplibs " in 69461b12faf6Smrg *" $qarg.ltframework "*) ;; 6947e35d4d8eSmrg *) func_append deplibs " $qarg.ltframework" # this is fixed later 69481b12faf6Smrg ;; 69491b12faf6Smrg esac 695032b578d3Smrg ;; 69511b12faf6Smrg esac 69521b12faf6Smrg prev= 69531b12faf6Smrg continue 69541b12faf6Smrg ;; 69551b12faf6Smrg inst_prefix) 69560b0ce0bfSmrg inst_prefix_dir=$arg 69570b0ce0bfSmrg prev= 69580b0ce0bfSmrg continue 69590b0ce0bfSmrg ;; 69600b0ce0bfSmrg mllvm) 69610b0ce0bfSmrg # Clang does not use LLVM to link, so we can simply discard any 69620b0ce0bfSmrg # '-mllvm $arg' options when doing the link step. 69631b12faf6Smrg prev= 69641b12faf6Smrg continue 69651b12faf6Smrg ;; 69661b12faf6Smrg objectlist) 69671b12faf6Smrg if test -f "$arg"; then 69681b12faf6Smrg save_arg=$arg 69691b12faf6Smrg moreargs= 69701b12faf6Smrg for fil in `cat "$save_arg"` 69711b12faf6Smrg do 6972e35d4d8eSmrg# func_append moreargs " $fil" 69731b12faf6Smrg arg=$fil 69741b12faf6Smrg # A libtool-controlled object. 697532b578d3Smrg 69761b12faf6Smrg # Check to see that this really is a libtool object. 69771b12faf6Smrg if func_lalib_unsafe_p "$arg"; then 69781b12faf6Smrg pic_object= 69791b12faf6Smrg non_pic_object= 698032b578d3Smrg 69811b12faf6Smrg # Read the .lo file 69821b12faf6Smrg func_source "$arg" 698332b578d3Smrg 69841b12faf6Smrg if test -z "$pic_object" || 69851b12faf6Smrg test -z "$non_pic_object" || 69860b0ce0bfSmrg test none = "$pic_object" && 69870b0ce0bfSmrg test none = "$non_pic_object"; then 69880b0ce0bfSmrg func_fatal_error "cannot find name of object for '$arg'" 69891b12faf6Smrg fi 699032b578d3Smrg 69911b12faf6Smrg # Extract subdirectory from the argument. 69921b12faf6Smrg func_dirname "$arg" "/" "" 69930b0ce0bfSmrg xdir=$func_dirname_result 699432b578d3Smrg 69950b0ce0bfSmrg if test none != "$pic_object"; then 69961b12faf6Smrg # Prepend the subdirectory the object is found in. 69970b0ce0bfSmrg pic_object=$xdir$pic_object 699832b578d3Smrg 69990b0ce0bfSmrg if test dlfiles = "$prev"; then 70000b0ce0bfSmrg if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 7001e35d4d8eSmrg func_append dlfiles " $pic_object" 70021b12faf6Smrg prev= 70031b12faf6Smrg continue 70041b12faf6Smrg else 70051b12faf6Smrg # If libtool objects are unsupported, then we need to preload. 70061b12faf6Smrg prev=dlprefiles 70071b12faf6Smrg fi 70081b12faf6Smrg fi 700932b578d3Smrg 70101b12faf6Smrg # CHECK ME: I think I busted this. -Ossama 70110b0ce0bfSmrg if test dlprefiles = "$prev"; then 70121b12faf6Smrg # Preload the old-style object. 7013e35d4d8eSmrg func_append dlprefiles " $pic_object" 70141b12faf6Smrg prev= 70151b12faf6Smrg fi 701632b578d3Smrg 70171b12faf6Smrg # A PIC object. 70181b12faf6Smrg func_append libobjs " $pic_object" 70190b0ce0bfSmrg arg=$pic_object 70201b12faf6Smrg fi 702132b578d3Smrg 70221b12faf6Smrg # Non-PIC object. 70230b0ce0bfSmrg if test none != "$non_pic_object"; then 70241b12faf6Smrg # Prepend the subdirectory the object is found in. 70250b0ce0bfSmrg non_pic_object=$xdir$non_pic_object 702632b578d3Smrg 70271b12faf6Smrg # A standard non-PIC object 70281b12faf6Smrg func_append non_pic_objects " $non_pic_object" 70290b0ce0bfSmrg if test -z "$pic_object" || test none = "$pic_object"; then 70300b0ce0bfSmrg arg=$non_pic_object 70311b12faf6Smrg fi 70321b12faf6Smrg else 70331b12faf6Smrg # If the PIC object exists, use it instead. 70341b12faf6Smrg # $xdir was prepended to $pic_object above. 70350b0ce0bfSmrg non_pic_object=$pic_object 70361b12faf6Smrg func_append non_pic_objects " $non_pic_object" 70371b12faf6Smrg fi 70381b12faf6Smrg else 70391b12faf6Smrg # Only an error if not doing a dry-run. 70401b12faf6Smrg if $opt_dry_run; then 70411b12faf6Smrg # Extract subdirectory from the argument. 70421b12faf6Smrg func_dirname "$arg" "/" "" 70430b0ce0bfSmrg xdir=$func_dirname_result 70441b12faf6Smrg 70451b12faf6Smrg func_lo2o "$arg" 70461b12faf6Smrg pic_object=$xdir$objdir/$func_lo2o_result 70471b12faf6Smrg non_pic_object=$xdir$func_lo2o_result 70481b12faf6Smrg func_append libobjs " $pic_object" 70491b12faf6Smrg func_append non_pic_objects " $non_pic_object" 70501b12faf6Smrg else 70510b0ce0bfSmrg func_fatal_error "'$arg' is not a valid libtool object" 70521b12faf6Smrg fi 70531b12faf6Smrg fi 70541b12faf6Smrg done 70551b12faf6Smrg else 70560b0ce0bfSmrg func_fatal_error "link input file '$arg' does not exist" 70571b12faf6Smrg fi 70581b12faf6Smrg arg=$save_arg 70591b12faf6Smrg prev= 70601b12faf6Smrg continue 70611b12faf6Smrg ;; 70620b0ce0bfSmrg os2dllname) 70630b0ce0bfSmrg os2dllname=$arg 70640b0ce0bfSmrg prev= 70650b0ce0bfSmrg continue 70660b0ce0bfSmrg ;; 70671b12faf6Smrg precious_regex) 70680b0ce0bfSmrg precious_files_regex=$arg 70691b12faf6Smrg prev= 70701b12faf6Smrg continue 70711b12faf6Smrg ;; 70721b12faf6Smrg release) 70730b0ce0bfSmrg release=-$arg 70741b12faf6Smrg prev= 70751b12faf6Smrg continue 70761b12faf6Smrg ;; 70771b12faf6Smrg rpath | xrpath) 70781b12faf6Smrg # We need an absolute path. 70791b12faf6Smrg case $arg in 70801b12faf6Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 70811b12faf6Smrg *) 70821b12faf6Smrg func_fatal_error "only absolute run-paths are allowed" 70831b12faf6Smrg ;; 70841b12faf6Smrg esac 70850b0ce0bfSmrg if test rpath = "$prev"; then 70861b12faf6Smrg case "$rpath " in 70871b12faf6Smrg *" $arg "*) ;; 7088e35d4d8eSmrg *) func_append rpath " $arg" ;; 70891b12faf6Smrg esac 70901b12faf6Smrg else 70911b12faf6Smrg case "$xrpath " in 70921b12faf6Smrg *" $arg "*) ;; 7093e35d4d8eSmrg *) func_append xrpath " $arg" ;; 70941b12faf6Smrg esac 70951b12faf6Smrg fi 70961b12faf6Smrg prev= 70971b12faf6Smrg continue 70981b12faf6Smrg ;; 70991b12faf6Smrg shrext) 71000b0ce0bfSmrg shrext_cmds=$arg 71011b12faf6Smrg prev= 71021b12faf6Smrg continue 71031b12faf6Smrg ;; 71041b12faf6Smrg weak) 7105e35d4d8eSmrg func_append weak_libs " $arg" 71061b12faf6Smrg prev= 71071b12faf6Smrg continue 71081b12faf6Smrg ;; 71090b0ce0bfSmrg xassembler) 71100b0ce0bfSmrg func_append compiler_flags " -Xassembler $qarg" 71110b0ce0bfSmrg prev= 71120b0ce0bfSmrg func_append compile_command " -Xassembler $qarg" 71130b0ce0bfSmrg func_append finalize_command " -Xassembler $qarg" 71140b0ce0bfSmrg continue 71150b0ce0bfSmrg ;; 71161b12faf6Smrg xcclinker) 7117e35d4d8eSmrg func_append linker_flags " $qarg" 7118e35d4d8eSmrg func_append compiler_flags " $qarg" 71191b12faf6Smrg prev= 71201b12faf6Smrg func_append compile_command " $qarg" 71211b12faf6Smrg func_append finalize_command " $qarg" 71221b12faf6Smrg continue 71231b12faf6Smrg ;; 71241b12faf6Smrg xcompiler) 7125e35d4d8eSmrg func_append compiler_flags " $qarg" 71261b12faf6Smrg prev= 71271b12faf6Smrg func_append compile_command " $qarg" 71281b12faf6Smrg func_append finalize_command " $qarg" 71291b12faf6Smrg continue 71301b12faf6Smrg ;; 71311b12faf6Smrg xlinker) 7132e35d4d8eSmrg func_append linker_flags " $qarg" 7133e35d4d8eSmrg func_append compiler_flags " $wl$qarg" 71341b12faf6Smrg prev= 71351b12faf6Smrg func_append compile_command " $wl$qarg" 71361b12faf6Smrg func_append finalize_command " $wl$qarg" 71371b12faf6Smrg continue 713832b578d3Smrg ;; 713932b578d3Smrg *) 71401b12faf6Smrg eval "$prev=\"\$arg\"" 71411b12faf6Smrg prev= 71421b12faf6Smrg continue 714332b578d3Smrg ;; 714432b578d3Smrg esac 71451b12faf6Smrg fi # test -n "$prev" 714632b578d3Smrg 71470b0ce0bfSmrg prevarg=$arg 714832b578d3Smrg 71491b12faf6Smrg case $arg in 71501b12faf6Smrg -all-static) 71511b12faf6Smrg if test -n "$link_static_flag"; then 71521b12faf6Smrg # See comment for -static flag below, for more details. 71531b12faf6Smrg func_append compile_command " $link_static_flag" 71541b12faf6Smrg func_append finalize_command " $link_static_flag" 715532b578d3Smrg fi 71561b12faf6Smrg continue 71571b12faf6Smrg ;; 715832b578d3Smrg 71591b12faf6Smrg -allow-undefined) 71601b12faf6Smrg # FIXME: remove this flag sometime in the future. 71610b0ce0bfSmrg func_fatal_error "'-allow-undefined' must not be used because it is the default" 71621b12faf6Smrg ;; 716332b578d3Smrg 71641b12faf6Smrg -avoid-version) 71651b12faf6Smrg avoid_version=yes 71661b12faf6Smrg continue 71671b12faf6Smrg ;; 716832b578d3Smrg 7169e35d4d8eSmrg -bindir) 7170e35d4d8eSmrg prev=bindir 7171e35d4d8eSmrg continue 7172e35d4d8eSmrg ;; 7173e35d4d8eSmrg 71741b12faf6Smrg -dlopen) 71751b12faf6Smrg prev=dlfiles 71761b12faf6Smrg continue 71771b12faf6Smrg ;; 717832b578d3Smrg 71791b12faf6Smrg -dlpreopen) 71801b12faf6Smrg prev=dlprefiles 71811b12faf6Smrg continue 71821b12faf6Smrg ;; 718332b578d3Smrg 71841b12faf6Smrg -export-dynamic) 71851b12faf6Smrg export_dynamic=yes 71861b12faf6Smrg continue 71871b12faf6Smrg ;; 718832b578d3Smrg 71891b12faf6Smrg -export-symbols | -export-symbols-regex) 71901b12faf6Smrg if test -n "$export_symbols" || test -n "$export_symbols_regex"; then 71911b12faf6Smrg func_fatal_error "more than one -exported-symbols argument is not allowed" 71921b12faf6Smrg fi 71930b0ce0bfSmrg if test X-export-symbols = "X$arg"; then 71941b12faf6Smrg prev=expsyms 719532b578d3Smrg else 71961b12faf6Smrg prev=expsyms_regex 719732b578d3Smrg fi 71981b12faf6Smrg continue 71991b12faf6Smrg ;; 720032b578d3Smrg 72011b12faf6Smrg -framework) 72021b12faf6Smrg prev=framework 72031b12faf6Smrg continue 72041b12faf6Smrg ;; 720532b578d3Smrg 72061b12faf6Smrg -inst-prefix-dir) 72071b12faf6Smrg prev=inst_prefix 72081b12faf6Smrg continue 72091b12faf6Smrg ;; 721032b578d3Smrg 72111b12faf6Smrg # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* 72121b12faf6Smrg # so, if we see these flags be careful not to treat them like -L 72131b12faf6Smrg -L[A-Z][A-Z]*:*) 72141b12faf6Smrg case $with_gcc/$host in 72151b12faf6Smrg no/*-*-irix* | /*-*-irix*) 72161b12faf6Smrg func_append compile_command " $arg" 72171b12faf6Smrg func_append finalize_command " $arg" 72181b12faf6Smrg ;; 72191b12faf6Smrg esac 72201b12faf6Smrg continue 72211b12faf6Smrg ;; 722232b578d3Smrg 72231b12faf6Smrg -L*) 7224e35d4d8eSmrg func_stripname "-L" '' "$arg" 7225e35d4d8eSmrg if test -z "$func_stripname_result"; then 72261b12faf6Smrg if test "$#" -gt 0; then 72270b0ce0bfSmrg func_fatal_error "require no space between '-L' and '$1'" 722832b578d3Smrg else 72290b0ce0bfSmrg func_fatal_error "need path for '-L' option" 723032b578d3Smrg fi 72311b12faf6Smrg fi 7232e35d4d8eSmrg func_resolve_sysroot "$func_stripname_result" 7233e35d4d8eSmrg dir=$func_resolve_sysroot_result 72341b12faf6Smrg # We need an absolute path. 72351b12faf6Smrg case $dir in 72361b12faf6Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 72371b12faf6Smrg *) 72381b12faf6Smrg absdir=`cd "$dir" && pwd` 72391b12faf6Smrg test -z "$absdir" && \ 72400b0ce0bfSmrg func_fatal_error "cannot determine absolute directory name of '$dir'" 72410b0ce0bfSmrg dir=$absdir 72421b12faf6Smrg ;; 724332b578d3Smrg esac 72441b12faf6Smrg case "$deplibs " in 7245e35d4d8eSmrg *" -L$dir "* | *" $arg "*) 7246e35d4d8eSmrg # Will only happen for absolute or sysroot arguments 7247e35d4d8eSmrg ;; 72481b12faf6Smrg *) 7249e35d4d8eSmrg # Preserve sysroot, but never include relative directories 7250e35d4d8eSmrg case $dir in 7251e35d4d8eSmrg [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; 7252e35d4d8eSmrg *) func_append deplibs " -L$dir" ;; 7253e35d4d8eSmrg esac 7254e35d4d8eSmrg func_append lib_search_path " $dir" 72551b12faf6Smrg ;; 725632b578d3Smrg esac 725732b578d3Smrg case $host in 72581b12faf6Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 7259e35d4d8eSmrg testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` 72601b12faf6Smrg case :$dllsearchpath: in 72611b12faf6Smrg *":$dir:"*) ;; 72621b12faf6Smrg ::) dllsearchpath=$dir;; 7263e35d4d8eSmrg *) func_append dllsearchpath ":$dir";; 72641b12faf6Smrg esac 72651b12faf6Smrg case :$dllsearchpath: in 72661b12faf6Smrg *":$testbindir:"*) ;; 72671b12faf6Smrg ::) dllsearchpath=$testbindir;; 7268e35d4d8eSmrg *) func_append dllsearchpath ":$testbindir";; 72691b12faf6Smrg esac 72701b12faf6Smrg ;; 727132b578d3Smrg esac 72721b12faf6Smrg continue 72731b12faf6Smrg ;; 727432b578d3Smrg 72751b12faf6Smrg -l*) 72760b0ce0bfSmrg if test X-lc = "X$arg" || test X-lm = "X$arg"; then 72771b12faf6Smrg case $host in 7278e35d4d8eSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) 72791b12faf6Smrg # These systems don't actually have a C or math library (as such) 72801b12faf6Smrg continue 72811b12faf6Smrg ;; 72821b12faf6Smrg *-*-os2*) 72831b12faf6Smrg # These systems don't actually have a C library (as such) 72840b0ce0bfSmrg test X-lc = "X$arg" && continue 72851b12faf6Smrg ;; 72860b0ce0bfSmrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig* | *-*-midnightbsd*) 72871b12faf6Smrg # Do not include libc due to us having libc/libc_r. 72880b0ce0bfSmrg test X-lc = "X$arg" && continue 72891b12faf6Smrg ;; 72901b12faf6Smrg *-*-rhapsody* | *-*-darwin1.[012]) 72911b12faf6Smrg # Rhapsody C and math libraries are in the System framework 7292e35d4d8eSmrg func_append deplibs " System.ltframework" 72931b12faf6Smrg continue 72941b12faf6Smrg ;; 72951b12faf6Smrg *-*-sco3.2v5* | *-*-sco5v6*) 72961b12faf6Smrg # Causes problems with __ctype 72970b0ce0bfSmrg test X-lc = "X$arg" && continue 72981b12faf6Smrg ;; 72991b12faf6Smrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 73001b12faf6Smrg # Compiler inserts libc in the correct place for threads to work 73010b0ce0bfSmrg test X-lc = "X$arg" && continue 73021b12faf6Smrg ;; 73031b12faf6Smrg esac 73040b0ce0bfSmrg elif test X-lc_r = "X$arg"; then 73051b12faf6Smrg case $host in 73060b0ce0bfSmrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig* | *-*-midnightbsd*) 73071b12faf6Smrg # Do not include libc_r directly, use -pthread flag. 73081b12faf6Smrg continue 73091b12faf6Smrg ;; 73101b12faf6Smrg esac 73111b12faf6Smrg fi 7312e35d4d8eSmrg func_append deplibs " $arg" 73131b12faf6Smrg continue 73141b12faf6Smrg ;; 731532b578d3Smrg 73160b0ce0bfSmrg -mllvm) 73170b0ce0bfSmrg prev=mllvm 73180b0ce0bfSmrg continue 73190b0ce0bfSmrg ;; 73200b0ce0bfSmrg 73211b12faf6Smrg -module) 73221b12faf6Smrg module=yes 73231b12faf6Smrg continue 73241b12faf6Smrg ;; 732532b578d3Smrg 73261b12faf6Smrg # Tru64 UNIX uses -model [arg] to determine the layout of C++ 73271b12faf6Smrg # classes, name mangling, and exception handling. 73281b12faf6Smrg # Darwin uses the -arch flag to determine output architecture. 7329e35d4d8eSmrg -model|-arch|-isysroot|--sysroot) 7330e35d4d8eSmrg func_append compiler_flags " $arg" 73311b12faf6Smrg func_append compile_command " $arg" 73321b12faf6Smrg func_append finalize_command " $arg" 73331b12faf6Smrg prev=xcompiler 73341b12faf6Smrg continue 73351b12faf6Smrg ;; 73360b0ce0bfSmrg # Solaris ld rejects as of 11.4. Refer to Oracle bug 22985199. 73370b0ce0bfSmrg -pthread) 73380b0ce0bfSmrg case $host in 73390b0ce0bfSmrg *solaris2*) ;; 73400b0ce0bfSmrg *) 73410b0ce0bfSmrg case "$new_inherited_linker_flags " in 73420b0ce0bfSmrg *" $arg "*) ;; 73430b0ce0bfSmrg * ) func_append new_inherited_linker_flags " $arg" ;; 73440b0ce0bfSmrg esac 73450b0ce0bfSmrg ;; 73460b0ce0bfSmrg esac 73470b0ce0bfSmrg continue 73480b0ce0bfSmrg ;; 73490b0ce0bfSmrg -mt|-mthreads|-kthread|-Kthread|-pthreads|--thread-safe \ 7350e35d4d8eSmrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 7351e35d4d8eSmrg func_append compiler_flags " $arg" 73521b12faf6Smrg func_append compile_command " $arg" 73531b12faf6Smrg func_append finalize_command " $arg" 73541b12faf6Smrg case "$new_inherited_linker_flags " in 73551b12faf6Smrg *" $arg "*) ;; 7356e35d4d8eSmrg * ) func_append new_inherited_linker_flags " $arg" ;; 73571b12faf6Smrg esac 73581b12faf6Smrg continue 73591b12faf6Smrg ;; 736032b578d3Smrg 73611b12faf6Smrg -multi_module) 73620b0ce0bfSmrg single_module=$wl-multi_module 73631b12faf6Smrg continue 73641b12faf6Smrg ;; 736532b578d3Smrg 73661b12faf6Smrg -no-fast-install) 73671b12faf6Smrg fast_install=no 73681b12faf6Smrg continue 73691b12faf6Smrg ;; 737032b578d3Smrg 73711b12faf6Smrg -no-install) 73721b12faf6Smrg case $host in 73731b12faf6Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) 73741b12faf6Smrg # The PATH hackery in wrapper scripts is required on Windows 73751b12faf6Smrg # and Darwin in order for the loader to find any dlls it needs. 73760b0ce0bfSmrg func_warning "'-no-install' is ignored for $host" 73770b0ce0bfSmrg func_warning "assuming '-no-fast-install' instead" 73781b12faf6Smrg fast_install=no 73791b12faf6Smrg ;; 73801b12faf6Smrg *) no_install=yes ;; 73811b12faf6Smrg esac 73821b12faf6Smrg continue 73831b12faf6Smrg ;; 738432b578d3Smrg 73851b12faf6Smrg -no-undefined) 73861b12faf6Smrg allow_undefined=no 73871b12faf6Smrg continue 73881b12faf6Smrg ;; 738932b578d3Smrg 73901b12faf6Smrg -objectlist) 73911b12faf6Smrg prev=objectlist 73921b12faf6Smrg continue 73931b12faf6Smrg ;; 739432b578d3Smrg 73950b0ce0bfSmrg -os2dllname) 73960b0ce0bfSmrg prev=os2dllname 73970b0ce0bfSmrg continue 73980b0ce0bfSmrg ;; 73990b0ce0bfSmrg 74001b12faf6Smrg -o) prev=output ;; 740132b578d3Smrg 74021b12faf6Smrg -precious-files-regex) 74031b12faf6Smrg prev=precious_regex 74041b12faf6Smrg continue 74051b12faf6Smrg ;; 740632b578d3Smrg 74071b12faf6Smrg -release) 74081b12faf6Smrg prev=release 74091b12faf6Smrg continue 74101b12faf6Smrg ;; 741132b578d3Smrg 74121b12faf6Smrg -rpath) 74131b12faf6Smrg prev=rpath 74141b12faf6Smrg continue 74151b12faf6Smrg ;; 741632b578d3Smrg 74171b12faf6Smrg -R) 74181b12faf6Smrg prev=xrpath 74191b12faf6Smrg continue 74201b12faf6Smrg ;; 742132b578d3Smrg 74221b12faf6Smrg -R*) 74231b12faf6Smrg func_stripname '-R' '' "$arg" 74241b12faf6Smrg dir=$func_stripname_result 74251b12faf6Smrg # We need an absolute path. 74261b12faf6Smrg case $dir in 74271b12faf6Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 7428e35d4d8eSmrg =*) 7429e35d4d8eSmrg func_stripname '=' '' "$dir" 7430e35d4d8eSmrg dir=$lt_sysroot$func_stripname_result 7431e35d4d8eSmrg ;; 74321b12faf6Smrg *) 74331b12faf6Smrg func_fatal_error "only absolute run-paths are allowed" 74341b12faf6Smrg ;; 74351b12faf6Smrg esac 74361b12faf6Smrg case "$xrpath " in 74371b12faf6Smrg *" $dir "*) ;; 7438e35d4d8eSmrg *) func_append xrpath " $dir" ;; 74391b12faf6Smrg esac 74401b12faf6Smrg continue 74411b12faf6Smrg ;; 744232b578d3Smrg 74431b12faf6Smrg -shared) 74441b12faf6Smrg # The effects of -shared are defined in a previous loop. 74451b12faf6Smrg continue 74461b12faf6Smrg ;; 744732b578d3Smrg 74481b12faf6Smrg -shrext) 74491b12faf6Smrg prev=shrext 74501b12faf6Smrg continue 74511b12faf6Smrg ;; 745232b578d3Smrg 74531b12faf6Smrg -static | -static-libtool-libs) 74541b12faf6Smrg # The effects of -static are defined in a previous loop. 74551b12faf6Smrg # We used to do the same as -all-static on platforms that 74561b12faf6Smrg # didn't have a PIC flag, but the assumption that the effects 74571b12faf6Smrg # would be equivalent was wrong. It would break on at least 74581b12faf6Smrg # Digital Unix and AIX. 74591b12faf6Smrg continue 74601b12faf6Smrg ;; 746132b578d3Smrg 74621b12faf6Smrg -thread-safe) 74631b12faf6Smrg thread_safe=yes 74641b12faf6Smrg continue 74651b12faf6Smrg ;; 746632b578d3Smrg 74671b12faf6Smrg -version-info) 74681b12faf6Smrg prev=vinfo 74691b12faf6Smrg continue 74701b12faf6Smrg ;; 747132b578d3Smrg 74721b12faf6Smrg -version-number) 74731b12faf6Smrg prev=vinfo 74741b12faf6Smrg vinfo_number=yes 74751b12faf6Smrg continue 74761b12faf6Smrg ;; 747732b578d3Smrg 74781b12faf6Smrg -weak) 74791b12faf6Smrg prev=weak 74801b12faf6Smrg continue 74811b12faf6Smrg ;; 748232b578d3Smrg 74831b12faf6Smrg -Wc,*) 74841b12faf6Smrg func_stripname '-Wc,' '' "$arg" 74851b12faf6Smrg args=$func_stripname_result 74861b12faf6Smrg arg= 74870b0ce0bfSmrg save_ifs=$IFS; IFS=, 74881b12faf6Smrg for flag in $args; do 74890b0ce0bfSmrg IFS=$save_ifs 74900b0ce0bfSmrg func_quote_arg pretty "$flag" 74910b0ce0bfSmrg func_append arg " $func_quote_arg_result" 74920b0ce0bfSmrg func_append compiler_flags " $func_quote_arg_result" 74931b12faf6Smrg done 74940b0ce0bfSmrg IFS=$save_ifs 74951b12faf6Smrg func_stripname ' ' '' "$arg" 74961b12faf6Smrg arg=$func_stripname_result 74971b12faf6Smrg ;; 749832b578d3Smrg 74991b12faf6Smrg -Wl,*) 75001b12faf6Smrg func_stripname '-Wl,' '' "$arg" 75011b12faf6Smrg args=$func_stripname_result 75021b12faf6Smrg arg= 75030b0ce0bfSmrg save_ifs=$IFS; IFS=, 75041b12faf6Smrg for flag in $args; do 75050b0ce0bfSmrg IFS=$save_ifs 75060b0ce0bfSmrg func_quote_arg pretty "$flag" 75070b0ce0bfSmrg func_append arg " $wl$func_quote_arg_result" 75080b0ce0bfSmrg func_append compiler_flags " $wl$func_quote_arg_result" 75090b0ce0bfSmrg func_append linker_flags " $func_quote_arg_result" 75101b12faf6Smrg done 75110b0ce0bfSmrg IFS=$save_ifs 75121b12faf6Smrg func_stripname ' ' '' "$arg" 75131b12faf6Smrg arg=$func_stripname_result 75141b12faf6Smrg ;; 751532b578d3Smrg 75160b0ce0bfSmrg -Xassembler) 75170b0ce0bfSmrg prev=xassembler 75180b0ce0bfSmrg continue 75190b0ce0bfSmrg ;; 75200b0ce0bfSmrg 75211b12faf6Smrg -Xcompiler) 75221b12faf6Smrg prev=xcompiler 75231b12faf6Smrg continue 75241b12faf6Smrg ;; 752532b578d3Smrg 75261b12faf6Smrg -Xlinker) 75271b12faf6Smrg prev=xlinker 75281b12faf6Smrg continue 75291b12faf6Smrg ;; 753032b578d3Smrg 75311b12faf6Smrg -XCClinker) 75321b12faf6Smrg prev=xcclinker 75331b12faf6Smrg continue 75341b12faf6Smrg ;; 753532b578d3Smrg 75361b12faf6Smrg # -msg_* for osf cc 75371b12faf6Smrg -msg_*) 75380b0ce0bfSmrg func_quote_arg pretty "$arg" 75390b0ce0bfSmrg arg=$func_quote_arg_result 75401b12faf6Smrg ;; 754132b578d3Smrg 7542e35d4d8eSmrg # Flags to be passed through unchanged, with rationale: 7543e35d4d8eSmrg # -64, -mips[0-9] enable 64-bit mode for the SGI compiler 7544e35d4d8eSmrg # -r[0-9][0-9]* specify processor for the SGI compiler 7545e35d4d8eSmrg # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler 7546e35d4d8eSmrg # +DA*, +DD* enable 64-bit mode for the HP compiler 7547e35d4d8eSmrg # -q* compiler args for the IBM compiler 7548e35d4d8eSmrg # -m*, -t[45]*, -txscale* architecture-specific flags for GCC 7549e35d4d8eSmrg # -F/path path to uninstalled frameworks, gcc on darwin 7550e35d4d8eSmrg # -p, -pg, --coverage, -fprofile-* profiling flags for GCC 75510b0ce0bfSmrg # -fstack-protector* stack protector flags for GCC 7552e35d4d8eSmrg # @file GCC response files 7553e35d4d8eSmrg # -tp=* Portland pgcc target processor selection 7554e35d4d8eSmrg # --sysroot=* for sysroot support 75550b0ce0bfSmrg # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization 75560b0ce0bfSmrg # -specs=* GCC specs files 75570b0ce0bfSmrg # -stdlib=* select c++ std lib with clang 75580b0ce0bfSmrg # -fsanitize=* Clang/GCC memory and address sanitizer 75590b0ce0bfSmrg # -fuse-ld=* Linker select flags for GCC 75600b0ce0bfSmrg # -Wa,* Pass flags directly to the assembler 75611b12faf6Smrg -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ 7562e35d4d8eSmrg -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ 75630b0ce0bfSmrg -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*| \ 75640b0ce0bfSmrg -specs=*|-fsanitize=*|-fuse-ld=*|-Wa,*) 75650b0ce0bfSmrg func_quote_arg pretty "$arg" 75660b0ce0bfSmrg arg=$func_quote_arg_result 75671b12faf6Smrg func_append compile_command " $arg" 75681b12faf6Smrg func_append finalize_command " $arg" 7569e35d4d8eSmrg func_append compiler_flags " $arg" 75701b12faf6Smrg continue 75711b12faf6Smrg ;; 757232b578d3Smrg 75730b0ce0bfSmrg -Z*) 75740b0ce0bfSmrg if test os2 = "`expr $host : '.*\(os2\)'`"; then 75750b0ce0bfSmrg # OS/2 uses -Zxxx to specify OS/2-specific options 75760b0ce0bfSmrg compiler_flags="$compiler_flags $arg" 75770b0ce0bfSmrg func_append compile_command " $arg" 75780b0ce0bfSmrg func_append finalize_command " $arg" 75790b0ce0bfSmrg case $arg in 75800b0ce0bfSmrg -Zlinker | -Zstack) 75810b0ce0bfSmrg prev=xcompiler 75820b0ce0bfSmrg ;; 75830b0ce0bfSmrg esac 75840b0ce0bfSmrg continue 75850b0ce0bfSmrg else 75860b0ce0bfSmrg # Otherwise treat like 'Some other compiler flag' below 75870b0ce0bfSmrg func_quote_arg pretty "$arg" 75880b0ce0bfSmrg arg=$func_quote_arg_result 75890b0ce0bfSmrg fi 75900b0ce0bfSmrg ;; 75910b0ce0bfSmrg 75921b12faf6Smrg # Some other compiler flag. 75931b12faf6Smrg -* | +*) 75940b0ce0bfSmrg func_quote_arg pretty "$arg" 75950b0ce0bfSmrg arg=$func_quote_arg_result 75961b12faf6Smrg ;; 759732b578d3Smrg 75981b12faf6Smrg *.$objext) 75991b12faf6Smrg # A standard object. 7600e35d4d8eSmrg func_append objs " $arg" 76011b12faf6Smrg ;; 760232b578d3Smrg 76031b12faf6Smrg *.lo) 76041b12faf6Smrg # A libtool-controlled object. 760532b578d3Smrg 76061b12faf6Smrg # Check to see that this really is a libtool object. 76071b12faf6Smrg if func_lalib_unsafe_p "$arg"; then 76081b12faf6Smrg pic_object= 76091b12faf6Smrg non_pic_object= 761032b578d3Smrg 76111b12faf6Smrg # Read the .lo file 76121b12faf6Smrg func_source "$arg" 761332b578d3Smrg 76141b12faf6Smrg if test -z "$pic_object" || 76151b12faf6Smrg test -z "$non_pic_object" || 76160b0ce0bfSmrg test none = "$pic_object" && 76170b0ce0bfSmrg test none = "$non_pic_object"; then 76180b0ce0bfSmrg func_fatal_error "cannot find name of object for '$arg'" 76191b12faf6Smrg fi 762032b578d3Smrg 76211b12faf6Smrg # Extract subdirectory from the argument. 76221b12faf6Smrg func_dirname "$arg" "/" "" 76230b0ce0bfSmrg xdir=$func_dirname_result 762432b578d3Smrg 76250b0ce0bfSmrg test none = "$pic_object" || { 76261b12faf6Smrg # Prepend the subdirectory the object is found in. 76270b0ce0bfSmrg pic_object=$xdir$pic_object 762832b578d3Smrg 76290b0ce0bfSmrg if test dlfiles = "$prev"; then 76300b0ce0bfSmrg if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 7631e35d4d8eSmrg func_append dlfiles " $pic_object" 76321b12faf6Smrg prev= 76331b12faf6Smrg continue 76341b12faf6Smrg else 76351b12faf6Smrg # If libtool objects are unsupported, then we need to preload. 76361b12faf6Smrg prev=dlprefiles 76371b12faf6Smrg fi 76381b12faf6Smrg fi 763932b578d3Smrg 76401b12faf6Smrg # CHECK ME: I think I busted this. -Ossama 76410b0ce0bfSmrg if test dlprefiles = "$prev"; then 76421b12faf6Smrg # Preload the old-style object. 7643e35d4d8eSmrg func_append dlprefiles " $pic_object" 76441b12faf6Smrg prev= 76451b12faf6Smrg fi 764632b578d3Smrg 76471b12faf6Smrg # A PIC object. 76481b12faf6Smrg func_append libobjs " $pic_object" 76490b0ce0bfSmrg arg=$pic_object 76500b0ce0bfSmrg } 765132b578d3Smrg 76521b12faf6Smrg # Non-PIC object. 76530b0ce0bfSmrg if test none != "$non_pic_object"; then 76541b12faf6Smrg # Prepend the subdirectory the object is found in. 76550b0ce0bfSmrg non_pic_object=$xdir$non_pic_object 765632b578d3Smrg 76571b12faf6Smrg # A standard non-PIC object 76581b12faf6Smrg func_append non_pic_objects " $non_pic_object" 76590b0ce0bfSmrg if test -z "$pic_object" || test none = "$pic_object"; then 76600b0ce0bfSmrg arg=$non_pic_object 76611b12faf6Smrg fi 76621b12faf6Smrg else 76631b12faf6Smrg # If the PIC object exists, use it instead. 76641b12faf6Smrg # $xdir was prepended to $pic_object above. 76650b0ce0bfSmrg non_pic_object=$pic_object 76661b12faf6Smrg func_append non_pic_objects " $non_pic_object" 76671b12faf6Smrg fi 76681b12faf6Smrg else 76691b12faf6Smrg # Only an error if not doing a dry-run. 76701b12faf6Smrg if $opt_dry_run; then 76711b12faf6Smrg # Extract subdirectory from the argument. 76721b12faf6Smrg func_dirname "$arg" "/" "" 76730b0ce0bfSmrg xdir=$func_dirname_result 76741b12faf6Smrg 76751b12faf6Smrg func_lo2o "$arg" 76761b12faf6Smrg pic_object=$xdir$objdir/$func_lo2o_result 76771b12faf6Smrg non_pic_object=$xdir$func_lo2o_result 76781b12faf6Smrg func_append libobjs " $pic_object" 76791b12faf6Smrg func_append non_pic_objects " $non_pic_object" 76801b12faf6Smrg else 76810b0ce0bfSmrg func_fatal_error "'$arg' is not a valid libtool object" 76821b12faf6Smrg fi 76831b12faf6Smrg fi 76841b12faf6Smrg ;; 768532b578d3Smrg 76861b12faf6Smrg *.$libext) 76871b12faf6Smrg # An archive. 7688e35d4d8eSmrg func_append deplibs " $arg" 7689e35d4d8eSmrg func_append old_deplibs " $arg" 76901b12faf6Smrg continue 76911b12faf6Smrg ;; 76922a51b5beSmrg 76931b12faf6Smrg *.la) 76941b12faf6Smrg # A libtool-controlled library. 769532b578d3Smrg 7696e35d4d8eSmrg func_resolve_sysroot "$arg" 76970b0ce0bfSmrg if test dlfiles = "$prev"; then 76981b12faf6Smrg # This library was specified with -dlopen. 7699e35d4d8eSmrg func_append dlfiles " $func_resolve_sysroot_result" 77001b12faf6Smrg prev= 77010b0ce0bfSmrg elif test dlprefiles = "$prev"; then 77021b12faf6Smrg # The library was specified with -dlpreopen. 7703e35d4d8eSmrg func_append dlprefiles " $func_resolve_sysroot_result" 77041b12faf6Smrg prev= 77051b12faf6Smrg else 7706e35d4d8eSmrg func_append deplibs " $func_resolve_sysroot_result" 77071b12faf6Smrg fi 77081b12faf6Smrg continue 77091b12faf6Smrg ;; 771032b578d3Smrg 77111b12faf6Smrg # Some other compiler argument. 77121b12faf6Smrg *) 77131b12faf6Smrg # Unknown arguments in both finalize_command and compile_command need 77141b12faf6Smrg # to be aesthetically quoted because they are evaled later. 77150b0ce0bfSmrg func_quote_arg pretty "$arg" 77160b0ce0bfSmrg arg=$func_quote_arg_result 77171b12faf6Smrg ;; 77181b12faf6Smrg esac # arg 771932b578d3Smrg 77201b12faf6Smrg # Now actually substitute the argument into the commands. 77211b12faf6Smrg if test -n "$arg"; then 77221b12faf6Smrg func_append compile_command " $arg" 77231b12faf6Smrg func_append finalize_command " $arg" 77241b12faf6Smrg fi 77251b12faf6Smrg done # argument parsing loop 772632b578d3Smrg 77271b12faf6Smrg test -n "$prev" && \ 77280b0ce0bfSmrg func_fatal_help "the '$prevarg' option requires an argument" 772932b578d3Smrg 77300b0ce0bfSmrg if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then 77311b12faf6Smrg eval arg=\"$export_dynamic_flag_spec\" 77321b12faf6Smrg func_append compile_command " $arg" 77331b12faf6Smrg func_append finalize_command " $arg" 773432b578d3Smrg fi 773532b578d3Smrg 77361b12faf6Smrg oldlibs= 77371b12faf6Smrg # calculate the name of the file, without its directory 77381b12faf6Smrg func_basename "$output" 77390b0ce0bfSmrg outputname=$func_basename_result 77400b0ce0bfSmrg libobjs_save=$libobjs 77411b12faf6Smrg 77421b12faf6Smrg if test -n "$shlibpath_var"; then 77431b12faf6Smrg # get the directories listed in $shlibpath_var 77440b0ce0bfSmrg eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\` 77451b12faf6Smrg else 77461b12faf6Smrg shlib_search_path= 77471b12faf6Smrg fi 77481b12faf6Smrg eval sys_lib_search_path=\"$sys_lib_search_path_spec\" 77491b12faf6Smrg eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" 77501b12faf6Smrg 77510b0ce0bfSmrg # Definition is injected by LT_CONFIG during libtool generation. 77520b0ce0bfSmrg func_munge_path_list sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH" 77530b0ce0bfSmrg 77541b12faf6Smrg func_dirname "$output" "/" "" 77550b0ce0bfSmrg output_objdir=$func_dirname_result$objdir 7756e35d4d8eSmrg func_to_tool_file "$output_objdir/" 7757e35d4d8eSmrg tool_output_objdir=$func_to_tool_file_result 77581b12faf6Smrg # Create the object directory. 77591b12faf6Smrg func_mkdir_p "$output_objdir" 77601b12faf6Smrg 77611b12faf6Smrg # Determine the type of output 77621b12faf6Smrg case $output in 77631b12faf6Smrg "") 77641b12faf6Smrg func_fatal_help "you must specify an output file" 77651b12faf6Smrg ;; 77661b12faf6Smrg *.$libext) linkmode=oldlib ;; 77671b12faf6Smrg *.lo | *.$objext) linkmode=obj ;; 77681b12faf6Smrg *.la) linkmode=lib ;; 77691b12faf6Smrg *) linkmode=prog ;; # Anything else should be a program. 77701b12faf6Smrg esac 77711b12faf6Smrg 77721b12faf6Smrg specialdeplibs= 77731b12faf6Smrg 77741b12faf6Smrg libs= 77751b12faf6Smrg # Find all interdependent deplibs by searching for libraries 77761b12faf6Smrg # that are linked more than once (e.g. -la -lb -la) 77771b12faf6Smrg for deplib in $deplibs; do 77780b0ce0bfSmrg if $opt_preserve_dup_deps; then 77791b12faf6Smrg case "$libs " in 7780e35d4d8eSmrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 77811b12faf6Smrg esac 77821b12faf6Smrg fi 7783e35d4d8eSmrg func_append libs " $deplib" 77841b12faf6Smrg done 77851b12faf6Smrg 77860b0ce0bfSmrg if test lib = "$linkmode"; then 77871b12faf6Smrg libs="$predeps $libs $compiler_lib_search_path $postdeps" 77881b12faf6Smrg 77891b12faf6Smrg # Compute libraries that are listed more than once in $predeps 77901b12faf6Smrg # $postdeps and mark them as special (i.e., whose duplicates are 77911b12faf6Smrg # not to be eliminated). 77921b12faf6Smrg pre_post_deps= 77931b12faf6Smrg if $opt_duplicate_compiler_generated_deps; then 77941b12faf6Smrg for pre_post_dep in $predeps $postdeps; do 77951b12faf6Smrg case "$pre_post_deps " in 7796e35d4d8eSmrg *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; 77971b12faf6Smrg esac 7798e35d4d8eSmrg func_append pre_post_deps " $pre_post_dep" 77991b12faf6Smrg done 78001b12faf6Smrg fi 78011b12faf6Smrg pre_post_deps= 78021b12faf6Smrg fi 78031b12faf6Smrg 78041b12faf6Smrg deplibs= 78051b12faf6Smrg newdependency_libs= 78061b12faf6Smrg newlib_search_path= 78071b12faf6Smrg need_relink=no # whether we're linking any uninstalled libtool libraries 78081b12faf6Smrg notinst_deplibs= # not-installed libtool libraries 78091b12faf6Smrg notinst_path= # paths that contain not-installed libtool libraries 78101b12faf6Smrg 78111b12faf6Smrg case $linkmode in 78121b12faf6Smrg lib) 78131b12faf6Smrg passes="conv dlpreopen link" 78141b12faf6Smrg for file in $dlfiles $dlprefiles; do 78151b12faf6Smrg case $file in 78161b12faf6Smrg *.la) ;; 78171b12faf6Smrg *) 78180b0ce0bfSmrg func_fatal_help "libraries can '-dlopen' only libtool libraries: $file" 78191b12faf6Smrg ;; 78201b12faf6Smrg esac 78211b12faf6Smrg done 78221b12faf6Smrg ;; 78231b12faf6Smrg prog) 78241b12faf6Smrg compile_deplibs= 78251b12faf6Smrg finalize_deplibs= 78260b0ce0bfSmrg alldeplibs=false 78271b12faf6Smrg newdlfiles= 78281b12faf6Smrg newdlprefiles= 78291b12faf6Smrg passes="conv scan dlopen dlpreopen link" 78301b12faf6Smrg ;; 78311b12faf6Smrg *) passes="conv" 78321b12faf6Smrg ;; 78331b12faf6Smrg esac 78341b12faf6Smrg 78351b12faf6Smrg for pass in $passes; do 78361b12faf6Smrg # The preopen pass in lib mode reverses $deplibs; put it back here 78371b12faf6Smrg # so that -L comes before libs that need it for instance... 78380b0ce0bfSmrg if test lib,link = "$linkmode,$pass"; then 78391b12faf6Smrg ## FIXME: Find the place where the list is rebuilt in the wrong 78401b12faf6Smrg ## order, and fix it there properly 78411b12faf6Smrg tmp_deplibs= 78421b12faf6Smrg for deplib in $deplibs; do 78431b12faf6Smrg tmp_deplibs="$deplib $tmp_deplibs" 78441b12faf6Smrg done 78450b0ce0bfSmrg deplibs=$tmp_deplibs 78461b12faf6Smrg fi 78471b12faf6Smrg 78480b0ce0bfSmrg if test lib,link = "$linkmode,$pass" || 78490b0ce0bfSmrg test prog,scan = "$linkmode,$pass"; then 78500b0ce0bfSmrg libs=$deplibs 78511b12faf6Smrg deplibs= 78521b12faf6Smrg fi 78530b0ce0bfSmrg if test prog = "$linkmode"; then 78541b12faf6Smrg case $pass in 78550b0ce0bfSmrg dlopen) libs=$dlfiles ;; 78560b0ce0bfSmrg dlpreopen) libs=$dlprefiles ;; 7857e35d4d8eSmrg link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; 78581b12faf6Smrg esac 78591b12faf6Smrg fi 78600b0ce0bfSmrg if test lib,dlpreopen = "$linkmode,$pass"; then 78611b12faf6Smrg # Collect and forward deplibs of preopened libtool libs 78621b12faf6Smrg for lib in $dlprefiles; do 78631b12faf6Smrg # Ignore non-libtool-libs 78641b12faf6Smrg dependency_libs= 7865e35d4d8eSmrg func_resolve_sysroot "$lib" 78661b12faf6Smrg case $lib in 7867e35d4d8eSmrg *.la) func_source "$func_resolve_sysroot_result" ;; 78681b12faf6Smrg esac 78691b12faf6Smrg 78701b12faf6Smrg # Collect preopened libtool deplibs, except any this library 78711b12faf6Smrg # has declared as weak libs 78721b12faf6Smrg for deplib in $dependency_libs; do 7873e35d4d8eSmrg func_basename "$deplib" 7874e35d4d8eSmrg deplib_base=$func_basename_result 78751b12faf6Smrg case " $weak_libs " in 78761b12faf6Smrg *" $deplib_base "*) ;; 7877e35d4d8eSmrg *) func_append deplibs " $deplib" ;; 78781b12faf6Smrg esac 78791b12faf6Smrg done 78801b12faf6Smrg done 78810b0ce0bfSmrg libs=$dlprefiles 78821b12faf6Smrg fi 78830b0ce0bfSmrg if test dlopen = "$pass"; then 78841b12faf6Smrg # Collect dlpreopened libraries 78850b0ce0bfSmrg save_deplibs=$deplibs 78861b12faf6Smrg deplibs= 78871b12faf6Smrg fi 78881b12faf6Smrg 78891b12faf6Smrg for deplib in $libs; do 78901b12faf6Smrg lib= 78910b0ce0bfSmrg found=false 78921b12faf6Smrg case $deplib in 7893e35d4d8eSmrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 7894e35d4d8eSmrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 78950b0ce0bfSmrg if test prog,link = "$linkmode,$pass"; then 78961b12faf6Smrg compile_deplibs="$deplib $compile_deplibs" 78971b12faf6Smrg finalize_deplibs="$deplib $finalize_deplibs" 78981b12faf6Smrg else 7899e35d4d8eSmrg func_append compiler_flags " $deplib" 79000b0ce0bfSmrg if test lib = "$linkmode"; then 79011b12faf6Smrg case "$new_inherited_linker_flags " in 79021b12faf6Smrg *" $deplib "*) ;; 7903e35d4d8eSmrg * ) func_append new_inherited_linker_flags " $deplib" ;; 79041b12faf6Smrg esac 79051b12faf6Smrg fi 79061b12faf6Smrg fi 79071b12faf6Smrg continue 79081b12faf6Smrg ;; 79091b12faf6Smrg -l*) 79100b0ce0bfSmrg if test lib != "$linkmode" && test prog != "$linkmode"; then 79110b0ce0bfSmrg func_warning "'-l' is ignored for archives/objects" 79121b12faf6Smrg continue 79131b12faf6Smrg fi 79141b12faf6Smrg func_stripname '-l' '' "$deplib" 79151b12faf6Smrg name=$func_stripname_result 79160b0ce0bfSmrg if test lib = "$linkmode"; then 79171b12faf6Smrg searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" 79181b12faf6Smrg else 79191b12faf6Smrg searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" 79201b12faf6Smrg fi 79211b12faf6Smrg for searchdir in $searchdirs; do 79221b12faf6Smrg for search_ext in .la $std_shrext .so .a; do 79231b12faf6Smrg # Search the libtool library 79240b0ce0bfSmrg lib=$searchdir/lib$name$search_ext 79251b12faf6Smrg if test -f "$lib"; then 79260b0ce0bfSmrg if test .la = "$search_ext"; then 79270b0ce0bfSmrg found=: 79281b12faf6Smrg else 79290b0ce0bfSmrg found=false 79301b12faf6Smrg fi 79311b12faf6Smrg break 2 79321b12faf6Smrg fi 79331b12faf6Smrg done 79341b12faf6Smrg done 79350b0ce0bfSmrg if $found; then 79360b0ce0bfSmrg # deplib is a libtool library 79371b12faf6Smrg # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, 79381b12faf6Smrg # We need to do some special things here, and not later. 79390b0ce0bfSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 79401b12faf6Smrg case " $predeps $postdeps " in 79411b12faf6Smrg *" $deplib "*) 79421b12faf6Smrg if func_lalib_p "$lib"; then 79431b12faf6Smrg library_names= 79441b12faf6Smrg old_library= 79451b12faf6Smrg func_source "$lib" 79461b12faf6Smrg for l in $old_library $library_names; do 79470b0ce0bfSmrg ll=$l 79481b12faf6Smrg done 79490b0ce0bfSmrg if test "X$ll" = "X$old_library"; then # only static version available 79500b0ce0bfSmrg found=false 79511b12faf6Smrg func_dirname "$lib" "" "." 79520b0ce0bfSmrg ladir=$func_dirname_result 79531b12faf6Smrg lib=$ladir/$old_library 79540b0ce0bfSmrg if test prog,link = "$linkmode,$pass"; then 79551b12faf6Smrg compile_deplibs="$deplib $compile_deplibs" 79561b12faf6Smrg finalize_deplibs="$deplib $finalize_deplibs" 79571b12faf6Smrg else 79581b12faf6Smrg deplibs="$deplib $deplibs" 79590b0ce0bfSmrg test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 79601b12faf6Smrg fi 79611b12faf6Smrg continue 79621b12faf6Smrg fi 79631b12faf6Smrg fi 79641b12faf6Smrg ;; 79651b12faf6Smrg *) ;; 79661b12faf6Smrg esac 79671b12faf6Smrg fi 79680b0ce0bfSmrg else 79690b0ce0bfSmrg # deplib doesn't seem to be a libtool library 79700b0ce0bfSmrg if test prog,link = "$linkmode,$pass"; then 79710b0ce0bfSmrg compile_deplibs="$deplib $compile_deplibs" 79720b0ce0bfSmrg finalize_deplibs="$deplib $finalize_deplibs" 79730b0ce0bfSmrg else 79740b0ce0bfSmrg deplibs="$deplib $deplibs" 79750b0ce0bfSmrg test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 79760b0ce0bfSmrg fi 79770b0ce0bfSmrg continue 79781b12faf6Smrg fi 79791b12faf6Smrg ;; # -l 79801b12faf6Smrg *.ltframework) 79810b0ce0bfSmrg if test prog,link = "$linkmode,$pass"; then 79821b12faf6Smrg compile_deplibs="$deplib $compile_deplibs" 79831b12faf6Smrg finalize_deplibs="$deplib $finalize_deplibs" 79841b12faf6Smrg else 79851b12faf6Smrg deplibs="$deplib $deplibs" 79860b0ce0bfSmrg if test lib = "$linkmode"; then 79871b12faf6Smrg case "$new_inherited_linker_flags " in 79881b12faf6Smrg *" $deplib "*) ;; 7989e35d4d8eSmrg * ) func_append new_inherited_linker_flags " $deplib" ;; 79901b12faf6Smrg esac 79911b12faf6Smrg fi 79921b12faf6Smrg fi 79931b12faf6Smrg continue 79941b12faf6Smrg ;; 79951b12faf6Smrg -L*) 79961b12faf6Smrg case $linkmode in 79971b12faf6Smrg lib) 79981b12faf6Smrg deplibs="$deplib $deplibs" 79990b0ce0bfSmrg test conv = "$pass" && continue 80001b12faf6Smrg newdependency_libs="$deplib $newdependency_libs" 80011b12faf6Smrg func_stripname '-L' '' "$deplib" 8002e35d4d8eSmrg func_resolve_sysroot "$func_stripname_result" 8003e35d4d8eSmrg func_append newlib_search_path " $func_resolve_sysroot_result" 80041b12faf6Smrg ;; 80051b12faf6Smrg prog) 80060b0ce0bfSmrg if test conv = "$pass"; then 80071b12faf6Smrg deplibs="$deplib $deplibs" 80081b12faf6Smrg continue 80091b12faf6Smrg fi 80100b0ce0bfSmrg if test scan = "$pass"; then 80111b12faf6Smrg deplibs="$deplib $deplibs" 80121b12faf6Smrg else 80131b12faf6Smrg compile_deplibs="$deplib $compile_deplibs" 80141b12faf6Smrg finalize_deplibs="$deplib $finalize_deplibs" 80151b12faf6Smrg fi 80161b12faf6Smrg func_stripname '-L' '' "$deplib" 8017e35d4d8eSmrg func_resolve_sysroot "$func_stripname_result" 8018e35d4d8eSmrg func_append newlib_search_path " $func_resolve_sysroot_result" 80191b12faf6Smrg ;; 80201b12faf6Smrg *) 80210b0ce0bfSmrg func_warning "'-L' is ignored for archives/objects" 80221b12faf6Smrg ;; 80231b12faf6Smrg esac # linkmode 80241b12faf6Smrg continue 80251b12faf6Smrg ;; # -L 80261b12faf6Smrg -R*) 80270b0ce0bfSmrg if test link = "$pass"; then 80281b12faf6Smrg func_stripname '-R' '' "$deplib" 8029e35d4d8eSmrg func_resolve_sysroot "$func_stripname_result" 8030e35d4d8eSmrg dir=$func_resolve_sysroot_result 80311b12faf6Smrg # Make sure the xrpath contains only unique directories. 80321b12faf6Smrg case "$xrpath " in 80331b12faf6Smrg *" $dir "*) ;; 8034e35d4d8eSmrg *) func_append xrpath " $dir" ;; 80351b12faf6Smrg esac 80361b12faf6Smrg fi 80371b12faf6Smrg deplibs="$deplib $deplibs" 80381b12faf6Smrg continue 80391b12faf6Smrg ;; 8040e35d4d8eSmrg *.la) 8041e35d4d8eSmrg func_resolve_sysroot "$deplib" 8042e35d4d8eSmrg lib=$func_resolve_sysroot_result 8043e35d4d8eSmrg ;; 80441b12faf6Smrg *.$libext) 80450b0ce0bfSmrg if test conv = "$pass"; then 80461b12faf6Smrg deplibs="$deplib $deplibs" 80471b12faf6Smrg continue 80481b12faf6Smrg fi 80491b12faf6Smrg case $linkmode in 80501b12faf6Smrg lib) 80511b12faf6Smrg # Linking convenience modules into shared libraries is allowed, 80521b12faf6Smrg # but linking other static libraries is non-portable. 80531b12faf6Smrg case " $dlpreconveniencelibs " in 80541b12faf6Smrg *" $deplib "*) ;; 80551b12faf6Smrg *) 80560b0ce0bfSmrg valid_a_lib=false 80571b12faf6Smrg case $deplibs_check_method in 80581b12faf6Smrg match_pattern*) 80591b12faf6Smrg set dummy $deplibs_check_method; shift 80601b12faf6Smrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 8061e35d4d8eSmrg if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ 80621b12faf6Smrg | $EGREP "$match_pattern_regex" > /dev/null; then 80630b0ce0bfSmrg valid_a_lib=: 80641b12faf6Smrg fi 80651b12faf6Smrg ;; 80661b12faf6Smrg pass_all) 80670b0ce0bfSmrg valid_a_lib=: 80681b12faf6Smrg ;; 80691b12faf6Smrg esac 80700b0ce0bfSmrg if $valid_a_lib; then 80710b0ce0bfSmrg echo 80720b0ce0bfSmrg $ECHO "*** Warning: Linking the shared library $output against the" 80730b0ce0bfSmrg $ECHO "*** static library $deplib is not portable!" 80740b0ce0bfSmrg deplibs="$deplib $deplibs" 80750b0ce0bfSmrg else 8076e35d4d8eSmrg echo 80771b12faf6Smrg $ECHO "*** Warning: Trying to link with static lib archive $deplib." 8078e35d4d8eSmrg echo "*** I have the capability to make that library automatically link in when" 8079e35d4d8eSmrg echo "*** you link to this library. But I can only do this if you have a" 8080e35d4d8eSmrg echo "*** shared version of the library, which you do not appear to have" 8081e35d4d8eSmrg echo "*** because the file extensions .$libext of this argument makes me believe" 8082e35d4d8eSmrg echo "*** that it is just a static archive that I should not use here." 80831b12faf6Smrg fi 80841b12faf6Smrg ;; 80851b12faf6Smrg esac 80861b12faf6Smrg continue 80871b12faf6Smrg ;; 80881b12faf6Smrg prog) 80890b0ce0bfSmrg if test link != "$pass"; then 80901b12faf6Smrg deplibs="$deplib $deplibs" 80911b12faf6Smrg else 80921b12faf6Smrg compile_deplibs="$deplib $compile_deplibs" 80931b12faf6Smrg finalize_deplibs="$deplib $finalize_deplibs" 80941b12faf6Smrg fi 80951b12faf6Smrg continue 80961b12faf6Smrg ;; 80971b12faf6Smrg esac # linkmode 80981b12faf6Smrg ;; # *.$libext 80991b12faf6Smrg *.lo | *.$objext) 81000b0ce0bfSmrg if test conv = "$pass"; then 81011b12faf6Smrg deplibs="$deplib $deplibs" 81020b0ce0bfSmrg elif test prog = "$linkmode"; then 81030b0ce0bfSmrg if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then 81041b12faf6Smrg # If there is no dlopen support or we're linking statically, 81051b12faf6Smrg # we need to preload. 8106e35d4d8eSmrg func_append newdlprefiles " $deplib" 81071b12faf6Smrg compile_deplibs="$deplib $compile_deplibs" 81081b12faf6Smrg finalize_deplibs="$deplib $finalize_deplibs" 81091b12faf6Smrg else 8110e35d4d8eSmrg func_append newdlfiles " $deplib" 81111b12faf6Smrg fi 81121b12faf6Smrg fi 81131b12faf6Smrg continue 81141b12faf6Smrg ;; 81151b12faf6Smrg %DEPLIBS%) 81160b0ce0bfSmrg alldeplibs=: 81171b12faf6Smrg continue 81181b12faf6Smrg ;; 81191b12faf6Smrg esac # case $deplib 81201b12faf6Smrg 81210b0ce0bfSmrg $found || test -f "$lib" \ 81220b0ce0bfSmrg || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'" 81231b12faf6Smrg 81241b12faf6Smrg # Check to see that this really is a libtool archive. 81251b12faf6Smrg func_lalib_unsafe_p "$lib" \ 81260b0ce0bfSmrg || func_fatal_error "'$lib' is not a valid libtool archive" 81271b12faf6Smrg 81281b12faf6Smrg func_dirname "$lib" "" "." 81290b0ce0bfSmrg ladir=$func_dirname_result 81301b12faf6Smrg 81311b12faf6Smrg dlname= 81321b12faf6Smrg dlopen= 81331b12faf6Smrg dlpreopen= 81341b12faf6Smrg libdir= 81351b12faf6Smrg library_names= 81361b12faf6Smrg old_library= 81371b12faf6Smrg inherited_linker_flags= 81381b12faf6Smrg # If the library was installed with an old release of libtool, 81391b12faf6Smrg # it will not redefine variables installed, or shouldnotlink 81401b12faf6Smrg installed=yes 81411b12faf6Smrg shouldnotlink=no 81421b12faf6Smrg avoidtemprpath= 81431b12faf6Smrg 81441b12faf6Smrg 81451b12faf6Smrg # Read the .la file 81461b12faf6Smrg func_source "$lib" 81471b12faf6Smrg 81481b12faf6Smrg # Convert "-framework foo" to "foo.ltframework" 81491b12faf6Smrg if test -n "$inherited_linker_flags"; then 8150e35d4d8eSmrg tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` 81511b12faf6Smrg for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do 81521b12faf6Smrg case " $new_inherited_linker_flags " in 81531b12faf6Smrg *" $tmp_inherited_linker_flag "*) ;; 8154e35d4d8eSmrg *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; 81551b12faf6Smrg esac 81561b12faf6Smrg done 81571b12faf6Smrg fi 8158e35d4d8eSmrg dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 81590b0ce0bfSmrg if test lib,link = "$linkmode,$pass" || 81600b0ce0bfSmrg test prog,scan = "$linkmode,$pass" || 81610b0ce0bfSmrg { test prog != "$linkmode" && test lib != "$linkmode"; }; then 8162e35d4d8eSmrg test -n "$dlopen" && func_append dlfiles " $dlopen" 8163e35d4d8eSmrg test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" 81641b12faf6Smrg fi 81651b12faf6Smrg 81660b0ce0bfSmrg if test conv = "$pass"; then 81671b12faf6Smrg # Only check for convenience libraries 81681b12faf6Smrg deplibs="$lib $deplibs" 81691b12faf6Smrg if test -z "$libdir"; then 81701b12faf6Smrg if test -z "$old_library"; then 81710b0ce0bfSmrg func_fatal_error "cannot find name of link library for '$lib'" 81721b12faf6Smrg fi 81731b12faf6Smrg # It is a libtool convenience library, so add in its objects. 8174e35d4d8eSmrg func_append convenience " $ladir/$objdir/$old_library" 8175e35d4d8eSmrg func_append old_convenience " $ladir/$objdir/$old_library" 81760b0ce0bfSmrg elif test prog != "$linkmode" && test lib != "$linkmode"; then 81770b0ce0bfSmrg func_fatal_error "'$lib' is not a convenience library" 81781b12faf6Smrg fi 8179e35d4d8eSmrg tmp_libs= 8180e35d4d8eSmrg for deplib in $dependency_libs; do 8181e35d4d8eSmrg deplibs="$deplib $deplibs" 81820b0ce0bfSmrg if $opt_preserve_dup_deps; then 8183e35d4d8eSmrg case "$tmp_libs " in 8184e35d4d8eSmrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 8185e35d4d8eSmrg esac 8186e35d4d8eSmrg fi 8187e35d4d8eSmrg func_append tmp_libs " $deplib" 8188e35d4d8eSmrg done 81891b12faf6Smrg continue 81901b12faf6Smrg fi # $pass = conv 81911b12faf6Smrg 81921b12faf6Smrg 81931b12faf6Smrg # Get the name of the library we link against. 81941b12faf6Smrg linklib= 8195e35d4d8eSmrg if test -n "$old_library" && 81960b0ce0bfSmrg { test yes = "$prefer_static_libs" || 81970b0ce0bfSmrg test built,no = "$prefer_static_libs,$installed"; }; then 8198e35d4d8eSmrg linklib=$old_library 8199e35d4d8eSmrg else 8200e35d4d8eSmrg for l in $old_library $library_names; do 82010b0ce0bfSmrg linklib=$l 8202e35d4d8eSmrg done 8203e35d4d8eSmrg fi 82041b12faf6Smrg if test -z "$linklib"; then 82050b0ce0bfSmrg func_fatal_error "cannot find name of link library for '$lib'" 82061b12faf6Smrg fi 82071b12faf6Smrg 82081b12faf6Smrg # This library was specified with -dlopen. 82090b0ce0bfSmrg if test dlopen = "$pass"; then 82100b0ce0bfSmrg test -z "$libdir" \ 82110b0ce0bfSmrg && func_fatal_error "cannot -dlopen a convenience library: '$lib'" 82121b12faf6Smrg if test -z "$dlname" || 82130b0ce0bfSmrg test yes != "$dlopen_support" || 82140b0ce0bfSmrg test no = "$build_libtool_libs" 82150b0ce0bfSmrg then 82161b12faf6Smrg # If there is no dlname, no dlopen support or we're linking 82171b12faf6Smrg # statically, we need to preload. We also need to preload any 82181b12faf6Smrg # dependent libraries so libltdl's deplib preloader doesn't 82191b12faf6Smrg # bomb out in the load deplibs phase. 8220e35d4d8eSmrg func_append dlprefiles " $lib $dependency_libs" 82211b12faf6Smrg else 8222e35d4d8eSmrg func_append newdlfiles " $lib" 82231b12faf6Smrg fi 82241b12faf6Smrg continue 82251b12faf6Smrg fi # $pass = dlopen 82261b12faf6Smrg 82271b12faf6Smrg # We need an absolute path. 82281b12faf6Smrg case $ladir in 82290b0ce0bfSmrg [\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;; 82301b12faf6Smrg *) 82311b12faf6Smrg abs_ladir=`cd "$ladir" && pwd` 82321b12faf6Smrg if test -z "$abs_ladir"; then 82330b0ce0bfSmrg func_warning "cannot determine absolute directory name of '$ladir'" 82341b12faf6Smrg func_warning "passing it literally to the linker, although it might fail" 82350b0ce0bfSmrg abs_ladir=$ladir 82361b12faf6Smrg fi 82371b12faf6Smrg ;; 82381b12faf6Smrg esac 82391b12faf6Smrg func_basename "$lib" 82400b0ce0bfSmrg laname=$func_basename_result 82411b12faf6Smrg 82421b12faf6Smrg # Find the relevant object directory and library name. 82430b0ce0bfSmrg if test yes = "$installed"; then 8244e35d4d8eSmrg if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then 82450b0ce0bfSmrg func_warning "library '$lib' was moved." 82460b0ce0bfSmrg dir=$ladir 82470b0ce0bfSmrg absdir=$abs_ladir 82480b0ce0bfSmrg libdir=$abs_ladir 82491b12faf6Smrg else 82500b0ce0bfSmrg dir=$lt_sysroot$libdir 82510b0ce0bfSmrg absdir=$lt_sysroot$libdir 82521b12faf6Smrg fi 82530b0ce0bfSmrg test yes = "$hardcode_automatic" && avoidtemprpath=yes 82541b12faf6Smrg else 82551b12faf6Smrg if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then 82560b0ce0bfSmrg dir=$ladir 82570b0ce0bfSmrg absdir=$abs_ladir 82581b12faf6Smrg # Remove this search path later 8259e35d4d8eSmrg func_append notinst_path " $abs_ladir" 82601b12faf6Smrg else 82610b0ce0bfSmrg dir=$ladir/$objdir 82620b0ce0bfSmrg absdir=$abs_ladir/$objdir 82631b12faf6Smrg # Remove this search path later 8264e35d4d8eSmrg func_append notinst_path " $abs_ladir" 82651b12faf6Smrg fi 82661b12faf6Smrg fi # $installed = yes 82671b12faf6Smrg func_stripname 'lib' '.la' "$laname" 82681b12faf6Smrg name=$func_stripname_result 82691b12faf6Smrg 82701b12faf6Smrg # This library was specified with -dlpreopen. 82710b0ce0bfSmrg if test dlpreopen = "$pass"; then 82720b0ce0bfSmrg if test -z "$libdir" && test prog = "$linkmode"; then 82730b0ce0bfSmrg func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'" 82741b12faf6Smrg fi 82750b0ce0bfSmrg case $host in 8276e35d4d8eSmrg # special handling for platforms with PE-DLLs. 8277e35d4d8eSmrg *cygwin* | *mingw* | *cegcc* ) 8278e35d4d8eSmrg # Linker will automatically link against shared library if both 8279e35d4d8eSmrg # static and shared are present. Therefore, ensure we extract 8280e35d4d8eSmrg # symbols from the import library if a shared library is present 8281e35d4d8eSmrg # (otherwise, the dlopen module name will be incorrect). We do 8282e35d4d8eSmrg # this by putting the import library name into $newdlprefiles. 8283e35d4d8eSmrg # We recover the dlopen module name by 'saving' the la file 8284e35d4d8eSmrg # name in a special purpose variable, and (later) extracting the 8285e35d4d8eSmrg # dlname from the la file. 8286e35d4d8eSmrg if test -n "$dlname"; then 8287e35d4d8eSmrg func_tr_sh "$dir/$linklib" 8288e35d4d8eSmrg eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" 8289e35d4d8eSmrg func_append newdlprefiles " $dir/$linklib" 8290e35d4d8eSmrg else 8291e35d4d8eSmrg func_append newdlprefiles " $dir/$old_library" 8292e35d4d8eSmrg # Keep a list of preopened convenience libraries to check 8293e35d4d8eSmrg # that they are being used correctly in the link pass. 8294e35d4d8eSmrg test -z "$libdir" && \ 8295e35d4d8eSmrg func_append dlpreconveniencelibs " $dir/$old_library" 8296e35d4d8eSmrg fi 8297e35d4d8eSmrg ;; 8298e35d4d8eSmrg * ) 8299e35d4d8eSmrg # Prefer using a static library (so that no silly _DYNAMIC symbols 8300e35d4d8eSmrg # are required to link). 8301e35d4d8eSmrg if test -n "$old_library"; then 8302e35d4d8eSmrg func_append newdlprefiles " $dir/$old_library" 8303e35d4d8eSmrg # Keep a list of preopened convenience libraries to check 8304e35d4d8eSmrg # that they are being used correctly in the link pass. 8305e35d4d8eSmrg test -z "$libdir" && \ 8306e35d4d8eSmrg func_append dlpreconveniencelibs " $dir/$old_library" 8307e35d4d8eSmrg # Otherwise, use the dlname, so that lt_dlopen finds it. 8308e35d4d8eSmrg elif test -n "$dlname"; then 8309e35d4d8eSmrg func_append newdlprefiles " $dir/$dlname" 8310e35d4d8eSmrg else 8311e35d4d8eSmrg func_append newdlprefiles " $dir/$linklib" 8312e35d4d8eSmrg fi 8313e35d4d8eSmrg ;; 8314e35d4d8eSmrg esac 83151b12faf6Smrg fi # $pass = dlpreopen 83161b12faf6Smrg 83171b12faf6Smrg if test -z "$libdir"; then 83181b12faf6Smrg # Link the convenience library 83190b0ce0bfSmrg if test lib = "$linkmode"; then 83201b12faf6Smrg deplibs="$dir/$old_library $deplibs" 83210b0ce0bfSmrg elif test prog,link = "$linkmode,$pass"; then 83221b12faf6Smrg compile_deplibs="$dir/$old_library $compile_deplibs" 83231b12faf6Smrg finalize_deplibs="$dir/$old_library $finalize_deplibs" 83241b12faf6Smrg else 83251b12faf6Smrg deplibs="$lib $deplibs" # used for prog,scan pass 83261b12faf6Smrg fi 83271b12faf6Smrg continue 83281b12faf6Smrg fi 83291b12faf6Smrg 83301b12faf6Smrg 83310b0ce0bfSmrg if test prog = "$linkmode" && test link != "$pass"; then 8332e35d4d8eSmrg func_append newlib_search_path " $ladir" 83331b12faf6Smrg deplibs="$lib $deplibs" 83341b12faf6Smrg 83350b0ce0bfSmrg linkalldeplibs=false 83360b0ce0bfSmrg if test no != "$link_all_deplibs" || test -z "$library_names" || 83370b0ce0bfSmrg test no = "$build_libtool_libs"; then 83380b0ce0bfSmrg linkalldeplibs=: 83391b12faf6Smrg fi 83401b12faf6Smrg 83411b12faf6Smrg tmp_libs= 83421b12faf6Smrg for deplib in $dependency_libs; do 83431b12faf6Smrg case $deplib in 83441b12faf6Smrg -L*) func_stripname '-L' '' "$deplib" 8345e35d4d8eSmrg func_resolve_sysroot "$func_stripname_result" 8346e35d4d8eSmrg func_append newlib_search_path " $func_resolve_sysroot_result" 83471b12faf6Smrg ;; 83481b12faf6Smrg esac 83491b12faf6Smrg # Need to link against all dependency_libs? 83500b0ce0bfSmrg if $linkalldeplibs; then 83511b12faf6Smrg deplibs="$deplib $deplibs" 83521b12faf6Smrg else 83531b12faf6Smrg # Need to hardcode shared library paths 83541b12faf6Smrg # or/and link against static libraries 83551b12faf6Smrg newdependency_libs="$deplib $newdependency_libs" 83561b12faf6Smrg fi 83570b0ce0bfSmrg if $opt_preserve_dup_deps; then 83581b12faf6Smrg case "$tmp_libs " in 8359e35d4d8eSmrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 83601b12faf6Smrg esac 83611b12faf6Smrg fi 8362e35d4d8eSmrg func_append tmp_libs " $deplib" 83631b12faf6Smrg done # for deplib 83641b12faf6Smrg continue 83651b12faf6Smrg fi # $linkmode = prog... 83661b12faf6Smrg 83670b0ce0bfSmrg if test prog,link = "$linkmode,$pass"; then 83681b12faf6Smrg if test -n "$library_names" && 83690b0ce0bfSmrg { { test no = "$prefer_static_libs" || 83700b0ce0bfSmrg test built,yes = "$prefer_static_libs,$installed"; } || 83711b12faf6Smrg test -z "$old_library"; }; then 83721b12faf6Smrg # We need to hardcode the library path 83730b0ce0bfSmrg if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then 83741b12faf6Smrg # Make sure the rpath contains only unique directories. 83750b0ce0bfSmrg case $temp_rpath: in 83761b12faf6Smrg *"$absdir:"*) ;; 8377e35d4d8eSmrg *) func_append temp_rpath "$absdir:" ;; 83781b12faf6Smrg esac 83791b12faf6Smrg fi 83801b12faf6Smrg 83811b12faf6Smrg # Hardcode the library path. 83821b12faf6Smrg # Skip directories that are in the system default run-time 83831b12faf6Smrg # search path. 83841b12faf6Smrg case " $sys_lib_dlsearch_path " in 83851b12faf6Smrg *" $absdir "*) ;; 83861b12faf6Smrg *) 83871b12faf6Smrg case "$compile_rpath " in 83881b12faf6Smrg *" $absdir "*) ;; 8389e35d4d8eSmrg *) func_append compile_rpath " $absdir" ;; 83901b12faf6Smrg esac 83911b12faf6Smrg ;; 83921b12faf6Smrg esac 83931b12faf6Smrg case " $sys_lib_dlsearch_path " in 83941b12faf6Smrg *" $libdir "*) ;; 83951b12faf6Smrg *) 83961b12faf6Smrg case "$finalize_rpath " in 83971b12faf6Smrg *" $libdir "*) ;; 8398e35d4d8eSmrg *) func_append finalize_rpath " $libdir" ;; 83991b12faf6Smrg esac 84001b12faf6Smrg ;; 84011b12faf6Smrg esac 84021b12faf6Smrg fi # $linkmode,$pass = prog,link... 84031b12faf6Smrg 84040b0ce0bfSmrg if $alldeplibs && 84050b0ce0bfSmrg { test pass_all = "$deplibs_check_method" || 84060b0ce0bfSmrg { test yes = "$build_libtool_libs" && 84071b12faf6Smrg test -n "$library_names"; }; }; then 84081b12faf6Smrg # We only need to search for static libraries 84091b12faf6Smrg continue 84101b12faf6Smrg fi 84111b12faf6Smrg fi 84121b12faf6Smrg 84131b12faf6Smrg link_static=no # Whether the deplib will be linked statically 84141b12faf6Smrg use_static_libs=$prefer_static_libs 84150b0ce0bfSmrg if test built = "$use_static_libs" && test yes = "$installed"; then 84161b12faf6Smrg use_static_libs=no 84171b12faf6Smrg fi 84181b12faf6Smrg if test -n "$library_names" && 84190b0ce0bfSmrg { test no = "$use_static_libs" || test -z "$old_library"; }; then 84201b12faf6Smrg case $host in 84210b0ce0bfSmrg *cygwin* | *mingw* | *cegcc* | *os2*) 84221b12faf6Smrg # No point in relinking DLLs because paths are not encoded 8423e35d4d8eSmrg func_append notinst_deplibs " $lib" 84241b12faf6Smrg need_relink=no 84251b12faf6Smrg ;; 84261b12faf6Smrg *) 84270b0ce0bfSmrg if test no = "$installed"; then 8428e35d4d8eSmrg func_append notinst_deplibs " $lib" 84291b12faf6Smrg need_relink=yes 84301b12faf6Smrg fi 84311b12faf6Smrg ;; 84321b12faf6Smrg esac 84331b12faf6Smrg # This is a shared library 84341b12faf6Smrg 84351b12faf6Smrg # Warn about portability, can't link against -module's on some 84361b12faf6Smrg # systems (darwin). Don't bleat about dlopened modules though! 84370b0ce0bfSmrg dlopenmodule= 84381b12faf6Smrg for dlpremoduletest in $dlprefiles; do 84391b12faf6Smrg if test "X$dlpremoduletest" = "X$lib"; then 84400b0ce0bfSmrg dlopenmodule=$dlpremoduletest 84411b12faf6Smrg break 84421b12faf6Smrg fi 84431b12faf6Smrg done 84440b0ce0bfSmrg if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then 8445e35d4d8eSmrg echo 84460b0ce0bfSmrg if test prog = "$linkmode"; then 84471b12faf6Smrg $ECHO "*** Warning: Linking the executable $output against the loadable module" 84481b12faf6Smrg else 84491b12faf6Smrg $ECHO "*** Warning: Linking the shared library $output against the loadable module" 84501b12faf6Smrg fi 84511b12faf6Smrg $ECHO "*** $linklib is not portable!" 84521b12faf6Smrg fi 84530b0ce0bfSmrg if test lib = "$linkmode" && 84540b0ce0bfSmrg test yes = "$hardcode_into_libs"; then 84551b12faf6Smrg # Hardcode the library path. 84561b12faf6Smrg # Skip directories that are in the system default run-time 84571b12faf6Smrg # search path. 84581b12faf6Smrg case " $sys_lib_dlsearch_path " in 84591b12faf6Smrg *" $absdir "*) ;; 84601b12faf6Smrg *) 84611b12faf6Smrg case "$compile_rpath " in 84621b12faf6Smrg *" $absdir "*) ;; 8463e35d4d8eSmrg *) func_append compile_rpath " $absdir" ;; 84641b12faf6Smrg esac 84651b12faf6Smrg ;; 84661b12faf6Smrg esac 84671b12faf6Smrg case " $sys_lib_dlsearch_path " in 84681b12faf6Smrg *" $libdir "*) ;; 84691b12faf6Smrg *) 84701b12faf6Smrg case "$finalize_rpath " in 84711b12faf6Smrg *" $libdir "*) ;; 8472e35d4d8eSmrg *) func_append finalize_rpath " $libdir" ;; 84731b12faf6Smrg esac 84741b12faf6Smrg ;; 84751b12faf6Smrg esac 84761b12faf6Smrg fi 84771b12faf6Smrg 84781b12faf6Smrg if test -n "$old_archive_from_expsyms_cmds"; then 84791b12faf6Smrg # figure out the soname 84801b12faf6Smrg set dummy $library_names 84811b12faf6Smrg shift 84820b0ce0bfSmrg realname=$1 84831b12faf6Smrg shift 84841b12faf6Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 84851b12faf6Smrg # use dlname if we got it. it's perfectly good, no? 84861b12faf6Smrg if test -n "$dlname"; then 84870b0ce0bfSmrg soname=$dlname 84881b12faf6Smrg elif test -n "$soname_spec"; then 84891b12faf6Smrg # bleh windows 84901b12faf6Smrg case $host in 84910b0ce0bfSmrg *cygwin* | mingw* | *cegcc* | *os2*) 84921b12faf6Smrg func_arith $current - $age 84931b12faf6Smrg major=$func_arith_result 84940b0ce0bfSmrg versuffix=-$major 84951b12faf6Smrg ;; 84961b12faf6Smrg esac 84971b12faf6Smrg eval soname=\"$soname_spec\" 84981b12faf6Smrg else 84990b0ce0bfSmrg soname=$realname 85001b12faf6Smrg fi 85011b12faf6Smrg 85021b12faf6Smrg # Make a new name for the extract_expsyms_cmds to use 85030b0ce0bfSmrg soroot=$soname 85041b12faf6Smrg func_basename "$soroot" 85050b0ce0bfSmrg soname=$func_basename_result 85061b12faf6Smrg func_stripname 'lib' '.dll' "$soname" 85071b12faf6Smrg newlib=libimp-$func_stripname_result.a 85081b12faf6Smrg 85091b12faf6Smrg # If the library has no export list, then create one now 85101b12faf6Smrg if test -f "$output_objdir/$soname-def"; then : 85111b12faf6Smrg else 85120b0ce0bfSmrg func_verbose "extracting exported symbol list from '$soname'" 85131b12faf6Smrg func_execute_cmds "$extract_expsyms_cmds" 'exit $?' 85141b12faf6Smrg fi 85151b12faf6Smrg 85161b12faf6Smrg # Create $newlib 85171b12faf6Smrg if test -f "$output_objdir/$newlib"; then :; else 85180b0ce0bfSmrg func_verbose "generating import library for '$soname'" 85191b12faf6Smrg func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' 85201b12faf6Smrg fi 85211b12faf6Smrg # make sure the library variables are pointing to the new library 85221b12faf6Smrg dir=$output_objdir 85231b12faf6Smrg linklib=$newlib 85241b12faf6Smrg fi # test -n "$old_archive_from_expsyms_cmds" 85251b12faf6Smrg 85260b0ce0bfSmrg if test prog = "$linkmode" || test relink != "$opt_mode"; then 85271b12faf6Smrg add_shlibpath= 85281b12faf6Smrg add_dir= 85291b12faf6Smrg add= 85301b12faf6Smrg lib_linked=yes 85311b12faf6Smrg case $hardcode_action in 85321b12faf6Smrg immediate | unsupported) 85330b0ce0bfSmrg if test no = "$hardcode_direct"; then 85340b0ce0bfSmrg add=$dir/$linklib 85351b12faf6Smrg case $host in 85360b0ce0bfSmrg *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;; 85370b0ce0bfSmrg *-*-sysv4*uw2*) add_dir=-L$dir ;; 85381b12faf6Smrg *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ 85390b0ce0bfSmrg *-*-unixware7*) add_dir=-L$dir ;; 85401b12faf6Smrg *-*-darwin* ) 85410b0ce0bfSmrg # if the lib is a (non-dlopened) module then we cannot 85421b12faf6Smrg # link against it, someone is ignoring the earlier warnings 85431b12faf6Smrg if /usr/bin/file -L $add 2> /dev/null | 85440b0ce0bfSmrg $GREP ": [^:]* bundle" >/dev/null; then 85451b12faf6Smrg if test "X$dlopenmodule" != "X$lib"; then 85461b12faf6Smrg $ECHO "*** Warning: lib $linklib is a module, not a shared library" 85470b0ce0bfSmrg if test -z "$old_library"; then 8548e35d4d8eSmrg echo 8549e35d4d8eSmrg echo "*** And there doesn't seem to be a static archive available" 8550e35d4d8eSmrg echo "*** The link will probably fail, sorry" 85511b12faf6Smrg else 85520b0ce0bfSmrg add=$dir/$old_library 85531b12faf6Smrg fi 85541b12faf6Smrg elif test -n "$old_library"; then 85550b0ce0bfSmrg add=$dir/$old_library 85561b12faf6Smrg fi 85571b12faf6Smrg fi 85581b12faf6Smrg esac 85590b0ce0bfSmrg elif test no = "$hardcode_minus_L"; then 85601b12faf6Smrg case $host in 85610b0ce0bfSmrg *-*-sunos*) add_shlibpath=$dir ;; 85621b12faf6Smrg esac 85630b0ce0bfSmrg add_dir=-L$dir 85640b0ce0bfSmrg add=-l$name 85650b0ce0bfSmrg elif test no = "$hardcode_shlibpath_var"; then 85660b0ce0bfSmrg add_shlibpath=$dir 85670b0ce0bfSmrg add=-l$name 85681b12faf6Smrg else 85691b12faf6Smrg lib_linked=no 85701b12faf6Smrg fi 85711b12faf6Smrg ;; 85721b12faf6Smrg relink) 85730b0ce0bfSmrg if test yes = "$hardcode_direct" && 85740b0ce0bfSmrg test no = "$hardcode_direct_absolute"; then 85750b0ce0bfSmrg add=$dir/$linklib 85760b0ce0bfSmrg elif test yes = "$hardcode_minus_L"; then 85770b0ce0bfSmrg add_dir=-L$absdir 85781b12faf6Smrg # Try looking first in the location we're being installed to. 85791b12faf6Smrg if test -n "$inst_prefix_dir"; then 85801b12faf6Smrg case $libdir in 85811b12faf6Smrg [\\/]*) 8582e35d4d8eSmrg func_append add_dir " -L$inst_prefix_dir$libdir" 85831b12faf6Smrg ;; 85841b12faf6Smrg esac 85851b12faf6Smrg fi 85860b0ce0bfSmrg add=-l$name 85870b0ce0bfSmrg elif test yes = "$hardcode_shlibpath_var"; then 85880b0ce0bfSmrg add_shlibpath=$dir 85890b0ce0bfSmrg add=-l$name 85901b12faf6Smrg else 85911b12faf6Smrg lib_linked=no 85921b12faf6Smrg fi 85931b12faf6Smrg ;; 85941b12faf6Smrg *) lib_linked=no ;; 85951b12faf6Smrg esac 85961b12faf6Smrg 85970b0ce0bfSmrg if test yes != "$lib_linked"; then 85981b12faf6Smrg func_fatal_configuration "unsupported hardcode properties" 85991b12faf6Smrg fi 86001b12faf6Smrg 86011b12faf6Smrg if test -n "$add_shlibpath"; then 86021b12faf6Smrg case :$compile_shlibpath: in 86031b12faf6Smrg *":$add_shlibpath:"*) ;; 8604e35d4d8eSmrg *) func_append compile_shlibpath "$add_shlibpath:" ;; 86051b12faf6Smrg esac 86061b12faf6Smrg fi 86070b0ce0bfSmrg if test prog = "$linkmode"; then 86081b12faf6Smrg test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" 86091b12faf6Smrg test -n "$add" && compile_deplibs="$add $compile_deplibs" 86101b12faf6Smrg else 86111b12faf6Smrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 86121b12faf6Smrg test -n "$add" && deplibs="$add $deplibs" 86130b0ce0bfSmrg if test yes != "$hardcode_direct" && 86140b0ce0bfSmrg test yes != "$hardcode_minus_L" && 86150b0ce0bfSmrg test yes = "$hardcode_shlibpath_var"; then 86161b12faf6Smrg case :$finalize_shlibpath: in 86171b12faf6Smrg *":$libdir:"*) ;; 8618e35d4d8eSmrg *) func_append finalize_shlibpath "$libdir:" ;; 86191b12faf6Smrg esac 86201b12faf6Smrg fi 86211b12faf6Smrg fi 86221b12faf6Smrg fi 86231b12faf6Smrg 86240b0ce0bfSmrg if test prog = "$linkmode" || test relink = "$opt_mode"; then 86251b12faf6Smrg add_shlibpath= 86261b12faf6Smrg add_dir= 86271b12faf6Smrg add= 86281b12faf6Smrg # Finalize command for both is simple: just hardcode it. 86290b0ce0bfSmrg if test yes = "$hardcode_direct" && 86300b0ce0bfSmrg test no = "$hardcode_direct_absolute"; then 86310b0ce0bfSmrg add=$libdir/$linklib 86320b0ce0bfSmrg elif test yes = "$hardcode_minus_L"; then 86330b0ce0bfSmrg add_dir=-L$libdir 86340b0ce0bfSmrg add=-l$name 86350b0ce0bfSmrg elif test yes = "$hardcode_shlibpath_var"; then 86361b12faf6Smrg case :$finalize_shlibpath: in 86371b12faf6Smrg *":$libdir:"*) ;; 8638e35d4d8eSmrg *) func_append finalize_shlibpath "$libdir:" ;; 86391b12faf6Smrg esac 86400b0ce0bfSmrg add=-l$name 86410b0ce0bfSmrg elif test yes = "$hardcode_automatic"; then 86421b12faf6Smrg if test -n "$inst_prefix_dir" && 86430b0ce0bfSmrg test -f "$inst_prefix_dir$libdir/$linklib"; then 86440b0ce0bfSmrg add=$inst_prefix_dir$libdir/$linklib 86451b12faf6Smrg else 86460b0ce0bfSmrg add=$libdir/$linklib 86471b12faf6Smrg fi 86481b12faf6Smrg else 86491b12faf6Smrg # We cannot seem to hardcode it, guess we'll fake it. 86500b0ce0bfSmrg add_dir=-L$libdir 86511b12faf6Smrg # Try looking first in the location we're being installed to. 86521b12faf6Smrg if test -n "$inst_prefix_dir"; then 86531b12faf6Smrg case $libdir in 86541b12faf6Smrg [\\/]*) 8655e35d4d8eSmrg func_append add_dir " -L$inst_prefix_dir$libdir" 86561b12faf6Smrg ;; 86571b12faf6Smrg esac 86581b12faf6Smrg fi 86590b0ce0bfSmrg add=-l$name 86601b12faf6Smrg fi 86611b12faf6Smrg 86620b0ce0bfSmrg if test prog = "$linkmode"; then 86631b12faf6Smrg test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" 86641b12faf6Smrg test -n "$add" && finalize_deplibs="$add $finalize_deplibs" 86651b12faf6Smrg else 86661b12faf6Smrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 86671b12faf6Smrg test -n "$add" && deplibs="$add $deplibs" 86681b12faf6Smrg fi 86691b12faf6Smrg fi 86700b0ce0bfSmrg elif test prog = "$linkmode"; then 86711b12faf6Smrg # Here we assume that one of hardcode_direct or hardcode_minus_L 86721b12faf6Smrg # is not unsupported. This is valid on all known static and 86731b12faf6Smrg # shared platforms. 86740b0ce0bfSmrg if test unsupported != "$hardcode_direct"; then 86750b0ce0bfSmrg test -n "$old_library" && linklib=$old_library 86761b12faf6Smrg compile_deplibs="$dir/$linklib $compile_deplibs" 86771b12faf6Smrg finalize_deplibs="$dir/$linklib $finalize_deplibs" 86781b12faf6Smrg else 86791b12faf6Smrg compile_deplibs="-l$name -L$dir $compile_deplibs" 86801b12faf6Smrg finalize_deplibs="-l$name -L$dir $finalize_deplibs" 86811b12faf6Smrg fi 86820b0ce0bfSmrg elif test yes = "$build_libtool_libs"; then 86831b12faf6Smrg # Not a shared library 86840b0ce0bfSmrg if test pass_all != "$deplibs_check_method"; then 86851b12faf6Smrg # We're trying link a shared library against a static one 86861b12faf6Smrg # but the system doesn't support it. 86871b12faf6Smrg 86881b12faf6Smrg # Just print a warning and add the library to dependency_libs so 86891b12faf6Smrg # that the program can be linked against the static library. 8690e35d4d8eSmrg echo 86910b0ce0bfSmrg $ECHO "*** Warning: This system cannot link to static lib archive $lib." 8692e35d4d8eSmrg echo "*** I have the capability to make that library automatically link in when" 8693e35d4d8eSmrg echo "*** you link to this library. But I can only do this if you have a" 8694e35d4d8eSmrg echo "*** shared version of the library, which you do not appear to have." 86950b0ce0bfSmrg if test yes = "$module"; then 8696e35d4d8eSmrg echo "*** But as you try to build a module library, libtool will still create " 8697e35d4d8eSmrg echo "*** a static module, that should work as long as the dlopening application" 8698e35d4d8eSmrg echo "*** is linked with the -dlopen flag to resolve symbols at runtime." 86991b12faf6Smrg if test -z "$global_symbol_pipe"; then 8700e35d4d8eSmrg echo 8701e35d4d8eSmrg echo "*** However, this would only work if libtool was able to extract symbol" 87020b0ce0bfSmrg echo "*** lists from a program, using 'nm' or equivalent, but libtool could" 8703e35d4d8eSmrg echo "*** not find such a program. So, this module is probably useless." 87040b0ce0bfSmrg echo "*** 'nm' from GNU binutils and a full rebuild may help." 87051b12faf6Smrg fi 87060b0ce0bfSmrg if test no = "$build_old_libs"; then 87071b12faf6Smrg build_libtool_libs=module 87081b12faf6Smrg build_old_libs=yes 87091b12faf6Smrg else 87101b12faf6Smrg build_libtool_libs=no 87111b12faf6Smrg fi 87121b12faf6Smrg fi 87131b12faf6Smrg else 87141b12faf6Smrg deplibs="$dir/$old_library $deplibs" 87151b12faf6Smrg link_static=yes 87161b12faf6Smrg fi 87171b12faf6Smrg fi # link shared/static library? 87181b12faf6Smrg 87190b0ce0bfSmrg if test lib = "$linkmode"; then 87201b12faf6Smrg if test -n "$dependency_libs" && 87210b0ce0bfSmrg { test yes != "$hardcode_into_libs" || 87220b0ce0bfSmrg test yes = "$build_old_libs" || 87230b0ce0bfSmrg test yes = "$link_static"; }; then 87241b12faf6Smrg # Extract -R from dependency_libs 87251b12faf6Smrg temp_deplibs= 87261b12faf6Smrg for libdir in $dependency_libs; do 87271b12faf6Smrg case $libdir in 87281b12faf6Smrg -R*) func_stripname '-R' '' "$libdir" 87291b12faf6Smrg temp_xrpath=$func_stripname_result 87301b12faf6Smrg case " $xrpath " in 87311b12faf6Smrg *" $temp_xrpath "*) ;; 8732e35d4d8eSmrg *) func_append xrpath " $temp_xrpath";; 87331b12faf6Smrg esac;; 8734e35d4d8eSmrg *) func_append temp_deplibs " $libdir";; 87351b12faf6Smrg esac 87361b12faf6Smrg done 87370b0ce0bfSmrg dependency_libs=$temp_deplibs 87381b12faf6Smrg fi 87391b12faf6Smrg 8740e35d4d8eSmrg func_append newlib_search_path " $absdir" 87411b12faf6Smrg # Link against this library 87420b0ce0bfSmrg test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs" 87431b12faf6Smrg # ... and its dependency_libs 87441b12faf6Smrg tmp_libs= 87451b12faf6Smrg for deplib in $dependency_libs; do 87461b12faf6Smrg newdependency_libs="$deplib $newdependency_libs" 8747e35d4d8eSmrg case $deplib in 8748e35d4d8eSmrg -L*) func_stripname '-L' '' "$deplib" 8749e35d4d8eSmrg func_resolve_sysroot "$func_stripname_result";; 8750e35d4d8eSmrg *) func_resolve_sysroot "$deplib" ;; 8751e35d4d8eSmrg esac 87520b0ce0bfSmrg if $opt_preserve_dup_deps; then 87531b12faf6Smrg case "$tmp_libs " in 8754e35d4d8eSmrg *" $func_resolve_sysroot_result "*) 8755e35d4d8eSmrg func_append specialdeplibs " $func_resolve_sysroot_result" ;; 87561b12faf6Smrg esac 87571b12faf6Smrg fi 8758e35d4d8eSmrg func_append tmp_libs " $func_resolve_sysroot_result" 87591b12faf6Smrg done 87601b12faf6Smrg 87610b0ce0bfSmrg if test no != "$link_all_deplibs"; then 87621b12faf6Smrg # Add the search paths of all dependency libraries 87631b12faf6Smrg for deplib in $dependency_libs; do 87641b12faf6Smrg path= 87651b12faf6Smrg case $deplib in 87660b0ce0bfSmrg -L*) path=$deplib ;; 87671b12faf6Smrg *.la) 8768e35d4d8eSmrg func_resolve_sysroot "$deplib" 8769e35d4d8eSmrg deplib=$func_resolve_sysroot_result 87701b12faf6Smrg func_dirname "$deplib" "" "." 8771e35d4d8eSmrg dir=$func_dirname_result 87721b12faf6Smrg # We need an absolute path. 87731b12faf6Smrg case $dir in 87740b0ce0bfSmrg [\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;; 87751b12faf6Smrg *) 87761b12faf6Smrg absdir=`cd "$dir" && pwd` 87771b12faf6Smrg if test -z "$absdir"; then 87780b0ce0bfSmrg func_warning "cannot determine absolute directory name of '$dir'" 87790b0ce0bfSmrg absdir=$dir 87801b12faf6Smrg fi 87811b12faf6Smrg ;; 87821b12faf6Smrg esac 87831b12faf6Smrg if $GREP "^installed=no" $deplib > /dev/null; then 87841b12faf6Smrg case $host in 87851b12faf6Smrg *-*-darwin*) 87861b12faf6Smrg depdepl= 87870b0ce0bfSmrg eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` 87880b0ce0bfSmrg if test -n "$deplibrary_names"; then 87890b0ce0bfSmrg for tmp in $deplibrary_names; do 87901b12faf6Smrg depdepl=$tmp 87911b12faf6Smrg done 87920b0ce0bfSmrg if test -f "$absdir/$objdir/$depdepl"; then 87930b0ce0bfSmrg depdepl=$absdir/$objdir/$depdepl 87940b0ce0bfSmrg darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 87951b12faf6Smrg if test -z "$darwin_install_name"; then 87960b0ce0bfSmrg darwin_install_name=`$OTOOL64 -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 87971b12faf6Smrg fi 87980b0ce0bfSmrg func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl" 87990b0ce0bfSmrg func_append linker_flags " -dylib_file $darwin_install_name:$depdepl" 88001b12faf6Smrg path= 88011b12faf6Smrg fi 88021b12faf6Smrg fi 88031b12faf6Smrg ;; 88041b12faf6Smrg *) 88050b0ce0bfSmrg path=-L$absdir/$objdir 88061b12faf6Smrg ;; 88071b12faf6Smrg esac 88081b12faf6Smrg else 88090b0ce0bfSmrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` 88101b12faf6Smrg test -z "$libdir" && \ 88110b0ce0bfSmrg func_fatal_error "'$deplib' is not a valid libtool archive" 88121b12faf6Smrg test "$absdir" != "$libdir" && \ 88130b0ce0bfSmrg func_warning "'$deplib' seems to be moved" 88141b12faf6Smrg 88150b0ce0bfSmrg path=-L$absdir 88161b12faf6Smrg fi 88171b12faf6Smrg ;; 88181b12faf6Smrg esac 88191b12faf6Smrg case " $deplibs " in 88201b12faf6Smrg *" $path "*) ;; 88211b12faf6Smrg *) deplibs="$path $deplibs" ;; 88221b12faf6Smrg esac 88231b12faf6Smrg done 88241b12faf6Smrg fi # link_all_deplibs != no 88251b12faf6Smrg fi # linkmode = lib 88261b12faf6Smrg done # for deplib in $libs 88270b0ce0bfSmrg if test link = "$pass"; then 88280b0ce0bfSmrg if test prog = "$linkmode"; then 88291b12faf6Smrg compile_deplibs="$new_inherited_linker_flags $compile_deplibs" 88301b12faf6Smrg finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" 88311b12faf6Smrg else 8832e35d4d8eSmrg compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 88331b12faf6Smrg fi 88341b12faf6Smrg fi 88350b0ce0bfSmrg dependency_libs=$newdependency_libs 88360b0ce0bfSmrg if test dlpreopen = "$pass"; then 88371b12faf6Smrg # Link the dlpreopened libraries before other libraries 88381b12faf6Smrg for deplib in $save_deplibs; do 88391b12faf6Smrg deplibs="$deplib $deplibs" 88401b12faf6Smrg done 88411b12faf6Smrg fi 88420b0ce0bfSmrg if test dlopen != "$pass"; then 88430b0ce0bfSmrg test conv = "$pass" || { 88441b12faf6Smrg # Make sure lib_search_path contains only unique directories. 88451b12faf6Smrg lib_search_path= 88461b12faf6Smrg for dir in $newlib_search_path; do 88471b12faf6Smrg case "$lib_search_path " in 88481b12faf6Smrg *" $dir "*) ;; 8849e35d4d8eSmrg *) func_append lib_search_path " $dir" ;; 88501b12faf6Smrg esac 88511b12faf6Smrg done 88521b12faf6Smrg newlib_search_path= 88530b0ce0bfSmrg } 88541b12faf6Smrg 88550b0ce0bfSmrg if test prog,link = "$linkmode,$pass"; then 88561b12faf6Smrg vars="compile_deplibs finalize_deplibs" 88570b0ce0bfSmrg else 88580b0ce0bfSmrg vars=deplibs 88591b12faf6Smrg fi 88601b12faf6Smrg for var in $vars dependency_libs; do 88611b12faf6Smrg # Add libraries to $var in reverse order 88621b12faf6Smrg eval tmp_libs=\"\$$var\" 88631b12faf6Smrg new_libs= 88641b12faf6Smrg for deplib in $tmp_libs; do 88651b12faf6Smrg # FIXME: Pedantically, this is the right thing to do, so 88661b12faf6Smrg # that some nasty dependency loop isn't accidentally 88671b12faf6Smrg # broken: 88681b12faf6Smrg #new_libs="$deplib $new_libs" 88691b12faf6Smrg # Pragmatically, this seems to cause very few problems in 88701b12faf6Smrg # practice: 88711b12faf6Smrg case $deplib in 88721b12faf6Smrg -L*) new_libs="$deplib $new_libs" ;; 88731b12faf6Smrg -R*) ;; 88741b12faf6Smrg *) 88751b12faf6Smrg # And here is the reason: when a library appears more 88761b12faf6Smrg # than once as an explicit dependence of a library, or 88771b12faf6Smrg # is implicitly linked in more than once by the 88781b12faf6Smrg # compiler, it is considered special, and multiple 88791b12faf6Smrg # occurrences thereof are not removed. Compare this 88801b12faf6Smrg # with having the same library being listed as a 88811b12faf6Smrg # dependency of multiple other libraries: in this case, 88821b12faf6Smrg # we know (pedantically, we assume) the library does not 88831b12faf6Smrg # need to be listed more than once, so we keep only the 88841b12faf6Smrg # last copy. This is not always right, but it is rare 88851b12faf6Smrg # enough that we require users that really mean to play 88861b12faf6Smrg # such unportable linking tricks to link the library 88871b12faf6Smrg # using -Wl,-lname, so that libtool does not consider it 88881b12faf6Smrg # for duplicate removal. 88891b12faf6Smrg case " $specialdeplibs " in 88901b12faf6Smrg *" $deplib "*) new_libs="$deplib $new_libs" ;; 88911b12faf6Smrg *) 88921b12faf6Smrg case " $new_libs " in 88931b12faf6Smrg *" $deplib "*) ;; 88941b12faf6Smrg *) new_libs="$deplib $new_libs" ;; 88951b12faf6Smrg esac 88961b12faf6Smrg ;; 88971b12faf6Smrg esac 88981b12faf6Smrg ;; 88991b12faf6Smrg esac 89001b12faf6Smrg done 89011b12faf6Smrg tmp_libs= 89021b12faf6Smrg for deplib in $new_libs; do 89031b12faf6Smrg case $deplib in 89041b12faf6Smrg -L*) 89051b12faf6Smrg case " $tmp_libs " in 89061b12faf6Smrg *" $deplib "*) ;; 8907e35d4d8eSmrg *) func_append tmp_libs " $deplib" ;; 89081b12faf6Smrg esac 89091b12faf6Smrg ;; 8910e35d4d8eSmrg *) func_append tmp_libs " $deplib" ;; 89111b12faf6Smrg esac 89121b12faf6Smrg done 89131b12faf6Smrg eval $var=\"$tmp_libs\" 89141b12faf6Smrg done # for var 89151b12faf6Smrg fi 89160b0ce0bfSmrg 89170b0ce0bfSmrg # Add Sun CC postdeps if required: 89180b0ce0bfSmrg test CXX = "$tagname" && { 89190b0ce0bfSmrg case $host_os in 89200b0ce0bfSmrg linux*) 89210b0ce0bfSmrg case `$CC -V 2>&1 | $SED 5q` in 89220b0ce0bfSmrg *Sun\ C*) # Sun C++ 5.9 89230b0ce0bfSmrg func_suncc_cstd_abi 89240b0ce0bfSmrg 89250b0ce0bfSmrg if test no != "$suncc_use_cstd_abi"; then 89260b0ce0bfSmrg func_append postdeps ' -library=Cstd -library=Crun' 89270b0ce0bfSmrg fi 89280b0ce0bfSmrg ;; 89290b0ce0bfSmrg esac 89300b0ce0bfSmrg ;; 89310b0ce0bfSmrg 89320b0ce0bfSmrg solaris*) 89330b0ce0bfSmrg func_cc_basename "$CC" 89340b0ce0bfSmrg case $func_cc_basename_result in 89350b0ce0bfSmrg CC* | sunCC*) 89360b0ce0bfSmrg func_suncc_cstd_abi 89370b0ce0bfSmrg 89380b0ce0bfSmrg if test no != "$suncc_use_cstd_abi"; then 89390b0ce0bfSmrg func_append postdeps ' -library=Cstd -library=Crun' 89400b0ce0bfSmrg fi 89410b0ce0bfSmrg ;; 89420b0ce0bfSmrg esac 89430b0ce0bfSmrg ;; 89440b0ce0bfSmrg esac 89450b0ce0bfSmrg } 89460b0ce0bfSmrg 89471b12faf6Smrg # Last step: remove runtime libs from dependency_libs 89481b12faf6Smrg # (they stay in deplibs) 89491b12faf6Smrg tmp_libs= 89500b0ce0bfSmrg for i in $dependency_libs; do 89511b12faf6Smrg case " $predeps $postdeps $compiler_lib_search_path " in 89521b12faf6Smrg *" $i "*) 89530b0ce0bfSmrg i= 89541b12faf6Smrg ;; 89551b12faf6Smrg esac 89560b0ce0bfSmrg if test -n "$i"; then 8957e35d4d8eSmrg func_append tmp_libs " $i" 89581b12faf6Smrg fi 89591b12faf6Smrg done 89601b12faf6Smrg dependency_libs=$tmp_libs 89611b12faf6Smrg done # for pass 89620b0ce0bfSmrg if test prog = "$linkmode"; then 89630b0ce0bfSmrg dlfiles=$newdlfiles 89641b12faf6Smrg fi 89650b0ce0bfSmrg if test prog = "$linkmode" || test lib = "$linkmode"; then 89660b0ce0bfSmrg dlprefiles=$newdlprefiles 89671b12faf6Smrg fi 89681b12faf6Smrg 89691b12faf6Smrg case $linkmode in 89701b12faf6Smrg oldlib) 89710b0ce0bfSmrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 89720b0ce0bfSmrg func_warning "'-dlopen' is ignored for archives" 89731b12faf6Smrg fi 89741b12faf6Smrg 89751b12faf6Smrg case " $deplibs" in 89761b12faf6Smrg *\ -l* | *\ -L*) 89770b0ce0bfSmrg func_warning "'-l' and '-L' are ignored for archives" ;; 89781b12faf6Smrg esac 89791b12faf6Smrg 89801b12faf6Smrg test -n "$rpath" && \ 89810b0ce0bfSmrg func_warning "'-rpath' is ignored for archives" 89821b12faf6Smrg 89831b12faf6Smrg test -n "$xrpath" && \ 89840b0ce0bfSmrg func_warning "'-R' is ignored for archives" 89851b12faf6Smrg 89861b12faf6Smrg test -n "$vinfo" && \ 89870b0ce0bfSmrg func_warning "'-version-info/-version-number' is ignored for archives" 89881b12faf6Smrg 89891b12faf6Smrg test -n "$release" && \ 89900b0ce0bfSmrg func_warning "'-release' is ignored for archives" 89911b12faf6Smrg 89921b12faf6Smrg test -n "$export_symbols$export_symbols_regex" && \ 89930b0ce0bfSmrg func_warning "'-export-symbols' is ignored for archives" 89941b12faf6Smrg 89951b12faf6Smrg # Now set the variables for building old libraries. 89961b12faf6Smrg build_libtool_libs=no 89970b0ce0bfSmrg oldlibs=$output 8998e35d4d8eSmrg func_append objs "$old_deplibs" 89991b12faf6Smrg ;; 90001b12faf6Smrg 90011b12faf6Smrg lib) 90020b0ce0bfSmrg # Make sure we only generate libraries of the form 'libNAME.la'. 90031b12faf6Smrg case $outputname in 90041b12faf6Smrg lib*) 90051b12faf6Smrg func_stripname 'lib' '.la' "$outputname" 90061b12faf6Smrg name=$func_stripname_result 90071b12faf6Smrg eval shared_ext=\"$shrext_cmds\" 90081b12faf6Smrg eval libname=\"$libname_spec\" 90091b12faf6Smrg ;; 90101b12faf6Smrg *) 90110b0ce0bfSmrg test no = "$module" \ 90120b0ce0bfSmrg && func_fatal_help "libtool library '$output' must begin with 'lib'" 90131b12faf6Smrg 90140b0ce0bfSmrg if test no != "$need_lib_prefix"; then 90151b12faf6Smrg # Add the "lib" prefix for modules if required 90161b12faf6Smrg func_stripname '' '.la' "$outputname" 90171b12faf6Smrg name=$func_stripname_result 90181b12faf6Smrg eval shared_ext=\"$shrext_cmds\" 90191b12faf6Smrg eval libname=\"$libname_spec\" 90201b12faf6Smrg else 90211b12faf6Smrg func_stripname '' '.la' "$outputname" 90221b12faf6Smrg libname=$func_stripname_result 90231b12faf6Smrg fi 90241b12faf6Smrg ;; 90251b12faf6Smrg esac 90261b12faf6Smrg 90271b12faf6Smrg if test -n "$objs"; then 90280b0ce0bfSmrg if test pass_all != "$deplibs_check_method"; then 90290b0ce0bfSmrg func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs" 90301b12faf6Smrg else 9031e35d4d8eSmrg echo 90321b12faf6Smrg $ECHO "*** Warning: Linking the shared library $output against the non-libtool" 90331b12faf6Smrg $ECHO "*** objects $objs is not portable!" 9034e35d4d8eSmrg func_append libobjs " $objs" 90351b12faf6Smrg fi 90361b12faf6Smrg fi 90371b12faf6Smrg 90380b0ce0bfSmrg test no = "$dlself" \ 90390b0ce0bfSmrg || func_warning "'-dlopen self' is ignored for libtool libraries" 90401b12faf6Smrg 90411b12faf6Smrg set dummy $rpath 90421b12faf6Smrg shift 90430b0ce0bfSmrg test 1 -lt "$#" \ 90440b0ce0bfSmrg && func_warning "ignoring multiple '-rpath's for a libtool library" 90451b12faf6Smrg 90460b0ce0bfSmrg install_libdir=$1 90471b12faf6Smrg 90481b12faf6Smrg oldlibs= 90491b12faf6Smrg if test -z "$rpath"; then 90500b0ce0bfSmrg if test yes = "$build_libtool_libs"; then 90511b12faf6Smrg # Building a libtool convenience library. 90520b0ce0bfSmrg # Some compilers have problems with a '.al' extension so 90531b12faf6Smrg # convenience libraries should have the same extension an 90541b12faf6Smrg # archive normally would. 90551b12faf6Smrg oldlibs="$output_objdir/$libname.$libext $oldlibs" 90561b12faf6Smrg build_libtool_libs=convenience 90571b12faf6Smrg build_old_libs=yes 90581b12faf6Smrg fi 90591b12faf6Smrg 90601b12faf6Smrg test -n "$vinfo" && \ 90610b0ce0bfSmrg func_warning "'-version-info/-version-number' is ignored for convenience libraries" 90621b12faf6Smrg 90631b12faf6Smrg test -n "$release" && \ 90640b0ce0bfSmrg func_warning "'-release' is ignored for convenience libraries" 90651b12faf6Smrg else 90661b12faf6Smrg 90671b12faf6Smrg # Parse the version information argument. 90680b0ce0bfSmrg save_ifs=$IFS; IFS=: 90691b12faf6Smrg set dummy $vinfo 0 0 0 90701b12faf6Smrg shift 90710b0ce0bfSmrg IFS=$save_ifs 90721b12faf6Smrg 90731b12faf6Smrg test -n "$7" && \ 90740b0ce0bfSmrg func_fatal_help "too many parameters to '-version-info'" 90751b12faf6Smrg 90761b12faf6Smrg # convert absolute version numbers to libtool ages 90771b12faf6Smrg # this retains compatibility with .la files and attempts 90781b12faf6Smrg # to make the code below a bit more comprehensible 90791b12faf6Smrg 90801b12faf6Smrg case $vinfo_number in 90811b12faf6Smrg yes) 90820b0ce0bfSmrg number_major=$1 90830b0ce0bfSmrg number_minor=$2 90840b0ce0bfSmrg number_revision=$3 90851b12faf6Smrg # 90861b12faf6Smrg # There are really only two kinds -- those that 90871b12faf6Smrg # use the current revision as the major version 90881b12faf6Smrg # and those that subtract age and use age as 90891b12faf6Smrg # a minor version. But, then there is irix 90900b0ce0bfSmrg # that has an extra 1 added just for fun 90911b12faf6Smrg # 90921b12faf6Smrg case $version_type in 9093e35d4d8eSmrg # correct linux to gnu/linux during the next big refactor 90940b0ce0bfSmrg darwin|freebsd-elf|linux|midnightbsd-elf|osf|windows|none) 90951b12faf6Smrg func_arith $number_major + $number_minor 90961b12faf6Smrg current=$func_arith_result 90970b0ce0bfSmrg age=$number_minor 90980b0ce0bfSmrg revision=$number_revision 90991b12faf6Smrg ;; 91000b0ce0bfSmrg freebsd-aout|qnx|sunos) 91010b0ce0bfSmrg current=$number_major 91020b0ce0bfSmrg revision=$number_minor 91030b0ce0bfSmrg age=0 91041b12faf6Smrg ;; 91051b12faf6Smrg irix|nonstopux) 91061b12faf6Smrg func_arith $number_major + $number_minor 91071b12faf6Smrg current=$func_arith_result 91080b0ce0bfSmrg age=$number_minor 91090b0ce0bfSmrg revision=$number_minor 91101b12faf6Smrg lt_irix_increment=no 91111b12faf6Smrg ;; 91121b12faf6Smrg esac 91131b12faf6Smrg ;; 91141b12faf6Smrg no) 91150b0ce0bfSmrg current=$1 91160b0ce0bfSmrg revision=$2 91170b0ce0bfSmrg age=$3 91181b12faf6Smrg ;; 91191b12faf6Smrg esac 91201b12faf6Smrg 91211b12faf6Smrg # Check that each of the things are valid numbers. 91221b12faf6Smrg case $current in 91231b12faf6Smrg 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]) ;; 91241b12faf6Smrg *) 91250b0ce0bfSmrg func_error "CURRENT '$current' must be a nonnegative integer" 91260b0ce0bfSmrg func_fatal_error "'$vinfo' is not valid version information" 91271b12faf6Smrg ;; 91281b12faf6Smrg esac 91291b12faf6Smrg 91301b12faf6Smrg case $revision in 91311b12faf6Smrg 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]) ;; 91321b12faf6Smrg *) 91330b0ce0bfSmrg func_error "REVISION '$revision' must be a nonnegative integer" 91340b0ce0bfSmrg func_fatal_error "'$vinfo' is not valid version information" 91351b12faf6Smrg ;; 91361b12faf6Smrg esac 91371b12faf6Smrg 91381b12faf6Smrg case $age in 91391b12faf6Smrg 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]) ;; 91401b12faf6Smrg *) 91410b0ce0bfSmrg func_error "AGE '$age' must be a nonnegative integer" 91420b0ce0bfSmrg func_fatal_error "'$vinfo' is not valid version information" 91431b12faf6Smrg ;; 91441b12faf6Smrg esac 91451b12faf6Smrg 91461b12faf6Smrg if test "$age" -gt "$current"; then 91470b0ce0bfSmrg func_error "AGE '$age' is greater than the current interface number '$current'" 91480b0ce0bfSmrg func_fatal_error "'$vinfo' is not valid version information" 91491b12faf6Smrg fi 91501b12faf6Smrg 91511b12faf6Smrg # Calculate the version variables. 91521b12faf6Smrg major= 91531b12faf6Smrg versuffix= 91541b12faf6Smrg verstring= 91551b12faf6Smrg case $version_type in 91561b12faf6Smrg none) ;; 91571b12faf6Smrg 91581b12faf6Smrg darwin) 91591b12faf6Smrg # Like Linux, but with the current version available in 91601b12faf6Smrg # verstring for coding it into the library header 91611b12faf6Smrg func_arith $current - $age 91621b12faf6Smrg major=.$func_arith_result 91630b0ce0bfSmrg versuffix=$major.$age.$revision 91641b12faf6Smrg # Darwin ld doesn't like 0 for these options... 91651b12faf6Smrg func_arith $current + 1 91661b12faf6Smrg minor_current=$func_arith_result 91670b0ce0bfSmrg xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" 91681b12faf6Smrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 91690b0ce0bfSmrg # On Darwin other compilers 91700b0ce0bfSmrg case $CC in 91710b0ce0bfSmrg nagfor*) 91720b0ce0bfSmrg verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" 91730b0ce0bfSmrg ;; 91740b0ce0bfSmrg *) 91750b0ce0bfSmrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 91760b0ce0bfSmrg ;; 91770b0ce0bfSmrg esac 91781b12faf6Smrg ;; 91791b12faf6Smrg 91801b12faf6Smrg freebsd-aout) 91810b0ce0bfSmrg major=.$current 91820b0ce0bfSmrg versuffix=.$current.$revision 91831b12faf6Smrg ;; 91841b12faf6Smrg 91850b0ce0bfSmrg freebsd-elf | midnightbsd-elf) 91860b0ce0bfSmrg func_arith $current - $age 91870b0ce0bfSmrg major=.$func_arith_result 91880b0ce0bfSmrg versuffix=$major.$age.$revision 91891b12faf6Smrg ;; 91901b12faf6Smrg 91911b12faf6Smrg irix | nonstopux) 91920b0ce0bfSmrg if test no = "$lt_irix_increment"; then 91931b12faf6Smrg func_arith $current - $age 91941b12faf6Smrg else 91951b12faf6Smrg func_arith $current - $age + 1 91961b12faf6Smrg fi 91971b12faf6Smrg major=$func_arith_result 91981b12faf6Smrg 91991b12faf6Smrg case $version_type in 92001b12faf6Smrg nonstopux) verstring_prefix=nonstopux ;; 92011b12faf6Smrg *) verstring_prefix=sgi ;; 92021b12faf6Smrg esac 92030b0ce0bfSmrg verstring=$verstring_prefix$major.$revision 92041b12faf6Smrg 92051b12faf6Smrg # Add in all the interfaces that we are compatible with. 92061b12faf6Smrg loop=$revision 92070b0ce0bfSmrg while test 0 -ne "$loop"; do 92081b12faf6Smrg func_arith $revision - $loop 92091b12faf6Smrg iface=$func_arith_result 92101b12faf6Smrg func_arith $loop - 1 92111b12faf6Smrg loop=$func_arith_result 92120b0ce0bfSmrg verstring=$verstring_prefix$major.$iface:$verstring 92131b12faf6Smrg done 92141b12faf6Smrg 92150b0ce0bfSmrg # Before this point, $major must not contain '.'. 92161b12faf6Smrg major=.$major 92170b0ce0bfSmrg versuffix=$major.$revision 92181b12faf6Smrg ;; 92191b12faf6Smrg 9220e35d4d8eSmrg linux) # correct to gnu/linux during the next big refactor 92211b12faf6Smrg func_arith $current - $age 92221b12faf6Smrg major=.$func_arith_result 92230b0ce0bfSmrg versuffix=$major.$age.$revision 92241b12faf6Smrg ;; 92251b12faf6Smrg 92261b12faf6Smrg osf) 92271b12faf6Smrg func_arith $current - $age 92281b12faf6Smrg major=.$func_arith_result 92290b0ce0bfSmrg versuffix=.$current.$age.$revision 92300b0ce0bfSmrg verstring=$current.$age.$revision 92311b12faf6Smrg 92321b12faf6Smrg # Add in all the interfaces that we are compatible with. 92331b12faf6Smrg loop=$age 92340b0ce0bfSmrg while test 0 -ne "$loop"; do 92351b12faf6Smrg func_arith $current - $loop 92361b12faf6Smrg iface=$func_arith_result 92371b12faf6Smrg func_arith $loop - 1 92381b12faf6Smrg loop=$func_arith_result 92390b0ce0bfSmrg verstring=$verstring:$iface.0 92401b12faf6Smrg done 92411b12faf6Smrg 92421b12faf6Smrg # Make executables depend on our current version. 92430b0ce0bfSmrg func_append verstring ":$current.0" 92441b12faf6Smrg ;; 92451b12faf6Smrg 92461b12faf6Smrg qnx) 92470b0ce0bfSmrg major=.$current 92480b0ce0bfSmrg versuffix=.$current 92490b0ce0bfSmrg ;; 92500b0ce0bfSmrg 92510b0ce0bfSmrg sco) 92520b0ce0bfSmrg major=.$current 92530b0ce0bfSmrg versuffix=.$current 92541b12faf6Smrg ;; 92551b12faf6Smrg 92561b12faf6Smrg sunos) 92570b0ce0bfSmrg major=.$current 92580b0ce0bfSmrg versuffix=.$current.$revision 92591b12faf6Smrg ;; 92601b12faf6Smrg 92611b12faf6Smrg windows) 92621b12faf6Smrg # Use '-' rather than '.', since we only want one 92630b0ce0bfSmrg # extension on DOS 8.3 file systems. 92641b12faf6Smrg func_arith $current - $age 92651b12faf6Smrg major=$func_arith_result 92660b0ce0bfSmrg versuffix=-$major 92671b12faf6Smrg ;; 92681b12faf6Smrg 92691b12faf6Smrg *) 92700b0ce0bfSmrg func_fatal_configuration "unknown library version type '$version_type'" 92711b12faf6Smrg ;; 92721b12faf6Smrg esac 92731b12faf6Smrg 92741b12faf6Smrg # Clear the version info if we defaulted, and they specified a release. 92751b12faf6Smrg if test -z "$vinfo" && test -n "$release"; then 92761b12faf6Smrg major= 92771b12faf6Smrg case $version_type in 92781b12faf6Smrg darwin) 92791b12faf6Smrg # we can't check for "0.0" in archive_cmds due to quoting 92801b12faf6Smrg # problems, so we reset it completely 92811b12faf6Smrg verstring= 92821b12faf6Smrg ;; 92831b12faf6Smrg *) 92840b0ce0bfSmrg verstring=0.0 92851b12faf6Smrg ;; 92861b12faf6Smrg esac 92870b0ce0bfSmrg if test no = "$need_version"; then 92881b12faf6Smrg versuffix= 92891b12faf6Smrg else 92900b0ce0bfSmrg versuffix=.0.0 92911b12faf6Smrg fi 92921b12faf6Smrg fi 92931b12faf6Smrg 92941b12faf6Smrg # Remove version info from name if versioning should be avoided 92950b0ce0bfSmrg if test yes,no = "$avoid_version,$need_version"; then 92961b12faf6Smrg major= 92971b12faf6Smrg versuffix= 92980b0ce0bfSmrg verstring= 92991b12faf6Smrg fi 93001b12faf6Smrg 93011b12faf6Smrg # Check to see if the archive will have undefined symbols. 93020b0ce0bfSmrg if test yes = "$allow_undefined"; then 93030b0ce0bfSmrg if test unsupported = "$allow_undefined_flag"; then 93040b0ce0bfSmrg if test yes = "$build_old_libs"; then 93050b0ce0bfSmrg func_warning "undefined symbols not allowed in $host shared libraries; building static only" 93060b0ce0bfSmrg build_libtool_libs=no 93070b0ce0bfSmrg else 93080b0ce0bfSmrg func_fatal_error "can't build $host shared library unless -no-undefined is specified" 93090b0ce0bfSmrg fi 93101b12faf6Smrg fi 93111b12faf6Smrg else 93121b12faf6Smrg # Don't allow undefined symbols. 93130b0ce0bfSmrg allow_undefined_flag=$no_undefined_flag 93141b12faf6Smrg fi 93151b12faf6Smrg 93161b12faf6Smrg fi 93171b12faf6Smrg 93180b0ce0bfSmrg func_generate_dlsyms "$libname" "$libname" : 9319e35d4d8eSmrg func_append libobjs " $symfileobj" 93200b0ce0bfSmrg test " " = "$libobjs" && libobjs= 93211b12faf6Smrg 93220b0ce0bfSmrg if test relink != "$opt_mode"; then 93231b12faf6Smrg # Remove our outputs, but don't remove object files since they 93241b12faf6Smrg # may have been created when compiling PIC objects. 93251b12faf6Smrg removelist= 93261b12faf6Smrg tempremovelist=`$ECHO "$output_objdir/*"` 93271b12faf6Smrg for p in $tempremovelist; do 93281b12faf6Smrg case $p in 93291b12faf6Smrg *.$objext | *.gcno) 93301b12faf6Smrg ;; 93310b0ce0bfSmrg $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/$libname$release.*) 93320b0ce0bfSmrg if test -n "$precious_files_regex"; then 93331b12faf6Smrg if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 93341b12faf6Smrg then 93351b12faf6Smrg continue 93361b12faf6Smrg fi 93371b12faf6Smrg fi 9338e35d4d8eSmrg func_append removelist " $p" 93391b12faf6Smrg ;; 93401b12faf6Smrg *) ;; 93411b12faf6Smrg esac 93421b12faf6Smrg done 93431b12faf6Smrg test -n "$removelist" && \ 93441b12faf6Smrg func_show_eval "${RM}r \$removelist" 93451b12faf6Smrg fi 93461b12faf6Smrg 93471b12faf6Smrg # Now set the variables for building old libraries. 93480b0ce0bfSmrg if test yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; then 9349e35d4d8eSmrg func_append oldlibs " $output_objdir/$libname.$libext" 93501b12faf6Smrg 93511b12faf6Smrg # Transform .lo files to .o files. 93520b0ce0bfSmrg oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; $lo2o" | $NL2SP` 93531b12faf6Smrg fi 93541b12faf6Smrg 93551b12faf6Smrg # Eliminate all temporary directories. 93561b12faf6Smrg #for path in $notinst_path; do 9357e35d4d8eSmrg # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` 9358e35d4d8eSmrg # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` 9359e35d4d8eSmrg # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` 93601b12faf6Smrg #done 93611b12faf6Smrg 93621b12faf6Smrg if test -n "$xrpath"; then 93631b12faf6Smrg # If the user specified any rpath flags, then add them. 93641b12faf6Smrg temp_xrpath= 93651b12faf6Smrg for libdir in $xrpath; do 9366e35d4d8eSmrg func_replace_sysroot "$libdir" 9367e35d4d8eSmrg func_append temp_xrpath " -R$func_replace_sysroot_result" 93681b12faf6Smrg case "$finalize_rpath " in 93691b12faf6Smrg *" $libdir "*) ;; 9370e35d4d8eSmrg *) func_append finalize_rpath " $libdir" ;; 93711b12faf6Smrg esac 93721b12faf6Smrg done 93730b0ce0bfSmrg if test yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; then 93741b12faf6Smrg dependency_libs="$temp_xrpath $dependency_libs" 93751b12faf6Smrg fi 93761b12faf6Smrg fi 93771b12faf6Smrg 93781b12faf6Smrg # Make sure dlfiles contains only unique files that won't be dlpreopened 93790b0ce0bfSmrg old_dlfiles=$dlfiles 93801b12faf6Smrg dlfiles= 93811b12faf6Smrg for lib in $old_dlfiles; do 93821b12faf6Smrg case " $dlprefiles $dlfiles " in 93831b12faf6Smrg *" $lib "*) ;; 9384e35d4d8eSmrg *) func_append dlfiles " $lib" ;; 93851b12faf6Smrg esac 93861b12faf6Smrg done 93871b12faf6Smrg 93881b12faf6Smrg # Make sure dlprefiles contains only unique files 93890b0ce0bfSmrg old_dlprefiles=$dlprefiles 93901b12faf6Smrg dlprefiles= 93911b12faf6Smrg for lib in $old_dlprefiles; do 93921b12faf6Smrg case "$dlprefiles " in 93931b12faf6Smrg *" $lib "*) ;; 9394e35d4d8eSmrg *) func_append dlprefiles " $lib" ;; 93951b12faf6Smrg esac 93961b12faf6Smrg done 93971b12faf6Smrg 93980b0ce0bfSmrg if test yes = "$build_libtool_libs"; then 93991b12faf6Smrg if test -n "$rpath"; then 94001b12faf6Smrg case $host in 9401e35d4d8eSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) 94021b12faf6Smrg # these systems don't actually have a c library (as such)! 94031b12faf6Smrg ;; 94041b12faf6Smrg *-*-rhapsody* | *-*-darwin1.[012]) 94051b12faf6Smrg # Rhapsody C library is in the System framework 9406e35d4d8eSmrg func_append deplibs " System.ltframework" 94071b12faf6Smrg ;; 94081b12faf6Smrg *-*-netbsd*) 94091b12faf6Smrg # Don't link with libc until the a.out ld.so is fixed. 94101b12faf6Smrg ;; 94110b0ce0bfSmrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-midnightbsd*) 94121b12faf6Smrg # Do not include libc due to us having libc/libc_r. 94131b12faf6Smrg ;; 94141b12faf6Smrg *-*-sco3.2v5* | *-*-sco5v6*) 94151b12faf6Smrg # Causes problems with __ctype 94161b12faf6Smrg ;; 94171b12faf6Smrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 94181b12faf6Smrg # Compiler inserts libc in the correct place for threads to work 94191b12faf6Smrg ;; 94201b12faf6Smrg *) 94211b12faf6Smrg # Add libc to deplibs on all other systems if necessary. 94220b0ce0bfSmrg if test yes = "$build_libtool_need_lc"; then 9423e35d4d8eSmrg func_append deplibs " -lc" 94241b12faf6Smrg fi 94251b12faf6Smrg ;; 94261b12faf6Smrg esac 94271b12faf6Smrg fi 94281b12faf6Smrg 94291b12faf6Smrg # Transform deplibs into only deplibs that can be linked in shared. 94301b12faf6Smrg name_save=$name 94311b12faf6Smrg libname_save=$libname 94321b12faf6Smrg release_save=$release 94331b12faf6Smrg versuffix_save=$versuffix 94341b12faf6Smrg major_save=$major 94351b12faf6Smrg # I'm not sure if I'm treating the release correctly. I think 94361b12faf6Smrg # release should show up in the -l (ie -lgmp5) so we don't want to 94371b12faf6Smrg # add it in twice. Is that correct? 94380b0ce0bfSmrg release= 94390b0ce0bfSmrg versuffix= 94400b0ce0bfSmrg major= 94411b12faf6Smrg newdeplibs= 94421b12faf6Smrg droppeddeps=no 94431b12faf6Smrg case $deplibs_check_method in 94441b12faf6Smrg pass_all) 94451b12faf6Smrg # Don't check for shared/static. Everything works. 94461b12faf6Smrg # This might be a little naive. We might want to check 94471b12faf6Smrg # whether the library exists or not. But this is on 94481b12faf6Smrg # osf3 & osf4 and I'm not really sure... Just 94491b12faf6Smrg # implementing what was already the behavior. 94501b12faf6Smrg newdeplibs=$deplibs 94511b12faf6Smrg ;; 94521b12faf6Smrg test_compile) 94531b12faf6Smrg # This code stresses the "libraries are programs" paradigm to its 94541b12faf6Smrg # limits. Maybe even breaks it. We compile a program, linking it 94551b12faf6Smrg # against the deplibs as a proxy for the library. Then we can check 94561b12faf6Smrg # whether they linked in statically or dynamically with ldd. 94571b12faf6Smrg $opt_dry_run || $RM conftest.c 94581b12faf6Smrg cat > conftest.c <<EOF 94591b12faf6Smrg int main() { return 0; } 94601b12faf6SmrgEOF 94611b12faf6Smrg $opt_dry_run || $RM conftest 94621b12faf6Smrg if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then 94631b12faf6Smrg ldd_output=`ldd conftest` 94641b12faf6Smrg for i in $deplibs; do 94651b12faf6Smrg case $i in 94661b12faf6Smrg -l*) 94671b12faf6Smrg func_stripname -l '' "$i" 94681b12faf6Smrg name=$func_stripname_result 94690b0ce0bfSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 94701b12faf6Smrg case " $predeps $postdeps " in 94711b12faf6Smrg *" $i "*) 9472e35d4d8eSmrg func_append newdeplibs " $i" 94730b0ce0bfSmrg i= 94741b12faf6Smrg ;; 94751b12faf6Smrg esac 94761b12faf6Smrg fi 94770b0ce0bfSmrg if test -n "$i"; then 94781b12faf6Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 94791b12faf6Smrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 94801b12faf6Smrg set dummy $deplib_matches; shift 94811b12faf6Smrg deplib_match=$1 94820b0ce0bfSmrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then 9483e35d4d8eSmrg func_append newdeplibs " $i" 94841b12faf6Smrg else 94851b12faf6Smrg droppeddeps=yes 9486e35d4d8eSmrg echo 94871b12faf6Smrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 9488e35d4d8eSmrg echo "*** I have the capability to make that library automatically link in when" 9489e35d4d8eSmrg echo "*** you link to this library. But I can only do this if you have a" 9490e35d4d8eSmrg echo "*** shared version of the library, which I believe you do not have" 9491e35d4d8eSmrg echo "*** because a test_compile did reveal that the linker did not use it for" 9492e35d4d8eSmrg echo "*** its dynamic dependency list that programs get resolved with at runtime." 94931b12faf6Smrg fi 94941b12faf6Smrg fi 94951b12faf6Smrg ;; 94961b12faf6Smrg *) 9497e35d4d8eSmrg func_append newdeplibs " $i" 94981b12faf6Smrg ;; 94991b12faf6Smrg esac 95001b12faf6Smrg done 95011b12faf6Smrg else 95021b12faf6Smrg # Error occurred in the first compile. Let's try to salvage 95031b12faf6Smrg # the situation: Compile a separate program for each library. 95041b12faf6Smrg for i in $deplibs; do 95051b12faf6Smrg case $i in 95061b12faf6Smrg -l*) 95071b12faf6Smrg func_stripname -l '' "$i" 95081b12faf6Smrg name=$func_stripname_result 95091b12faf6Smrg $opt_dry_run || $RM conftest 95101b12faf6Smrg if $LTCC $LTCFLAGS -o conftest conftest.c $i; then 95111b12faf6Smrg ldd_output=`ldd conftest` 95120b0ce0bfSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 95131b12faf6Smrg case " $predeps $postdeps " in 95141b12faf6Smrg *" $i "*) 9515e35d4d8eSmrg func_append newdeplibs " $i" 95160b0ce0bfSmrg i= 95171b12faf6Smrg ;; 95181b12faf6Smrg esac 95191b12faf6Smrg fi 95200b0ce0bfSmrg if test -n "$i"; then 95211b12faf6Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 95221b12faf6Smrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 95231b12faf6Smrg set dummy $deplib_matches; shift 95241b12faf6Smrg deplib_match=$1 95250b0ce0bfSmrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then 9526e35d4d8eSmrg func_append newdeplibs " $i" 95271b12faf6Smrg else 95281b12faf6Smrg droppeddeps=yes 9529e35d4d8eSmrg echo 95301b12faf6Smrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 9531e35d4d8eSmrg echo "*** I have the capability to make that library automatically link in when" 9532e35d4d8eSmrg echo "*** you link to this library. But I can only do this if you have a" 9533e35d4d8eSmrg echo "*** shared version of the library, which you do not appear to have" 9534e35d4d8eSmrg echo "*** because a test_compile did reveal that the linker did not use this one" 9535e35d4d8eSmrg echo "*** as a dynamic dependency that programs can get resolved with at runtime." 95361b12faf6Smrg fi 95371b12faf6Smrg fi 95381b12faf6Smrg else 95391b12faf6Smrg droppeddeps=yes 9540e35d4d8eSmrg echo 95411b12faf6Smrg $ECHO "*** Warning! Library $i is needed by this library but I was not able to" 9542e35d4d8eSmrg echo "*** make it link in! You will probably need to install it or some" 9543e35d4d8eSmrg echo "*** library that it depends on before this library will be fully" 9544e35d4d8eSmrg echo "*** functional. Installing it before continuing would be even better." 95451b12faf6Smrg fi 95461b12faf6Smrg ;; 95471b12faf6Smrg *) 9548e35d4d8eSmrg func_append newdeplibs " $i" 95491b12faf6Smrg ;; 95501b12faf6Smrg esac 95511b12faf6Smrg done 95521b12faf6Smrg fi 95531b12faf6Smrg ;; 95541b12faf6Smrg file_magic*) 95551b12faf6Smrg set dummy $deplibs_check_method; shift 95561b12faf6Smrg file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 95571b12faf6Smrg for a_deplib in $deplibs; do 95581b12faf6Smrg case $a_deplib in 95591b12faf6Smrg -l*) 95601b12faf6Smrg func_stripname -l '' "$a_deplib" 95611b12faf6Smrg name=$func_stripname_result 95620b0ce0bfSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 95631b12faf6Smrg case " $predeps $postdeps " in 95641b12faf6Smrg *" $a_deplib "*) 9565e35d4d8eSmrg func_append newdeplibs " $a_deplib" 95660b0ce0bfSmrg a_deplib= 95671b12faf6Smrg ;; 95681b12faf6Smrg esac 95691b12faf6Smrg fi 95700b0ce0bfSmrg if test -n "$a_deplib"; then 95711b12faf6Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 9572e35d4d8eSmrg if test -n "$file_magic_glob"; then 9573e35d4d8eSmrg libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob` 9574e35d4d8eSmrg else 9575e35d4d8eSmrg libnameglob=$libname 9576e35d4d8eSmrg fi 95770b0ce0bfSmrg test yes = "$want_nocaseglob" && nocaseglob=`shopt -p nocaseglob` 95781b12faf6Smrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 95790b0ce0bfSmrg if test yes = "$want_nocaseglob"; then 9580e35d4d8eSmrg shopt -s nocaseglob 9581e35d4d8eSmrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 9582e35d4d8eSmrg $nocaseglob 9583e35d4d8eSmrg else 9584e35d4d8eSmrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 9585e35d4d8eSmrg fi 95861b12faf6Smrg for potent_lib in $potential_libs; do 95871b12faf6Smrg # Follow soft links. 95881b12faf6Smrg if ls -lLd "$potent_lib" 2>/dev/null | 95891b12faf6Smrg $GREP " -> " >/dev/null; then 95901b12faf6Smrg continue 95911b12faf6Smrg fi 95921b12faf6Smrg # The statement above tries to avoid entering an 95931b12faf6Smrg # endless loop below, in case of cyclic links. 95941b12faf6Smrg # We might still enter an endless loop, since a link 95951b12faf6Smrg # loop can be closed while we follow links, 95961b12faf6Smrg # but so what? 95970b0ce0bfSmrg potlib=$potent_lib 95981b12faf6Smrg while test -h "$potlib" 2>/dev/null; do 95990b0ce0bfSmrg potliblink=`ls -ld $potlib | $SED 's/.* -> //'` 96001b12faf6Smrg case $potliblink in 96010b0ce0bfSmrg [\\/]* | [A-Za-z]:[\\/]*) potlib=$potliblink;; 96020b0ce0bfSmrg *) potlib=`$ECHO "$potlib" | $SED 's|[^/]*$||'`"$potliblink";; 96031b12faf6Smrg esac 96041b12faf6Smrg done 96051b12faf6Smrg if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | 96061b12faf6Smrg $SED -e 10q | 96071b12faf6Smrg $EGREP "$file_magic_regex" > /dev/null; then 9608e35d4d8eSmrg func_append newdeplibs " $a_deplib" 96090b0ce0bfSmrg a_deplib= 96101b12faf6Smrg break 2 96111b12faf6Smrg fi 96121b12faf6Smrg done 96131b12faf6Smrg done 96141b12faf6Smrg fi 96150b0ce0bfSmrg if test -n "$a_deplib"; then 96161b12faf6Smrg droppeddeps=yes 9617e35d4d8eSmrg echo 96181b12faf6Smrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 9619e35d4d8eSmrg echo "*** I have the capability to make that library automatically link in when" 9620e35d4d8eSmrg echo "*** you link to this library. But I can only do this if you have a" 9621e35d4d8eSmrg echo "*** shared version of the library, which you do not appear to have" 9622e35d4d8eSmrg echo "*** because I did check the linker path looking for a file starting" 96230b0ce0bfSmrg if test -z "$potlib"; then 96241b12faf6Smrg $ECHO "*** with $libname but no candidates were found. (...for file magic test)" 96251b12faf6Smrg else 96261b12faf6Smrg $ECHO "*** with $libname and none of the candidates passed a file format test" 96271b12faf6Smrg $ECHO "*** using a file magic. Last file checked: $potlib" 96281b12faf6Smrg fi 96291b12faf6Smrg fi 96301b12faf6Smrg ;; 96311b12faf6Smrg *) 96321b12faf6Smrg # Add a -L argument. 9633e35d4d8eSmrg func_append newdeplibs " $a_deplib" 96341b12faf6Smrg ;; 96351b12faf6Smrg esac 96361b12faf6Smrg done # Gone through all deplibs. 96371b12faf6Smrg ;; 96381b12faf6Smrg match_pattern*) 96391b12faf6Smrg set dummy $deplibs_check_method; shift 96401b12faf6Smrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 96411b12faf6Smrg for a_deplib in $deplibs; do 96421b12faf6Smrg case $a_deplib in 96431b12faf6Smrg -l*) 96441b12faf6Smrg func_stripname -l '' "$a_deplib" 96451b12faf6Smrg name=$func_stripname_result 96460b0ce0bfSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 96471b12faf6Smrg case " $predeps $postdeps " in 96481b12faf6Smrg *" $a_deplib "*) 9649e35d4d8eSmrg func_append newdeplibs " $a_deplib" 96500b0ce0bfSmrg a_deplib= 96511b12faf6Smrg ;; 96521b12faf6Smrg esac 96531b12faf6Smrg fi 96540b0ce0bfSmrg if test -n "$a_deplib"; then 96551b12faf6Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 96561b12faf6Smrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 96571b12faf6Smrg potential_libs=`ls $i/$libname[.-]* 2>/dev/null` 96581b12faf6Smrg for potent_lib in $potential_libs; do 96590b0ce0bfSmrg potlib=$potent_lib # see symlink-check above in file_magic test 9660e35d4d8eSmrg if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ 96611b12faf6Smrg $EGREP "$match_pattern_regex" > /dev/null; then 9662e35d4d8eSmrg func_append newdeplibs " $a_deplib" 96630b0ce0bfSmrg a_deplib= 96641b12faf6Smrg break 2 96651b12faf6Smrg fi 96661b12faf6Smrg done 96671b12faf6Smrg done 96681b12faf6Smrg fi 96690b0ce0bfSmrg if test -n "$a_deplib"; then 96701b12faf6Smrg droppeddeps=yes 9671e35d4d8eSmrg echo 96721b12faf6Smrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 9673e35d4d8eSmrg echo "*** I have the capability to make that library automatically link in when" 9674e35d4d8eSmrg echo "*** you link to this library. But I can only do this if you have a" 9675e35d4d8eSmrg echo "*** shared version of the library, which you do not appear to have" 9676e35d4d8eSmrg echo "*** because I did check the linker path looking for a file starting" 96770b0ce0bfSmrg if test -z "$potlib"; then 96781b12faf6Smrg $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" 96791b12faf6Smrg else 96801b12faf6Smrg $ECHO "*** with $libname and none of the candidates passed a file format test" 96811b12faf6Smrg $ECHO "*** using a regex pattern. Last file checked: $potlib" 96821b12faf6Smrg fi 96831b12faf6Smrg fi 96841b12faf6Smrg ;; 96851b12faf6Smrg *) 96861b12faf6Smrg # Add a -L argument. 9687e35d4d8eSmrg func_append newdeplibs " $a_deplib" 96881b12faf6Smrg ;; 96891b12faf6Smrg esac 96901b12faf6Smrg done # Gone through all deplibs. 96911b12faf6Smrg ;; 96921b12faf6Smrg none | unknown | *) 96930b0ce0bfSmrg newdeplibs= 9694e35d4d8eSmrg tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` 96950b0ce0bfSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 96960b0ce0bfSmrg for i in $predeps $postdeps; do 96971b12faf6Smrg # can't use Xsed below, because $i might contain '/' 96980b0ce0bfSmrg tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s|$i||"` 96991b12faf6Smrg done 97001b12faf6Smrg fi 9701e35d4d8eSmrg case $tmp_deplibs in 9702e35d4d8eSmrg *[!\ \ ]*) 9703e35d4d8eSmrg echo 97040b0ce0bfSmrg if test none = "$deplibs_check_method"; then 9705e35d4d8eSmrg echo "*** Warning: inter-library dependencies are not supported in this platform." 97061b12faf6Smrg else 9707e35d4d8eSmrg echo "*** Warning: inter-library dependencies are not known to be supported." 97081b12faf6Smrg fi 9709e35d4d8eSmrg echo "*** All declared inter-library dependencies are being dropped." 97101b12faf6Smrg droppeddeps=yes 9711e35d4d8eSmrg ;; 9712e35d4d8eSmrg esac 97131b12faf6Smrg ;; 97141b12faf6Smrg esac 97151b12faf6Smrg versuffix=$versuffix_save 97161b12faf6Smrg major=$major_save 97171b12faf6Smrg release=$release_save 97181b12faf6Smrg libname=$libname_save 97191b12faf6Smrg name=$name_save 97201b12faf6Smrg 97211b12faf6Smrg case $host in 97221b12faf6Smrg *-*-rhapsody* | *-*-darwin1.[012]) 97231b12faf6Smrg # On Rhapsody replace the C library with the System framework 9724e35d4d8eSmrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` 97251b12faf6Smrg ;; 97261b12faf6Smrg esac 97271b12faf6Smrg 97280b0ce0bfSmrg if test yes = "$droppeddeps"; then 97290b0ce0bfSmrg if test yes = "$module"; then 9730e35d4d8eSmrg echo 9731e35d4d8eSmrg echo "*** Warning: libtool could not satisfy all declared inter-library" 97321b12faf6Smrg $ECHO "*** dependencies of module $libname. Therefore, libtool will create" 9733e35d4d8eSmrg echo "*** a static module, that should work as long as the dlopening" 9734e35d4d8eSmrg echo "*** application is linked with the -dlopen flag." 97351b12faf6Smrg if test -z "$global_symbol_pipe"; then 9736e35d4d8eSmrg echo 9737e35d4d8eSmrg echo "*** However, this would only work if libtool was able to extract symbol" 97380b0ce0bfSmrg echo "*** lists from a program, using 'nm' or equivalent, but libtool could" 9739e35d4d8eSmrg echo "*** not find such a program. So, this module is probably useless." 97400b0ce0bfSmrg echo "*** 'nm' from GNU binutils and a full rebuild may help." 97411b12faf6Smrg fi 97420b0ce0bfSmrg if test no = "$build_old_libs"; then 97430b0ce0bfSmrg oldlibs=$output_objdir/$libname.$libext 97441b12faf6Smrg build_libtool_libs=module 97451b12faf6Smrg build_old_libs=yes 97461b12faf6Smrg else 97471b12faf6Smrg build_libtool_libs=no 97481b12faf6Smrg fi 97491b12faf6Smrg else 9750e35d4d8eSmrg echo "*** The inter-library dependencies that have been dropped here will be" 9751e35d4d8eSmrg echo "*** automatically added whenever a program is linked with this library" 9752e35d4d8eSmrg echo "*** or is declared to -dlopen it." 97531b12faf6Smrg 97540b0ce0bfSmrg if test no = "$allow_undefined"; then 9755e35d4d8eSmrg echo 9756e35d4d8eSmrg echo "*** Since this library must not contain undefined symbols," 9757e35d4d8eSmrg echo "*** because either the platform does not support them or" 9758e35d4d8eSmrg echo "*** it was explicitly requested with -no-undefined," 9759e35d4d8eSmrg echo "*** libtool will only create a static version of it." 97600b0ce0bfSmrg if test no = "$build_old_libs"; then 97610b0ce0bfSmrg oldlibs=$output_objdir/$libname.$libext 97621b12faf6Smrg build_libtool_libs=module 97631b12faf6Smrg build_old_libs=yes 97641b12faf6Smrg else 97651b12faf6Smrg build_libtool_libs=no 97661b12faf6Smrg fi 97671b12faf6Smrg fi 97681b12faf6Smrg fi 97691b12faf6Smrg fi 97701b12faf6Smrg # Done checking deplibs! 97711b12faf6Smrg deplibs=$newdeplibs 97721b12faf6Smrg fi 97731b12faf6Smrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 97741b12faf6Smrg case $host in 97751b12faf6Smrg *-*-darwin*) 9776e35d4d8eSmrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 9777e35d4d8eSmrg new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 9778e35d4d8eSmrg deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 97791b12faf6Smrg ;; 97801b12faf6Smrg esac 97811b12faf6Smrg 97821b12faf6Smrg # move library search paths that coincide with paths to not yet 97831b12faf6Smrg # installed libraries to the beginning of the library search list 97841b12faf6Smrg new_libs= 97851b12faf6Smrg for path in $notinst_path; do 97861b12faf6Smrg case " $new_libs " in 97871b12faf6Smrg *" -L$path/$objdir "*) ;; 97881b12faf6Smrg *) 97891b12faf6Smrg case " $deplibs " in 97901b12faf6Smrg *" -L$path/$objdir "*) 9791e35d4d8eSmrg func_append new_libs " -L$path/$objdir" ;; 97921b12faf6Smrg esac 97931b12faf6Smrg ;; 97941b12faf6Smrg esac 97951b12faf6Smrg done 97961b12faf6Smrg for deplib in $deplibs; do 97971b12faf6Smrg case $deplib in 97981b12faf6Smrg -L*) 97991b12faf6Smrg case " $new_libs " in 98001b12faf6Smrg *" $deplib "*) ;; 9801e35d4d8eSmrg *) func_append new_libs " $deplib" ;; 98021b12faf6Smrg esac 98031b12faf6Smrg ;; 9804e35d4d8eSmrg *) func_append new_libs " $deplib" ;; 98051b12faf6Smrg esac 98061b12faf6Smrg done 98070b0ce0bfSmrg deplibs=$new_libs 98081b12faf6Smrg 98091b12faf6Smrg # All the library-specific variables (install_libdir is set above). 98101b12faf6Smrg library_names= 98111b12faf6Smrg old_library= 98121b12faf6Smrg dlname= 98131b12faf6Smrg 98141b12faf6Smrg # Test again, we may have decided not to build it any more 98150b0ce0bfSmrg if test yes = "$build_libtool_libs"; then 98160b0ce0bfSmrg # Remove $wl instances when linking with ld. 9817e35d4d8eSmrg # FIXME: should test the right _cmds variable. 9818e35d4d8eSmrg case $archive_cmds in 9819e35d4d8eSmrg *\$LD\ *) wl= ;; 9820e35d4d8eSmrg esac 98210b0ce0bfSmrg if test yes = "$hardcode_into_libs"; then 98221b12faf6Smrg # Hardcode the library paths 98231b12faf6Smrg hardcode_libdirs= 98241b12faf6Smrg dep_rpath= 98250b0ce0bfSmrg rpath=$finalize_rpath 98260b0ce0bfSmrg test relink = "$opt_mode" || rpath=$compile_rpath$rpath 98271b12faf6Smrg for libdir in $rpath; do 98281b12faf6Smrg if test -n "$hardcode_libdir_flag_spec"; then 98291b12faf6Smrg if test -n "$hardcode_libdir_separator"; then 9830e35d4d8eSmrg func_replace_sysroot "$libdir" 9831e35d4d8eSmrg libdir=$func_replace_sysroot_result 98321b12faf6Smrg if test -z "$hardcode_libdirs"; then 98330b0ce0bfSmrg hardcode_libdirs=$libdir 98341b12faf6Smrg else 98351b12faf6Smrg # Just accumulate the unique libdirs. 98361b12faf6Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 98371b12faf6Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 98381b12faf6Smrg ;; 98391b12faf6Smrg *) 9840e35d4d8eSmrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 98411b12faf6Smrg ;; 98421b12faf6Smrg esac 98431b12faf6Smrg fi 98441b12faf6Smrg else 98451b12faf6Smrg eval flag=\"$hardcode_libdir_flag_spec\" 9846e35d4d8eSmrg func_append dep_rpath " $flag" 98471b12faf6Smrg fi 98481b12faf6Smrg elif test -n "$runpath_var"; then 98491b12faf6Smrg case "$perm_rpath " in 98501b12faf6Smrg *" $libdir "*) ;; 9851e35d4d8eSmrg *) func_append perm_rpath " $libdir" ;; 98521b12faf6Smrg esac 98531b12faf6Smrg fi 98541b12faf6Smrg done 98551b12faf6Smrg # Substitute the hardcoded libdirs into the rpath. 98561b12faf6Smrg if test -n "$hardcode_libdir_separator" && 98571b12faf6Smrg test -n "$hardcode_libdirs"; then 98580b0ce0bfSmrg libdir=$hardcode_libdirs 9859e35d4d8eSmrg eval "dep_rpath=\"$hardcode_libdir_flag_spec\"" 98601b12faf6Smrg fi 98611b12faf6Smrg if test -n "$runpath_var" && test -n "$perm_rpath"; then 98621b12faf6Smrg # We should set the runpath_var. 98631b12faf6Smrg rpath= 98641b12faf6Smrg for dir in $perm_rpath; do 9865e35d4d8eSmrg func_append rpath "$dir:" 98661b12faf6Smrg done 98671b12faf6Smrg eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" 98681b12faf6Smrg fi 98691b12faf6Smrg test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" 98701b12faf6Smrg fi 987132b578d3Smrg 98720b0ce0bfSmrg shlibpath=$finalize_shlibpath 98730b0ce0bfSmrg test relink = "$opt_mode" || shlibpath=$compile_shlibpath$shlibpath 98741b12faf6Smrg if test -n "$shlibpath"; then 98751b12faf6Smrg eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" 98761b12faf6Smrg fi 987732b578d3Smrg 98781b12faf6Smrg # Get the real and link names of the library. 98791b12faf6Smrg eval shared_ext=\"$shrext_cmds\" 98801b12faf6Smrg eval library_names=\"$library_names_spec\" 98811b12faf6Smrg set dummy $library_names 98821b12faf6Smrg shift 98830b0ce0bfSmrg realname=$1 98841b12faf6Smrg shift 988532b578d3Smrg 98861b12faf6Smrg if test -n "$soname_spec"; then 98871b12faf6Smrg eval soname=\"$soname_spec\" 98881b12faf6Smrg else 98890b0ce0bfSmrg soname=$realname 98901b12faf6Smrg fi 98911b12faf6Smrg if test -z "$dlname"; then 98921b12faf6Smrg dlname=$soname 98931b12faf6Smrg fi 989432b578d3Smrg 98950b0ce0bfSmrg lib=$output_objdir/$realname 98961b12faf6Smrg linknames= 98971b12faf6Smrg for link 98981b12faf6Smrg do 9899e35d4d8eSmrg func_append linknames " $link" 99001b12faf6Smrg done 990132b578d3Smrg 99021b12faf6Smrg # Use standard objects if they are pic 9903e35d4d8eSmrg test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` 99041b12faf6Smrg test "X$libobjs" = "X " && libobjs= 990532b578d3Smrg 99061b12faf6Smrg delfiles= 99071b12faf6Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 99081b12faf6Smrg $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" 99090b0ce0bfSmrg export_symbols=$output_objdir/$libname.uexp 9910e35d4d8eSmrg func_append delfiles " $export_symbols" 99111b12faf6Smrg fi 991232b578d3Smrg 99131b12faf6Smrg orig_export_symbols= 99141b12faf6Smrg case $host_os in 99151b12faf6Smrg cygwin* | mingw* | cegcc*) 99161b12faf6Smrg if test -n "$export_symbols" && test -z "$export_symbols_regex"; then 99171b12faf6Smrg # exporting using user supplied symfile 99180b0ce0bfSmrg func_dll_def_p "$export_symbols" || { 99191b12faf6Smrg # and it's NOT already a .def file. Must figure out 99201b12faf6Smrg # which of the given symbols are data symbols and tag 99211b12faf6Smrg # them as such. So, trigger use of export_symbols_cmds. 99221b12faf6Smrg # export_symbols gets reassigned inside the "prepare 99231b12faf6Smrg # the list of exported symbols" if statement, so the 99241b12faf6Smrg # include_expsyms logic still works. 99250b0ce0bfSmrg orig_export_symbols=$export_symbols 99261b12faf6Smrg export_symbols= 99271b12faf6Smrg always_export_symbols=yes 99280b0ce0bfSmrg } 99291b12faf6Smrg fi 99301b12faf6Smrg ;; 99311b12faf6Smrg esac 993232b578d3Smrg 99331b12faf6Smrg # Prepare the list of exported symbols 99341b12faf6Smrg if test -z "$export_symbols"; then 99350b0ce0bfSmrg if test yes = "$always_export_symbols" || test -n "$export_symbols_regex"; then 99360b0ce0bfSmrg func_verbose "generating symbol list for '$libname.la'" 99370b0ce0bfSmrg export_symbols=$output_objdir/$libname.exp 99381b12faf6Smrg $opt_dry_run || $RM $export_symbols 99391b12faf6Smrg cmds=$export_symbols_cmds 99400b0ce0bfSmrg save_ifs=$IFS; IFS='~' 9941e35d4d8eSmrg for cmd1 in $cmds; do 99420b0ce0bfSmrg IFS=$save_ifs 9943e35d4d8eSmrg # Take the normal branch if the nm_file_list_spec branch 9944e35d4d8eSmrg # doesn't work or if tool conversion is not needed. 9945e35d4d8eSmrg case $nm_file_list_spec~$to_tool_file_cmd in 9946e35d4d8eSmrg *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) 9947e35d4d8eSmrg try_normal_branch=yes 9948e35d4d8eSmrg eval cmd=\"$cmd1\" 9949e35d4d8eSmrg func_len " $cmd" 9950e35d4d8eSmrg len=$func_len_result 9951e35d4d8eSmrg ;; 9952e35d4d8eSmrg *) 9953e35d4d8eSmrg try_normal_branch=no 9954e35d4d8eSmrg ;; 9955e35d4d8eSmrg esac 99560b0ce0bfSmrg if test yes = "$try_normal_branch" \ 9957e35d4d8eSmrg && { test "$len" -lt "$max_cmd_len" \ 9958e35d4d8eSmrg || test "$max_cmd_len" -le -1; } 9959e35d4d8eSmrg then 9960e35d4d8eSmrg func_show_eval "$cmd" 'exit $?' 9961e35d4d8eSmrg skipped_export=false 9962e35d4d8eSmrg elif test -n "$nm_file_list_spec"; then 9963e35d4d8eSmrg func_basename "$output" 9964e35d4d8eSmrg output_la=$func_basename_result 9965e35d4d8eSmrg save_libobjs=$libobjs 9966e35d4d8eSmrg save_output=$output 99670b0ce0bfSmrg output=$output_objdir/$output_la.nm 9968e35d4d8eSmrg func_to_tool_file "$output" 9969e35d4d8eSmrg libobjs=$nm_file_list_spec$func_to_tool_file_result 9970e35d4d8eSmrg func_append delfiles " $output" 9971e35d4d8eSmrg func_verbose "creating $NM input file list: $output" 9972e35d4d8eSmrg for obj in $save_libobjs; do 9973e35d4d8eSmrg func_to_tool_file "$obj" 9974e35d4d8eSmrg $ECHO "$func_to_tool_file_result" 9975e35d4d8eSmrg done > "$output" 9976e35d4d8eSmrg eval cmd=\"$cmd1\" 99771b12faf6Smrg func_show_eval "$cmd" 'exit $?' 9978e35d4d8eSmrg output=$save_output 9979e35d4d8eSmrg libobjs=$save_libobjs 99801b12faf6Smrg skipped_export=false 99811b12faf6Smrg else 99821b12faf6Smrg # The command line is too long to execute in one step. 99831b12faf6Smrg func_verbose "using reloadable object file for export list..." 99841b12faf6Smrg skipped_export=: 99851b12faf6Smrg # Break out early, otherwise skipped_export may be 99861b12faf6Smrg # set to false by a later but shorter cmd. 99871b12faf6Smrg break 99881b12faf6Smrg fi 99891b12faf6Smrg done 99900b0ce0bfSmrg IFS=$save_ifs 99910b0ce0bfSmrg if test -n "$export_symbols_regex" && test : != "$skipped_export"; then 99921b12faf6Smrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 99931b12faf6Smrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 99941b12faf6Smrg fi 99951b12faf6Smrg fi 999632b578d3Smrg fi 999732b578d3Smrg 99981b12faf6Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 99990b0ce0bfSmrg tmp_export_symbols=$export_symbols 100000b0ce0bfSmrg test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols 10001e35d4d8eSmrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 100021b12faf6Smrg fi 1000332b578d3Smrg 100040b0ce0bfSmrg if test : != "$skipped_export" && test -n "$orig_export_symbols"; then 100051b12faf6Smrg # The given exports_symbols file has to be filtered, so filter it. 100060b0ce0bfSmrg func_verbose "filter symbol list for '$libname.la' to tag DATA exports" 100071b12faf6Smrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 100080b0ce0bfSmrg # 's' commands, which not all seds can handle. GNU sed should be fine 100091b12faf6Smrg # though. Also, the filter scales superlinearly with the number of 100101b12faf6Smrg # global variables. join(1) would be nice here, but unfortunately 100111b12faf6Smrg # isn't a blessed tool. 100121b12faf6Smrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 10013e35d4d8eSmrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 100141b12faf6Smrg export_symbols=$output_objdir/$libname.def 100151b12faf6Smrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 100161b12faf6Smrg fi 1001732b578d3Smrg 100181b12faf6Smrg tmp_deplibs= 100191b12faf6Smrg for test_deplib in $deplibs; do 100201b12faf6Smrg case " $convenience " in 100211b12faf6Smrg *" $test_deplib "*) ;; 100221b12faf6Smrg *) 10023e35d4d8eSmrg func_append tmp_deplibs " $test_deplib" 100241b12faf6Smrg ;; 100251b12faf6Smrg esac 100261b12faf6Smrg done 100270b0ce0bfSmrg deplibs=$tmp_deplibs 1002832b578d3Smrg 100291b12faf6Smrg if test -n "$convenience"; then 100301b12faf6Smrg if test -n "$whole_archive_flag_spec" && 100310b0ce0bfSmrg test yes = "$compiler_needs_object" && 100321b12faf6Smrg test -z "$libobjs"; then 100331b12faf6Smrg # extract the archives, so we have objects to list. 100341b12faf6Smrg # TODO: could optimize this to just extract one archive. 100351b12faf6Smrg whole_archive_flag_spec= 100361b12faf6Smrg fi 100371b12faf6Smrg if test -n "$whole_archive_flag_spec"; then 100381b12faf6Smrg save_libobjs=$libobjs 100391b12faf6Smrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 100401b12faf6Smrg test "X$libobjs" = "X " && libobjs= 100411b12faf6Smrg else 100420b0ce0bfSmrg gentop=$output_objdir/${outputname}x 10043e35d4d8eSmrg func_append generated " $gentop" 1004432b578d3Smrg 100451b12faf6Smrg func_extract_archives $gentop $convenience 10046e35d4d8eSmrg func_append libobjs " $func_extract_archives_result" 100471b12faf6Smrg test "X$libobjs" = "X " && libobjs= 100481b12faf6Smrg fi 1004932b578d3Smrg fi 1005032b578d3Smrg 100510b0ce0bfSmrg if test yes = "$thread_safe" && test -n "$thread_safe_flag_spec"; then 100521b12faf6Smrg eval flag=\"$thread_safe_flag_spec\" 10053e35d4d8eSmrg func_append linker_flags " $flag" 1005432b578d3Smrg fi 1005532b578d3Smrg 100561b12faf6Smrg # Make a backup of the uninstalled library when relinking 100570b0ce0bfSmrg if test relink = "$opt_mode"; then 100581b12faf6Smrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? 100591b12faf6Smrg fi 1006032b578d3Smrg 100611b12faf6Smrg # Do each of the archive commands. 100620b0ce0bfSmrg if test yes = "$module" && test -n "$module_cmds"; then 100631b12faf6Smrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 100641b12faf6Smrg eval test_cmds=\"$module_expsym_cmds\" 100651b12faf6Smrg cmds=$module_expsym_cmds 100661b12faf6Smrg else 100671b12faf6Smrg eval test_cmds=\"$module_cmds\" 100681b12faf6Smrg cmds=$module_cmds 100691b12faf6Smrg fi 1007032b578d3Smrg else 100711b12faf6Smrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 100721b12faf6Smrg eval test_cmds=\"$archive_expsym_cmds\" 100731b12faf6Smrg cmds=$archive_expsym_cmds 100741b12faf6Smrg else 100751b12faf6Smrg eval test_cmds=\"$archive_cmds\" 100761b12faf6Smrg cmds=$archive_cmds 100771b12faf6Smrg fi 1007832b578d3Smrg fi 1007932b578d3Smrg 100800b0ce0bfSmrg if test : != "$skipped_export" && 100811b12faf6Smrg func_len " $test_cmds" && 100821b12faf6Smrg len=$func_len_result && 100831b12faf6Smrg test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 100841b12faf6Smrg : 100851b12faf6Smrg else 100861b12faf6Smrg # The command line is too long to link in one step, link piecewise 100871b12faf6Smrg # or, if using GNU ld and skipped_export is not :, use a linker 100881b12faf6Smrg # script. 1008932b578d3Smrg 100901b12faf6Smrg # Save the value of $output and $libobjs because we want to 100911b12faf6Smrg # use them later. If we have whole_archive_flag_spec, we 100921b12faf6Smrg # want to use save_libobjs as it was before 100931b12faf6Smrg # whole_archive_flag_spec was expanded, because we can't 100941b12faf6Smrg # assume the linker understands whole_archive_flag_spec. 100951b12faf6Smrg # This may have to be revisited, in case too many 100961b12faf6Smrg # convenience libraries get linked in and end up exceeding 100971b12faf6Smrg # the spec. 100981b12faf6Smrg if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then 100991b12faf6Smrg save_libobjs=$libobjs 101001b12faf6Smrg fi 101011b12faf6Smrg save_output=$output 10102e35d4d8eSmrg func_basename "$output" 10103e35d4d8eSmrg output_la=$func_basename_result 1010432b578d3Smrg 101051b12faf6Smrg # Clear the reloadable object creation command queue and 101061b12faf6Smrg # initialize k to one. 101071b12faf6Smrg test_cmds= 101081b12faf6Smrg concat_cmds= 101091b12faf6Smrg objlist= 101101b12faf6Smrg last_robj= 101111b12faf6Smrg k=1 101121b12faf6Smrg 101130b0ce0bfSmrg if test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then 101140b0ce0bfSmrg output=$output_objdir/$output_la.lnkscript 101151b12faf6Smrg func_verbose "creating GNU ld script: $output" 10116e35d4d8eSmrg echo 'INPUT (' > $output 101171b12faf6Smrg for obj in $save_libobjs 1011832b578d3Smrg do 10119e35d4d8eSmrg func_to_tool_file "$obj" 10120e35d4d8eSmrg $ECHO "$func_to_tool_file_result" >> $output 101211b12faf6Smrg done 10122e35d4d8eSmrg echo ')' >> $output 10123e35d4d8eSmrg func_append delfiles " $output" 10124e35d4d8eSmrg func_to_tool_file "$output" 10125e35d4d8eSmrg output=$func_to_tool_file_result 101260b0ce0bfSmrg elif test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then 101270b0ce0bfSmrg output=$output_objdir/$output_la.lnk 101281b12faf6Smrg func_verbose "creating linker input file list: $output" 101291b12faf6Smrg : > $output 101301b12faf6Smrg set x $save_libobjs 101311b12faf6Smrg shift 101321b12faf6Smrg firstobj= 101330b0ce0bfSmrg if test yes = "$compiler_needs_object"; then 101341b12faf6Smrg firstobj="$1 " 101351b12faf6Smrg shift 101361b12faf6Smrg fi 101371b12faf6Smrg for obj 101381b12faf6Smrg do 10139e35d4d8eSmrg func_to_tool_file "$obj" 10140e35d4d8eSmrg $ECHO "$func_to_tool_file_result" >> $output 101411b12faf6Smrg done 10142e35d4d8eSmrg func_append delfiles " $output" 10143e35d4d8eSmrg func_to_tool_file "$output" 10144e35d4d8eSmrg output=$firstobj\"$file_list_spec$func_to_tool_file_result\" 101451b12faf6Smrg else 101461b12faf6Smrg if test -n "$save_libobjs"; then 101471b12faf6Smrg func_verbose "creating reloadable object files..." 101480b0ce0bfSmrg output=$output_objdir/$output_la-$k.$objext 101491b12faf6Smrg eval test_cmds=\"$reload_cmds\" 101501b12faf6Smrg func_len " $test_cmds" 101511b12faf6Smrg len0=$func_len_result 101521b12faf6Smrg len=$len0 101531b12faf6Smrg 101541b12faf6Smrg # Loop over the list of objects to be linked. 101551b12faf6Smrg for obj in $save_libobjs 101561b12faf6Smrg do 101571b12faf6Smrg func_len " $obj" 101581b12faf6Smrg func_arith $len + $func_len_result 101591b12faf6Smrg len=$func_arith_result 101600b0ce0bfSmrg if test -z "$objlist" || 101611b12faf6Smrg test "$len" -lt "$max_cmd_len"; then 101621b12faf6Smrg func_append objlist " $obj" 101631b12faf6Smrg else 101641b12faf6Smrg # The command $test_cmds is almost too long, add a 101651b12faf6Smrg # command to the queue. 101660b0ce0bfSmrg if test 1 -eq "$k"; then 101671b12faf6Smrg # The first file doesn't have a previous command to add. 10168e35d4d8eSmrg reload_objs=$objlist 10169e35d4d8eSmrg eval concat_cmds=\"$reload_cmds\" 101701b12faf6Smrg else 101711b12faf6Smrg # All subsequent reloadable object files will link in 101721b12faf6Smrg # the last one created. 10173e35d4d8eSmrg reload_objs="$objlist $last_robj" 10174e35d4d8eSmrg eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" 101751b12faf6Smrg fi 101760b0ce0bfSmrg last_robj=$output_objdir/$output_la-$k.$objext 101771b12faf6Smrg func_arith $k + 1 101781b12faf6Smrg k=$func_arith_result 101790b0ce0bfSmrg output=$output_objdir/$output_la-$k.$objext 10180e35d4d8eSmrg objlist=" $obj" 101811b12faf6Smrg func_len " $last_robj" 101821b12faf6Smrg func_arith $len0 + $func_len_result 101831b12faf6Smrg len=$func_arith_result 101841b12faf6Smrg fi 101851b12faf6Smrg done 101861b12faf6Smrg # Handle the remaining objects by creating one last 101871b12faf6Smrg # reloadable object file. All subsequent reloadable object 101881b12faf6Smrg # files will link in the last one created. 101891b12faf6Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 10190e35d4d8eSmrg reload_objs="$objlist $last_robj" 101910b0ce0bfSmrg eval concat_cmds=\"\$concat_cmds$reload_cmds\" 101921b12faf6Smrg if test -n "$last_robj"; then 101930b0ce0bfSmrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 101941b12faf6Smrg fi 10195e35d4d8eSmrg func_append delfiles " $output" 1019632b578d3Smrg 101971b12faf6Smrg else 101981b12faf6Smrg output= 101991b12faf6Smrg fi 1020032b578d3Smrg 102010b0ce0bfSmrg ${skipped_export-false} && { 102020b0ce0bfSmrg func_verbose "generating symbol list for '$libname.la'" 102030b0ce0bfSmrg export_symbols=$output_objdir/$libname.exp 102041b12faf6Smrg $opt_dry_run || $RM $export_symbols 102051b12faf6Smrg libobjs=$output 102061b12faf6Smrg # Append the command to create the export file. 102071b12faf6Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 102081b12faf6Smrg eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" 102091b12faf6Smrg if test -n "$last_robj"; then 102101b12faf6Smrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 102111b12faf6Smrg fi 102120b0ce0bfSmrg } 1021332b578d3Smrg 102141b12faf6Smrg test -n "$save_libobjs" && 102151b12faf6Smrg func_verbose "creating a temporary reloadable object file: $output" 1021632b578d3Smrg 102171b12faf6Smrg # Loop through the commands generated above and execute them. 102180b0ce0bfSmrg save_ifs=$IFS; IFS='~' 102191b12faf6Smrg for cmd in $concat_cmds; do 102200b0ce0bfSmrg IFS=$save_ifs 102210b0ce0bfSmrg $opt_quiet || { 102220b0ce0bfSmrg func_quote_arg expand,pretty "$cmd" 102230b0ce0bfSmrg eval "func_echo $func_quote_arg_result" 102241b12faf6Smrg } 102251b12faf6Smrg $opt_dry_run || eval "$cmd" || { 102261b12faf6Smrg lt_exit=$? 102271b12faf6Smrg 102281b12faf6Smrg # Restore the uninstalled library and exit 102290b0ce0bfSmrg if test relink = "$opt_mode"; then 102301b12faf6Smrg ( cd "$output_objdir" && \ 102311b12faf6Smrg $RM "${realname}T" && \ 102321b12faf6Smrg $MV "${realname}U" "$realname" ) 102331b12faf6Smrg fi 1023432b578d3Smrg 102351b12faf6Smrg exit $lt_exit 102361b12faf6Smrg } 102371b12faf6Smrg done 102380b0ce0bfSmrg IFS=$save_ifs 1023932b578d3Smrg 102401b12faf6Smrg if test -n "$export_symbols_regex" && ${skipped_export-false}; then 102411b12faf6Smrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 102421b12faf6Smrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 1024332b578d3Smrg fi 1024432b578d3Smrg fi 1024532b578d3Smrg 102460b0ce0bfSmrg ${skipped_export-false} && { 102471b12faf6Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 102480b0ce0bfSmrg tmp_export_symbols=$export_symbols 102490b0ce0bfSmrg test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols 10250e35d4d8eSmrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 102511b12faf6Smrg fi 1025232b578d3Smrg 102531b12faf6Smrg if test -n "$orig_export_symbols"; then 102541b12faf6Smrg # The given exports_symbols file has to be filtered, so filter it. 102550b0ce0bfSmrg func_verbose "filter symbol list for '$libname.la' to tag DATA exports" 102561b12faf6Smrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 102570b0ce0bfSmrg # 's' commands, which not all seds can handle. GNU sed should be fine 102581b12faf6Smrg # though. Also, the filter scales superlinearly with the number of 102591b12faf6Smrg # global variables. join(1) would be nice here, but unfortunately 102601b12faf6Smrg # isn't a blessed tool. 102611b12faf6Smrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 10262e35d4d8eSmrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 102631b12faf6Smrg export_symbols=$output_objdir/$libname.def 102641b12faf6Smrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 102651b12faf6Smrg fi 102660b0ce0bfSmrg } 1026732b578d3Smrg 102681b12faf6Smrg libobjs=$output 102691b12faf6Smrg # Restore the value of output. 102701b12faf6Smrg output=$save_output 1027132b578d3Smrg 102721b12faf6Smrg if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then 102731b12faf6Smrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 102741b12faf6Smrg test "X$libobjs" = "X " && libobjs= 102751b12faf6Smrg fi 102761b12faf6Smrg # Expand the library linking commands again to reset the 102771b12faf6Smrg # value of $libobjs for piecewise linking. 1027832b578d3Smrg 102791b12faf6Smrg # Do each of the archive commands. 102800b0ce0bfSmrg if test yes = "$module" && test -n "$module_cmds"; then 102811b12faf6Smrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 102821b12faf6Smrg cmds=$module_expsym_cmds 102831b12faf6Smrg else 102841b12faf6Smrg cmds=$module_cmds 1028532b578d3Smrg fi 1028632b578d3Smrg else 102871b12faf6Smrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 102881b12faf6Smrg cmds=$archive_expsym_cmds 102891b12faf6Smrg else 102901b12faf6Smrg cmds=$archive_cmds 102911b12faf6Smrg fi 1029232b578d3Smrg fi 102931b12faf6Smrg fi 1029432b578d3Smrg 102951b12faf6Smrg if test -n "$delfiles"; then 102961b12faf6Smrg # Append the command to remove temporary files to $cmds. 102971b12faf6Smrg eval cmds=\"\$cmds~\$RM $delfiles\" 102981b12faf6Smrg fi 1029932b578d3Smrg 103001b12faf6Smrg # Add any objects from preloaded convenience libraries 103011b12faf6Smrg if test -n "$dlprefiles"; then 103020b0ce0bfSmrg gentop=$output_objdir/${outputname}x 10303e35d4d8eSmrg func_append generated " $gentop" 1030432b578d3Smrg 103051b12faf6Smrg func_extract_archives $gentop $dlprefiles 10306e35d4d8eSmrg func_append libobjs " $func_extract_archives_result" 103071b12faf6Smrg test "X$libobjs" = "X " && libobjs= 103081b12faf6Smrg fi 1030932b578d3Smrg 103100b0ce0bfSmrg save_ifs=$IFS; IFS='~' 103111b12faf6Smrg for cmd in $cmds; do 103120b0ce0bfSmrg IFS=$sp$nl 103131b12faf6Smrg eval cmd=\"$cmd\" 103140b0ce0bfSmrg IFS=$save_ifs 103150b0ce0bfSmrg $opt_quiet || { 103160b0ce0bfSmrg func_quote_arg expand,pretty "$cmd" 103170b0ce0bfSmrg eval "func_echo $func_quote_arg_result" 103181b12faf6Smrg } 103191b12faf6Smrg $opt_dry_run || eval "$cmd" || { 103201b12faf6Smrg lt_exit=$? 1032132b578d3Smrg 103221b12faf6Smrg # Restore the uninstalled library and exit 103230b0ce0bfSmrg if test relink = "$opt_mode"; then 103241b12faf6Smrg ( cd "$output_objdir" && \ 103251b12faf6Smrg $RM "${realname}T" && \ 103261b12faf6Smrg $MV "${realname}U" "$realname" ) 103271b12faf6Smrg fi 1032832b578d3Smrg 103291b12faf6Smrg exit $lt_exit 103301b12faf6Smrg } 103311b12faf6Smrg done 103320b0ce0bfSmrg IFS=$save_ifs 1033332b578d3Smrg 103341b12faf6Smrg # Restore the uninstalled library and exit 103350b0ce0bfSmrg if test relink = "$opt_mode"; then 103361b12faf6Smrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? 1033732b578d3Smrg 103381b12faf6Smrg if test -n "$convenience"; then 103391b12faf6Smrg if test -z "$whole_archive_flag_spec"; then 103401b12faf6Smrg func_show_eval '${RM}r "$gentop"' 103411b12faf6Smrg fi 103421b12faf6Smrg fi 1034332b578d3Smrg 103441b12faf6Smrg exit $EXIT_SUCCESS 103451b12faf6Smrg fi 103461b12faf6Smrg 103471b12faf6Smrg # Create links to the real library. 103481b12faf6Smrg for linkname in $linknames; do 103491b12faf6Smrg if test "$realname" != "$linkname"; then 103501b12faf6Smrg func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' 1035132b578d3Smrg fi 1035232b578d3Smrg done 1035332b578d3Smrg 103541b12faf6Smrg # If -module or -export-dynamic was specified, set the dlname. 103550b0ce0bfSmrg if test yes = "$module" || test yes = "$export_dynamic"; then 103561b12faf6Smrg # On all known operating systems, these are identical. 103570b0ce0bfSmrg dlname=$soname 103581b12faf6Smrg fi 103591b12faf6Smrg fi 1036032b578d3Smrg ;; 1036132b578d3Smrg 103621b12faf6Smrg obj) 103630b0ce0bfSmrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 103640b0ce0bfSmrg func_warning "'-dlopen' is ignored for objects" 103651b12faf6Smrg fi 1036632b578d3Smrg 103671b12faf6Smrg case " $deplibs" in 103681b12faf6Smrg *\ -l* | *\ -L*) 103690b0ce0bfSmrg func_warning "'-l' and '-L' are ignored for objects" ;; 1037032b578d3Smrg esac 1037132b578d3Smrg 103721b12faf6Smrg test -n "$rpath" && \ 103730b0ce0bfSmrg func_warning "'-rpath' is ignored for objects" 103741b12faf6Smrg 103751b12faf6Smrg test -n "$xrpath" && \ 103760b0ce0bfSmrg func_warning "'-R' is ignored for objects" 1037732b578d3Smrg 103781b12faf6Smrg test -n "$vinfo" && \ 103790b0ce0bfSmrg func_warning "'-version-info' is ignored for objects" 1038032b578d3Smrg 103811b12faf6Smrg test -n "$release" && \ 103820b0ce0bfSmrg func_warning "'-release' is ignored for objects" 103831b12faf6Smrg 103841b12faf6Smrg case $output in 103851b12faf6Smrg *.lo) 103861b12faf6Smrg test -n "$objs$old_deplibs" && \ 103870b0ce0bfSmrg func_fatal_error "cannot build library object '$output' from non-libtool objects" 103881b12faf6Smrg 103891b12faf6Smrg libobj=$output 103901b12faf6Smrg func_lo2o "$libobj" 103911b12faf6Smrg obj=$func_lo2o_result 1039232b578d3Smrg ;; 1039332b578d3Smrg *) 103941b12faf6Smrg libobj= 103950b0ce0bfSmrg obj=$output 1039632b578d3Smrg ;; 1039732b578d3Smrg esac 1039832b578d3Smrg 103991b12faf6Smrg # Delete the old objects. 104001b12faf6Smrg $opt_dry_run || $RM $obj $libobj 1040132b578d3Smrg 104021b12faf6Smrg # Objects from convenience libraries. This assumes 104031b12faf6Smrg # single-version convenience libraries. Whenever we create 104041b12faf6Smrg # different ones for PIC/non-PIC, this we'll have to duplicate 104051b12faf6Smrg # the extraction. 104061b12faf6Smrg reload_conv_objs= 104071b12faf6Smrg gentop= 104080b0ce0bfSmrg # if reload_cmds runs $LD directly, get rid of -Wl from 104090b0ce0bfSmrg # whole_archive_flag_spec and hope we can get by with turning comma 104100b0ce0bfSmrg # into space. 104110b0ce0bfSmrg case $reload_cmds in 104120b0ce0bfSmrg *\$LD[\ \$]*) wl= ;; 104130b0ce0bfSmrg esac 104141b12faf6Smrg if test -n "$convenience"; then 104151b12faf6Smrg if test -n "$whole_archive_flag_spec"; then 104161b12faf6Smrg eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" 104170b0ce0bfSmrg test -n "$wl" || tmp_whole_archive_flags=`$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` 104180b0ce0bfSmrg reload_conv_objs=$reload_objs\ $tmp_whole_archive_flags 104191b12faf6Smrg else 104200b0ce0bfSmrg gentop=$output_objdir/${obj}x 10421e35d4d8eSmrg func_append generated " $gentop" 1042232b578d3Smrg 104231b12faf6Smrg func_extract_archives $gentop $convenience 104241b12faf6Smrg reload_conv_objs="$reload_objs $func_extract_archives_result" 104251b12faf6Smrg fi 1042632b578d3Smrg fi 1042732b578d3Smrg 10428e35d4d8eSmrg # If we're not building shared, we need to use non_pic_objs 104290b0ce0bfSmrg test yes = "$build_libtool_libs" || libobjs=$non_pic_objects 10430e35d4d8eSmrg 104311b12faf6Smrg # Create the old-style object. 104320b0ce0bfSmrg reload_objs=$objs$old_deplibs' '`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; /\.lib$/d; $lo2o" | $NL2SP`' '$reload_conv_objs 1043332b578d3Smrg 104340b0ce0bfSmrg output=$obj 104351b12faf6Smrg func_execute_cmds "$reload_cmds" 'exit $?' 1043632b578d3Smrg 104371b12faf6Smrg # Exit if we aren't doing a library object file. 104381b12faf6Smrg if test -z "$libobj"; then 104391b12faf6Smrg if test -n "$gentop"; then 104401b12faf6Smrg func_show_eval '${RM}r "$gentop"' 104411b12faf6Smrg fi 104421b12faf6Smrg 104431b12faf6Smrg exit $EXIT_SUCCESS 1044432b578d3Smrg fi 104451b12faf6Smrg 104460b0ce0bfSmrg test yes = "$build_libtool_libs" || { 104471b12faf6Smrg if test -n "$gentop"; then 104481b12faf6Smrg func_show_eval '${RM}r "$gentop"' 104491b12faf6Smrg fi 104501b12faf6Smrg 104511b12faf6Smrg # Create an invalid libtool object if no PIC, so that we don't 104521b12faf6Smrg # accidentally link it into a program. 104531b12faf6Smrg # $show "echo timestamp > $libobj" 104541b12faf6Smrg # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? 104551b12faf6Smrg exit $EXIT_SUCCESS 104560b0ce0bfSmrg } 104571b12faf6Smrg 104580b0ce0bfSmrg if test -n "$pic_flag" || test default != "$pic_mode"; then 104591b12faf6Smrg # Only do commands if we really have different PIC objects. 104601b12faf6Smrg reload_objs="$libobjs $reload_conv_objs" 104610b0ce0bfSmrg output=$libobj 104621b12faf6Smrg func_execute_cmds "$reload_cmds" 'exit $?' 104631b12faf6Smrg fi 104641b12faf6Smrg 104651b12faf6Smrg if test -n "$gentop"; then 104661b12faf6Smrg func_show_eval '${RM}r "$gentop"' 104671b12faf6Smrg fi 104681b12faf6Smrg 104691b12faf6Smrg exit $EXIT_SUCCESS 1047032b578d3Smrg ;; 1047132b578d3Smrg 104721b12faf6Smrg prog) 104731b12faf6Smrg case $host in 104741b12faf6Smrg *cygwin*) func_stripname '' '.exe' "$output" 104751b12faf6Smrg output=$func_stripname_result.exe;; 104761b12faf6Smrg esac 104771b12faf6Smrg test -n "$vinfo" && \ 104780b0ce0bfSmrg func_warning "'-version-info' is ignored for programs" 1047932b578d3Smrg 104801b12faf6Smrg test -n "$release" && \ 104810b0ce0bfSmrg func_warning "'-release' is ignored for programs" 1048232b578d3Smrg 104830b0ce0bfSmrg $preload \ 104840b0ce0bfSmrg && test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \ 104850b0ce0bfSmrg && func_warning "'LT_INIT([dlopen])' not used. Assuming no dlopen support." 104861b12faf6Smrg 104871b12faf6Smrg case $host in 104881b12faf6Smrg *-*-rhapsody* | *-*-darwin1.[012]) 104891b12faf6Smrg # On Rhapsody replace the C library is the System framework 10490e35d4d8eSmrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` 10491e35d4d8eSmrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` 1049232b578d3Smrg ;; 104931b12faf6Smrg esac 1049432b578d3Smrg 104951b12faf6Smrg case $host in 104961b12faf6Smrg *-*-darwin*) 104971b12faf6Smrg # Don't allow lazy linking, it breaks C++ global constructors 104981b12faf6Smrg # But is supposedly fixed on 10.4 or later (yay!). 104990b0ce0bfSmrg if test CXX = "$tagname"; then 105001b12faf6Smrg case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 105011b12faf6Smrg 10.[0123]) 105020b0ce0bfSmrg func_append compile_command " $wl-bind_at_load" 105030b0ce0bfSmrg func_append finalize_command " $wl-bind_at_load" 105041b12faf6Smrg ;; 105051b12faf6Smrg esac 1050632b578d3Smrg fi 105071b12faf6Smrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 10508e35d4d8eSmrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 10509e35d4d8eSmrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 105101b12faf6Smrg ;; 105111b12faf6Smrg esac 1051232b578d3Smrg 1051332b578d3Smrg 105141b12faf6Smrg # move library search paths that coincide with paths to not yet 105151b12faf6Smrg # installed libraries to the beginning of the library search list 105161b12faf6Smrg new_libs= 105171b12faf6Smrg for path in $notinst_path; do 105181b12faf6Smrg case " $new_libs " in 105191b12faf6Smrg *" -L$path/$objdir "*) ;; 105201b12faf6Smrg *) 105211b12faf6Smrg case " $compile_deplibs " in 105221b12faf6Smrg *" -L$path/$objdir "*) 10523e35d4d8eSmrg func_append new_libs " -L$path/$objdir" ;; 1052432b578d3Smrg esac 105251b12faf6Smrg ;; 105261b12faf6Smrg esac 105271b12faf6Smrg done 105281b12faf6Smrg for deplib in $compile_deplibs; do 105291b12faf6Smrg case $deplib in 105301b12faf6Smrg -L*) 105311b12faf6Smrg case " $new_libs " in 105321b12faf6Smrg *" $deplib "*) ;; 10533e35d4d8eSmrg *) func_append new_libs " $deplib" ;; 1053432b578d3Smrg esac 105351b12faf6Smrg ;; 10536e35d4d8eSmrg *) func_append new_libs " $deplib" ;; 105371b12faf6Smrg esac 105381b12faf6Smrg done 105390b0ce0bfSmrg compile_deplibs=$new_libs 1054032b578d3Smrg 1054132b578d3Smrg 10542e35d4d8eSmrg func_append compile_command " $compile_deplibs" 10543e35d4d8eSmrg func_append finalize_command " $finalize_deplibs" 1054432b578d3Smrg 105451b12faf6Smrg if test -n "$rpath$xrpath"; then 105461b12faf6Smrg # If the user specified any rpath flags, then add them. 105471b12faf6Smrg for libdir in $rpath $xrpath; do 105481b12faf6Smrg # This is the magic to use -rpath. 105491b12faf6Smrg case "$finalize_rpath " in 105501b12faf6Smrg *" $libdir "*) ;; 10551e35d4d8eSmrg *) func_append finalize_rpath " $libdir" ;; 105521b12faf6Smrg esac 105531b12faf6Smrg done 105541b12faf6Smrg fi 1055532b578d3Smrg 105561b12faf6Smrg # Now hardcode the library paths 105571b12faf6Smrg rpath= 105581b12faf6Smrg hardcode_libdirs= 105591b12faf6Smrg for libdir in $compile_rpath $finalize_rpath; do 105601b12faf6Smrg if test -n "$hardcode_libdir_flag_spec"; then 105611b12faf6Smrg if test -n "$hardcode_libdir_separator"; then 105621b12faf6Smrg if test -z "$hardcode_libdirs"; then 105630b0ce0bfSmrg hardcode_libdirs=$libdir 105641b12faf6Smrg else 105651b12faf6Smrg # Just accumulate the unique libdirs. 105661b12faf6Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 105671b12faf6Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 105681b12faf6Smrg ;; 105691b12faf6Smrg *) 10570e35d4d8eSmrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 105711b12faf6Smrg ;; 105721b12faf6Smrg esac 105731b12faf6Smrg fi 1057432b578d3Smrg else 105751b12faf6Smrg eval flag=\"$hardcode_libdir_flag_spec\" 10576e35d4d8eSmrg func_append rpath " $flag" 1057732b578d3Smrg fi 105781b12faf6Smrg elif test -n "$runpath_var"; then 105791b12faf6Smrg case "$perm_rpath " in 105801b12faf6Smrg *" $libdir "*) ;; 10581e35d4d8eSmrg *) func_append perm_rpath " $libdir" ;; 105821b12faf6Smrg esac 105831b12faf6Smrg fi 105841b12faf6Smrg case $host in 105851b12faf6Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 105860b0ce0bfSmrg testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'` 105871b12faf6Smrg case :$dllsearchpath: in 105881b12faf6Smrg *":$libdir:"*) ;; 105891b12faf6Smrg ::) dllsearchpath=$libdir;; 10590e35d4d8eSmrg *) func_append dllsearchpath ":$libdir";; 105911b12faf6Smrg esac 105921b12faf6Smrg case :$dllsearchpath: in 105931b12faf6Smrg *":$testbindir:"*) ;; 105941b12faf6Smrg ::) dllsearchpath=$testbindir;; 10595e35d4d8eSmrg *) func_append dllsearchpath ":$testbindir";; 105961b12faf6Smrg esac 105971b12faf6Smrg ;; 105981b12faf6Smrg esac 105991b12faf6Smrg done 106001b12faf6Smrg # Substitute the hardcoded libdirs into the rpath. 106011b12faf6Smrg if test -n "$hardcode_libdir_separator" && 106021b12faf6Smrg test -n "$hardcode_libdirs"; then 106030b0ce0bfSmrg libdir=$hardcode_libdirs 106041b12faf6Smrg eval rpath=\" $hardcode_libdir_flag_spec\" 106051b12faf6Smrg fi 106060b0ce0bfSmrg compile_rpath=$rpath 1060732b578d3Smrg 106081b12faf6Smrg rpath= 106091b12faf6Smrg hardcode_libdirs= 106101b12faf6Smrg for libdir in $finalize_rpath; do 106111b12faf6Smrg if test -n "$hardcode_libdir_flag_spec"; then 106121b12faf6Smrg if test -n "$hardcode_libdir_separator"; then 106131b12faf6Smrg if test -z "$hardcode_libdirs"; then 106140b0ce0bfSmrg hardcode_libdirs=$libdir 106151b12faf6Smrg else 106161b12faf6Smrg # Just accumulate the unique libdirs. 106171b12faf6Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 106181b12faf6Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 106191b12faf6Smrg ;; 106201b12faf6Smrg *) 10621e35d4d8eSmrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 106221b12faf6Smrg ;; 106231b12faf6Smrg esac 106241b12faf6Smrg fi 1062532b578d3Smrg else 106261b12faf6Smrg eval flag=\"$hardcode_libdir_flag_spec\" 10627e35d4d8eSmrg func_append rpath " $flag" 1062832b578d3Smrg fi 106291b12faf6Smrg elif test -n "$runpath_var"; then 106301b12faf6Smrg case "$finalize_perm_rpath " in 106311b12faf6Smrg *" $libdir "*) ;; 10632e35d4d8eSmrg *) func_append finalize_perm_rpath " $libdir" ;; 106331b12faf6Smrg esac 1063432b578d3Smrg fi 106351b12faf6Smrg done 106361b12faf6Smrg # Substitute the hardcoded libdirs into the rpath. 106371b12faf6Smrg if test -n "$hardcode_libdir_separator" && 106381b12faf6Smrg test -n "$hardcode_libdirs"; then 106390b0ce0bfSmrg libdir=$hardcode_libdirs 106401b12faf6Smrg eval rpath=\" $hardcode_libdir_flag_spec\" 106411b12faf6Smrg fi 106420b0ce0bfSmrg finalize_rpath=$rpath 1064332b578d3Smrg 106440b0ce0bfSmrg if test -n "$libobjs" && test yes = "$build_old_libs"; then 106451b12faf6Smrg # Transform all the library objects into standard objects. 10646e35d4d8eSmrg compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 10647e35d4d8eSmrg finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 106481b12faf6Smrg fi 1064932b578d3Smrg 106500b0ce0bfSmrg func_generate_dlsyms "$outputname" "@PROGRAM@" false 1065132b578d3Smrg 106521b12faf6Smrg # template prelinking step 106531b12faf6Smrg if test -n "$prelink_cmds"; then 106541b12faf6Smrg func_execute_cmds "$prelink_cmds" 'exit $?' 106551b12faf6Smrg fi 1065632b578d3Smrg 106570b0ce0bfSmrg wrappers_required=: 106581b12faf6Smrg case $host in 10659e35d4d8eSmrg *cegcc* | *mingw32ce*) 10660e35d4d8eSmrg # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. 106610b0ce0bfSmrg wrappers_required=false 10662e35d4d8eSmrg ;; 106631b12faf6Smrg *cygwin* | *mingw* ) 106640b0ce0bfSmrg test yes = "$build_libtool_libs" || wrappers_required=false 106651b12faf6Smrg ;; 106661b12faf6Smrg *) 106670b0ce0bfSmrg if test no = "$need_relink" || test yes != "$build_libtool_libs"; then 106680b0ce0bfSmrg wrappers_required=false 106691b12faf6Smrg fi 106701b12faf6Smrg ;; 106711b12faf6Smrg esac 106720b0ce0bfSmrg $wrappers_required || { 106731b12faf6Smrg # Replace the output file specification. 10674e35d4d8eSmrg compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 106750b0ce0bfSmrg link_command=$compile_command$compile_rpath 1067632b578d3Smrg 106771b12faf6Smrg # We have no uninstalled library dependencies, so finalize right now. 106781b12faf6Smrg exit_status=0 106791b12faf6Smrg func_show_eval "$link_command" 'exit_status=$?' 1068032b578d3Smrg 10681e35d4d8eSmrg if test -n "$postlink_cmds"; then 10682e35d4d8eSmrg func_to_tool_file "$output" 10683e35d4d8eSmrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 10684e35d4d8eSmrg func_execute_cmds "$postlink_cmds" 'exit $?' 10685e35d4d8eSmrg fi 10686e35d4d8eSmrg 106871b12faf6Smrg # Delete the generated files. 106880b0ce0bfSmrg if test -f "$output_objdir/${outputname}S.$objext"; then 106890b0ce0bfSmrg func_show_eval '$RM "$output_objdir/${outputname}S.$objext"' 1069032b578d3Smrg fi 1069132b578d3Smrg 106921b12faf6Smrg exit $exit_status 106930b0ce0bfSmrg } 1069432b578d3Smrg 106951b12faf6Smrg if test -n "$compile_shlibpath$finalize_shlibpath"; then 106961b12faf6Smrg compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" 106971b12faf6Smrg fi 106981b12faf6Smrg if test -n "$finalize_shlibpath"; then 106991b12faf6Smrg finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" 107001b12faf6Smrg fi 1070132b578d3Smrg 107021b12faf6Smrg compile_var= 107031b12faf6Smrg finalize_var= 107041b12faf6Smrg if test -n "$runpath_var"; then 107051b12faf6Smrg if test -n "$perm_rpath"; then 107061b12faf6Smrg # We should set the runpath_var. 107071b12faf6Smrg rpath= 107081b12faf6Smrg for dir in $perm_rpath; do 10709e35d4d8eSmrg func_append rpath "$dir:" 107101b12faf6Smrg done 107111b12faf6Smrg compile_var="$runpath_var=\"$rpath\$$runpath_var\" " 1071232b578d3Smrg fi 107131b12faf6Smrg if test -n "$finalize_perm_rpath"; then 107141b12faf6Smrg # We should set the runpath_var. 107151b12faf6Smrg rpath= 107161b12faf6Smrg for dir in $finalize_perm_rpath; do 10717e35d4d8eSmrg func_append rpath "$dir:" 107181b12faf6Smrg done 107191b12faf6Smrg finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " 1072032b578d3Smrg fi 107211b12faf6Smrg fi 1072232b578d3Smrg 107230b0ce0bfSmrg if test yes = "$no_install"; then 107241b12faf6Smrg # We don't need to create a wrapper script. 107250b0ce0bfSmrg link_command=$compile_var$compile_command$compile_rpath 107261b12faf6Smrg # Replace the output file specification. 10727e35d4d8eSmrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 107281b12faf6Smrg # Delete the old output file. 107291b12faf6Smrg $opt_dry_run || $RM $output 107301b12faf6Smrg # Link the executable and exit 107311b12faf6Smrg func_show_eval "$link_command" 'exit $?' 10732e35d4d8eSmrg 10733e35d4d8eSmrg if test -n "$postlink_cmds"; then 10734e35d4d8eSmrg func_to_tool_file "$output" 10735e35d4d8eSmrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 10736e35d4d8eSmrg func_execute_cmds "$postlink_cmds" 'exit $?' 10737e35d4d8eSmrg fi 10738e35d4d8eSmrg 1073932b578d3Smrg exit $EXIT_SUCCESS 107401b12faf6Smrg fi 1074132b578d3Smrg 107420b0ce0bfSmrg case $hardcode_action,$fast_install in 107430b0ce0bfSmrg relink,*) 107440b0ce0bfSmrg # Fast installation is not supported 107450b0ce0bfSmrg link_command=$compile_var$compile_command$compile_rpath 107460b0ce0bfSmrg relink_command=$finalize_var$finalize_command$finalize_rpath 107471b12faf6Smrg 107480b0ce0bfSmrg func_warning "this platform does not like uninstalled shared libraries" 107490b0ce0bfSmrg func_warning "'$output' will be relinked during installation" 107500b0ce0bfSmrg ;; 107510b0ce0bfSmrg *,yes) 107520b0ce0bfSmrg link_command=$finalize_var$compile_command$finalize_rpath 107530b0ce0bfSmrg relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` 107540b0ce0bfSmrg ;; 107550b0ce0bfSmrg *,no) 107560b0ce0bfSmrg link_command=$compile_var$compile_command$compile_rpath 107570b0ce0bfSmrg relink_command=$finalize_var$finalize_command$finalize_rpath 107580b0ce0bfSmrg ;; 107590b0ce0bfSmrg *,needless) 107600b0ce0bfSmrg link_command=$finalize_var$compile_command$finalize_rpath 107610b0ce0bfSmrg relink_command= 107620b0ce0bfSmrg ;; 107630b0ce0bfSmrg esac 1076432b578d3Smrg 107651b12faf6Smrg # Replace the output file specification. 10766e35d4d8eSmrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` 1076732b578d3Smrg 107681b12faf6Smrg # Delete the old output files. 107691b12faf6Smrg $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname 1077032b578d3Smrg 107711b12faf6Smrg func_show_eval "$link_command" 'exit $?' 1077232b578d3Smrg 10773e35d4d8eSmrg if test -n "$postlink_cmds"; then 10774e35d4d8eSmrg func_to_tool_file "$output_objdir/$outputname" 10775e35d4d8eSmrg 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'` 10776e35d4d8eSmrg func_execute_cmds "$postlink_cmds" 'exit $?' 10777e35d4d8eSmrg fi 10778e35d4d8eSmrg 107791b12faf6Smrg # Now create the wrapper script. 107801b12faf6Smrg func_verbose "creating $output" 1078132b578d3Smrg 107821b12faf6Smrg # Quote the relink command for shipping. 107831b12faf6Smrg if test -n "$relink_command"; then 107841b12faf6Smrg # Preserve any variables that may affect compiler behavior 107851b12faf6Smrg for var in $variables_saved_for_relink; do 107861b12faf6Smrg if eval test -z \"\${$var+set}\"; then 107871b12faf6Smrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 107881b12faf6Smrg elif eval var_value=\$$var; test -z "$var_value"; then 107891b12faf6Smrg relink_command="$var=; export $var; $relink_command" 1079032b578d3Smrg else 107910b0ce0bfSmrg func_quote_arg pretty "$var_value" 107920b0ce0bfSmrg relink_command="$var=$func_quote_arg_result; export $var; $relink_command" 1079332b578d3Smrg fi 107941b12faf6Smrg done 107950b0ce0bfSmrg func_quote eval cd "`pwd`" 107960b0ce0bfSmrg func_quote_arg pretty,unquoted "($func_quote_result; $relink_command)" 107970b0ce0bfSmrg relink_command=$func_quote_arg_unquoted_result 107981b12faf6Smrg fi 107991b12faf6Smrg 108001b12faf6Smrg # Only actually do things if not in dry run mode. 108011b12faf6Smrg $opt_dry_run || { 108021b12faf6Smrg # win32 will think the script is a binary if it has 108031b12faf6Smrg # a .exe suffix, so we strip it off here. 108041b12faf6Smrg case $output in 108051b12faf6Smrg *.exe) func_stripname '' '.exe' "$output" 108061b12faf6Smrg output=$func_stripname_result ;; 108071b12faf6Smrg esac 108081b12faf6Smrg # test for cygwin because mv fails w/o .exe extensions 108091b12faf6Smrg case $host in 108101b12faf6Smrg *cygwin*) 108111b12faf6Smrg exeext=.exe 108121b12faf6Smrg func_stripname '' '.exe' "$outputname" 108131b12faf6Smrg outputname=$func_stripname_result ;; 108141b12faf6Smrg *) exeext= ;; 1081532b578d3Smrg esac 108161b12faf6Smrg case $host in 108171b12faf6Smrg *cygwin* | *mingw* ) 108181b12faf6Smrg func_dirname_and_basename "$output" "" "." 108191b12faf6Smrg output_name=$func_basename_result 108201b12faf6Smrg output_path=$func_dirname_result 108210b0ce0bfSmrg cwrappersource=$output_path/$objdir/lt-$output_name.c 108220b0ce0bfSmrg cwrapper=$output_path/$output_name.exe 108231b12faf6Smrg $RM $cwrappersource $cwrapper 108241b12faf6Smrg trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 108251b12faf6Smrg 108261b12faf6Smrg func_emit_cwrapperexe_src > $cwrappersource 108271b12faf6Smrg 108281b12faf6Smrg # The wrapper executable is built using the $host compiler, 108291b12faf6Smrg # because it contains $host paths and files. If cross- 108301b12faf6Smrg # compiling, it, like the target executable, must be 108311b12faf6Smrg # executed on the $host or under an emulation environment. 108321b12faf6Smrg $opt_dry_run || { 108331b12faf6Smrg $LTCC $LTCFLAGS -o $cwrapper $cwrappersource 108341b12faf6Smrg $STRIP $cwrapper 108351b12faf6Smrg } 1083632b578d3Smrg 108371b12faf6Smrg # Now, create the wrapper script for func_source use: 108381b12faf6Smrg func_ltwrapper_scriptname $cwrapper 108391b12faf6Smrg $RM $func_ltwrapper_scriptname_result 108401b12faf6Smrg trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 108411b12faf6Smrg $opt_dry_run || { 108421b12faf6Smrg # note: this script will not be executed, so do not chmod. 108430b0ce0bfSmrg if test "x$build" = "x$host"; then 108441b12faf6Smrg $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result 108451b12faf6Smrg else 108461b12faf6Smrg func_emit_wrapper no > $func_ltwrapper_scriptname_result 108471b12faf6Smrg fi 108481b12faf6Smrg } 108491b12faf6Smrg ;; 108501b12faf6Smrg * ) 108511b12faf6Smrg $RM $output 108521b12faf6Smrg trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 1085332b578d3Smrg 108541b12faf6Smrg func_emit_wrapper no > $output 108551b12faf6Smrg chmod +x $output 108561b12faf6Smrg ;; 108571b12faf6Smrg esac 108581b12faf6Smrg } 108591b12faf6Smrg exit $EXIT_SUCCESS 108601b12faf6Smrg ;; 108611b12faf6Smrg esac 1086232b578d3Smrg 108631b12faf6Smrg # See if we need to build an old-fashioned archive. 108641b12faf6Smrg for oldlib in $oldlibs; do 1086532b578d3Smrg 108660b0ce0bfSmrg case $build_libtool_libs in 108670b0ce0bfSmrg convenience) 108680b0ce0bfSmrg oldobjs="$libobjs_save $symfileobj" 108690b0ce0bfSmrg addlibs=$convenience 108701b12faf6Smrg build_libtool_libs=no 108710b0ce0bfSmrg ;; 108720b0ce0bfSmrg module) 108730b0ce0bfSmrg oldobjs=$libobjs_save 108740b0ce0bfSmrg addlibs=$old_convenience 108750b0ce0bfSmrg build_libtool_libs=no 108760b0ce0bfSmrg ;; 108770b0ce0bfSmrg *) 108781b12faf6Smrg oldobjs="$old_deplibs $non_pic_objects" 108790b0ce0bfSmrg $preload && test -f "$symfileobj" \ 108800b0ce0bfSmrg && func_append oldobjs " $symfileobj" 108810b0ce0bfSmrg addlibs=$old_convenience 108820b0ce0bfSmrg ;; 108830b0ce0bfSmrg esac 1088432b578d3Smrg 108851b12faf6Smrg if test -n "$addlibs"; then 108860b0ce0bfSmrg gentop=$output_objdir/${outputname}x 10887e35d4d8eSmrg func_append generated " $gentop" 1088832b578d3Smrg 108891b12faf6Smrg func_extract_archives $gentop $addlibs 10890e35d4d8eSmrg func_append oldobjs " $func_extract_archives_result" 108911b12faf6Smrg fi 1089232b578d3Smrg 108931b12faf6Smrg # Do each command in the archive commands. 108940b0ce0bfSmrg if test -n "$old_archive_from_new_cmds" && test yes = "$build_libtool_libs"; then 108951b12faf6Smrg cmds=$old_archive_from_new_cmds 108961b12faf6Smrg else 1089732b578d3Smrg 108981b12faf6Smrg # Add any objects from preloaded convenience libraries 108991b12faf6Smrg if test -n "$dlprefiles"; then 109000b0ce0bfSmrg gentop=$output_objdir/${outputname}x 10901e35d4d8eSmrg func_append generated " $gentop" 1090232b578d3Smrg 109031b12faf6Smrg func_extract_archives $gentop $dlprefiles 10904e35d4d8eSmrg func_append oldobjs " $func_extract_archives_result" 109051b12faf6Smrg fi 1090632b578d3Smrg 109071b12faf6Smrg # POSIX demands no paths to be encoded in archives. We have 109081b12faf6Smrg # to avoid creating archives with duplicate basenames if we 109091b12faf6Smrg # might have to extract them afterwards, e.g., when creating a 109101b12faf6Smrg # static archive out of a convenience library, or when linking 109111b12faf6Smrg # the entirety of a libtool archive into another (currently 109121b12faf6Smrg # not supported by libtool). 109131b12faf6Smrg if (for obj in $oldobjs 109141b12faf6Smrg do 109151b12faf6Smrg func_basename "$obj" 109161b12faf6Smrg $ECHO "$func_basename_result" 109171b12faf6Smrg done | sort | sort -uc >/dev/null 2>&1); then 109181b12faf6Smrg : 109191b12faf6Smrg else 10920e35d4d8eSmrg echo "copying selected object files to avoid basename conflicts..." 109210b0ce0bfSmrg gentop=$output_objdir/${outputname}x 10922e35d4d8eSmrg func_append generated " $gentop" 109231b12faf6Smrg func_mkdir_p "$gentop" 109241b12faf6Smrg save_oldobjs=$oldobjs 109251b12faf6Smrg oldobjs= 109261b12faf6Smrg counter=1 109271b12faf6Smrg for obj in $save_oldobjs 109281b12faf6Smrg do 109291b12faf6Smrg func_basename "$obj" 109300b0ce0bfSmrg objbase=$func_basename_result 109311b12faf6Smrg case " $oldobjs " in 109321b12faf6Smrg " ") oldobjs=$obj ;; 109331b12faf6Smrg *[\ /]"$objbase "*) 109341b12faf6Smrg while :; do 109351b12faf6Smrg # Make sure we don't pick an alternate name that also 109361b12faf6Smrg # overlaps. 109371b12faf6Smrg newobj=lt$counter-$objbase 109381b12faf6Smrg func_arith $counter + 1 109391b12faf6Smrg counter=$func_arith_result 109401b12faf6Smrg case " $oldobjs " in 109411b12faf6Smrg *[\ /]"$newobj "*) ;; 109421b12faf6Smrg *) if test ! -f "$gentop/$newobj"; then break; fi ;; 109431b12faf6Smrg esac 109441b12faf6Smrg done 109451b12faf6Smrg func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" 10946e35d4d8eSmrg func_append oldobjs " $gentop/$newobj" 109471b12faf6Smrg ;; 10948e35d4d8eSmrg *) func_append oldobjs " $obj" ;; 109491b12faf6Smrg esac 1095032b578d3Smrg done 1095132b578d3Smrg fi 10952e35d4d8eSmrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 10953e35d4d8eSmrg tool_oldlib=$func_to_tool_file_result 109541b12faf6Smrg eval cmds=\"$old_archive_cmds\" 1095532b578d3Smrg 109561b12faf6Smrg func_len " $cmds" 109571b12faf6Smrg len=$func_len_result 109581b12faf6Smrg if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 109591b12faf6Smrg cmds=$old_archive_cmds 10960e35d4d8eSmrg elif test -n "$archiver_list_spec"; then 10961e35d4d8eSmrg func_verbose "using command file archive linking..." 10962e35d4d8eSmrg for obj in $oldobjs 10963e35d4d8eSmrg do 10964e35d4d8eSmrg func_to_tool_file "$obj" 10965e35d4d8eSmrg $ECHO "$func_to_tool_file_result" 10966e35d4d8eSmrg done > $output_objdir/$libname.libcmd 10967e35d4d8eSmrg func_to_tool_file "$output_objdir/$libname.libcmd" 10968e35d4d8eSmrg oldobjs=" $archiver_list_spec$func_to_tool_file_result" 10969e35d4d8eSmrg cmds=$old_archive_cmds 109701b12faf6Smrg else 109711b12faf6Smrg # the command line is too long to link in one step, link in parts 109721b12faf6Smrg func_verbose "using piecewise archive linking..." 109731b12faf6Smrg save_RANLIB=$RANLIB 109741b12faf6Smrg RANLIB=: 109751b12faf6Smrg objlist= 109761b12faf6Smrg concat_cmds= 109771b12faf6Smrg save_oldobjs=$oldobjs 109781b12faf6Smrg oldobjs= 109791b12faf6Smrg # Is there a better way of finding the last object in the list? 109801b12faf6Smrg for obj in $save_oldobjs 109811b12faf6Smrg do 109821b12faf6Smrg last_oldobj=$obj 109831b12faf6Smrg done 109841b12faf6Smrg eval test_cmds=\"$old_archive_cmds\" 109851b12faf6Smrg func_len " $test_cmds" 109861b12faf6Smrg len0=$func_len_result 109871b12faf6Smrg len=$len0 109881b12faf6Smrg for obj in $save_oldobjs 109891b12faf6Smrg do 109901b12faf6Smrg func_len " $obj" 109911b12faf6Smrg func_arith $len + $func_len_result 109921b12faf6Smrg len=$func_arith_result 109931b12faf6Smrg func_append objlist " $obj" 109941b12faf6Smrg if test "$len" -lt "$max_cmd_len"; then 109951b12faf6Smrg : 109961b12faf6Smrg else 109971b12faf6Smrg # the above command should be used before it gets too long 109981b12faf6Smrg oldobjs=$objlist 109990b0ce0bfSmrg if test "$obj" = "$last_oldobj"; then 110001b12faf6Smrg RANLIB=$save_RANLIB 110011b12faf6Smrg fi 110021b12faf6Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 110030b0ce0bfSmrg eval concat_cmds=\"\$concat_cmds$old_archive_cmds\" 110041b12faf6Smrg objlist= 110051b12faf6Smrg len=$len0 110061b12faf6Smrg fi 110071b12faf6Smrg done 110081b12faf6Smrg RANLIB=$save_RANLIB 110091b12faf6Smrg oldobjs=$objlist 110100b0ce0bfSmrg if test -z "$oldobjs"; then 110111b12faf6Smrg eval cmds=\"\$concat_cmds\" 110121b12faf6Smrg else 110131b12faf6Smrg eval cmds=\"\$concat_cmds~\$old_archive_cmds\" 110141b12faf6Smrg fi 110151b12faf6Smrg fi 110161b12faf6Smrg fi 110171b12faf6Smrg func_execute_cmds "$cmds" 'exit $?' 1101832b578d3Smrg done 1101932b578d3Smrg 110201b12faf6Smrg test -n "$generated" && \ 110211b12faf6Smrg func_show_eval "${RM}r$generated" 1102232b578d3Smrg 110231b12faf6Smrg # Now create the libtool archive. 110241b12faf6Smrg case $output in 110251b12faf6Smrg *.la) 110261b12faf6Smrg old_library= 110270b0ce0bfSmrg test yes = "$build_old_libs" && old_library=$libname.$libext 110281b12faf6Smrg func_verbose "creating $output" 1102932b578d3Smrg 110301b12faf6Smrg # Preserve any variables that may affect compiler behavior 110311b12faf6Smrg for var in $variables_saved_for_relink; do 110321b12faf6Smrg if eval test -z \"\${$var+set}\"; then 110331b12faf6Smrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 110341b12faf6Smrg elif eval var_value=\$$var; test -z "$var_value"; then 110351b12faf6Smrg relink_command="$var=; export $var; $relink_command" 1103632b578d3Smrg else 110370b0ce0bfSmrg func_quote_arg pretty,unquoted "$var_value" 110380b0ce0bfSmrg relink_command="$var=$func_quote_arg_unquoted_result; export $var; $relink_command" 1103932b578d3Smrg fi 110401b12faf6Smrg done 110411b12faf6Smrg # Quote the link command for shipping. 110420b0ce0bfSmrg func_quote eval cd "`pwd`" 110430b0ce0bfSmrg relink_command="($func_quote_result; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" 110440b0ce0bfSmrg func_quote_arg pretty,unquoted "$relink_command" 110450b0ce0bfSmrg relink_command=$func_quote_arg_unquoted_result 110460b0ce0bfSmrg if test yes = "$hardcode_automatic"; then 110471b12faf6Smrg relink_command= 110481b12faf6Smrg fi 1104932b578d3Smrg 110501b12faf6Smrg # Only create the output if not a dry run. 110511b12faf6Smrg $opt_dry_run || { 110521b12faf6Smrg for installed in no yes; do 110530b0ce0bfSmrg if test yes = "$installed"; then 110541b12faf6Smrg if test -z "$install_libdir"; then 110551b12faf6Smrg break 110561b12faf6Smrg fi 110570b0ce0bfSmrg output=$output_objdir/${outputname}i 110581b12faf6Smrg # Replace all uninstalled libtool libraries with the installed ones 110591b12faf6Smrg newdependency_libs= 110601b12faf6Smrg for deplib in $dependency_libs; do 110611b12faf6Smrg case $deplib in 110621b12faf6Smrg *.la) 110631b12faf6Smrg func_basename "$deplib" 110640b0ce0bfSmrg name=$func_basename_result 11065e35d4d8eSmrg func_resolve_sysroot "$deplib" 110660b0ce0bfSmrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` 110671b12faf6Smrg test -z "$libdir" && \ 110680b0ce0bfSmrg func_fatal_error "'$deplib' is not a valid libtool archive" 11069e35d4d8eSmrg func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" 11070e35d4d8eSmrg ;; 11071e35d4d8eSmrg -L*) 11072e35d4d8eSmrg func_stripname -L '' "$deplib" 11073e35d4d8eSmrg func_replace_sysroot "$func_stripname_result" 11074e35d4d8eSmrg func_append newdependency_libs " -L$func_replace_sysroot_result" 110751b12faf6Smrg ;; 11076e35d4d8eSmrg -R*) 11077e35d4d8eSmrg func_stripname -R '' "$deplib" 11078e35d4d8eSmrg func_replace_sysroot "$func_stripname_result" 11079e35d4d8eSmrg func_append newdependency_libs " -R$func_replace_sysroot_result" 11080e35d4d8eSmrg ;; 11081e35d4d8eSmrg *) func_append newdependency_libs " $deplib" ;; 110821b12faf6Smrg esac 110831b12faf6Smrg done 110840b0ce0bfSmrg dependency_libs=$newdependency_libs 110851b12faf6Smrg newdlfiles= 110861b12faf6Smrg 110871b12faf6Smrg for lib in $dlfiles; do 110881b12faf6Smrg case $lib in 110891b12faf6Smrg *.la) 110901b12faf6Smrg func_basename "$lib" 110910b0ce0bfSmrg name=$func_basename_result 110920b0ce0bfSmrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 110931b12faf6Smrg test -z "$libdir" && \ 110940b0ce0bfSmrg func_fatal_error "'$lib' is not a valid libtool archive" 11095e35d4d8eSmrg func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" 110961b12faf6Smrg ;; 11097e35d4d8eSmrg *) func_append newdlfiles " $lib" ;; 110981b12faf6Smrg esac 110991b12faf6Smrg done 111000b0ce0bfSmrg dlfiles=$newdlfiles 111011b12faf6Smrg newdlprefiles= 111021b12faf6Smrg for lib in $dlprefiles; do 111031b12faf6Smrg case $lib in 111041b12faf6Smrg *.la) 111051b12faf6Smrg # Only pass preopened files to the pseudo-archive (for 111061b12faf6Smrg # eventual linking with the app. that links it) if we 111071b12faf6Smrg # didn't already link the preopened objects directly into 111081b12faf6Smrg # the library: 111091b12faf6Smrg func_basename "$lib" 111100b0ce0bfSmrg name=$func_basename_result 111110b0ce0bfSmrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 111121b12faf6Smrg test -z "$libdir" && \ 111130b0ce0bfSmrg func_fatal_error "'$lib' is not a valid libtool archive" 11114e35d4d8eSmrg func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" 111151b12faf6Smrg ;; 111161b12faf6Smrg esac 111171b12faf6Smrg done 111180b0ce0bfSmrg dlprefiles=$newdlprefiles 111191b12faf6Smrg else 111201b12faf6Smrg newdlfiles= 111211b12faf6Smrg for lib in $dlfiles; do 111221b12faf6Smrg case $lib in 111230b0ce0bfSmrg [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; 111241b12faf6Smrg *) abs=`pwd`"/$lib" ;; 111251b12faf6Smrg esac 11126e35d4d8eSmrg func_append newdlfiles " $abs" 111271b12faf6Smrg done 111280b0ce0bfSmrg dlfiles=$newdlfiles 111291b12faf6Smrg newdlprefiles= 111301b12faf6Smrg for lib in $dlprefiles; do 111311b12faf6Smrg case $lib in 111320b0ce0bfSmrg [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; 111331b12faf6Smrg *) abs=`pwd`"/$lib" ;; 111341b12faf6Smrg esac 11135e35d4d8eSmrg func_append newdlprefiles " $abs" 111361b12faf6Smrg done 111370b0ce0bfSmrg dlprefiles=$newdlprefiles 111381b12faf6Smrg fi 111391b12faf6Smrg $RM $output 111401b12faf6Smrg # place dlname in correct position for cygwin 11141e35d4d8eSmrg # In fact, it would be nice if we could use this code for all target 11142e35d4d8eSmrg # systems that can't hard-code library paths into their executables 11143e35d4d8eSmrg # and that have no shared library path variable independent of PATH, 11144e35d4d8eSmrg # but it turns out we can't easily determine that from inspecting 11145e35d4d8eSmrg # libtool variables, so we have to hard-code the OSs to which it 11146e35d4d8eSmrg # applies here; at the moment, that means platforms that use the PE 11147e35d4d8eSmrg # object format with DLL files. See the long comment at the top of 11148e35d4d8eSmrg # tests/bindir.at for full details. 111491b12faf6Smrg tdlname=$dlname 111501b12faf6Smrg case $host,$output,$installed,$module,$dlname in 11151e35d4d8eSmrg *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) 11152e35d4d8eSmrg # If a -bindir argument was supplied, place the dll there. 111530b0ce0bfSmrg if test -n "$bindir"; then 11154e35d4d8eSmrg func_relative_path "$install_libdir" "$bindir" 111550b0ce0bfSmrg tdlname=$func_relative_path_result/$dlname 11156e35d4d8eSmrg else 11157e35d4d8eSmrg # Otherwise fall back on heuristic. 11158e35d4d8eSmrg tdlname=../bin/$dlname 11159e35d4d8eSmrg fi 11160e35d4d8eSmrg ;; 111611b12faf6Smrg esac 111621b12faf6Smrg $ECHO > $output "\ 111631b12faf6Smrg# $outputname - a libtool library file 111640b0ce0bfSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 111651b12faf6Smrg# 111661b12faf6Smrg# Please DO NOT delete this file! 111671b12faf6Smrg# It is necessary for linking the library. 1116832b578d3Smrg 111691b12faf6Smrg# The name that we can dlopen(3). 111701b12faf6Smrgdlname='$tdlname' 1117132b578d3Smrg 111721b12faf6Smrg# Names of this library. 111731b12faf6Smrglibrary_names='$library_names' 1117432b578d3Smrg 111751b12faf6Smrg# The name of the static archive. 111761b12faf6Smrgold_library='$old_library' 1117732b578d3Smrg 111780b0ce0bfSmrg# Linker flags that cannot go in dependency_libs. 111791b12faf6Smrginherited_linker_flags='$new_inherited_linker_flags' 1118032b578d3Smrg 111811b12faf6Smrg# Libraries that this one depends upon. 111821b12faf6Smrgdependency_libs='$dependency_libs' 1118332b578d3Smrg 111841b12faf6Smrg# Names of additional weak libraries provided by this library 111851b12faf6Smrgweak_library_names='$weak_libs' 1118632b578d3Smrg 111871b12faf6Smrg# Version information for $libname. 111881b12faf6Smrgcurrent=$current 111891b12faf6Smrgage=$age 111901b12faf6Smrgrevision=$revision 1119132b578d3Smrg 111921b12faf6Smrg# Is this an already installed library? 111931b12faf6Smrginstalled=$installed 1119432b578d3Smrg 111951b12faf6Smrg# Should we warn about portability when linking against -modules? 111961b12faf6Smrgshouldnotlink=$module 1119732b578d3Smrg 111981b12faf6Smrg# Files to dlopen/dlpreopen 111991b12faf6Smrgdlopen='$dlfiles' 112001b12faf6Smrgdlpreopen='$dlprefiles' 1120132b578d3Smrg 112021b12faf6Smrg# Directory that this library needs to be installed in: 112031b12faf6Smrglibdir='$install_libdir'" 112040b0ce0bfSmrg if test no,yes = "$installed,$need_relink"; then 112051b12faf6Smrg $ECHO >> $output "\ 112061b12faf6Smrgrelink_command=\"$relink_command\"" 112071b12faf6Smrg fi 112081b12faf6Smrg done 112091b12faf6Smrg } 1121032b578d3Smrg 112111b12faf6Smrg # Do a symbolic link so that the libtool archive can be found in 112121b12faf6Smrg # LD_LIBRARY_PATH before the program is installed. 112131b12faf6Smrg func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' 112141b12faf6Smrg ;; 112151b12faf6Smrg esac 112161b12faf6Smrg exit $EXIT_SUCCESS 112171b12faf6Smrg} 1121832b578d3Smrg 112190b0ce0bfSmrgif test link = "$opt_mode" || test relink = "$opt_mode"; then 112200b0ce0bfSmrg func_mode_link ${1+"$@"} 112210b0ce0bfSmrgfi 1122232b578d3Smrg 1122332b578d3Smrg 112241b12faf6Smrg# func_mode_uninstall arg... 112251b12faf6Smrgfunc_mode_uninstall () 112261b12faf6Smrg{ 112270b0ce0bfSmrg $debug_cmd 112280b0ce0bfSmrg 112290b0ce0bfSmrg RM=$nonopt 1123032b578d3Smrg files= 112310b0ce0bfSmrg rmforce=false 1123232b578d3Smrg exit_status=0 1123332b578d3Smrg 1123432b578d3Smrg # This variable tells wrapper scripts just to set variables rather 1123532b578d3Smrg # than running their programs. 112360b0ce0bfSmrg libtool_install_magic=$magic 1123732b578d3Smrg 1123832b578d3Smrg for arg 1123932b578d3Smrg do 1124032b578d3Smrg case $arg in 112410b0ce0bfSmrg -f) func_append RM " $arg"; rmforce=: ;; 11242e35d4d8eSmrg -*) func_append RM " $arg" ;; 11243e35d4d8eSmrg *) func_append files " $arg" ;; 1124432b578d3Smrg esac 1124532b578d3Smrg done 1124632b578d3Smrg 112471b12faf6Smrg test -z "$RM" && \ 112481b12faf6Smrg func_fatal_help "you must specify an RM program" 1124932b578d3Smrg 1125032b578d3Smrg rmdirs= 1125132b578d3Smrg 1125232b578d3Smrg for file in $files; do 112531b12faf6Smrg func_dirname "$file" "" "." 112540b0ce0bfSmrg dir=$func_dirname_result 112550b0ce0bfSmrg if test . = "$dir"; then 112560b0ce0bfSmrg odir=$objdir 1125732b578d3Smrg else 112580b0ce0bfSmrg odir=$dir/$objdir 1125932b578d3Smrg fi 112601b12faf6Smrg func_basename "$file" 112610b0ce0bfSmrg name=$func_basename_result 112620b0ce0bfSmrg test uninstall = "$opt_mode" && odir=$dir 1126332b578d3Smrg 11264e35d4d8eSmrg # Remember odir for removal later, being careful to avoid duplicates 112650b0ce0bfSmrg if test clean = "$opt_mode"; then 1126632b578d3Smrg case " $rmdirs " in 11267e35d4d8eSmrg *" $odir "*) ;; 11268e35d4d8eSmrg *) func_append rmdirs " $odir" ;; 1126932b578d3Smrg esac 1127032b578d3Smrg fi 1127132b578d3Smrg 1127232b578d3Smrg # Don't error if the file doesn't exist and rm -f was used. 112731b12faf6Smrg if { test -L "$file"; } >/dev/null 2>&1 || 112741b12faf6Smrg { test -h "$file"; } >/dev/null 2>&1 || 112751b12faf6Smrg test -f "$file"; then 1127632b578d3Smrg : 1127732b578d3Smrg elif test -d "$file"; then 1127832b578d3Smrg exit_status=1 1127932b578d3Smrg continue 112800b0ce0bfSmrg elif $rmforce; then 1128132b578d3Smrg continue 1128232b578d3Smrg fi 1128332b578d3Smrg 112840b0ce0bfSmrg rmfiles=$file 1128532b578d3Smrg 1128632b578d3Smrg case $name in 1128732b578d3Smrg *.la) 1128832b578d3Smrg # Possibly a libtool archive, so verify it. 112891b12faf6Smrg if func_lalib_p "$file"; then 112901b12faf6Smrg func_source $dir/$name 1129132b578d3Smrg 1129232b578d3Smrg # Delete the libtool libraries and symlinks. 1129332b578d3Smrg for n in $library_names; do 11294e35d4d8eSmrg func_append rmfiles " $odir/$n" 1129532b578d3Smrg done 11296e35d4d8eSmrg test -n "$old_library" && func_append rmfiles " $odir/$old_library" 1129732b578d3Smrg 112980b0ce0bfSmrg case $opt_mode in 1129932b578d3Smrg clean) 11300e35d4d8eSmrg case " $library_names " in 1130132b578d3Smrg *" $dlname "*) ;; 11302e35d4d8eSmrg *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; 1130332b578d3Smrg esac 11304e35d4d8eSmrg test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" 1130532b578d3Smrg ;; 1130632b578d3Smrg uninstall) 1130732b578d3Smrg if test -n "$library_names"; then 1130832b578d3Smrg # Do each command in the postuninstall commands. 113090b0ce0bfSmrg func_execute_cmds "$postuninstall_cmds" '$rmforce || exit_status=1' 1131032b578d3Smrg fi 1131132b578d3Smrg 1131232b578d3Smrg if test -n "$old_library"; then 1131332b578d3Smrg # Do each command in the old_postuninstall commands. 113140b0ce0bfSmrg func_execute_cmds "$old_postuninstall_cmds" '$rmforce || exit_status=1' 1131532b578d3Smrg fi 1131632b578d3Smrg # FIXME: should reinstall the best remaining shared library. 1131732b578d3Smrg ;; 1131832b578d3Smrg esac 1131932b578d3Smrg fi 1132032b578d3Smrg ;; 1132132b578d3Smrg 1132232b578d3Smrg *.lo) 1132332b578d3Smrg # Possibly a libtool object, so verify it. 113241b12faf6Smrg if func_lalib_p "$file"; then 1132532b578d3Smrg 1132632b578d3Smrg # Read the .lo file 113271b12faf6Smrg func_source $dir/$name 1132832b578d3Smrg 1132932b578d3Smrg # Add PIC object to the list of files to remove. 113300b0ce0bfSmrg if test -n "$pic_object" && test none != "$pic_object"; then 11331e35d4d8eSmrg func_append rmfiles " $dir/$pic_object" 1133232b578d3Smrg fi 1133332b578d3Smrg 1133432b578d3Smrg # Add non-PIC object to the list of files to remove. 113350b0ce0bfSmrg if test -n "$non_pic_object" && test none != "$non_pic_object"; then 11336e35d4d8eSmrg func_append rmfiles " $dir/$non_pic_object" 1133732b578d3Smrg fi 1133832b578d3Smrg fi 1133932b578d3Smrg ;; 1134032b578d3Smrg 1134132b578d3Smrg *) 113420b0ce0bfSmrg if test clean = "$opt_mode"; then 1134332b578d3Smrg noexename=$name 1134432b578d3Smrg case $file in 1134532b578d3Smrg *.exe) 113461b12faf6Smrg func_stripname '' '.exe' "$file" 113471b12faf6Smrg file=$func_stripname_result 113481b12faf6Smrg func_stripname '' '.exe' "$name" 113491b12faf6Smrg noexename=$func_stripname_result 1135032b578d3Smrg # $file with .exe has already been added to rmfiles, 1135132b578d3Smrg # add $file without .exe 11352e35d4d8eSmrg func_append rmfiles " $file" 1135332b578d3Smrg ;; 1135432b578d3Smrg esac 1135532b578d3Smrg # Do a test to see if this is a libtool program. 113561b12faf6Smrg if func_ltwrapper_p "$file"; then 113571b12faf6Smrg if func_ltwrapper_executable_p "$file"; then 113581b12faf6Smrg func_ltwrapper_scriptname "$file" 113591b12faf6Smrg relink_command= 113601b12faf6Smrg func_source $func_ltwrapper_scriptname_result 11361e35d4d8eSmrg func_append rmfiles " $func_ltwrapper_scriptname_result" 113621b12faf6Smrg else 113631b12faf6Smrg relink_command= 113641b12faf6Smrg func_source $dir/$noexename 113651b12faf6Smrg fi 1136632b578d3Smrg 1136732b578d3Smrg # note $name still contains .exe if it was in $file originally 1136832b578d3Smrg # as does the version of $file that was added into $rmfiles 113690b0ce0bfSmrg func_append rmfiles " $odir/$name $odir/${name}S.$objext" 113700b0ce0bfSmrg if test yes = "$fast_install" && test -n "$relink_command"; then 11371e35d4d8eSmrg func_append rmfiles " $odir/lt-$name" 1137232b578d3Smrg fi 113730b0ce0bfSmrg if test "X$noexename" != "X$name"; then 113740b0ce0bfSmrg func_append rmfiles " $odir/lt-$noexename.c" 1137532b578d3Smrg fi 1137632b578d3Smrg fi 1137732b578d3Smrg fi 1137832b578d3Smrg ;; 1137932b578d3Smrg esac 113801b12faf6Smrg func_show_eval "$RM $rmfiles" 'exit_status=1' 1138132b578d3Smrg done 1138232b578d3Smrg 113830b0ce0bfSmrg # Try to remove the $objdir's in the directories where we deleted files 1138432b578d3Smrg for dir in $rmdirs; do 1138532b578d3Smrg if test -d "$dir"; then 113861b12faf6Smrg func_show_eval "rmdir $dir >/dev/null 2>&1" 1138732b578d3Smrg fi 1138832b578d3Smrg done 1138932b578d3Smrg 1139032b578d3Smrg exit $exit_status 113911b12faf6Smrg} 1139232b578d3Smrg 113930b0ce0bfSmrgif test uninstall = "$opt_mode" || test clean = "$opt_mode"; then 113940b0ce0bfSmrg func_mode_uninstall ${1+"$@"} 113950b0ce0bfSmrgfi 1139632b578d3Smrg 11397e35d4d8eSmrgtest -z "$opt_mode" && { 113980b0ce0bfSmrg help=$generic_help 113991b12faf6Smrg func_fatal_help "you must specify a MODE" 114001b12faf6Smrg} 114011b12faf6Smrg 114021b12faf6Smrgtest -z "$exec_cmd" && \ 114030b0ce0bfSmrg func_fatal_help "invalid operation mode '$opt_mode'" 1140432b578d3Smrg 1140532b578d3Smrgif test -n "$exec_cmd"; then 114061b12faf6Smrg eval exec "$exec_cmd" 1140732b578d3Smrg exit $EXIT_FAILURE 1140832b578d3Smrgfi 1140932b578d3Smrg 114101b12faf6Smrgexit $exit_status 1141132b578d3Smrg 1141232b578d3Smrg 1141332b578d3Smrg# The TAGs below are defined such that we never get into a situation 114140b0ce0bfSmrg# where we disable both kinds of libraries. Given conflicting 1141532b578d3Smrg# choices, we go for a static library, that is the most portable, 1141632b578d3Smrg# since we can't tell whether shared libraries were disabled because 1141732b578d3Smrg# the user asked for that or because the platform doesn't support 1141832b578d3Smrg# them. This is particularly important on AIX, because we don't 1141932b578d3Smrg# support having both static and shared libraries enabled at the same 1142032b578d3Smrg# time on that platform, so we default to a shared-only configuration. 1142132b578d3Smrg# If a disable-shared tag is given, we'll fallback to a static-only 1142232b578d3Smrg# configuration. But we'll never go from static-only to shared-only. 1142332b578d3Smrg 1142432b578d3Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared 114251b12faf6Smrgbuild_libtool_libs=no 114261b12faf6Smrgbuild_old_libs=yes 1142732b578d3Smrg# ### END LIBTOOL TAG CONFIG: disable-shared 1142832b578d3Smrg 1142932b578d3Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static 114301b12faf6Smrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` 1143132b578d3Smrg# ### END LIBTOOL TAG CONFIG: disable-static 1143232b578d3Smrg 1143332b578d3Smrg# Local Variables: 1143432b578d3Smrg# mode:shell-script 1143532b578d3Smrg# sh-indentation:2 1143632b578d3Smrg# End: 11437