115ffece8Smrg#! /usr/bin/env sh 215ffece8Smrg## DO NOT EDIT - This file generated from ./build-aux/ltmain.in 315ffece8Smrg## by inline-source v2019-02-19.15 4a7b590b3Smrg 515ffece8Smrg# libtool (GNU libtool) 2.4.7 615ffece8Smrg# Provide generalized library-building support services. 7a7b590b3Smrg# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 8a7b590b3Smrg 915ffece8Smrg# Copyright (C) 1996-2019, 2021-2022 Free Software Foundation, Inc. 10a7b590b3Smrg# This is free software; see the source for copying conditions. There is NO 11a7b590b3Smrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12a7b590b3Smrg 13a7b590b3Smrg# GNU Libtool is free software; you can redistribute it and/or modify 14943345d3Smrg# it under the terms of the GNU General Public License as published by 15943345d3Smrg# the Free Software Foundation; either version 2 of the License, or 16943345d3Smrg# (at your option) any later version. 17943345d3Smrg# 18a7b590b3Smrg# As a special exception to the GNU General Public License, 19a7b590b3Smrg# if you distribute this file as part of a program or library that 20a7b590b3Smrg# is built using GNU Libtool, you may include this file under the 21a7b590b3Smrg# same distribution terms that you use for the rest of that program. 22a7b590b3Smrg# 23a7b590b3Smrg# GNU Libtool is distributed in the hope that it will be useful, but 24943345d3Smrg# WITHOUT ANY WARRANTY; without even the implied warranty of 25943345d3Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 26943345d3Smrg# General Public License for more details. 27943345d3Smrg# 28943345d3Smrg# You should have received a copy of the GNU General Public License 2915ffece8Smrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 30943345d3Smrg 3115ffece8Smrg 3215ffece8SmrgPROGRAM=libtool 3315ffece8SmrgPACKAGE=libtool 3415ffece8SmrgVERSION=2.4.7 3515ffece8Smrgpackage_revision=2.4.7 3615ffece8Smrg 3715ffece8Smrg 3815ffece8Smrg## ------ ## 3915ffece8Smrg## Usage. ## 4015ffece8Smrg## ------ ## 4115ffece8Smrg 4215ffece8Smrg# Run './libtool --help' for help with using this script from the 4315ffece8Smrg# command line. 4415ffece8Smrg 4515ffece8Smrg 4615ffece8Smrg## ------------------------------- ## 4715ffece8Smrg## User overridable command paths. ## 4815ffece8Smrg## ------------------------------- ## 4915ffece8Smrg 5015ffece8Smrg# After configure completes, it has a better idea of some of the 5115ffece8Smrg# shell tools we need than the defaults used by the functions shared 5215ffece8Smrg# with bootstrap, so set those here where they can still be over- 5315ffece8Smrg# ridden by the user, but otherwise take precedence. 5415ffece8Smrg 5515ffece8Smrg: ${AUTOCONF="autoconf"} 5615ffece8Smrg: ${AUTOMAKE="automake"} 5715ffece8Smrg 5815ffece8Smrg 5915ffece8Smrg## -------------------------- ## 6015ffece8Smrg## Source external libraries. ## 6115ffece8Smrg## -------------------------- ## 6215ffece8Smrg 6315ffece8Smrg# Much of our low-level functionality needs to be sourced from external 6415ffece8Smrg# libraries, which are installed to $pkgauxdir. 6515ffece8Smrg 6615ffece8Smrg# Set a version string for this script. 6715ffece8Smrgscriptversion=2019-02-19.15; # UTC 6815ffece8Smrg 6915ffece8Smrg# General shell script boiler plate, and helper functions. 7015ffece8Smrg# Written by Gary V. Vaughan, 2004 7115ffece8Smrg 7215ffece8Smrg# This is free software. There is NO warranty; not even for 7315ffece8Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 74a7b590b3Smrg# 7515ffece8Smrg# Copyright (C) 2004-2019, 2021 Bootstrap Authors 76a7b590b3Smrg# 7715ffece8Smrg# This file is dual licensed under the terms of the MIT license 7815ffece8Smrg# <https://opensource.org/license/MIT>, and GPL version 2 or later 7915ffece8Smrg# <http://www.gnu.org/licenses/gpl-2.0.html>. You must apply one of 8015ffece8Smrg# these licenses when using or redistributing this software or any of 8115ffece8Smrg# the files within it. See the URLs above, or the file `LICENSE` 8215ffece8Smrg# included in the Bootstrap distribution for the full license texts. 8315ffece8Smrg 8415ffece8Smrg# Please report bugs or propose patches to: 8515ffece8Smrg# <https://github.com/gnulib-modules/bootstrap/issues> 8615ffece8Smrg 8715ffece8Smrg 8815ffece8Smrg## ------ ## 8915ffece8Smrg## Usage. ## 9015ffece8Smrg## ------ ## 9115ffece8Smrg 9215ffece8Smrg# Evaluate this file near the top of your script to gain access to 9315ffece8Smrg# the functions and variables defined here: 94a7b590b3Smrg# 9515ffece8Smrg# . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh 96a7b590b3Smrg# 9715ffece8Smrg# If you need to override any of the default environment variable 9815ffece8Smrg# settings, do that before evaluating this file. 99943345d3Smrg 100943345d3Smrg 10115ffece8Smrg## -------------------- ## 10215ffece8Smrg## Shell normalisation. ## 10315ffece8Smrg## -------------------- ## 10415ffece8Smrg 10515ffece8Smrg# Some shells need a little help to be as Bourne compatible as possible. 10615ffece8Smrg# Before doing anything else, make sure all that help has been provided! 10715ffece8Smrg 10815ffece8SmrgDUALCASE=1; export DUALCASE # for MKS sh 10915ffece8Smrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : 110f67b85aaSmrg emulate sh 111f67b85aaSmrg NULLCMD=: 11215ffece8Smrg # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which 113f67b85aaSmrg # is contrary to our usage. Disable this feature. 114f67b85aaSmrg alias -g '${1+"$@"}'='"$@"' 115943345d3Smrg setopt NO_GLOB_SUBST 116f67b85aaSmrgelse 11715ffece8Smrg case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac 118943345d3Smrgfi 1193e51e026Smrg 12015ffece8Smrg# NLS nuisances: We save the old values in case they are required later. 12115ffece8Smrg_G_user_locale= 12215ffece8Smrg_G_safe_locale= 12315ffece8Smrgfor _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 124f67b85aaSmrgdo 12515ffece8Smrg eval "if test set = \"\${$_G_var+set}\"; then 12615ffece8Smrg save_$_G_var=\$$_G_var 12715ffece8Smrg $_G_var=C 12815ffece8Smrg export $_G_var 12915ffece8Smrg _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\" 13015ffece8Smrg _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\" 1315e695a52Smrg fi" 132f67b85aaSmrgdone 13315ffece8Smrg# These NLS vars are set unconditionally (bootstrap issue #24). Unset those 13415ffece8Smrg# in case the environment reset is needed later and the $save_* variant is not 13515ffece8Smrg# defined (see the code above). 1363e51e026SmrgLC_ALL=C 1373e51e026SmrgLANGUAGE=C 1383e51e026Smrgexport LANGUAGE LC_ALL 139943345d3Smrg 14015ffece8Smrg# Make sure IFS has a sensible default 14115ffece8Smrgsp=' ' 14215ffece8Smrgnl=' 14315ffece8Smrg' 14415ffece8SmrgIFS="$sp $nl" 14515ffece8Smrg 14615ffece8Smrg# There are apparently some retarded systems that use ';' as a PATH separator! 14715ffece8Smrgif test "${PATH_SEPARATOR+set}" != set; then 14815ffece8Smrg PATH_SEPARATOR=: 14915ffece8Smrg (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { 15015ffece8Smrg (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || 15115ffece8Smrg PATH_SEPARATOR=';' 15215ffece8Smrg } 15315ffece8Smrgfi 154a7b590b3Smrg 155a7b590b3Smrg 15615ffece8Smrg# func_unset VAR 15715ffece8Smrg# -------------- 15815ffece8Smrg# Portably unset VAR. 15915ffece8Smrg# In some shells, an 'unset VAR' statement leaves a non-zero return 16015ffece8Smrg# status if VAR is already unset, which might be problematic if the 16115ffece8Smrg# statement is used at the end of a function (thus poisoning its return 16215ffece8Smrg# value) or when 'set -e' is active (causing even a spurious abort of 16315ffece8Smrg# the script in this case). 16415ffece8Smrgfunc_unset () 16515ffece8Smrg{ 16615ffece8Smrg { eval $1=; (eval unset $1) >/dev/null 2>&1 && eval unset $1 || : ; } 16715ffece8Smrg} 168a7b590b3Smrg 169a7b590b3Smrg 17015ffece8Smrg# Make sure CDPATH doesn't cause `cd` commands to output the target dir. 17115ffece8Smrgfunc_unset CDPATH 172a7b590b3Smrg 17315ffece8Smrg# Make sure ${,E,F}GREP behave sanely. 17415ffece8Smrgfunc_unset GREP_OPTIONS 175a7b590b3Smrg 1765e695a52Smrg 17715ffece8Smrg## ------------------------- ## 17815ffece8Smrg## Locate command utilities. ## 17915ffece8Smrg## ------------------------- ## 180943345d3Smrg 181a7b590b3Smrg 18215ffece8Smrg# func_executable_p FILE 18315ffece8Smrg# ---------------------- 18415ffece8Smrg# Check that FILE is an executable regular file. 18515ffece8Smrgfunc_executable_p () 1863e51e026Smrg{ 18715ffece8Smrg test -f "$1" && test -x "$1" 18815ffece8Smrg} 1893e51e026Smrg 1903e51e026Smrg 19115ffece8Smrg# func_path_progs PROGS_LIST CHECK_FUNC [PATH] 19215ffece8Smrg# -------------------------------------------- 19315ffece8Smrg# Search for either a program that responds to --version with output 19415ffece8Smrg# containing "GNU", or else returned by CHECK_FUNC otherwise, by 19515ffece8Smrg# trying all the directories in PATH with each of the elements of 19615ffece8Smrg# PROGS_LIST. 19715ffece8Smrg# 19815ffece8Smrg# CHECK_FUNC should accept the path to a candidate program, and 19915ffece8Smrg# set $func_check_prog_result if it truncates its output less than 20015ffece8Smrg# $_G_path_prog_max characters. 20115ffece8Smrgfunc_path_progs () 2023e51e026Smrg{ 20315ffece8Smrg _G_progs_list=$1 20415ffece8Smrg _G_check_func=$2 20515ffece8Smrg _G_PATH=${3-"$PATH"} 20615ffece8Smrg 20715ffece8Smrg _G_path_prog_max=0 20815ffece8Smrg _G_path_prog_found=false 20915ffece8Smrg _G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:} 21015ffece8Smrg for _G_dir in $_G_PATH; do 21115ffece8Smrg IFS=$_G_save_IFS 21215ffece8Smrg test -z "$_G_dir" && _G_dir=. 21315ffece8Smrg for _G_prog_name in $_G_progs_list; do 21415ffece8Smrg for _exeext in '' .EXE; do 21515ffece8Smrg _G_path_prog=$_G_dir/$_G_prog_name$_exeext 21615ffece8Smrg func_executable_p "$_G_path_prog" || continue 21715ffece8Smrg case `"$_G_path_prog" --version 2>&1` in 21815ffece8Smrg *GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;; 21915ffece8Smrg *) $_G_check_func $_G_path_prog 22015ffece8Smrg func_path_progs_result=$func_check_prog_result 22115ffece8Smrg ;; 22215ffece8Smrg esac 22315ffece8Smrg $_G_path_prog_found && break 3 22415ffece8Smrg done 22515ffece8Smrg done 22615ffece8Smrg done 22715ffece8Smrg IFS=$_G_save_IFS 22815ffece8Smrg test -z "$func_path_progs_result" && { 22915ffece8Smrg echo "no acceptable sed could be found in \$PATH" >&2 23015ffece8Smrg exit 1 23115ffece8Smrg } 23215ffece8Smrg} 2333e51e026Smrg 2343e51e026Smrg 23515ffece8Smrg# We want to be able to use the functions in this file before configure 23615ffece8Smrg# has figured out where the best binaries are kept, which means we have 23715ffece8Smrg# to search for them ourselves - except when the results are already set 23815ffece8Smrg# where we skip the searches. 2393e51e026Smrg 24015ffece8Smrg# Unless the user overrides by setting SED, search the path for either GNU 24115ffece8Smrg# sed, or the sed that truncates its output the least. 24215ffece8Smrgtest -z "$SED" && { 24315ffece8Smrg _G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ 24415ffece8Smrg for _G_i in 1 2 3 4 5 6 7; do 24515ffece8Smrg _G_sed_script=$_G_sed_script$nl$_G_sed_script 24615ffece8Smrg done 24715ffece8Smrg echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed 24815ffece8Smrg _G_sed_script= 2493e51e026Smrg 25015ffece8Smrg func_check_prog_sed () 25115ffece8Smrg { 25215ffece8Smrg _G_path_prog=$1 2533e51e026Smrg 25415ffece8Smrg _G_count=0 25515ffece8Smrg printf 0123456789 >conftest.in 25615ffece8Smrg while : 25715ffece8Smrg do 25815ffece8Smrg cat conftest.in conftest.in >conftest.tmp 25915ffece8Smrg mv conftest.tmp conftest.in 26015ffece8Smrg cp conftest.in conftest.nl 26115ffece8Smrg echo '' >> conftest.nl 26215ffece8Smrg "$_G_path_prog" -f conftest.sed <conftest.nl >conftest.out 2>/dev/null || break 26315ffece8Smrg diff conftest.out conftest.nl >/dev/null 2>&1 || break 26415ffece8Smrg _G_count=`expr $_G_count + 1` 26515ffece8Smrg if test "$_G_count" -gt "$_G_path_prog_max"; then 26615ffece8Smrg # Best one so far, save it but keep looking for a better one 26715ffece8Smrg func_check_prog_result=$_G_path_prog 26815ffece8Smrg _G_path_prog_max=$_G_count 26915ffece8Smrg fi 27015ffece8Smrg # 10*(2^10) chars as input seems more than enough 27115ffece8Smrg test 10 -lt "$_G_count" && break 27215ffece8Smrg done 27315ffece8Smrg rm -f conftest.in conftest.tmp conftest.nl conftest.out 27415ffece8Smrg } 2753e51e026Smrg 27615ffece8Smrg func_path_progs "sed gsed" func_check_prog_sed "$PATH:/usr/xpg4/bin" 27715ffece8Smrg rm -f conftest.sed 27815ffece8Smrg SED=$func_path_progs_result 27915ffece8Smrg} 2803e51e026Smrg 28115ffece8Smrg 28215ffece8Smrg# Unless the user overrides by setting GREP, search the path for either GNU 28315ffece8Smrg# grep, or the grep that truncates its output the least. 28415ffece8Smrgtest -z "$GREP" && { 28515ffece8Smrg func_check_prog_grep () 28615ffece8Smrg { 28715ffece8Smrg _G_path_prog=$1 28815ffece8Smrg 28915ffece8Smrg _G_count=0 29015ffece8Smrg _G_path_prog_max=0 29115ffece8Smrg printf 0123456789 >conftest.in 29215ffece8Smrg while : 29315ffece8Smrg do 29415ffece8Smrg cat conftest.in conftest.in >conftest.tmp 29515ffece8Smrg mv conftest.tmp conftest.in 29615ffece8Smrg cp conftest.in conftest.nl 29715ffece8Smrg echo 'GREP' >> conftest.nl 29815ffece8Smrg "$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' <conftest.nl >conftest.out 2>/dev/null || break 29915ffece8Smrg diff conftest.out conftest.nl >/dev/null 2>&1 || break 30015ffece8Smrg _G_count=`expr $_G_count + 1` 30115ffece8Smrg if test "$_G_count" -gt "$_G_path_prog_max"; then 30215ffece8Smrg # Best one so far, save it but keep looking for a better one 30315ffece8Smrg func_check_prog_result=$_G_path_prog 30415ffece8Smrg _G_path_prog_max=$_G_count 30515ffece8Smrg fi 30615ffece8Smrg # 10*(2^10) chars as input seems more than enough 30715ffece8Smrg test 10 -lt "$_G_count" && break 30815ffece8Smrg done 30915ffece8Smrg rm -f conftest.in conftest.tmp conftest.nl conftest.out 31015ffece8Smrg } 31115ffece8Smrg 31215ffece8Smrg func_path_progs "grep ggrep" func_check_prog_grep "$PATH:/usr/xpg4/bin" 31315ffece8Smrg GREP=$func_path_progs_result 31415ffece8Smrg} 31515ffece8Smrg 31615ffece8Smrg 31715ffece8Smrg## ------------------------------- ## 31815ffece8Smrg## User overridable command paths. ## 31915ffece8Smrg## ------------------------------- ## 32015ffece8Smrg 32115ffece8Smrg# All uppercase variable names are used for environment variables. These 32215ffece8Smrg# variables can be overridden by the user before calling a script that 32315ffece8Smrg# uses them if a suitable command of that name is not already available 32415ffece8Smrg# in the command search PATH. 32515ffece8Smrg 32615ffece8Smrg: ${CP="cp -f"} 32715ffece8Smrg: ${ECHO="printf %s\n"} 32815ffece8Smrg: ${EGREP="$GREP -E"} 32915ffece8Smrg: ${FGREP="$GREP -F"} 33015ffece8Smrg: ${LN_S="ln -s"} 33115ffece8Smrg: ${MAKE="make"} 33215ffece8Smrg: ${MKDIR="mkdir"} 33315ffece8Smrg: ${MV="mv -f"} 33415ffece8Smrg: ${RM="rm -f"} 33515ffece8Smrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"} 33615ffece8Smrg 33715ffece8Smrg 33815ffece8Smrg## -------------------- ## 33915ffece8Smrg## Useful sed snippets. ## 34015ffece8Smrg## -------------------- ## 34115ffece8Smrg 34215ffece8Smrgsed_dirname='s|/[^/]*$||' 34315ffece8Smrgsed_basename='s|^.*/||' 34415ffece8Smrg 34515ffece8Smrg# Sed substitution that helps us do robust quoting. It backslashifies 34615ffece8Smrg# metacharacters that are still active within double-quoted strings. 34715ffece8Smrgsed_quote_subst='s|\([`"$\\]\)|\\\1|g' 34815ffece8Smrg 34915ffece8Smrg# Same as above, but do not quote variable references. 35015ffece8Smrgsed_double_quote_subst='s/\(["`\\]\)/\\\1/g' 35115ffece8Smrg 35215ffece8Smrg# Sed substitution that turns a string into a regex matching for the 35315ffece8Smrg# string literally. 35415ffece8Smrgsed_make_literal_regex='s|[].[^$\\*\/]|\\&|g' 35515ffece8Smrg 35615ffece8Smrg# Sed substitution that converts a w32 file name or path 35715ffece8Smrg# that contains forward slashes, into one that contains 35815ffece8Smrg# (escaped) backslashes. A very naive implementation. 35915ffece8Smrgsed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' 36015ffece8Smrg 36115ffece8Smrg# Re-'\' parameter expansions in output of sed_double_quote_subst that 36215ffece8Smrg# were '\'-ed in input to the same. If an odd number of '\' preceded a 36315ffece8Smrg# '$' in input to sed_double_quote_subst, that '$' was protected from 36415ffece8Smrg# expansion. Since each input '\' is now two '\'s, look for any number 36515ffece8Smrg# of runs of four '\'s followed by two '\'s and then a '$'. '\' that '$'. 36615ffece8Smrg_G_bs='\\' 36715ffece8Smrg_G_bs2='\\\\' 36815ffece8Smrg_G_bs4='\\\\\\\\' 36915ffece8Smrg_G_dollar='\$' 37015ffece8Smrgsed_double_backslash="\ 37115ffece8Smrg s/$_G_bs4/&\\ 37215ffece8Smrg/g 37315ffece8Smrg s/^$_G_bs2$_G_dollar/$_G_bs&/ 37415ffece8Smrg s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g 37515ffece8Smrg s/\n//g" 37615ffece8Smrg 37715ffece8Smrg# require_check_ifs_backslash 37815ffece8Smrg# --------------------------- 37915ffece8Smrg# Check if we can use backslash as IFS='\' separator, and set 38015ffece8Smrg# $check_ifs_backshlash_broken to ':' or 'false'. 38115ffece8Smrgrequire_check_ifs_backslash=func_require_check_ifs_backslash 38215ffece8Smrgfunc_require_check_ifs_backslash () 3833e51e026Smrg{ 38415ffece8Smrg _G_save_IFS=$IFS 38515ffece8Smrg IFS='\' 38615ffece8Smrg _G_check_ifs_backshlash='a\\b' 38715ffece8Smrg for _G_i in $_G_check_ifs_backshlash 38815ffece8Smrg do 38915ffece8Smrg case $_G_i in 39015ffece8Smrg a) 39115ffece8Smrg check_ifs_backshlash_broken=false 3923e51e026Smrg ;; 39315ffece8Smrg '') 39415ffece8Smrg break 3953e51e026Smrg ;; 39615ffece8Smrg *) 39715ffece8Smrg check_ifs_backshlash_broken=: 39815ffece8Smrg break 3993e51e026Smrg ;; 4003e51e026Smrg esac 4013e51e026Smrg done 40215ffece8Smrg IFS=$_G_save_IFS 40315ffece8Smrg require_check_ifs_backslash=: 404a7b590b3Smrg} 405943345d3Smrg 406a7b590b3Smrg 40715ffece8Smrg## ----------------- ## 40815ffece8Smrg## Global variables. ## 40915ffece8Smrg## ----------------- ## 4103e51e026Smrg 41115ffece8Smrg# Except for the global variables explicitly listed below, the following 41215ffece8Smrg# functions in the '^func_' namespace, and the '^require_' namespace 41315ffece8Smrg# variables initialised in the 'Resource management' section, sourcing 41415ffece8Smrg# this file will not pollute your global namespace with anything 41515ffece8Smrg# else. There's no portable way to scope variables in Bourne shell 41615ffece8Smrg# though, so actually running these functions will sometimes place 41715ffece8Smrg# results into a variable named after the function, and often use 41815ffece8Smrg# temporary variables in the '^_G_' namespace. If you are careful to 41915ffece8Smrg# avoid using those namespaces casually in your sourcing script, things 42015ffece8Smrg# should continue to work as you expect. And, of course, you can freely 42115ffece8Smrg# overwrite any of the functions or variables defined here before 42215ffece8Smrg# calling anything to customize them. 42315ffece8Smrg 42415ffece8SmrgEXIT_SUCCESS=0 42515ffece8SmrgEXIT_FAILURE=1 42615ffece8SmrgEXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. 42715ffece8SmrgEXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. 42815ffece8Smrg 42915ffece8Smrg# Allow overriding, eg assuming that you follow the convention of 43015ffece8Smrg# putting '$debug_cmd' at the start of all your functions, you can get 43115ffece8Smrg# bash to show function call trace with: 43215ffece8Smrg# 43315ffece8Smrg# debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name 43415ffece8Smrgdebug_cmd=${debug_cmd-":"} 43515ffece8Smrgexit_cmd=: 43615ffece8Smrg 43715ffece8Smrg# By convention, finish your script with: 43815ffece8Smrg# 43915ffece8Smrg# exit $exit_status 44015ffece8Smrg# 44115ffece8Smrg# so that you can set exit_status to non-zero if you want to indicate 44215ffece8Smrg# something went wrong during execution without actually bailing out at 44315ffece8Smrg# the point of failure. 44415ffece8Smrgexit_status=$EXIT_SUCCESS 445a7b590b3Smrg 44615ffece8Smrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh 44715ffece8Smrg# is ksh but when the shell is invoked as "sh" and the current value of 44815ffece8Smrg# the _XPG environment variable is not equal to 1 (one), the special 44915ffece8Smrg# positional parameter $0, within a function call, is the name of the 45015ffece8Smrg# function. 45115ffece8Smrgprogpath=$0 45215ffece8Smrg 45315ffece8Smrg# The name of this program. 45415ffece8Smrgprogname=`$ECHO "$progpath" |$SED "$sed_basename"` 455a7b590b3Smrg 45615ffece8Smrg# Make sure we have an absolute progpath for reexecution: 457a7b590b3Smrgcase $progpath in 458a7b590b3Smrg [\\/]*|[A-Za-z]:\\*) ;; 459a7b590b3Smrg *[\\/]*) 46015ffece8Smrg progdir=`$ECHO "$progpath" |$SED "$sed_dirname"` 461a7b590b3Smrg progdir=`cd "$progdir" && pwd` 46215ffece8Smrg progpath=$progdir/$progname 463a7b590b3Smrg ;; 464a7b590b3Smrg *) 46515ffece8Smrg _G_IFS=$IFS 4663e51e026Smrg IFS=${PATH_SEPARATOR-:} 467a7b590b3Smrg for progdir in $PATH; do 46815ffece8Smrg IFS=$_G_IFS 469a7b590b3Smrg test -x "$progdir/$progname" && break 470a7b590b3Smrg done 47115ffece8Smrg IFS=$_G_IFS 472a7b590b3Smrg test -n "$progdir" || progdir=`pwd` 47315ffece8Smrg progpath=$progdir/$progname 474a7b590b3Smrg ;; 475a7b590b3Smrgesac 476a7b590b3Smrg 477a7b590b3Smrg 47815ffece8Smrg## ----------------- ## 47915ffece8Smrg## Standard options. ## 48015ffece8Smrg## ----------------- ## 4813e51e026Smrg 48215ffece8Smrg# The following options affect the operation of the functions defined 48315ffece8Smrg# below, and should be set appropriately depending on run-time para- 48415ffece8Smrg# meters passed on the command line. 485a7b590b3Smrg 486a7b590b3Smrgopt_dry_run=false 487a7b590b3Smrgopt_quiet=false 488a7b590b3Smrgopt_verbose=false 489a7b590b3Smrg 49015ffece8Smrg# Categories 'all' and 'none' are always available. Append any others 49115ffece8Smrg# you will pass as the first argument to func_warning from your own 49215ffece8Smrg# code. 49315ffece8Smrgwarning_categories= 494a7b590b3Smrg 49515ffece8Smrg# By default, display warnings according to 'opt_warning_types'. Set 49615ffece8Smrg# 'warning_func' to ':' to elide all warnings, or func_fatal_error to 49715ffece8Smrg# treat the next displayed warning as a fatal error. 49815ffece8Smrgwarning_func=func_warn_and_continue 499a7b590b3Smrg 50015ffece8Smrg# Set to 'all' to display all warnings, 'none' to suppress all 50115ffece8Smrg# warnings, or a space delimited list of some subset of 50215ffece8Smrg# 'warning_categories' to display only the listed warnings. 50315ffece8Smrgopt_warning_types=all 504a7b590b3Smrg 5053e51e026Smrg 50615ffece8Smrg## -------------------- ## 50715ffece8Smrg## Resource management. ## 50815ffece8Smrg## -------------------- ## 509a7b590b3Smrg 51015ffece8Smrg# This section contains definitions for functions that each ensure a 51115ffece8Smrg# particular resource (a file, or a non-empty configuration variable for 51215ffece8Smrg# example) is available, and if appropriate to extract default values 51315ffece8Smrg# from pertinent package files. Call them using their associated 51415ffece8Smrg# 'require_*' variable to ensure that they are executed, at most, once. 51515ffece8Smrg# 51615ffece8Smrg# It's entirely deliberate that calling these functions can set 51715ffece8Smrg# variables that don't obey the namespace limitations obeyed by the rest 51815ffece8Smrg# of this file, in order that that they be as useful as possible to 51915ffece8Smrg# callers. 520a7b590b3Smrg 521a7b590b3Smrg 52215ffece8Smrg# require_term_colors 52315ffece8Smrg# ------------------- 52415ffece8Smrg# Allow display of bold text on terminals that support it. 52515ffece8Smrgrequire_term_colors=func_require_term_colors 52615ffece8Smrgfunc_require_term_colors () 527a7b590b3Smrg{ 52815ffece8Smrg $debug_cmd 52915ffece8Smrg 53015ffece8Smrg test -t 1 && { 53115ffece8Smrg # COLORTERM and USE_ANSI_COLORS environment variables take 53215ffece8Smrg # precedence, because most terminfo databases neglect to describe 53315ffece8Smrg # whether color sequences are supported. 53415ffece8Smrg test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"} 53515ffece8Smrg 53615ffece8Smrg if test 1 = "$USE_ANSI_COLORS"; then 53715ffece8Smrg # Standard ANSI escape sequences 53815ffece8Smrg tc_reset='[0m' 53915ffece8Smrg tc_bold='[1m'; tc_standout='[7m' 54015ffece8Smrg tc_red='[31m'; tc_green='[32m' 54115ffece8Smrg tc_blue='[34m'; tc_cyan='[36m' 54215ffece8Smrg else 54315ffece8Smrg # Otherwise trust the terminfo database after all. 54415ffece8Smrg test -n "`tput sgr0 2>/dev/null`" && { 54515ffece8Smrg tc_reset=`tput sgr0` 54615ffece8Smrg test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold` 54715ffece8Smrg tc_standout=$tc_bold 54815ffece8Smrg test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso` 54915ffece8Smrg test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1` 55015ffece8Smrg test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2` 55115ffece8Smrg test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4` 55215ffece8Smrg test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5` 55315ffece8Smrg } 55415ffece8Smrg fi 55515ffece8Smrg } 556a7b590b3Smrg 55715ffece8Smrg require_term_colors=: 558a7b590b3Smrg} 559a7b590b3Smrg 560a7b590b3Smrg 56115ffece8Smrg## ----------------- ## 56215ffece8Smrg## Function library. ## 56315ffece8Smrg## ----------------- ## 564a7b590b3Smrg 56515ffece8Smrg# This section contains a variety of useful functions to call in your 56615ffece8Smrg# scripts. Take note of the portable wrappers for features provided by 56715ffece8Smrg# some modern shells, which will fall back to slower equivalents on 56815ffece8Smrg# less featureful shells. 569a7b590b3Smrg 57015ffece8Smrg 57115ffece8Smrg# func_append VAR VALUE 57215ffece8Smrg# --------------------- 57315ffece8Smrg# Append VALUE onto the existing contents of VAR. 57415ffece8Smrg 57515ffece8Smrg # We should try to minimise forks, especially on Windows where they are 57615ffece8Smrg # unreasonably slow, so skip the feature probes when bash or zsh are 57715ffece8Smrg # being used: 57815ffece8Smrg if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then 57915ffece8Smrg : ${_G_HAVE_ARITH_OP="yes"} 58015ffece8Smrg : ${_G_HAVE_XSI_OPS="yes"} 58115ffece8Smrg # The += operator was introduced in bash 3.1 58215ffece8Smrg case $BASH_VERSION in 58315ffece8Smrg [12].* | 3.0 | 3.0*) ;; 58415ffece8Smrg *) 58515ffece8Smrg : ${_G_HAVE_PLUSEQ_OP="yes"} 58615ffece8Smrg ;; 58715ffece8Smrg esac 58815ffece8Smrg fi 58915ffece8Smrg 59015ffece8Smrg # _G_HAVE_PLUSEQ_OP 59115ffece8Smrg # Can be empty, in which case the shell is probed, "yes" if += is 59215ffece8Smrg # useable or anything else if it does not work. 59315ffece8Smrg test -z "$_G_HAVE_PLUSEQ_OP" \ 59415ffece8Smrg && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \ 59515ffece8Smrg && _G_HAVE_PLUSEQ_OP=yes 59615ffece8Smrg 59715ffece8Smrgif test yes = "$_G_HAVE_PLUSEQ_OP" 59815ffece8Smrgthen 59915ffece8Smrg # This is an XSI compatible shell, allowing a faster implementation... 60015ffece8Smrg eval 'func_append () 60115ffece8Smrg { 60215ffece8Smrg $debug_cmd 60315ffece8Smrg 60415ffece8Smrg eval "$1+=\$2" 60515ffece8Smrg }' 60615ffece8Smrgelse 60715ffece8Smrg # ...otherwise fall back to using expr, which is often a shell builtin. 60815ffece8Smrg func_append () 60915ffece8Smrg { 61015ffece8Smrg $debug_cmd 61115ffece8Smrg 61215ffece8Smrg eval "$1=\$$1\$2" 61315ffece8Smrg } 61415ffece8Smrgfi 61515ffece8Smrg 61615ffece8Smrg 61715ffece8Smrg# func_append_quoted VAR VALUE 61815ffece8Smrg# ---------------------------- 61915ffece8Smrg# Quote VALUE and append to the end of shell variable VAR, separated 62015ffece8Smrg# by a space. 62115ffece8Smrgif test yes = "$_G_HAVE_PLUSEQ_OP"; then 62215ffece8Smrg eval 'func_append_quoted () 62315ffece8Smrg { 62415ffece8Smrg $debug_cmd 62515ffece8Smrg 62615ffece8Smrg func_quote_arg pretty "$2" 62715ffece8Smrg eval "$1+=\\ \$func_quote_arg_result" 62815ffece8Smrg }' 62915ffece8Smrgelse 63015ffece8Smrg func_append_quoted () 63115ffece8Smrg { 63215ffece8Smrg $debug_cmd 63315ffece8Smrg 63415ffece8Smrg func_quote_arg pretty "$2" 63515ffece8Smrg eval "$1=\$$1\\ \$func_quote_arg_result" 63615ffece8Smrg } 63715ffece8Smrgfi 63815ffece8Smrg 63915ffece8Smrg 64015ffece8Smrg# func_append_uniq VAR VALUE 64115ffece8Smrg# -------------------------- 64215ffece8Smrg# Append unique VALUE onto the existing contents of VAR, assuming 64315ffece8Smrg# entries are delimited by the first character of VALUE. For example: 64415ffece8Smrg# 64515ffece8Smrg# func_append_uniq options " --another-option option-argument" 64615ffece8Smrg# 64715ffece8Smrg# will only append to $options if " --another-option option-argument " 64815ffece8Smrg# is not already present somewhere in $options already (note spaces at 64915ffece8Smrg# each end implied by leading space in second argument). 65015ffece8Smrgfunc_append_uniq () 65115ffece8Smrg{ 65215ffece8Smrg $debug_cmd 65315ffece8Smrg 65415ffece8Smrg eval _G_current_value='`$ECHO $'$1'`' 65515ffece8Smrg _G_delim=`expr "$2" : '\(.\)'` 65615ffece8Smrg 65715ffece8Smrg case $_G_delim$_G_current_value$_G_delim in 65815ffece8Smrg *"$2$_G_delim"*) ;; 65915ffece8Smrg *) func_append "$@" ;; 66015ffece8Smrg esac 66115ffece8Smrg} 66215ffece8Smrg 66315ffece8Smrg 66415ffece8Smrg# func_arith TERM... 66515ffece8Smrg# ------------------ 66615ffece8Smrg# Set func_arith_result to the result of evaluating TERMs. 66715ffece8Smrg test -z "$_G_HAVE_ARITH_OP" \ 66815ffece8Smrg && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \ 66915ffece8Smrg && _G_HAVE_ARITH_OP=yes 67015ffece8Smrg 67115ffece8Smrgif test yes = "$_G_HAVE_ARITH_OP"; then 67215ffece8Smrg eval 'func_arith () 67315ffece8Smrg { 67415ffece8Smrg $debug_cmd 67515ffece8Smrg 67615ffece8Smrg func_arith_result=$(( $* )) 67715ffece8Smrg }' 67815ffece8Smrgelse 67915ffece8Smrg func_arith () 68015ffece8Smrg { 68115ffece8Smrg $debug_cmd 68215ffece8Smrg 68315ffece8Smrg func_arith_result=`expr "$@"` 68415ffece8Smrg } 68515ffece8Smrgfi 68615ffece8Smrg 68715ffece8Smrg 68815ffece8Smrg# func_basename FILE 68915ffece8Smrg# ------------------ 69015ffece8Smrg# Set func_basename_result to FILE with everything up to and including 69115ffece8Smrg# the last / stripped. 69215ffece8Smrgif test yes = "$_G_HAVE_XSI_OPS"; then 69315ffece8Smrg # If this shell supports suffix pattern removal, then use it to avoid 69415ffece8Smrg # forking. Hide the definitions single quotes in case the shell chokes 69515ffece8Smrg # on unsupported syntax... 69615ffece8Smrg _b='func_basename_result=${1##*/}' 69715ffece8Smrg _d='case $1 in 69815ffece8Smrg */*) func_dirname_result=${1%/*}$2 ;; 69915ffece8Smrg * ) func_dirname_result=$3 ;; 70015ffece8Smrg esac' 70115ffece8Smrg 70215ffece8Smrgelse 70315ffece8Smrg # ...otherwise fall back to using sed. 70415ffece8Smrg _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`' 70515ffece8Smrg _d='func_dirname_result=`$ECHO "$1" |$SED "$sed_dirname"` 70615ffece8Smrg if test "X$func_dirname_result" = "X$1"; then 70715ffece8Smrg func_dirname_result=$3 70815ffece8Smrg else 70915ffece8Smrg func_append func_dirname_result "$2" 71015ffece8Smrg fi' 71115ffece8Smrgfi 71215ffece8Smrg 71315ffece8Smrgeval 'func_basename () 714a7b590b3Smrg{ 71515ffece8Smrg $debug_cmd 71615ffece8Smrg 71715ffece8Smrg '"$_b"' 71815ffece8Smrg}' 719a7b590b3Smrg 720a7b590b3Smrg 72115ffece8Smrg# func_dirname FILE APPEND NONDIR_REPLACEMENT 72215ffece8Smrg# ------------------------------------------- 72315ffece8Smrg# Compute the dirname of FILE. If nonempty, add APPEND to the result, 72415ffece8Smrg# otherwise set result to NONDIR_REPLACEMENT. 72515ffece8Smrgeval 'func_dirname () 72615ffece8Smrg{ 72715ffece8Smrg $debug_cmd 72815ffece8Smrg 72915ffece8Smrg '"$_d"' 73015ffece8Smrg}' 73115ffece8Smrg 73215ffece8Smrg 73315ffece8Smrg# func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT 73415ffece8Smrg# -------------------------------------------------------- 73515ffece8Smrg# Perform func_basename and func_dirname in a single function 73615ffece8Smrg# call: 73715ffece8Smrg# dirname: Compute the dirname of FILE. If nonempty, 73815ffece8Smrg# add APPEND to the result, otherwise set result 73915ffece8Smrg# to NONDIR_REPLACEMENT. 74015ffece8Smrg# value returned in "$func_dirname_result" 74115ffece8Smrg# basename: Compute filename of FILE. 74215ffece8Smrg# value retuned in "$func_basename_result" 74315ffece8Smrg# For efficiency, we do not delegate to the functions above but instead 74415ffece8Smrg# duplicate the functionality here. 74515ffece8Smrgeval 'func_dirname_and_basename () 74615ffece8Smrg{ 74715ffece8Smrg $debug_cmd 74815ffece8Smrg 74915ffece8Smrg '"$_b"' 75015ffece8Smrg '"$_d"' 75115ffece8Smrg}' 75215ffece8Smrg 75315ffece8Smrg 75415ffece8Smrg# func_echo ARG... 75515ffece8Smrg# ---------------- 75615ffece8Smrg# Echo program name prefixed message. 75715ffece8Smrgfunc_echo () 75815ffece8Smrg{ 75915ffece8Smrg $debug_cmd 76015ffece8Smrg 76115ffece8Smrg _G_message=$* 76215ffece8Smrg 76315ffece8Smrg func_echo_IFS=$IFS 76415ffece8Smrg IFS=$nl 76515ffece8Smrg for _G_line in $_G_message; do 76615ffece8Smrg IFS=$func_echo_IFS 76715ffece8Smrg $ECHO "$progname: $_G_line" 76815ffece8Smrg done 76915ffece8Smrg IFS=$func_echo_IFS 77015ffece8Smrg} 77115ffece8Smrg 77215ffece8Smrg 77315ffece8Smrg# func_echo_all ARG... 77415ffece8Smrg# -------------------- 77515ffece8Smrg# Invoke $ECHO with all args, space-separated. 77615ffece8Smrgfunc_echo_all () 77715ffece8Smrg{ 77815ffece8Smrg $ECHO "$*" 77915ffece8Smrg} 78015ffece8Smrg 78115ffece8Smrg 78215ffece8Smrg# func_echo_infix_1 INFIX ARG... 78315ffece8Smrg# ------------------------------ 78415ffece8Smrg# Echo program name, followed by INFIX on the first line, with any 78515ffece8Smrg# additional lines not showing INFIX. 78615ffece8Smrgfunc_echo_infix_1 () 78715ffece8Smrg{ 78815ffece8Smrg $debug_cmd 78915ffece8Smrg 79015ffece8Smrg $require_term_colors 79115ffece8Smrg 79215ffece8Smrg _G_infix=$1; shift 79315ffece8Smrg _G_indent=$_G_infix 79415ffece8Smrg _G_prefix="$progname: $_G_infix: " 79515ffece8Smrg _G_message=$* 79615ffece8Smrg 79715ffece8Smrg # Strip color escape sequences before counting printable length 79815ffece8Smrg for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan" 79915ffece8Smrg do 80015ffece8Smrg test -n "$_G_tc" && { 80115ffece8Smrg _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"` 80215ffece8Smrg _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"` 80315ffece8Smrg } 80415ffece8Smrg done 80515ffece8Smrg _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`" " ## exclude from sc_prohibit_nested_quotes 80615ffece8Smrg 80715ffece8Smrg func_echo_infix_1_IFS=$IFS 80815ffece8Smrg IFS=$nl 80915ffece8Smrg for _G_line in $_G_message; do 81015ffece8Smrg IFS=$func_echo_infix_1_IFS 81115ffece8Smrg $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2 81215ffece8Smrg _G_prefix=$_G_indent 81315ffece8Smrg done 81415ffece8Smrg IFS=$func_echo_infix_1_IFS 81515ffece8Smrg} 81615ffece8Smrg 81715ffece8Smrg 81815ffece8Smrg# func_error ARG... 81915ffece8Smrg# ----------------- 82015ffece8Smrg# Echo program name prefixed message to standard error. 82115ffece8Smrgfunc_error () 82215ffece8Smrg{ 82315ffece8Smrg $debug_cmd 82415ffece8Smrg 82515ffece8Smrg $require_term_colors 82615ffece8Smrg 82715ffece8Smrg func_echo_infix_1 " $tc_standout${tc_red}error$tc_reset" "$*" >&2 82815ffece8Smrg} 82915ffece8Smrg 83015ffece8Smrg 83115ffece8Smrg# func_fatal_error ARG... 83215ffece8Smrg# ----------------------- 83315ffece8Smrg# Echo program name prefixed message to standard error, and exit. 83415ffece8Smrgfunc_fatal_error () 83515ffece8Smrg{ 83615ffece8Smrg $debug_cmd 83715ffece8Smrg 83815ffece8Smrg func_error "$*" 83915ffece8Smrg exit $EXIT_FAILURE 84015ffece8Smrg} 84115ffece8Smrg 84215ffece8Smrg 84315ffece8Smrg# func_grep EXPRESSION FILENAME 84415ffece8Smrg# ----------------------------- 84515ffece8Smrg# Check whether EXPRESSION matches any line of FILENAME, without output. 84615ffece8Smrgfunc_grep () 84715ffece8Smrg{ 84815ffece8Smrg $debug_cmd 84915ffece8Smrg 85015ffece8Smrg $GREP "$1" "$2" >/dev/null 2>&1 85115ffece8Smrg} 85215ffece8Smrg 85315ffece8Smrg 85415ffece8Smrg# func_len STRING 85515ffece8Smrg# --------------- 85615ffece8Smrg# Set func_len_result to the length of STRING. STRING may not 85715ffece8Smrg# start with a hyphen. 85815ffece8Smrg test -z "$_G_HAVE_XSI_OPS" \ 85915ffece8Smrg && (eval 'x=a/b/c; 86015ffece8Smrg test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ 86115ffece8Smrg && _G_HAVE_XSI_OPS=yes 86215ffece8Smrg 86315ffece8Smrgif test yes = "$_G_HAVE_XSI_OPS"; then 86415ffece8Smrg eval 'func_len () 86515ffece8Smrg { 86615ffece8Smrg $debug_cmd 86715ffece8Smrg 86815ffece8Smrg func_len_result=${#1} 86915ffece8Smrg }' 87015ffece8Smrgelse 87115ffece8Smrg func_len () 87215ffece8Smrg { 87315ffece8Smrg $debug_cmd 87415ffece8Smrg 87515ffece8Smrg func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len` 87615ffece8Smrg } 87715ffece8Smrgfi 87815ffece8Smrg 87915ffece8Smrg 88015ffece8Smrg# func_mkdir_p DIRECTORY-PATH 88115ffece8Smrg# --------------------------- 88215ffece8Smrg# Make sure the entire path to DIRECTORY-PATH is available. 88315ffece8Smrgfunc_mkdir_p () 88415ffece8Smrg{ 88515ffece8Smrg $debug_cmd 88615ffece8Smrg 88715ffece8Smrg _G_directory_path=$1 88815ffece8Smrg _G_dir_list= 88915ffece8Smrg 89015ffece8Smrg if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then 89115ffece8Smrg 89215ffece8Smrg # Protect directory names starting with '-' 89315ffece8Smrg case $_G_directory_path in 89415ffece8Smrg -*) _G_directory_path=./$_G_directory_path ;; 895a7b590b3Smrg esac 896a7b590b3Smrg 897a7b590b3Smrg # While some portion of DIR does not yet exist... 89815ffece8Smrg while test ! -d "$_G_directory_path"; do 899a7b590b3Smrg # ...make a list in topmost first order. Use a colon delimited 900a7b590b3Smrg # list incase some portion of path contains whitespace. 90115ffece8Smrg _G_dir_list=$_G_directory_path:$_G_dir_list 902a7b590b3Smrg 903a7b590b3Smrg # If the last portion added has no slash in it, the list is done 90415ffece8Smrg case $_G_directory_path in */*) ;; *) break ;; esac 905a7b590b3Smrg 906a7b590b3Smrg # ...otherwise throw away the child directory and loop 90715ffece8Smrg _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"` 908a7b590b3Smrg done 90915ffece8Smrg _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'` 910a7b590b3Smrg 91115ffece8Smrg func_mkdir_p_IFS=$IFS; IFS=: 91215ffece8Smrg for _G_dir in $_G_dir_list; do 91315ffece8Smrg IFS=$func_mkdir_p_IFS 91415ffece8Smrg # mkdir can fail with a 'File exist' error if two processes 915a7b590b3Smrg # try to create one of the directories concurrently. Don't 916a7b590b3Smrg # stop in that case! 91715ffece8Smrg $MKDIR "$_G_dir" 2>/dev/null || : 918a7b590b3Smrg done 91915ffece8Smrg IFS=$func_mkdir_p_IFS 920a7b590b3Smrg 921a7b590b3Smrg # Bail out if we (or some other process) failed to create a directory. 92215ffece8Smrg test -d "$_G_directory_path" || \ 92315ffece8Smrg func_fatal_error "Failed to create '$1'" 924a7b590b3Smrg fi 925a7b590b3Smrg} 926943345d3Smrg 927943345d3Smrg 92815ffece8Smrg# func_mktempdir [BASENAME] 92915ffece8Smrg# ------------------------- 930943345d3Smrg# Make a temporary directory that won't clash with other running 931943345d3Smrg# libtool processes, and avoids race conditions if possible. If 93215ffece8Smrg# given, BASENAME is the basename for that directory. 933943345d3Smrgfunc_mktempdir () 934943345d3Smrg{ 93515ffece8Smrg $debug_cmd 936943345d3Smrg 93715ffece8Smrg _G_template=${TMPDIR-/tmp}/${1-$progname} 93815ffece8Smrg 93915ffece8Smrg if test : = "$opt_dry_run"; then 940943345d3Smrg # Return a directory name, but don't create it in dry-run mode 94115ffece8Smrg _G_tmpdir=$_G_template-$$ 942943345d3Smrg else 943943345d3Smrg 944943345d3Smrg # If mktemp works, use that first and foremost 94515ffece8Smrg _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null` 946943345d3Smrg 94715ffece8Smrg if test ! -d "$_G_tmpdir"; then 948a7b590b3Smrg # Failing that, at least try and use $RANDOM to avoid a race 94915ffece8Smrg _G_tmpdir=$_G_template-${RANDOM-0}$$ 950943345d3Smrg 95115ffece8Smrg func_mktempdir_umask=`umask` 952a7b590b3Smrg umask 0077 95315ffece8Smrg $MKDIR "$_G_tmpdir" 95415ffece8Smrg umask $func_mktempdir_umask 955943345d3Smrg fi 956943345d3Smrg 957943345d3Smrg # If we're not in dry-run mode, bomb out on failure 95815ffece8Smrg test -d "$_G_tmpdir" || \ 95915ffece8Smrg func_fatal_error "cannot create temporary directory '$_G_tmpdir'" 960943345d3Smrg fi 961943345d3Smrg 96215ffece8Smrg $ECHO "$_G_tmpdir" 963943345d3Smrg} 964943345d3Smrg 965943345d3Smrg 96615ffece8Smrg# func_normal_abspath PATH 96715ffece8Smrg# ------------------------ 96815ffece8Smrg# Remove doubled-up and trailing slashes, "." path components, 96915ffece8Smrg# and cancel out any ".." path components in PATH after making 97015ffece8Smrg# it an absolute path. 97115ffece8Smrgfunc_normal_abspath () 972943345d3Smrg{ 97315ffece8Smrg $debug_cmd 97415ffece8Smrg 97515ffece8Smrg # These SED scripts presuppose an absolute path with a trailing slash. 97615ffece8Smrg _G_pathcar='s|^/\([^/]*\).*$|\1|' 97715ffece8Smrg _G_pathcdr='s|^/[^/]*||' 97815ffece8Smrg _G_removedotparts=':dotsl 97915ffece8Smrg s|/\./|/|g 98015ffece8Smrg t dotsl 98115ffece8Smrg s|/\.$|/|' 98215ffece8Smrg _G_collapseslashes='s|/\{1,\}|/|g' 98315ffece8Smrg _G_finalslash='s|/*$|/|' 98415ffece8Smrg 98515ffece8Smrg # Start from root dir and reassemble the path. 98615ffece8Smrg func_normal_abspath_result= 98715ffece8Smrg func_normal_abspath_tpath=$1 98815ffece8Smrg func_normal_abspath_altnamespace= 98915ffece8Smrg case $func_normal_abspath_tpath in 99015ffece8Smrg "") 99115ffece8Smrg # Empty path, that just means $cwd. 99215ffece8Smrg func_stripname '' '/' "`pwd`" 99315ffece8Smrg func_normal_abspath_result=$func_stripname_result 99415ffece8Smrg return 99515ffece8Smrg ;; 99615ffece8Smrg # The next three entries are used to spot a run of precisely 99715ffece8Smrg # two leading slashes without using negated character classes; 99815ffece8Smrg # we take advantage of case's first-match behaviour. 99915ffece8Smrg ///*) 100015ffece8Smrg # Unusual form of absolute path, do nothing. 100115ffece8Smrg ;; 100215ffece8Smrg //*) 100315ffece8Smrg # Not necessarily an ordinary path; POSIX reserves leading '//' 100415ffece8Smrg # and for example Cygwin uses it to access remote file shares 100515ffece8Smrg # over CIFS/SMB, so we conserve a leading double slash if found. 100615ffece8Smrg func_normal_abspath_altnamespace=/ 100715ffece8Smrg ;; 100815ffece8Smrg /*) 100915ffece8Smrg # Absolute path, do nothing. 101015ffece8Smrg ;; 1011a7b590b3Smrg *) 101215ffece8Smrg # Relative path, prepend $cwd. 101315ffece8Smrg func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath 101415ffece8Smrg ;; 1015a7b590b3Smrg esac 1016a7b590b3Smrg 101715ffece8Smrg # Cancel out all the simple stuff to save iterations. We also want 101815ffece8Smrg # the path to end with a slash for ease of parsing, so make sure 101915ffece8Smrg # there is one (and only one) here. 102015ffece8Smrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 102115ffece8Smrg -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"` 102215ffece8Smrg while :; do 102315ffece8Smrg # Processed it all yet? 102415ffece8Smrg if test / = "$func_normal_abspath_tpath"; then 102515ffece8Smrg # If we ascended to the root using ".." the result may be empty now. 102615ffece8Smrg if test -z "$func_normal_abspath_result"; then 102715ffece8Smrg func_normal_abspath_result=/ 102815ffece8Smrg fi 102915ffece8Smrg break 103015ffece8Smrg fi 103115ffece8Smrg func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ 103215ffece8Smrg -e "$_G_pathcar"` 103315ffece8Smrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 103415ffece8Smrg -e "$_G_pathcdr"` 103515ffece8Smrg # Figure out what to do with it 103615ffece8Smrg case $func_normal_abspath_tcomponent in 103715ffece8Smrg "") 103815ffece8Smrg # Trailing empty path component, ignore it. 103915ffece8Smrg ;; 104015ffece8Smrg ..) 104115ffece8Smrg # Parent dir; strip last assembled component from result. 104215ffece8Smrg func_dirname "$func_normal_abspath_result" 104315ffece8Smrg func_normal_abspath_result=$func_dirname_result 104415ffece8Smrg ;; 104515ffece8Smrg *) 104615ffece8Smrg # Actual path component, append it. 104715ffece8Smrg func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent" 104815ffece8Smrg ;; 104915ffece8Smrg esac 105015ffece8Smrg done 105115ffece8Smrg # Restore leading double-slash if one was found on entry. 105215ffece8Smrg func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result 105315ffece8Smrg} 105415ffece8Smrg 105515ffece8Smrg 105615ffece8Smrg# func_notquiet ARG... 105715ffece8Smrg# -------------------- 105815ffece8Smrg# Echo program name prefixed message only when not in quiet mode. 105915ffece8Smrgfunc_notquiet () 106015ffece8Smrg{ 106115ffece8Smrg $debug_cmd 106215ffece8Smrg 106315ffece8Smrg $opt_quiet || func_echo ${1+"$@"} 106415ffece8Smrg 106515ffece8Smrg # A bug in bash halts the script if the last line of a function 106615ffece8Smrg # fails when set -e is in force, so we need another command to 106715ffece8Smrg # work around that: 106815ffece8Smrg : 106915ffece8Smrg} 107015ffece8Smrg 107115ffece8Smrg 107215ffece8Smrg# func_relative_path SRCDIR DSTDIR 107315ffece8Smrg# -------------------------------- 107415ffece8Smrg# Set func_relative_path_result to the relative path from SRCDIR to DSTDIR. 107515ffece8Smrgfunc_relative_path () 107615ffece8Smrg{ 107715ffece8Smrg $debug_cmd 107815ffece8Smrg 107915ffece8Smrg func_relative_path_result= 108015ffece8Smrg func_normal_abspath "$1" 108115ffece8Smrg func_relative_path_tlibdir=$func_normal_abspath_result 108215ffece8Smrg func_normal_abspath "$2" 108315ffece8Smrg func_relative_path_tbindir=$func_normal_abspath_result 108415ffece8Smrg 108515ffece8Smrg # Ascend the tree starting from libdir 108615ffece8Smrg while :; do 108715ffece8Smrg # check if we have found a prefix of bindir 108815ffece8Smrg case $func_relative_path_tbindir in 108915ffece8Smrg $func_relative_path_tlibdir) 109015ffece8Smrg # found an exact match 109115ffece8Smrg func_relative_path_tcancelled= 109215ffece8Smrg break 109315ffece8Smrg ;; 109415ffece8Smrg $func_relative_path_tlibdir*) 109515ffece8Smrg # found a matching prefix 109615ffece8Smrg func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" 109715ffece8Smrg func_relative_path_tcancelled=$func_stripname_result 109815ffece8Smrg if test -z "$func_relative_path_result"; then 109915ffece8Smrg func_relative_path_result=. 110015ffece8Smrg fi 110115ffece8Smrg break 110215ffece8Smrg ;; 110315ffece8Smrg *) 110415ffece8Smrg func_dirname $func_relative_path_tlibdir 110515ffece8Smrg func_relative_path_tlibdir=$func_dirname_result 110615ffece8Smrg if test -z "$func_relative_path_tlibdir"; then 110715ffece8Smrg # Have to descend all the way to the root! 110815ffece8Smrg func_relative_path_result=../$func_relative_path_result 110915ffece8Smrg func_relative_path_tcancelled=$func_relative_path_tbindir 111015ffece8Smrg break 111115ffece8Smrg fi 111215ffece8Smrg func_relative_path_result=../$func_relative_path_result 111315ffece8Smrg ;; 111415ffece8Smrg esac 111515ffece8Smrg done 111615ffece8Smrg 111715ffece8Smrg # Now calculate path; take care to avoid doubling-up slashes. 111815ffece8Smrg func_stripname '' '/' "$func_relative_path_result" 111915ffece8Smrg func_relative_path_result=$func_stripname_result 112015ffece8Smrg func_stripname '/' '/' "$func_relative_path_tcancelled" 112115ffece8Smrg if test -n "$func_stripname_result"; then 112215ffece8Smrg func_append func_relative_path_result "/$func_stripname_result" 112315ffece8Smrg fi 112415ffece8Smrg 112515ffece8Smrg # Normalisation. If bindir is libdir, return '.' else relative path. 112615ffece8Smrg if test -n "$func_relative_path_result"; then 112715ffece8Smrg func_stripname './' '' "$func_relative_path_result" 112815ffece8Smrg func_relative_path_result=$func_stripname_result 112915ffece8Smrg fi 113015ffece8Smrg 113115ffece8Smrg test -n "$func_relative_path_result" || func_relative_path_result=. 113215ffece8Smrg 113315ffece8Smrg : 113415ffece8Smrg} 113515ffece8Smrg 113615ffece8Smrg 113715ffece8Smrg# func_quote_portable EVAL ARG 113815ffece8Smrg# ---------------------------- 113915ffece8Smrg# Internal function to portably implement func_quote_arg. Note that we still 114015ffece8Smrg# keep attention to performance here so we as much as possible try to avoid 114115ffece8Smrg# calling sed binary (so far O(N) complexity as long as func_append is O(1)). 114215ffece8Smrgfunc_quote_portable () 114315ffece8Smrg{ 114415ffece8Smrg $debug_cmd 114515ffece8Smrg 114615ffece8Smrg $require_check_ifs_backslash 114715ffece8Smrg 114815ffece8Smrg func_quote_portable_result=$2 114915ffece8Smrg 115015ffece8Smrg # one-time-loop (easy break) 115115ffece8Smrg while true 115215ffece8Smrg do 115315ffece8Smrg if $1; then 115415ffece8Smrg func_quote_portable_result=`$ECHO "$2" | $SED \ 115515ffece8Smrg -e "$sed_double_quote_subst" -e "$sed_double_backslash"` 115615ffece8Smrg break 115715ffece8Smrg fi 115815ffece8Smrg 115915ffece8Smrg # Quote for eval. 116015ffece8Smrg case $func_quote_portable_result in 116115ffece8Smrg *[\\\`\"\$]*) 116215ffece8Smrg # Fallback to sed for $func_check_bs_ifs_broken=:, or when the string 116315ffece8Smrg # contains the shell wildcard characters. 116415ffece8Smrg case $check_ifs_backshlash_broken$func_quote_portable_result in 116515ffece8Smrg :*|*[\[\*\?]*) 116615ffece8Smrg func_quote_portable_result=`$ECHO "$func_quote_portable_result" \ 116715ffece8Smrg | $SED "$sed_quote_subst"` 116815ffece8Smrg break 116915ffece8Smrg ;; 117015ffece8Smrg esac 117115ffece8Smrg 117215ffece8Smrg func_quote_portable_old_IFS=$IFS 117315ffece8Smrg for _G_char in '\' '`' '"' '$' 117415ffece8Smrg do 117515ffece8Smrg # STATE($1) PREV($2) SEPARATOR($3) 117615ffece8Smrg set start "" "" 117715ffece8Smrg func_quote_portable_result=dummy"$_G_char$func_quote_portable_result$_G_char"dummy 117815ffece8Smrg IFS=$_G_char 117915ffece8Smrg for _G_part in $func_quote_portable_result 118015ffece8Smrg do 118115ffece8Smrg case $1 in 118215ffece8Smrg quote) 118315ffece8Smrg func_append func_quote_portable_result "$3$2" 118415ffece8Smrg set quote "$_G_part" "\\$_G_char" 118515ffece8Smrg ;; 118615ffece8Smrg start) 118715ffece8Smrg set first "" "" 118815ffece8Smrg func_quote_portable_result= 118915ffece8Smrg ;; 119015ffece8Smrg first) 119115ffece8Smrg set quote "$_G_part" "" 119215ffece8Smrg ;; 119315ffece8Smrg esac 119415ffece8Smrg done 119515ffece8Smrg done 119615ffece8Smrg IFS=$func_quote_portable_old_IFS 119715ffece8Smrg ;; 119815ffece8Smrg *) ;; 119915ffece8Smrg esac 120015ffece8Smrg break 120115ffece8Smrg done 120215ffece8Smrg 120315ffece8Smrg func_quote_portable_unquoted_result=$func_quote_portable_result 120415ffece8Smrg case $func_quote_portable_result in 120515ffece8Smrg # double-quote args containing shell metacharacters to delay 120615ffece8Smrg # word splitting, command substitution and variable expansion 120715ffece8Smrg # for a subsequent eval. 120815ffece8Smrg # many bourne shells cannot handle close brackets correctly 1209a7b590b3Smrg # in scan sets, so we specify it separately. 1210a7b590b3Smrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 121115ffece8Smrg func_quote_portable_result=\"$func_quote_portable_result\" 121215ffece8Smrg ;; 121315ffece8Smrg esac 121415ffece8Smrg} 121515ffece8Smrg 121615ffece8Smrg 121715ffece8Smrg# func_quotefast_eval ARG 121815ffece8Smrg# ----------------------- 121915ffece8Smrg# Quote one ARG (internal). This is equivalent to 'func_quote_arg eval ARG', 122015ffece8Smrg# but optimized for speed. Result is stored in $func_quotefast_eval. 122115ffece8Smrgif test xyes = `(x=; printf -v x %q yes; echo x"$x") 2>/dev/null`; then 122215ffece8Smrg printf -v _GL_test_printf_tilde %q '~' 122315ffece8Smrg if test '\~' = "$_GL_test_printf_tilde"; then 122415ffece8Smrg func_quotefast_eval () 122515ffece8Smrg { 122615ffece8Smrg printf -v func_quotefast_eval_result %q "$1" 122715ffece8Smrg } 122815ffece8Smrg else 122915ffece8Smrg # Broken older Bash implementations. Make those faster too if possible. 123015ffece8Smrg func_quotefast_eval () 123115ffece8Smrg { 123215ffece8Smrg case $1 in 123315ffece8Smrg '~'*) 123415ffece8Smrg func_quote_portable false "$1" 123515ffece8Smrg func_quotefast_eval_result=$func_quote_portable_result 123615ffece8Smrg ;; 123715ffece8Smrg *) 123815ffece8Smrg printf -v func_quotefast_eval_result %q "$1" 123915ffece8Smrg ;; 124015ffece8Smrg esac 124115ffece8Smrg } 124215ffece8Smrg fi 124315ffece8Smrgelse 124415ffece8Smrg func_quotefast_eval () 124515ffece8Smrg { 124615ffece8Smrg func_quote_portable false "$1" 124715ffece8Smrg func_quotefast_eval_result=$func_quote_portable_result 124815ffece8Smrg } 124915ffece8Smrgfi 125015ffece8Smrg 125115ffece8Smrg 125215ffece8Smrg# func_quote_arg MODEs ARG 125315ffece8Smrg# ------------------------ 125415ffece8Smrg# Quote one ARG to be evaled later. MODEs argument may contain zero or more 125515ffece8Smrg# specifiers listed below separated by ',' character. This function returns two 125615ffece8Smrg# values: 125715ffece8Smrg# i) func_quote_arg_result 125815ffece8Smrg# double-quoted (when needed), suitable for a subsequent eval 125915ffece8Smrg# ii) func_quote_arg_unquoted_result 126015ffece8Smrg# has all characters that are still active within double 126115ffece8Smrg# quotes backslashified. Available only if 'unquoted' is specified. 126215ffece8Smrg# 126315ffece8Smrg# Available modes: 126415ffece8Smrg# ---------------- 126515ffece8Smrg# 'eval' (default) 126615ffece8Smrg# - escape shell special characters 126715ffece8Smrg# 'expand' 126815ffece8Smrg# - the same as 'eval'; but do not quote variable references 126915ffece8Smrg# 'pretty' 127015ffece8Smrg# - request aesthetic output, i.e. '"a b"' instead of 'a\ b'. This might 127115ffece8Smrg# be used later in func_quote to get output like: 'echo "a b"' instead 127215ffece8Smrg# of 'echo a\ b'. This is slower than default on some shells. 127315ffece8Smrg# 'unquoted' 127415ffece8Smrg# - produce also $func_quote_arg_unquoted_result which does not contain 127515ffece8Smrg# wrapping double-quotes. 127615ffece8Smrg# 127715ffece8Smrg# Examples for 'func_quote_arg pretty,unquoted string': 127815ffece8Smrg# 127915ffece8Smrg# string | *_result | *_unquoted_result 128015ffece8Smrg# ------------+-----------------------+------------------- 128115ffece8Smrg# " | \" | \" 128215ffece8Smrg# a b | "a b" | a b 128315ffece8Smrg# "a b" | "\"a b\"" | \"a b\" 128415ffece8Smrg# * | "*" | * 128515ffece8Smrg# z="${x-$y}" | "z=\"\${x-\$y}\"" | z=\"\${x-\$y}\" 128615ffece8Smrg# 128715ffece8Smrg# Examples for 'func_quote_arg pretty,unquoted,expand string': 128815ffece8Smrg# 128915ffece8Smrg# string | *_result | *_unquoted_result 129015ffece8Smrg# --------------+---------------------+-------------------- 129115ffece8Smrg# z="${x-$y}" | "z=\"${x-$y}\"" | z=\"${x-$y}\" 129215ffece8Smrgfunc_quote_arg () 129315ffece8Smrg{ 129415ffece8Smrg _G_quote_expand=false 129515ffece8Smrg case ,$1, in 129615ffece8Smrg *,expand,*) 129715ffece8Smrg _G_quote_expand=: 129815ffece8Smrg ;; 129915ffece8Smrg esac 130015ffece8Smrg 130115ffece8Smrg case ,$1, in 130215ffece8Smrg *,pretty,*|*,expand,*|*,unquoted,*) 130315ffece8Smrg func_quote_portable $_G_quote_expand "$2" 130415ffece8Smrg func_quote_arg_result=$func_quote_portable_result 130515ffece8Smrg func_quote_arg_unquoted_result=$func_quote_portable_unquoted_result 1306a7b590b3Smrg ;; 1307a7b590b3Smrg *) 130815ffece8Smrg # Faster quote-for-eval for some shells. 130915ffece8Smrg func_quotefast_eval "$2" 131015ffece8Smrg func_quote_arg_result=$func_quotefast_eval_result 131115ffece8Smrg ;; 131215ffece8Smrg esac 131315ffece8Smrg} 131415ffece8Smrg 131515ffece8Smrg 131615ffece8Smrg# func_quote MODEs ARGs... 131715ffece8Smrg# ------------------------ 131815ffece8Smrg# Quote all ARGs to be evaled later and join them into single command. See 131915ffece8Smrg# func_quote_arg's description for more info. 132015ffece8Smrgfunc_quote () 132115ffece8Smrg{ 132215ffece8Smrg $debug_cmd 132315ffece8Smrg _G_func_quote_mode=$1 ; shift 132415ffece8Smrg func_quote_result= 132515ffece8Smrg while test 0 -lt $#; do 132615ffece8Smrg func_quote_arg "$_G_func_quote_mode" "$1" 132715ffece8Smrg if test -n "$func_quote_result"; then 132815ffece8Smrg func_append func_quote_result " $func_quote_arg_result" 132915ffece8Smrg else 133015ffece8Smrg func_append func_quote_result "$func_quote_arg_result" 133115ffece8Smrg fi 133215ffece8Smrg shift 133315ffece8Smrg done 133415ffece8Smrg} 133515ffece8Smrg 133615ffece8Smrg 133715ffece8Smrg# func_stripname PREFIX SUFFIX NAME 133815ffece8Smrg# --------------------------------- 133915ffece8Smrg# strip PREFIX and SUFFIX from NAME, and store in func_stripname_result. 134015ffece8Smrg# PREFIX and SUFFIX must not contain globbing or regex special 134115ffece8Smrg# characters, hashes, percent signs, but SUFFIX may contain a leading 134215ffece8Smrg# dot (in which case that matches only a dot). 134315ffece8Smrgif test yes = "$_G_HAVE_XSI_OPS"; then 134415ffece8Smrg eval 'func_stripname () 134515ffece8Smrg { 134615ffece8Smrg $debug_cmd 134715ffece8Smrg 134815ffece8Smrg # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are 134915ffece8Smrg # positional parameters, so assign one to ordinary variable first. 135015ffece8Smrg func_stripname_result=$3 135115ffece8Smrg func_stripname_result=${func_stripname_result#"$1"} 135215ffece8Smrg func_stripname_result=${func_stripname_result%"$2"} 135315ffece8Smrg }' 135415ffece8Smrgelse 135515ffece8Smrg func_stripname () 135615ffece8Smrg { 135715ffece8Smrg $debug_cmd 135815ffece8Smrg 135915ffece8Smrg case $2 in 136015ffece8Smrg .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;; 136115ffece8Smrg *) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;; 136215ffece8Smrg esac 136315ffece8Smrg } 136415ffece8Smrgfi 136515ffece8Smrg 136615ffece8Smrg 136715ffece8Smrg# func_show_eval CMD [FAIL_EXP] 136815ffece8Smrg# ----------------------------- 136915ffece8Smrg# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is 137015ffece8Smrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 137115ffece8Smrg# is given, then evaluate it. 137215ffece8Smrgfunc_show_eval () 137315ffece8Smrg{ 137415ffece8Smrg $debug_cmd 137515ffece8Smrg 137615ffece8Smrg _G_cmd=$1 137715ffece8Smrg _G_fail_exp=${2-':'} 137815ffece8Smrg 137915ffece8Smrg func_quote_arg pretty,expand "$_G_cmd" 138015ffece8Smrg eval "func_notquiet $func_quote_arg_result" 138115ffece8Smrg 138215ffece8Smrg $opt_dry_run || { 138315ffece8Smrg eval "$_G_cmd" 138415ffece8Smrg _G_status=$? 138515ffece8Smrg if test 0 -ne "$_G_status"; then 138615ffece8Smrg eval "(exit $_G_status); $_G_fail_exp" 138715ffece8Smrg fi 138815ffece8Smrg } 138915ffece8Smrg} 139015ffece8Smrg 139115ffece8Smrg 139215ffece8Smrg# func_show_eval_locale CMD [FAIL_EXP] 139315ffece8Smrg# ------------------------------------ 139415ffece8Smrg# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is 139515ffece8Smrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 139615ffece8Smrg# is given, then evaluate it. Use the saved locale for evaluation. 139715ffece8Smrgfunc_show_eval_locale () 139815ffece8Smrg{ 139915ffece8Smrg $debug_cmd 140015ffece8Smrg 140115ffece8Smrg _G_cmd=$1 140215ffece8Smrg _G_fail_exp=${2-':'} 140315ffece8Smrg 140415ffece8Smrg $opt_quiet || { 140515ffece8Smrg func_quote_arg expand,pretty "$_G_cmd" 140615ffece8Smrg eval "func_echo $func_quote_arg_result" 140715ffece8Smrg } 140815ffece8Smrg 140915ffece8Smrg $opt_dry_run || { 141015ffece8Smrg eval "$_G_user_locale 141115ffece8Smrg $_G_cmd" 141215ffece8Smrg _G_status=$? 141315ffece8Smrg eval "$_G_safe_locale" 141415ffece8Smrg if test 0 -ne "$_G_status"; then 141515ffece8Smrg eval "(exit $_G_status); $_G_fail_exp" 141615ffece8Smrg fi 141715ffece8Smrg } 141815ffece8Smrg} 141915ffece8Smrg 142015ffece8Smrg 142115ffece8Smrg# func_tr_sh 142215ffece8Smrg# ---------- 142315ffece8Smrg# Turn $1 into a string suitable for a shell variable name. 142415ffece8Smrg# Result is stored in $func_tr_sh_result. All characters 142515ffece8Smrg# not in the set a-zA-Z0-9_ are replaced with '_'. Further, 142615ffece8Smrg# if $1 begins with a digit, a '_' is prepended as well. 142715ffece8Smrgfunc_tr_sh () 142815ffece8Smrg{ 142915ffece8Smrg $debug_cmd 143015ffece8Smrg 143115ffece8Smrg case $1 in 143215ffece8Smrg [0-9]* | *[!a-zA-Z0-9_]*) 143315ffece8Smrg func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'` 143415ffece8Smrg ;; 143515ffece8Smrg * ) 143615ffece8Smrg func_tr_sh_result=$1 143715ffece8Smrg ;; 143815ffece8Smrg esac 143915ffece8Smrg} 144015ffece8Smrg 144115ffece8Smrg 144215ffece8Smrg# func_verbose ARG... 144315ffece8Smrg# ------------------- 144415ffece8Smrg# Echo program name prefixed message in verbose mode only. 144515ffece8Smrgfunc_verbose () 144615ffece8Smrg{ 144715ffece8Smrg $debug_cmd 144815ffece8Smrg 144915ffece8Smrg $opt_verbose && func_echo "$*" 145015ffece8Smrg 145115ffece8Smrg : 145215ffece8Smrg} 145315ffece8Smrg 145415ffece8Smrg 145515ffece8Smrg# func_warn_and_continue ARG... 145615ffece8Smrg# ----------------------------- 145715ffece8Smrg# Echo program name prefixed warning message to standard error. 145815ffece8Smrgfunc_warn_and_continue () 145915ffece8Smrg{ 146015ffece8Smrg $debug_cmd 146115ffece8Smrg 146215ffece8Smrg $require_term_colors 146315ffece8Smrg 146415ffece8Smrg func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2 146515ffece8Smrg} 146615ffece8Smrg 146715ffece8Smrg 146815ffece8Smrg# func_warning CATEGORY ARG... 146915ffece8Smrg# ---------------------------- 147015ffece8Smrg# Echo program name prefixed warning message to standard error. Warning 147115ffece8Smrg# messages can be filtered according to CATEGORY, where this function 147215ffece8Smrg# elides messages where CATEGORY is not listed in the global variable 147315ffece8Smrg# 'opt_warning_types'. 147415ffece8Smrgfunc_warning () 147515ffece8Smrg{ 147615ffece8Smrg $debug_cmd 147715ffece8Smrg 147815ffece8Smrg # CATEGORY must be in the warning_categories list! 147915ffece8Smrg case " $warning_categories " in 148015ffece8Smrg *" $1 "*) ;; 148115ffece8Smrg *) func_internal_error "invalid warning category '$1'" ;; 148215ffece8Smrg esac 148315ffece8Smrg 148415ffece8Smrg _G_category=$1 148515ffece8Smrg shift 148615ffece8Smrg 148715ffece8Smrg case " $opt_warning_types " in 148815ffece8Smrg *" $_G_category "*) $warning_func ${1+"$@"} ;; 148915ffece8Smrg esac 149015ffece8Smrg} 149115ffece8Smrg 149215ffece8Smrg 149315ffece8Smrg# func_sort_ver VER1 VER2 149415ffece8Smrg# ----------------------- 149515ffece8Smrg# 'sort -V' is not generally available. 149615ffece8Smrg# Note this deviates from the version comparison in automake 149715ffece8Smrg# in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a 149815ffece8Smrg# but this should suffice as we won't be specifying old 149915ffece8Smrg# version formats or redundant trailing .0 in bootstrap.conf. 150015ffece8Smrg# If we did want full compatibility then we should probably 150115ffece8Smrg# use m4_version_compare from autoconf. 150215ffece8Smrgfunc_sort_ver () 150315ffece8Smrg{ 150415ffece8Smrg $debug_cmd 150515ffece8Smrg 150615ffece8Smrg printf '%s\n%s\n' "$1" "$2" \ 150715ffece8Smrg | 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 150815ffece8Smrg} 150915ffece8Smrg 151015ffece8Smrg# func_lt_ver PREV CURR 151115ffece8Smrg# --------------------- 151215ffece8Smrg# Return true if PREV and CURR are in the correct order according to 151315ffece8Smrg# func_sort_ver, otherwise false. Use it like this: 151415ffece8Smrg# 151515ffece8Smrg# func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..." 151615ffece8Smrgfunc_lt_ver () 151715ffece8Smrg{ 151815ffece8Smrg $debug_cmd 151915ffece8Smrg 152015ffece8Smrg test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q` 152115ffece8Smrg} 152215ffece8Smrg 152315ffece8Smrg 152415ffece8Smrg# Local variables: 152515ffece8Smrg# mode: shell-script 152615ffece8Smrg# sh-indentation: 2 152715ffece8Smrg# eval: (add-hook 'before-save-hook 'time-stamp) 152815ffece8Smrg# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" 152915ffece8Smrg# time-stamp-time-zone: "UTC" 153015ffece8Smrg# End: 153115ffece8Smrg#! /bin/sh 153215ffece8Smrg 153315ffece8Smrg# A portable, pluggable option parser for Bourne shell. 153415ffece8Smrg# Written by Gary V. Vaughan, 2010 153515ffece8Smrg 153615ffece8Smrg# This is free software. There is NO warranty; not even for 153715ffece8Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 153815ffece8Smrg# 153915ffece8Smrg# Copyright (C) 2010-2019, 2021 Bootstrap Authors 154015ffece8Smrg# 154115ffece8Smrg# This file is dual licensed under the terms of the MIT license 154215ffece8Smrg# <https://opensource.org/license/MIT>, and GPL version 2 or later 154315ffece8Smrg# <http://www.gnu.org/licenses/gpl-2.0.html>. You must apply one of 154415ffece8Smrg# these licenses when using or redistributing this software or any of 154515ffece8Smrg# the files within it. See the URLs above, or the file `LICENSE` 154615ffece8Smrg# included in the Bootstrap distribution for the full license texts. 154715ffece8Smrg 154815ffece8Smrg# Please report bugs or propose patches to: 154915ffece8Smrg# <https://github.com/gnulib-modules/bootstrap/issues> 155015ffece8Smrg 155115ffece8Smrg# Set a version string for this script. 155215ffece8Smrgscriptversion=2019-02-19.15; # UTC 155315ffece8Smrg 155415ffece8Smrg 155515ffece8Smrg## ------ ## 155615ffece8Smrg## Usage. ## 155715ffece8Smrg## ------ ## 155815ffece8Smrg 155915ffece8Smrg# This file is a library for parsing options in your shell scripts along 156015ffece8Smrg# with assorted other useful supporting features that you can make use 156115ffece8Smrg# of too. 156215ffece8Smrg# 156315ffece8Smrg# For the simplest scripts you might need only: 156415ffece8Smrg# 156515ffece8Smrg# #!/bin/sh 156615ffece8Smrg# . relative/path/to/funclib.sh 156715ffece8Smrg# . relative/path/to/options-parser 156815ffece8Smrg# scriptversion=1.0 156915ffece8Smrg# func_options ${1+"$@"} 157015ffece8Smrg# eval set dummy "$func_options_result"; shift 157115ffece8Smrg# ...rest of your script... 157215ffece8Smrg# 157315ffece8Smrg# In order for the '--version' option to work, you will need to have a 157415ffece8Smrg# suitably formatted comment like the one at the top of this file 157515ffece8Smrg# starting with '# Written by ' and ending with '# Copyright'. 157615ffece8Smrg# 157715ffece8Smrg# For '-h' and '--help' to work, you will also need a one line 157815ffece8Smrg# description of your script's purpose in a comment directly above the 157915ffece8Smrg# '# Written by ' line, like the one at the top of this file. 158015ffece8Smrg# 158115ffece8Smrg# The default options also support '--debug', which will turn on shell 158215ffece8Smrg# execution tracing (see the comment above debug_cmd below for another 158315ffece8Smrg# use), and '--verbose' and the func_verbose function to allow your script 158415ffece8Smrg# to display verbose messages only when your user has specified 158515ffece8Smrg# '--verbose'. 158615ffece8Smrg# 158715ffece8Smrg# After sourcing this file, you can plug in processing for additional 158815ffece8Smrg# options by amending the variables from the 'Configuration' section 158915ffece8Smrg# below, and following the instructions in the 'Option parsing' 159015ffece8Smrg# section further down. 159115ffece8Smrg 159215ffece8Smrg## -------------- ## 159315ffece8Smrg## Configuration. ## 159415ffece8Smrg## -------------- ## 159515ffece8Smrg 159615ffece8Smrg# You should override these variables in your script after sourcing this 159715ffece8Smrg# file so that they reflect the customisations you have added to the 159815ffece8Smrg# option parser. 159915ffece8Smrg 160015ffece8Smrg# The usage line for option parsing errors and the start of '-h' and 160115ffece8Smrg# '--help' output messages. You can embed shell variables for delayed 160215ffece8Smrg# expansion at the time the message is displayed, but you will need to 160315ffece8Smrg# quote other shell meta-characters carefully to prevent them being 160415ffece8Smrg# expanded when the contents are evaled. 160515ffece8Smrgusage='$progpath [OPTION]...' 160615ffece8Smrg 160715ffece8Smrg# Short help message in response to '-h' and '--help'. Add to this or 160815ffece8Smrg# override it after sourcing this library to reflect the full set of 160915ffece8Smrg# options your script accepts. 161015ffece8Smrgusage_message="\ 161115ffece8Smrg --debug enable verbose shell tracing 161215ffece8Smrg -W, --warnings=CATEGORY 161315ffece8Smrg report the warnings falling in CATEGORY [all] 161415ffece8Smrg -v, --verbose verbosely report processing 161515ffece8Smrg --version print version information and exit 161615ffece8Smrg -h, --help print short or long help message and exit 161715ffece8Smrg" 161815ffece8Smrg 161915ffece8Smrg# Additional text appended to 'usage_message' in response to '--help'. 162015ffece8Smrglong_help_message=" 162115ffece8SmrgWarning categories include: 162215ffece8Smrg 'all' show all warnings 162315ffece8Smrg 'none' turn off all the warnings 162415ffece8Smrg 'error' warnings are treated as fatal errors" 162515ffece8Smrg 162615ffece8Smrg# Help message printed before fatal option parsing errors. 162715ffece8Smrgfatal_help="Try '\$progname --help' for more information." 162815ffece8Smrg 162915ffece8Smrg 163015ffece8Smrg 163115ffece8Smrg## ------------------------- ## 163215ffece8Smrg## Hook function management. ## 163315ffece8Smrg## ------------------------- ## 163415ffece8Smrg 163515ffece8Smrg# This section contains functions for adding, removing, and running hooks 163615ffece8Smrg# in the main code. A hook is just a list of function names that can be 163715ffece8Smrg# run in order later on. 163815ffece8Smrg 163915ffece8Smrg# func_hookable FUNC_NAME 164015ffece8Smrg# ----------------------- 164115ffece8Smrg# Declare that FUNC_NAME will run hooks added with 164215ffece8Smrg# 'func_add_hook FUNC_NAME ...'. 164315ffece8Smrgfunc_hookable () 164415ffece8Smrg{ 164515ffece8Smrg $debug_cmd 164615ffece8Smrg 164715ffece8Smrg func_append hookable_fns " $1" 164815ffece8Smrg} 164915ffece8Smrg 165015ffece8Smrg 165115ffece8Smrg# func_add_hook FUNC_NAME HOOK_FUNC 165215ffece8Smrg# --------------------------------- 165315ffece8Smrg# Request that FUNC_NAME call HOOK_FUNC before it returns. FUNC_NAME must 165415ffece8Smrg# first have been declared "hookable" by a call to 'func_hookable'. 165515ffece8Smrgfunc_add_hook () 165615ffece8Smrg{ 165715ffece8Smrg $debug_cmd 165815ffece8Smrg 165915ffece8Smrg case " $hookable_fns " in 166015ffece8Smrg *" $1 "*) ;; 166115ffece8Smrg *) func_fatal_error "'$1' does not accept hook functions." ;; 166215ffece8Smrg esac 166315ffece8Smrg 166415ffece8Smrg eval func_append ${1}_hooks '" $2"' 166515ffece8Smrg} 166615ffece8Smrg 166715ffece8Smrg 166815ffece8Smrg# func_remove_hook FUNC_NAME HOOK_FUNC 166915ffece8Smrg# ------------------------------------ 167015ffece8Smrg# Remove HOOK_FUNC from the list of hook functions to be called by 167115ffece8Smrg# FUNC_NAME. 167215ffece8Smrgfunc_remove_hook () 167315ffece8Smrg{ 167415ffece8Smrg $debug_cmd 167515ffece8Smrg 167615ffece8Smrg eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`' 167715ffece8Smrg} 167815ffece8Smrg 167915ffece8Smrg 168015ffece8Smrg# func_propagate_result FUNC_NAME_A FUNC_NAME_B 168115ffece8Smrg# --------------------------------------------- 168215ffece8Smrg# If the *_result variable of FUNC_NAME_A _is set_, assign its value to 168315ffece8Smrg# *_result variable of FUNC_NAME_B. 168415ffece8Smrgfunc_propagate_result () 168515ffece8Smrg{ 168615ffece8Smrg $debug_cmd 168715ffece8Smrg 168815ffece8Smrg func_propagate_result_result=: 168915ffece8Smrg if eval "test \"\${${1}_result+set}\" = set" 169015ffece8Smrg then 169115ffece8Smrg eval "${2}_result=\$${1}_result" 169215ffece8Smrg else 169315ffece8Smrg func_propagate_result_result=false 169415ffece8Smrg fi 169515ffece8Smrg} 169615ffece8Smrg 169715ffece8Smrg 169815ffece8Smrg# func_run_hooks FUNC_NAME [ARG]... 169915ffece8Smrg# --------------------------------- 170015ffece8Smrg# Run all hook functions registered to FUNC_NAME. 170115ffece8Smrg# It's assumed that the list of hook functions contains nothing more 170215ffece8Smrg# than a whitespace-delimited list of legal shell function names, and 170315ffece8Smrg# no effort is wasted trying to catch shell meta-characters or preserve 170415ffece8Smrg# whitespace. 170515ffece8Smrgfunc_run_hooks () 170615ffece8Smrg{ 170715ffece8Smrg $debug_cmd 170815ffece8Smrg 170915ffece8Smrg case " $hookable_fns " in 171015ffece8Smrg *" $1 "*) ;; 171115ffece8Smrg *) func_fatal_error "'$1' does not support hook functions." ;; 1712943345d3Smrg esac 171315ffece8Smrg 171415ffece8Smrg eval _G_hook_fns=\$$1_hooks; shift 171515ffece8Smrg 171615ffece8Smrg for _G_hook in $_G_hook_fns; do 171715ffece8Smrg func_unset "${_G_hook}_result" 171815ffece8Smrg eval $_G_hook '${1+"$@"}' 171915ffece8Smrg func_propagate_result $_G_hook func_run_hooks 172015ffece8Smrg if $func_propagate_result_result; then 172115ffece8Smrg eval set dummy "$func_run_hooks_result"; shift 172215ffece8Smrg fi 172315ffece8Smrg done 172415ffece8Smrg} 172515ffece8Smrg 172615ffece8Smrg 172715ffece8Smrg 172815ffece8Smrg## --------------- ## 172915ffece8Smrg## Option parsing. ## 173015ffece8Smrg## --------------- ## 173115ffece8Smrg 173215ffece8Smrg# In order to add your own option parsing hooks, you must accept the 173315ffece8Smrg# full positional parameter list from your hook function. You may remove 173415ffece8Smrg# or edit any options that you action, and then pass back the remaining 173515ffece8Smrg# unprocessed options in '<hooked_function_name>_result', escaped 173615ffece8Smrg# suitably for 'eval'. 173715ffece8Smrg# 173815ffece8Smrg# The '<hooked_function_name>_result' variable is automatically unset 173915ffece8Smrg# before your hook gets called; for best performance, only set the 174015ffece8Smrg# *_result variable when necessary (i.e. don't call the 'func_quote' 174115ffece8Smrg# function unnecessarily because it can be an expensive operation on some 174215ffece8Smrg# machines). 174315ffece8Smrg# 174415ffece8Smrg# Like this: 174515ffece8Smrg# 174615ffece8Smrg# my_options_prep () 174715ffece8Smrg# { 174815ffece8Smrg# $debug_cmd 174915ffece8Smrg# 175015ffece8Smrg# # Extend the existing usage message. 175115ffece8Smrg# usage_message=$usage_message' 175215ffece8Smrg# -s, --silent don'\''t print informational messages 175315ffece8Smrg# ' 175415ffece8Smrg# # No change in '$@' (ignored completely by this hook). Leave 175515ffece8Smrg# # my_options_prep_result variable intact. 175615ffece8Smrg# } 175715ffece8Smrg# func_add_hook func_options_prep my_options_prep 175815ffece8Smrg# 175915ffece8Smrg# 176015ffece8Smrg# my_silent_option () 176115ffece8Smrg# { 176215ffece8Smrg# $debug_cmd 176315ffece8Smrg# 176415ffece8Smrg# args_changed=false 176515ffece8Smrg# 176615ffece8Smrg# # Note that, for efficiency, we parse as many options as we can 176715ffece8Smrg# # recognise in a loop before passing the remainder back to the 176815ffece8Smrg# # caller on the first unrecognised argument we encounter. 176915ffece8Smrg# while test $# -gt 0; do 177015ffece8Smrg# opt=$1; shift 177115ffece8Smrg# case $opt in 177215ffece8Smrg# --silent|-s) opt_silent=: 177315ffece8Smrg# args_changed=: 177415ffece8Smrg# ;; 177515ffece8Smrg# # Separate non-argument short options: 177615ffece8Smrg# -s*) func_split_short_opt "$_G_opt" 177715ffece8Smrg# set dummy "$func_split_short_opt_name" \ 177815ffece8Smrg# "-$func_split_short_opt_arg" ${1+"$@"} 177915ffece8Smrg# shift 178015ffece8Smrg# args_changed=: 178115ffece8Smrg# ;; 178215ffece8Smrg# *) # Make sure the first unrecognised option "$_G_opt" 178315ffece8Smrg# # is added back to "$@" in case we need it later, 178415ffece8Smrg# # if $args_changed was set to 'true'. 178515ffece8Smrg# set dummy "$_G_opt" ${1+"$@"}; shift; break ;; 178615ffece8Smrg# esac 178715ffece8Smrg# done 178815ffece8Smrg# 178915ffece8Smrg# # Only call 'func_quote' here if we processed at least one argument. 179015ffece8Smrg# if $args_changed; then 179115ffece8Smrg# func_quote eval ${1+"$@"} 179215ffece8Smrg# my_silent_option_result=$func_quote_result 179315ffece8Smrg# fi 179415ffece8Smrg# } 179515ffece8Smrg# func_add_hook func_parse_options my_silent_option 179615ffece8Smrg# 179715ffece8Smrg# 179815ffece8Smrg# my_option_validation () 179915ffece8Smrg# { 180015ffece8Smrg# $debug_cmd 180115ffece8Smrg# 180215ffece8Smrg# $opt_silent && $opt_verbose && func_fatal_help "\ 180315ffece8Smrg# '--silent' and '--verbose' options are mutually exclusive." 180415ffece8Smrg# } 180515ffece8Smrg# func_add_hook func_validate_options my_option_validation 180615ffece8Smrg# 180715ffece8Smrg# You'll also need to manually amend $usage_message to reflect the extra 180815ffece8Smrg# options you parse. It's preferable to append if you can, so that 180915ffece8Smrg# multiple option parsing hooks can be added safely. 181015ffece8Smrg 181115ffece8Smrg 181215ffece8Smrg# func_options_finish [ARG]... 181315ffece8Smrg# ---------------------------- 181415ffece8Smrg# Finishing the option parse loop (call 'func_options' hooks ATM). 181515ffece8Smrgfunc_options_finish () 181615ffece8Smrg{ 181715ffece8Smrg $debug_cmd 181815ffece8Smrg 181915ffece8Smrg func_run_hooks func_options ${1+"$@"} 182015ffece8Smrg func_propagate_result func_run_hooks func_options_finish 182115ffece8Smrg} 182215ffece8Smrg 182315ffece8Smrg 182415ffece8Smrg# func_options [ARG]... 182515ffece8Smrg# --------------------- 182615ffece8Smrg# All the functions called inside func_options are hookable. See the 182715ffece8Smrg# individual implementations for details. 182815ffece8Smrgfunc_hookable func_options 182915ffece8Smrgfunc_options () 183015ffece8Smrg{ 183115ffece8Smrg $debug_cmd 183215ffece8Smrg 183315ffece8Smrg _G_options_quoted=false 183415ffece8Smrg 183515ffece8Smrg for my_func in options_prep parse_options validate_options options_finish 183615ffece8Smrg do 183715ffece8Smrg func_unset func_${my_func}_result 183815ffece8Smrg func_unset func_run_hooks_result 183915ffece8Smrg eval func_$my_func '${1+"$@"}' 184015ffece8Smrg func_propagate_result func_$my_func func_options 184115ffece8Smrg if $func_propagate_result_result; then 184215ffece8Smrg eval set dummy "$func_options_result"; shift 184315ffece8Smrg _G_options_quoted=: 184415ffece8Smrg fi 184515ffece8Smrg done 184615ffece8Smrg 184715ffece8Smrg $_G_options_quoted || { 184815ffece8Smrg # As we (func_options) are top-level options-parser function and 184915ffece8Smrg # nobody quoted "$@" for us yet, we need to do it explicitly for 185015ffece8Smrg # caller. 185115ffece8Smrg func_quote eval ${1+"$@"} 185215ffece8Smrg func_options_result=$func_quote_result 185315ffece8Smrg } 1854943345d3Smrg} 1855943345d3Smrg 1856943345d3Smrg 185715ffece8Smrg# func_options_prep [ARG]... 185815ffece8Smrg# -------------------------- 185915ffece8Smrg# All initialisations required before starting the option parse loop. 186015ffece8Smrg# Note that when calling hook functions, we pass through the list of 186115ffece8Smrg# positional parameters. If a hook function modifies that list, and 186215ffece8Smrg# needs to propagate that back to rest of this script, then the complete 186315ffece8Smrg# modified list must be put in 'func_run_hooks_result' before returning. 186415ffece8Smrgfunc_hookable func_options_prep 186515ffece8Smrgfunc_options_prep () 1866943345d3Smrg{ 186715ffece8Smrg $debug_cmd 1868a7b590b3Smrg 186915ffece8Smrg # Option defaults: 187015ffece8Smrg opt_verbose=false 187115ffece8Smrg opt_warning_types= 1872a7b590b3Smrg 187315ffece8Smrg func_run_hooks func_options_prep ${1+"$@"} 187415ffece8Smrg func_propagate_result func_run_hooks func_options_prep 1875943345d3Smrg} 1876943345d3Smrg 1877943345d3Smrg 187815ffece8Smrg# func_parse_options [ARG]... 187915ffece8Smrg# --------------------------- 188015ffece8Smrg# The main option parsing loop. 188115ffece8Smrgfunc_hookable func_parse_options 188215ffece8Smrgfunc_parse_options () 1883943345d3Smrg{ 188415ffece8Smrg $debug_cmd 188515ffece8Smrg 188615ffece8Smrg _G_parse_options_requote=false 188715ffece8Smrg # this just eases exit handling 188815ffece8Smrg while test $# -gt 0; do 188915ffece8Smrg # Defer to hook functions for initial option parsing, so they 189015ffece8Smrg # get priority in the event of reusing an option name. 189115ffece8Smrg func_run_hooks func_parse_options ${1+"$@"} 189215ffece8Smrg func_propagate_result func_run_hooks func_parse_options 189315ffece8Smrg if $func_propagate_result_result; then 189415ffece8Smrg eval set dummy "$func_parse_options_result"; shift 189515ffece8Smrg # Even though we may have changed "$@", we passed the "$@" array 189615ffece8Smrg # down into the hook and it quoted it for us (because we are in 189715ffece8Smrg # this if-branch). No need to quote it again. 189815ffece8Smrg _G_parse_options_requote=false 189915ffece8Smrg fi 1900943345d3Smrg 190115ffece8Smrg # Break out of the loop if we already parsed every option. 190215ffece8Smrg test $# -gt 0 || break 190315ffece8Smrg 190415ffece8Smrg # We expect that one of the options parsed in this function matches 190515ffece8Smrg # and thus we remove _G_opt from "$@" and need to re-quote. 190615ffece8Smrg _G_match_parse_options=: 190715ffece8Smrg _G_opt=$1 190815ffece8Smrg shift 190915ffece8Smrg case $_G_opt in 191015ffece8Smrg --debug|-x) debug_cmd='set -x' 191115ffece8Smrg func_echo "enabling shell trace mode" >&2 191215ffece8Smrg $debug_cmd 191315ffece8Smrg ;; 191415ffece8Smrg 191515ffece8Smrg --no-warnings|--no-warning|--no-warn) 191615ffece8Smrg set dummy --warnings none ${1+"$@"} 191715ffece8Smrg shift 191815ffece8Smrg ;; 191915ffece8Smrg 192015ffece8Smrg --warnings|--warning|-W) 192115ffece8Smrg if test $# = 0 && func_missing_arg $_G_opt; then 192215ffece8Smrg _G_parse_options_requote=: 192315ffece8Smrg break 192415ffece8Smrg fi 192515ffece8Smrg case " $warning_categories $1" in 192615ffece8Smrg *" $1 "*) 192715ffece8Smrg # trailing space prevents matching last $1 above 192815ffece8Smrg func_append_uniq opt_warning_types " $1" 192915ffece8Smrg ;; 193015ffece8Smrg *all) 193115ffece8Smrg opt_warning_types=$warning_categories 193215ffece8Smrg ;; 193315ffece8Smrg *none) 193415ffece8Smrg opt_warning_types=none 193515ffece8Smrg warning_func=: 193615ffece8Smrg ;; 193715ffece8Smrg *error) 193815ffece8Smrg opt_warning_types=$warning_categories 193915ffece8Smrg warning_func=func_fatal_error 194015ffece8Smrg ;; 194115ffece8Smrg *) 194215ffece8Smrg func_fatal_error \ 194315ffece8Smrg "unsupported warning category: '$1'" 194415ffece8Smrg ;; 194515ffece8Smrg esac 194615ffece8Smrg shift 194715ffece8Smrg ;; 194815ffece8Smrg 194915ffece8Smrg --verbose|-v) opt_verbose=: ;; 195015ffece8Smrg --version) func_version ;; 195115ffece8Smrg -\?|-h) func_usage ;; 195215ffece8Smrg --help) func_help ;; 195315ffece8Smrg 195415ffece8Smrg # Separate optargs to long options (plugins may need this): 195515ffece8Smrg --*=*) func_split_equals "$_G_opt" 195615ffece8Smrg set dummy "$func_split_equals_lhs" \ 195715ffece8Smrg "$func_split_equals_rhs" ${1+"$@"} 195815ffece8Smrg shift 195915ffece8Smrg ;; 196015ffece8Smrg 196115ffece8Smrg # Separate optargs to short options: 196215ffece8Smrg -W*) 196315ffece8Smrg func_split_short_opt "$_G_opt" 196415ffece8Smrg set dummy "$func_split_short_opt_name" \ 196515ffece8Smrg "$func_split_short_opt_arg" ${1+"$@"} 196615ffece8Smrg shift 196715ffece8Smrg ;; 196815ffece8Smrg 196915ffece8Smrg # Separate non-argument short options: 197015ffece8Smrg -\?*|-h*|-v*|-x*) 197115ffece8Smrg func_split_short_opt "$_G_opt" 197215ffece8Smrg set dummy "$func_split_short_opt_name" \ 197315ffece8Smrg "-$func_split_short_opt_arg" ${1+"$@"} 197415ffece8Smrg shift 197515ffece8Smrg ;; 197615ffece8Smrg 197715ffece8Smrg --) _G_parse_options_requote=: ; break ;; 197815ffece8Smrg -*) func_fatal_help "unrecognised option: '$_G_opt'" ;; 197915ffece8Smrg *) set dummy "$_G_opt" ${1+"$@"}; shift 198015ffece8Smrg _G_match_parse_options=false 198115ffece8Smrg break 198215ffece8Smrg ;; 198315ffece8Smrg esac 1984a7b590b3Smrg 198515ffece8Smrg if $_G_match_parse_options; then 198615ffece8Smrg _G_parse_options_requote=: 1987a7b590b3Smrg fi 198815ffece8Smrg done 198915ffece8Smrg 199015ffece8Smrg if $_G_parse_options_requote; then 199115ffece8Smrg # save modified positional parameters for caller 199215ffece8Smrg func_quote eval ${1+"$@"} 199315ffece8Smrg func_parse_options_result=$func_quote_result 1994943345d3Smrg fi 1995943345d3Smrg} 1996943345d3Smrg 1997a7b590b3Smrg 199815ffece8Smrg# func_validate_options [ARG]... 199915ffece8Smrg# ------------------------------ 200015ffece8Smrg# Perform any sanity checks on option settings and/or unconsumed 200115ffece8Smrg# arguments. 200215ffece8Smrgfunc_hookable func_validate_options 200315ffece8Smrgfunc_validate_options () 2004943345d3Smrg{ 200515ffece8Smrg $debug_cmd 2006a7b590b3Smrg 200715ffece8Smrg # Display all warnings if -W was not given. 200815ffece8Smrg test -n "$opt_warning_types" || opt_warning_types=" $warning_categories" 2009a7b590b3Smrg 201015ffece8Smrg func_run_hooks func_validate_options ${1+"$@"} 201115ffece8Smrg func_propagate_result func_run_hooks func_validate_options 2012943345d3Smrg 201315ffece8Smrg # Bail if the options were screwed! 201415ffece8Smrg $exit_cmd $EXIT_FAILURE 20153e51e026Smrg} 2016a7b590b3Smrg 2017a7b590b3Smrg 20183e51e026Smrg 201915ffece8Smrg## ----------------- ## 202015ffece8Smrg## Helper functions. ## 202115ffece8Smrg## ----------------- ## 2022a7b590b3Smrg 202315ffece8Smrg# This section contains the helper functions used by the rest of the 202415ffece8Smrg# hookable option parser framework in ascii-betical order. 202515ffece8Smrg 202615ffece8Smrg 202715ffece8Smrg# func_fatal_help ARG... 202815ffece8Smrg# ---------------------- 202915ffece8Smrg# Echo program name prefixed message to standard error, followed by 203015ffece8Smrg# a help hint, and exit. 203115ffece8Smrgfunc_fatal_help () 2032a7b590b3Smrg{ 203315ffece8Smrg $debug_cmd 20343e51e026Smrg 203515ffece8Smrg eval \$ECHO \""Usage: $usage"\" 203615ffece8Smrg eval \$ECHO \""$fatal_help"\" 203715ffece8Smrg func_error ${1+"$@"} 203815ffece8Smrg exit $EXIT_FAILURE 2039a7b590b3Smrg} 2040a7b590b3Smrg 204115ffece8Smrg 204215ffece8Smrg# func_help 204315ffece8Smrg# --------- 204415ffece8Smrg# Echo long help message to standard output and exit. 2045a7b590b3Smrgfunc_help () 2046a7b590b3Smrg{ 204715ffece8Smrg $debug_cmd 204815ffece8Smrg 204915ffece8Smrg func_usage_message 205015ffece8Smrg $ECHO "$long_help_message" 205115ffece8Smrg exit 0 2052a7b590b3Smrg} 2053a7b590b3Smrg 205415ffece8Smrg 205515ffece8Smrg# func_missing_arg ARGNAME 205615ffece8Smrg# ------------------------ 2057a7b590b3Smrg# Echo program name prefixed message to standard error and set global 2058a7b590b3Smrg# exit_cmd. 2059a7b590b3Smrgfunc_missing_arg () 2060a7b590b3Smrg{ 206115ffece8Smrg $debug_cmd 20623e51e026Smrg 206315ffece8Smrg func_error "Missing argument for '$1'." 2064a7b590b3Smrg exit_cmd=exit 2065943345d3Smrg} 2066943345d3Smrg 2067943345d3Smrg 206815ffece8Smrg# func_split_equals STRING 206915ffece8Smrg# ------------------------ 207015ffece8Smrg# Set func_split_equals_lhs and func_split_equals_rhs shell variables 207115ffece8Smrg# after splitting STRING at the '=' sign. 207215ffece8Smrgtest -z "$_G_HAVE_XSI_OPS" \ 207315ffece8Smrg && (eval 'x=a/b/c; 207415ffece8Smrg test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ 207515ffece8Smrg && _G_HAVE_XSI_OPS=yes 207615ffece8Smrg 207715ffece8Smrgif test yes = "$_G_HAVE_XSI_OPS" 207815ffece8Smrgthen 207915ffece8Smrg # This is an XSI compatible shell, allowing a faster implementation... 208015ffece8Smrg eval 'func_split_equals () 208115ffece8Smrg { 208215ffece8Smrg $debug_cmd 208315ffece8Smrg 208415ffece8Smrg func_split_equals_lhs=${1%%=*} 208515ffece8Smrg func_split_equals_rhs=${1#*=} 208615ffece8Smrg if test "x$func_split_equals_lhs" = "x$1"; then 208715ffece8Smrg func_split_equals_rhs= 208815ffece8Smrg fi 208915ffece8Smrg }' 209015ffece8Smrgelse 209115ffece8Smrg # ...otherwise fall back to using expr, which is often a shell builtin. 209215ffece8Smrg func_split_equals () 209315ffece8Smrg { 209415ffece8Smrg $debug_cmd 209515ffece8Smrg 209615ffece8Smrg func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'` 209715ffece8Smrg func_split_equals_rhs= 209815ffece8Smrg test "x$func_split_equals_lhs=" = "x$1" \ 209915ffece8Smrg || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'` 210015ffece8Smrg } 210115ffece8Smrgfi #func_split_equals 210215ffece8Smrg 210315ffece8Smrg 210415ffece8Smrg# func_split_short_opt SHORTOPT 210515ffece8Smrg# ----------------------------- 21063e51e026Smrg# Set func_split_short_opt_name and func_split_short_opt_arg shell 21073e51e026Smrg# variables after splitting SHORTOPT after the 2nd character. 210815ffece8Smrgif test yes = "$_G_HAVE_XSI_OPS" 210915ffece8Smrgthen 211015ffece8Smrg # This is an XSI compatible shell, allowing a faster implementation... 211115ffece8Smrg eval 'func_split_short_opt () 211215ffece8Smrg { 211315ffece8Smrg $debug_cmd 211415ffece8Smrg 211515ffece8Smrg func_split_short_opt_arg=${1#??} 211615ffece8Smrg func_split_short_opt_name=${1%"$func_split_short_opt_arg"} 211715ffece8Smrg }' 211815ffece8Smrgelse 211915ffece8Smrg # ...otherwise fall back to using expr, which is often a shell builtin. 212015ffece8Smrg func_split_short_opt () 212115ffece8Smrg { 212215ffece8Smrg $debug_cmd 212315ffece8Smrg 212415ffece8Smrg func_split_short_opt_name=`expr "x$1" : 'x\(-.\)'` 212515ffece8Smrg func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'` 212615ffece8Smrg } 212715ffece8Smrgfi #func_split_short_opt 212815ffece8Smrg 212915ffece8Smrg 213015ffece8Smrg# func_usage 213115ffece8Smrg# ---------- 213215ffece8Smrg# Echo short help message to standard output and exit. 213315ffece8Smrgfunc_usage () 21343e51e026Smrg{ 213515ffece8Smrg $debug_cmd 2136943345d3Smrg 213715ffece8Smrg func_usage_message 213815ffece8Smrg $ECHO "Run '$progname --help |${PAGER-more}' for full usage" 213915ffece8Smrg exit 0 214015ffece8Smrg} 21413e51e026Smrg 21423e51e026Smrg 214315ffece8Smrg# func_usage_message 214415ffece8Smrg# ------------------ 214515ffece8Smrg# Echo short help message to standard output. 214615ffece8Smrgfunc_usage_message () 21473e51e026Smrg{ 214815ffece8Smrg $debug_cmd 214915ffece8Smrg 215015ffece8Smrg eval \$ECHO \""Usage: $usage"\" 215115ffece8Smrg echo 215215ffece8Smrg $SED -n 's|^# || 215315ffece8Smrg /^Written by/{ 215415ffece8Smrg x;p;x 215515ffece8Smrg } 215615ffece8Smrg h 215715ffece8Smrg /^Written by/q' < "$progpath" 215815ffece8Smrg echo 215915ffece8Smrg eval \$ECHO \""$usage_message"\" 216015ffece8Smrg} 21613e51e026Smrg 21623e51e026Smrg 216315ffece8Smrg# func_version 216415ffece8Smrg# ------------ 216515ffece8Smrg# Echo version message to standard output and exit. 216615ffece8Smrg# The version message is extracted from the calling file's header 216715ffece8Smrg# comments, with leading '# ' stripped: 216815ffece8Smrg# 1. First display the progname and version 216915ffece8Smrg# 2. Followed by the header comment line matching /^# Written by / 217015ffece8Smrg# 3. Then a blank line followed by the first following line matching 217115ffece8Smrg# /^# Copyright / 217215ffece8Smrg# 4. Immediately followed by any lines between the previous matches, 217315ffece8Smrg# except lines preceding the intervening completely blank line. 217415ffece8Smrg# For example, see the header comments of this file. 217515ffece8Smrgfunc_version () 217615ffece8Smrg{ 217715ffece8Smrg $debug_cmd 217815ffece8Smrg 217915ffece8Smrg printf '%s\n' "$progname $scriptversion" 218015ffece8Smrg $SED -n ' 218115ffece8Smrg /^# Written by /!b 218215ffece8Smrg s|^# ||; p; n 2183a7b590b3Smrg 218415ffece8Smrg :fwd2blnk 218515ffece8Smrg /./ { 218615ffece8Smrg n 218715ffece8Smrg b fwd2blnk 218815ffece8Smrg } 218915ffece8Smrg p; n 219015ffece8Smrg 219115ffece8Smrg :holdwrnt 219215ffece8Smrg s|^# || 219315ffece8Smrg s|^# *$|| 219415ffece8Smrg /^Copyright /!{ 219515ffece8Smrg /./H 219615ffece8Smrg n 219715ffece8Smrg b holdwrnt 219815ffece8Smrg } 2199a7b590b3Smrg 220015ffece8Smrg s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2| 220115ffece8Smrg G 220215ffece8Smrg s|\(\n\)\n*|\1|g 220315ffece8Smrg p; q' < "$progpath" 2204a7b590b3Smrg 220515ffece8Smrg exit $? 220615ffece8Smrg} 2207943345d3Smrg 2208943345d3Smrg 220915ffece8Smrg# Local variables: 221015ffece8Smrg# mode: shell-script 221115ffece8Smrg# sh-indentation: 2 221215ffece8Smrg# eval: (add-hook 'before-save-hook 'time-stamp) 221315ffece8Smrg# time-stamp-pattern: "30/scriptversion=%:y-%02m-%02d.%02H; # UTC" 221415ffece8Smrg# time-stamp-time-zone: "UTC" 221515ffece8Smrg# End: 2216943345d3Smrg 221715ffece8Smrg# Set a version string. 221815ffece8Smrgscriptversion='(GNU libtool) 2.4.7' 2219943345d3Smrg 2220a7b590b3Smrg 222115ffece8Smrg# func_echo ARG... 222215ffece8Smrg# ---------------- 222315ffece8Smrg# Libtool also displays the current mode in messages, so override 222415ffece8Smrg# funclib.sh func_echo with this custom definition. 222515ffece8Smrgfunc_echo () 22263e51e026Smrg{ 222715ffece8Smrg $debug_cmd 22283e51e026Smrg 222915ffece8Smrg _G_message=$* 223015ffece8Smrg 223115ffece8Smrg func_echo_IFS=$IFS 223215ffece8Smrg IFS=$nl 223315ffece8Smrg for _G_line in $_G_message; do 223415ffece8Smrg IFS=$func_echo_IFS 223515ffece8Smrg $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line" 223615ffece8Smrg done 223715ffece8Smrg IFS=$func_echo_IFS 223815ffece8Smrg} 22393e51e026Smrg 22403e51e026Smrg 224115ffece8Smrg# func_warning ARG... 224215ffece8Smrg# ------------------- 224315ffece8Smrg# Libtool warnings are not categorized, so override funclib.sh 224415ffece8Smrg# func_warning with this simpler definition. 224515ffece8Smrgfunc_warning () 22463e51e026Smrg{ 224715ffece8Smrg $debug_cmd 22483e51e026Smrg 224915ffece8Smrg $warning_func ${1+"$@"} 225015ffece8Smrg} 22513e51e026Smrg 22523e51e026Smrg 225315ffece8Smrg## ---------------- ## 225415ffece8Smrg## Options parsing. ## 225515ffece8Smrg## ---------------- ## 225615ffece8Smrg 225715ffece8Smrg# Hook in the functions to make sure our own options are parsed during 225815ffece8Smrg# the option parsing loop. 225915ffece8Smrg 226015ffece8Smrgusage='$progpath [OPTION]... [MODE-ARG]...' 226115ffece8Smrg 226215ffece8Smrg# Short help message in response to '-h'. 226315ffece8Smrgusage_message="Options: 226415ffece8Smrg --config show all configuration variables 226515ffece8Smrg --debug enable verbose shell tracing 226615ffece8Smrg -n, --dry-run display commands without modifying any files 226715ffece8Smrg --features display basic configuration information and exit 226815ffece8Smrg --mode=MODE use operation mode MODE 226915ffece8Smrg --no-warnings equivalent to '-Wnone' 227015ffece8Smrg --preserve-dup-deps don't remove duplicate dependency libraries 227115ffece8Smrg --quiet, --silent don't print informational messages 227215ffece8Smrg --tag=TAG use configuration variables from tag TAG 227315ffece8Smrg -v, --verbose print more informational messages than default 227415ffece8Smrg --version print version information 227515ffece8Smrg -W, --warnings=CATEGORY report the warnings falling in CATEGORY [all] 227615ffece8Smrg -h, --help, --help-all print short, long, or detailed help message 227715ffece8Smrg" 22783e51e026Smrg 227915ffece8Smrg# Additional text appended to 'usage_message' in response to '--help'. 228015ffece8Smrgfunc_help () 22813e51e026Smrg{ 228215ffece8Smrg $debug_cmd 228315ffece8Smrg 228415ffece8Smrg func_usage_message 228515ffece8Smrg $ECHO "$long_help_message 228615ffece8Smrg 228715ffece8SmrgMODE must be one of the following: 228815ffece8Smrg 228915ffece8Smrg clean remove files from the build directory 229015ffece8Smrg compile compile a source file into a libtool object 229115ffece8Smrg execute automatically set library path, then run a program 229215ffece8Smrg finish complete the installation of libtool libraries 229315ffece8Smrg install install libraries or executables 229415ffece8Smrg link create a library or an executable 229515ffece8Smrg uninstall remove libraries from an installed directory 229615ffece8Smrg 229715ffece8SmrgMODE-ARGS vary depending on the MODE. When passed as first option, 229815ffece8Smrg'--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that. 229915ffece8SmrgTry '$progname --help --mode=MODE' for a more detailed description of MODE. 230015ffece8Smrg 230115ffece8SmrgWhen reporting a bug, please describe a test case to reproduce it and 230215ffece8Smrginclude the following information: 230315ffece8Smrg 230415ffece8Smrg host-triplet: $host 230515ffece8Smrg shell: $SHELL 230615ffece8Smrg compiler: $LTCC 230715ffece8Smrg compiler flags: $LTCFLAGS 230815ffece8Smrg linker: $LD (gnu? $with_gnu_ld) 230915ffece8Smrg version: $progname (GNU libtool) 2.4.7 231015ffece8Smrg automake: `($AUTOMAKE --version) 2>/dev/null |$SED 1q` 231115ffece8Smrg autoconf: `($AUTOCONF --version) 2>/dev/null |$SED 1q` 231215ffece8Smrg 231315ffece8SmrgReport bugs to <bug-libtool@gnu.org>. 231415ffece8SmrgGNU libtool home page: <http://www.gnu.org/software/libtool/>. 231515ffece8SmrgGeneral help using GNU software: <http://www.gnu.org/gethelp/>." 231615ffece8Smrg exit 0 231715ffece8Smrg} 23183e51e026Smrg 23193e51e026Smrg 232015ffece8Smrg# func_lo2o OBJECT-NAME 232115ffece8Smrg# --------------------- 232215ffece8Smrg# Transform OBJECT-NAME from a '.lo' suffix to the platform specific 232315ffece8Smrg# object suffix. 232415ffece8Smrg 232515ffece8Smrglo2o=s/\\.lo\$/.$objext/ 232615ffece8Smrgo2lo=s/\\.$objext\$/.lo/ 232715ffece8Smrg 232815ffece8Smrgif test yes = "$_G_HAVE_XSI_OPS"; then 232915ffece8Smrg eval 'func_lo2o () 233015ffece8Smrg { 233115ffece8Smrg case $1 in 233215ffece8Smrg *.lo) func_lo2o_result=${1%.lo}.$objext ;; 233315ffece8Smrg * ) func_lo2o_result=$1 ;; 233415ffece8Smrg esac 233515ffece8Smrg }' 23363e51e026Smrg 233715ffece8Smrg # func_xform LIBOBJ-OR-SOURCE 233815ffece8Smrg # --------------------------- 233915ffece8Smrg # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise) 234015ffece8Smrg # suffix to a '.lo' libtool-object suffix. 234115ffece8Smrg eval 'func_xform () 234215ffece8Smrg { 234315ffece8Smrg func_xform_result=${1%.*}.lo 234415ffece8Smrg }' 234515ffece8Smrgelse 234615ffece8Smrg # ...otherwise fall back to using sed. 234715ffece8Smrg func_lo2o () 234815ffece8Smrg { 234915ffece8Smrg func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"` 235015ffece8Smrg } 235115ffece8Smrg 235215ffece8Smrg func_xform () 235315ffece8Smrg { 235415ffece8Smrg func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'` 235515ffece8Smrg } 235615ffece8Smrgfi 23573e51e026Smrg 235815ffece8Smrg 235915ffece8Smrg# func_fatal_configuration ARG... 236015ffece8Smrg# ------------------------------- 2361a7b590b3Smrg# Echo program name prefixed message to standard error, followed by 2362a7b590b3Smrg# a configuration failure hint, and exit. 2363a7b590b3Smrgfunc_fatal_configuration () 2364a7b590b3Smrg{ 236515ffece8Smrg func_fatal_error ${1+"$@"} \ 236615ffece8Smrg "See the $PACKAGE documentation for more information." \ 236715ffece8Smrg "Fatal configuration error." 2368a7b590b3Smrg} 2369943345d3Smrg 23705e695a52Smrg 2371a7b590b3Smrg# func_config 237215ffece8Smrg# ----------- 2373a7b590b3Smrg# Display the configuration for all the tags in this script. 2374a7b590b3Smrgfunc_config () 2375a7b590b3Smrg{ 2376a7b590b3Smrg re_begincf='^# ### BEGIN LIBTOOL' 2377a7b590b3Smrg re_endcf='^# ### END LIBTOOL' 2378a7b590b3Smrg 2379a7b590b3Smrg # Default configuration. 2380a7b590b3Smrg $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" 2381943345d3Smrg 2382943345d3Smrg # Now print the configurations for the tags. 2383943345d3Smrg for tagname in $taglist; do 2384a7b590b3Smrg $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" 2385943345d3Smrg done 2386943345d3Smrg 2387a7b590b3Smrg exit $? 2388a7b590b3Smrg} 2389943345d3Smrg 239015ffece8Smrg 2391a7b590b3Smrg# func_features 239215ffece8Smrg# ------------- 2393a7b590b3Smrg# Display the features supported by this script. 2394a7b590b3Smrgfunc_features () 2395a7b590b3Smrg{ 23963e51e026Smrg echo "host: $host" 239715ffece8Smrg if test yes = "$build_libtool_libs"; then 23983e51e026Smrg echo "enable shared libraries" 2399943345d3Smrg else 24003e51e026Smrg echo "disable shared libraries" 2401943345d3Smrg fi 240215ffece8Smrg if test yes = "$build_old_libs"; then 24033e51e026Smrg echo "enable static libraries" 2404943345d3Smrg else 24053e51e026Smrg echo "disable static libraries" 2406943345d3Smrg fi 2407a7b590b3Smrg 2408943345d3Smrg exit $? 2409a7b590b3Smrg} 2410943345d3Smrg 241115ffece8Smrg 241215ffece8Smrg# func_enable_tag TAGNAME 241315ffece8Smrg# ----------------------- 2414a7b590b3Smrg# Verify that TAGNAME is valid, and either flag an error and exit, or 2415a7b590b3Smrg# enable the TAGNAME tag. We also add TAGNAME to the global $taglist 2416a7b590b3Smrg# variable here. 2417a7b590b3Smrgfunc_enable_tag () 2418a7b590b3Smrg{ 241915ffece8Smrg # Global variable: 242015ffece8Smrg tagname=$1 2421943345d3Smrg 242215ffece8Smrg re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" 242315ffece8Smrg re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" 242415ffece8Smrg sed_extractcf=/$re_begincf/,/$re_endcf/p 2425943345d3Smrg 242615ffece8Smrg # Validate tagname. 242715ffece8Smrg case $tagname in 242815ffece8Smrg *[!-_A-Za-z0-9,/]*) 242915ffece8Smrg func_fatal_error "invalid tag name: $tagname" 243015ffece8Smrg ;; 243115ffece8Smrg esac 2432943345d3Smrg 243315ffece8Smrg # Don't test for the "default" C tag, as we know it's 243415ffece8Smrg # there but not specially marked. 243515ffece8Smrg case $tagname in 243615ffece8Smrg CC) ;; 2437a7b590b3Smrg *) 243815ffece8Smrg if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then 243915ffece8Smrg taglist="$taglist $tagname" 244015ffece8Smrg 244115ffece8Smrg # Evaluate the configuration. Be careful to quote the path 244215ffece8Smrg # and the sed script, to avoid splitting on whitespace, but 244315ffece8Smrg # also don't use non-portable quotes within backquotes within 244415ffece8Smrg # quotes we have to do it in 2 steps: 244515ffece8Smrg extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` 244615ffece8Smrg eval "$extractedcf" 244715ffece8Smrg else 244815ffece8Smrg func_error "ignoring unknown tag $tagname" 244915ffece8Smrg fi 245015ffece8Smrg ;; 245115ffece8Smrg esac 2452a7b590b3Smrg} 2453a7b590b3Smrg 245415ffece8Smrg 24553e51e026Smrg# func_check_version_match 245615ffece8Smrg# ------------------------ 24573e51e026Smrg# Ensure that we are using m4 macros, and libtool script from the same 24583e51e026Smrg# release of libtool. 24593e51e026Smrgfunc_check_version_match () 2460a7b590b3Smrg{ 246115ffece8Smrg if test "$package_revision" != "$macro_revision"; then 246215ffece8Smrg if test "$VERSION" != "$macro_version"; then 246315ffece8Smrg if test -z "$macro_version"; then 246415ffece8Smrg cat >&2 <<_LT_EOF 24653e51e026Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 24663e51e026Smrg$progname: definition of this LT_INIT comes from an older release. 24673e51e026Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 24683e51e026Smrg$progname: and run autoconf again. 24693e51e026Smrg_LT_EOF 247015ffece8Smrg else 247115ffece8Smrg cat >&2 <<_LT_EOF 24723e51e026Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 24733e51e026Smrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version. 24743e51e026Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 24753e51e026Smrg$progname: and run autoconf again. 24763e51e026Smrg_LT_EOF 247715ffece8Smrg fi 247815ffece8Smrg else 247915ffece8Smrg cat >&2 <<_LT_EOF 24803e51e026Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, 24813e51e026Smrg$progname: but the definition of this LT_INIT comes from revision $macro_revision. 24823e51e026Smrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision 24833e51e026Smrg$progname: of $PACKAGE $VERSION and run autoconf again. 24843e51e026Smrg_LT_EOF 248515ffece8Smrg fi 24863e51e026Smrg 248715ffece8Smrg exit $EXIT_MISMATCH 248815ffece8Smrg fi 24893e51e026Smrg} 24903e51e026Smrg 24913e51e026Smrg 249215ffece8Smrg# libtool_options_prep [ARG]... 249315ffece8Smrg# ----------------------------- 249415ffece8Smrg# Preparation for options parsed by libtool. 249515ffece8Smrglibtool_options_prep () 249615ffece8Smrg{ 249715ffece8Smrg $debug_mode 24983e51e026Smrg 249915ffece8Smrg # Option defaults: 250015ffece8Smrg opt_config=false 250115ffece8Smrg opt_dlopen= 250215ffece8Smrg opt_dry_run=false 250315ffece8Smrg opt_help=false 250415ffece8Smrg opt_mode= 250515ffece8Smrg opt_preserve_dup_deps=false 250615ffece8Smrg opt_quiet=false 25073e51e026Smrg 250815ffece8Smrg nonopt= 250915ffece8Smrg preserve_args= 2510943345d3Smrg 251115ffece8Smrg _G_rc_lt_options_prep=: 2512943345d3Smrg 251315ffece8Smrg # Shorthand for --mode=foo, only valid as the first argument 251415ffece8Smrg case $1 in 251515ffece8Smrg clean|clea|cle|cl) 251615ffece8Smrg shift; set dummy --mode clean ${1+"$@"}; shift 251715ffece8Smrg ;; 251815ffece8Smrg compile|compil|compi|comp|com|co|c) 251915ffece8Smrg shift; set dummy --mode compile ${1+"$@"}; shift 252015ffece8Smrg ;; 252115ffece8Smrg execute|execut|execu|exec|exe|ex|e) 252215ffece8Smrg shift; set dummy --mode execute ${1+"$@"}; shift 252315ffece8Smrg ;; 252415ffece8Smrg finish|finis|fini|fin|fi|f) 252515ffece8Smrg shift; set dummy --mode finish ${1+"$@"}; shift 252615ffece8Smrg ;; 252715ffece8Smrg install|instal|insta|inst|ins|in|i) 252815ffece8Smrg shift; set dummy --mode install ${1+"$@"}; shift 252915ffece8Smrg ;; 253015ffece8Smrg link|lin|li|l) 253115ffece8Smrg shift; set dummy --mode link ${1+"$@"}; shift 253215ffece8Smrg ;; 253315ffece8Smrg uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) 253415ffece8Smrg shift; set dummy --mode uninstall ${1+"$@"}; shift 253515ffece8Smrg ;; 253615ffece8Smrg *) 253715ffece8Smrg _G_rc_lt_options_prep=false 253815ffece8Smrg ;; 2539a7b590b3Smrg esac 2540a7b590b3Smrg 254115ffece8Smrg if $_G_rc_lt_options_prep; then 254215ffece8Smrg # Pass back the list of options. 254315ffece8Smrg func_quote eval ${1+"$@"} 254415ffece8Smrg libtool_options_prep_result=$func_quote_result 254515ffece8Smrg fi 254615ffece8Smrg} 254715ffece8Smrgfunc_add_hook func_options_prep libtool_options_prep 25483e51e026Smrg 25493e51e026Smrg 255015ffece8Smrg# libtool_parse_options [ARG]... 255115ffece8Smrg# --------------------------------- 255215ffece8Smrg# Provide handling for libtool specific options. 255315ffece8Smrglibtool_parse_options () 255415ffece8Smrg{ 255515ffece8Smrg $debug_cmd 2556a7b590b3Smrg 255715ffece8Smrg _G_rc_lt_parse_options=false 2558943345d3Smrg 255915ffece8Smrg # Perform our own loop to consume as many options as possible in 256015ffece8Smrg # each iteration. 256115ffece8Smrg while test $# -gt 0; do 256215ffece8Smrg _G_match_lt_parse_options=: 256315ffece8Smrg _G_opt=$1 256415ffece8Smrg shift 256515ffece8Smrg case $_G_opt in 256615ffece8Smrg --dry-run|--dryrun|-n) 256715ffece8Smrg opt_dry_run=: 256815ffece8Smrg ;; 256915ffece8Smrg 257015ffece8Smrg --config) func_config ;; 257115ffece8Smrg 257215ffece8Smrg --dlopen|-dlopen) 257315ffece8Smrg opt_dlopen="${opt_dlopen+$opt_dlopen 257415ffece8Smrg}$1" 257515ffece8Smrg shift 257615ffece8Smrg ;; 257715ffece8Smrg 257815ffece8Smrg --preserve-dup-deps) 257915ffece8Smrg opt_preserve_dup_deps=: ;; 258015ffece8Smrg 258115ffece8Smrg --features) func_features ;; 258215ffece8Smrg 258315ffece8Smrg --finish) set dummy --mode finish ${1+"$@"}; shift ;; 258415ffece8Smrg 258515ffece8Smrg --help) opt_help=: ;; 258615ffece8Smrg 258715ffece8Smrg --help-all) opt_help=': help-all' ;; 258815ffece8Smrg 258915ffece8Smrg --mode) test $# = 0 && func_missing_arg $_G_opt && break 259015ffece8Smrg opt_mode=$1 259115ffece8Smrg case $1 in 259215ffece8Smrg # Valid mode arguments: 259315ffece8Smrg clean|compile|execute|finish|install|link|relink|uninstall) ;; 259415ffece8Smrg 259515ffece8Smrg # Catch anything else as an error 259615ffece8Smrg *) func_error "invalid argument for $_G_opt" 259715ffece8Smrg exit_cmd=exit 259815ffece8Smrg break 259915ffece8Smrg ;; 260015ffece8Smrg esac 260115ffece8Smrg shift 260215ffece8Smrg ;; 260315ffece8Smrg 260415ffece8Smrg --no-silent|--no-quiet) 260515ffece8Smrg opt_quiet=false 260615ffece8Smrg func_append preserve_args " $_G_opt" 260715ffece8Smrg ;; 260815ffece8Smrg 260915ffece8Smrg --no-warnings|--no-warning|--no-warn) 261015ffece8Smrg opt_warning=false 261115ffece8Smrg func_append preserve_args " $_G_opt" 261215ffece8Smrg ;; 261315ffece8Smrg 261415ffece8Smrg --no-verbose) 261515ffece8Smrg opt_verbose=false 261615ffece8Smrg func_append preserve_args " $_G_opt" 261715ffece8Smrg ;; 261815ffece8Smrg 261915ffece8Smrg --silent|--quiet) 262015ffece8Smrg opt_quiet=: 262115ffece8Smrg opt_verbose=false 262215ffece8Smrg func_append preserve_args " $_G_opt" 262315ffece8Smrg ;; 262415ffece8Smrg 262515ffece8Smrg --tag) test $# = 0 && func_missing_arg $_G_opt && break 262615ffece8Smrg opt_tag=$1 262715ffece8Smrg func_append preserve_args " $_G_opt $1" 262815ffece8Smrg func_enable_tag "$1" 262915ffece8Smrg shift 263015ffece8Smrg ;; 263115ffece8Smrg 263215ffece8Smrg --verbose|-v) opt_quiet=false 263315ffece8Smrg opt_verbose=: 263415ffece8Smrg func_append preserve_args " $_G_opt" 263515ffece8Smrg ;; 263615ffece8Smrg 263715ffece8Smrg # An option not handled by this hook function: 263815ffece8Smrg *) set dummy "$_G_opt" ${1+"$@"} ; shift 263915ffece8Smrg _G_match_lt_parse_options=false 264015ffece8Smrg break 264115ffece8Smrg ;; 264215ffece8Smrg esac 264315ffece8Smrg $_G_match_lt_parse_options && _G_rc_lt_parse_options=: 264415ffece8Smrg done 2645a7b590b3Smrg 264615ffece8Smrg if $_G_rc_lt_parse_options; then 264715ffece8Smrg # save modified positional parameters for caller 264815ffece8Smrg func_quote eval ${1+"$@"} 264915ffece8Smrg libtool_parse_options_result=$func_quote_result 2650a7b590b3Smrg fi 265115ffece8Smrg} 265215ffece8Smrgfunc_add_hook func_parse_options libtool_parse_options 2653a7b590b3Smrg 2654a7b590b3Smrg 265515ffece8Smrg 265615ffece8Smrg# libtool_validate_options [ARG]... 265715ffece8Smrg# --------------------------------- 265815ffece8Smrg# Perform any sanity checks on option settings and/or unconsumed 265915ffece8Smrg# arguments. 266015ffece8Smrglibtool_validate_options () 266115ffece8Smrg{ 266215ffece8Smrg # save first non-option argument 266315ffece8Smrg if test 0 -lt $#; then 266415ffece8Smrg nonopt=$1 266515ffece8Smrg shift 26663e51e026Smrg fi 2667943345d3Smrg 266815ffece8Smrg # preserve --debug 266915ffece8Smrg test : = "$debug_cmd" || func_append preserve_args " --debug" 267015ffece8Smrg 267115ffece8Smrg case $host in 267215ffece8Smrg # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452 267315ffece8Smrg # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788 267415ffece8Smrg *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*) 267515ffece8Smrg # don't eliminate duplications in $postdeps and $predeps 267615ffece8Smrg opt_duplicate_compiler_generated_deps=: 267715ffece8Smrg ;; 267815ffece8Smrg *) 267915ffece8Smrg opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps 268015ffece8Smrg ;; 268115ffece8Smrg esac 268215ffece8Smrg 268315ffece8Smrg $opt_help || { 268415ffece8Smrg # Sanity checks first: 268515ffece8Smrg func_check_version_match 268615ffece8Smrg 268715ffece8Smrg test yes != "$build_libtool_libs" \ 268815ffece8Smrg && test yes != "$build_old_libs" \ 268915ffece8Smrg && func_fatal_configuration "not configured to build any kind of library" 2690a7b590b3Smrg 269115ffece8Smrg # Darwin sucks 269215ffece8Smrg eval std_shrext=\"$shrext_cmds\" 269315ffece8Smrg 269415ffece8Smrg # Only execute mode is allowed to have -dlopen flags. 269515ffece8Smrg if test -n "$opt_dlopen" && test execute != "$opt_mode"; then 269615ffece8Smrg func_error "unrecognized option '-dlopen'" 269715ffece8Smrg $ECHO "$help" 1>&2 269815ffece8Smrg exit $EXIT_FAILURE 269915ffece8Smrg fi 270015ffece8Smrg 270115ffece8Smrg # Change the help message to a mode-specific one. 270215ffece8Smrg generic_help=$help 270315ffece8Smrg help="Try '$progname --help --mode=$opt_mode' for more information." 270415ffece8Smrg } 2705a7b590b3Smrg 270615ffece8Smrg # Pass back the unparsed argument list 270715ffece8Smrg func_quote eval ${1+"$@"} 270815ffece8Smrg libtool_validate_options_result=$func_quote_result 27093e51e026Smrg} 271015ffece8Smrgfunc_add_hook func_validate_options libtool_validate_options 2711a7b590b3Smrg 2712a7b590b3Smrg 271315ffece8Smrg# Process options as early as possible so that --help and --version 271415ffece8Smrg# can return quickly. 271515ffece8Smrgfunc_options ${1+"$@"} 271615ffece8Smrgeval set dummy "$func_options_result"; shift 271715ffece8Smrg 2718943345d3Smrg 2719943345d3Smrg 27203e51e026Smrg## ----------- ## 27213e51e026Smrg## Main. ## 27223e51e026Smrg## ----------- ## 2723943345d3Smrg 272415ffece8Smrgmagic='%%%MAGIC variable%%%' 272515ffece8Smrgmagic_exe='%%%MAGIC EXE variable%%%' 272615ffece8Smrg 272715ffece8Smrg# Global variables. 272815ffece8Smrgextracted_archives= 272915ffece8Smrgextracted_serial=0 273015ffece8Smrg 273115ffece8Smrg# If this variable is set in any of the actions, the command in it 273215ffece8Smrg# will be execed at the end. This prevents here-documents from being 273315ffece8Smrg# left over by shells. 273415ffece8Smrgexec_cmd= 273515ffece8Smrg 273615ffece8Smrg 273715ffece8Smrg# A function that is used when there is no print builtin or printf. 273815ffece8Smrgfunc_fallback_echo () 273915ffece8Smrg{ 274015ffece8Smrg eval 'cat <<_LTECHO_EOF 274115ffece8Smrg$1 274215ffece8Smrg_LTECHO_EOF' 274315ffece8Smrg} 274415ffece8Smrg 274515ffece8Smrg# func_generated_by_libtool 274615ffece8Smrg# True iff stdin has been generated by Libtool. This function is only 274715ffece8Smrg# a basic sanity check; it will hardly flush out determined imposters. 274815ffece8Smrgfunc_generated_by_libtool_p () 274915ffece8Smrg{ 275015ffece8Smrg $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 275115ffece8Smrg} 275215ffece8Smrg 2753a7b590b3Smrg# func_lalib_p file 275415ffece8Smrg# True iff FILE is a libtool '.la' library or '.lo' object file. 2755a7b590b3Smrg# This function is only a basic sanity check; it will hardly flush out 2756a7b590b3Smrg# determined imposters. 2757a7b590b3Smrgfunc_lalib_p () 2758a7b590b3Smrg{ 2759a7b590b3Smrg test -f "$1" && 276015ffece8Smrg $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p 2761a7b590b3Smrg} 2762943345d3Smrg 2763a7b590b3Smrg# func_lalib_unsafe_p file 276415ffece8Smrg# True iff FILE is a libtool '.la' library or '.lo' object file. 2765a7b590b3Smrg# This function implements the same check as func_lalib_p without 2766a7b590b3Smrg# resorting to external programs. To this end, it redirects stdin and 2767a7b590b3Smrg# closes it afterwards, without saving the original file descriptor. 2768a7b590b3Smrg# As a safety measure, use it only where a negative result would be 276915ffece8Smrg# fatal anyway. Works if 'file' does not exist. 2770a7b590b3Smrgfunc_lalib_unsafe_p () 2771a7b590b3Smrg{ 2772a7b590b3Smrg lalib_p=no 2773a7b590b3Smrg if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then 2774a7b590b3Smrg for lalib_p_l in 1 2 3 4 2775a7b590b3Smrg do 2776a7b590b3Smrg read lalib_p_line 277715ffece8Smrg case $lalib_p_line in 2778a7b590b3Smrg \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; 2779a7b590b3Smrg esac 2780a7b590b3Smrg done 2781a7b590b3Smrg exec 0<&5 5<&- 2782a7b590b3Smrg fi 278315ffece8Smrg test yes = "$lalib_p" 2784a7b590b3Smrg} 2785943345d3Smrg 2786a7b590b3Smrg# func_ltwrapper_script_p file 2787a7b590b3Smrg# True iff FILE is a libtool wrapper script 2788a7b590b3Smrg# This function is only a basic sanity check; it will hardly flush out 2789a7b590b3Smrg# determined imposters. 2790a7b590b3Smrgfunc_ltwrapper_script_p () 2791a7b590b3Smrg{ 279215ffece8Smrg test -f "$1" && 279315ffece8Smrg $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p 2794a7b590b3Smrg} 2795943345d3Smrg 2796a7b590b3Smrg# func_ltwrapper_executable_p file 2797a7b590b3Smrg# True iff FILE is a libtool wrapper executable 2798a7b590b3Smrg# This function is only a basic sanity check; it will hardly flush out 2799a7b590b3Smrg# determined imposters. 2800a7b590b3Smrgfunc_ltwrapper_executable_p () 2801a7b590b3Smrg{ 2802a7b590b3Smrg func_ltwrapper_exec_suffix= 2803a7b590b3Smrg case $1 in 2804a7b590b3Smrg *.exe) ;; 2805a7b590b3Smrg *) func_ltwrapper_exec_suffix=.exe ;; 2806a7b590b3Smrg esac 2807a7b590b3Smrg $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 2808a7b590b3Smrg} 2809943345d3Smrg 2810a7b590b3Smrg# func_ltwrapper_scriptname file 2811a7b590b3Smrg# Assumes file is an ltwrapper_executable 2812a7b590b3Smrg# uses $file to determine the appropriate filename for a 2813a7b590b3Smrg# temporary ltwrapper_script. 2814a7b590b3Smrgfunc_ltwrapper_scriptname () 2815a7b590b3Smrg{ 28163e51e026Smrg func_dirname_and_basename "$1" "" "." 28173e51e026Smrg func_stripname '' '.exe' "$func_basename_result" 281815ffece8Smrg func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper 2819a7b590b3Smrg} 2820a7b590b3Smrg 2821a7b590b3Smrg# func_ltwrapper_p file 2822a7b590b3Smrg# True iff FILE is a libtool wrapper script or wrapper executable 2823a7b590b3Smrg# This function is only a basic sanity check; it will hardly flush out 2824a7b590b3Smrg# determined imposters. 2825a7b590b3Smrgfunc_ltwrapper_p () 2826a7b590b3Smrg{ 2827a7b590b3Smrg func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" 2828a7b590b3Smrg} 2829a7b590b3Smrg 2830a7b590b3Smrg 2831a7b590b3Smrg# func_execute_cmds commands fail_cmd 2832a7b590b3Smrg# Execute tilde-delimited COMMANDS. 2833a7b590b3Smrg# If FAIL_CMD is given, eval that upon failure. 2834a7b590b3Smrg# FAIL_CMD may read-access the current command in variable CMD! 2835a7b590b3Smrgfunc_execute_cmds () 2836a7b590b3Smrg{ 283715ffece8Smrg $debug_cmd 283815ffece8Smrg 2839a7b590b3Smrg save_ifs=$IFS; IFS='~' 2840a7b590b3Smrg for cmd in $1; do 284115ffece8Smrg IFS=$sp$nl 2842a7b590b3Smrg eval cmd=\"$cmd\" 284315ffece8Smrg IFS=$save_ifs 2844a7b590b3Smrg func_show_eval "$cmd" "${2-:}" 2845a7b590b3Smrg done 2846a7b590b3Smrg IFS=$save_ifs 2847a7b590b3Smrg} 2848a7b590b3Smrg 2849a7b590b3Smrg 2850a7b590b3Smrg# func_source file 2851a7b590b3Smrg# Source FILE, adding directory component if necessary. 2852a7b590b3Smrg# Note that it is not necessary on cygwin/mingw to append a dot to 2853a7b590b3Smrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe 2854a7b590b3Smrg# behavior happens only for exec(3), not for open(2)! Also, sourcing 285515ffece8Smrg# 'FILE.' does not work on cygwin managed mounts. 2856a7b590b3Smrgfunc_source () 2857a7b590b3Smrg{ 285815ffece8Smrg $debug_cmd 285915ffece8Smrg 2860a7b590b3Smrg case $1 in 2861a7b590b3Smrg */* | *\\*) . "$1" ;; 2862a7b590b3Smrg *) . "./$1" ;; 2863a7b590b3Smrg esac 2864a7b590b3Smrg} 2865a7b590b3Smrg 2866a7b590b3Smrg 28673e51e026Smrg# func_resolve_sysroot PATH 28683e51e026Smrg# Replace a leading = in PATH with a sysroot. Store the result into 28693e51e026Smrg# func_resolve_sysroot_result 28703e51e026Smrgfunc_resolve_sysroot () 28713e51e026Smrg{ 28723e51e026Smrg func_resolve_sysroot_result=$1 28733e51e026Smrg case $func_resolve_sysroot_result in 28743e51e026Smrg =*) 28753e51e026Smrg func_stripname '=' '' "$func_resolve_sysroot_result" 28763e51e026Smrg func_resolve_sysroot_result=$lt_sysroot$func_stripname_result 28773e51e026Smrg ;; 28783e51e026Smrg esac 28793e51e026Smrg} 28803e51e026Smrg 28813e51e026Smrg# func_replace_sysroot PATH 28823e51e026Smrg# If PATH begins with the sysroot, replace it with = and 28833e51e026Smrg# store the result into func_replace_sysroot_result. 28843e51e026Smrgfunc_replace_sysroot () 28853e51e026Smrg{ 288615ffece8Smrg case $lt_sysroot:$1 in 28873e51e026Smrg ?*:"$lt_sysroot"*) 28883e51e026Smrg func_stripname "$lt_sysroot" '' "$1" 288915ffece8Smrg func_replace_sysroot_result='='$func_stripname_result 28903e51e026Smrg ;; 28913e51e026Smrg *) 28923e51e026Smrg # Including no sysroot. 28933e51e026Smrg func_replace_sysroot_result=$1 28943e51e026Smrg ;; 28953e51e026Smrg esac 28963e51e026Smrg} 28973e51e026Smrg 2898a7b590b3Smrg# func_infer_tag arg 2899a7b590b3Smrg# Infer tagged configuration to use if any are available and 2900a7b590b3Smrg# if one wasn't chosen via the "--tag" command line option. 2901a7b590b3Smrg# Only attempt this if the compiler in the base compile 2902a7b590b3Smrg# command doesn't match the default compiler. 2903a7b590b3Smrg# arg is usually of the form 'gcc ...' 2904a7b590b3Smrgfunc_infer_tag () 2905a7b590b3Smrg{ 290615ffece8Smrg $debug_cmd 290715ffece8Smrg 2908a7b590b3Smrg if test -n "$available_tags" && test -z "$tagname"; then 2909a7b590b3Smrg CC_quoted= 2910a7b590b3Smrg for arg in $CC; do 29113e51e026Smrg func_append_quoted CC_quoted "$arg" 2912a7b590b3Smrg done 29133e51e026Smrg CC_expanded=`func_echo_all $CC` 29143e51e026Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 2915a7b590b3Smrg case $@ in 2916a7b590b3Smrg # Blanks in the command may have been stripped by the calling shell, 2917a7b590b3Smrg # but not from the CC environment variable when configure was run. 29183e51e026Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 29193e51e026Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; 2920a7b590b3Smrg # Blanks at the start of $base_compile will cause this to fail 2921a7b590b3Smrg # if we don't check for them as well. 2922a7b590b3Smrg *) 2923a7b590b3Smrg for z in $available_tags; do 2924a7b590b3Smrg if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then 2925a7b590b3Smrg # Evaluate the configuration. 292615ffece8Smrg eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" 2927a7b590b3Smrg CC_quoted= 2928a7b590b3Smrg for arg in $CC; do 2929a7b590b3Smrg # Double-quote args containing other shell metacharacters. 29303e51e026Smrg func_append_quoted CC_quoted "$arg" 2931a7b590b3Smrg done 29323e51e026Smrg CC_expanded=`func_echo_all $CC` 29333e51e026Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 2934a7b590b3Smrg case "$@ " in 29353e51e026Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 29363e51e026Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) 2937a7b590b3Smrg # The compiler in the base compile command matches 2938a7b590b3Smrg # the one in the tagged configuration. 2939a7b590b3Smrg # Assume this is the tagged configuration we want. 2940a7b590b3Smrg tagname=$z 2941a7b590b3Smrg break 2942a7b590b3Smrg ;; 2943a7b590b3Smrg esac 2944a7b590b3Smrg fi 2945a7b590b3Smrg done 2946a7b590b3Smrg # If $tagname still isn't set, then no tagged configuration 2947a7b590b3Smrg # was found and let the user know that the "--tag" command 2948a7b590b3Smrg # line option must be used. 2949a7b590b3Smrg if test -z "$tagname"; then 2950a7b590b3Smrg func_echo "unable to infer tagged configuration" 295115ffece8Smrg func_fatal_error "specify a tag with '--tag'" 2952a7b590b3Smrg# else 2953a7b590b3Smrg# func_verbose "using $tagname tagged configuration" 2954a7b590b3Smrg fi 2955a7b590b3Smrg ;; 2956a7b590b3Smrg esac 2957a7b590b3Smrg fi 2958a7b590b3Smrg} 2959a7b590b3Smrg 2960a7b590b3Smrg 2961a7b590b3Smrg 2962a7b590b3Smrg# func_write_libtool_object output_name pic_name nonpic_name 2963a7b590b3Smrg# Create a libtool object file (analogous to a ".la" file), 2964a7b590b3Smrg# but don't create it if we're doing a dry run. 2965a7b590b3Smrgfunc_write_libtool_object () 2966a7b590b3Smrg{ 296715ffece8Smrg write_libobj=$1 296815ffece8Smrg if test yes = "$build_libtool_libs"; then 296915ffece8Smrg write_lobj=\'$2\' 2970a7b590b3Smrg else 2971a7b590b3Smrg write_lobj=none 2972a7b590b3Smrg fi 2973a7b590b3Smrg 297415ffece8Smrg if test yes = "$build_old_libs"; then 297515ffece8Smrg write_oldobj=\'$3\' 2976a7b590b3Smrg else 2977a7b590b3Smrg write_oldobj=none 2978a7b590b3Smrg fi 2979a7b590b3Smrg 2980a7b590b3Smrg $opt_dry_run || { 2981a7b590b3Smrg cat >${write_libobj}T <<EOF 2982a7b590b3Smrg# $write_libobj - a libtool object file 298315ffece8Smrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 2984a7b590b3Smrg# 2985a7b590b3Smrg# Please DO NOT delete this file! 2986a7b590b3Smrg# It is necessary for linking the library. 2987a7b590b3Smrg 2988a7b590b3Smrg# Name of the PIC object. 2989a7b590b3Smrgpic_object=$write_lobj 2990a7b590b3Smrg 2991a7b590b3Smrg# Name of the non-PIC object 2992a7b590b3Smrgnon_pic_object=$write_oldobj 2993a7b590b3Smrg 2994a7b590b3SmrgEOF 299515ffece8Smrg $MV "${write_libobj}T" "$write_libobj" 2996a7b590b3Smrg } 2997a7b590b3Smrg} 2998a7b590b3Smrg 29993e51e026Smrg 30003e51e026Smrg################################################## 30013e51e026Smrg# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS # 30023e51e026Smrg################################################## 30033e51e026Smrg 30043e51e026Smrg# func_convert_core_file_wine_to_w32 ARG 30053e51e026Smrg# Helper function used by file name conversion functions when $build is *nix, 30063e51e026Smrg# and $host is mingw, cygwin, or some other w32 environment. Relies on a 30073e51e026Smrg# correctly configured wine environment available, with the winepath program 30083e51e026Smrg# in $build's $PATH. 30093e51e026Smrg# 30103e51e026Smrg# ARG is the $build file name to be converted to w32 format. 30113e51e026Smrg# Result is available in $func_convert_core_file_wine_to_w32_result, and will 30123e51e026Smrg# be empty on error (or when ARG is empty) 30133e51e026Smrgfunc_convert_core_file_wine_to_w32 () 30143e51e026Smrg{ 301515ffece8Smrg $debug_cmd 301615ffece8Smrg 301715ffece8Smrg func_convert_core_file_wine_to_w32_result=$1 30183e51e026Smrg if test -n "$1"; then 30193e51e026Smrg # Unfortunately, winepath does not exit with a non-zero error code, so we 30203e51e026Smrg # are forced to check the contents of stdout. On the other hand, if the 30213e51e026Smrg # command is not found, the shell will set an exit code of 127 and print 30223e51e026Smrg # *an error message* to stdout. So we must check for both error code of 30233e51e026Smrg # zero AND non-empty stdout, which explains the odd construction: 30243e51e026Smrg func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null` 302515ffece8Smrg if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then 30263e51e026Smrg func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | 302715ffece8Smrg $SED -e "$sed_naive_backslashify"` 30283e51e026Smrg else 30293e51e026Smrg func_convert_core_file_wine_to_w32_result= 30303e51e026Smrg fi 30313e51e026Smrg fi 30323e51e026Smrg} 30333e51e026Smrg# end: func_convert_core_file_wine_to_w32 30343e51e026Smrg 30353e51e026Smrg 30363e51e026Smrg# func_convert_core_path_wine_to_w32 ARG 30373e51e026Smrg# Helper function used by path conversion functions when $build is *nix, and 30383e51e026Smrg# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly 30393e51e026Smrg# configured wine environment available, with the winepath program in $build's 30403e51e026Smrg# $PATH. Assumes ARG has no leading or trailing path separator characters. 30413e51e026Smrg# 30423e51e026Smrg# ARG is path to be converted from $build format to win32. 30433e51e026Smrg# Result is available in $func_convert_core_path_wine_to_w32_result. 30443e51e026Smrg# Unconvertible file (directory) names in ARG are skipped; if no directory names 30453e51e026Smrg# are convertible, then the result may be empty. 30463e51e026Smrgfunc_convert_core_path_wine_to_w32 () 30473e51e026Smrg{ 304815ffece8Smrg $debug_cmd 304915ffece8Smrg 30503e51e026Smrg # unfortunately, winepath doesn't convert paths, only file names 305115ffece8Smrg func_convert_core_path_wine_to_w32_result= 30523e51e026Smrg if test -n "$1"; then 30533e51e026Smrg oldIFS=$IFS 30543e51e026Smrg IFS=: 30553e51e026Smrg for func_convert_core_path_wine_to_w32_f in $1; do 30563e51e026Smrg IFS=$oldIFS 30573e51e026Smrg func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" 305815ffece8Smrg if test -n "$func_convert_core_file_wine_to_w32_result"; then 30593e51e026Smrg if test -z "$func_convert_core_path_wine_to_w32_result"; then 306015ffece8Smrg func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result 30613e51e026Smrg else 30623e51e026Smrg func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" 30633e51e026Smrg fi 30643e51e026Smrg fi 30653e51e026Smrg done 30663e51e026Smrg IFS=$oldIFS 30673e51e026Smrg fi 30683e51e026Smrg} 30693e51e026Smrg# end: func_convert_core_path_wine_to_w32 30703e51e026Smrg 30713e51e026Smrg 30723e51e026Smrg# func_cygpath ARGS... 30733e51e026Smrg# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when 30743e51e026Smrg# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) 30753e51e026Smrg# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or 30763e51e026Smrg# (2), returns the Cygwin file name or path in func_cygpath_result (input 30773e51e026Smrg# file name or path is assumed to be in w32 format, as previously converted 30783e51e026Smrg# from $build's *nix or MSYS format). In case (3), returns the w32 file name 30793e51e026Smrg# or path in func_cygpath_result (input file name or path is assumed to be in 30803e51e026Smrg# Cygwin format). Returns an empty string on error. 30813e51e026Smrg# 30823e51e026Smrg# ARGS are passed to cygpath, with the last one being the file name or path to 30833e51e026Smrg# be converted. 30843e51e026Smrg# 30853e51e026Smrg# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH 30863e51e026Smrg# environment variable; do not put it in $PATH. 30873e51e026Smrgfunc_cygpath () 30883e51e026Smrg{ 308915ffece8Smrg $debug_cmd 309015ffece8Smrg 30913e51e026Smrg if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then 30923e51e026Smrg func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` 30933e51e026Smrg if test "$?" -ne 0; then 30943e51e026Smrg # on failure, ensure result is empty 30953e51e026Smrg func_cygpath_result= 30963e51e026Smrg fi 30973e51e026Smrg else 30983e51e026Smrg func_cygpath_result= 309915ffece8Smrg func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'" 31003e51e026Smrg fi 31013e51e026Smrg} 31023e51e026Smrg#end: func_cygpath 31033e51e026Smrg 31043e51e026Smrg 31053e51e026Smrg# func_convert_core_msys_to_w32 ARG 31063e51e026Smrg# Convert file name or path ARG from MSYS format to w32 format. Return 31073e51e026Smrg# result in func_convert_core_msys_to_w32_result. 31083e51e026Smrgfunc_convert_core_msys_to_w32 () 31093e51e026Smrg{ 311015ffece8Smrg $debug_cmd 311115ffece8Smrg 31123e51e026Smrg # awkward: cmd appends spaces to result 31133e51e026Smrg func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | 311415ffece8Smrg $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"` 31153e51e026Smrg} 31163e51e026Smrg#end: func_convert_core_msys_to_w32 31173e51e026Smrg 31183e51e026Smrg 31193e51e026Smrg# func_convert_file_check ARG1 ARG2 31203e51e026Smrg# Verify that ARG1 (a file name in $build format) was converted to $host 31213e51e026Smrg# format in ARG2. Otherwise, emit an error message, but continue (resetting 31223e51e026Smrg# func_to_host_file_result to ARG1). 31233e51e026Smrgfunc_convert_file_check () 31243e51e026Smrg{ 312515ffece8Smrg $debug_cmd 312615ffece8Smrg 312715ffece8Smrg if test -z "$2" && test -n "$1"; then 31283e51e026Smrg func_error "Could not determine host file name corresponding to" 312915ffece8Smrg func_error " '$1'" 31303e51e026Smrg func_error "Continuing, but uninstalled executables may not work." 31313e51e026Smrg # Fallback: 313215ffece8Smrg func_to_host_file_result=$1 31333e51e026Smrg fi 31343e51e026Smrg} 31353e51e026Smrg# end func_convert_file_check 31363e51e026Smrg 31373e51e026Smrg 31383e51e026Smrg# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH 31393e51e026Smrg# Verify that FROM_PATH (a path in $build format) was converted to $host 31403e51e026Smrg# format in TO_PATH. Otherwise, emit an error message, but continue, resetting 31413e51e026Smrg# func_to_host_file_result to a simplistic fallback value (see below). 31423e51e026Smrgfunc_convert_path_check () 31433e51e026Smrg{ 314415ffece8Smrg $debug_cmd 314515ffece8Smrg 31463e51e026Smrg if test -z "$4" && test -n "$3"; then 31473e51e026Smrg func_error "Could not determine the host path corresponding to" 314815ffece8Smrg func_error " '$3'" 31493e51e026Smrg func_error "Continuing, but uninstalled executables may not work." 31503e51e026Smrg # Fallback. This is a deliberately simplistic "conversion" and 31513e51e026Smrg # should not be "improved". See libtool.info. 31523e51e026Smrg if test "x$1" != "x$2"; then 31533e51e026Smrg lt_replace_pathsep_chars="s|$1|$2|g" 31543e51e026Smrg func_to_host_path_result=`echo "$3" | 31553e51e026Smrg $SED -e "$lt_replace_pathsep_chars"` 31563e51e026Smrg else 315715ffece8Smrg func_to_host_path_result=$3 31583e51e026Smrg fi 31593e51e026Smrg fi 31603e51e026Smrg} 31613e51e026Smrg# end func_convert_path_check 31623e51e026Smrg 31633e51e026Smrg 31643e51e026Smrg# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG 31653e51e026Smrg# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT 31663e51e026Smrg# and appending REPL if ORIG matches BACKPAT. 31673e51e026Smrgfunc_convert_path_front_back_pathsep () 31683e51e026Smrg{ 316915ffece8Smrg $debug_cmd 317015ffece8Smrg 31713e51e026Smrg case $4 in 317215ffece8Smrg $1 ) func_to_host_path_result=$3$func_to_host_path_result 31733e51e026Smrg ;; 31743e51e026Smrg esac 31753e51e026Smrg case $4 in 31763e51e026Smrg $2 ) func_append func_to_host_path_result "$3" 31773e51e026Smrg ;; 31783e51e026Smrg esac 31793e51e026Smrg} 31803e51e026Smrg# end func_convert_path_front_back_pathsep 31813e51e026Smrg 31823e51e026Smrg 31833e51e026Smrg################################################## 31843e51e026Smrg# $build to $host FILE NAME CONVERSION FUNCTIONS # 31853e51e026Smrg################################################## 318615ffece8Smrg# invoked via '$to_host_file_cmd ARG' 31873e51e026Smrg# 31883e51e026Smrg# In each case, ARG is the path to be converted from $build to $host format. 31893e51e026Smrg# Result will be available in $func_to_host_file_result. 31903e51e026Smrg 31913e51e026Smrg 31923e51e026Smrg# func_to_host_file ARG 31933e51e026Smrg# Converts the file name ARG from $build format to $host format. Return result 31943e51e026Smrg# in func_to_host_file_result. 31953e51e026Smrgfunc_to_host_file () 31963e51e026Smrg{ 319715ffece8Smrg $debug_cmd 319815ffece8Smrg 31993e51e026Smrg $to_host_file_cmd "$1" 32003e51e026Smrg} 32013e51e026Smrg# end func_to_host_file 32023e51e026Smrg 32033e51e026Smrg 32043e51e026Smrg# func_to_tool_file ARG LAZY 32053e51e026Smrg# converts the file name ARG from $build format to toolchain format. Return 32063e51e026Smrg# result in func_to_tool_file_result. If the conversion in use is listed 32073e51e026Smrg# in (the comma separated) LAZY, no conversion takes place. 32083e51e026Smrgfunc_to_tool_file () 32093e51e026Smrg{ 321015ffece8Smrg $debug_cmd 321115ffece8Smrg 32123e51e026Smrg case ,$2, in 32133e51e026Smrg *,"$to_tool_file_cmd",*) 32143e51e026Smrg func_to_tool_file_result=$1 32153e51e026Smrg ;; 32163e51e026Smrg *) 32173e51e026Smrg $to_tool_file_cmd "$1" 32183e51e026Smrg func_to_tool_file_result=$func_to_host_file_result 32193e51e026Smrg ;; 32203e51e026Smrg esac 32213e51e026Smrg} 32223e51e026Smrg# end func_to_tool_file 32233e51e026Smrg 32243e51e026Smrg 32253e51e026Smrg# func_convert_file_noop ARG 32263e51e026Smrg# Copy ARG to func_to_host_file_result. 32273e51e026Smrgfunc_convert_file_noop () 32283e51e026Smrg{ 322915ffece8Smrg func_to_host_file_result=$1 32303e51e026Smrg} 32313e51e026Smrg# end func_convert_file_noop 32323e51e026Smrg 32333e51e026Smrg 32343e51e026Smrg# func_convert_file_msys_to_w32 ARG 32353e51e026Smrg# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic 32363e51e026Smrg# conversion to w32 is not available inside the cwrapper. Returns result in 32373e51e026Smrg# func_to_host_file_result. 32383e51e026Smrgfunc_convert_file_msys_to_w32 () 32393e51e026Smrg{ 324015ffece8Smrg $debug_cmd 324115ffece8Smrg 324215ffece8Smrg func_to_host_file_result=$1 32433e51e026Smrg if test -n "$1"; then 32443e51e026Smrg func_convert_core_msys_to_w32 "$1" 324515ffece8Smrg func_to_host_file_result=$func_convert_core_msys_to_w32_result 32463e51e026Smrg fi 32473e51e026Smrg func_convert_file_check "$1" "$func_to_host_file_result" 32483e51e026Smrg} 32493e51e026Smrg# end func_convert_file_msys_to_w32 32503e51e026Smrg 32513e51e026Smrg 32523e51e026Smrg# func_convert_file_cygwin_to_w32 ARG 32533e51e026Smrg# Convert file name ARG from Cygwin to w32 format. Returns result in 32543e51e026Smrg# func_to_host_file_result. 32553e51e026Smrgfunc_convert_file_cygwin_to_w32 () 32563e51e026Smrg{ 325715ffece8Smrg $debug_cmd 325815ffece8Smrg 325915ffece8Smrg func_to_host_file_result=$1 32603e51e026Smrg if test -n "$1"; then 32613e51e026Smrg # because $build is cygwin, we call "the" cygpath in $PATH; no need to use 32623e51e026Smrg # LT_CYGPATH in this case. 32633e51e026Smrg func_to_host_file_result=`cygpath -m "$1"` 32643e51e026Smrg fi 32653e51e026Smrg func_convert_file_check "$1" "$func_to_host_file_result" 32663e51e026Smrg} 32673e51e026Smrg# end func_convert_file_cygwin_to_w32 32683e51e026Smrg 32693e51e026Smrg 32703e51e026Smrg# func_convert_file_nix_to_w32 ARG 32713e51e026Smrg# Convert file name ARG from *nix to w32 format. Requires a wine environment 32723e51e026Smrg# and a working winepath. Returns result in func_to_host_file_result. 32733e51e026Smrgfunc_convert_file_nix_to_w32 () 32743e51e026Smrg{ 327515ffece8Smrg $debug_cmd 327615ffece8Smrg 327715ffece8Smrg func_to_host_file_result=$1 32783e51e026Smrg if test -n "$1"; then 32793e51e026Smrg func_convert_core_file_wine_to_w32 "$1" 328015ffece8Smrg func_to_host_file_result=$func_convert_core_file_wine_to_w32_result 32813e51e026Smrg fi 32823e51e026Smrg func_convert_file_check "$1" "$func_to_host_file_result" 32833e51e026Smrg} 32843e51e026Smrg# end func_convert_file_nix_to_w32 32853e51e026Smrg 32863e51e026Smrg 32873e51e026Smrg# func_convert_file_msys_to_cygwin ARG 32883e51e026Smrg# Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 32893e51e026Smrg# Returns result in func_to_host_file_result. 32903e51e026Smrgfunc_convert_file_msys_to_cygwin () 32913e51e026Smrg{ 329215ffece8Smrg $debug_cmd 329315ffece8Smrg 329415ffece8Smrg func_to_host_file_result=$1 32953e51e026Smrg if test -n "$1"; then 32963e51e026Smrg func_convert_core_msys_to_w32 "$1" 32973e51e026Smrg func_cygpath -u "$func_convert_core_msys_to_w32_result" 329815ffece8Smrg func_to_host_file_result=$func_cygpath_result 32993e51e026Smrg fi 33003e51e026Smrg func_convert_file_check "$1" "$func_to_host_file_result" 33013e51e026Smrg} 33023e51e026Smrg# end func_convert_file_msys_to_cygwin 33033e51e026Smrg 33043e51e026Smrg 33053e51e026Smrg# func_convert_file_nix_to_cygwin ARG 33063e51e026Smrg# Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed 33073e51e026Smrg# in a wine environment, working winepath, and LT_CYGPATH set. Returns result 33083e51e026Smrg# in func_to_host_file_result. 33093e51e026Smrgfunc_convert_file_nix_to_cygwin () 33103e51e026Smrg{ 331115ffece8Smrg $debug_cmd 331215ffece8Smrg 331315ffece8Smrg func_to_host_file_result=$1 33143e51e026Smrg if test -n "$1"; then 33153e51e026Smrg # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. 33163e51e026Smrg func_convert_core_file_wine_to_w32 "$1" 33173e51e026Smrg func_cygpath -u "$func_convert_core_file_wine_to_w32_result" 331815ffece8Smrg func_to_host_file_result=$func_cygpath_result 33193e51e026Smrg fi 33203e51e026Smrg func_convert_file_check "$1" "$func_to_host_file_result" 33213e51e026Smrg} 33223e51e026Smrg# end func_convert_file_nix_to_cygwin 33233e51e026Smrg 33243e51e026Smrg 33253e51e026Smrg############################################# 33263e51e026Smrg# $build to $host PATH CONVERSION FUNCTIONS # 33273e51e026Smrg############################################# 332815ffece8Smrg# invoked via '$to_host_path_cmd ARG' 33293e51e026Smrg# 33303e51e026Smrg# In each case, ARG is the path to be converted from $build to $host format. 33313e51e026Smrg# The result will be available in $func_to_host_path_result. 33323e51e026Smrg# 33333e51e026Smrg# Path separators are also converted from $build format to $host format. If 33343e51e026Smrg# ARG begins or ends with a path separator character, it is preserved (but 33353e51e026Smrg# converted to $host format) on output. 33363e51e026Smrg# 33373e51e026Smrg# All path conversion functions are named using the following convention: 33383e51e026Smrg# file name conversion function : func_convert_file_X_to_Y () 33393e51e026Smrg# path conversion function : func_convert_path_X_to_Y () 33403e51e026Smrg# where, for any given $build/$host combination the 'X_to_Y' value is the 33413e51e026Smrg# same. If conversion functions are added for new $build/$host combinations, 33423e51e026Smrg# the two new functions must follow this pattern, or func_init_to_host_path_cmd 33433e51e026Smrg# will break. 33443e51e026Smrg 33453e51e026Smrg 33463e51e026Smrg# func_init_to_host_path_cmd 33473e51e026Smrg# Ensures that function "pointer" variable $to_host_path_cmd is set to the 33483e51e026Smrg# appropriate value, based on the value of $to_host_file_cmd. 33493e51e026Smrgto_host_path_cmd= 33503e51e026Smrgfunc_init_to_host_path_cmd () 33513e51e026Smrg{ 335215ffece8Smrg $debug_cmd 335315ffece8Smrg 33543e51e026Smrg if test -z "$to_host_path_cmd"; then 33553e51e026Smrg func_stripname 'func_convert_file_' '' "$to_host_file_cmd" 335615ffece8Smrg to_host_path_cmd=func_convert_path_$func_stripname_result 33573e51e026Smrg fi 33583e51e026Smrg} 33593e51e026Smrg 33603e51e026Smrg 33613e51e026Smrg# func_to_host_path ARG 33623e51e026Smrg# Converts the path ARG from $build format to $host format. Return result 33633e51e026Smrg# in func_to_host_path_result. 33643e51e026Smrgfunc_to_host_path () 33653e51e026Smrg{ 336615ffece8Smrg $debug_cmd 336715ffece8Smrg 33683e51e026Smrg func_init_to_host_path_cmd 33693e51e026Smrg $to_host_path_cmd "$1" 33703e51e026Smrg} 33713e51e026Smrg# end func_to_host_path 33723e51e026Smrg 33733e51e026Smrg 33743e51e026Smrg# func_convert_path_noop ARG 33753e51e026Smrg# Copy ARG to func_to_host_path_result. 33763e51e026Smrgfunc_convert_path_noop () 33773e51e026Smrg{ 337815ffece8Smrg func_to_host_path_result=$1 33793e51e026Smrg} 33803e51e026Smrg# end func_convert_path_noop 33813e51e026Smrg 33823e51e026Smrg 33833e51e026Smrg# func_convert_path_msys_to_w32 ARG 33843e51e026Smrg# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic 33853e51e026Smrg# conversion to w32 is not available inside the cwrapper. Returns result in 33863e51e026Smrg# func_to_host_path_result. 33873e51e026Smrgfunc_convert_path_msys_to_w32 () 33883e51e026Smrg{ 338915ffece8Smrg $debug_cmd 339015ffece8Smrg 339115ffece8Smrg func_to_host_path_result=$1 33923e51e026Smrg if test -n "$1"; then 33933e51e026Smrg # Remove leading and trailing path separator characters from ARG. MSYS 33943e51e026Smrg # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; 33953e51e026Smrg # and winepath ignores them completely. 33963e51e026Smrg func_stripname : : "$1" 33973e51e026Smrg func_to_host_path_tmp1=$func_stripname_result 33983e51e026Smrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 339915ffece8Smrg func_to_host_path_result=$func_convert_core_msys_to_w32_result 34003e51e026Smrg func_convert_path_check : ";" \ 34013e51e026Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 34023e51e026Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 34033e51e026Smrg fi 34043e51e026Smrg} 34053e51e026Smrg# end func_convert_path_msys_to_w32 34063e51e026Smrg 34073e51e026Smrg 34083e51e026Smrg# func_convert_path_cygwin_to_w32 ARG 34093e51e026Smrg# Convert path ARG from Cygwin to w32 format. Returns result in 34103e51e026Smrg# func_to_host_file_result. 34113e51e026Smrgfunc_convert_path_cygwin_to_w32 () 34123e51e026Smrg{ 341315ffece8Smrg $debug_cmd 341415ffece8Smrg 341515ffece8Smrg func_to_host_path_result=$1 34163e51e026Smrg if test -n "$1"; then 34173e51e026Smrg # See func_convert_path_msys_to_w32: 34183e51e026Smrg func_stripname : : "$1" 34193e51e026Smrg func_to_host_path_tmp1=$func_stripname_result 34203e51e026Smrg func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` 34213e51e026Smrg func_convert_path_check : ";" \ 34223e51e026Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 34233e51e026Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 34243e51e026Smrg fi 34253e51e026Smrg} 34263e51e026Smrg# end func_convert_path_cygwin_to_w32 34273e51e026Smrg 34283e51e026Smrg 34293e51e026Smrg# func_convert_path_nix_to_w32 ARG 34303e51e026Smrg# Convert path ARG from *nix to w32 format. Requires a wine environment and 34313e51e026Smrg# a working winepath. Returns result in func_to_host_file_result. 34323e51e026Smrgfunc_convert_path_nix_to_w32 () 34333e51e026Smrg{ 343415ffece8Smrg $debug_cmd 343515ffece8Smrg 343615ffece8Smrg func_to_host_path_result=$1 34373e51e026Smrg if test -n "$1"; then 34383e51e026Smrg # See func_convert_path_msys_to_w32: 34393e51e026Smrg func_stripname : : "$1" 34403e51e026Smrg func_to_host_path_tmp1=$func_stripname_result 34413e51e026Smrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 344215ffece8Smrg func_to_host_path_result=$func_convert_core_path_wine_to_w32_result 34433e51e026Smrg func_convert_path_check : ";" \ 34443e51e026Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 34453e51e026Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 34463e51e026Smrg fi 34473e51e026Smrg} 34483e51e026Smrg# end func_convert_path_nix_to_w32 34493e51e026Smrg 34503e51e026Smrg 34513e51e026Smrg# func_convert_path_msys_to_cygwin ARG 34523e51e026Smrg# Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 34533e51e026Smrg# Returns result in func_to_host_file_result. 34543e51e026Smrgfunc_convert_path_msys_to_cygwin () 34553e51e026Smrg{ 345615ffece8Smrg $debug_cmd 345715ffece8Smrg 345815ffece8Smrg func_to_host_path_result=$1 34593e51e026Smrg if test -n "$1"; then 34603e51e026Smrg # See func_convert_path_msys_to_w32: 34613e51e026Smrg func_stripname : : "$1" 34623e51e026Smrg func_to_host_path_tmp1=$func_stripname_result 34633e51e026Smrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 34643e51e026Smrg func_cygpath -u -p "$func_convert_core_msys_to_w32_result" 346515ffece8Smrg func_to_host_path_result=$func_cygpath_result 34663e51e026Smrg func_convert_path_check : : \ 34673e51e026Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 34683e51e026Smrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 34693e51e026Smrg fi 34703e51e026Smrg} 34713e51e026Smrg# end func_convert_path_msys_to_cygwin 34723e51e026Smrg 34733e51e026Smrg 34743e51e026Smrg# func_convert_path_nix_to_cygwin ARG 34753e51e026Smrg# Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a 34763e51e026Smrg# a wine environment, working winepath, and LT_CYGPATH set. Returns result in 34773e51e026Smrg# func_to_host_file_result. 34783e51e026Smrgfunc_convert_path_nix_to_cygwin () 34793e51e026Smrg{ 348015ffece8Smrg $debug_cmd 348115ffece8Smrg 348215ffece8Smrg func_to_host_path_result=$1 34833e51e026Smrg if test -n "$1"; then 34843e51e026Smrg # Remove leading and trailing path separator characters from 34853e51e026Smrg # ARG. msys behavior is inconsistent here, cygpath turns them 34863e51e026Smrg # into '.;' and ';.', and winepath ignores them completely. 34873e51e026Smrg func_stripname : : "$1" 34883e51e026Smrg func_to_host_path_tmp1=$func_stripname_result 34893e51e026Smrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 34903e51e026Smrg func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" 349115ffece8Smrg func_to_host_path_result=$func_cygpath_result 34923e51e026Smrg func_convert_path_check : : \ 34933e51e026Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 34943e51e026Smrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 34953e51e026Smrg fi 34963e51e026Smrg} 34973e51e026Smrg# end func_convert_path_nix_to_cygwin 34983e51e026Smrg 34993e51e026Smrg 350015ffece8Smrg# func_dll_def_p FILE 350115ffece8Smrg# True iff FILE is a Windows DLL '.def' file. 350215ffece8Smrg# Keep in sync with _LT_DLL_DEF_P in libtool.m4 350315ffece8Smrgfunc_dll_def_p () 350415ffece8Smrg{ 350515ffece8Smrg $debug_cmd 350615ffece8Smrg 350715ffece8Smrg func_dll_def_p_tmp=`$SED -n \ 350815ffece8Smrg -e 's/^[ ]*//' \ 350915ffece8Smrg -e '/^\(;.*\)*$/d' \ 351015ffece8Smrg -e 's/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p' \ 351115ffece8Smrg -e q \ 351215ffece8Smrg "$1"` 351315ffece8Smrg test DEF = "$func_dll_def_p_tmp" 351415ffece8Smrg} 351515ffece8Smrg 351615ffece8Smrg 3517a7b590b3Smrg# func_mode_compile arg... 3518a7b590b3Smrgfunc_mode_compile () 3519a7b590b3Smrg{ 352015ffece8Smrg $debug_cmd 352115ffece8Smrg 3522a7b590b3Smrg # Get the compilation command and the source file. 3523a7b590b3Smrg base_compile= 352415ffece8Smrg srcfile=$nonopt # always keep a non-empty value in "srcfile" 3525a7b590b3Smrg suppress_opt=yes 3526a7b590b3Smrg suppress_output= 3527a7b590b3Smrg arg_mode=normal 3528a7b590b3Smrg libobj= 3529a7b590b3Smrg later= 3530a7b590b3Smrg pie_flag= 3531a7b590b3Smrg 3532a7b590b3Smrg for arg 3533a7b590b3Smrg do 3534a7b590b3Smrg case $arg_mode in 3535a7b590b3Smrg arg ) 3536a7b590b3Smrg # do not "continue". Instead, add this to base_compile 353715ffece8Smrg lastarg=$arg 3538a7b590b3Smrg arg_mode=normal 3539a7b590b3Smrg ;; 3540a7b590b3Smrg 3541a7b590b3Smrg target ) 354215ffece8Smrg libobj=$arg 3543a7b590b3Smrg arg_mode=normal 3544a7b590b3Smrg continue 3545a7b590b3Smrg ;; 3546a7b590b3Smrg 3547a7b590b3Smrg normal ) 3548a7b590b3Smrg # Accept any command-line options. 3549a7b590b3Smrg case $arg in 3550a7b590b3Smrg -o) 3551a7b590b3Smrg test -n "$libobj" && \ 355215ffece8Smrg func_fatal_error "you cannot specify '-o' more than once" 3553a7b590b3Smrg arg_mode=target 3554a7b590b3Smrg continue 3555a7b590b3Smrg ;; 3556a7b590b3Smrg 3557a7b590b3Smrg -pie | -fpie | -fPIE) 35583e51e026Smrg func_append pie_flag " $arg" 3559a7b590b3Smrg continue 3560a7b590b3Smrg ;; 3561a7b590b3Smrg 3562a7b590b3Smrg -shared | -static | -prefer-pic | -prefer-non-pic) 35633e51e026Smrg func_append later " $arg" 3564a7b590b3Smrg continue 3565a7b590b3Smrg ;; 3566a7b590b3Smrg 3567a7b590b3Smrg -no-suppress) 3568943345d3Smrg suppress_opt=no 3569943345d3Smrg continue 3570943345d3Smrg ;; 3571943345d3Smrg 3572943345d3Smrg -Xcompiler) 3573943345d3Smrg arg_mode=arg # the next one goes into the "base_compile" arg list 3574943345d3Smrg continue # The current "srcfile" will either be retained or 3575943345d3Smrg ;; # replaced later. I would guess that would be a bug. 3576943345d3Smrg 3577943345d3Smrg -Wc,*) 3578a7b590b3Smrg func_stripname '-Wc,' '' "$arg" 3579a7b590b3Smrg args=$func_stripname_result 3580943345d3Smrg lastarg= 358115ffece8Smrg save_ifs=$IFS; IFS=, 3582a7b590b3Smrg for arg in $args; do 358315ffece8Smrg IFS=$save_ifs 35843e51e026Smrg func_append_quoted lastarg "$arg" 3585943345d3Smrg done 358615ffece8Smrg IFS=$save_ifs 3587a7b590b3Smrg func_stripname ' ' '' "$lastarg" 3588a7b590b3Smrg lastarg=$func_stripname_result 3589943345d3Smrg 3590943345d3Smrg # Add the arguments to base_compile. 35913e51e026Smrg func_append base_compile " $lastarg" 3592943345d3Smrg continue 3593943345d3Smrg ;; 3594943345d3Smrg 3595a7b590b3Smrg *) 3596943345d3Smrg # Accept the current argument as the source file. 3597943345d3Smrg # The previous "srcfile" becomes the current argument. 3598943345d3Smrg # 359915ffece8Smrg lastarg=$srcfile 360015ffece8Smrg srcfile=$arg 3601943345d3Smrg ;; 3602943345d3Smrg esac # case $arg 3603943345d3Smrg ;; 3604943345d3Smrg esac # case $arg_mode 3605943345d3Smrg 3606943345d3Smrg # Aesthetically quote the previous argument. 36073e51e026Smrg func_append_quoted base_compile "$lastarg" 3608943345d3Smrg done # for arg 3609943345d3Smrg 3610943345d3Smrg case $arg_mode in 3611943345d3Smrg arg) 3612a7b590b3Smrg func_fatal_error "you must specify an argument for -Xcompile" 3613943345d3Smrg ;; 3614943345d3Smrg target) 361515ffece8Smrg func_fatal_error "you must specify a target with '-o'" 3616943345d3Smrg ;; 3617943345d3Smrg *) 3618943345d3Smrg # Get the name of the library object. 3619a7b590b3Smrg test -z "$libobj" && { 3620a7b590b3Smrg func_basename "$srcfile" 362115ffece8Smrg libobj=$func_basename_result 3622a7b590b3Smrg } 3623943345d3Smrg ;; 3624943345d3Smrg esac 3625943345d3Smrg 3626943345d3Smrg # Recognize several different file suffixes. 3627943345d3Smrg # If the user specifies -o file.o, it is replaced with file.lo 3628943345d3Smrg case $libobj in 3629a7b590b3Smrg *.[cCFSifmso] | \ 3630a7b590b3Smrg *.ada | *.adb | *.ads | *.asm | \ 3631a7b590b3Smrg *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ 36323e51e026Smrg *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup) 3633a7b590b3Smrg func_xform "$libobj" 3634a7b590b3Smrg libobj=$func_xform_result 3635a7b590b3Smrg ;; 3636943345d3Smrg esac 3637943345d3Smrg 3638943345d3Smrg case $libobj in 3639a7b590b3Smrg *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; 3640943345d3Smrg *) 364115ffece8Smrg func_fatal_error "cannot determine name of library object from '$libobj'" 3642943345d3Smrg ;; 3643943345d3Smrg esac 3644943345d3Smrg 3645943345d3Smrg func_infer_tag $base_compile 3646943345d3Smrg 3647943345d3Smrg for arg in $later; do 3648943345d3Smrg case $arg in 3649a7b590b3Smrg -shared) 365015ffece8Smrg test yes = "$build_libtool_libs" \ 365115ffece8Smrg || func_fatal_configuration "cannot build a shared library" 3652a7b590b3Smrg build_old_libs=no 3653a7b590b3Smrg continue 3654a7b590b3Smrg ;; 3655a7b590b3Smrg 3656943345d3Smrg -static) 3657a7b590b3Smrg build_libtool_libs=no 3658943345d3Smrg build_old_libs=yes 3659943345d3Smrg continue 3660943345d3Smrg ;; 3661943345d3Smrg 3662943345d3Smrg -prefer-pic) 3663943345d3Smrg pic_mode=yes 3664943345d3Smrg continue 3665943345d3Smrg ;; 3666943345d3Smrg 3667943345d3Smrg -prefer-non-pic) 3668943345d3Smrg pic_mode=no 3669943345d3Smrg continue 3670943345d3Smrg ;; 3671943345d3Smrg esac 3672943345d3Smrg done 3673943345d3Smrg 367415ffece8Smrg func_quote_arg pretty "$libobj" 367515ffece8Smrg test "X$libobj" != "X$func_quote_arg_result" \ 3676a7b590b3Smrg && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ 367715ffece8Smrg && func_warning "libobj name '$libobj' may not contain shell special characters." 3678a7b590b3Smrg func_dirname_and_basename "$obj" "/" "" 367915ffece8Smrg objname=$func_basename_result 368015ffece8Smrg xdir=$func_dirname_result 368115ffece8Smrg lobj=$xdir$objdir/$objname 3682943345d3Smrg 3683a7b590b3Smrg test -z "$base_compile" && \ 3684a7b590b3Smrg func_fatal_help "you must specify a compilation command" 3685943345d3Smrg 3686943345d3Smrg # Delete any leftover library objects. 368715ffece8Smrg if test yes = "$build_old_libs"; then 3688943345d3Smrg removelist="$obj $lobj $libobj ${libobj}T" 3689943345d3Smrg else 3690943345d3Smrg removelist="$lobj $libobj ${libobj}T" 3691943345d3Smrg fi 3692943345d3Smrg 3693943345d3Smrg # On Cygwin there's no "real" PIC flag so we must build both object types 3694943345d3Smrg case $host_os in 3695a7b590b3Smrg cygwin* | mingw* | pw32* | os2* | cegcc*) 3696943345d3Smrg pic_mode=default 3697943345d3Smrg ;; 3698943345d3Smrg esac 369915ffece8Smrg if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then 3700943345d3Smrg # non-PIC code in shared libraries is not supported 3701943345d3Smrg pic_mode=default 3702943345d3Smrg fi 3703943345d3Smrg 3704943345d3Smrg # Calculate the filename of the output object if compiler does 3705943345d3Smrg # not support -o with -c 370615ffece8Smrg if test no = "$compiler_c_o"; then 370715ffece8Smrg output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext 370815ffece8Smrg lockfile=$output_obj.lock 3709943345d3Smrg else 3710943345d3Smrg output_obj= 3711943345d3Smrg need_locks=no 3712943345d3Smrg lockfile= 3713943345d3Smrg fi 3714943345d3Smrg 3715943345d3Smrg # Lock this critical section if it is needed 3716943345d3Smrg # We use this script file to make the link, it avoids creating a new file 371715ffece8Smrg if test yes = "$need_locks"; then 3718a7b590b3Smrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 3719a7b590b3Smrg func_echo "Waiting for $lockfile to be removed" 3720943345d3Smrg sleep 2 3721943345d3Smrg done 372215ffece8Smrg elif test warn = "$need_locks"; then 3723943345d3Smrg if test -f "$lockfile"; then 3724a7b590b3Smrg $ECHO "\ 3725943345d3Smrg*** ERROR, $lockfile exists and contains: 3726943345d3Smrg`cat $lockfile 2>/dev/null` 3727943345d3Smrg 3728943345d3SmrgThis indicates that another process is trying to use the same 3729943345d3Smrgtemporary object file, and libtool could not work around it because 373015ffece8Smrgyour compiler does not support '-c' and '-o' together. If you 3731943345d3Smrgrepeat this compilation, it may succeed, by chance, but you had better 3732943345d3Smrgavoid parallel builds (make -j) in this platform, or get a better 3733943345d3Smrgcompiler." 3734943345d3Smrg 3735a7b590b3Smrg $opt_dry_run || $RM $removelist 3736943345d3Smrg exit $EXIT_FAILURE 3737943345d3Smrg fi 37383e51e026Smrg func_append removelist " $output_obj" 3739a7b590b3Smrg $ECHO "$srcfile" > "$lockfile" 3740943345d3Smrg fi 3741943345d3Smrg 3742a7b590b3Smrg $opt_dry_run || $RM $removelist 37433e51e026Smrg func_append removelist " $lockfile" 3744a7b590b3Smrg trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 3745a7b590b3Smrg 37463e51e026Smrg func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 37473e51e026Smrg srcfile=$func_to_tool_file_result 374815ffece8Smrg func_quote_arg pretty "$srcfile" 374915ffece8Smrg qsrcfile=$func_quote_arg_result 3750943345d3Smrg 3751943345d3Smrg # Only build a PIC object if we are building libtool libraries. 375215ffece8Smrg if test yes = "$build_libtool_libs"; then 3753943345d3Smrg # Without this assignment, base_compile gets emptied. 3754943345d3Smrg fbsd_hideous_sh_bug=$base_compile 3755943345d3Smrg 375615ffece8Smrg if test no != "$pic_mode"; then 3757943345d3Smrg command="$base_compile $qsrcfile $pic_flag" 3758943345d3Smrg else 3759943345d3Smrg # Don't build PIC code 3760943345d3Smrg command="$base_compile $qsrcfile" 3761943345d3Smrg fi 3762943345d3Smrg 3763a7b590b3Smrg func_mkdir_p "$xdir$objdir" 3764943345d3Smrg 3765943345d3Smrg if test -z "$output_obj"; then 3766943345d3Smrg # Place PIC objects in $objdir 37673e51e026Smrg func_append command " -o $lobj" 3768943345d3Smrg fi 3769943345d3Smrg 3770a7b590b3Smrg func_show_eval_locale "$command" \ 3771a7b590b3Smrg 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' 3772943345d3Smrg 377315ffece8Smrg if test warn = "$need_locks" && 3774943345d3Smrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 3775a7b590b3Smrg $ECHO "\ 3776943345d3Smrg*** ERROR, $lockfile contains: 3777943345d3Smrg`cat $lockfile 2>/dev/null` 3778943345d3Smrg 3779943345d3Smrgbut it should contain: 3780943345d3Smrg$srcfile 3781943345d3Smrg 3782943345d3SmrgThis indicates that another process is trying to use the same 3783943345d3Smrgtemporary object file, and libtool could not work around it because 378415ffece8Smrgyour compiler does not support '-c' and '-o' together. If you 3785943345d3Smrgrepeat this compilation, it may succeed, by chance, but you had better 3786943345d3Smrgavoid parallel builds (make -j) in this platform, or get a better 3787943345d3Smrgcompiler." 3788943345d3Smrg 3789a7b590b3Smrg $opt_dry_run || $RM $removelist 3790943345d3Smrg exit $EXIT_FAILURE 3791943345d3Smrg fi 3792943345d3Smrg 3793943345d3Smrg # Just move the object if needed, then go on to compile the next one 3794943345d3Smrg if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then 3795a7b590b3Smrg func_show_eval '$MV "$output_obj" "$lobj"' \ 3796a7b590b3Smrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 3797943345d3Smrg fi 3798943345d3Smrg 3799943345d3Smrg # Allow error messages only from the first compilation. 380015ffece8Smrg if test yes = "$suppress_opt"; then 3801a7b590b3Smrg suppress_output=' >/dev/null 2>&1' 3802943345d3Smrg fi 3803943345d3Smrg fi 3804943345d3Smrg 3805943345d3Smrg # Only build a position-dependent object if we build old libraries. 380615ffece8Smrg if test yes = "$build_old_libs"; then 380715ffece8Smrg if test yes != "$pic_mode"; then 3808943345d3Smrg # Don't build PIC code 3809a7b590b3Smrg command="$base_compile $qsrcfile$pie_flag" 3810943345d3Smrg else 3811943345d3Smrg command="$base_compile $qsrcfile $pic_flag" 3812943345d3Smrg fi 381315ffece8Smrg if test yes = "$compiler_c_o"; then 38143e51e026Smrg func_append command " -o $obj" 3815943345d3Smrg fi 3816943345d3Smrg 3817943345d3Smrg # Suppress compiler output if we already did a PIC compilation. 38183e51e026Smrg func_append command "$suppress_output" 3819a7b590b3Smrg func_show_eval_locale "$command" \ 3820a7b590b3Smrg '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 3821943345d3Smrg 382215ffece8Smrg if test warn = "$need_locks" && 3823943345d3Smrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 3824a7b590b3Smrg $ECHO "\ 3825943345d3Smrg*** ERROR, $lockfile contains: 3826943345d3Smrg`cat $lockfile 2>/dev/null` 3827943345d3Smrg 3828943345d3Smrgbut it should contain: 3829943345d3Smrg$srcfile 3830943345d3Smrg 3831943345d3SmrgThis indicates that another process is trying to use the same 3832943345d3Smrgtemporary object file, and libtool could not work around it because 383315ffece8Smrgyour compiler does not support '-c' and '-o' together. If you 3834943345d3Smrgrepeat this compilation, it may succeed, by chance, but you had better 3835943345d3Smrgavoid parallel builds (make -j) in this platform, or get a better 3836943345d3Smrgcompiler." 3837943345d3Smrg 3838a7b590b3Smrg $opt_dry_run || $RM $removelist 3839943345d3Smrg exit $EXIT_FAILURE 3840943345d3Smrg fi 3841943345d3Smrg 3842943345d3Smrg # Just move the object if needed 3843943345d3Smrg if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then 3844a7b590b3Smrg func_show_eval '$MV "$output_obj" "$obj"' \ 3845a7b590b3Smrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 3846943345d3Smrg fi 3847943345d3Smrg fi 3848943345d3Smrg 3849a7b590b3Smrg $opt_dry_run || { 3850a7b590b3Smrg func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" 3851943345d3Smrg 3852a7b590b3Smrg # Unlock the critical section if it was locked 385315ffece8Smrg if test no != "$need_locks"; then 3854a7b590b3Smrg removelist=$lockfile 3855a7b590b3Smrg $RM "$lockfile" 3856a7b590b3Smrg fi 3857a7b590b3Smrg } 3858943345d3Smrg 3859943345d3Smrg exit $EXIT_SUCCESS 3860a7b590b3Smrg} 3861943345d3Smrg 3862a7b590b3Smrg$opt_help || { 386315ffece8Smrg test compile = "$opt_mode" && func_mode_compile ${1+"$@"} 3864a7b590b3Smrg} 3865943345d3Smrg 3866a7b590b3Smrgfunc_mode_help () 3867a7b590b3Smrg{ 3868a7b590b3Smrg # We need to display help for each of the modes. 38693e51e026Smrg case $opt_mode in 3870a7b590b3Smrg "") 3871a7b590b3Smrg # Generic help is extracted from the usage comments 3872a7b590b3Smrg # at the start of this file. 3873a7b590b3Smrg func_help 3874a7b590b3Smrg ;; 3875943345d3Smrg 3876a7b590b3Smrg clean) 3877a7b590b3Smrg $ECHO \ 3878a7b590b3Smrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... 3879943345d3Smrg 3880a7b590b3SmrgRemove files from the build directory. 3881943345d3Smrg 3882a7b590b3SmrgRM is the name of the program to use to delete files associated with each FILE 388315ffece8Smrg(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 3884a7b590b3Smrgto RM. 3885943345d3Smrg 3886a7b590b3SmrgIf FILE is a libtool library, object or program, all the files associated 3887a7b590b3Smrgwith it are deleted. Otherwise, only FILE itself is deleted using RM." 3888a7b590b3Smrg ;; 3889943345d3Smrg 3890a7b590b3Smrg compile) 3891a7b590b3Smrg $ECHO \ 3892a7b590b3Smrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE 3893943345d3Smrg 3894a7b590b3SmrgCompile a source file into a libtool library object. 3895943345d3Smrg 3896a7b590b3SmrgThis mode accepts the following additional options: 3897943345d3Smrg 3898a7b590b3Smrg -o OUTPUT-FILE set the output file name to OUTPUT-FILE 3899a7b590b3Smrg -no-suppress do not suppress compiler output for multiple passes 39003e51e026Smrg -prefer-pic try to build PIC objects only 39013e51e026Smrg -prefer-non-pic try to build non-PIC objects only 390215ffece8Smrg -shared do not build a '.o' file suitable for static linking 390315ffece8Smrg -static only build a '.o' file suitable for static linking 390415ffece8Smrg -Wc,FLAG 390515ffece8Smrg -Xcompiler FLAG pass FLAG directly to the compiler 3906943345d3Smrg 390715ffece8SmrgCOMPILE-COMMAND is a command to be used in creating a 'standard' object file 3908a7b590b3Smrgfrom the given SOURCEFILE. 3909943345d3Smrg 3910a7b590b3SmrgThe output file name is determined by removing the directory component from 391115ffece8SmrgSOURCEFILE, then substituting the C source code suffix '.c' with the 391215ffece8Smrglibrary object suffix, '.lo'." 3913a7b590b3Smrg ;; 3914943345d3Smrg 3915a7b590b3Smrg execute) 3916a7b590b3Smrg $ECHO \ 3917a7b590b3Smrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... 3918943345d3Smrg 3919a7b590b3SmrgAutomatically set library path, then run a program. 3920943345d3Smrg 3921a7b590b3SmrgThis mode accepts the following additional options: 3922943345d3Smrg 3923a7b590b3Smrg -dlopen FILE add the directory containing FILE to the library path 3924943345d3Smrg 392515ffece8SmrgThis mode sets the library path environment variable according to '-dlopen' 3926a7b590b3Smrgflags. 3927943345d3Smrg 3928a7b590b3SmrgIf any of the ARGS are libtool executable wrappers, then they are translated 3929a7b590b3Smrginto their corresponding uninstalled binary, and any of their required library 3930a7b590b3Smrgdirectories are added to the library path. 3931943345d3Smrg 3932a7b590b3SmrgThen, COMMAND is executed, with ARGS as arguments." 3933a7b590b3Smrg ;; 3934943345d3Smrg 3935a7b590b3Smrg finish) 3936a7b590b3Smrg $ECHO \ 3937a7b590b3Smrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]... 3938943345d3Smrg 3939a7b590b3SmrgComplete the installation of libtool libraries. 3940943345d3Smrg 3941a7b590b3SmrgEach LIBDIR is a directory that contains libtool libraries. 3942943345d3Smrg 3943a7b590b3SmrgThe commands that this mode executes may require superuser privileges. Use 394415ffece8Smrgthe '--dry-run' option if you just want to see what would be executed." 3945a7b590b3Smrg ;; 3946943345d3Smrg 3947a7b590b3Smrg install) 3948a7b590b3Smrg $ECHO \ 3949a7b590b3Smrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... 3950943345d3Smrg 3951a7b590b3SmrgInstall executables or libraries. 3952943345d3Smrg 3953a7b590b3SmrgINSTALL-COMMAND is the installation command. The first component should be 395415ffece8Smrgeither the 'install' or 'cp' program. 3955943345d3Smrg 3956a7b590b3SmrgThe following components of INSTALL-COMMAND are treated specially: 3957943345d3Smrg 39583e51e026Smrg -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation 3959943345d3Smrg 3960a7b590b3SmrgThe rest of the components are interpreted as arguments to that command (only 3961a7b590b3SmrgBSD-compatible install options are recognized)." 3962a7b590b3Smrg ;; 3963943345d3Smrg 3964a7b590b3Smrg link) 3965a7b590b3Smrg $ECHO \ 3966a7b590b3Smrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND... 3967943345d3Smrg 3968a7b590b3SmrgLink object files or libraries together to form another library, or to 3969a7b590b3Smrgcreate an executable program. 3970943345d3Smrg 3971a7b590b3SmrgLINK-COMMAND is a command using the C compiler that you would use to create 3972a7b590b3Smrga program from several object files. 3973943345d3Smrg 3974a7b590b3SmrgThe following components of LINK-COMMAND are treated specially: 3975943345d3Smrg 3976a7b590b3Smrg -all-static do not do any dynamic linking at all 3977a7b590b3Smrg -avoid-version do not add a version suffix if possible 39783e51e026Smrg -bindir BINDIR specify path to binaries directory (for systems where 39793e51e026Smrg libraries must be found in the PATH setting at runtime) 398015ffece8Smrg -dlopen FILE '-dlpreopen' FILE if it cannot be dlopened at runtime 3981a7b590b3Smrg -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols 3982a7b590b3Smrg -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) 3983a7b590b3Smrg -export-symbols SYMFILE 3984a7b590b3Smrg try to export only the symbols listed in SYMFILE 3985a7b590b3Smrg -export-symbols-regex REGEX 3986a7b590b3Smrg try to export only the symbols matching REGEX 3987a7b590b3Smrg -LLIBDIR search LIBDIR for required installed libraries 3988a7b590b3Smrg -lNAME OUTPUT-FILE requires the installed library libNAME 3989a7b590b3Smrg -module build a library that can dlopened 3990a7b590b3Smrg -no-fast-install disable the fast-install mode 3991a7b590b3Smrg -no-install link a not-installable executable 3992a7b590b3Smrg -no-undefined declare that a library does not refer to external symbols 3993a7b590b3Smrg -o OUTPUT-FILE create OUTPUT-FILE from the specified objects 399415ffece8Smrg -objectlist FILE use a list of object files found in FILE to specify objects 399515ffece8Smrg -os2dllname NAME force a short DLL name on OS/2 (no effect on other OSes) 3996a7b590b3Smrg -precious-files-regex REGEX 3997a7b590b3Smrg don't remove output files matching REGEX 3998a7b590b3Smrg -release RELEASE specify package release information 3999a7b590b3Smrg -rpath LIBDIR the created library will eventually be installed in LIBDIR 4000a7b590b3Smrg -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries 4001a7b590b3Smrg -shared only do dynamic linking of libtool libraries 4002a7b590b3Smrg -shrext SUFFIX override the standard shared library file extension 4003a7b590b3Smrg -static do not do any dynamic linking of uninstalled libtool libraries 4004a7b590b3Smrg -static-libtool-libs 4005a7b590b3Smrg do not do any dynamic linking of libtool libraries 4006a7b590b3Smrg -version-info CURRENT[:REVISION[:AGE]] 4007a7b590b3Smrg specify library version info [each variable defaults to 0] 4008a7b590b3Smrg -weak LIBNAME declare that the target provides the LIBNAME interface 40093e51e026Smrg -Wc,FLAG 40103e51e026Smrg -Xcompiler FLAG pass linker-specific FLAG directly to the compiler 401115ffece8Smrg -Wa,FLAG 401215ffece8Smrg -Xassembler FLAG pass linker-specific FLAG directly to the assembler 40133e51e026Smrg -Wl,FLAG 40143e51e026Smrg -Xlinker FLAG pass linker-specific FLAG directly to the linker 40153e51e026Smrg -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) 4016943345d3Smrg 401715ffece8SmrgAll other options (arguments beginning with '-') are ignored. 4018943345d3Smrg 401915ffece8SmrgEvery other argument is treated as a filename. Files ending in '.la' are 4020a7b590b3Smrgtreated as uninstalled libtool libraries, other files are standard or library 4021a7b590b3Smrgobject files. 40225e695a52Smrg 402315ffece8SmrgIf the OUTPUT-FILE ends in '.la', then a libtool library is created, 402415ffece8Smrgonly library objects ('.lo' files) may be specified, and '-rpath' is 4025a7b590b3Smrgrequired, except when creating a convenience library. 4026943345d3Smrg 402715ffece8SmrgIf OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created 402815ffece8Smrgusing 'ar' and 'ranlib', or on Windows using 'lib'. 4029943345d3Smrg 403015ffece8SmrgIf OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file 4031a7b590b3Smrgis created, otherwise an executable program is created." 4032943345d3Smrg ;; 4033943345d3Smrg 4034a7b590b3Smrg uninstall) 4035a7b590b3Smrg $ECHO \ 4036a7b590b3Smrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... 4037943345d3Smrg 4038a7b590b3SmrgRemove libraries from an installation directory. 4039943345d3Smrg 4040a7b590b3SmrgRM is the name of the program to use to delete files associated with each FILE 404115ffece8Smrg(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 4042a7b590b3Smrgto RM. 4043943345d3Smrg 4044a7b590b3SmrgIf FILE is a libtool library, all the files associated with it are deleted. 4045a7b590b3SmrgOtherwise, only FILE itself is deleted using RM." 4046a7b590b3Smrg ;; 4047943345d3Smrg 4048a7b590b3Smrg *) 404915ffece8Smrg func_fatal_help "invalid operation mode '$opt_mode'" 4050a7b590b3Smrg ;; 4051a7b590b3Smrg esac 4052943345d3Smrg 40533e51e026Smrg echo 405415ffece8Smrg $ECHO "Try '$progname --help' for more information about other modes." 4055a7b590b3Smrg} 4056943345d3Smrg 40573e51e026Smrg# Now that we've collected a possible --mode arg, show help if necessary 40583e51e026Smrgif $opt_help; then 405915ffece8Smrg if test : = "$opt_help"; then 40603e51e026Smrg func_mode_help 40613e51e026Smrg else 40623e51e026Smrg { 40633e51e026Smrg func_help noexit 40643e51e026Smrg for opt_mode in compile link execute install finish uninstall clean; do 40653e51e026Smrg func_mode_help 40663e51e026Smrg done 406715ffece8Smrg } | $SED -n '1p; 2,$s/^Usage:/ or: /p' 40683e51e026Smrg { 40693e51e026Smrg func_help noexit 40703e51e026Smrg for opt_mode in compile link execute install finish uninstall clean; do 40713e51e026Smrg echo 40723e51e026Smrg func_mode_help 40733e51e026Smrg done 40743e51e026Smrg } | 407515ffece8Smrg $SED '1d 40763e51e026Smrg /^When reporting/,/^Report/{ 40773e51e026Smrg H 40783e51e026Smrg d 40793e51e026Smrg } 40803e51e026Smrg $x 40813e51e026Smrg /information about other modes/d 40823e51e026Smrg /more detailed .*MODE/d 40833e51e026Smrg s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' 40843e51e026Smrg fi 40853e51e026Smrg exit $? 40863e51e026Smrgfi 4087943345d3Smrg 4088943345d3Smrg 4089a7b590b3Smrg# func_mode_execute arg... 4090a7b590b3Smrgfunc_mode_execute () 4091a7b590b3Smrg{ 409215ffece8Smrg $debug_cmd 409315ffece8Smrg 4094a7b590b3Smrg # The first argument is the command name. 409515ffece8Smrg cmd=$nonopt 4096a7b590b3Smrg test -z "$cmd" && \ 4097a7b590b3Smrg func_fatal_help "you must specify a COMMAND" 4098943345d3Smrg 4099a7b590b3Smrg # Handle -dlopen flags immediately. 41003e51e026Smrg for file in $opt_dlopen; do 4101a7b590b3Smrg test -f "$file" \ 410215ffece8Smrg || func_fatal_help "'$file' is not a file" 4103943345d3Smrg 4104a7b590b3Smrg dir= 4105a7b590b3Smrg case $file in 4106a7b590b3Smrg *.la) 41073e51e026Smrg func_resolve_sysroot "$file" 41083e51e026Smrg file=$func_resolve_sysroot_result 41093e51e026Smrg 4110a7b590b3Smrg # Check to see that this really is a libtool archive. 4111a7b590b3Smrg func_lalib_unsafe_p "$file" \ 411215ffece8Smrg || func_fatal_help "'$lib' is not a valid libtool archive" 4113943345d3Smrg 4114a7b590b3Smrg # Read the libtool library. 4115a7b590b3Smrg dlname= 4116a7b590b3Smrg library_names= 4117a7b590b3Smrg func_source "$file" 4118943345d3Smrg 4119a7b590b3Smrg # Skip this library if it cannot be dlopened. 4120a7b590b3Smrg if test -z "$dlname"; then 4121a7b590b3Smrg # Warn if it was a shared library. 4122a7b590b3Smrg test -n "$library_names" && \ 412315ffece8Smrg func_warning "'$file' was not linked with '-export-dynamic'" 4124a7b590b3Smrg continue 4125a7b590b3Smrg fi 4126943345d3Smrg 4127a7b590b3Smrg func_dirname "$file" "" "." 412815ffece8Smrg dir=$func_dirname_result 4129943345d3Smrg 4130a7b590b3Smrg if test -f "$dir/$objdir/$dlname"; then 41313e51e026Smrg func_append dir "/$objdir" 4132a7b590b3Smrg else 4133a7b590b3Smrg if test ! -f "$dir/$dlname"; then 413415ffece8Smrg func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'" 4135a7b590b3Smrg fi 4136a7b590b3Smrg fi 4137943345d3Smrg ;; 4138943345d3Smrg 4139a7b590b3Smrg *.lo) 4140a7b590b3Smrg # Just add the directory containing the .lo file. 4141a7b590b3Smrg func_dirname "$file" "" "." 414215ffece8Smrg dir=$func_dirname_result 4143943345d3Smrg ;; 4144943345d3Smrg 4145a7b590b3Smrg *) 414615ffece8Smrg func_warning "'-dlopen' is ignored for non-libtool libraries and objects" 4147943345d3Smrg continue 4148943345d3Smrg ;; 4149a7b590b3Smrg esac 4150943345d3Smrg 4151a7b590b3Smrg # Get the absolute pathname. 4152a7b590b3Smrg absdir=`cd "$dir" && pwd` 415315ffece8Smrg test -n "$absdir" && dir=$absdir 4154943345d3Smrg 4155a7b590b3Smrg # Now add the directory to shlibpath_var. 4156a7b590b3Smrg if eval "test -z \"\$$shlibpath_var\""; then 4157a7b590b3Smrg eval "$shlibpath_var=\"\$dir\"" 4158a7b590b3Smrg else 4159a7b590b3Smrg eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" 4160a7b590b3Smrg fi 4161a7b590b3Smrg done 4162943345d3Smrg 4163a7b590b3Smrg # This variable tells wrapper scripts just to set shlibpath_var 4164a7b590b3Smrg # rather than running their programs. 416515ffece8Smrg libtool_execute_magic=$magic 4166943345d3Smrg 4167a7b590b3Smrg # Check if any of the arguments is a wrapper script. 4168a7b590b3Smrg args= 4169a7b590b3Smrg for file 4170a7b590b3Smrg do 4171a7b590b3Smrg case $file in 41723e51e026Smrg -* | *.la | *.lo ) ;; 4173a7b590b3Smrg *) 4174a7b590b3Smrg # Do a test to see if this is really a libtool program. 4175a7b590b3Smrg if func_ltwrapper_script_p "$file"; then 4176a7b590b3Smrg func_source "$file" 4177a7b590b3Smrg # Transform arg to wrapped name. 417815ffece8Smrg file=$progdir/$program 4179a7b590b3Smrg elif func_ltwrapper_executable_p "$file"; then 4180a7b590b3Smrg func_ltwrapper_scriptname "$file" 4181a7b590b3Smrg func_source "$func_ltwrapper_scriptname_result" 4182a7b590b3Smrg # Transform arg to wrapped name. 418315ffece8Smrg file=$progdir/$program 4184a7b590b3Smrg fi 4185a7b590b3Smrg ;; 4186a7b590b3Smrg esac 4187a7b590b3Smrg # Quote arguments (to preserve shell metacharacters). 41883e51e026Smrg func_append_quoted args "$file" 4189a7b590b3Smrg done 4190943345d3Smrg 419115ffece8Smrg if $opt_dry_run; then 419215ffece8Smrg # Display what would be done. 419315ffece8Smrg if test -n "$shlibpath_var"; then 419415ffece8Smrg eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" 419515ffece8Smrg echo "export $shlibpath_var" 419615ffece8Smrg fi 419715ffece8Smrg $ECHO "$cmd$args" 419815ffece8Smrg exit $EXIT_SUCCESS 419915ffece8Smrg else 4200a7b590b3Smrg if test -n "$shlibpath_var"; then 4201a7b590b3Smrg # Export the shlibpath_var. 4202a7b590b3Smrg eval "export $shlibpath_var" 4203a7b590b3Smrg fi 4204943345d3Smrg 4205a7b590b3Smrg # Restore saved environment variables 4206a7b590b3Smrg for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 4207a7b590b3Smrg do 4208a7b590b3Smrg eval "if test \"\${save_$lt_var+set}\" = set; then 4209a7b590b3Smrg $lt_var=\$save_$lt_var; export $lt_var 4210943345d3Smrg else 4211a7b590b3Smrg $lt_unset $lt_var 4212a7b590b3Smrg fi" 4213a7b590b3Smrg done 4214943345d3Smrg 4215a7b590b3Smrg # Now prepare to actually exec the command. 421615ffece8Smrg exec_cmd=\$cmd$args 4217a7b590b3Smrg fi 4218a7b590b3Smrg} 4219943345d3Smrg 422015ffece8Smrgtest execute = "$opt_mode" && func_mode_execute ${1+"$@"} 4221943345d3Smrg 4222943345d3Smrg 4223a7b590b3Smrg# func_mode_finish arg... 4224a7b590b3Smrgfunc_mode_finish () 4225a7b590b3Smrg{ 422615ffece8Smrg $debug_cmd 422715ffece8Smrg 42283e51e026Smrg libs= 42293e51e026Smrg libdirs= 4230a7b590b3Smrg admincmds= 4231943345d3Smrg 42323e51e026Smrg for opt in "$nonopt" ${1+"$@"} 42333e51e026Smrg do 42343e51e026Smrg if test -d "$opt"; then 42353e51e026Smrg func_append libdirs " $opt" 42363e51e026Smrg 42373e51e026Smrg elif test -f "$opt"; then 42383e51e026Smrg if func_lalib_unsafe_p "$opt"; then 42393e51e026Smrg func_append libs " $opt" 42403e51e026Smrg else 424115ffece8Smrg func_warning "'$opt' is not a valid libtool archive" 42423e51e026Smrg fi 42433e51e026Smrg 42443e51e026Smrg else 424515ffece8Smrg func_fatal_error "invalid argument '$opt'" 42463e51e026Smrg fi 42473e51e026Smrg done 42483e51e026Smrg 42493e51e026Smrg if test -n "$libs"; then 42503e51e026Smrg if test -n "$lt_sysroot"; then 42513e51e026Smrg sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` 42523e51e026Smrg sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" 42533e51e026Smrg else 42543e51e026Smrg sysroot_cmd= 42553e51e026Smrg fi 42563e51e026Smrg 42573e51e026Smrg # Remove sysroot references 42583e51e026Smrg if $opt_dry_run; then 42593e51e026Smrg for lib in $libs; do 426015ffece8Smrg echo "removing references to $lt_sysroot and '=' prefixes from $lib" 42613e51e026Smrg done 42623e51e026Smrg else 42633e51e026Smrg tmpdir=`func_mktempdir` 42643e51e026Smrg for lib in $libs; do 426515ffece8Smrg $SED -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ 42663e51e026Smrg > $tmpdir/tmp-la 42673e51e026Smrg mv -f $tmpdir/tmp-la $lib 42683e51e026Smrg done 42693e51e026Smrg ${RM}r "$tmpdir" 42703e51e026Smrg fi 42713e51e026Smrg fi 4272943345d3Smrg 42733e51e026Smrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 4274a7b590b3Smrg for libdir in $libdirs; do 4275a7b590b3Smrg if test -n "$finish_cmds"; then 4276a7b590b3Smrg # Do each command in the finish commands. 4277a7b590b3Smrg func_execute_cmds "$finish_cmds" 'admincmds="$admincmds 4278a7b590b3Smrg'"$cmd"'"' 4279943345d3Smrg fi 4280a7b590b3Smrg if test -n "$finish_eval"; then 4281a7b590b3Smrg # Do the single finish_eval. 4282a7b590b3Smrg eval cmds=\"$finish_eval\" 42833e51e026Smrg $opt_dry_run || eval "$cmds" || func_append admincmds " 4284a7b590b3Smrg $cmds" 4285a7b590b3Smrg fi 4286a7b590b3Smrg done 4287a7b590b3Smrg fi 4288943345d3Smrg 4289a7b590b3Smrg # Exit here if they wanted silent mode. 429015ffece8Smrg $opt_quiet && exit $EXIT_SUCCESS 4291943345d3Smrg 42923e51e026Smrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 42933e51e026Smrg echo "----------------------------------------------------------------------" 42943e51e026Smrg echo "Libraries have been installed in:" 42953e51e026Smrg for libdir in $libdirs; do 42963e51e026Smrg $ECHO " $libdir" 42973e51e026Smrg done 42983e51e026Smrg echo 42993e51e026Smrg echo "If you ever happen to want to link against installed libraries" 43003e51e026Smrg echo "in a given directory, LIBDIR, you must either use libtool, and" 430115ffece8Smrg echo "specify the full pathname of the library, or use the '-LLIBDIR'" 43023e51e026Smrg echo "flag during linking and do at least one of the following:" 43033e51e026Smrg if test -n "$shlibpath_var"; then 430415ffece8Smrg echo " - add LIBDIR to the '$shlibpath_var' environment variable" 43053e51e026Smrg echo " during execution" 43063e51e026Smrg fi 43073e51e026Smrg if test -n "$runpath_var"; then 430815ffece8Smrg echo " - add LIBDIR to the '$runpath_var' environment variable" 43093e51e026Smrg echo " during linking" 43103e51e026Smrg fi 43113e51e026Smrg if test -n "$hardcode_libdir_flag_spec"; then 43123e51e026Smrg libdir=LIBDIR 43133e51e026Smrg eval flag=\"$hardcode_libdir_flag_spec\" 4314a7b590b3Smrg 431515ffece8Smrg $ECHO " - use the '$flag' linker flag" 43163e51e026Smrg fi 43173e51e026Smrg if test -n "$admincmds"; then 43183e51e026Smrg $ECHO " - have your system administrator run these commands:$admincmds" 43193e51e026Smrg fi 43203e51e026Smrg if test -f /etc/ld.so.conf; then 432115ffece8Smrg echo " - have your system administrator add LIBDIR to '/etc/ld.so.conf'" 43223e51e026Smrg fi 43233e51e026Smrg echo 4324a7b590b3Smrg 43253e51e026Smrg echo "See any operating system documentation about shared libraries for" 43263e51e026Smrg case $host in 43273e51e026Smrg solaris2.[6789]|solaris2.1[0-9]) 43283e51e026Smrg echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" 43293e51e026Smrg echo "pages." 43303e51e026Smrg ;; 43313e51e026Smrg *) 43323e51e026Smrg echo "more information, such as the ld(1) and ld.so(8) manual pages." 43333e51e026Smrg ;; 43343e51e026Smrg esac 43353e51e026Smrg echo "----------------------------------------------------------------------" 43363e51e026Smrg fi 4337a7b590b3Smrg exit $EXIT_SUCCESS 4338a7b590b3Smrg} 4339a7b590b3Smrg 434015ffece8Smrgtest finish = "$opt_mode" && func_mode_finish ${1+"$@"} 4341a7b590b3Smrg 4342a7b590b3Smrg 4343a7b590b3Smrg# func_mode_install arg... 4344a7b590b3Smrgfunc_mode_install () 4345a7b590b3Smrg{ 434615ffece8Smrg $debug_cmd 434715ffece8Smrg 4348a7b590b3Smrg # There may be an optional sh(1) argument at the beginning of 4349a7b590b3Smrg # install_prog (especially on Windows NT). 435015ffece8Smrg if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" || 4351a7b590b3Smrg # Allow the use of GNU shtool's install command. 435215ffece8Smrg case $nonopt in *shtool*) :;; *) false;; esac 435315ffece8Smrg then 4354a7b590b3Smrg # Aesthetically quote it. 435515ffece8Smrg func_quote_arg pretty "$nonopt" 435615ffece8Smrg install_prog="$func_quote_arg_result " 4357a7b590b3Smrg arg=$1 4358a7b590b3Smrg shift 4359a7b590b3Smrg else 4360a7b590b3Smrg install_prog= 4361a7b590b3Smrg arg=$nonopt 4362a7b590b3Smrg fi 4363a7b590b3Smrg 4364a7b590b3Smrg # The real first argument should be the name of the installation program. 4365a7b590b3Smrg # Aesthetically quote it. 436615ffece8Smrg func_quote_arg pretty "$arg" 436715ffece8Smrg func_append install_prog "$func_quote_arg_result" 43683e51e026Smrg install_shared_prog=$install_prog 43693e51e026Smrg case " $install_prog " in 43703e51e026Smrg *[\\\ /]cp\ *) install_cp=: ;; 43713e51e026Smrg *) install_cp=false ;; 43723e51e026Smrg esac 4373a7b590b3Smrg 4374a7b590b3Smrg # We need to accept at least all the BSD install flags. 4375a7b590b3Smrg dest= 4376a7b590b3Smrg files= 4377a7b590b3Smrg opts= 4378a7b590b3Smrg prev= 4379a7b590b3Smrg install_type= 438015ffece8Smrg isdir=false 4381a7b590b3Smrg stripme= 43823e51e026Smrg no_mode=: 4383a7b590b3Smrg for arg 4384a7b590b3Smrg do 43853e51e026Smrg arg2= 4386a7b590b3Smrg if test -n "$dest"; then 43873e51e026Smrg func_append files " $dest" 4388a7b590b3Smrg dest=$arg 4389a7b590b3Smrg continue 4390a7b590b3Smrg fi 4391a7b590b3Smrg 4392a7b590b3Smrg case $arg in 439315ffece8Smrg -d) isdir=: ;; 4394a7b590b3Smrg -f) 43953e51e026Smrg if $install_cp; then :; else 43963e51e026Smrg prev=$arg 43973e51e026Smrg fi 4398a7b590b3Smrg ;; 4399a7b590b3Smrg -g | -m | -o) 4400a7b590b3Smrg prev=$arg 4401a7b590b3Smrg ;; 4402a7b590b3Smrg -s) 4403a7b590b3Smrg stripme=" -s" 4404a7b590b3Smrg continue 4405a7b590b3Smrg ;; 4406a7b590b3Smrg -*) 4407a7b590b3Smrg ;; 4408a7b590b3Smrg *) 4409a7b590b3Smrg # If the previous option needed an argument, then skip it. 4410a7b590b3Smrg if test -n "$prev"; then 441115ffece8Smrg if test X-m = "X$prev" && test -n "$install_override_mode"; then 44123e51e026Smrg arg2=$install_override_mode 44133e51e026Smrg no_mode=false 44143e51e026Smrg fi 4415943345d3Smrg prev= 4416943345d3Smrg else 4417a7b590b3Smrg dest=$arg 4418a7b590b3Smrg continue 4419943345d3Smrg fi 4420943345d3Smrg ;; 4421a7b590b3Smrg esac 4422943345d3Smrg 4423a7b590b3Smrg # Aesthetically quote the argument. 442415ffece8Smrg func_quote_arg pretty "$arg" 442515ffece8Smrg func_append install_prog " $func_quote_arg_result" 44263e51e026Smrg if test -n "$arg2"; then 442715ffece8Smrg func_quote_arg pretty "$arg2" 44283e51e026Smrg fi 442915ffece8Smrg func_append install_shared_prog " $func_quote_arg_result" 4430a7b590b3Smrg done 4431943345d3Smrg 4432a7b590b3Smrg test -z "$install_prog" && \ 4433a7b590b3Smrg func_fatal_help "you must specify an install program" 4434943345d3Smrg 4435a7b590b3Smrg test -n "$prev" && \ 443615ffece8Smrg func_fatal_help "the '$prev' option requires an argument" 4437943345d3Smrg 44383e51e026Smrg if test -n "$install_override_mode" && $no_mode; then 44393e51e026Smrg if $install_cp; then :; else 444015ffece8Smrg func_quote_arg pretty "$install_override_mode" 444115ffece8Smrg func_append install_shared_prog " -m $func_quote_arg_result" 44423e51e026Smrg fi 44433e51e026Smrg fi 44443e51e026Smrg 4445a7b590b3Smrg if test -z "$files"; then 4446a7b590b3Smrg if test -z "$dest"; then 4447a7b590b3Smrg func_fatal_help "no file or destination specified" 4448a7b590b3Smrg else 4449a7b590b3Smrg func_fatal_help "you must specify a destination" 4450a7b590b3Smrg fi 4451943345d3Smrg fi 4452943345d3Smrg 4453a7b590b3Smrg # Strip any trailing slash from the destination. 4454a7b590b3Smrg func_stripname '' '/' "$dest" 4455a7b590b3Smrg dest=$func_stripname_result 4456943345d3Smrg 4457a7b590b3Smrg # Check to see that the destination is a directory. 445815ffece8Smrg test -d "$dest" && isdir=: 445915ffece8Smrg if $isdir; then 446015ffece8Smrg destdir=$dest 4461a7b590b3Smrg destname= 4462943345d3Smrg else 4463a7b590b3Smrg func_dirname_and_basename "$dest" "" "." 446415ffece8Smrg destdir=$func_dirname_result 446515ffece8Smrg destname=$func_basename_result 4466943345d3Smrg 4467a7b590b3Smrg # Not a directory, so check to see that there is only one file specified. 4468a7b590b3Smrg set dummy $files; shift 4469a7b590b3Smrg test "$#" -gt 1 && \ 447015ffece8Smrg func_fatal_help "'$dest' is not a directory" 4471943345d3Smrg fi 4472a7b590b3Smrg case $destdir in 4473a7b590b3Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 4474943345d3Smrg *) 4475a7b590b3Smrg for file in $files; do 4476a7b590b3Smrg case $file in 4477a7b590b3Smrg *.lo) ;; 4478a7b590b3Smrg *) 447915ffece8Smrg func_fatal_help "'$destdir' must be an absolute directory name" 4480a7b590b3Smrg ;; 4481a7b590b3Smrg esac 4482a7b590b3Smrg done 4483943345d3Smrg ;; 4484943345d3Smrg esac 4485943345d3Smrg 4486a7b590b3Smrg # This variable tells wrapper scripts just to set variables rather 4487a7b590b3Smrg # than running their programs. 448815ffece8Smrg libtool_install_magic=$magic 4489943345d3Smrg 4490a7b590b3Smrg staticlibs= 4491a7b590b3Smrg future_libdirs= 4492a7b590b3Smrg current_libdirs= 4493a7b590b3Smrg for file in $files; do 4494943345d3Smrg 4495a7b590b3Smrg # Do each installation. 4496a7b590b3Smrg case $file in 4497a7b590b3Smrg *.$libext) 4498a7b590b3Smrg # Do the static libraries later. 44993e51e026Smrg func_append staticlibs " $file" 4500a7b590b3Smrg ;; 4501a7b590b3Smrg 4502a7b590b3Smrg *.la) 45033e51e026Smrg func_resolve_sysroot "$file" 45043e51e026Smrg file=$func_resolve_sysroot_result 45053e51e026Smrg 4506a7b590b3Smrg # Check to see that this really is a libtool archive. 4507a7b590b3Smrg func_lalib_unsafe_p "$file" \ 450815ffece8Smrg || func_fatal_help "'$file' is not a valid libtool archive" 4509a7b590b3Smrg 4510a7b590b3Smrg library_names= 4511a7b590b3Smrg old_library= 4512a7b590b3Smrg relink_command= 4513a7b590b3Smrg func_source "$file" 4514a7b590b3Smrg 4515a7b590b3Smrg # Add the libdir to current_libdirs if it is the destination. 4516a7b590b3Smrg if test "X$destdir" = "X$libdir"; then 4517a7b590b3Smrg case "$current_libdirs " in 4518a7b590b3Smrg *" $libdir "*) ;; 45193e51e026Smrg *) func_append current_libdirs " $libdir" ;; 4520943345d3Smrg esac 4521a7b590b3Smrg else 4522a7b590b3Smrg # Note the libdir as a future libdir. 4523a7b590b3Smrg case "$future_libdirs " in 4524a7b590b3Smrg *" $libdir "*) ;; 45253e51e026Smrg *) func_append future_libdirs " $libdir" ;; 4526a7b590b3Smrg esac 4527a7b590b3Smrg fi 4528943345d3Smrg 4529a7b590b3Smrg func_dirname "$file" "/" "" 453015ffece8Smrg dir=$func_dirname_result 45313e51e026Smrg func_append dir "$objdir" 4532a7b590b3Smrg 4533a7b590b3Smrg if test -n "$relink_command"; then 4534a7b590b3Smrg # Determine the prefix the user has applied to our future dir. 45353e51e026Smrg inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` 4536a7b590b3Smrg 4537a7b590b3Smrg # Don't allow the user to place us outside of our expected 4538a7b590b3Smrg # location b/c this prevents finding dependent libraries that 4539a7b590b3Smrg # are installed to the same prefix. 4540a7b590b3Smrg # At present, this check doesn't affect windows .dll's that 4541a7b590b3Smrg # are installed into $libdir/../bin (currently, that works fine) 4542a7b590b3Smrg # but it's something to keep an eye on. 4543a7b590b3Smrg test "$inst_prefix_dir" = "$destdir" && \ 454415ffece8Smrg func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir" 4545a7b590b3Smrg 4546a7b590b3Smrg if test -n "$inst_prefix_dir"; then 4547a7b590b3Smrg # Stick the inst_prefix_dir data into the link command. 45483e51e026Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` 4549a7b590b3Smrg else 45503e51e026Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` 4551a7b590b3Smrg fi 4552a7b590b3Smrg 455315ffece8Smrg func_warning "relinking '$file'" 4554a7b590b3Smrg func_show_eval "$relink_command" \ 455515ffece8Smrg 'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"' 4556a7b590b3Smrg fi 4557a7b590b3Smrg 4558a7b590b3Smrg # See the names of the shared library. 4559a7b590b3Smrg set dummy $library_names; shift 4560a7b590b3Smrg if test -n "$1"; then 456115ffece8Smrg realname=$1 4562a7b590b3Smrg shift 4563a7b590b3Smrg 456415ffece8Smrg srcname=$realname 456515ffece8Smrg test -n "$relink_command" && srcname=${realname}T 4566a7b590b3Smrg 4567a7b590b3Smrg # Install the shared library and build the symlinks. 45683e51e026Smrg func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ 4569a7b590b3Smrg 'exit $?' 457015ffece8Smrg tstripme=$stripme 4571a7b590b3Smrg case $host_os in 4572a7b590b3Smrg cygwin* | mingw* | pw32* | cegcc*) 4573a7b590b3Smrg case $realname in 4574a7b590b3Smrg *.dll.a) 457515ffece8Smrg tstripme= 457615ffece8Smrg ;; 457715ffece8Smrg esac 457815ffece8Smrg ;; 457915ffece8Smrg os2*) 458015ffece8Smrg case $realname in 458115ffece8Smrg *_dll.a) 458215ffece8Smrg tstripme= 4583a7b590b3Smrg ;; 4584a7b590b3Smrg esac 4585943345d3Smrg ;; 4586943345d3Smrg esac 4587a7b590b3Smrg if test -n "$tstripme" && test -n "$striplib"; then 4588a7b590b3Smrg func_show_eval "$striplib $destdir/$realname" 'exit $?' 4589943345d3Smrg fi 4590a7b590b3Smrg 4591a7b590b3Smrg if test "$#" -gt 0; then 4592a7b590b3Smrg # Delete the old symlinks, and create new ones. 459315ffece8Smrg # Try 'ln -sf' first, because the 'ln' binary might depend on 4594a7b590b3Smrg # the symlink we replace! Solaris /bin/ln does not understand -f, 4595a7b590b3Smrg # so we also need to try rm && ln -s. 4596a7b590b3Smrg for linkname 4597a7b590b3Smrg do 4598a7b590b3Smrg test "$linkname" != "$realname" \ 4599a7b590b3Smrg && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" 4600943345d3Smrg done 4601943345d3Smrg fi 4602943345d3Smrg 4603a7b590b3Smrg # Do each command in the postinstall commands. 460415ffece8Smrg lib=$destdir/$realname 4605a7b590b3Smrg func_execute_cmds "$postinstall_cmds" 'exit $?' 4606943345d3Smrg fi 4607943345d3Smrg 4608a7b590b3Smrg # Install the pseudo-library for information purposes. 4609a7b590b3Smrg func_basename "$file" 461015ffece8Smrg name=$func_basename_result 461115ffece8Smrg instname=$dir/${name}i 4612a7b590b3Smrg func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' 4613943345d3Smrg 4614a7b590b3Smrg # Maybe install the static library, too. 46153e51e026Smrg test -n "$old_library" && func_append staticlibs " $dir/$old_library" 4616a7b590b3Smrg ;; 4617943345d3Smrg 4618a7b590b3Smrg *.lo) 4619a7b590b3Smrg # Install (i.e. copy) a libtool object. 4620943345d3Smrg 4621a7b590b3Smrg # Figure out destination file name, if it wasn't already specified. 4622a7b590b3Smrg if test -n "$destname"; then 462315ffece8Smrg destfile=$destdir/$destname 4624a7b590b3Smrg else 4625a7b590b3Smrg func_basename "$file" 462615ffece8Smrg destfile=$func_basename_result 462715ffece8Smrg destfile=$destdir/$destfile 4628943345d3Smrg fi 4629943345d3Smrg 4630a7b590b3Smrg # Deduce the name of the destination old-style object file. 4631a7b590b3Smrg case $destfile in 4632a7b590b3Smrg *.lo) 4633a7b590b3Smrg func_lo2o "$destfile" 4634a7b590b3Smrg staticdest=$func_lo2o_result 4635a7b590b3Smrg ;; 4636a7b590b3Smrg *.$objext) 463715ffece8Smrg staticdest=$destfile 4638a7b590b3Smrg destfile= 4639a7b590b3Smrg ;; 4640a7b590b3Smrg *) 464115ffece8Smrg func_fatal_help "cannot copy a libtool object to '$destfile'" 4642a7b590b3Smrg ;; 4643a7b590b3Smrg esac 4644943345d3Smrg 4645a7b590b3Smrg # Install the libtool object if requested. 4646a7b590b3Smrg test -n "$destfile" && \ 4647a7b590b3Smrg func_show_eval "$install_prog $file $destfile" 'exit $?' 4648943345d3Smrg 4649a7b590b3Smrg # Install the old object if enabled. 465015ffece8Smrg if test yes = "$build_old_libs"; then 4651a7b590b3Smrg # Deduce the name of the old-style object file. 4652a7b590b3Smrg func_lo2o "$file" 4653a7b590b3Smrg staticobj=$func_lo2o_result 4654a7b590b3Smrg func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' 4655943345d3Smrg fi 4656a7b590b3Smrg exit $EXIT_SUCCESS 4657a7b590b3Smrg ;; 4658943345d3Smrg 4659a7b590b3Smrg *) 4660a7b590b3Smrg # Figure out destination file name, if it wasn't already specified. 4661a7b590b3Smrg if test -n "$destname"; then 466215ffece8Smrg destfile=$destdir/$destname 4663a7b590b3Smrg else 4664a7b590b3Smrg func_basename "$file" 466515ffece8Smrg destfile=$func_basename_result 466615ffece8Smrg destfile=$destdir/$destfile 4667a7b590b3Smrg fi 4668943345d3Smrg 4669a7b590b3Smrg # If the file is missing, and there is a .exe on the end, strip it 4670a7b590b3Smrg # because it is most likely a libtool script we actually want to 4671a7b590b3Smrg # install 467215ffece8Smrg stripped_ext= 4673a7b590b3Smrg case $file in 4674a7b590b3Smrg *.exe) 4675a7b590b3Smrg if test ! -f "$file"; then 4676a7b590b3Smrg func_stripname '' '.exe' "$file" 4677a7b590b3Smrg file=$func_stripname_result 467815ffece8Smrg stripped_ext=.exe 4679a7b590b3Smrg fi 4680a7b590b3Smrg ;; 4681a7b590b3Smrg esac 4682a7b590b3Smrg 4683a7b590b3Smrg # Do a test to see if this is really a libtool program. 4684a7b590b3Smrg case $host in 4685a7b590b3Smrg *cygwin* | *mingw*) 4686a7b590b3Smrg if func_ltwrapper_executable_p "$file"; then 4687a7b590b3Smrg func_ltwrapper_scriptname "$file" 4688a7b590b3Smrg wrapper=$func_ltwrapper_scriptname_result 4689a7b590b3Smrg else 4690a7b590b3Smrg func_stripname '' '.exe' "$file" 4691a7b590b3Smrg wrapper=$func_stripname_result 4692a7b590b3Smrg fi 4693a7b590b3Smrg ;; 4694943345d3Smrg *) 4695a7b590b3Smrg wrapper=$file 4696a7b590b3Smrg ;; 4697a7b590b3Smrg esac 4698a7b590b3Smrg if func_ltwrapper_script_p "$wrapper"; then 4699a7b590b3Smrg notinst_deplibs= 4700a7b590b3Smrg relink_command= 4701a7b590b3Smrg 4702a7b590b3Smrg func_source "$wrapper" 4703a7b590b3Smrg 4704a7b590b3Smrg # Check the variables that should have been set. 4705a7b590b3Smrg test -z "$generated_by_libtool_version" && \ 470615ffece8Smrg func_fatal_error "invalid libtool wrapper script '$wrapper'" 4707a7b590b3Smrg 470815ffece8Smrg finalize=: 4709a7b590b3Smrg for lib in $notinst_deplibs; do 4710a7b590b3Smrg # Check to see that each library is installed. 4711a7b590b3Smrg libdir= 4712a7b590b3Smrg if test -f "$lib"; then 4713a7b590b3Smrg func_source "$lib" 4714a7b590b3Smrg fi 471515ffece8Smrg libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'` 4716a7b590b3Smrg if test -n "$libdir" && test ! -f "$libfile"; then 471715ffece8Smrg func_warning "'$lib' has not been installed in '$libdir'" 471815ffece8Smrg finalize=false 4719a7b590b3Smrg fi 4720a7b590b3Smrg done 4721a7b590b3Smrg 4722a7b590b3Smrg relink_command= 4723a7b590b3Smrg func_source "$wrapper" 4724a7b590b3Smrg 4725a7b590b3Smrg outputname= 472615ffece8Smrg if test no = "$fast_install" && test -n "$relink_command"; then 4727a7b590b3Smrg $opt_dry_run || { 472815ffece8Smrg if $finalize; then 4729a7b590b3Smrg tmpdir=`func_mktempdir` 4730a7b590b3Smrg func_basename "$file$stripped_ext" 473115ffece8Smrg file=$func_basename_result 473215ffece8Smrg outputname=$tmpdir/$file 4733a7b590b3Smrg # Replace the output file specification. 47343e51e026Smrg relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` 4735a7b590b3Smrg 473615ffece8Smrg $opt_quiet || { 473715ffece8Smrg func_quote_arg expand,pretty "$relink_command" 473815ffece8Smrg eval "func_echo $func_quote_arg_result" 4739a7b590b3Smrg } 4740a7b590b3Smrg if eval "$relink_command"; then : 4741a7b590b3Smrg else 474215ffece8Smrg func_error "error: relink '$file' with the above command before installing it" 4743a7b590b3Smrg $opt_dry_run || ${RM}r "$tmpdir" 4744a7b590b3Smrg continue 4745a7b590b3Smrg fi 474615ffece8Smrg file=$outputname 4747a7b590b3Smrg else 474815ffece8Smrg func_warning "cannot relink '$file'" 4749a7b590b3Smrg fi 4750a7b590b3Smrg } 4751a7b590b3Smrg else 4752a7b590b3Smrg # Install the binary that we compiled earlier. 47533e51e026Smrg file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` 4754943345d3Smrg fi 4755a7b590b3Smrg fi 4756a7b590b3Smrg 4757a7b590b3Smrg # remove .exe since cygwin /usr/bin/install will append another 4758a7b590b3Smrg # one anyway 4759a7b590b3Smrg case $install_prog,$host in 4760a7b590b3Smrg */usr/bin/install*,*cygwin*) 4761a7b590b3Smrg case $file:$destfile in 4762a7b590b3Smrg *.exe:*.exe) 4763a7b590b3Smrg # this is ok 4764a7b590b3Smrg ;; 4765a7b590b3Smrg *.exe:*) 4766a7b590b3Smrg destfile=$destfile.exe 4767a7b590b3Smrg ;; 4768a7b590b3Smrg *:*.exe) 4769a7b590b3Smrg func_stripname '' '.exe' "$destfile" 4770a7b590b3Smrg destfile=$func_stripname_result 4771a7b590b3Smrg ;; 4772a7b590b3Smrg esac 4773943345d3Smrg ;; 4774943345d3Smrg esac 4775a7b590b3Smrg func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' 4776a7b590b3Smrg $opt_dry_run || if test -n "$outputname"; then 4777a7b590b3Smrg ${RM}r "$tmpdir" 4778a7b590b3Smrg fi 4779a7b590b3Smrg ;; 4780a7b590b3Smrg esac 4781a7b590b3Smrg done 4782943345d3Smrg 4783a7b590b3Smrg for file in $staticlibs; do 4784a7b590b3Smrg func_basename "$file" 478515ffece8Smrg name=$func_basename_result 4786a7b590b3Smrg 4787a7b590b3Smrg # Set up the ranlib parameters. 478815ffece8Smrg oldlib=$destdir/$name 47893e51e026Smrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 47903e51e026Smrg tool_oldlib=$func_to_tool_file_result 4791a7b590b3Smrg 4792a7b590b3Smrg func_show_eval "$install_prog \$file \$oldlib" 'exit $?' 4793a7b590b3Smrg 4794a7b590b3Smrg if test -n "$stripme" && test -n "$old_striplib"; then 47953e51e026Smrg func_show_eval "$old_striplib $tool_oldlib" 'exit $?' 4796a7b590b3Smrg fi 4797a7b590b3Smrg 4798a7b590b3Smrg # Do each command in the postinstall commands. 4799a7b590b3Smrg func_execute_cmds "$old_postinstall_cmds" 'exit $?' 4800a7b590b3Smrg done 4801a7b590b3Smrg 4802a7b590b3Smrg test -n "$future_libdirs" && \ 480315ffece8Smrg func_warning "remember to run '$progname --finish$future_libdirs'" 4804a7b590b3Smrg 4805a7b590b3Smrg if test -n "$current_libdirs"; then 4806a7b590b3Smrg # Maybe just do a dry run. 4807a7b590b3Smrg $opt_dry_run && current_libdirs=" -n$current_libdirs" 480815ffece8Smrg exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs' 4809a7b590b3Smrg else 4810a7b590b3Smrg exit $EXIT_SUCCESS 4811a7b590b3Smrg fi 4812a7b590b3Smrg} 4813a7b590b3Smrg 481415ffece8Smrgtest install = "$opt_mode" && func_mode_install ${1+"$@"} 4815a7b590b3Smrg 4816a7b590b3Smrg 4817a7b590b3Smrg# func_generate_dlsyms outputname originator pic_p 4818a7b590b3Smrg# Extract symbols from dlprefiles and create ${outputname}S.o with 4819a7b590b3Smrg# a dlpreopen symbol table. 4820a7b590b3Smrgfunc_generate_dlsyms () 4821a7b590b3Smrg{ 482215ffece8Smrg $debug_cmd 482315ffece8Smrg 482415ffece8Smrg my_outputname=$1 482515ffece8Smrg my_originator=$2 482615ffece8Smrg my_pic_p=${3-false} 482715ffece8Smrg my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'` 4828a7b590b3Smrg my_dlsyms= 4829a7b590b3Smrg 483015ffece8Smrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 4831a7b590b3Smrg if test -n "$NM" && test -n "$global_symbol_pipe"; then 483215ffece8Smrg my_dlsyms=${my_outputname}S.c 4833a7b590b3Smrg else 4834a7b590b3Smrg func_error "not configured to extract global symbols from dlpreopened files" 4835a7b590b3Smrg fi 4836a7b590b3Smrg fi 4837a7b590b3Smrg 4838a7b590b3Smrg if test -n "$my_dlsyms"; then 4839a7b590b3Smrg case $my_dlsyms in 4840a7b590b3Smrg "") ;; 4841a7b590b3Smrg *.c) 4842a7b590b3Smrg # Discover the nlist of each of the dlfiles. 484315ffece8Smrg nlist=$output_objdir/$my_outputname.nm 4844a7b590b3Smrg 4845a7b590b3Smrg func_show_eval "$RM $nlist ${nlist}S ${nlist}T" 4846a7b590b3Smrg 4847a7b590b3Smrg # Parse the name list into a source file. 4848a7b590b3Smrg func_verbose "creating $output_objdir/$my_dlsyms" 4849a7b590b3Smrg 4850a7b590b3Smrg $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ 485115ffece8Smrg/* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */ 485215ffece8Smrg/* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */ 4853a7b590b3Smrg 4854a7b590b3Smrg#ifdef __cplusplus 4855a7b590b3Smrgextern \"C\" { 4856a7b590b3Smrg#endif 4857a7b590b3Smrg 485815ffece8Smrg#if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) 48593e51e026Smrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\" 48603e51e026Smrg#endif 48613e51e026Smrg 48623e51e026Smrg/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ 486315ffece8Smrg#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE 486415ffece8Smrg/* DATA imports from DLLs on WIN32 can't be const, because runtime 48653e51e026Smrg relocations are performed -- see ld's documentation on pseudo-relocs. */ 48663e51e026Smrg# define LT_DLSYM_CONST 486715ffece8Smrg#elif defined __osf__ 48683e51e026Smrg/* This system does not cope well with relocations in const data. */ 48693e51e026Smrg# define LT_DLSYM_CONST 48703e51e026Smrg#else 48713e51e026Smrg# define LT_DLSYM_CONST const 48723e51e026Smrg#endif 48733e51e026Smrg 487415ffece8Smrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 487515ffece8Smrg 4876a7b590b3Smrg/* External symbol declarations for the compiler. */\ 4877a7b590b3Smrg" 4878a7b590b3Smrg 487915ffece8Smrg if test yes = "$dlself"; then 488015ffece8Smrg func_verbose "generating symbol list for '$output'" 4881a7b590b3Smrg 4882a7b590b3Smrg $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" 4883a7b590b3Smrg 4884a7b590b3Smrg # Add our own program objects to the symbol list. 48853e51e026Smrg progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` 4886a7b590b3Smrg for progfile in $progfiles; do 48873e51e026Smrg func_to_tool_file "$progfile" func_convert_file_msys_to_w32 488815ffece8Smrg func_verbose "extracting global C symbols from '$func_to_tool_file_result'" 48893e51e026Smrg $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" 4890a7b590b3Smrg done 4891a7b590b3Smrg 4892a7b590b3Smrg if test -n "$exclude_expsyms"; then 4893a7b590b3Smrg $opt_dry_run || { 4894a7b590b3Smrg eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' 4895a7b590b3Smrg eval '$MV "$nlist"T "$nlist"' 4896a7b590b3Smrg } 4897943345d3Smrg fi 4898a7b590b3Smrg 4899a7b590b3Smrg if test -n "$export_symbols_regex"; then 4900a7b590b3Smrg $opt_dry_run || { 4901a7b590b3Smrg eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' 4902a7b590b3Smrg eval '$MV "$nlist"T "$nlist"' 4903a7b590b3Smrg } 4904a7b590b3Smrg fi 4905a7b590b3Smrg 4906a7b590b3Smrg # Prepare the list of exported symbols 4907a7b590b3Smrg if test -z "$export_symbols"; then 490815ffece8Smrg export_symbols=$output_objdir/$outputname.exp 4909a7b590b3Smrg $opt_dry_run || { 4910a7b590b3Smrg $RM $export_symbols 491115ffece8Smrg eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' 4912a7b590b3Smrg case $host in 4913a7b590b3Smrg *cygwin* | *mingw* | *cegcc* ) 4914a7b590b3Smrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 4915a7b590b3Smrg eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' 4916a7b590b3Smrg ;; 4917a7b590b3Smrg esac 4918a7b590b3Smrg } 4919943345d3Smrg else 4920a7b590b3Smrg $opt_dry_run || { 492115ffece8Smrg eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' 4922a7b590b3Smrg eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' 4923a7b590b3Smrg eval '$MV "$nlist"T "$nlist"' 4924a7b590b3Smrg case $host in 49253e51e026Smrg *cygwin* | *mingw* | *cegcc* ) 4926a7b590b3Smrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 4927a7b590b3Smrg eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' 4928a7b590b3Smrg ;; 4929a7b590b3Smrg esac 4930a7b590b3Smrg } 4931943345d3Smrg fi 4932a7b590b3Smrg fi 4933943345d3Smrg 4934a7b590b3Smrg for dlprefile in $dlprefiles; do 493515ffece8Smrg func_verbose "extracting global C symbols from '$dlprefile'" 4936a7b590b3Smrg func_basename "$dlprefile" 493715ffece8Smrg name=$func_basename_result 49383e51e026Smrg case $host in 49393e51e026Smrg *cygwin* | *mingw* | *cegcc* ) 49403e51e026Smrg # if an import library, we need to obtain dlname 49413e51e026Smrg if func_win32_import_lib_p "$dlprefile"; then 49423e51e026Smrg func_tr_sh "$dlprefile" 49433e51e026Smrg eval "curr_lafile=\$libfile_$func_tr_sh_result" 494415ffece8Smrg dlprefile_dlbasename= 49453e51e026Smrg if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then 49463e51e026Smrg # Use subshell, to avoid clobbering current variable values 49473e51e026Smrg dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` 494815ffece8Smrg if test -n "$dlprefile_dlname"; then 49493e51e026Smrg func_basename "$dlprefile_dlname" 495015ffece8Smrg dlprefile_dlbasename=$func_basename_result 49513e51e026Smrg else 49523e51e026Smrg # no lafile. user explicitly requested -dlpreopen <import library>. 49533e51e026Smrg $sharedlib_from_linklib_cmd "$dlprefile" 49543e51e026Smrg dlprefile_dlbasename=$sharedlib_from_linklib_result 49553e51e026Smrg fi 49563e51e026Smrg fi 49573e51e026Smrg $opt_dry_run || { 495815ffece8Smrg if test -n "$dlprefile_dlbasename"; then 49593e51e026Smrg eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' 49603e51e026Smrg else 49613e51e026Smrg func_warning "Could not compute DLL name from $name" 49623e51e026Smrg eval '$ECHO ": $name " >> "$nlist"' 49633e51e026Smrg fi 49643e51e026Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 49653e51e026Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | 49663e51e026Smrg $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" 49673e51e026Smrg } 49683e51e026Smrg else # not an import lib 49693e51e026Smrg $opt_dry_run || { 49703e51e026Smrg eval '$ECHO ": $name " >> "$nlist"' 49713e51e026Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 49723e51e026Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 49733e51e026Smrg } 49743e51e026Smrg fi 49753e51e026Smrg ;; 49763e51e026Smrg *) 49773e51e026Smrg $opt_dry_run || { 49783e51e026Smrg eval '$ECHO ": $name " >> "$nlist"' 49793e51e026Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 49803e51e026Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 49813e51e026Smrg } 49823e51e026Smrg ;; 49833e51e026Smrg esac 4984a7b590b3Smrg done 4985a7b590b3Smrg 4986a7b590b3Smrg $opt_dry_run || { 4987a7b590b3Smrg # Make sure we have at least an empty file. 4988a7b590b3Smrg test -f "$nlist" || : > "$nlist" 4989a7b590b3Smrg 4990a7b590b3Smrg if test -n "$exclude_expsyms"; then 4991a7b590b3Smrg $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T 4992a7b590b3Smrg $MV "$nlist"T "$nlist" 4993943345d3Smrg fi 4994a7b590b3Smrg 4995a7b590b3Smrg # Try sorting and uniquifying the output. 4996a7b590b3Smrg if $GREP -v "^: " < "$nlist" | 4997a7b590b3Smrg if sort -k 3 </dev/null >/dev/null 2>&1; then 4998a7b590b3Smrg sort -k 3 4999a7b590b3Smrg else 5000a7b590b3Smrg sort +2 5001a7b590b3Smrg fi | 5002a7b590b3Smrg uniq > "$nlist"S; then 5003a7b590b3Smrg : 5004943345d3Smrg else 5005a7b590b3Smrg $GREP -v "^: " < "$nlist" > "$nlist"S 5006943345d3Smrg fi 5007943345d3Smrg 5008a7b590b3Smrg if test -f "$nlist"S; then 5009a7b590b3Smrg eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' 5010943345d3Smrg else 50113e51e026Smrg echo '/* NONE */' >> "$output_objdir/$my_dlsyms" 5012943345d3Smrg fi 5013943345d3Smrg 501415ffece8Smrg func_show_eval '$RM "${nlist}I"' 501515ffece8Smrg if test -n "$global_symbol_to_import"; then 501615ffece8Smrg eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I' 501715ffece8Smrg fi 501815ffece8Smrg 50193e51e026Smrg echo >> "$output_objdir/$my_dlsyms" "\ 5020943345d3Smrg 5021a7b590b3Smrg/* The mapping between symbol names and symbols. */ 5022a7b590b3Smrgtypedef struct { 5023a7b590b3Smrg const char *name; 5024a7b590b3Smrg void *address; 5025a7b590b3Smrg} lt_dlsymlist; 50263e51e026Smrgextern LT_DLSYM_CONST lt_dlsymlist 502715ffece8Smrglt_${my_prefix}_LTX_preloaded_symbols[];\ 502815ffece8Smrg" 502915ffece8Smrg 503015ffece8Smrg if test -s "$nlist"I; then 503115ffece8Smrg echo >> "$output_objdir/$my_dlsyms" "\ 503215ffece8Smrgstatic void lt_syminit(void) 503315ffece8Smrg{ 503415ffece8Smrg LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols; 503515ffece8Smrg for (; symbol->name; ++symbol) 503615ffece8Smrg {" 503715ffece8Smrg $SED 's/.*/ if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms" 503815ffece8Smrg echo >> "$output_objdir/$my_dlsyms" "\ 503915ffece8Smrg } 504015ffece8Smrg}" 504115ffece8Smrg fi 504215ffece8Smrg echo >> "$output_objdir/$my_dlsyms" "\ 50433e51e026SmrgLT_DLSYM_CONST lt_dlsymlist 5044a7b590b3Smrglt_${my_prefix}_LTX_preloaded_symbols[] = 504515ffece8Smrg{ {\"$my_originator\", (void *) 0}," 504615ffece8Smrg 504715ffece8Smrg if test -s "$nlist"I; then 504815ffece8Smrg echo >> "$output_objdir/$my_dlsyms" "\ 504915ffece8Smrg {\"@INIT@\", (void *) <_syminit}," 505015ffece8Smrg fi 5051943345d3Smrg 5052a7b590b3Smrg case $need_lib_prefix in 5053a7b590b3Smrg no) 5054a7b590b3Smrg eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" 5055a7b590b3Smrg ;; 5056a7b590b3Smrg *) 5057a7b590b3Smrg eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" 5058a7b590b3Smrg ;; 5059a7b590b3Smrg esac 50603e51e026Smrg echo >> "$output_objdir/$my_dlsyms" "\ 5061a7b590b3Smrg {0, (void *) 0} 5062a7b590b3Smrg}; 5063943345d3Smrg 5064a7b590b3Smrg/* This works around a problem in FreeBSD linker */ 5065a7b590b3Smrg#ifdef FREEBSD_WORKAROUND 5066a7b590b3Smrgstatic const void *lt_preloaded_setup() { 5067a7b590b3Smrg return lt_${my_prefix}_LTX_preloaded_symbols; 5068a7b590b3Smrg} 5069a7b590b3Smrg#endif 5070a7b590b3Smrg 5071a7b590b3Smrg#ifdef __cplusplus 5072a7b590b3Smrg} 5073a7b590b3Smrg#endif\ 5074a7b590b3Smrg" 5075a7b590b3Smrg } # !$opt_dry_run 5076a7b590b3Smrg 5077a7b590b3Smrg pic_flag_for_symtable= 5078a7b590b3Smrg case "$compile_command " in 5079a7b590b3Smrg *" -static "*) ;; 5080a7b590b3Smrg *) 5081a7b590b3Smrg case $host in 5082a7b590b3Smrg # compiling the symbol table file with pic_flag works around 5083a7b590b3Smrg # a FreeBSD bug that causes programs to crash when -lm is 5084a7b590b3Smrg # linked before any other PIC object. But we must not use 5085a7b590b3Smrg # pic_flag when linking with -static. The problem exists in 5086a7b590b3Smrg # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. 50873e51e026Smrg *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) 5088a7b590b3Smrg pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; 5089a7b590b3Smrg *-*-hpux*) 5090a7b590b3Smrg pic_flag_for_symtable=" $pic_flag" ;; 5091a7b590b3Smrg *) 509215ffece8Smrg $my_pic_p && pic_flag_for_symtable=" $pic_flag" 5093a7b590b3Smrg ;; 5094a7b590b3Smrg esac 5095a7b590b3Smrg ;; 5096a7b590b3Smrg esac 5097a7b590b3Smrg symtab_cflags= 5098a7b590b3Smrg for arg in $LTCFLAGS; do 5099a7b590b3Smrg case $arg in 5100a7b590b3Smrg -pie | -fpie | -fPIE) ;; 51013e51e026Smrg *) func_append symtab_cflags " $arg" ;; 5102a7b590b3Smrg esac 5103a7b590b3Smrg done 5104943345d3Smrg 5105a7b590b3Smrg # Now compile the dynamic symbol file. 5106a7b590b3Smrg func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' 5107943345d3Smrg 5108a7b590b3Smrg # Clean up the generated files. 510915ffece8Smrg func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"' 5110943345d3Smrg 5111a7b590b3Smrg # Transform the symbol file into the correct name. 511215ffece8Smrg symfileobj=$output_objdir/${my_outputname}S.$objext 5113a7b590b3Smrg case $host in 5114a7b590b3Smrg *cygwin* | *mingw* | *cegcc* ) 5115a7b590b3Smrg if test -f "$output_objdir/$my_outputname.def"; then 51163e51e026Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 51173e51e026Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 5118a7b590b3Smrg else 51193e51e026Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 51203e51e026Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 5121943345d3Smrg fi 5122a7b590b3Smrg ;; 5123a7b590b3Smrg *) 51243e51e026Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 51253e51e026Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 5126a7b590b3Smrg ;; 5127a7b590b3Smrg esac 5128a7b590b3Smrg ;; 5129a7b590b3Smrg *) 513015ffece8Smrg func_fatal_error "unknown suffix for '$my_dlsyms'" 5131a7b590b3Smrg ;; 5132a7b590b3Smrg esac 5133a7b590b3Smrg else 5134a7b590b3Smrg # We keep going just in case the user didn't refer to 5135a7b590b3Smrg # lt_preloaded_symbols. The linker will fail if global_symbol_pipe 5136a7b590b3Smrg # really was required. 5137943345d3Smrg 5138a7b590b3Smrg # Nullify the symbol file. 51393e51e026Smrg compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` 51403e51e026Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` 5141a7b590b3Smrg fi 5142a7b590b3Smrg} 5143943345d3Smrg 514415ffece8Smrg# func_cygming_gnu_implib_p ARG 514515ffece8Smrg# This predicate returns with zero status (TRUE) if 514615ffece8Smrg# ARG is a GNU/binutils-style import library. Returns 514715ffece8Smrg# with nonzero status (FALSE) otherwise. 514815ffece8Smrgfunc_cygming_gnu_implib_p () 514915ffece8Smrg{ 515015ffece8Smrg $debug_cmd 515115ffece8Smrg 515215ffece8Smrg func_to_tool_file "$1" func_convert_file_msys_to_w32 515315ffece8Smrg 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)$'` 515415ffece8Smrg test -n "$func_cygming_gnu_implib_tmp" 515515ffece8Smrg} 515615ffece8Smrg 515715ffece8Smrg# func_cygming_ms_implib_p ARG 515815ffece8Smrg# This predicate returns with zero status (TRUE) if 515915ffece8Smrg# ARG is an MS-style import library. Returns 516015ffece8Smrg# with nonzero status (FALSE) otherwise. 516115ffece8Smrgfunc_cygming_ms_implib_p () 516215ffece8Smrg{ 516315ffece8Smrg $debug_cmd 516415ffece8Smrg 516515ffece8Smrg func_to_tool_file "$1" func_convert_file_msys_to_w32 516615ffece8Smrg func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` 516715ffece8Smrg test -n "$func_cygming_ms_implib_tmp" 516815ffece8Smrg} 516915ffece8Smrg 5170a7b590b3Smrg# func_win32_libid arg 5171a7b590b3Smrg# return the library type of file 'arg' 5172a7b590b3Smrg# 5173a7b590b3Smrg# Need a lot of goo to handle *both* DLLs and import libs 5174a7b590b3Smrg# Has to be a shell function in order to 'eat' the argument 5175a7b590b3Smrg# that is supplied when $file_magic_command is called. 51763e51e026Smrg# Despite the name, also deal with 64 bit binaries. 5177a7b590b3Smrgfunc_win32_libid () 5178a7b590b3Smrg{ 517915ffece8Smrg $debug_cmd 518015ffece8Smrg 518115ffece8Smrg win32_libid_type=unknown 5182a7b590b3Smrg win32_fileres=`file -L $1 2>/dev/null` 5183a7b590b3Smrg case $win32_fileres in 5184a7b590b3Smrg *ar\ archive\ import\ library*) # definitely import 5185a7b590b3Smrg win32_libid_type="x86 archive import" 5186a7b590b3Smrg ;; 5187a7b590b3Smrg *ar\ archive*) # could be an import, or static 51883e51e026Smrg # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. 5189a7b590b3Smrg if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | 51903e51e026Smrg $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then 519115ffece8Smrg case $nm_interface in 519215ffece8Smrg "MS dumpbin") 519315ffece8Smrg if func_cygming_ms_implib_p "$1" || 519415ffece8Smrg func_cygming_gnu_implib_p "$1" 519515ffece8Smrg then 519615ffece8Smrg win32_nmres=import 519715ffece8Smrg else 519815ffece8Smrg win32_nmres= 519915ffece8Smrg fi 520015ffece8Smrg ;; 520115ffece8Smrg *) 520215ffece8Smrg func_to_tool_file "$1" func_convert_file_msys_to_w32 520315ffece8Smrg win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | 520415ffece8Smrg $SED -n -e ' 5205a7b590b3Smrg 1,100{ 5206a7b590b3Smrg / I /{ 520715ffece8Smrg s|.*|import| 5208a7b590b3Smrg p 5209a7b590b3Smrg q 5210a7b590b3Smrg } 5211a7b590b3Smrg }'` 521215ffece8Smrg ;; 521315ffece8Smrg esac 5214a7b590b3Smrg case $win32_nmres in 5215a7b590b3Smrg import*) win32_libid_type="x86 archive import";; 5216a7b590b3Smrg *) win32_libid_type="x86 archive static";; 5217a7b590b3Smrg esac 5218a7b590b3Smrg fi 5219a7b590b3Smrg ;; 5220a7b590b3Smrg *DLL*) 5221a7b590b3Smrg win32_libid_type="x86 DLL" 5222a7b590b3Smrg ;; 5223a7b590b3Smrg *executable*) # but shell scripts are "executable" too... 5224a7b590b3Smrg case $win32_fileres in 5225a7b590b3Smrg *MS\ Windows\ PE\ Intel*) 5226a7b590b3Smrg win32_libid_type="x86 DLL" 5227a7b590b3Smrg ;; 5228a7b590b3Smrg esac 5229a7b590b3Smrg ;; 5230a7b590b3Smrg esac 5231a7b590b3Smrg $ECHO "$win32_libid_type" 5232a7b590b3Smrg} 5233943345d3Smrg 52343e51e026Smrg# func_cygming_dll_for_implib ARG 52353e51e026Smrg# 52363e51e026Smrg# Platform-specific function to extract the 52373e51e026Smrg# name of the DLL associated with the specified 52383e51e026Smrg# import library ARG. 52393e51e026Smrg# Invoked by eval'ing the libtool variable 52403e51e026Smrg# $sharedlib_from_linklib_cmd 52413e51e026Smrg# Result is available in the variable 52423e51e026Smrg# $sharedlib_from_linklib_result 52433e51e026Smrgfunc_cygming_dll_for_implib () 52443e51e026Smrg{ 524515ffece8Smrg $debug_cmd 524615ffece8Smrg 52473e51e026Smrg sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` 52483e51e026Smrg} 52493e51e026Smrg 52503e51e026Smrg# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs 52513e51e026Smrg# 52523e51e026Smrg# The is the core of a fallback implementation of a 52533e51e026Smrg# platform-specific function to extract the name of the 52543e51e026Smrg# DLL associated with the specified import library LIBNAME. 52553e51e026Smrg# 52563e51e026Smrg# SECTION_NAME is either .idata$6 or .idata$7, depending 52573e51e026Smrg# on the platform and compiler that created the implib. 52583e51e026Smrg# 52593e51e026Smrg# Echos the name of the DLL associated with the 52603e51e026Smrg# specified import library. 52613e51e026Smrgfunc_cygming_dll_for_implib_fallback_core () 52623e51e026Smrg{ 526315ffece8Smrg $debug_cmd 526415ffece8Smrg 52653e51e026Smrg match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` 52663e51e026Smrg $OBJDUMP -s --section "$1" "$2" 2>/dev/null | 52673e51e026Smrg $SED '/^Contents of section '"$match_literal"':/{ 52683e51e026Smrg # Place marker at beginning of archive member dllname section 52693e51e026Smrg s/.*/====MARK====/ 52703e51e026Smrg p 52713e51e026Smrg d 52723e51e026Smrg } 52733e51e026Smrg # These lines can sometimes be longer than 43 characters, but 52743e51e026Smrg # are always uninteresting 52753e51e026Smrg /:[ ]*file format pe[i]\{,1\}-/d 52763e51e026Smrg /^In archive [^:]*:/d 52773e51e026Smrg # Ensure marker is printed 52783e51e026Smrg /^====MARK====/p 52793e51e026Smrg # Remove all lines with less than 43 characters 52803e51e026Smrg /^.\{43\}/!d 52813e51e026Smrg # From remaining lines, remove first 43 characters 52823e51e026Smrg s/^.\{43\}//' | 52833e51e026Smrg $SED -n ' 52843e51e026Smrg # Join marker and all lines until next marker into a single line 52853e51e026Smrg /^====MARK====/ b para 52863e51e026Smrg H 52873e51e026Smrg $ b para 52883e51e026Smrg b 52893e51e026Smrg :para 52903e51e026Smrg x 52913e51e026Smrg s/\n//g 52923e51e026Smrg # Remove the marker 52933e51e026Smrg s/^====MARK====// 52943e51e026Smrg # Remove trailing dots and whitespace 52953e51e026Smrg s/[\. \t]*$// 52963e51e026Smrg # Print 52973e51e026Smrg /./p' | 52983e51e026Smrg # we now have a list, one entry per line, of the stringified 52993e51e026Smrg # contents of the appropriate section of all members of the 530015ffece8Smrg # archive that possess that section. Heuristic: eliminate 530115ffece8Smrg # all those that have a first or second character that is 53023e51e026Smrg # a '.' (that is, objdump's representation of an unprintable 53033e51e026Smrg # character.) This should work for all archives with less than 53043e51e026Smrg # 0x302f exports -- but will fail for DLLs whose name actually 53053e51e026Smrg # begins with a literal '.' or a single character followed by 53063e51e026Smrg # a '.'. 53073e51e026Smrg # 53083e51e026Smrg # Of those that remain, print the first one. 53093e51e026Smrg $SED -e '/^\./d;/^.\./d;q' 53103e51e026Smrg} 53113e51e026Smrg 53123e51e026Smrg# func_cygming_dll_for_implib_fallback ARG 53133e51e026Smrg# Platform-specific function to extract the 53143e51e026Smrg# name of the DLL associated with the specified 53153e51e026Smrg# import library ARG. 53163e51e026Smrg# 53173e51e026Smrg# This fallback implementation is for use when $DLLTOOL 53183e51e026Smrg# does not support the --identify-strict option. 53193e51e026Smrg# Invoked by eval'ing the libtool variable 53203e51e026Smrg# $sharedlib_from_linklib_cmd 53213e51e026Smrg# Result is available in the variable 53223e51e026Smrg# $sharedlib_from_linklib_result 53233e51e026Smrgfunc_cygming_dll_for_implib_fallback () 53243e51e026Smrg{ 532515ffece8Smrg $debug_cmd 532615ffece8Smrg 532715ffece8Smrg if func_cygming_gnu_implib_p "$1"; then 53283e51e026Smrg # binutils import library 53293e51e026Smrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` 533015ffece8Smrg elif func_cygming_ms_implib_p "$1"; then 53313e51e026Smrg # ms-generated import library 53323e51e026Smrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` 53333e51e026Smrg else 53343e51e026Smrg # unknown 533515ffece8Smrg sharedlib_from_linklib_result= 53363e51e026Smrg fi 53373e51e026Smrg} 5338943345d3Smrg 5339943345d3Smrg 5340a7b590b3Smrg# func_extract_an_archive dir oldlib 5341a7b590b3Smrgfunc_extract_an_archive () 5342a7b590b3Smrg{ 534315ffece8Smrg $debug_cmd 534415ffece8Smrg 534515ffece8Smrg f_ex_an_ar_dir=$1; shift 534615ffece8Smrg f_ex_an_ar_oldlib=$1 534715ffece8Smrg if test yes = "$lock_old_archive_extraction"; then 53483e51e026Smrg lockfile=$f_ex_an_ar_oldlib.lock 53493e51e026Smrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 53503e51e026Smrg func_echo "Waiting for $lockfile to be removed" 53513e51e026Smrg sleep 2 53523e51e026Smrg done 53533e51e026Smrg fi 53543e51e026Smrg func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ 53553e51e026Smrg 'stat=$?; rm -f "$lockfile"; exit $stat' 535615ffece8Smrg if test yes = "$lock_old_archive_extraction"; then 53573e51e026Smrg $opt_dry_run || rm -f "$lockfile" 53583e51e026Smrg fi 5359a7b590b3Smrg if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then 5360a7b590b3Smrg : 5361a7b590b3Smrg else 5362a7b590b3Smrg func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 5363a7b590b3Smrg fi 5364a7b590b3Smrg} 5365943345d3Smrg 5366943345d3Smrg 5367a7b590b3Smrg# func_extract_archives gentop oldlib ... 5368a7b590b3Smrgfunc_extract_archives () 5369a7b590b3Smrg{ 537015ffece8Smrg $debug_cmd 537115ffece8Smrg 537215ffece8Smrg my_gentop=$1; shift 5373a7b590b3Smrg my_oldlibs=${1+"$@"} 537415ffece8Smrg my_oldobjs= 537515ffece8Smrg my_xlib= 537615ffece8Smrg my_xabs= 537715ffece8Smrg my_xdir= 5378943345d3Smrg 5379a7b590b3Smrg for my_xlib in $my_oldlibs; do 5380a7b590b3Smrg # Extract the objects. 5381a7b590b3Smrg case $my_xlib in 538215ffece8Smrg [\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;; 5383a7b590b3Smrg *) my_xabs=`pwd`"/$my_xlib" ;; 5384a7b590b3Smrg esac 5385a7b590b3Smrg func_basename "$my_xlib" 538615ffece8Smrg my_xlib=$func_basename_result 5387a7b590b3Smrg my_xlib_u=$my_xlib 5388a7b590b3Smrg while :; do 5389a7b590b3Smrg case " $extracted_archives " in 5390a7b590b3Smrg *" $my_xlib_u "*) 5391a7b590b3Smrg func_arith $extracted_serial + 1 5392a7b590b3Smrg extracted_serial=$func_arith_result 5393a7b590b3Smrg my_xlib_u=lt$extracted_serial-$my_xlib ;; 5394a7b590b3Smrg *) break ;; 5395a7b590b3Smrg esac 5396a7b590b3Smrg done 5397a7b590b3Smrg extracted_archives="$extracted_archives $my_xlib_u" 539815ffece8Smrg my_xdir=$my_gentop/$my_xlib_u 5399943345d3Smrg 5400a7b590b3Smrg func_mkdir_p "$my_xdir" 5401943345d3Smrg 5402a7b590b3Smrg case $host in 5403a7b590b3Smrg *-darwin*) 5404a7b590b3Smrg func_verbose "Extracting $my_xabs" 5405a7b590b3Smrg # Do not bother doing anything if just a dry run 5406a7b590b3Smrg $opt_dry_run || { 5407a7b590b3Smrg darwin_orig_dir=`pwd` 5408a7b590b3Smrg cd $my_xdir || exit $? 5409a7b590b3Smrg darwin_archive=$my_xabs 5410a7b590b3Smrg darwin_curdir=`pwd` 541115ffece8Smrg func_basename "$darwin_archive" 541215ffece8Smrg darwin_base_archive=$func_basename_result 5413a7b590b3Smrg darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` 5414a7b590b3Smrg if test -n "$darwin_arches"; then 5415a7b590b3Smrg darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` 5416a7b590b3Smrg darwin_arch= 5417a7b590b3Smrg func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" 541815ffece8Smrg for darwin_arch in $darwin_arches; do 541915ffece8Smrg func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch" 542015ffece8Smrg $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive" 542115ffece8Smrg cd "unfat-$$/$darwin_base_archive-$darwin_arch" 542215ffece8Smrg func_extract_an_archive "`pwd`" "$darwin_base_archive" 5423a7b590b3Smrg cd "$darwin_curdir" 542415ffece8Smrg $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" 5425a7b590b3Smrg done # $darwin_arches 5426a7b590b3Smrg ## Okay now we've a bunch of thin objects, gotta fatten them up :) 542715ffece8Smrg darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$sed_basename" | sort -u` 5428a7b590b3Smrg darwin_file= 5429a7b590b3Smrg darwin_files= 5430a7b590b3Smrg for darwin_file in $darwin_filelist; do 54313e51e026Smrg darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` 5432a7b590b3Smrg $LIPO -create -output "$darwin_file" $darwin_files 5433a7b590b3Smrg done # $darwin_filelist 5434a7b590b3Smrg $RM -rf unfat-$$ 5435a7b590b3Smrg cd "$darwin_orig_dir" 5436943345d3Smrg else 5437a7b590b3Smrg cd $darwin_orig_dir 5438a7b590b3Smrg func_extract_an_archive "$my_xdir" "$my_xabs" 5439a7b590b3Smrg fi # $darwin_arches 5440a7b590b3Smrg } # !$opt_dry_run 5441a7b590b3Smrg ;; 5442a7b590b3Smrg *) 5443a7b590b3Smrg func_extract_an_archive "$my_xdir" "$my_xabs" 5444a7b590b3Smrg ;; 5445a7b590b3Smrg esac 54463e51e026Smrg my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` 5447a7b590b3Smrg done 5448943345d3Smrg 544915ffece8Smrg func_extract_archives_result=$my_oldobjs 5450a7b590b3Smrg} 5451943345d3Smrg 5452943345d3Smrg 54533e51e026Smrg# func_emit_wrapper [arg=no] 54543e51e026Smrg# 54553e51e026Smrg# Emit a libtool wrapper script on stdout. 54563e51e026Smrg# Don't directly open a file because we may want to 54573e51e026Smrg# incorporate the script contents within a cygwin/mingw 54583e51e026Smrg# wrapper executable. Must ONLY be called from within 54593e51e026Smrg# func_mode_link because it depends on a number of variables 54603e51e026Smrg# set therein. 5461a7b590b3Smrg# 54623e51e026Smrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR 54633e51e026Smrg# variable will take. If 'yes', then the emitted script 546415ffece8Smrg# will assume that the directory where it is stored is 54653e51e026Smrg# the $objdir directory. This is a cygwin/mingw-specific 54663e51e026Smrg# behavior. 54673e51e026Smrgfunc_emit_wrapper () 5468a7b590b3Smrg{ 54693e51e026Smrg func_emit_wrapper_arg1=${1-no} 5470943345d3Smrg 5471a7b590b3Smrg $ECHO "\ 5472a7b590b3Smrg#! $SHELL 5473943345d3Smrg 5474a7b590b3Smrg# $output - temporary wrapper script for $objdir/$outputname 547515ffece8Smrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 5476a7b590b3Smrg# 5477a7b590b3Smrg# The $output program cannot be directly executed until all the libtool 5478a7b590b3Smrg# libraries that it depends on are installed. 5479a7b590b3Smrg# 5480a7b590b3Smrg# This wrapper script should never be moved out of the build directory. 5481a7b590b3Smrg# If it is, it will not operate correctly. 5482943345d3Smrg 5483a7b590b3Smrg# Sed substitution that helps us do robust quoting. It backslashifies 5484a7b590b3Smrg# metacharacters that are still active within double-quoted strings. 5485a7b590b3Smrgsed_quote_subst='$sed_quote_subst' 5486943345d3Smrg 5487a7b590b3Smrg# Be Bourne compatible 5488a7b590b3Smrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then 5489a7b590b3Smrg emulate sh 5490a7b590b3Smrg NULLCMD=: 5491a7b590b3Smrg # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which 5492a7b590b3Smrg # is contrary to our usage. Disable this feature. 5493a7b590b3Smrg alias -g '\${1+\"\$@\"}'='\"\$@\"' 5494a7b590b3Smrg setopt NO_GLOB_SUBST 5495a7b590b3Smrgelse 5496a7b590b3Smrg case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac 5497a7b590b3Smrgfi 5498a7b590b3SmrgBIN_SH=xpg4; export BIN_SH # for Tru64 5499a7b590b3SmrgDUALCASE=1; export DUALCASE # for MKS sh 5500943345d3Smrg 5501a7b590b3Smrg# The HP-UX ksh and POSIX shell print the target directory to stdout 5502a7b590b3Smrg# if CDPATH is set. 5503a7b590b3Smrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 5504943345d3Smrg 5505a7b590b3Smrgrelink_command=\"$relink_command\" 5506943345d3Smrg 5507a7b590b3Smrg# This environment variable determines our operation mode. 5508a7b590b3Smrgif test \"\$libtool_install_magic\" = \"$magic\"; then 5509a7b590b3Smrg # install mode needs the following variables: 5510a7b590b3Smrg generated_by_libtool_version='$macro_version' 5511a7b590b3Smrg notinst_deplibs='$notinst_deplibs' 5512a7b590b3Smrgelse 5513a7b590b3Smrg # When we are sourced in execute mode, \$file and \$ECHO are already set. 5514a7b590b3Smrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 55153e51e026Smrg file=\"\$0\"" 55163e51e026Smrg 551715ffece8Smrg func_quote_arg pretty "$ECHO" 551815ffece8Smrg qECHO=$func_quote_arg_result 55193e51e026Smrg $ECHO "\ 55203e51e026Smrg 55213e51e026Smrg# A function that is used when there is no print builtin or printf. 55223e51e026Smrgfunc_fallback_echo () 55233e51e026Smrg{ 55243e51e026Smrg eval 'cat <<_LTECHO_EOF 55253e51e026Smrg\$1 55263e51e026Smrg_LTECHO_EOF' 55273e51e026Smrg} 552815ffece8Smrg ECHO=$qECHO 55293e51e026Smrg fi 55303e51e026Smrg 55313e51e026Smrg# Very basic option parsing. These options are (a) specific to 55323e51e026Smrg# the libtool wrapper, (b) are identical between the wrapper 553315ffece8Smrg# /script/ and the wrapper /executable/ that is used only on 55343e51e026Smrg# windows platforms, and (c) all begin with the string "--lt-" 553515ffece8Smrg# (application programs are unlikely to have options that match 55363e51e026Smrg# this pattern). 55373e51e026Smrg# 55383e51e026Smrg# There are only two supported options: --lt-debug and 55393e51e026Smrg# --lt-dump-script. There is, deliberately, no --lt-help. 55403e51e026Smrg# 55413e51e026Smrg# The first argument to this parsing function should be the 55423e51e026Smrg# script's $0 value, followed by "$@". 55433e51e026Smrglt_option_debug= 55443e51e026Smrgfunc_parse_lt_options () 55453e51e026Smrg{ 55463e51e026Smrg lt_script_arg0=\$0 55473e51e026Smrg shift 55483e51e026Smrg for lt_opt 55493e51e026Smrg do 55503e51e026Smrg case \"\$lt_opt\" in 55513e51e026Smrg --lt-debug) lt_option_debug=1 ;; 55523e51e026Smrg --lt-dump-script) 55533e51e026Smrg lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` 55543e51e026Smrg test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. 55553e51e026Smrg lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` 55563e51e026Smrg cat \"\$lt_dump_D/\$lt_dump_F\" 55573e51e026Smrg exit 0 55583e51e026Smrg ;; 55593e51e026Smrg --lt-*) 55603e51e026Smrg \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 55613e51e026Smrg exit 1 55623e51e026Smrg ;; 55633e51e026Smrg esac 55643e51e026Smrg done 55653e51e026Smrg 55663e51e026Smrg # Print the debug banner immediately: 55673e51e026Smrg if test -n \"\$lt_option_debug\"; then 556815ffece8Smrg echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2 55693e51e026Smrg fi 55703e51e026Smrg} 55713e51e026Smrg 55723e51e026Smrg# Used when --lt-debug. Prints its arguments to stdout 55733e51e026Smrg# (redirection is the responsibility of the caller) 55743e51e026Smrgfunc_lt_dump_args () 55753e51e026Smrg{ 55763e51e026Smrg lt_dump_args_N=1; 55773e51e026Smrg for lt_arg 55783e51e026Smrg do 557915ffece8Smrg \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\" 55803e51e026Smrg lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` 55813e51e026Smrg done 55823e51e026Smrg} 55833e51e026Smrg 55843e51e026Smrg# Core function for launching the target application 55853e51e026Smrgfunc_exec_program_core () 55863e51e026Smrg{ 5587a7b590b3Smrg" 55883e51e026Smrg case $host in 55893e51e026Smrg # Backslashes separate directories on plain windows 55903e51e026Smrg *-*-mingw | *-*-os2* | *-cegcc*) 55913e51e026Smrg $ECHO "\ 55923e51e026Smrg if test -n \"\$lt_option_debug\"; then 559315ffece8Smrg \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2 55943e51e026Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 55953e51e026Smrg fi 55963e51e026Smrg exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} 55973e51e026Smrg" 55983e51e026Smrg ;; 55993e51e026Smrg 56003e51e026Smrg *) 56013e51e026Smrg $ECHO "\ 56023e51e026Smrg if test -n \"\$lt_option_debug\"; then 560315ffece8Smrg \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2 56043e51e026Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 56053e51e026Smrg fi 56063e51e026Smrg exec \"\$progdir/\$program\" \${1+\"\$@\"} 56073e51e026Smrg" 56083e51e026Smrg ;; 56093e51e026Smrg esac 56103e51e026Smrg $ECHO "\ 56113e51e026Smrg \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 56123e51e026Smrg exit 1 56133e51e026Smrg} 56143e51e026Smrg 56153e51e026Smrg# A function to encapsulate launching the target application 56163e51e026Smrg# Strips options in the --lt-* namespace from \$@ and 56173e51e026Smrg# launches target application with the remaining arguments. 56183e51e026Smrgfunc_exec_program () 56193e51e026Smrg{ 56203e51e026Smrg case \" \$* \" in 56213e51e026Smrg *\\ --lt-*) 56223e51e026Smrg for lt_wr_arg 56233e51e026Smrg do 56243e51e026Smrg case \$lt_wr_arg in 56253e51e026Smrg --lt-*) ;; 56263e51e026Smrg *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; 56273e51e026Smrg esac 56283e51e026Smrg shift 56293e51e026Smrg done ;; 56303e51e026Smrg esac 56313e51e026Smrg func_exec_program_core \${1+\"\$@\"} 56323e51e026Smrg} 56333e51e026Smrg 56343e51e026Smrg # Parse options 56353e51e026Smrg func_parse_lt_options \"\$0\" \${1+\"\$@\"} 5636943345d3Smrg 5637a7b590b3Smrg # Find the directory that this script lives in. 56383e51e026Smrg thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` 5639a7b590b3Smrg test \"x\$thisdir\" = \"x\$file\" && thisdir=. 5640943345d3Smrg 5641a7b590b3Smrg # Follow symbolic links until we get to the real thisdir. 56423e51e026Smrg file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` 5643a7b590b3Smrg while test -n \"\$file\"; do 56443e51e026Smrg destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` 5645943345d3Smrg 5646a7b590b3Smrg # If there was a directory component, then change thisdir. 5647a7b590b3Smrg if test \"x\$destdir\" != \"x\$file\"; then 5648a7b590b3Smrg case \"\$destdir\" in 5649a7b590b3Smrg [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; 5650a7b590b3Smrg *) thisdir=\"\$thisdir/\$destdir\" ;; 5651943345d3Smrg esac 5652a7b590b3Smrg fi 5653943345d3Smrg 56543e51e026Smrg file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` 56553e51e026Smrg file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` 5656a7b590b3Smrg done 5657943345d3Smrg 5658a7b590b3Smrg # Usually 'no', except on cygwin/mingw when embedded into 5659a7b590b3Smrg # the cwrapper. 56603e51e026Smrg WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 5661a7b590b3Smrg if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then 5662a7b590b3Smrg # special case for '.' 5663a7b590b3Smrg if test \"\$thisdir\" = \".\"; then 5664a7b590b3Smrg thisdir=\`pwd\` 5665a7b590b3Smrg fi 5666a7b590b3Smrg # remove .libs from thisdir 5667a7b590b3Smrg case \"\$thisdir\" in 56683e51e026Smrg *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; 5669a7b590b3Smrg $objdir ) thisdir=. ;; 5670a7b590b3Smrg esac 5671a7b590b3Smrg fi 5672a7b590b3Smrg 5673a7b590b3Smrg # Try to get the absolute directory name. 5674a7b590b3Smrg absdir=\`cd \"\$thisdir\" && pwd\` 5675a7b590b3Smrg test -n \"\$absdir\" && thisdir=\"\$absdir\" 5676a7b590b3Smrg" 5677a7b590b3Smrg 567815ffece8Smrg if test yes = "$fast_install"; then 5679a7b590b3Smrg $ECHO "\ 5680a7b590b3Smrg program=lt-'$outputname'$exeext 5681a7b590b3Smrg progdir=\"\$thisdir/$objdir\" 5682a7b590b3Smrg 5683a7b590b3Smrg if test ! -f \"\$progdir/\$program\" || 568415ffece8Smrg { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\ 5685a7b590b3Smrg test \"X\$file\" != \"X\$progdir/\$program\"; }; then 5686a7b590b3Smrg 5687a7b590b3Smrg file=\"\$\$-\$program\" 5688a7b590b3Smrg 5689a7b590b3Smrg if test ! -d \"\$progdir\"; then 5690a7b590b3Smrg $MKDIR \"\$progdir\" 5691a7b590b3Smrg else 5692a7b590b3Smrg $RM \"\$progdir/\$file\" 5693a7b590b3Smrg fi" 5694a7b590b3Smrg 5695a7b590b3Smrg $ECHO "\ 5696a7b590b3Smrg 5697a7b590b3Smrg # relink executable if necessary 5698a7b590b3Smrg if test -n \"\$relink_command\"; then 5699a7b590b3Smrg if relink_command_output=\`eval \$relink_command 2>&1\`; then : 5700a7b590b3Smrg else 570115ffece8Smrg \$ECHO \"\$relink_command_output\" >&2 5702a7b590b3Smrg $RM \"\$progdir/\$file\" 5703a7b590b3Smrg exit 1 5704943345d3Smrg fi 5705a7b590b3Smrg fi 5706943345d3Smrg 5707a7b590b3Smrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || 5708a7b590b3Smrg { $RM \"\$progdir/\$program\"; 5709a7b590b3Smrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } 5710a7b590b3Smrg $RM \"\$progdir/\$file\" 5711a7b590b3Smrg fi" 5712a7b590b3Smrg else 5713a7b590b3Smrg $ECHO "\ 5714a7b590b3Smrg program='$outputname' 5715a7b590b3Smrg progdir=\"\$thisdir/$objdir\" 5716a7b590b3Smrg" 5717943345d3Smrg fi 5718943345d3Smrg 5719a7b590b3Smrg $ECHO "\ 5720943345d3Smrg 5721a7b590b3Smrg if test -f \"\$progdir/\$program\"; then" 5722943345d3Smrg 57233e51e026Smrg # fixup the dll searchpath if we need to. 57243e51e026Smrg # 57253e51e026Smrg # Fix the DLL searchpath if we need to. Do this before prepending 57263e51e026Smrg # to shlibpath, because on Windows, both are PATH and uninstalled 57273e51e026Smrg # libraries must come first. 57283e51e026Smrg if test -n "$dllsearchpath"; then 57293e51e026Smrg $ECHO "\ 57303e51e026Smrg # Add the dll search path components to the executable PATH 57313e51e026Smrg PATH=$dllsearchpath:\$PATH 57323e51e026Smrg" 57333e51e026Smrg fi 57343e51e026Smrg 5735a7b590b3Smrg # Export our shlibpath_var if we have one. 573615ffece8Smrg if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 5737a7b590b3Smrg $ECHO "\ 5738a7b590b3Smrg # Add our own library path to $shlibpath_var 5739a7b590b3Smrg $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" 5740a7b590b3Smrg 5741a7b590b3Smrg # Some systems cannot cope with colon-terminated $shlibpath_var 5742a7b590b3Smrg # The second colon is a workaround for a bug in BeOS R4 sed 57433e51e026Smrg $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` 5744943345d3Smrg 5745a7b590b3Smrg export $shlibpath_var 5746a7b590b3Smrg" 5747943345d3Smrg fi 5748943345d3Smrg 5749a7b590b3Smrg $ECHO "\ 5750a7b590b3Smrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 5751a7b590b3Smrg # Run the actual program with our arguments. 57523e51e026Smrg func_exec_program \${1+\"\$@\"} 5753a7b590b3Smrg fi 5754a7b590b3Smrg else 5755a7b590b3Smrg # The program doesn't exist. 575615ffece8Smrg \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2 5757a7b590b3Smrg \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 57583e51e026Smrg \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 5759a7b590b3Smrg exit 1 5760a7b590b3Smrg fi 5761a7b590b3Smrgfi\ 5762a7b590b3Smrg" 5763a7b590b3Smrg} 5764943345d3Smrg 5765943345d3Smrg 5766a7b590b3Smrg# func_emit_cwrapperexe_src 5767a7b590b3Smrg# emit the source code for a wrapper executable on stdout 5768a7b590b3Smrg# Must ONLY be called from within func_mode_link because 5769a7b590b3Smrg# it depends on a number of variable set therein. 5770a7b590b3Smrgfunc_emit_cwrapperexe_src () 5771a7b590b3Smrg{ 5772a7b590b3Smrg cat <<EOF 5773943345d3Smrg 5774a7b590b3Smrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname 577515ffece8Smrg Generated by $PROGRAM (GNU $PACKAGE) $VERSION 5776943345d3Smrg 5777a7b590b3Smrg The $output program cannot be directly executed until all the libtool 5778a7b590b3Smrg libraries that it depends on are installed. 5779943345d3Smrg 5780a7b590b3Smrg This wrapper executable should never be moved out of the build directory. 5781a7b590b3Smrg If it is, it will not operate correctly. 5782a7b590b3Smrg*/ 5783a7b590b3SmrgEOF 5784a7b590b3Smrg cat <<"EOF" 57853e51e026Smrg#ifdef _MSC_VER 57863e51e026Smrg# define _CRT_SECURE_NO_DEPRECATE 1 57873e51e026Smrg#endif 5788a7b590b3Smrg#include <stdio.h> 5789a7b590b3Smrg#include <stdlib.h> 5790a7b590b3Smrg#ifdef _MSC_VER 5791a7b590b3Smrg# include <direct.h> 5792a7b590b3Smrg# include <process.h> 5793a7b590b3Smrg# include <io.h> 5794a7b590b3Smrg#else 5795a7b590b3Smrg# include <unistd.h> 5796a7b590b3Smrg# include <stdint.h> 5797a7b590b3Smrg# ifdef __CYGWIN__ 5798a7b590b3Smrg# include <io.h> 5799a7b590b3Smrg# endif 5800a7b590b3Smrg#endif 5801a7b590b3Smrg#include <malloc.h> 5802a7b590b3Smrg#include <stdarg.h> 5803a7b590b3Smrg#include <assert.h> 5804a7b590b3Smrg#include <string.h> 5805a7b590b3Smrg#include <ctype.h> 5806a7b590b3Smrg#include <errno.h> 5807a7b590b3Smrg#include <fcntl.h> 5808a7b590b3Smrg#include <sys/stat.h> 5809943345d3Smrg 581015ffece8Smrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 581115ffece8Smrg 58123e51e026Smrg/* declarations of non-ANSI functions */ 581315ffece8Smrg#if defined __MINGW32__ 58143e51e026Smrg# ifdef __STRICT_ANSI__ 58153e51e026Smrgint _putenv (const char *); 58163e51e026Smrg# endif 581715ffece8Smrg#elif defined __CYGWIN__ 58183e51e026Smrg# ifdef __STRICT_ANSI__ 58193e51e026Smrgchar *realpath (const char *, char *); 58203e51e026Smrgint putenv (char *); 58213e51e026Smrgint setenv (const char *, const char *, int); 58223e51e026Smrg# endif 582315ffece8Smrg/* #elif defined other_platform || defined ... */ 58243e51e026Smrg#endif 58253e51e026Smrg 58263e51e026Smrg/* portability defines, excluding path handling macros */ 582715ffece8Smrg#if defined _MSC_VER 58283e51e026Smrg# define setmode _setmode 58293e51e026Smrg# define stat _stat 58303e51e026Smrg# define chmod _chmod 58313e51e026Smrg# define getcwd _getcwd 58323e51e026Smrg# define putenv _putenv 58333e51e026Smrg# define S_IXUSR _S_IEXEC 583415ffece8Smrg#elif defined __MINGW32__ 58353e51e026Smrg# define setmode _setmode 58363e51e026Smrg# define stat _stat 58373e51e026Smrg# define chmod _chmod 58383e51e026Smrg# define getcwd _getcwd 58393e51e026Smrg# define putenv _putenv 584015ffece8Smrg#elif defined __CYGWIN__ 58413e51e026Smrg# define HAVE_SETENV 58423e51e026Smrg# define FOPEN_WB "wb" 584315ffece8Smrg/* #elif defined other platforms ... */ 58443e51e026Smrg#endif 58453e51e026Smrg 584615ffece8Smrg#if defined PATH_MAX 5847a7b590b3Smrg# define LT_PATHMAX PATH_MAX 584815ffece8Smrg#elif defined MAXPATHLEN 5849a7b590b3Smrg# define LT_PATHMAX MAXPATHLEN 5850a7b590b3Smrg#else 5851a7b590b3Smrg# define LT_PATHMAX 1024 5852a7b590b3Smrg#endif 5853943345d3Smrg 5854a7b590b3Smrg#ifndef S_IXOTH 5855a7b590b3Smrg# define S_IXOTH 0 5856a7b590b3Smrg#endif 5857a7b590b3Smrg#ifndef S_IXGRP 5858a7b590b3Smrg# define S_IXGRP 0 5859a7b590b3Smrg#endif 5860943345d3Smrg 58613e51e026Smrg/* path handling portability macros */ 5862a7b590b3Smrg#ifndef DIR_SEPARATOR 5863a7b590b3Smrg# define DIR_SEPARATOR '/' 5864a7b590b3Smrg# define PATH_SEPARATOR ':' 5865a7b590b3Smrg#endif 5866943345d3Smrg 586715ffece8Smrg#if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \ 586815ffece8Smrg defined __OS2__ 5869a7b590b3Smrg# define HAVE_DOS_BASED_FILE_SYSTEM 5870a7b590b3Smrg# define FOPEN_WB "wb" 5871a7b590b3Smrg# ifndef DIR_SEPARATOR_2 5872a7b590b3Smrg# define DIR_SEPARATOR_2 '\\' 5873a7b590b3Smrg# endif 5874a7b590b3Smrg# ifndef PATH_SEPARATOR_2 5875a7b590b3Smrg# define PATH_SEPARATOR_2 ';' 5876a7b590b3Smrg# endif 5877a7b590b3Smrg#endif 5878943345d3Smrg 5879a7b590b3Smrg#ifndef DIR_SEPARATOR_2 5880a7b590b3Smrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) 5881a7b590b3Smrg#else /* DIR_SEPARATOR_2 */ 5882a7b590b3Smrg# define IS_DIR_SEPARATOR(ch) \ 5883a7b590b3Smrg (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) 5884a7b590b3Smrg#endif /* DIR_SEPARATOR_2 */ 5885943345d3Smrg 5886a7b590b3Smrg#ifndef PATH_SEPARATOR_2 5887a7b590b3Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) 5888a7b590b3Smrg#else /* PATH_SEPARATOR_2 */ 5889a7b590b3Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) 5890a7b590b3Smrg#endif /* PATH_SEPARATOR_2 */ 5891943345d3Smrg 5892a7b590b3Smrg#ifndef FOPEN_WB 5893a7b590b3Smrg# define FOPEN_WB "w" 5894a7b590b3Smrg#endif 5895a7b590b3Smrg#ifndef _O_BINARY 5896a7b590b3Smrg# define _O_BINARY 0 5897a7b590b3Smrg#endif 5898943345d3Smrg 5899a7b590b3Smrg#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) 5900a7b590b3Smrg#define XFREE(stale) do { \ 590115ffece8Smrg if (stale) { free (stale); stale = 0; } \ 5902a7b590b3Smrg} while (0) 5903943345d3Smrg 590415ffece8Smrg#if defined LT_DEBUGWRAPPER 59053e51e026Smrgstatic int lt_debug = 1; 5906a7b590b3Smrg#else 59073e51e026Smrgstatic int lt_debug = 0; 5908a7b590b3Smrg#endif 5909943345d3Smrg 59103e51e026Smrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ 5911943345d3Smrg 5912a7b590b3Smrgvoid *xmalloc (size_t num); 5913a7b590b3Smrgchar *xstrdup (const char *string); 5914a7b590b3Smrgconst char *base_name (const char *name); 5915a7b590b3Smrgchar *find_executable (const char *wrapper); 5916a7b590b3Smrgchar *chase_symlinks (const char *pathspec); 5917a7b590b3Smrgint make_executable (const char *path); 5918a7b590b3Smrgint check_executable (const char *path); 5919a7b590b3Smrgchar *strendzap (char *str, const char *pat); 59203e51e026Smrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...); 59213e51e026Smrgvoid lt_fatal (const char *file, int line, const char *message, ...); 59223e51e026Smrgstatic const char *nonnull (const char *s); 59233e51e026Smrgstatic const char *nonempty (const char *s); 5924a7b590b3Smrgvoid lt_setenv (const char *name, const char *value); 5925a7b590b3Smrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end); 5926a7b590b3Smrgvoid lt_update_exe_path (const char *name, const char *value); 5927a7b590b3Smrgvoid lt_update_lib_path (const char *name, const char *value); 59283e51e026Smrgchar **prepare_spawn (char **argv); 59293e51e026Smrgvoid lt_dump_script (FILE *f); 5930a7b590b3SmrgEOF 5931a7b590b3Smrg 5932a7b590b3Smrg cat <<EOF 593315ffece8Smrg#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5) 593415ffece8Smrg# define externally_visible volatile 593515ffece8Smrg#else 593615ffece8Smrg# define externally_visible __attribute__((externally_visible)) volatile 593715ffece8Smrg#endif 593815ffece8Smrgexternally_visible const char * MAGIC_EXE = "$magic_exe"; 5939a7b590b3Smrgconst char * LIB_PATH_VARNAME = "$shlibpath_var"; 5940a7b590b3SmrgEOF 5941943345d3Smrg 594215ffece8Smrg if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 59433e51e026Smrg func_to_host_path "$temp_rpath" 5944a7b590b3Smrg cat <<EOF 59453e51e026Smrgconst char * LIB_PATH_VALUE = "$func_to_host_path_result"; 5946a7b590b3SmrgEOF 5947a7b590b3Smrg else 5948a7b590b3Smrg cat <<"EOF" 5949a7b590b3Smrgconst char * LIB_PATH_VALUE = ""; 5950a7b590b3SmrgEOF 5951943345d3Smrg fi 5952943345d3Smrg 5953a7b590b3Smrg if test -n "$dllsearchpath"; then 59543e51e026Smrg func_to_host_path "$dllsearchpath:" 5955a7b590b3Smrg cat <<EOF 5956a7b590b3Smrgconst char * EXE_PATH_VARNAME = "PATH"; 59573e51e026Smrgconst char * EXE_PATH_VALUE = "$func_to_host_path_result"; 5958943345d3SmrgEOF 5959943345d3Smrg else 5960a7b590b3Smrg cat <<"EOF" 5961a7b590b3Smrgconst char * EXE_PATH_VARNAME = ""; 5962a7b590b3Smrgconst char * EXE_PATH_VALUE = ""; 5963a7b590b3SmrgEOF 5964943345d3Smrg fi 5965a7b590b3Smrg 596615ffece8Smrg if test yes = "$fast_install"; then 5967a7b590b3Smrg cat <<EOF 5968a7b590b3Smrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */ 5969a7b590b3SmrgEOF 5970943345d3Smrg else 5971a7b590b3Smrg cat <<EOF 5972a7b590b3Smrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */ 5973a7b590b3SmrgEOF 5974943345d3Smrg fi 5975943345d3Smrg 5976943345d3Smrg 5977a7b590b3Smrg cat <<"EOF" 5978943345d3Smrg 5979a7b590b3Smrg#define LTWRAPPER_OPTION_PREFIX "--lt-" 5980943345d3Smrg 5981a7b590b3Smrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX; 5982a7b590b3Smrgstatic const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script"; 59833e51e026Smrgstatic const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug"; 5984943345d3Smrg 5985a7b590b3Smrgint 5986a7b590b3Smrgmain (int argc, char *argv[]) 5987a7b590b3Smrg{ 5988a7b590b3Smrg char **newargz; 5989a7b590b3Smrg int newargc; 5990a7b590b3Smrg char *tmp_pathspec; 5991a7b590b3Smrg char *actual_cwrapper_path; 5992a7b590b3Smrg char *actual_cwrapper_name; 5993a7b590b3Smrg char *target_name; 5994a7b590b3Smrg char *lt_argv_zero; 599515ffece8Smrg int rval = 127; 5996943345d3Smrg 5997a7b590b3Smrg int i; 5998943345d3Smrg 5999a7b590b3Smrg program_name = (char *) xstrdup (base_name (argv[0])); 600015ffece8Smrg newargz = XMALLOC (char *, (size_t) argc + 1); 6001943345d3Smrg 60023e51e026Smrg /* very simple arg parsing; don't want to rely on getopt 60033e51e026Smrg * also, copy all non cwrapper options to newargz, except 60043e51e026Smrg * argz[0], which is handled differently 60053e51e026Smrg */ 60063e51e026Smrg newargc=0; 6007a7b590b3Smrg for (i = 1; i < argc; i++) 6008a7b590b3Smrg { 600915ffece8Smrg if (STREQ (argv[i], dumpscript_opt)) 6010a7b590b3Smrg { 6011a7b590b3SmrgEOF 601215ffece8Smrg case $host in 6013a7b590b3Smrg *mingw* | *cygwin* ) 6014a7b590b3Smrg # make stdout use "unix" line endings 6015a7b590b3Smrg echo " setmode(1,_O_BINARY);" 6016a7b590b3Smrg ;; 6017a7b590b3Smrg esac 6018943345d3Smrg 6019a7b590b3Smrg cat <<"EOF" 60203e51e026Smrg lt_dump_script (stdout); 6021a7b590b3Smrg return 0; 6022a7b590b3Smrg } 602315ffece8Smrg if (STREQ (argv[i], debug_opt)) 60243e51e026Smrg { 60253e51e026Smrg lt_debug = 1; 60263e51e026Smrg continue; 60273e51e026Smrg } 602815ffece8Smrg if (STREQ (argv[i], ltwrapper_option_prefix)) 60293e51e026Smrg { 60303e51e026Smrg /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX 60313e51e026Smrg namespace, but it is not one of the ones we know about and 60323e51e026Smrg have already dealt with, above (inluding dump-script), then 60333e51e026Smrg report an error. Otherwise, targets might begin to believe 60343e51e026Smrg they are allowed to use options in the LTWRAPPER_OPTION_PREFIX 60353e51e026Smrg namespace. The first time any user complains about this, we'll 60363e51e026Smrg need to make LTWRAPPER_OPTION_PREFIX a configure-time option 60373e51e026Smrg or a configure.ac-settable value. 60383e51e026Smrg */ 60393e51e026Smrg lt_fatal (__FILE__, __LINE__, 60403e51e026Smrg "unrecognized %s option: '%s'", 60413e51e026Smrg ltwrapper_option_prefix, argv[i]); 60423e51e026Smrg } 60433e51e026Smrg /* otherwise ... */ 60443e51e026Smrg newargz[++newargc] = xstrdup (argv[i]); 6045a7b590b3Smrg } 60463e51e026Smrg newargz[++newargc] = NULL; 60473e51e026Smrg 60483e51e026SmrgEOF 60493e51e026Smrg cat <<EOF 60503e51e026Smrg /* The GNU banner must be the first non-error debug message */ 605115ffece8Smrg lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE) $VERSION\n"); 60523e51e026SmrgEOF 60533e51e026Smrg cat <<"EOF" 60543e51e026Smrg lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]); 60553e51e026Smrg lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name); 6056943345d3Smrg 6057a7b590b3Smrg tmp_pathspec = find_executable (argv[0]); 6058a7b590b3Smrg if (tmp_pathspec == NULL) 60593e51e026Smrg lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]); 60603e51e026Smrg lt_debugprintf (__FILE__, __LINE__, 60613e51e026Smrg "(main) found exe (before symlink chase) at: %s\n", 60623e51e026Smrg tmp_pathspec); 6063a7b590b3Smrg 6064a7b590b3Smrg actual_cwrapper_path = chase_symlinks (tmp_pathspec); 60653e51e026Smrg lt_debugprintf (__FILE__, __LINE__, 60663e51e026Smrg "(main) found exe (after symlink chase) at: %s\n", 60673e51e026Smrg actual_cwrapper_path); 6068a7b590b3Smrg XFREE (tmp_pathspec); 6069a7b590b3Smrg 60703e51e026Smrg actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path)); 6071a7b590b3Smrg strendzap (actual_cwrapper_path, actual_cwrapper_name); 6072a7b590b3Smrg 6073a7b590b3Smrg /* wrapper name transforms */ 6074a7b590b3Smrg strendzap (actual_cwrapper_name, ".exe"); 6075a7b590b3Smrg tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1); 6076a7b590b3Smrg XFREE (actual_cwrapper_name); 6077a7b590b3Smrg actual_cwrapper_name = tmp_pathspec; 6078a7b590b3Smrg tmp_pathspec = 0; 6079a7b590b3Smrg 6080a7b590b3Smrg /* target_name transforms -- use actual target program name; might have lt- prefix */ 6081a7b590b3Smrg target_name = xstrdup (base_name (TARGET_PROGRAM_NAME)); 6082a7b590b3Smrg strendzap (target_name, ".exe"); 6083a7b590b3Smrg tmp_pathspec = lt_extend_str (target_name, ".exe", 1); 6084a7b590b3Smrg XFREE (target_name); 6085a7b590b3Smrg target_name = tmp_pathspec; 6086a7b590b3Smrg tmp_pathspec = 0; 6087a7b590b3Smrg 60883e51e026Smrg lt_debugprintf (__FILE__, __LINE__, 60893e51e026Smrg "(main) libtool target name: %s\n", 60903e51e026Smrg target_name); 6091a7b590b3SmrgEOF 6092943345d3Smrg 6093a7b590b3Smrg cat <<EOF 6094a7b590b3Smrg newargz[0] = 6095a7b590b3Smrg XMALLOC (char, (strlen (actual_cwrapper_path) + 6096a7b590b3Smrg strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1)); 6097a7b590b3Smrg strcpy (newargz[0], actual_cwrapper_path); 6098a7b590b3Smrg strcat (newargz[0], "$objdir"); 6099a7b590b3Smrg strcat (newargz[0], "/"); 6100a7b590b3SmrgEOF 6101943345d3Smrg 6102a7b590b3Smrg cat <<"EOF" 6103a7b590b3Smrg /* stop here, and copy so we don't have to do this twice */ 6104a7b590b3Smrg tmp_pathspec = xstrdup (newargz[0]); 6105943345d3Smrg 6106a7b590b3Smrg /* do NOT want the lt- prefix here, so use actual_cwrapper_name */ 6107a7b590b3Smrg strcat (newargz[0], actual_cwrapper_name); 6108943345d3Smrg 6109a7b590b3Smrg /* DO want the lt- prefix here if it exists, so use target_name */ 6110a7b590b3Smrg lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1); 6111a7b590b3Smrg XFREE (tmp_pathspec); 6112a7b590b3Smrg tmp_pathspec = NULL; 6113a7b590b3SmrgEOF 6114943345d3Smrg 6115a7b590b3Smrg case $host_os in 6116a7b590b3Smrg mingw*) 6117a7b590b3Smrg cat <<"EOF" 6118a7b590b3Smrg { 6119a7b590b3Smrg char* p; 6120a7b590b3Smrg while ((p = strchr (newargz[0], '\\')) != NULL) 6121a7b590b3Smrg { 6122a7b590b3Smrg *p = '/'; 6123a7b590b3Smrg } 6124a7b590b3Smrg while ((p = strchr (lt_argv_zero, '\\')) != NULL) 6125a7b590b3Smrg { 6126a7b590b3Smrg *p = '/'; 6127a7b590b3Smrg } 6128a7b590b3Smrg } 6129a7b590b3SmrgEOF 6130a7b590b3Smrg ;; 6131a7b590b3Smrg esac 6132943345d3Smrg 6133a7b590b3Smrg cat <<"EOF" 6134a7b590b3Smrg XFREE (target_name); 6135a7b590b3Smrg XFREE (actual_cwrapper_path); 6136a7b590b3Smrg XFREE (actual_cwrapper_name); 6137943345d3Smrg 6138a7b590b3Smrg lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */ 6139a7b590b3Smrg lt_setenv ("DUALCASE", "1"); /* for MSK sh */ 61403e51e026Smrg /* Update the DLL searchpath. EXE_PATH_VALUE ($dllsearchpath) must 61413e51e026Smrg be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath) 61423e51e026Smrg because on Windows, both *_VARNAMEs are PATH but uninstalled 61433e51e026Smrg libraries must come first. */ 6144a7b590b3Smrg lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE); 61453e51e026Smrg lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE); 6146943345d3Smrg 61473e51e026Smrg lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n", 61483e51e026Smrg nonnull (lt_argv_zero)); 6149a7b590b3Smrg for (i = 0; i < newargc; i++) 6150a7b590b3Smrg { 61513e51e026Smrg lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n", 61523e51e026Smrg i, nonnull (newargz[i])); 6153a7b590b3Smrg } 6154943345d3Smrg 6155a7b590b3SmrgEOF 6156943345d3Smrg 6157a7b590b3Smrg case $host_os in 6158a7b590b3Smrg mingw*) 6159a7b590b3Smrg cat <<"EOF" 6160a7b590b3Smrg /* execv doesn't actually work on mingw as expected on unix */ 61613e51e026Smrg newargz = prepare_spawn (newargz); 616215ffece8Smrg rval = (int) _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz); 6163a7b590b3Smrg if (rval == -1) 6164a7b590b3Smrg { 6165a7b590b3Smrg /* failed to start process */ 61663e51e026Smrg lt_debugprintf (__FILE__, __LINE__, 61673e51e026Smrg "(main) failed to launch target \"%s\": %s\n", 61683e51e026Smrg lt_argv_zero, nonnull (strerror (errno))); 6169a7b590b3Smrg return 127; 6170a7b590b3Smrg } 6171a7b590b3Smrg return rval; 6172a7b590b3SmrgEOF 6173a7b590b3Smrg ;; 6174a7b590b3Smrg *) 6175a7b590b3Smrg cat <<"EOF" 6176a7b590b3Smrg execv (lt_argv_zero, newargz); 6177a7b590b3Smrg return rval; /* =127, but avoids unused variable warning */ 6178a7b590b3SmrgEOF 6179a7b590b3Smrg ;; 6180a7b590b3Smrg esac 6181943345d3Smrg 6182a7b590b3Smrg cat <<"EOF" 6183a7b590b3Smrg} 6184943345d3Smrg 6185a7b590b3Smrgvoid * 6186a7b590b3Smrgxmalloc (size_t num) 6187a7b590b3Smrg{ 6188a7b590b3Smrg void *p = (void *) malloc (num); 6189a7b590b3Smrg if (!p) 61903e51e026Smrg lt_fatal (__FILE__, __LINE__, "memory exhausted"); 6191943345d3Smrg 6192a7b590b3Smrg return p; 6193a7b590b3Smrg} 6194943345d3Smrg 6195a7b590b3Smrgchar * 6196a7b590b3Smrgxstrdup (const char *string) 6197a7b590b3Smrg{ 6198a7b590b3Smrg return string ? strcpy ((char *) xmalloc (strlen (string) + 1), 6199a7b590b3Smrg string) : NULL; 6200a7b590b3Smrg} 6201943345d3Smrg 6202a7b590b3Smrgconst char * 6203a7b590b3Smrgbase_name (const char *name) 6204a7b590b3Smrg{ 6205a7b590b3Smrg const char *base; 6206943345d3Smrg 620715ffece8Smrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 6208a7b590b3Smrg /* Skip over the disk name in MSDOS pathnames. */ 6209a7b590b3Smrg if (isalpha ((unsigned char) name[0]) && name[1] == ':') 6210a7b590b3Smrg name += 2; 6211a7b590b3Smrg#endif 6212943345d3Smrg 6213a7b590b3Smrg for (base = name; *name; name++) 6214a7b590b3Smrg if (IS_DIR_SEPARATOR (*name)) 6215a7b590b3Smrg base = name + 1; 6216a7b590b3Smrg return base; 6217a7b590b3Smrg} 6218943345d3Smrg 6219a7b590b3Smrgint 6220a7b590b3Smrgcheck_executable (const char *path) 6221a7b590b3Smrg{ 6222a7b590b3Smrg struct stat st; 6223943345d3Smrg 62243e51e026Smrg lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n", 62253e51e026Smrg nonempty (path)); 6226a7b590b3Smrg if ((!path) || (!*path)) 6227a7b590b3Smrg return 0; 6228943345d3Smrg 6229a7b590b3Smrg if ((stat (path, &st) >= 0) 6230a7b590b3Smrg && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) 6231a7b590b3Smrg return 1; 6232a7b590b3Smrg else 6233a7b590b3Smrg return 0; 6234a7b590b3Smrg} 6235943345d3Smrg 6236a7b590b3Smrgint 6237a7b590b3Smrgmake_executable (const char *path) 6238a7b590b3Smrg{ 6239a7b590b3Smrg int rval = 0; 6240a7b590b3Smrg struct stat st; 6241943345d3Smrg 62423e51e026Smrg lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", 62433e51e026Smrg nonempty (path)); 6244a7b590b3Smrg if ((!path) || (!*path)) 6245a7b590b3Smrg return 0; 6246943345d3Smrg 6247a7b590b3Smrg if (stat (path, &st) >= 0) 6248a7b590b3Smrg { 6249a7b590b3Smrg rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); 6250a7b590b3Smrg } 6251a7b590b3Smrg return rval; 6252a7b590b3Smrg} 6253943345d3Smrg 6254a7b590b3Smrg/* Searches for the full path of the wrapper. Returns 6255a7b590b3Smrg newly allocated full path name if found, NULL otherwise 6256a7b590b3Smrg Does not chase symlinks, even on platforms that support them. 6257a7b590b3Smrg*/ 6258a7b590b3Smrgchar * 6259a7b590b3Smrgfind_executable (const char *wrapper) 6260a7b590b3Smrg{ 6261a7b590b3Smrg int has_slash = 0; 6262a7b590b3Smrg const char *p; 6263a7b590b3Smrg const char *p_next; 6264a7b590b3Smrg /* static buffer for getcwd */ 6265a7b590b3Smrg char tmp[LT_PATHMAX + 1]; 626615ffece8Smrg size_t tmp_len; 6267a7b590b3Smrg char *concat_name; 6268943345d3Smrg 62693e51e026Smrg lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", 62703e51e026Smrg nonempty (wrapper)); 6271943345d3Smrg 6272a7b590b3Smrg if ((wrapper == NULL) || (*wrapper == '\0')) 6273a7b590b3Smrg return NULL; 6274943345d3Smrg 6275a7b590b3Smrg /* Absolute path? */ 627615ffece8Smrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 6277a7b590b3Smrg if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') 6278a7b590b3Smrg { 6279a7b590b3Smrg concat_name = xstrdup (wrapper); 6280a7b590b3Smrg if (check_executable (concat_name)) 6281a7b590b3Smrg return concat_name; 6282a7b590b3Smrg XFREE (concat_name); 6283a7b590b3Smrg } 6284a7b590b3Smrg else 6285a7b590b3Smrg { 6286a7b590b3Smrg#endif 6287a7b590b3Smrg if (IS_DIR_SEPARATOR (wrapper[0])) 6288a7b590b3Smrg { 6289a7b590b3Smrg concat_name = xstrdup (wrapper); 6290a7b590b3Smrg if (check_executable (concat_name)) 6291a7b590b3Smrg return concat_name; 6292a7b590b3Smrg XFREE (concat_name); 6293a7b590b3Smrg } 629415ffece8Smrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 6295a7b590b3Smrg } 6296a7b590b3Smrg#endif 6297943345d3Smrg 6298a7b590b3Smrg for (p = wrapper; *p; p++) 6299a7b590b3Smrg if (*p == '/') 6300a7b590b3Smrg { 6301a7b590b3Smrg has_slash = 1; 6302a7b590b3Smrg break; 6303a7b590b3Smrg } 6304a7b590b3Smrg if (!has_slash) 6305a7b590b3Smrg { 6306a7b590b3Smrg /* no slashes; search PATH */ 6307a7b590b3Smrg const char *path = getenv ("PATH"); 6308a7b590b3Smrg if (path != NULL) 6309a7b590b3Smrg { 6310a7b590b3Smrg for (p = path; *p; p = p_next) 6311a7b590b3Smrg { 6312a7b590b3Smrg const char *q; 6313a7b590b3Smrg size_t p_len; 6314a7b590b3Smrg for (q = p; *q; q++) 6315a7b590b3Smrg if (IS_PATH_SEPARATOR (*q)) 6316a7b590b3Smrg break; 631715ffece8Smrg p_len = (size_t) (q - p); 6318a7b590b3Smrg p_next = (*q == '\0' ? q : q + 1); 6319a7b590b3Smrg if (p_len == 0) 6320a7b590b3Smrg { 6321a7b590b3Smrg /* empty path: current directory */ 6322a7b590b3Smrg if (getcwd (tmp, LT_PATHMAX) == NULL) 63233e51e026Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 63243e51e026Smrg nonnull (strerror (errno))); 6325a7b590b3Smrg tmp_len = strlen (tmp); 6326a7b590b3Smrg concat_name = 6327a7b590b3Smrg XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 6328a7b590b3Smrg memcpy (concat_name, tmp, tmp_len); 6329a7b590b3Smrg concat_name[tmp_len] = '/'; 6330a7b590b3Smrg strcpy (concat_name + tmp_len + 1, wrapper); 6331a7b590b3Smrg } 6332a7b590b3Smrg else 6333a7b590b3Smrg { 6334a7b590b3Smrg concat_name = 6335a7b590b3Smrg XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); 6336a7b590b3Smrg memcpy (concat_name, p, p_len); 6337a7b590b3Smrg concat_name[p_len] = '/'; 6338a7b590b3Smrg strcpy (concat_name + p_len + 1, wrapper); 6339a7b590b3Smrg } 6340a7b590b3Smrg if (check_executable (concat_name)) 6341a7b590b3Smrg return concat_name; 6342a7b590b3Smrg XFREE (concat_name); 6343a7b590b3Smrg } 6344a7b590b3Smrg } 6345a7b590b3Smrg /* not found in PATH; assume curdir */ 6346a7b590b3Smrg } 6347a7b590b3Smrg /* Relative path | not found in path: prepend cwd */ 6348a7b590b3Smrg if (getcwd (tmp, LT_PATHMAX) == NULL) 63493e51e026Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 63503e51e026Smrg nonnull (strerror (errno))); 6351a7b590b3Smrg tmp_len = strlen (tmp); 6352a7b590b3Smrg concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 6353a7b590b3Smrg memcpy (concat_name, tmp, tmp_len); 6354a7b590b3Smrg concat_name[tmp_len] = '/'; 6355a7b590b3Smrg strcpy (concat_name + tmp_len + 1, wrapper); 6356943345d3Smrg 6357a7b590b3Smrg if (check_executable (concat_name)) 6358a7b590b3Smrg return concat_name; 6359a7b590b3Smrg XFREE (concat_name); 6360a7b590b3Smrg return NULL; 6361a7b590b3Smrg} 6362943345d3Smrg 6363a7b590b3Smrgchar * 6364a7b590b3Smrgchase_symlinks (const char *pathspec) 6365a7b590b3Smrg{ 6366a7b590b3Smrg#ifndef S_ISLNK 6367a7b590b3Smrg return xstrdup (pathspec); 6368a7b590b3Smrg#else 6369a7b590b3Smrg char buf[LT_PATHMAX]; 6370a7b590b3Smrg struct stat s; 6371a7b590b3Smrg char *tmp_pathspec = xstrdup (pathspec); 6372a7b590b3Smrg char *p; 6373a7b590b3Smrg int has_symlinks = 0; 6374a7b590b3Smrg while (strlen (tmp_pathspec) && !has_symlinks) 6375a7b590b3Smrg { 63763e51e026Smrg lt_debugprintf (__FILE__, __LINE__, 63773e51e026Smrg "checking path component for symlinks: %s\n", 63783e51e026Smrg tmp_pathspec); 6379a7b590b3Smrg if (lstat (tmp_pathspec, &s) == 0) 6380a7b590b3Smrg { 6381a7b590b3Smrg if (S_ISLNK (s.st_mode) != 0) 6382a7b590b3Smrg { 6383a7b590b3Smrg has_symlinks = 1; 6384a7b590b3Smrg break; 6385a7b590b3Smrg } 6386943345d3Smrg 6387a7b590b3Smrg /* search backwards for last DIR_SEPARATOR */ 6388a7b590b3Smrg p = tmp_pathspec + strlen (tmp_pathspec) - 1; 6389a7b590b3Smrg while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 6390a7b590b3Smrg p--; 6391a7b590b3Smrg if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 6392a7b590b3Smrg { 6393a7b590b3Smrg /* no more DIR_SEPARATORS left */ 6394a7b590b3Smrg break; 6395a7b590b3Smrg } 6396a7b590b3Smrg *p = '\0'; 6397a7b590b3Smrg } 6398a7b590b3Smrg else 6399a7b590b3Smrg { 64003e51e026Smrg lt_fatal (__FILE__, __LINE__, 64013e51e026Smrg "error accessing file \"%s\": %s", 64023e51e026Smrg tmp_pathspec, nonnull (strerror (errno))); 6403a7b590b3Smrg } 6404a7b590b3Smrg } 6405a7b590b3Smrg XFREE (tmp_pathspec); 6406943345d3Smrg 6407a7b590b3Smrg if (!has_symlinks) 6408a7b590b3Smrg { 6409a7b590b3Smrg return xstrdup (pathspec); 6410a7b590b3Smrg } 6411943345d3Smrg 6412a7b590b3Smrg tmp_pathspec = realpath (pathspec, buf); 6413a7b590b3Smrg if (tmp_pathspec == 0) 6414a7b590b3Smrg { 64153e51e026Smrg lt_fatal (__FILE__, __LINE__, 64163e51e026Smrg "could not follow symlinks for %s", pathspec); 6417a7b590b3Smrg } 6418a7b590b3Smrg return xstrdup (tmp_pathspec); 6419a7b590b3Smrg#endif 6420a7b590b3Smrg} 6421943345d3Smrg 6422a7b590b3Smrgchar * 6423a7b590b3Smrgstrendzap (char *str, const char *pat) 6424a7b590b3Smrg{ 6425a7b590b3Smrg size_t len, patlen; 6426943345d3Smrg 6427a7b590b3Smrg assert (str != NULL); 6428a7b590b3Smrg assert (pat != NULL); 6429943345d3Smrg 6430a7b590b3Smrg len = strlen (str); 6431a7b590b3Smrg patlen = strlen (pat); 6432943345d3Smrg 6433a7b590b3Smrg if (patlen <= len) 6434a7b590b3Smrg { 6435a7b590b3Smrg str += len - patlen; 643615ffece8Smrg if (STREQ (str, pat)) 6437a7b590b3Smrg *str = '\0'; 6438a7b590b3Smrg } 6439a7b590b3Smrg return str; 6440a7b590b3Smrg} 6441943345d3Smrg 64423e51e026Smrgvoid 64433e51e026Smrglt_debugprintf (const char *file, int line, const char *fmt, ...) 64443e51e026Smrg{ 64453e51e026Smrg va_list args; 64463e51e026Smrg if (lt_debug) 64473e51e026Smrg { 64483e51e026Smrg (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); 64493e51e026Smrg va_start (args, fmt); 64503e51e026Smrg (void) vfprintf (stderr, fmt, args); 64513e51e026Smrg va_end (args); 64523e51e026Smrg } 64533e51e026Smrg} 64543e51e026Smrg 6455a7b590b3Smrgstatic void 64563e51e026Smrglt_error_core (int exit_status, const char *file, 64573e51e026Smrg int line, const char *mode, 6458a7b590b3Smrg const char *message, va_list ap) 6459a7b590b3Smrg{ 64603e51e026Smrg fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); 6461a7b590b3Smrg vfprintf (stderr, message, ap); 6462a7b590b3Smrg fprintf (stderr, ".\n"); 6463943345d3Smrg 6464a7b590b3Smrg if (exit_status >= 0) 6465a7b590b3Smrg exit (exit_status); 6466a7b590b3Smrg} 6467943345d3Smrg 6468a7b590b3Smrgvoid 64693e51e026Smrglt_fatal (const char *file, int line, const char *message, ...) 6470a7b590b3Smrg{ 6471a7b590b3Smrg va_list ap; 6472a7b590b3Smrg va_start (ap, message); 64733e51e026Smrg lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); 6474a7b590b3Smrg va_end (ap); 6475a7b590b3Smrg} 6476943345d3Smrg 64773e51e026Smrgstatic const char * 64783e51e026Smrgnonnull (const char *s) 64793e51e026Smrg{ 64803e51e026Smrg return s ? s : "(null)"; 64813e51e026Smrg} 64823e51e026Smrg 64833e51e026Smrgstatic const char * 64843e51e026Smrgnonempty (const char *s) 64853e51e026Smrg{ 64863e51e026Smrg return (s && !*s) ? "(empty)" : nonnull (s); 64873e51e026Smrg} 64883e51e026Smrg 6489a7b590b3Smrgvoid 6490a7b590b3Smrglt_setenv (const char *name, const char *value) 6491a7b590b3Smrg{ 64923e51e026Smrg lt_debugprintf (__FILE__, __LINE__, 64933e51e026Smrg "(lt_setenv) setting '%s' to '%s'\n", 64943e51e026Smrg nonnull (name), nonnull (value)); 6495a7b590b3Smrg { 6496a7b590b3Smrg#ifdef HAVE_SETENV 6497a7b590b3Smrg /* always make a copy, for consistency with !HAVE_SETENV */ 6498a7b590b3Smrg char *str = xstrdup (value); 6499a7b590b3Smrg setenv (name, str, 1); 6500a7b590b3Smrg#else 650115ffece8Smrg size_t len = strlen (name) + 1 + strlen (value) + 1; 6502a7b590b3Smrg char *str = XMALLOC (char, len); 6503a7b590b3Smrg sprintf (str, "%s=%s", name, value); 6504a7b590b3Smrg if (putenv (str) != EXIT_SUCCESS) 6505a7b590b3Smrg { 6506a7b590b3Smrg XFREE (str); 6507a7b590b3Smrg } 6508a7b590b3Smrg#endif 6509a7b590b3Smrg } 6510a7b590b3Smrg} 6511943345d3Smrg 6512a7b590b3Smrgchar * 6513a7b590b3Smrglt_extend_str (const char *orig_value, const char *add, int to_end) 6514a7b590b3Smrg{ 6515a7b590b3Smrg char *new_value; 6516a7b590b3Smrg if (orig_value && *orig_value) 6517a7b590b3Smrg { 651815ffece8Smrg size_t orig_value_len = strlen (orig_value); 651915ffece8Smrg size_t add_len = strlen (add); 6520a7b590b3Smrg new_value = XMALLOC (char, add_len + orig_value_len + 1); 6521a7b590b3Smrg if (to_end) 6522a7b590b3Smrg { 6523a7b590b3Smrg strcpy (new_value, orig_value); 6524a7b590b3Smrg strcpy (new_value + orig_value_len, add); 6525a7b590b3Smrg } 6526a7b590b3Smrg else 6527a7b590b3Smrg { 6528a7b590b3Smrg strcpy (new_value, add); 6529a7b590b3Smrg strcpy (new_value + add_len, orig_value); 6530a7b590b3Smrg } 6531a7b590b3Smrg } 6532a7b590b3Smrg else 6533a7b590b3Smrg { 6534a7b590b3Smrg new_value = xstrdup (add); 6535a7b590b3Smrg } 6536a7b590b3Smrg return new_value; 6537a7b590b3Smrg} 6538943345d3Smrg 6539a7b590b3Smrgvoid 6540a7b590b3Smrglt_update_exe_path (const char *name, const char *value) 6541a7b590b3Smrg{ 65423e51e026Smrg lt_debugprintf (__FILE__, __LINE__, 65433e51e026Smrg "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", 65443e51e026Smrg nonnull (name), nonnull (value)); 6545943345d3Smrg 6546a7b590b3Smrg if (name && *name && value && *value) 6547a7b590b3Smrg { 6548a7b590b3Smrg char *new_value = lt_extend_str (getenv (name), value, 0); 6549a7b590b3Smrg /* some systems can't cope with a ':'-terminated path #' */ 655015ffece8Smrg size_t len = strlen (new_value); 655115ffece8Smrg while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1])) 6552a7b590b3Smrg { 655315ffece8Smrg new_value[--len] = '\0'; 6554a7b590b3Smrg } 6555a7b590b3Smrg lt_setenv (name, new_value); 6556a7b590b3Smrg XFREE (new_value); 6557a7b590b3Smrg } 6558a7b590b3Smrg} 6559943345d3Smrg 6560a7b590b3Smrgvoid 6561a7b590b3Smrglt_update_lib_path (const char *name, const char *value) 6562a7b590b3Smrg{ 65633e51e026Smrg lt_debugprintf (__FILE__, __LINE__, 65643e51e026Smrg "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", 65653e51e026Smrg nonnull (name), nonnull (value)); 6566943345d3Smrg 6567a7b590b3Smrg if (name && *name && value && *value) 6568a7b590b3Smrg { 6569a7b590b3Smrg char *new_value = lt_extend_str (getenv (name), value, 0); 6570a7b590b3Smrg lt_setenv (name, new_value); 6571a7b590b3Smrg XFREE (new_value); 6572a7b590b3Smrg } 6573a7b590b3Smrg} 6574943345d3Smrg 65753e51e026SmrgEOF 65763e51e026Smrg case $host_os in 65773e51e026Smrg mingw*) 65783e51e026Smrg cat <<"EOF" 65793e51e026Smrg 65803e51e026Smrg/* Prepares an argument vector before calling spawn(). 65813e51e026Smrg Note that spawn() does not by itself call the command interpreter 65823e51e026Smrg (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : 65833e51e026Smrg ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); 65843e51e026Smrg GetVersionEx(&v); 65853e51e026Smrg v.dwPlatformId == VER_PLATFORM_WIN32_NT; 65863e51e026Smrg }) ? "cmd.exe" : "command.com"). 65873e51e026Smrg Instead it simply concatenates the arguments, separated by ' ', and calls 65883e51e026Smrg CreateProcess(). We must quote the arguments since Win32 CreateProcess() 65893e51e026Smrg interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a 65903e51e026Smrg special way: 65913e51e026Smrg - Space and tab are interpreted as delimiters. They are not treated as 65923e51e026Smrg delimiters if they are surrounded by double quotes: "...". 65933e51e026Smrg - Unescaped double quotes are removed from the input. Their only effect is 65943e51e026Smrg that within double quotes, space and tab are treated like normal 65953e51e026Smrg characters. 65963e51e026Smrg - Backslashes not followed by double quotes are not special. 65973e51e026Smrg - But 2*n+1 backslashes followed by a double quote become 65983e51e026Smrg n backslashes followed by a double quote (n >= 0): 65993e51e026Smrg \" -> " 66003e51e026Smrg \\\" -> \" 66013e51e026Smrg \\\\\" -> \\" 66023e51e026Smrg */ 66033e51e026Smrg#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" 66043e51e026Smrg#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" 66053e51e026Smrgchar ** 66063e51e026Smrgprepare_spawn (char **argv) 66073e51e026Smrg{ 66083e51e026Smrg size_t argc; 66093e51e026Smrg char **new_argv; 66103e51e026Smrg size_t i; 66113e51e026Smrg 66123e51e026Smrg /* Count number of arguments. */ 66133e51e026Smrg for (argc = 0; argv[argc] != NULL; argc++) 66143e51e026Smrg ; 66153e51e026Smrg 66163e51e026Smrg /* Allocate new argument vector. */ 66173e51e026Smrg new_argv = XMALLOC (char *, argc + 1); 66183e51e026Smrg 66193e51e026Smrg /* Put quoted arguments into the new argument vector. */ 66203e51e026Smrg for (i = 0; i < argc; i++) 66213e51e026Smrg { 66223e51e026Smrg const char *string = argv[i]; 66233e51e026Smrg 66243e51e026Smrg if (string[0] == '\0') 66253e51e026Smrg new_argv[i] = xstrdup ("\"\""); 66263e51e026Smrg else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) 66273e51e026Smrg { 66283e51e026Smrg int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); 66293e51e026Smrg size_t length; 66303e51e026Smrg unsigned int backslashes; 66313e51e026Smrg const char *s; 66323e51e026Smrg char *quoted_string; 66333e51e026Smrg char *p; 66343e51e026Smrg 66353e51e026Smrg length = 0; 66363e51e026Smrg backslashes = 0; 66373e51e026Smrg if (quote_around) 66383e51e026Smrg length++; 66393e51e026Smrg for (s = string; *s != '\0'; s++) 66403e51e026Smrg { 66413e51e026Smrg char c = *s; 66423e51e026Smrg if (c == '"') 66433e51e026Smrg length += backslashes + 1; 66443e51e026Smrg length++; 66453e51e026Smrg if (c == '\\') 66463e51e026Smrg backslashes++; 66473e51e026Smrg else 66483e51e026Smrg backslashes = 0; 66493e51e026Smrg } 66503e51e026Smrg if (quote_around) 66513e51e026Smrg length += backslashes + 1; 66523e51e026Smrg 66533e51e026Smrg quoted_string = XMALLOC (char, length + 1); 66543e51e026Smrg 66553e51e026Smrg p = quoted_string; 66563e51e026Smrg backslashes = 0; 66573e51e026Smrg if (quote_around) 66583e51e026Smrg *p++ = '"'; 66593e51e026Smrg for (s = string; *s != '\0'; s++) 66603e51e026Smrg { 66613e51e026Smrg char c = *s; 66623e51e026Smrg if (c == '"') 66633e51e026Smrg { 66643e51e026Smrg unsigned int j; 66653e51e026Smrg for (j = backslashes + 1; j > 0; j--) 66663e51e026Smrg *p++ = '\\'; 66673e51e026Smrg } 66683e51e026Smrg *p++ = c; 66693e51e026Smrg if (c == '\\') 66703e51e026Smrg backslashes++; 66713e51e026Smrg else 66723e51e026Smrg backslashes = 0; 66733e51e026Smrg } 66743e51e026Smrg if (quote_around) 66753e51e026Smrg { 66763e51e026Smrg unsigned int j; 66773e51e026Smrg for (j = backslashes; j > 0; j--) 66783e51e026Smrg *p++ = '\\'; 66793e51e026Smrg *p++ = '"'; 66803e51e026Smrg } 66813e51e026Smrg *p = '\0'; 66823e51e026Smrg 66833e51e026Smrg new_argv[i] = quoted_string; 66843e51e026Smrg } 66853e51e026Smrg else 66863e51e026Smrg new_argv[i] = (char *) string; 66873e51e026Smrg } 66883e51e026Smrg new_argv[argc] = NULL; 66893e51e026Smrg 66903e51e026Smrg return new_argv; 66913e51e026Smrg} 66923e51e026SmrgEOF 66933e51e026Smrg ;; 66943e51e026Smrg esac 6695943345d3Smrg 66963e51e026Smrg cat <<"EOF" 66973e51e026Smrgvoid lt_dump_script (FILE* f) 66983e51e026Smrg{ 66993e51e026SmrgEOF 67003e51e026Smrg func_emit_wrapper yes | 67013e51e026Smrg $SED -n -e ' 67023e51e026Smrgs/^\(.\{79\}\)\(..*\)/\1\ 67033e51e026Smrg\2/ 67043e51e026Smrgh 67053e51e026Smrgs/\([\\"]\)/\\\1/g 67063e51e026Smrgs/$/\\n/ 67073e51e026Smrgs/\([^\n]*\).*/ fputs ("\1", f);/p 67083e51e026Smrgg 67093e51e026SmrgD' 67103e51e026Smrg cat <<"EOF" 67113e51e026Smrg} 6712a7b590b3SmrgEOF 6713a7b590b3Smrg} 6714a7b590b3Smrg# end: func_emit_cwrapperexe_src 6715943345d3Smrg 67163e51e026Smrg# func_win32_import_lib_p ARG 67173e51e026Smrg# True if ARG is an import lib, as indicated by $file_magic_cmd 67183e51e026Smrgfunc_win32_import_lib_p () 67193e51e026Smrg{ 672015ffece8Smrg $debug_cmd 672115ffece8Smrg 67223e51e026Smrg case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in 67233e51e026Smrg *import*) : ;; 67243e51e026Smrg *) false ;; 67253e51e026Smrg esac 67263e51e026Smrg} 67273e51e026Smrg 672815ffece8Smrg# func_suncc_cstd_abi 672915ffece8Smrg# !!ONLY CALL THIS FOR SUN CC AFTER $compile_command IS FULLY EXPANDED!! 673015ffece8Smrg# Several compiler flags select an ABI that is incompatible with the 673115ffece8Smrg# Cstd library. Avoid specifying it if any are in CXXFLAGS. 673215ffece8Smrgfunc_suncc_cstd_abi () 673315ffece8Smrg{ 673415ffece8Smrg $debug_cmd 673515ffece8Smrg 673615ffece8Smrg case " $compile_command " in 673715ffece8Smrg *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*) 673815ffece8Smrg suncc_use_cstd_abi=no 673915ffece8Smrg ;; 674015ffece8Smrg *) 674115ffece8Smrg suncc_use_cstd_abi=yes 674215ffece8Smrg ;; 674315ffece8Smrg esac 674415ffece8Smrg} 674515ffece8Smrg 6746a7b590b3Smrg# func_mode_link arg... 6747a7b590b3Smrgfunc_mode_link () 6748a7b590b3Smrg{ 674915ffece8Smrg $debug_cmd 675015ffece8Smrg 6751a7b590b3Smrg case $host in 6752a7b590b3Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 6753a7b590b3Smrg # It is impossible to link a dll without this setting, and 6754a7b590b3Smrg # we shouldn't force the makefile maintainer to figure out 675515ffece8Smrg # what system we are compiling for in order to pass an extra 6756a7b590b3Smrg # flag for every libtool invocation. 6757a7b590b3Smrg # allow_undefined=no 6758943345d3Smrg 6759a7b590b3Smrg # FIXME: Unfortunately, there are problems with the above when trying 676015ffece8Smrg # to make a dll that has undefined symbols, in which case not 6761a7b590b3Smrg # even a static library is built. For now, we need to specify 6762a7b590b3Smrg # -no-undefined on the libtool link line when we can be certain 6763a7b590b3Smrg # that all symbols are satisfied, otherwise we get a static library. 6764a7b590b3Smrg allow_undefined=yes 6765a7b590b3Smrg ;; 6766a7b590b3Smrg *) 6767a7b590b3Smrg allow_undefined=yes 6768a7b590b3Smrg ;; 6769a7b590b3Smrg esac 6770a7b590b3Smrg libtool_args=$nonopt 6771a7b590b3Smrg base_compile="$nonopt $@" 6772a7b590b3Smrg compile_command=$nonopt 6773a7b590b3Smrg finalize_command=$nonopt 6774943345d3Smrg 6775a7b590b3Smrg compile_rpath= 6776a7b590b3Smrg finalize_rpath= 6777a7b590b3Smrg compile_shlibpath= 6778a7b590b3Smrg finalize_shlibpath= 6779a7b590b3Smrg convenience= 6780a7b590b3Smrg old_convenience= 6781a7b590b3Smrg deplibs= 6782a7b590b3Smrg old_deplibs= 6783a7b590b3Smrg compiler_flags= 6784a7b590b3Smrg linker_flags= 6785a7b590b3Smrg dllsearchpath= 6786a7b590b3Smrg lib_search_path=`pwd` 6787a7b590b3Smrg inst_prefix_dir= 6788a7b590b3Smrg new_inherited_linker_flags= 6789943345d3Smrg 6790a7b590b3Smrg avoid_version=no 67913e51e026Smrg bindir= 6792a7b590b3Smrg dlfiles= 6793a7b590b3Smrg dlprefiles= 6794a7b590b3Smrg dlself=no 6795a7b590b3Smrg export_dynamic=no 6796a7b590b3Smrg export_symbols= 6797a7b590b3Smrg export_symbols_regex= 6798a7b590b3Smrg generated= 6799a7b590b3Smrg libobjs= 6800a7b590b3Smrg ltlibs= 6801a7b590b3Smrg module=no 6802a7b590b3Smrg no_install=no 6803a7b590b3Smrg objs= 680415ffece8Smrg os2dllname= 6805a7b590b3Smrg non_pic_objects= 6806a7b590b3Smrg precious_files_regex= 6807a7b590b3Smrg prefer_static_libs=no 680815ffece8Smrg preload=false 6809a7b590b3Smrg prev= 6810a7b590b3Smrg prevarg= 6811a7b590b3Smrg release= 6812a7b590b3Smrg rpath= 6813a7b590b3Smrg xrpath= 6814a7b590b3Smrg perm_rpath= 6815a7b590b3Smrg temp_rpath= 6816a7b590b3Smrg thread_safe=no 6817a7b590b3Smrg vinfo= 6818a7b590b3Smrg vinfo_number=no 6819a7b590b3Smrg weak_libs= 682015ffece8Smrg single_module=$wl-single_module 6821a7b590b3Smrg func_infer_tag $base_compile 6822a7b590b3Smrg 6823a7b590b3Smrg # We need to know -static, to get the right output filenames. 6824a7b590b3Smrg for arg 6825a7b590b3Smrg do 6826a7b590b3Smrg case $arg in 6827a7b590b3Smrg -shared) 682815ffece8Smrg test yes != "$build_libtool_libs" \ 682915ffece8Smrg && func_fatal_configuration "cannot build a shared library" 6830a7b590b3Smrg build_old_libs=no 6831a7b590b3Smrg break 6832a7b590b3Smrg ;; 6833a7b590b3Smrg -all-static | -static | -static-libtool-libs) 6834a7b590b3Smrg case $arg in 6835a7b590b3Smrg -all-static) 683615ffece8Smrg if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then 6837a7b590b3Smrg func_warning "complete static linking is impossible in this configuration" 6838a7b590b3Smrg fi 6839a7b590b3Smrg if test -n "$link_static_flag"; then 6840a7b590b3Smrg dlopen_self=$dlopen_self_static 6841a7b590b3Smrg fi 6842a7b590b3Smrg prefer_static_libs=yes 6843a7b590b3Smrg ;; 6844a7b590b3Smrg -static) 6845a7b590b3Smrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 6846a7b590b3Smrg dlopen_self=$dlopen_self_static 6847a7b590b3Smrg fi 6848a7b590b3Smrg prefer_static_libs=built 6849a7b590b3Smrg ;; 6850a7b590b3Smrg -static-libtool-libs) 6851a7b590b3Smrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 6852a7b590b3Smrg dlopen_self=$dlopen_self_static 6853943345d3Smrg fi 6854a7b590b3Smrg prefer_static_libs=yes 6855a7b590b3Smrg ;; 6856a7b590b3Smrg esac 6857a7b590b3Smrg build_libtool_libs=no 6858a7b590b3Smrg build_old_libs=yes 6859a7b590b3Smrg break 6860a7b590b3Smrg ;; 6861a7b590b3Smrg esac 6862a7b590b3Smrg done 6863943345d3Smrg 6864a7b590b3Smrg # See if our shared archives depend on static archives. 6865a7b590b3Smrg test -n "$old_archive_from_new_cmds" && build_old_libs=yes 6866943345d3Smrg 6867a7b590b3Smrg # Go through the arguments, transforming them on the way. 6868a7b590b3Smrg while test "$#" -gt 0; do 686915ffece8Smrg arg=$1 6870a7b590b3Smrg shift 687115ffece8Smrg func_quote_arg pretty,unquoted "$arg" 687215ffece8Smrg qarg=$func_quote_arg_unquoted_result 687315ffece8Smrg func_append libtool_args " $func_quote_arg_result" 6874943345d3Smrg 6875a7b590b3Smrg # If the previous option needs an argument, assign it. 6876a7b590b3Smrg if test -n "$prev"; then 6877a7b590b3Smrg case $prev in 6878a7b590b3Smrg output) 6879a7b590b3Smrg func_append compile_command " @OUTPUT@" 6880a7b590b3Smrg func_append finalize_command " @OUTPUT@" 6881a7b590b3Smrg ;; 6882a7b590b3Smrg esac 6883943345d3Smrg 6884a7b590b3Smrg case $prev in 68853e51e026Smrg bindir) 688615ffece8Smrg bindir=$arg 68873e51e026Smrg prev= 68883e51e026Smrg continue 68893e51e026Smrg ;; 6890a7b590b3Smrg dlfiles|dlprefiles) 689115ffece8Smrg $preload || { 6892a7b590b3Smrg # Add the symbol object into the linking commands. 6893a7b590b3Smrg func_append compile_command " @SYMFILE@" 6894a7b590b3Smrg func_append finalize_command " @SYMFILE@" 689515ffece8Smrg preload=: 689615ffece8Smrg } 6897a7b590b3Smrg case $arg in 6898a7b590b3Smrg *.la | *.lo) ;; # We handle these cases below. 6899a7b590b3Smrg force) 690015ffece8Smrg if test no = "$dlself"; then 6901a7b590b3Smrg dlself=needless 6902a7b590b3Smrg export_dynamic=yes 6903a7b590b3Smrg fi 6904a7b590b3Smrg prev= 6905a7b590b3Smrg continue 6906a7b590b3Smrg ;; 6907a7b590b3Smrg self) 690815ffece8Smrg if test dlprefiles = "$prev"; then 6909a7b590b3Smrg dlself=yes 691015ffece8Smrg elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then 6911a7b590b3Smrg dlself=yes 6912943345d3Smrg else 6913a7b590b3Smrg dlself=needless 6914a7b590b3Smrg export_dynamic=yes 6915943345d3Smrg fi 6916a7b590b3Smrg prev= 6917a7b590b3Smrg continue 6918a7b590b3Smrg ;; 6919a7b590b3Smrg *) 692015ffece8Smrg if test dlfiles = "$prev"; then 69213e51e026Smrg func_append dlfiles " $arg" 6922943345d3Smrg else 69233e51e026Smrg func_append dlprefiles " $arg" 6924943345d3Smrg fi 6925a7b590b3Smrg prev= 6926a7b590b3Smrg continue 6927a7b590b3Smrg ;; 6928a7b590b3Smrg esac 6929a7b590b3Smrg ;; 6930a7b590b3Smrg expsyms) 693115ffece8Smrg export_symbols=$arg 6932a7b590b3Smrg test -f "$arg" \ 693315ffece8Smrg || func_fatal_error "symbol file '$arg' does not exist" 6934a7b590b3Smrg prev= 6935a7b590b3Smrg continue 6936a7b590b3Smrg ;; 6937a7b590b3Smrg expsyms_regex) 693815ffece8Smrg export_symbols_regex=$arg 6939a7b590b3Smrg prev= 6940a7b590b3Smrg continue 6941a7b590b3Smrg ;; 6942a7b590b3Smrg framework) 6943943345d3Smrg case $host in 6944a7b590b3Smrg *-*-darwin*) 6945a7b590b3Smrg case "$deplibs " in 6946a7b590b3Smrg *" $qarg.ltframework "*) ;; 69473e51e026Smrg *) func_append deplibs " $qarg.ltframework" # this is fixed later 6948a7b590b3Smrg ;; 6949a7b590b3Smrg esac 6950a7b590b3Smrg ;; 6951943345d3Smrg esac 6952a7b590b3Smrg prev= 6953a7b590b3Smrg continue 6954943345d3Smrg ;; 6955a7b590b3Smrg inst_prefix) 695615ffece8Smrg inst_prefix_dir=$arg 695715ffece8Smrg prev= 695815ffece8Smrg continue 695915ffece8Smrg ;; 696015ffece8Smrg mllvm) 696115ffece8Smrg # Clang does not use LLVM to link, so we can simply discard any 696215ffece8Smrg # '-mllvm $arg' options when doing the link step. 6963a7b590b3Smrg prev= 6964a7b590b3Smrg continue 6965943345d3Smrg ;; 6966a7b590b3Smrg objectlist) 6967a7b590b3Smrg if test -f "$arg"; then 6968a7b590b3Smrg save_arg=$arg 6969a7b590b3Smrg moreargs= 6970a7b590b3Smrg for fil in `cat "$save_arg"` 6971a7b590b3Smrg do 69723e51e026Smrg# func_append moreargs " $fil" 6973a7b590b3Smrg arg=$fil 6974a7b590b3Smrg # A libtool-controlled object. 6975943345d3Smrg 6976a7b590b3Smrg # Check to see that this really is a libtool object. 6977a7b590b3Smrg if func_lalib_unsafe_p "$arg"; then 6978a7b590b3Smrg pic_object= 6979a7b590b3Smrg non_pic_object= 6980943345d3Smrg 6981a7b590b3Smrg # Read the .lo file 6982a7b590b3Smrg func_source "$arg" 6983943345d3Smrg 6984a7b590b3Smrg if test -z "$pic_object" || 6985a7b590b3Smrg test -z "$non_pic_object" || 698615ffece8Smrg test none = "$pic_object" && 698715ffece8Smrg test none = "$non_pic_object"; then 698815ffece8Smrg func_fatal_error "cannot find name of object for '$arg'" 6989a7b590b3Smrg fi 6990943345d3Smrg 6991a7b590b3Smrg # Extract subdirectory from the argument. 6992a7b590b3Smrg func_dirname "$arg" "/" "" 699315ffece8Smrg xdir=$func_dirname_result 6994943345d3Smrg 699515ffece8Smrg if test none != "$pic_object"; then 6996a7b590b3Smrg # Prepend the subdirectory the object is found in. 699715ffece8Smrg pic_object=$xdir$pic_object 6998943345d3Smrg 699915ffece8Smrg if test dlfiles = "$prev"; then 700015ffece8Smrg if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 70013e51e026Smrg func_append dlfiles " $pic_object" 7002a7b590b3Smrg prev= 7003a7b590b3Smrg continue 7004a7b590b3Smrg else 7005a7b590b3Smrg # If libtool objects are unsupported, then we need to preload. 7006a7b590b3Smrg prev=dlprefiles 7007a7b590b3Smrg fi 7008a7b590b3Smrg fi 7009943345d3Smrg 7010a7b590b3Smrg # CHECK ME: I think I busted this. -Ossama 701115ffece8Smrg if test dlprefiles = "$prev"; then 7012a7b590b3Smrg # Preload the old-style object. 70133e51e026Smrg func_append dlprefiles " $pic_object" 7014a7b590b3Smrg prev= 7015a7b590b3Smrg fi 7016943345d3Smrg 7017a7b590b3Smrg # A PIC object. 7018a7b590b3Smrg func_append libobjs " $pic_object" 701915ffece8Smrg arg=$pic_object 7020a7b590b3Smrg fi 7021943345d3Smrg 7022a7b590b3Smrg # Non-PIC object. 702315ffece8Smrg if test none != "$non_pic_object"; then 7024a7b590b3Smrg # Prepend the subdirectory the object is found in. 702515ffece8Smrg non_pic_object=$xdir$non_pic_object 7026943345d3Smrg 7027a7b590b3Smrg # A standard non-PIC object 7028a7b590b3Smrg func_append non_pic_objects " $non_pic_object" 702915ffece8Smrg if test -z "$pic_object" || test none = "$pic_object"; then 703015ffece8Smrg arg=$non_pic_object 7031a7b590b3Smrg fi 7032a7b590b3Smrg else 7033a7b590b3Smrg # If the PIC object exists, use it instead. 7034a7b590b3Smrg # $xdir was prepended to $pic_object above. 703515ffece8Smrg non_pic_object=$pic_object 7036a7b590b3Smrg func_append non_pic_objects " $non_pic_object" 7037a7b590b3Smrg fi 7038a7b590b3Smrg else 7039a7b590b3Smrg # Only an error if not doing a dry-run. 7040a7b590b3Smrg if $opt_dry_run; then 7041a7b590b3Smrg # Extract subdirectory from the argument. 7042a7b590b3Smrg func_dirname "$arg" "/" "" 704315ffece8Smrg xdir=$func_dirname_result 7044a7b590b3Smrg 7045a7b590b3Smrg func_lo2o "$arg" 7046a7b590b3Smrg pic_object=$xdir$objdir/$func_lo2o_result 7047a7b590b3Smrg non_pic_object=$xdir$func_lo2o_result 7048a7b590b3Smrg func_append libobjs " $pic_object" 7049a7b590b3Smrg func_append non_pic_objects " $non_pic_object" 7050a7b590b3Smrg else 705115ffece8Smrg func_fatal_error "'$arg' is not a valid libtool object" 7052a7b590b3Smrg fi 7053a7b590b3Smrg fi 7054a7b590b3Smrg done 7055943345d3Smrg else 705615ffece8Smrg func_fatal_error "link input file '$arg' does not exist" 7057943345d3Smrg fi 7058a7b590b3Smrg arg=$save_arg 7059a7b590b3Smrg prev= 7060a7b590b3Smrg continue 7061a7b590b3Smrg ;; 706215ffece8Smrg os2dllname) 706315ffece8Smrg os2dllname=$arg 706415ffece8Smrg prev= 706515ffece8Smrg continue 706615ffece8Smrg ;; 7067a7b590b3Smrg precious_regex) 706815ffece8Smrg precious_files_regex=$arg 7069a7b590b3Smrg prev= 7070a7b590b3Smrg continue 7071a7b590b3Smrg ;; 7072a7b590b3Smrg release) 707315ffece8Smrg release=-$arg 7074a7b590b3Smrg prev= 7075a7b590b3Smrg continue 7076a7b590b3Smrg ;; 7077a7b590b3Smrg rpath | xrpath) 7078a7b590b3Smrg # We need an absolute path. 7079a7b590b3Smrg case $arg in 7080a7b590b3Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 7081a7b590b3Smrg *) 7082a7b590b3Smrg func_fatal_error "only absolute run-paths are allowed" 7083a7b590b3Smrg ;; 7084a7b590b3Smrg esac 708515ffece8Smrg if test rpath = "$prev"; then 7086a7b590b3Smrg case "$rpath " in 7087a7b590b3Smrg *" $arg "*) ;; 70883e51e026Smrg *) func_append rpath " $arg" ;; 7089a7b590b3Smrg esac 7090943345d3Smrg else 7091a7b590b3Smrg case "$xrpath " in 7092a7b590b3Smrg *" $arg "*) ;; 70933e51e026Smrg *) func_append xrpath " $arg" ;; 7094a7b590b3Smrg esac 7095943345d3Smrg fi 7096a7b590b3Smrg prev= 7097a7b590b3Smrg continue 7098a7b590b3Smrg ;; 7099a7b590b3Smrg shrext) 710015ffece8Smrg shrext_cmds=$arg 7101a7b590b3Smrg prev= 7102a7b590b3Smrg continue 7103a7b590b3Smrg ;; 7104a7b590b3Smrg weak) 71053e51e026Smrg func_append weak_libs " $arg" 7106a7b590b3Smrg prev= 7107a7b590b3Smrg continue 7108a7b590b3Smrg ;; 710915ffece8Smrg xassembler) 711015ffece8Smrg func_append compiler_flags " -Xassembler $qarg" 711115ffece8Smrg prev= 711215ffece8Smrg func_append compile_command " -Xassembler $qarg" 711315ffece8Smrg func_append finalize_command " -Xassembler $qarg" 711415ffece8Smrg continue 711515ffece8Smrg ;; 7116a7b590b3Smrg xcclinker) 71173e51e026Smrg func_append linker_flags " $qarg" 71183e51e026Smrg func_append compiler_flags " $qarg" 7119a7b590b3Smrg prev= 7120a7b590b3Smrg func_append compile_command " $qarg" 7121a7b590b3Smrg func_append finalize_command " $qarg" 7122a7b590b3Smrg continue 7123a7b590b3Smrg ;; 7124a7b590b3Smrg xcompiler) 71253e51e026Smrg func_append compiler_flags " $qarg" 7126a7b590b3Smrg prev= 7127a7b590b3Smrg func_append compile_command " $qarg" 7128a7b590b3Smrg func_append finalize_command " $qarg" 7129a7b590b3Smrg continue 7130a7b590b3Smrg ;; 7131a7b590b3Smrg xlinker) 71323e51e026Smrg func_append linker_flags " $qarg" 71333e51e026Smrg func_append compiler_flags " $wl$qarg" 7134a7b590b3Smrg prev= 7135a7b590b3Smrg func_append compile_command " $wl$qarg" 7136a7b590b3Smrg func_append finalize_command " $wl$qarg" 7137a7b590b3Smrg continue 7138a7b590b3Smrg ;; 7139a7b590b3Smrg *) 7140a7b590b3Smrg eval "$prev=\"\$arg\"" 7141a7b590b3Smrg prev= 7142a7b590b3Smrg continue 7143a7b590b3Smrg ;; 7144943345d3Smrg esac 7145a7b590b3Smrg fi # test -n "$prev" 7146943345d3Smrg 714715ffece8Smrg prevarg=$arg 7148943345d3Smrg 7149a7b590b3Smrg case $arg in 7150a7b590b3Smrg -all-static) 7151a7b590b3Smrg if test -n "$link_static_flag"; then 7152a7b590b3Smrg # See comment for -static flag below, for more details. 7153a7b590b3Smrg func_append compile_command " $link_static_flag" 7154a7b590b3Smrg func_append finalize_command " $link_static_flag" 7155a7b590b3Smrg fi 7156a7b590b3Smrg continue 7157a7b590b3Smrg ;; 7158943345d3Smrg 7159a7b590b3Smrg -allow-undefined) 7160a7b590b3Smrg # FIXME: remove this flag sometime in the future. 716115ffece8Smrg func_fatal_error "'-allow-undefined' must not be used because it is the default" 7162a7b590b3Smrg ;; 7163943345d3Smrg 7164a7b590b3Smrg -avoid-version) 7165a7b590b3Smrg avoid_version=yes 7166a7b590b3Smrg continue 7167a7b590b3Smrg ;; 7168943345d3Smrg 71693e51e026Smrg -bindir) 71703e51e026Smrg prev=bindir 71713e51e026Smrg continue 71723e51e026Smrg ;; 71733e51e026Smrg 7174a7b590b3Smrg -dlopen) 7175a7b590b3Smrg prev=dlfiles 7176a7b590b3Smrg continue 7177a7b590b3Smrg ;; 7178943345d3Smrg 7179a7b590b3Smrg -dlpreopen) 7180a7b590b3Smrg prev=dlprefiles 7181a7b590b3Smrg continue 7182a7b590b3Smrg ;; 7183943345d3Smrg 7184a7b590b3Smrg -export-dynamic) 7185a7b590b3Smrg export_dynamic=yes 7186a7b590b3Smrg continue 7187a7b590b3Smrg ;; 7188943345d3Smrg 7189a7b590b3Smrg -export-symbols | -export-symbols-regex) 7190a7b590b3Smrg if test -n "$export_symbols" || test -n "$export_symbols_regex"; then 7191a7b590b3Smrg func_fatal_error "more than one -exported-symbols argument is not allowed" 7192a7b590b3Smrg fi 719315ffece8Smrg if test X-export-symbols = "X$arg"; then 7194a7b590b3Smrg prev=expsyms 7195a7b590b3Smrg else 7196a7b590b3Smrg prev=expsyms_regex 7197a7b590b3Smrg fi 7198a7b590b3Smrg continue 7199a7b590b3Smrg ;; 7200943345d3Smrg 7201a7b590b3Smrg -framework) 7202a7b590b3Smrg prev=framework 7203a7b590b3Smrg continue 7204a7b590b3Smrg ;; 7205943345d3Smrg 7206a7b590b3Smrg -inst-prefix-dir) 7207a7b590b3Smrg prev=inst_prefix 7208a7b590b3Smrg continue 7209a7b590b3Smrg ;; 7210943345d3Smrg 7211a7b590b3Smrg # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* 7212a7b590b3Smrg # so, if we see these flags be careful not to treat them like -L 7213a7b590b3Smrg -L[A-Z][A-Z]*:*) 7214a7b590b3Smrg case $with_gcc/$host in 7215a7b590b3Smrg no/*-*-irix* | /*-*-irix*) 7216a7b590b3Smrg func_append compile_command " $arg" 7217a7b590b3Smrg func_append finalize_command " $arg" 7218a7b590b3Smrg ;; 7219a7b590b3Smrg esac 7220a7b590b3Smrg continue 7221a7b590b3Smrg ;; 7222943345d3Smrg 7223a7b590b3Smrg -L*) 72243e51e026Smrg func_stripname "-L" '' "$arg" 72253e51e026Smrg if test -z "$func_stripname_result"; then 7226a7b590b3Smrg if test "$#" -gt 0; then 722715ffece8Smrg func_fatal_error "require no space between '-L' and '$1'" 7228a7b590b3Smrg else 722915ffece8Smrg func_fatal_error "need path for '-L' option" 7230a7b590b3Smrg fi 7231a7b590b3Smrg fi 72323e51e026Smrg func_resolve_sysroot "$func_stripname_result" 72333e51e026Smrg dir=$func_resolve_sysroot_result 7234a7b590b3Smrg # We need an absolute path. 7235a7b590b3Smrg case $dir in 7236a7b590b3Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 7237a7b590b3Smrg *) 7238a7b590b3Smrg absdir=`cd "$dir" && pwd` 7239a7b590b3Smrg test -z "$absdir" && \ 724015ffece8Smrg func_fatal_error "cannot determine absolute directory name of '$dir'" 724115ffece8Smrg dir=$absdir 7242a7b590b3Smrg ;; 7243a7b590b3Smrg esac 7244a7b590b3Smrg case "$deplibs " in 72453e51e026Smrg *" -L$dir "* | *" $arg "*) 72463e51e026Smrg # Will only happen for absolute or sysroot arguments 72473e51e026Smrg ;; 7248a7b590b3Smrg *) 72493e51e026Smrg # Preserve sysroot, but never include relative directories 72503e51e026Smrg case $dir in 72513e51e026Smrg [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; 72523e51e026Smrg *) func_append deplibs " -L$dir" ;; 72533e51e026Smrg esac 72543e51e026Smrg func_append lib_search_path " $dir" 7255a7b590b3Smrg ;; 7256a7b590b3Smrg esac 7257a7b590b3Smrg case $host in 7258a7b590b3Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 72593e51e026Smrg testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` 7260a7b590b3Smrg case :$dllsearchpath: in 7261a7b590b3Smrg *":$dir:"*) ;; 7262a7b590b3Smrg ::) dllsearchpath=$dir;; 72633e51e026Smrg *) func_append dllsearchpath ":$dir";; 7264a7b590b3Smrg esac 7265a7b590b3Smrg case :$dllsearchpath: in 7266a7b590b3Smrg *":$testbindir:"*) ;; 7267a7b590b3Smrg ::) dllsearchpath=$testbindir;; 72683e51e026Smrg *) func_append dllsearchpath ":$testbindir";; 7269a7b590b3Smrg esac 7270a7b590b3Smrg ;; 7271a7b590b3Smrg esac 7272a7b590b3Smrg continue 7273a7b590b3Smrg ;; 7274943345d3Smrg 7275a7b590b3Smrg -l*) 727615ffece8Smrg if test X-lc = "X$arg" || test X-lm = "X$arg"; then 7277a7b590b3Smrg case $host in 72783e51e026Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) 7279a7b590b3Smrg # These systems don't actually have a C or math library (as such) 7280a7b590b3Smrg continue 7281a7b590b3Smrg ;; 7282a7b590b3Smrg *-*-os2*) 7283a7b590b3Smrg # These systems don't actually have a C library (as such) 728415ffece8Smrg test X-lc = "X$arg" && continue 7285a7b590b3Smrg ;; 728615ffece8Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig* | *-*-midnightbsd*) 7287a7b590b3Smrg # Do not include libc due to us having libc/libc_r. 728815ffece8Smrg test X-lc = "X$arg" && continue 7289a7b590b3Smrg ;; 7290a7b590b3Smrg *-*-rhapsody* | *-*-darwin1.[012]) 7291a7b590b3Smrg # Rhapsody C and math libraries are in the System framework 72923e51e026Smrg func_append deplibs " System.ltframework" 7293a7b590b3Smrg continue 7294a7b590b3Smrg ;; 7295a7b590b3Smrg *-*-sco3.2v5* | *-*-sco5v6*) 7296a7b590b3Smrg # Causes problems with __ctype 729715ffece8Smrg test X-lc = "X$arg" && continue 7298a7b590b3Smrg ;; 7299a7b590b3Smrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 7300a7b590b3Smrg # Compiler inserts libc in the correct place for threads to work 730115ffece8Smrg test X-lc = "X$arg" && continue 7302a7b590b3Smrg ;; 7303a7b590b3Smrg esac 730415ffece8Smrg elif test X-lc_r = "X$arg"; then 7305a7b590b3Smrg case $host in 730615ffece8Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig* | *-*-midnightbsd*) 7307a7b590b3Smrg # Do not include libc_r directly, use -pthread flag. 7308a7b590b3Smrg continue 7309a7b590b3Smrg ;; 7310a7b590b3Smrg esac 7311a7b590b3Smrg fi 73123e51e026Smrg func_append deplibs " $arg" 7313a7b590b3Smrg continue 7314a7b590b3Smrg ;; 7315943345d3Smrg 731615ffece8Smrg -mllvm) 731715ffece8Smrg prev=mllvm 731815ffece8Smrg continue 731915ffece8Smrg ;; 732015ffece8Smrg 7321a7b590b3Smrg -module) 7322a7b590b3Smrg module=yes 7323a7b590b3Smrg continue 7324a7b590b3Smrg ;; 7325943345d3Smrg 7326a7b590b3Smrg # Tru64 UNIX uses -model [arg] to determine the layout of C++ 7327a7b590b3Smrg # classes, name mangling, and exception handling. 7328a7b590b3Smrg # Darwin uses the -arch flag to determine output architecture. 73293e51e026Smrg -model|-arch|-isysroot|--sysroot) 73303e51e026Smrg func_append compiler_flags " $arg" 7331a7b590b3Smrg func_append compile_command " $arg" 7332a7b590b3Smrg func_append finalize_command " $arg" 7333a7b590b3Smrg prev=xcompiler 7334a7b590b3Smrg continue 7335a7b590b3Smrg ;; 733615ffece8Smrg # Solaris ld rejects as of 11.4. Refer to Oracle bug 22985199. 733715ffece8Smrg -pthread) 733815ffece8Smrg case $host in 733915ffece8Smrg *solaris2*) ;; 734015ffece8Smrg *) 734115ffece8Smrg case "$new_inherited_linker_flags " in 734215ffece8Smrg *" $arg "*) ;; 734315ffece8Smrg * ) func_append new_inherited_linker_flags " $arg" ;; 734415ffece8Smrg esac 734515ffece8Smrg ;; 734615ffece8Smrg esac 734715ffece8Smrg continue 734815ffece8Smrg ;; 734915ffece8Smrg -mt|-mthreads|-kthread|-Kthread|-pthreads|--thread-safe \ 73503e51e026Smrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 73513e51e026Smrg func_append compiler_flags " $arg" 7352a7b590b3Smrg func_append compile_command " $arg" 7353a7b590b3Smrg func_append finalize_command " $arg" 7354a7b590b3Smrg case "$new_inherited_linker_flags " in 7355a7b590b3Smrg *" $arg "*) ;; 73563e51e026Smrg * ) func_append new_inherited_linker_flags " $arg" ;; 7357a7b590b3Smrg esac 7358a7b590b3Smrg continue 7359a7b590b3Smrg ;; 7360943345d3Smrg 7361a7b590b3Smrg -multi_module) 736215ffece8Smrg single_module=$wl-multi_module 7363a7b590b3Smrg continue 7364a7b590b3Smrg ;; 7365943345d3Smrg 7366a7b590b3Smrg -no-fast-install) 7367a7b590b3Smrg fast_install=no 7368a7b590b3Smrg continue 7369a7b590b3Smrg ;; 7370943345d3Smrg 7371a7b590b3Smrg -no-install) 7372a7b590b3Smrg case $host in 7373a7b590b3Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) 7374a7b590b3Smrg # The PATH hackery in wrapper scripts is required on Windows 7375a7b590b3Smrg # and Darwin in order for the loader to find any dlls it needs. 737615ffece8Smrg func_warning "'-no-install' is ignored for $host" 737715ffece8Smrg func_warning "assuming '-no-fast-install' instead" 7378a7b590b3Smrg fast_install=no 7379a7b590b3Smrg ;; 7380a7b590b3Smrg *) no_install=yes ;; 7381a7b590b3Smrg esac 7382a7b590b3Smrg continue 7383a7b590b3Smrg ;; 7384943345d3Smrg 7385a7b590b3Smrg -no-undefined) 7386a7b590b3Smrg allow_undefined=no 7387a7b590b3Smrg continue 7388a7b590b3Smrg ;; 7389943345d3Smrg 7390a7b590b3Smrg -objectlist) 7391a7b590b3Smrg prev=objectlist 7392a7b590b3Smrg continue 7393a7b590b3Smrg ;; 7394943345d3Smrg 739515ffece8Smrg -os2dllname) 739615ffece8Smrg prev=os2dllname 739715ffece8Smrg continue 739815ffece8Smrg ;; 739915ffece8Smrg 7400a7b590b3Smrg -o) prev=output ;; 7401943345d3Smrg 7402a7b590b3Smrg -precious-files-regex) 7403a7b590b3Smrg prev=precious_regex 7404a7b590b3Smrg continue 7405a7b590b3Smrg ;; 7406943345d3Smrg 7407a7b590b3Smrg -release) 7408a7b590b3Smrg prev=release 7409a7b590b3Smrg continue 7410a7b590b3Smrg ;; 7411943345d3Smrg 7412a7b590b3Smrg -rpath) 7413a7b590b3Smrg prev=rpath 7414a7b590b3Smrg continue 7415a7b590b3Smrg ;; 7416943345d3Smrg 7417a7b590b3Smrg -R) 7418a7b590b3Smrg prev=xrpath 7419a7b590b3Smrg continue 7420a7b590b3Smrg ;; 7421943345d3Smrg 7422a7b590b3Smrg -R*) 7423a7b590b3Smrg func_stripname '-R' '' "$arg" 7424a7b590b3Smrg dir=$func_stripname_result 7425a7b590b3Smrg # We need an absolute path. 7426a7b590b3Smrg case $dir in 7427a7b590b3Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 74283e51e026Smrg =*) 74293e51e026Smrg func_stripname '=' '' "$dir" 74303e51e026Smrg dir=$lt_sysroot$func_stripname_result 74313e51e026Smrg ;; 7432a7b590b3Smrg *) 7433a7b590b3Smrg func_fatal_error "only absolute run-paths are allowed" 7434a7b590b3Smrg ;; 7435a7b590b3Smrg esac 7436a7b590b3Smrg case "$xrpath " in 7437a7b590b3Smrg *" $dir "*) ;; 74383e51e026Smrg *) func_append xrpath " $dir" ;; 7439a7b590b3Smrg esac 7440a7b590b3Smrg continue 7441a7b590b3Smrg ;; 7442943345d3Smrg 7443a7b590b3Smrg -shared) 7444a7b590b3Smrg # The effects of -shared are defined in a previous loop. 7445a7b590b3Smrg continue 7446a7b590b3Smrg ;; 7447943345d3Smrg 7448a7b590b3Smrg -shrext) 7449a7b590b3Smrg prev=shrext 7450a7b590b3Smrg continue 7451a7b590b3Smrg ;; 7452943345d3Smrg 7453a7b590b3Smrg -static | -static-libtool-libs) 7454a7b590b3Smrg # The effects of -static are defined in a previous loop. 7455a7b590b3Smrg # We used to do the same as -all-static on platforms that 7456a7b590b3Smrg # didn't have a PIC flag, but the assumption that the effects 7457a7b590b3Smrg # would be equivalent was wrong. It would break on at least 7458a7b590b3Smrg # Digital Unix and AIX. 7459a7b590b3Smrg continue 7460a7b590b3Smrg ;; 7461943345d3Smrg 7462a7b590b3Smrg -thread-safe) 7463a7b590b3Smrg thread_safe=yes 7464a7b590b3Smrg continue 7465a7b590b3Smrg ;; 7466943345d3Smrg 7467a7b590b3Smrg -version-info) 7468a7b590b3Smrg prev=vinfo 7469a7b590b3Smrg continue 7470a7b590b3Smrg ;; 7471943345d3Smrg 7472a7b590b3Smrg -version-number) 7473a7b590b3Smrg prev=vinfo 7474a7b590b3Smrg vinfo_number=yes 7475a7b590b3Smrg continue 7476a7b590b3Smrg ;; 7477943345d3Smrg 7478a7b590b3Smrg -weak) 7479a7b590b3Smrg prev=weak 7480a7b590b3Smrg continue 7481a7b590b3Smrg ;; 7482943345d3Smrg 7483a7b590b3Smrg -Wc,*) 7484a7b590b3Smrg func_stripname '-Wc,' '' "$arg" 7485a7b590b3Smrg args=$func_stripname_result 7486a7b590b3Smrg arg= 748715ffece8Smrg save_ifs=$IFS; IFS=, 7488a7b590b3Smrg for flag in $args; do 748915ffece8Smrg IFS=$save_ifs 749015ffece8Smrg func_quote_arg pretty "$flag" 749115ffece8Smrg func_append arg " $func_quote_arg_result" 749215ffece8Smrg func_append compiler_flags " $func_quote_arg_result" 7493a7b590b3Smrg done 749415ffece8Smrg IFS=$save_ifs 7495a7b590b3Smrg func_stripname ' ' '' "$arg" 7496a7b590b3Smrg arg=$func_stripname_result 7497a7b590b3Smrg ;; 7498943345d3Smrg 7499a7b590b3Smrg -Wl,*) 7500a7b590b3Smrg func_stripname '-Wl,' '' "$arg" 7501a7b590b3Smrg args=$func_stripname_result 7502a7b590b3Smrg arg= 750315ffece8Smrg save_ifs=$IFS; IFS=, 7504a7b590b3Smrg for flag in $args; do 750515ffece8Smrg IFS=$save_ifs 750615ffece8Smrg func_quote_arg pretty "$flag" 750715ffece8Smrg func_append arg " $wl$func_quote_arg_result" 750815ffece8Smrg func_append compiler_flags " $wl$func_quote_arg_result" 750915ffece8Smrg func_append linker_flags " $func_quote_arg_result" 7510a7b590b3Smrg done 751115ffece8Smrg IFS=$save_ifs 7512a7b590b3Smrg func_stripname ' ' '' "$arg" 7513a7b590b3Smrg arg=$func_stripname_result 7514a7b590b3Smrg ;; 7515943345d3Smrg 751615ffece8Smrg -Xassembler) 751715ffece8Smrg prev=xassembler 751815ffece8Smrg continue 751915ffece8Smrg ;; 752015ffece8Smrg 7521a7b590b3Smrg -Xcompiler) 7522a7b590b3Smrg prev=xcompiler 7523a7b590b3Smrg continue 7524a7b590b3Smrg ;; 7525943345d3Smrg 7526a7b590b3Smrg -Xlinker) 7527a7b590b3Smrg prev=xlinker 7528a7b590b3Smrg continue 7529a7b590b3Smrg ;; 7530943345d3Smrg 7531a7b590b3Smrg -XCClinker) 7532a7b590b3Smrg prev=xcclinker 7533a7b590b3Smrg continue 7534a7b590b3Smrg ;; 7535943345d3Smrg 7536a7b590b3Smrg # -msg_* for osf cc 7537a7b590b3Smrg -msg_*) 753815ffece8Smrg func_quote_arg pretty "$arg" 753915ffece8Smrg arg=$func_quote_arg_result 7540a7b590b3Smrg ;; 7541943345d3Smrg 75423e51e026Smrg # Flags to be passed through unchanged, with rationale: 75433e51e026Smrg # -64, -mips[0-9] enable 64-bit mode for the SGI compiler 75443e51e026Smrg # -r[0-9][0-9]* specify processor for the SGI compiler 75453e51e026Smrg # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler 75463e51e026Smrg # +DA*, +DD* enable 64-bit mode for the HP compiler 75473e51e026Smrg # -q* compiler args for the IBM compiler 75483e51e026Smrg # -m*, -t[45]*, -txscale* architecture-specific flags for GCC 75493e51e026Smrg # -F/path path to uninstalled frameworks, gcc on darwin 75503e51e026Smrg # -p, -pg, --coverage, -fprofile-* profiling flags for GCC 755115ffece8Smrg # -fstack-protector* stack protector flags for GCC 75523e51e026Smrg # @file GCC response files 75533e51e026Smrg # -tp=* Portland pgcc target processor selection 75543e51e026Smrg # --sysroot=* for sysroot support 755515ffece8Smrg # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization 755615ffece8Smrg # -specs=* GCC specs files 755715ffece8Smrg # -stdlib=* select c++ std lib with clang 755815ffece8Smrg # -fsanitize=* Clang/GCC memory and address sanitizer 755915ffece8Smrg # -fuse-ld=* Linker select flags for GCC 756015ffece8Smrg # -Wa,* Pass flags directly to the assembler 7561a7b590b3Smrg -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ 75623e51e026Smrg -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ 756315ffece8Smrg -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*| \ 756415ffece8Smrg -specs=*|-fsanitize=*|-fuse-ld=*|-Wa,*) 756515ffece8Smrg func_quote_arg pretty "$arg" 756615ffece8Smrg arg=$func_quote_arg_result 7567a7b590b3Smrg func_append compile_command " $arg" 7568a7b590b3Smrg func_append finalize_command " $arg" 75693e51e026Smrg func_append compiler_flags " $arg" 7570a7b590b3Smrg continue 7571a7b590b3Smrg ;; 7572943345d3Smrg 757315ffece8Smrg -Z*) 757415ffece8Smrg if test os2 = "`expr $host : '.*\(os2\)'`"; then 757515ffece8Smrg # OS/2 uses -Zxxx to specify OS/2-specific options 757615ffece8Smrg compiler_flags="$compiler_flags $arg" 757715ffece8Smrg func_append compile_command " $arg" 757815ffece8Smrg func_append finalize_command " $arg" 757915ffece8Smrg case $arg in 758015ffece8Smrg -Zlinker | -Zstack) 758115ffece8Smrg prev=xcompiler 758215ffece8Smrg ;; 758315ffece8Smrg esac 758415ffece8Smrg continue 758515ffece8Smrg else 758615ffece8Smrg # Otherwise treat like 'Some other compiler flag' below 758715ffece8Smrg func_quote_arg pretty "$arg" 758815ffece8Smrg arg=$func_quote_arg_result 758915ffece8Smrg fi 759015ffece8Smrg ;; 759115ffece8Smrg 7592a7b590b3Smrg # Some other compiler flag. 7593a7b590b3Smrg -* | +*) 759415ffece8Smrg func_quote_arg pretty "$arg" 759515ffece8Smrg arg=$func_quote_arg_result 7596a7b590b3Smrg ;; 7597943345d3Smrg 7598a7b590b3Smrg *.$objext) 7599a7b590b3Smrg # A standard object. 76003e51e026Smrg func_append objs " $arg" 7601a7b590b3Smrg ;; 7602943345d3Smrg 7603a7b590b3Smrg *.lo) 7604a7b590b3Smrg # A libtool-controlled object. 7605943345d3Smrg 7606a7b590b3Smrg # Check to see that this really is a libtool object. 7607a7b590b3Smrg if func_lalib_unsafe_p "$arg"; then 7608a7b590b3Smrg pic_object= 7609a7b590b3Smrg non_pic_object= 7610943345d3Smrg 7611a7b590b3Smrg # Read the .lo file 7612a7b590b3Smrg func_source "$arg" 7613943345d3Smrg 7614a7b590b3Smrg if test -z "$pic_object" || 7615a7b590b3Smrg test -z "$non_pic_object" || 761615ffece8Smrg test none = "$pic_object" && 761715ffece8Smrg test none = "$non_pic_object"; then 761815ffece8Smrg func_fatal_error "cannot find name of object for '$arg'" 7619a7b590b3Smrg fi 7620943345d3Smrg 7621a7b590b3Smrg # Extract subdirectory from the argument. 7622a7b590b3Smrg func_dirname "$arg" "/" "" 762315ffece8Smrg xdir=$func_dirname_result 7624f67b85aaSmrg 762515ffece8Smrg test none = "$pic_object" || { 7626a7b590b3Smrg # Prepend the subdirectory the object is found in. 762715ffece8Smrg pic_object=$xdir$pic_object 7628943345d3Smrg 762915ffece8Smrg if test dlfiles = "$prev"; then 763015ffece8Smrg if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 76313e51e026Smrg func_append dlfiles " $pic_object" 7632a7b590b3Smrg prev= 7633a7b590b3Smrg continue 7634a7b590b3Smrg else 7635a7b590b3Smrg # If libtool objects are unsupported, then we need to preload. 7636a7b590b3Smrg prev=dlprefiles 7637a7b590b3Smrg fi 7638a7b590b3Smrg fi 7639943345d3Smrg 7640a7b590b3Smrg # CHECK ME: I think I busted this. -Ossama 764115ffece8Smrg if test dlprefiles = "$prev"; then 7642a7b590b3Smrg # Preload the old-style object. 76433e51e026Smrg func_append dlprefiles " $pic_object" 7644a7b590b3Smrg prev= 7645a7b590b3Smrg fi 7646943345d3Smrg 7647a7b590b3Smrg # A PIC object. 7648a7b590b3Smrg func_append libobjs " $pic_object" 764915ffece8Smrg arg=$pic_object 765015ffece8Smrg } 7651943345d3Smrg 7652a7b590b3Smrg # Non-PIC object. 765315ffece8Smrg if test none != "$non_pic_object"; then 7654a7b590b3Smrg # Prepend the subdirectory the object is found in. 765515ffece8Smrg non_pic_object=$xdir$non_pic_object 7656943345d3Smrg 7657a7b590b3Smrg # A standard non-PIC object 7658a7b590b3Smrg func_append non_pic_objects " $non_pic_object" 765915ffece8Smrg if test -z "$pic_object" || test none = "$pic_object"; then 766015ffece8Smrg arg=$non_pic_object 7661a7b590b3Smrg fi 7662a7b590b3Smrg else 7663a7b590b3Smrg # If the PIC object exists, use it instead. 7664a7b590b3Smrg # $xdir was prepended to $pic_object above. 766515ffece8Smrg non_pic_object=$pic_object 7666a7b590b3Smrg func_append non_pic_objects " $non_pic_object" 7667a7b590b3Smrg fi 7668a7b590b3Smrg else 7669a7b590b3Smrg # Only an error if not doing a dry-run. 7670a7b590b3Smrg if $opt_dry_run; then 7671a7b590b3Smrg # Extract subdirectory from the argument. 7672a7b590b3Smrg func_dirname "$arg" "/" "" 767315ffece8Smrg xdir=$func_dirname_result 7674a7b590b3Smrg 7675a7b590b3Smrg func_lo2o "$arg" 7676a7b590b3Smrg pic_object=$xdir$objdir/$func_lo2o_result 7677a7b590b3Smrg non_pic_object=$xdir$func_lo2o_result 7678a7b590b3Smrg func_append libobjs " $pic_object" 7679a7b590b3Smrg func_append non_pic_objects " $non_pic_object" 7680a7b590b3Smrg else 768115ffece8Smrg func_fatal_error "'$arg' is not a valid libtool object" 7682a7b590b3Smrg fi 7683a7b590b3Smrg fi 7684a7b590b3Smrg ;; 7685943345d3Smrg 7686a7b590b3Smrg *.$libext) 7687a7b590b3Smrg # An archive. 76883e51e026Smrg func_append deplibs " $arg" 76893e51e026Smrg func_append old_deplibs " $arg" 7690a7b590b3Smrg continue 7691a7b590b3Smrg ;; 7692a7b590b3Smrg 7693a7b590b3Smrg *.la) 7694a7b590b3Smrg # A libtool-controlled library. 7695a7b590b3Smrg 76963e51e026Smrg func_resolve_sysroot "$arg" 769715ffece8Smrg if test dlfiles = "$prev"; then 7698a7b590b3Smrg # This library was specified with -dlopen. 76993e51e026Smrg func_append dlfiles " $func_resolve_sysroot_result" 7700a7b590b3Smrg prev= 770115ffece8Smrg elif test dlprefiles = "$prev"; then 7702a7b590b3Smrg # The library was specified with -dlpreopen. 77033e51e026Smrg func_append dlprefiles " $func_resolve_sysroot_result" 7704a7b590b3Smrg prev= 7705a7b590b3Smrg else 77063e51e026Smrg func_append deplibs " $func_resolve_sysroot_result" 7707a7b590b3Smrg fi 7708a7b590b3Smrg continue 7709a7b590b3Smrg ;; 7710a7b590b3Smrg 7711a7b590b3Smrg # Some other compiler argument. 7712a7b590b3Smrg *) 7713a7b590b3Smrg # Unknown arguments in both finalize_command and compile_command need 7714a7b590b3Smrg # to be aesthetically quoted because they are evaled later. 771515ffece8Smrg func_quote_arg pretty "$arg" 771615ffece8Smrg arg=$func_quote_arg_result 7717a7b590b3Smrg ;; 7718a7b590b3Smrg esac # arg 7719a7b590b3Smrg 7720a7b590b3Smrg # Now actually substitute the argument into the commands. 7721a7b590b3Smrg if test -n "$arg"; then 7722a7b590b3Smrg func_append compile_command " $arg" 7723a7b590b3Smrg func_append finalize_command " $arg" 7724a7b590b3Smrg fi 7725a7b590b3Smrg done # argument parsing loop 7726a7b590b3Smrg 7727a7b590b3Smrg test -n "$prev" && \ 772815ffece8Smrg func_fatal_help "the '$prevarg' option requires an argument" 7729a7b590b3Smrg 773015ffece8Smrg if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then 7731a7b590b3Smrg eval arg=\"$export_dynamic_flag_spec\" 7732a7b590b3Smrg func_append compile_command " $arg" 7733a7b590b3Smrg func_append finalize_command " $arg" 7734a7b590b3Smrg fi 7735a7b590b3Smrg 7736a7b590b3Smrg oldlibs= 7737a7b590b3Smrg # calculate the name of the file, without its directory 7738a7b590b3Smrg func_basename "$output" 773915ffece8Smrg outputname=$func_basename_result 774015ffece8Smrg libobjs_save=$libobjs 7741a7b590b3Smrg 7742a7b590b3Smrg if test -n "$shlibpath_var"; then 7743a7b590b3Smrg # get the directories listed in $shlibpath_var 774415ffece8Smrg eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\` 7745a7b590b3Smrg else 7746a7b590b3Smrg shlib_search_path= 7747a7b590b3Smrg fi 7748a7b590b3Smrg eval sys_lib_search_path=\"$sys_lib_search_path_spec\" 7749a7b590b3Smrg eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" 7750a7b590b3Smrg 775115ffece8Smrg # Definition is injected by LT_CONFIG during libtool generation. 775215ffece8Smrg func_munge_path_list sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH" 775315ffece8Smrg 7754a7b590b3Smrg func_dirname "$output" "/" "" 775515ffece8Smrg output_objdir=$func_dirname_result$objdir 77563e51e026Smrg func_to_tool_file "$output_objdir/" 77573e51e026Smrg tool_output_objdir=$func_to_tool_file_result 7758a7b590b3Smrg # Create the object directory. 7759a7b590b3Smrg func_mkdir_p "$output_objdir" 7760a7b590b3Smrg 7761a7b590b3Smrg # Determine the type of output 7762a7b590b3Smrg case $output in 7763a7b590b3Smrg "") 7764a7b590b3Smrg func_fatal_help "you must specify an output file" 7765a7b590b3Smrg ;; 7766a7b590b3Smrg *.$libext) linkmode=oldlib ;; 7767a7b590b3Smrg *.lo | *.$objext) linkmode=obj ;; 7768a7b590b3Smrg *.la) linkmode=lib ;; 7769a7b590b3Smrg *) linkmode=prog ;; # Anything else should be a program. 7770a7b590b3Smrg esac 7771a7b590b3Smrg 7772a7b590b3Smrg specialdeplibs= 7773a7b590b3Smrg 7774a7b590b3Smrg libs= 7775a7b590b3Smrg # Find all interdependent deplibs by searching for libraries 7776a7b590b3Smrg # that are linked more than once (e.g. -la -lb -la) 7777a7b590b3Smrg for deplib in $deplibs; do 777815ffece8Smrg if $opt_preserve_dup_deps; then 7779a7b590b3Smrg case "$libs " in 77803e51e026Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 7781a7b590b3Smrg esac 7782a7b590b3Smrg fi 77833e51e026Smrg func_append libs " $deplib" 7784a7b590b3Smrg done 7785a7b590b3Smrg 778615ffece8Smrg if test lib = "$linkmode"; then 7787a7b590b3Smrg libs="$predeps $libs $compiler_lib_search_path $postdeps" 7788a7b590b3Smrg 7789a7b590b3Smrg # Compute libraries that are listed more than once in $predeps 7790a7b590b3Smrg # $postdeps and mark them as special (i.e., whose duplicates are 7791a7b590b3Smrg # not to be eliminated). 7792a7b590b3Smrg pre_post_deps= 7793a7b590b3Smrg if $opt_duplicate_compiler_generated_deps; then 7794a7b590b3Smrg for pre_post_dep in $predeps $postdeps; do 7795a7b590b3Smrg case "$pre_post_deps " in 77963e51e026Smrg *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; 7797a7b590b3Smrg esac 77983e51e026Smrg func_append pre_post_deps " $pre_post_dep" 7799a7b590b3Smrg done 7800a7b590b3Smrg fi 7801a7b590b3Smrg pre_post_deps= 7802a7b590b3Smrg fi 7803a7b590b3Smrg 7804a7b590b3Smrg deplibs= 7805a7b590b3Smrg newdependency_libs= 7806a7b590b3Smrg newlib_search_path= 7807a7b590b3Smrg need_relink=no # whether we're linking any uninstalled libtool libraries 7808a7b590b3Smrg notinst_deplibs= # not-installed libtool libraries 7809a7b590b3Smrg notinst_path= # paths that contain not-installed libtool libraries 7810a7b590b3Smrg 7811a7b590b3Smrg case $linkmode in 7812a7b590b3Smrg lib) 7813a7b590b3Smrg passes="conv dlpreopen link" 7814a7b590b3Smrg for file in $dlfiles $dlprefiles; do 7815a7b590b3Smrg case $file in 7816a7b590b3Smrg *.la) ;; 7817a7b590b3Smrg *) 781815ffece8Smrg func_fatal_help "libraries can '-dlopen' only libtool libraries: $file" 7819a7b590b3Smrg ;; 7820a7b590b3Smrg esac 7821a7b590b3Smrg done 7822a7b590b3Smrg ;; 7823a7b590b3Smrg prog) 7824a7b590b3Smrg compile_deplibs= 7825a7b590b3Smrg finalize_deplibs= 782615ffece8Smrg alldeplibs=false 7827a7b590b3Smrg newdlfiles= 7828a7b590b3Smrg newdlprefiles= 7829a7b590b3Smrg passes="conv scan dlopen dlpreopen link" 7830a7b590b3Smrg ;; 7831a7b590b3Smrg *) passes="conv" 7832a7b590b3Smrg ;; 7833a7b590b3Smrg esac 7834a7b590b3Smrg 7835a7b590b3Smrg for pass in $passes; do 7836a7b590b3Smrg # The preopen pass in lib mode reverses $deplibs; put it back here 7837a7b590b3Smrg # so that -L comes before libs that need it for instance... 783815ffece8Smrg if test lib,link = "$linkmode,$pass"; then 7839a7b590b3Smrg ## FIXME: Find the place where the list is rebuilt in the wrong 7840a7b590b3Smrg ## order, and fix it there properly 7841a7b590b3Smrg tmp_deplibs= 7842a7b590b3Smrg for deplib in $deplibs; do 7843a7b590b3Smrg tmp_deplibs="$deplib $tmp_deplibs" 7844a7b590b3Smrg done 784515ffece8Smrg deplibs=$tmp_deplibs 7846a7b590b3Smrg fi 7847a7b590b3Smrg 784815ffece8Smrg if test lib,link = "$linkmode,$pass" || 784915ffece8Smrg test prog,scan = "$linkmode,$pass"; then 785015ffece8Smrg libs=$deplibs 7851a7b590b3Smrg deplibs= 7852a7b590b3Smrg fi 785315ffece8Smrg if test prog = "$linkmode"; then 7854a7b590b3Smrg case $pass in 785515ffece8Smrg dlopen) libs=$dlfiles ;; 785615ffece8Smrg dlpreopen) libs=$dlprefiles ;; 7857a7b590b3Smrg link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; 7858a7b590b3Smrg esac 7859a7b590b3Smrg fi 786015ffece8Smrg if test lib,dlpreopen = "$linkmode,$pass"; then 7861a7b590b3Smrg # Collect and forward deplibs of preopened libtool libs 7862a7b590b3Smrg for lib in $dlprefiles; do 7863a7b590b3Smrg # Ignore non-libtool-libs 7864a7b590b3Smrg dependency_libs= 78653e51e026Smrg func_resolve_sysroot "$lib" 7866a7b590b3Smrg case $lib in 78673e51e026Smrg *.la) func_source "$func_resolve_sysroot_result" ;; 7868a7b590b3Smrg esac 7869a7b590b3Smrg 7870a7b590b3Smrg # Collect preopened libtool deplibs, except any this library 7871a7b590b3Smrg # has declared as weak libs 7872a7b590b3Smrg for deplib in $dependency_libs; do 78733e51e026Smrg func_basename "$deplib" 78743e51e026Smrg deplib_base=$func_basename_result 7875a7b590b3Smrg case " $weak_libs " in 7876a7b590b3Smrg *" $deplib_base "*) ;; 78773e51e026Smrg *) func_append deplibs " $deplib" ;; 7878a7b590b3Smrg esac 7879a7b590b3Smrg done 7880a7b590b3Smrg done 788115ffece8Smrg libs=$dlprefiles 7882a7b590b3Smrg fi 788315ffece8Smrg if test dlopen = "$pass"; then 7884a7b590b3Smrg # Collect dlpreopened libraries 788515ffece8Smrg save_deplibs=$deplibs 7886a7b590b3Smrg deplibs= 7887a7b590b3Smrg fi 7888a7b590b3Smrg 7889a7b590b3Smrg for deplib in $libs; do 7890a7b590b3Smrg lib= 789115ffece8Smrg found=false 7892a7b590b3Smrg case $deplib in 78933e51e026Smrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 78943e51e026Smrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 789515ffece8Smrg if test prog,link = "$linkmode,$pass"; then 7896a7b590b3Smrg compile_deplibs="$deplib $compile_deplibs" 7897a7b590b3Smrg finalize_deplibs="$deplib $finalize_deplibs" 7898a7b590b3Smrg else 78993e51e026Smrg func_append compiler_flags " $deplib" 790015ffece8Smrg if test lib = "$linkmode"; then 7901a7b590b3Smrg case "$new_inherited_linker_flags " in 7902a7b590b3Smrg *" $deplib "*) ;; 79033e51e026Smrg * ) func_append new_inherited_linker_flags " $deplib" ;; 7904a7b590b3Smrg esac 7905a7b590b3Smrg fi 7906a7b590b3Smrg fi 7907a7b590b3Smrg continue 7908a7b590b3Smrg ;; 7909a7b590b3Smrg -l*) 791015ffece8Smrg if test lib != "$linkmode" && test prog != "$linkmode"; then 791115ffece8Smrg func_warning "'-l' is ignored for archives/objects" 7912a7b590b3Smrg continue 7913a7b590b3Smrg fi 7914a7b590b3Smrg func_stripname '-l' '' "$deplib" 7915a7b590b3Smrg name=$func_stripname_result 791615ffece8Smrg if test lib = "$linkmode"; then 7917a7b590b3Smrg searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" 7918a7b590b3Smrg else 7919a7b590b3Smrg searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" 7920a7b590b3Smrg fi 7921a7b590b3Smrg for searchdir in $searchdirs; do 7922a7b590b3Smrg for search_ext in .la $std_shrext .so .a; do 7923a7b590b3Smrg # Search the libtool library 792415ffece8Smrg lib=$searchdir/lib$name$search_ext 7925a7b590b3Smrg if test -f "$lib"; then 792615ffece8Smrg if test .la = "$search_ext"; then 792715ffece8Smrg found=: 7928a7b590b3Smrg else 792915ffece8Smrg found=false 7930a7b590b3Smrg fi 7931a7b590b3Smrg break 2 7932a7b590b3Smrg fi 7933a7b590b3Smrg done 7934a7b590b3Smrg done 793515ffece8Smrg if $found; then 793615ffece8Smrg # deplib is a libtool library 7937a7b590b3Smrg # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, 7938a7b590b3Smrg # We need to do some special things here, and not later. 793915ffece8Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 7940a7b590b3Smrg case " $predeps $postdeps " in 7941a7b590b3Smrg *" $deplib "*) 7942a7b590b3Smrg if func_lalib_p "$lib"; then 7943a7b590b3Smrg library_names= 7944a7b590b3Smrg old_library= 7945a7b590b3Smrg func_source "$lib" 7946a7b590b3Smrg for l in $old_library $library_names; do 794715ffece8Smrg ll=$l 7948a7b590b3Smrg done 794915ffece8Smrg if test "X$ll" = "X$old_library"; then # only static version available 795015ffece8Smrg found=false 7951a7b590b3Smrg func_dirname "$lib" "" "." 795215ffece8Smrg ladir=$func_dirname_result 7953a7b590b3Smrg lib=$ladir/$old_library 795415ffece8Smrg if test prog,link = "$linkmode,$pass"; then 7955a7b590b3Smrg compile_deplibs="$deplib $compile_deplibs" 7956a7b590b3Smrg finalize_deplibs="$deplib $finalize_deplibs" 7957a7b590b3Smrg else 7958a7b590b3Smrg deplibs="$deplib $deplibs" 795915ffece8Smrg test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 7960a7b590b3Smrg fi 7961a7b590b3Smrg continue 7962a7b590b3Smrg fi 7963a7b590b3Smrg fi 7964a7b590b3Smrg ;; 7965a7b590b3Smrg *) ;; 7966a7b590b3Smrg esac 7967a7b590b3Smrg fi 796815ffece8Smrg else 796915ffece8Smrg # deplib doesn't seem to be a libtool library 797015ffece8Smrg if test prog,link = "$linkmode,$pass"; then 797115ffece8Smrg compile_deplibs="$deplib $compile_deplibs" 797215ffece8Smrg finalize_deplibs="$deplib $finalize_deplibs" 797315ffece8Smrg else 797415ffece8Smrg deplibs="$deplib $deplibs" 797515ffece8Smrg test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 797615ffece8Smrg fi 797715ffece8Smrg continue 7978a7b590b3Smrg fi 7979a7b590b3Smrg ;; # -l 7980a7b590b3Smrg *.ltframework) 798115ffece8Smrg if test prog,link = "$linkmode,$pass"; then 7982a7b590b3Smrg compile_deplibs="$deplib $compile_deplibs" 7983a7b590b3Smrg finalize_deplibs="$deplib $finalize_deplibs" 7984a7b590b3Smrg else 7985a7b590b3Smrg deplibs="$deplib $deplibs" 798615ffece8Smrg if test lib = "$linkmode"; then 7987a7b590b3Smrg case "$new_inherited_linker_flags " in 7988a7b590b3Smrg *" $deplib "*) ;; 79893e51e026Smrg * ) func_append new_inherited_linker_flags " $deplib" ;; 7990a7b590b3Smrg esac 7991a7b590b3Smrg fi 7992a7b590b3Smrg fi 7993a7b590b3Smrg continue 7994a7b590b3Smrg ;; 7995a7b590b3Smrg -L*) 7996a7b590b3Smrg case $linkmode in 7997a7b590b3Smrg lib) 7998a7b590b3Smrg deplibs="$deplib $deplibs" 799915ffece8Smrg test conv = "$pass" && continue 8000a7b590b3Smrg newdependency_libs="$deplib $newdependency_libs" 8001a7b590b3Smrg func_stripname '-L' '' "$deplib" 80023e51e026Smrg func_resolve_sysroot "$func_stripname_result" 80033e51e026Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 8004a7b590b3Smrg ;; 8005a7b590b3Smrg prog) 800615ffece8Smrg if test conv = "$pass"; then 8007a7b590b3Smrg deplibs="$deplib $deplibs" 8008a7b590b3Smrg continue 8009a7b590b3Smrg fi 801015ffece8Smrg if test scan = "$pass"; then 8011a7b590b3Smrg deplibs="$deplib $deplibs" 8012a7b590b3Smrg else 8013a7b590b3Smrg compile_deplibs="$deplib $compile_deplibs" 8014a7b590b3Smrg finalize_deplibs="$deplib $finalize_deplibs" 8015a7b590b3Smrg fi 8016a7b590b3Smrg func_stripname '-L' '' "$deplib" 80173e51e026Smrg func_resolve_sysroot "$func_stripname_result" 80183e51e026Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 8019a7b590b3Smrg ;; 8020a7b590b3Smrg *) 802115ffece8Smrg func_warning "'-L' is ignored for archives/objects" 8022a7b590b3Smrg ;; 8023a7b590b3Smrg esac # linkmode 8024a7b590b3Smrg continue 8025a7b590b3Smrg ;; # -L 8026a7b590b3Smrg -R*) 802715ffece8Smrg if test link = "$pass"; then 8028a7b590b3Smrg func_stripname '-R' '' "$deplib" 80293e51e026Smrg func_resolve_sysroot "$func_stripname_result" 80303e51e026Smrg dir=$func_resolve_sysroot_result 8031a7b590b3Smrg # Make sure the xrpath contains only unique directories. 8032a7b590b3Smrg case "$xrpath " in 8033a7b590b3Smrg *" $dir "*) ;; 80343e51e026Smrg *) func_append xrpath " $dir" ;; 8035a7b590b3Smrg esac 8036a7b590b3Smrg fi 8037a7b590b3Smrg deplibs="$deplib $deplibs" 8038a7b590b3Smrg continue 8039a7b590b3Smrg ;; 80403e51e026Smrg *.la) 80413e51e026Smrg func_resolve_sysroot "$deplib" 80423e51e026Smrg lib=$func_resolve_sysroot_result 80433e51e026Smrg ;; 8044a7b590b3Smrg *.$libext) 804515ffece8Smrg if test conv = "$pass"; then 8046a7b590b3Smrg deplibs="$deplib $deplibs" 8047a7b590b3Smrg continue 8048a7b590b3Smrg fi 8049a7b590b3Smrg case $linkmode in 8050a7b590b3Smrg lib) 8051a7b590b3Smrg # Linking convenience modules into shared libraries is allowed, 8052a7b590b3Smrg # but linking other static libraries is non-portable. 8053a7b590b3Smrg case " $dlpreconveniencelibs " in 8054a7b590b3Smrg *" $deplib "*) ;; 8055a7b590b3Smrg *) 805615ffece8Smrg valid_a_lib=false 8057a7b590b3Smrg case $deplibs_check_method in 8058a7b590b3Smrg match_pattern*) 8059a7b590b3Smrg set dummy $deplibs_check_method; shift 8060a7b590b3Smrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 80613e51e026Smrg if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ 8062a7b590b3Smrg | $EGREP "$match_pattern_regex" > /dev/null; then 806315ffece8Smrg valid_a_lib=: 8064a7b590b3Smrg fi 8065a7b590b3Smrg ;; 8066a7b590b3Smrg pass_all) 806715ffece8Smrg valid_a_lib=: 8068a7b590b3Smrg ;; 8069a7b590b3Smrg esac 807015ffece8Smrg if $valid_a_lib; then 807115ffece8Smrg echo 807215ffece8Smrg $ECHO "*** Warning: Linking the shared library $output against the" 807315ffece8Smrg $ECHO "*** static library $deplib is not portable!" 807415ffece8Smrg deplibs="$deplib $deplibs" 807515ffece8Smrg else 80763e51e026Smrg echo 8077a7b590b3Smrg $ECHO "*** Warning: Trying to link with static lib archive $deplib." 80783e51e026Smrg echo "*** I have the capability to make that library automatically link in when" 80793e51e026Smrg echo "*** you link to this library. But I can only do this if you have a" 80803e51e026Smrg echo "*** shared version of the library, which you do not appear to have" 80813e51e026Smrg echo "*** because the file extensions .$libext of this argument makes me believe" 80823e51e026Smrg echo "*** that it is just a static archive that I should not use here." 8083a7b590b3Smrg fi 8084a7b590b3Smrg ;; 8085a7b590b3Smrg esac 8086a7b590b3Smrg continue 8087a7b590b3Smrg ;; 8088a7b590b3Smrg prog) 808915ffece8Smrg if test link != "$pass"; then 8090a7b590b3Smrg deplibs="$deplib $deplibs" 8091a7b590b3Smrg else 8092a7b590b3Smrg compile_deplibs="$deplib $compile_deplibs" 8093a7b590b3Smrg finalize_deplibs="$deplib $finalize_deplibs" 8094a7b590b3Smrg fi 8095a7b590b3Smrg continue 8096a7b590b3Smrg ;; 8097a7b590b3Smrg esac # linkmode 8098a7b590b3Smrg ;; # *.$libext 8099a7b590b3Smrg *.lo | *.$objext) 810015ffece8Smrg if test conv = "$pass"; then 8101a7b590b3Smrg deplibs="$deplib $deplibs" 810215ffece8Smrg elif test prog = "$linkmode"; then 810315ffece8Smrg if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then 8104a7b590b3Smrg # If there is no dlopen support or we're linking statically, 8105a7b590b3Smrg # we need to preload. 81063e51e026Smrg func_append newdlprefiles " $deplib" 8107a7b590b3Smrg compile_deplibs="$deplib $compile_deplibs" 8108a7b590b3Smrg finalize_deplibs="$deplib $finalize_deplibs" 8109a7b590b3Smrg else 81103e51e026Smrg func_append newdlfiles " $deplib" 8111a7b590b3Smrg fi 8112a7b590b3Smrg fi 8113a7b590b3Smrg continue 8114a7b590b3Smrg ;; 8115a7b590b3Smrg %DEPLIBS%) 811615ffece8Smrg alldeplibs=: 8117a7b590b3Smrg continue 8118a7b590b3Smrg ;; 8119a7b590b3Smrg esac # case $deplib 8120a7b590b3Smrg 812115ffece8Smrg $found || test -f "$lib" \ 812215ffece8Smrg || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'" 8123a7b590b3Smrg 8124a7b590b3Smrg # Check to see that this really is a libtool archive. 8125a7b590b3Smrg func_lalib_unsafe_p "$lib" \ 812615ffece8Smrg || func_fatal_error "'$lib' is not a valid libtool archive" 8127a7b590b3Smrg 8128a7b590b3Smrg func_dirname "$lib" "" "." 812915ffece8Smrg ladir=$func_dirname_result 8130a7b590b3Smrg 8131a7b590b3Smrg dlname= 8132a7b590b3Smrg dlopen= 8133a7b590b3Smrg dlpreopen= 8134a7b590b3Smrg libdir= 8135a7b590b3Smrg library_names= 8136a7b590b3Smrg old_library= 8137a7b590b3Smrg inherited_linker_flags= 8138a7b590b3Smrg # If the library was installed with an old release of libtool, 8139a7b590b3Smrg # it will not redefine variables installed, or shouldnotlink 8140a7b590b3Smrg installed=yes 8141a7b590b3Smrg shouldnotlink=no 8142a7b590b3Smrg avoidtemprpath= 8143a7b590b3Smrg 8144a7b590b3Smrg 8145a7b590b3Smrg # Read the .la file 8146a7b590b3Smrg func_source "$lib" 8147a7b590b3Smrg 8148a7b590b3Smrg # Convert "-framework foo" to "foo.ltframework" 8149a7b590b3Smrg if test -n "$inherited_linker_flags"; then 81503e51e026Smrg tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` 8151a7b590b3Smrg for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do 8152a7b590b3Smrg case " $new_inherited_linker_flags " in 8153a7b590b3Smrg *" $tmp_inherited_linker_flag "*) ;; 81543e51e026Smrg *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; 8155a7b590b3Smrg esac 8156a7b590b3Smrg done 8157a7b590b3Smrg fi 81583e51e026Smrg dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 815915ffece8Smrg if test lib,link = "$linkmode,$pass" || 816015ffece8Smrg test prog,scan = "$linkmode,$pass" || 816115ffece8Smrg { test prog != "$linkmode" && test lib != "$linkmode"; }; then 81623e51e026Smrg test -n "$dlopen" && func_append dlfiles " $dlopen" 81633e51e026Smrg test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" 8164a7b590b3Smrg fi 8165a7b590b3Smrg 816615ffece8Smrg if test conv = "$pass"; then 8167a7b590b3Smrg # Only check for convenience libraries 8168a7b590b3Smrg deplibs="$lib $deplibs" 8169a7b590b3Smrg if test -z "$libdir"; then 8170a7b590b3Smrg if test -z "$old_library"; then 817115ffece8Smrg func_fatal_error "cannot find name of link library for '$lib'" 8172a7b590b3Smrg fi 8173a7b590b3Smrg # It is a libtool convenience library, so add in its objects. 81743e51e026Smrg func_append convenience " $ladir/$objdir/$old_library" 81753e51e026Smrg func_append old_convenience " $ladir/$objdir/$old_library" 817615ffece8Smrg elif test prog != "$linkmode" && test lib != "$linkmode"; then 817715ffece8Smrg func_fatal_error "'$lib' is not a convenience library" 8178a7b590b3Smrg fi 8179a7b590b3Smrg tmp_libs= 8180a7b590b3Smrg for deplib in $dependency_libs; do 8181a7b590b3Smrg deplibs="$deplib $deplibs" 818215ffece8Smrg if $opt_preserve_dup_deps; then 8183a7b590b3Smrg case "$tmp_libs " in 81843e51e026Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 8185a7b590b3Smrg esac 8186a7b590b3Smrg fi 81873e51e026Smrg func_append tmp_libs " $deplib" 8188a7b590b3Smrg done 8189a7b590b3Smrg continue 8190a7b590b3Smrg fi # $pass = conv 8191a7b590b3Smrg 8192a7b590b3Smrg 8193a7b590b3Smrg # Get the name of the library we link against. 8194a7b590b3Smrg linklib= 81953e51e026Smrg if test -n "$old_library" && 819615ffece8Smrg { test yes = "$prefer_static_libs" || 819715ffece8Smrg test built,no = "$prefer_static_libs,$installed"; }; then 81983e51e026Smrg linklib=$old_library 81993e51e026Smrg else 82003e51e026Smrg for l in $old_library $library_names; do 820115ffece8Smrg linklib=$l 82023e51e026Smrg done 82033e51e026Smrg fi 8204a7b590b3Smrg if test -z "$linklib"; then 820515ffece8Smrg func_fatal_error "cannot find name of link library for '$lib'" 8206a7b590b3Smrg fi 8207a7b590b3Smrg 8208a7b590b3Smrg # This library was specified with -dlopen. 820915ffece8Smrg if test dlopen = "$pass"; then 821015ffece8Smrg test -z "$libdir" \ 821115ffece8Smrg && func_fatal_error "cannot -dlopen a convenience library: '$lib'" 8212a7b590b3Smrg if test -z "$dlname" || 821315ffece8Smrg test yes != "$dlopen_support" || 821415ffece8Smrg test no = "$build_libtool_libs" 821515ffece8Smrg then 8216a7b590b3Smrg # If there is no dlname, no dlopen support or we're linking 8217a7b590b3Smrg # statically, we need to preload. We also need to preload any 8218a7b590b3Smrg # dependent libraries so libltdl's deplib preloader doesn't 8219a7b590b3Smrg # bomb out in the load deplibs phase. 82203e51e026Smrg func_append dlprefiles " $lib $dependency_libs" 8221a7b590b3Smrg else 82223e51e026Smrg func_append newdlfiles " $lib" 8223a7b590b3Smrg fi 8224a7b590b3Smrg continue 8225a7b590b3Smrg fi # $pass = dlopen 8226a7b590b3Smrg 8227a7b590b3Smrg # We need an absolute path. 8228a7b590b3Smrg case $ladir in 822915ffece8Smrg [\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;; 8230a7b590b3Smrg *) 8231a7b590b3Smrg abs_ladir=`cd "$ladir" && pwd` 8232a7b590b3Smrg if test -z "$abs_ladir"; then 823315ffece8Smrg func_warning "cannot determine absolute directory name of '$ladir'" 8234a7b590b3Smrg func_warning "passing it literally to the linker, although it might fail" 823515ffece8Smrg abs_ladir=$ladir 8236a7b590b3Smrg fi 8237a7b590b3Smrg ;; 8238a7b590b3Smrg esac 8239a7b590b3Smrg func_basename "$lib" 824015ffece8Smrg laname=$func_basename_result 8241a7b590b3Smrg 8242a7b590b3Smrg # Find the relevant object directory and library name. 824315ffece8Smrg if test yes = "$installed"; then 82443e51e026Smrg if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then 824515ffece8Smrg func_warning "library '$lib' was moved." 824615ffece8Smrg dir=$ladir 824715ffece8Smrg absdir=$abs_ladir 824815ffece8Smrg libdir=$abs_ladir 8249a7b590b3Smrg else 825015ffece8Smrg dir=$lt_sysroot$libdir 825115ffece8Smrg absdir=$lt_sysroot$libdir 8252a7b590b3Smrg fi 825315ffece8Smrg test yes = "$hardcode_automatic" && avoidtemprpath=yes 8254a7b590b3Smrg else 8255a7b590b3Smrg if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then 825615ffece8Smrg dir=$ladir 825715ffece8Smrg absdir=$abs_ladir 8258a7b590b3Smrg # Remove this search path later 82593e51e026Smrg func_append notinst_path " $abs_ladir" 8260a7b590b3Smrg else 826115ffece8Smrg dir=$ladir/$objdir 826215ffece8Smrg absdir=$abs_ladir/$objdir 8263a7b590b3Smrg # Remove this search path later 82643e51e026Smrg func_append notinst_path " $abs_ladir" 8265a7b590b3Smrg fi 8266a7b590b3Smrg fi # $installed = yes 8267a7b590b3Smrg func_stripname 'lib' '.la' "$laname" 8268a7b590b3Smrg name=$func_stripname_result 8269a7b590b3Smrg 8270a7b590b3Smrg # This library was specified with -dlpreopen. 827115ffece8Smrg if test dlpreopen = "$pass"; then 827215ffece8Smrg if test -z "$libdir" && test prog = "$linkmode"; then 827315ffece8Smrg func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'" 8274a7b590b3Smrg fi 827515ffece8Smrg case $host in 82763e51e026Smrg # special handling for platforms with PE-DLLs. 82773e51e026Smrg *cygwin* | *mingw* | *cegcc* ) 82783e51e026Smrg # Linker will automatically link against shared library if both 82793e51e026Smrg # static and shared are present. Therefore, ensure we extract 82803e51e026Smrg # symbols from the import library if a shared library is present 82813e51e026Smrg # (otherwise, the dlopen module name will be incorrect). We do 82823e51e026Smrg # this by putting the import library name into $newdlprefiles. 82833e51e026Smrg # We recover the dlopen module name by 'saving' the la file 82843e51e026Smrg # name in a special purpose variable, and (later) extracting the 82853e51e026Smrg # dlname from the la file. 82863e51e026Smrg if test -n "$dlname"; then 82873e51e026Smrg func_tr_sh "$dir/$linklib" 82883e51e026Smrg eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" 82893e51e026Smrg func_append newdlprefiles " $dir/$linklib" 82903e51e026Smrg else 82913e51e026Smrg func_append newdlprefiles " $dir/$old_library" 82923e51e026Smrg # Keep a list of preopened convenience libraries to check 82933e51e026Smrg # that they are being used correctly in the link pass. 82943e51e026Smrg test -z "$libdir" && \ 82953e51e026Smrg func_append dlpreconveniencelibs " $dir/$old_library" 82963e51e026Smrg fi 82973e51e026Smrg ;; 82983e51e026Smrg * ) 82993e51e026Smrg # Prefer using a static library (so that no silly _DYNAMIC symbols 83003e51e026Smrg # are required to link). 83013e51e026Smrg if test -n "$old_library"; then 83023e51e026Smrg func_append newdlprefiles " $dir/$old_library" 83033e51e026Smrg # Keep a list of preopened convenience libraries to check 83043e51e026Smrg # that they are being used correctly in the link pass. 83053e51e026Smrg test -z "$libdir" && \ 83063e51e026Smrg func_append dlpreconveniencelibs " $dir/$old_library" 83073e51e026Smrg # Otherwise, use the dlname, so that lt_dlopen finds it. 83083e51e026Smrg elif test -n "$dlname"; then 83093e51e026Smrg func_append newdlprefiles " $dir/$dlname" 83103e51e026Smrg else 83113e51e026Smrg func_append newdlprefiles " $dir/$linklib" 83123e51e026Smrg fi 83133e51e026Smrg ;; 83143e51e026Smrg esac 8315a7b590b3Smrg fi # $pass = dlpreopen 8316a7b590b3Smrg 8317a7b590b3Smrg if test -z "$libdir"; then 8318a7b590b3Smrg # Link the convenience library 831915ffece8Smrg if test lib = "$linkmode"; then 8320a7b590b3Smrg deplibs="$dir/$old_library $deplibs" 832115ffece8Smrg elif test prog,link = "$linkmode,$pass"; then 8322a7b590b3Smrg compile_deplibs="$dir/$old_library $compile_deplibs" 8323a7b590b3Smrg finalize_deplibs="$dir/$old_library $finalize_deplibs" 8324a7b590b3Smrg else 8325a7b590b3Smrg deplibs="$lib $deplibs" # used for prog,scan pass 8326a7b590b3Smrg fi 8327a7b590b3Smrg continue 8328a7b590b3Smrg fi 8329a7b590b3Smrg 8330a7b590b3Smrg 833115ffece8Smrg if test prog = "$linkmode" && test link != "$pass"; then 83323e51e026Smrg func_append newlib_search_path " $ladir" 8333a7b590b3Smrg deplibs="$lib $deplibs" 8334a7b590b3Smrg 833515ffece8Smrg linkalldeplibs=false 833615ffece8Smrg if test no != "$link_all_deplibs" || test -z "$library_names" || 833715ffece8Smrg test no = "$build_libtool_libs"; then 833815ffece8Smrg linkalldeplibs=: 8339a7b590b3Smrg fi 8340a7b590b3Smrg 8341a7b590b3Smrg tmp_libs= 8342a7b590b3Smrg for deplib in $dependency_libs; do 8343a7b590b3Smrg case $deplib in 8344a7b590b3Smrg -L*) func_stripname '-L' '' "$deplib" 83453e51e026Smrg func_resolve_sysroot "$func_stripname_result" 83463e51e026Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 8347a7b590b3Smrg ;; 8348a7b590b3Smrg esac 8349a7b590b3Smrg # Need to link against all dependency_libs? 835015ffece8Smrg if $linkalldeplibs; then 8351a7b590b3Smrg deplibs="$deplib $deplibs" 8352a7b590b3Smrg else 8353a7b590b3Smrg # Need to hardcode shared library paths 8354a7b590b3Smrg # or/and link against static libraries 8355a7b590b3Smrg newdependency_libs="$deplib $newdependency_libs" 8356a7b590b3Smrg fi 835715ffece8Smrg if $opt_preserve_dup_deps; then 8358a7b590b3Smrg case "$tmp_libs " in 83593e51e026Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 8360a7b590b3Smrg esac 8361a7b590b3Smrg fi 83623e51e026Smrg func_append tmp_libs " $deplib" 8363a7b590b3Smrg done # for deplib 8364a7b590b3Smrg continue 8365a7b590b3Smrg fi # $linkmode = prog... 8366a7b590b3Smrg 836715ffece8Smrg if test prog,link = "$linkmode,$pass"; then 8368a7b590b3Smrg if test -n "$library_names" && 836915ffece8Smrg { { test no = "$prefer_static_libs" || 837015ffece8Smrg test built,yes = "$prefer_static_libs,$installed"; } || 8371a7b590b3Smrg test -z "$old_library"; }; then 8372a7b590b3Smrg # We need to hardcode the library path 837315ffece8Smrg if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then 8374a7b590b3Smrg # Make sure the rpath contains only unique directories. 837515ffece8Smrg case $temp_rpath: in 8376a7b590b3Smrg *"$absdir:"*) ;; 83773e51e026Smrg *) func_append temp_rpath "$absdir:" ;; 8378a7b590b3Smrg esac 8379a7b590b3Smrg fi 8380a7b590b3Smrg 8381a7b590b3Smrg # Hardcode the library path. 8382a7b590b3Smrg # Skip directories that are in the system default run-time 8383a7b590b3Smrg # search path. 8384a7b590b3Smrg case " $sys_lib_dlsearch_path " in 8385a7b590b3Smrg *" $absdir "*) ;; 8386a7b590b3Smrg *) 8387a7b590b3Smrg case "$compile_rpath " in 8388a7b590b3Smrg *" $absdir "*) ;; 83893e51e026Smrg *) func_append compile_rpath " $absdir" ;; 8390a7b590b3Smrg esac 8391a7b590b3Smrg ;; 8392a7b590b3Smrg esac 8393a7b590b3Smrg case " $sys_lib_dlsearch_path " in 8394a7b590b3Smrg *" $libdir "*) ;; 8395a7b590b3Smrg *) 8396a7b590b3Smrg case "$finalize_rpath " in 8397a7b590b3Smrg *" $libdir "*) ;; 83983e51e026Smrg *) func_append finalize_rpath " $libdir" ;; 8399a7b590b3Smrg esac 8400a7b590b3Smrg ;; 8401a7b590b3Smrg esac 8402a7b590b3Smrg fi # $linkmode,$pass = prog,link... 8403a7b590b3Smrg 840415ffece8Smrg if $alldeplibs && 840515ffece8Smrg { test pass_all = "$deplibs_check_method" || 840615ffece8Smrg { test yes = "$build_libtool_libs" && 8407a7b590b3Smrg test -n "$library_names"; }; }; then 8408a7b590b3Smrg # We only need to search for static libraries 8409a7b590b3Smrg continue 8410a7b590b3Smrg fi 8411a7b590b3Smrg fi 8412a7b590b3Smrg 8413a7b590b3Smrg link_static=no # Whether the deplib will be linked statically 8414a7b590b3Smrg use_static_libs=$prefer_static_libs 841515ffece8Smrg if test built = "$use_static_libs" && test yes = "$installed"; then 8416a7b590b3Smrg use_static_libs=no 8417a7b590b3Smrg fi 8418a7b590b3Smrg if test -n "$library_names" && 841915ffece8Smrg { test no = "$use_static_libs" || test -z "$old_library"; }; then 8420a7b590b3Smrg case $host in 842115ffece8Smrg *cygwin* | *mingw* | *cegcc* | *os2*) 8422a7b590b3Smrg # No point in relinking DLLs because paths are not encoded 84233e51e026Smrg func_append notinst_deplibs " $lib" 8424a7b590b3Smrg need_relink=no 8425a7b590b3Smrg ;; 8426a7b590b3Smrg *) 842715ffece8Smrg if test no = "$installed"; then 84283e51e026Smrg func_append notinst_deplibs " $lib" 8429a7b590b3Smrg need_relink=yes 8430a7b590b3Smrg fi 8431a7b590b3Smrg ;; 8432a7b590b3Smrg esac 8433a7b590b3Smrg # This is a shared library 8434a7b590b3Smrg 8435a7b590b3Smrg # Warn about portability, can't link against -module's on some 8436a7b590b3Smrg # systems (darwin). Don't bleat about dlopened modules though! 843715ffece8Smrg dlopenmodule= 8438a7b590b3Smrg for dlpremoduletest in $dlprefiles; do 8439a7b590b3Smrg if test "X$dlpremoduletest" = "X$lib"; then 844015ffece8Smrg dlopenmodule=$dlpremoduletest 8441a7b590b3Smrg break 8442a7b590b3Smrg fi 8443a7b590b3Smrg done 844415ffece8Smrg if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then 84453e51e026Smrg echo 844615ffece8Smrg if test prog = "$linkmode"; then 8447a7b590b3Smrg $ECHO "*** Warning: Linking the executable $output against the loadable module" 8448a7b590b3Smrg else 8449a7b590b3Smrg $ECHO "*** Warning: Linking the shared library $output against the loadable module" 8450a7b590b3Smrg fi 8451a7b590b3Smrg $ECHO "*** $linklib is not portable!" 8452a7b590b3Smrg fi 845315ffece8Smrg if test lib = "$linkmode" && 845415ffece8Smrg test yes = "$hardcode_into_libs"; then 8455a7b590b3Smrg # Hardcode the library path. 8456a7b590b3Smrg # Skip directories that are in the system default run-time 8457a7b590b3Smrg # search path. 8458a7b590b3Smrg case " $sys_lib_dlsearch_path " in 8459a7b590b3Smrg *" $absdir "*) ;; 8460a7b590b3Smrg *) 8461a7b590b3Smrg case "$compile_rpath " in 8462a7b590b3Smrg *" $absdir "*) ;; 84633e51e026Smrg *) func_append compile_rpath " $absdir" ;; 8464a7b590b3Smrg esac 8465a7b590b3Smrg ;; 8466a7b590b3Smrg esac 8467a7b590b3Smrg case " $sys_lib_dlsearch_path " in 8468a7b590b3Smrg *" $libdir "*) ;; 8469a7b590b3Smrg *) 8470a7b590b3Smrg case "$finalize_rpath " in 8471a7b590b3Smrg *" $libdir "*) ;; 84723e51e026Smrg *) func_append finalize_rpath " $libdir" ;; 8473a7b590b3Smrg esac 8474a7b590b3Smrg ;; 8475a7b590b3Smrg esac 8476a7b590b3Smrg fi 8477a7b590b3Smrg 8478a7b590b3Smrg if test -n "$old_archive_from_expsyms_cmds"; then 8479a7b590b3Smrg # figure out the soname 8480a7b590b3Smrg set dummy $library_names 8481a7b590b3Smrg shift 848215ffece8Smrg realname=$1 8483a7b590b3Smrg shift 8484a7b590b3Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 8485a7b590b3Smrg # use dlname if we got it. it's perfectly good, no? 8486a7b590b3Smrg if test -n "$dlname"; then 848715ffece8Smrg soname=$dlname 8488a7b590b3Smrg elif test -n "$soname_spec"; then 8489a7b590b3Smrg # bleh windows 8490a7b590b3Smrg case $host in 849115ffece8Smrg *cygwin* | mingw* | *cegcc* | *os2*) 8492a7b590b3Smrg func_arith $current - $age 8493a7b590b3Smrg major=$func_arith_result 849415ffece8Smrg versuffix=-$major 8495a7b590b3Smrg ;; 8496a7b590b3Smrg esac 8497a7b590b3Smrg eval soname=\"$soname_spec\" 8498a7b590b3Smrg else 849915ffece8Smrg soname=$realname 8500a7b590b3Smrg fi 8501a7b590b3Smrg 8502a7b590b3Smrg # Make a new name for the extract_expsyms_cmds to use 850315ffece8Smrg soroot=$soname 8504a7b590b3Smrg func_basename "$soroot" 850515ffece8Smrg soname=$func_basename_result 8506a7b590b3Smrg func_stripname 'lib' '.dll' "$soname" 8507a7b590b3Smrg newlib=libimp-$func_stripname_result.a 8508a7b590b3Smrg 8509a7b590b3Smrg # If the library has no export list, then create one now 8510a7b590b3Smrg if test -f "$output_objdir/$soname-def"; then : 8511a7b590b3Smrg else 851215ffece8Smrg func_verbose "extracting exported symbol list from '$soname'" 8513a7b590b3Smrg func_execute_cmds "$extract_expsyms_cmds" 'exit $?' 8514a7b590b3Smrg fi 8515a7b590b3Smrg 8516a7b590b3Smrg # Create $newlib 8517a7b590b3Smrg if test -f "$output_objdir/$newlib"; then :; else 851815ffece8Smrg func_verbose "generating import library for '$soname'" 8519a7b590b3Smrg func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' 8520a7b590b3Smrg fi 8521a7b590b3Smrg # make sure the library variables are pointing to the new library 8522a7b590b3Smrg dir=$output_objdir 8523a7b590b3Smrg linklib=$newlib 8524a7b590b3Smrg fi # test -n "$old_archive_from_expsyms_cmds" 8525a7b590b3Smrg 852615ffece8Smrg if test prog = "$linkmode" || test relink != "$opt_mode"; then 8527a7b590b3Smrg add_shlibpath= 8528a7b590b3Smrg add_dir= 8529a7b590b3Smrg add= 8530a7b590b3Smrg lib_linked=yes 8531a7b590b3Smrg case $hardcode_action in 8532a7b590b3Smrg immediate | unsupported) 853315ffece8Smrg if test no = "$hardcode_direct"; then 853415ffece8Smrg add=$dir/$linklib 8535a7b590b3Smrg case $host in 853615ffece8Smrg *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;; 853715ffece8Smrg *-*-sysv4*uw2*) add_dir=-L$dir ;; 8538a7b590b3Smrg *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ 853915ffece8Smrg *-*-unixware7*) add_dir=-L$dir ;; 8540a7b590b3Smrg *-*-darwin* ) 854115ffece8Smrg # if the lib is a (non-dlopened) module then we cannot 8542a7b590b3Smrg # link against it, someone is ignoring the earlier warnings 8543a7b590b3Smrg if /usr/bin/file -L $add 2> /dev/null | 854415ffece8Smrg $GREP ": [^:]* bundle" >/dev/null; then 8545a7b590b3Smrg if test "X$dlopenmodule" != "X$lib"; then 8546a7b590b3Smrg $ECHO "*** Warning: lib $linklib is a module, not a shared library" 854715ffece8Smrg if test -z "$old_library"; then 85483e51e026Smrg echo 85493e51e026Smrg echo "*** And there doesn't seem to be a static archive available" 85503e51e026Smrg echo "*** The link will probably fail, sorry" 8551a7b590b3Smrg else 855215ffece8Smrg add=$dir/$old_library 8553a7b590b3Smrg fi 8554a7b590b3Smrg elif test -n "$old_library"; then 855515ffece8Smrg add=$dir/$old_library 8556a7b590b3Smrg fi 8557a7b590b3Smrg fi 8558a7b590b3Smrg esac 855915ffece8Smrg elif test no = "$hardcode_minus_L"; then 8560a7b590b3Smrg case $host in 856115ffece8Smrg *-*-sunos*) add_shlibpath=$dir ;; 8562a7b590b3Smrg esac 856315ffece8Smrg add_dir=-L$dir 856415ffece8Smrg add=-l$name 856515ffece8Smrg elif test no = "$hardcode_shlibpath_var"; then 856615ffece8Smrg add_shlibpath=$dir 856715ffece8Smrg add=-l$name 8568a7b590b3Smrg else 8569a7b590b3Smrg lib_linked=no 8570a7b590b3Smrg fi 8571a7b590b3Smrg ;; 8572a7b590b3Smrg relink) 857315ffece8Smrg if test yes = "$hardcode_direct" && 857415ffece8Smrg test no = "$hardcode_direct_absolute"; then 857515ffece8Smrg add=$dir/$linklib 857615ffece8Smrg elif test yes = "$hardcode_minus_L"; then 857715ffece8Smrg add_dir=-L$absdir 8578a7b590b3Smrg # Try looking first in the location we're being installed to. 8579a7b590b3Smrg if test -n "$inst_prefix_dir"; then 8580a7b590b3Smrg case $libdir in 8581a7b590b3Smrg [\\/]*) 85823e51e026Smrg func_append add_dir " -L$inst_prefix_dir$libdir" 8583a7b590b3Smrg ;; 8584a7b590b3Smrg esac 8585a7b590b3Smrg fi 858615ffece8Smrg add=-l$name 858715ffece8Smrg elif test yes = "$hardcode_shlibpath_var"; then 858815ffece8Smrg add_shlibpath=$dir 858915ffece8Smrg add=-l$name 8590a7b590b3Smrg else 8591a7b590b3Smrg lib_linked=no 8592a7b590b3Smrg fi 8593a7b590b3Smrg ;; 8594a7b590b3Smrg *) lib_linked=no ;; 8595a7b590b3Smrg esac 8596a7b590b3Smrg 859715ffece8Smrg if test yes != "$lib_linked"; then 8598a7b590b3Smrg func_fatal_configuration "unsupported hardcode properties" 8599a7b590b3Smrg fi 8600a7b590b3Smrg 8601a7b590b3Smrg if test -n "$add_shlibpath"; then 8602a7b590b3Smrg case :$compile_shlibpath: in 8603a7b590b3Smrg *":$add_shlibpath:"*) ;; 86043e51e026Smrg *) func_append compile_shlibpath "$add_shlibpath:" ;; 8605a7b590b3Smrg esac 8606a7b590b3Smrg fi 860715ffece8Smrg if test prog = "$linkmode"; then 8608a7b590b3Smrg test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" 8609a7b590b3Smrg test -n "$add" && compile_deplibs="$add $compile_deplibs" 8610a7b590b3Smrg else 8611a7b590b3Smrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 8612a7b590b3Smrg test -n "$add" && deplibs="$add $deplibs" 861315ffece8Smrg if test yes != "$hardcode_direct" && 861415ffece8Smrg test yes != "$hardcode_minus_L" && 861515ffece8Smrg test yes = "$hardcode_shlibpath_var"; then 8616a7b590b3Smrg case :$finalize_shlibpath: in 8617a7b590b3Smrg *":$libdir:"*) ;; 86183e51e026Smrg *) func_append finalize_shlibpath "$libdir:" ;; 8619a7b590b3Smrg esac 8620a7b590b3Smrg fi 8621a7b590b3Smrg fi 8622a7b590b3Smrg fi 8623a7b590b3Smrg 862415ffece8Smrg if test prog = "$linkmode" || test relink = "$opt_mode"; then 8625a7b590b3Smrg add_shlibpath= 8626a7b590b3Smrg add_dir= 8627a7b590b3Smrg add= 8628a7b590b3Smrg # Finalize command for both is simple: just hardcode it. 862915ffece8Smrg if test yes = "$hardcode_direct" && 863015ffece8Smrg test no = "$hardcode_direct_absolute"; then 863115ffece8Smrg add=$libdir/$linklib 863215ffece8Smrg elif test yes = "$hardcode_minus_L"; then 863315ffece8Smrg add_dir=-L$libdir 863415ffece8Smrg add=-l$name 863515ffece8Smrg elif test yes = "$hardcode_shlibpath_var"; then 8636a7b590b3Smrg case :$finalize_shlibpath: in 8637a7b590b3Smrg *":$libdir:"*) ;; 86383e51e026Smrg *) func_append finalize_shlibpath "$libdir:" ;; 8639a7b590b3Smrg esac 864015ffece8Smrg add=-l$name 864115ffece8Smrg elif test yes = "$hardcode_automatic"; then 8642a7b590b3Smrg if test -n "$inst_prefix_dir" && 864315ffece8Smrg test -f "$inst_prefix_dir$libdir/$linklib"; then 864415ffece8Smrg add=$inst_prefix_dir$libdir/$linklib 8645a7b590b3Smrg else 864615ffece8Smrg add=$libdir/$linklib 8647a7b590b3Smrg fi 8648a7b590b3Smrg else 8649a7b590b3Smrg # We cannot seem to hardcode it, guess we'll fake it. 865015ffece8Smrg add_dir=-L$libdir 8651a7b590b3Smrg # Try looking first in the location we're being installed to. 8652a7b590b3Smrg if test -n "$inst_prefix_dir"; then 8653a7b590b3Smrg case $libdir in 8654a7b590b3Smrg [\\/]*) 86553e51e026Smrg func_append add_dir " -L$inst_prefix_dir$libdir" 8656a7b590b3Smrg ;; 8657a7b590b3Smrg esac 8658a7b590b3Smrg fi 865915ffece8Smrg add=-l$name 8660a7b590b3Smrg fi 8661a7b590b3Smrg 866215ffece8Smrg if test prog = "$linkmode"; then 8663a7b590b3Smrg test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" 8664a7b590b3Smrg test -n "$add" && finalize_deplibs="$add $finalize_deplibs" 8665a7b590b3Smrg else 8666a7b590b3Smrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 8667a7b590b3Smrg test -n "$add" && deplibs="$add $deplibs" 8668a7b590b3Smrg fi 8669a7b590b3Smrg fi 867015ffece8Smrg elif test prog = "$linkmode"; then 8671a7b590b3Smrg # Here we assume that one of hardcode_direct or hardcode_minus_L 8672a7b590b3Smrg # is not unsupported. This is valid on all known static and 8673a7b590b3Smrg # shared platforms. 867415ffece8Smrg if test unsupported != "$hardcode_direct"; then 867515ffece8Smrg test -n "$old_library" && linklib=$old_library 8676a7b590b3Smrg compile_deplibs="$dir/$linklib $compile_deplibs" 8677a7b590b3Smrg finalize_deplibs="$dir/$linklib $finalize_deplibs" 8678a7b590b3Smrg else 8679a7b590b3Smrg compile_deplibs="-l$name -L$dir $compile_deplibs" 8680a7b590b3Smrg finalize_deplibs="-l$name -L$dir $finalize_deplibs" 8681a7b590b3Smrg fi 868215ffece8Smrg elif test yes = "$build_libtool_libs"; then 8683a7b590b3Smrg # Not a shared library 868415ffece8Smrg if test pass_all != "$deplibs_check_method"; then 8685a7b590b3Smrg # We're trying link a shared library against a static one 8686a7b590b3Smrg # but the system doesn't support it. 8687a7b590b3Smrg 8688a7b590b3Smrg # Just print a warning and add the library to dependency_libs so 8689a7b590b3Smrg # that the program can be linked against the static library. 86903e51e026Smrg echo 869115ffece8Smrg $ECHO "*** Warning: This system cannot link to static lib archive $lib." 86923e51e026Smrg echo "*** I have the capability to make that library automatically link in when" 86933e51e026Smrg echo "*** you link to this library. But I can only do this if you have a" 86943e51e026Smrg echo "*** shared version of the library, which you do not appear to have." 869515ffece8Smrg if test yes = "$module"; then 86963e51e026Smrg echo "*** But as you try to build a module library, libtool will still create " 86973e51e026Smrg echo "*** a static module, that should work as long as the dlopening application" 86983e51e026Smrg echo "*** is linked with the -dlopen flag to resolve symbols at runtime." 8699a7b590b3Smrg if test -z "$global_symbol_pipe"; then 87003e51e026Smrg echo 87013e51e026Smrg echo "*** However, this would only work if libtool was able to extract symbol" 870215ffece8Smrg echo "*** lists from a program, using 'nm' or equivalent, but libtool could" 87033e51e026Smrg echo "*** not find such a program. So, this module is probably useless." 870415ffece8Smrg echo "*** 'nm' from GNU binutils and a full rebuild may help." 8705a7b590b3Smrg fi 870615ffece8Smrg if test no = "$build_old_libs"; then 8707a7b590b3Smrg build_libtool_libs=module 8708a7b590b3Smrg build_old_libs=yes 8709a7b590b3Smrg else 8710a7b590b3Smrg build_libtool_libs=no 8711a7b590b3Smrg fi 8712a7b590b3Smrg fi 8713a7b590b3Smrg else 8714a7b590b3Smrg deplibs="$dir/$old_library $deplibs" 8715a7b590b3Smrg link_static=yes 8716a7b590b3Smrg fi 8717a7b590b3Smrg fi # link shared/static library? 8718a7b590b3Smrg 871915ffece8Smrg if test lib = "$linkmode"; then 8720a7b590b3Smrg if test -n "$dependency_libs" && 872115ffece8Smrg { test yes != "$hardcode_into_libs" || 872215ffece8Smrg test yes = "$build_old_libs" || 872315ffece8Smrg test yes = "$link_static"; }; then 8724a7b590b3Smrg # Extract -R from dependency_libs 8725a7b590b3Smrg temp_deplibs= 8726a7b590b3Smrg for libdir in $dependency_libs; do 8727a7b590b3Smrg case $libdir in 8728a7b590b3Smrg -R*) func_stripname '-R' '' "$libdir" 8729a7b590b3Smrg temp_xrpath=$func_stripname_result 8730a7b590b3Smrg case " $xrpath " in 8731a7b590b3Smrg *" $temp_xrpath "*) ;; 87323e51e026Smrg *) func_append xrpath " $temp_xrpath";; 8733a7b590b3Smrg esac;; 87343e51e026Smrg *) func_append temp_deplibs " $libdir";; 8735a7b590b3Smrg esac 8736a7b590b3Smrg done 873715ffece8Smrg dependency_libs=$temp_deplibs 8738a7b590b3Smrg fi 8739a7b590b3Smrg 87403e51e026Smrg func_append newlib_search_path " $absdir" 8741a7b590b3Smrg # Link against this library 874215ffece8Smrg test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs" 8743a7b590b3Smrg # ... and its dependency_libs 8744a7b590b3Smrg tmp_libs= 8745a7b590b3Smrg for deplib in $dependency_libs; do 8746a7b590b3Smrg newdependency_libs="$deplib $newdependency_libs" 87473e51e026Smrg case $deplib in 87483e51e026Smrg -L*) func_stripname '-L' '' "$deplib" 87493e51e026Smrg func_resolve_sysroot "$func_stripname_result";; 87503e51e026Smrg *) func_resolve_sysroot "$deplib" ;; 87513e51e026Smrg esac 875215ffece8Smrg if $opt_preserve_dup_deps; then 8753a7b590b3Smrg case "$tmp_libs " in 87543e51e026Smrg *" $func_resolve_sysroot_result "*) 87553e51e026Smrg func_append specialdeplibs " $func_resolve_sysroot_result" ;; 8756a7b590b3Smrg esac 8757a7b590b3Smrg fi 87583e51e026Smrg func_append tmp_libs " $func_resolve_sysroot_result" 8759a7b590b3Smrg done 8760a7b590b3Smrg 876115ffece8Smrg if test no != "$link_all_deplibs"; then 8762a7b590b3Smrg # Add the search paths of all dependency libraries 8763a7b590b3Smrg for deplib in $dependency_libs; do 87643e51e026Smrg path= 8765a7b590b3Smrg case $deplib in 876615ffece8Smrg -L*) path=$deplib ;; 8767a7b590b3Smrg *.la) 87683e51e026Smrg func_resolve_sysroot "$deplib" 87693e51e026Smrg deplib=$func_resolve_sysroot_result 8770a7b590b3Smrg func_dirname "$deplib" "" "." 87713e51e026Smrg dir=$func_dirname_result 8772a7b590b3Smrg # We need an absolute path. 8773a7b590b3Smrg case $dir in 877415ffece8Smrg [\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;; 8775a7b590b3Smrg *) 8776a7b590b3Smrg absdir=`cd "$dir" && pwd` 8777a7b590b3Smrg if test -z "$absdir"; then 877815ffece8Smrg func_warning "cannot determine absolute directory name of '$dir'" 877915ffece8Smrg absdir=$dir 8780a7b590b3Smrg fi 8781a7b590b3Smrg ;; 8782a7b590b3Smrg esac 8783a7b590b3Smrg if $GREP "^installed=no" $deplib > /dev/null; then 8784a7b590b3Smrg case $host in 8785a7b590b3Smrg *-*-darwin*) 8786a7b590b3Smrg depdepl= 878715ffece8Smrg eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` 878815ffece8Smrg if test -n "$deplibrary_names"; then 878915ffece8Smrg for tmp in $deplibrary_names; do 8790a7b590b3Smrg depdepl=$tmp 8791a7b590b3Smrg done 879215ffece8Smrg if test -f "$absdir/$objdir/$depdepl"; then 879315ffece8Smrg depdepl=$absdir/$objdir/$depdepl 879415ffece8Smrg darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 8795a7b590b3Smrg if test -z "$darwin_install_name"; then 879615ffece8Smrg darwin_install_name=`$OTOOL64 -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 8797a7b590b3Smrg fi 879815ffece8Smrg func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl" 879915ffece8Smrg func_append linker_flags " -dylib_file $darwin_install_name:$depdepl" 8800a7b590b3Smrg path= 8801a7b590b3Smrg fi 8802a7b590b3Smrg fi 8803a7b590b3Smrg ;; 8804a7b590b3Smrg *) 880515ffece8Smrg path=-L$absdir/$objdir 8806a7b590b3Smrg ;; 8807a7b590b3Smrg esac 8808a7b590b3Smrg else 880915ffece8Smrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` 8810a7b590b3Smrg test -z "$libdir" && \ 881115ffece8Smrg func_fatal_error "'$deplib' is not a valid libtool archive" 8812a7b590b3Smrg test "$absdir" != "$libdir" && \ 881315ffece8Smrg func_warning "'$deplib' seems to be moved" 8814a7b590b3Smrg 881515ffece8Smrg path=-L$absdir 8816a7b590b3Smrg fi 8817a7b590b3Smrg ;; 8818a7b590b3Smrg esac 8819a7b590b3Smrg case " $deplibs " in 8820a7b590b3Smrg *" $path "*) ;; 8821a7b590b3Smrg *) deplibs="$path $deplibs" ;; 8822a7b590b3Smrg esac 8823a7b590b3Smrg done 8824a7b590b3Smrg fi # link_all_deplibs != no 8825a7b590b3Smrg fi # linkmode = lib 8826a7b590b3Smrg done # for deplib in $libs 882715ffece8Smrg if test link = "$pass"; then 882815ffece8Smrg if test prog = "$linkmode"; then 8829a7b590b3Smrg compile_deplibs="$new_inherited_linker_flags $compile_deplibs" 8830a7b590b3Smrg finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" 8831a7b590b3Smrg else 88323e51e026Smrg compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 8833a7b590b3Smrg fi 8834a7b590b3Smrg fi 883515ffece8Smrg dependency_libs=$newdependency_libs 883615ffece8Smrg if test dlpreopen = "$pass"; then 8837a7b590b3Smrg # Link the dlpreopened libraries before other libraries 8838a7b590b3Smrg for deplib in $save_deplibs; do 8839a7b590b3Smrg deplibs="$deplib $deplibs" 8840a7b590b3Smrg done 8841a7b590b3Smrg fi 884215ffece8Smrg if test dlopen != "$pass"; then 884315ffece8Smrg test conv = "$pass" || { 8844a7b590b3Smrg # Make sure lib_search_path contains only unique directories. 8845a7b590b3Smrg lib_search_path= 8846a7b590b3Smrg for dir in $newlib_search_path; do 8847a7b590b3Smrg case "$lib_search_path " in 8848a7b590b3Smrg *" $dir "*) ;; 88493e51e026Smrg *) func_append lib_search_path " $dir" ;; 8850a7b590b3Smrg esac 8851a7b590b3Smrg done 8852a7b590b3Smrg newlib_search_path= 885315ffece8Smrg } 8854a7b590b3Smrg 885515ffece8Smrg if test prog,link = "$linkmode,$pass"; then 8856a7b590b3Smrg vars="compile_deplibs finalize_deplibs" 885715ffece8Smrg else 885815ffece8Smrg vars=deplibs 8859a7b590b3Smrg fi 8860a7b590b3Smrg for var in $vars dependency_libs; do 8861a7b590b3Smrg # Add libraries to $var in reverse order 8862a7b590b3Smrg eval tmp_libs=\"\$$var\" 8863a7b590b3Smrg new_libs= 8864a7b590b3Smrg for deplib in $tmp_libs; do 8865a7b590b3Smrg # FIXME: Pedantically, this is the right thing to do, so 8866a7b590b3Smrg # that some nasty dependency loop isn't accidentally 8867a7b590b3Smrg # broken: 8868a7b590b3Smrg #new_libs="$deplib $new_libs" 8869a7b590b3Smrg # Pragmatically, this seems to cause very few problems in 8870a7b590b3Smrg # practice: 8871a7b590b3Smrg case $deplib in 8872a7b590b3Smrg -L*) new_libs="$deplib $new_libs" ;; 8873a7b590b3Smrg -R*) ;; 8874a7b590b3Smrg *) 8875a7b590b3Smrg # And here is the reason: when a library appears more 8876a7b590b3Smrg # than once as an explicit dependence of a library, or 8877a7b590b3Smrg # is implicitly linked in more than once by the 8878a7b590b3Smrg # compiler, it is considered special, and multiple 8879a7b590b3Smrg # occurrences thereof are not removed. Compare this 8880a7b590b3Smrg # with having the same library being listed as a 8881a7b590b3Smrg # dependency of multiple other libraries: in this case, 8882a7b590b3Smrg # we know (pedantically, we assume) the library does not 8883a7b590b3Smrg # need to be listed more than once, so we keep only the 8884a7b590b3Smrg # last copy. This is not always right, but it is rare 8885a7b590b3Smrg # enough that we require users that really mean to play 8886a7b590b3Smrg # such unportable linking tricks to link the library 8887a7b590b3Smrg # using -Wl,-lname, so that libtool does not consider it 8888a7b590b3Smrg # for duplicate removal. 8889a7b590b3Smrg case " $specialdeplibs " in 8890a7b590b3Smrg *" $deplib "*) new_libs="$deplib $new_libs" ;; 8891a7b590b3Smrg *) 8892a7b590b3Smrg case " $new_libs " in 8893a7b590b3Smrg *" $deplib "*) ;; 8894a7b590b3Smrg *) new_libs="$deplib $new_libs" ;; 8895a7b590b3Smrg esac 8896a7b590b3Smrg ;; 8897a7b590b3Smrg esac 8898a7b590b3Smrg ;; 8899a7b590b3Smrg esac 8900a7b590b3Smrg done 8901a7b590b3Smrg tmp_libs= 8902a7b590b3Smrg for deplib in $new_libs; do 8903a7b590b3Smrg case $deplib in 8904a7b590b3Smrg -L*) 8905a7b590b3Smrg case " $tmp_libs " in 8906a7b590b3Smrg *" $deplib "*) ;; 89073e51e026Smrg *) func_append tmp_libs " $deplib" ;; 8908a7b590b3Smrg esac 8909a7b590b3Smrg ;; 89103e51e026Smrg *) func_append tmp_libs " $deplib" ;; 8911a7b590b3Smrg esac 8912a7b590b3Smrg done 8913a7b590b3Smrg eval $var=\"$tmp_libs\" 8914a7b590b3Smrg done # for var 8915a7b590b3Smrg fi 891615ffece8Smrg 891715ffece8Smrg # Add Sun CC postdeps if required: 891815ffece8Smrg test CXX = "$tagname" && { 891915ffece8Smrg case $host_os in 892015ffece8Smrg linux*) 892115ffece8Smrg case `$CC -V 2>&1 | $SED 5q` in 892215ffece8Smrg *Sun\ C*) # Sun C++ 5.9 892315ffece8Smrg func_suncc_cstd_abi 892415ffece8Smrg 892515ffece8Smrg if test no != "$suncc_use_cstd_abi"; then 892615ffece8Smrg func_append postdeps ' -library=Cstd -library=Crun' 892715ffece8Smrg fi 892815ffece8Smrg ;; 892915ffece8Smrg esac 893015ffece8Smrg ;; 893115ffece8Smrg 893215ffece8Smrg solaris*) 893315ffece8Smrg func_cc_basename "$CC" 893415ffece8Smrg case $func_cc_basename_result in 893515ffece8Smrg CC* | sunCC*) 893615ffece8Smrg func_suncc_cstd_abi 893715ffece8Smrg 893815ffece8Smrg if test no != "$suncc_use_cstd_abi"; then 893915ffece8Smrg func_append postdeps ' -library=Cstd -library=Crun' 894015ffece8Smrg fi 894115ffece8Smrg ;; 894215ffece8Smrg esac 894315ffece8Smrg ;; 894415ffece8Smrg esac 894515ffece8Smrg } 894615ffece8Smrg 8947a7b590b3Smrg # Last step: remove runtime libs from dependency_libs 8948a7b590b3Smrg # (they stay in deplibs) 8949a7b590b3Smrg tmp_libs= 895015ffece8Smrg for i in $dependency_libs; do 8951a7b590b3Smrg case " $predeps $postdeps $compiler_lib_search_path " in 8952a7b590b3Smrg *" $i "*) 895315ffece8Smrg i= 8954a7b590b3Smrg ;; 8955a7b590b3Smrg esac 895615ffece8Smrg if test -n "$i"; then 89573e51e026Smrg func_append tmp_libs " $i" 8958a7b590b3Smrg fi 8959a7b590b3Smrg done 8960a7b590b3Smrg dependency_libs=$tmp_libs 8961a7b590b3Smrg done # for pass 896215ffece8Smrg if test prog = "$linkmode"; then 896315ffece8Smrg dlfiles=$newdlfiles 8964a7b590b3Smrg fi 896515ffece8Smrg if test prog = "$linkmode" || test lib = "$linkmode"; then 896615ffece8Smrg dlprefiles=$newdlprefiles 8967a7b590b3Smrg fi 8968a7b590b3Smrg 8969a7b590b3Smrg case $linkmode in 8970a7b590b3Smrg oldlib) 897115ffece8Smrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 897215ffece8Smrg func_warning "'-dlopen' is ignored for archives" 8973a7b590b3Smrg fi 8974a7b590b3Smrg 8975a7b590b3Smrg case " $deplibs" in 8976a7b590b3Smrg *\ -l* | *\ -L*) 897715ffece8Smrg func_warning "'-l' and '-L' are ignored for archives" ;; 8978a7b590b3Smrg esac 8979a7b590b3Smrg 8980a7b590b3Smrg test -n "$rpath" && \ 898115ffece8Smrg func_warning "'-rpath' is ignored for archives" 8982a7b590b3Smrg 8983a7b590b3Smrg test -n "$xrpath" && \ 898415ffece8Smrg func_warning "'-R' is ignored for archives" 8985a7b590b3Smrg 8986a7b590b3Smrg test -n "$vinfo" && \ 898715ffece8Smrg func_warning "'-version-info/-version-number' is ignored for archives" 8988a7b590b3Smrg 8989a7b590b3Smrg test -n "$release" && \ 899015ffece8Smrg func_warning "'-release' is ignored for archives" 8991a7b590b3Smrg 8992a7b590b3Smrg test -n "$export_symbols$export_symbols_regex" && \ 899315ffece8Smrg func_warning "'-export-symbols' is ignored for archives" 8994a7b590b3Smrg 8995a7b590b3Smrg # Now set the variables for building old libraries. 8996a7b590b3Smrg build_libtool_libs=no 899715ffece8Smrg oldlibs=$output 89983e51e026Smrg func_append objs "$old_deplibs" 8999a7b590b3Smrg ;; 9000a7b590b3Smrg 9001a7b590b3Smrg lib) 900215ffece8Smrg # Make sure we only generate libraries of the form 'libNAME.la'. 9003a7b590b3Smrg case $outputname in 9004a7b590b3Smrg lib*) 9005a7b590b3Smrg func_stripname 'lib' '.la' "$outputname" 9006a7b590b3Smrg name=$func_stripname_result 9007a7b590b3Smrg eval shared_ext=\"$shrext_cmds\" 9008a7b590b3Smrg eval libname=\"$libname_spec\" 9009a7b590b3Smrg ;; 9010a7b590b3Smrg *) 901115ffece8Smrg test no = "$module" \ 901215ffece8Smrg && func_fatal_help "libtool library '$output' must begin with 'lib'" 9013a7b590b3Smrg 901415ffece8Smrg if test no != "$need_lib_prefix"; then 9015a7b590b3Smrg # Add the "lib" prefix for modules if required 9016a7b590b3Smrg func_stripname '' '.la' "$outputname" 9017a7b590b3Smrg name=$func_stripname_result 9018a7b590b3Smrg eval shared_ext=\"$shrext_cmds\" 9019a7b590b3Smrg eval libname=\"$libname_spec\" 9020a7b590b3Smrg else 9021a7b590b3Smrg func_stripname '' '.la' "$outputname" 9022a7b590b3Smrg libname=$func_stripname_result 9023a7b590b3Smrg fi 9024a7b590b3Smrg ;; 9025a7b590b3Smrg esac 9026a7b590b3Smrg 9027a7b590b3Smrg if test -n "$objs"; then 902815ffece8Smrg if test pass_all != "$deplibs_check_method"; then 902915ffece8Smrg func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs" 9030a7b590b3Smrg else 90313e51e026Smrg echo 9032a7b590b3Smrg $ECHO "*** Warning: Linking the shared library $output against the non-libtool" 9033a7b590b3Smrg $ECHO "*** objects $objs is not portable!" 90343e51e026Smrg func_append libobjs " $objs" 9035a7b590b3Smrg fi 9036a7b590b3Smrg fi 9037a7b590b3Smrg 903815ffece8Smrg test no = "$dlself" \ 903915ffece8Smrg || func_warning "'-dlopen self' is ignored for libtool libraries" 9040a7b590b3Smrg 9041a7b590b3Smrg set dummy $rpath 9042a7b590b3Smrg shift 904315ffece8Smrg test 1 -lt "$#" \ 904415ffece8Smrg && func_warning "ignoring multiple '-rpath's for a libtool library" 9045a7b590b3Smrg 904615ffece8Smrg install_libdir=$1 9047a7b590b3Smrg 9048a7b590b3Smrg oldlibs= 9049a7b590b3Smrg if test -z "$rpath"; then 905015ffece8Smrg if test yes = "$build_libtool_libs"; then 9051a7b590b3Smrg # Building a libtool convenience library. 905215ffece8Smrg # Some compilers have problems with a '.al' extension so 9053a7b590b3Smrg # convenience libraries should have the same extension an 9054a7b590b3Smrg # archive normally would. 9055a7b590b3Smrg oldlibs="$output_objdir/$libname.$libext $oldlibs" 9056a7b590b3Smrg build_libtool_libs=convenience 9057a7b590b3Smrg build_old_libs=yes 9058a7b590b3Smrg fi 9059a7b590b3Smrg 9060a7b590b3Smrg test -n "$vinfo" && \ 906115ffece8Smrg func_warning "'-version-info/-version-number' is ignored for convenience libraries" 9062a7b590b3Smrg 9063a7b590b3Smrg test -n "$release" && \ 906415ffece8Smrg func_warning "'-release' is ignored for convenience libraries" 9065a7b590b3Smrg else 9066a7b590b3Smrg 9067a7b590b3Smrg # Parse the version information argument. 906815ffece8Smrg save_ifs=$IFS; IFS=: 9069a7b590b3Smrg set dummy $vinfo 0 0 0 9070a7b590b3Smrg shift 907115ffece8Smrg IFS=$save_ifs 9072a7b590b3Smrg 9073a7b590b3Smrg test -n "$7" && \ 907415ffece8Smrg func_fatal_help "too many parameters to '-version-info'" 9075a7b590b3Smrg 9076a7b590b3Smrg # convert absolute version numbers to libtool ages 9077a7b590b3Smrg # this retains compatibility with .la files and attempts 9078a7b590b3Smrg # to make the code below a bit more comprehensible 9079a7b590b3Smrg 9080a7b590b3Smrg case $vinfo_number in 9081a7b590b3Smrg yes) 908215ffece8Smrg number_major=$1 908315ffece8Smrg number_minor=$2 908415ffece8Smrg number_revision=$3 9085a7b590b3Smrg # 9086a7b590b3Smrg # There are really only two kinds -- those that 9087a7b590b3Smrg # use the current revision as the major version 9088a7b590b3Smrg # and those that subtract age and use age as 9089a7b590b3Smrg # a minor version. But, then there is irix 909015ffece8Smrg # that has an extra 1 added just for fun 9091a7b590b3Smrg # 9092a7b590b3Smrg case $version_type in 90933e51e026Smrg # correct linux to gnu/linux during the next big refactor 909415ffece8Smrg darwin|freebsd-elf|linux|midnightbsd-elf|osf|windows|none) 9095a7b590b3Smrg func_arith $number_major + $number_minor 9096a7b590b3Smrg current=$func_arith_result 909715ffece8Smrg age=$number_minor 909815ffece8Smrg revision=$number_revision 9099a7b590b3Smrg ;; 910015ffece8Smrg freebsd-aout|qnx|sunos) 910115ffece8Smrg current=$number_major 910215ffece8Smrg revision=$number_minor 910315ffece8Smrg age=0 9104a7b590b3Smrg ;; 9105a7b590b3Smrg irix|nonstopux) 9106a7b590b3Smrg func_arith $number_major + $number_minor 9107a7b590b3Smrg current=$func_arith_result 910815ffece8Smrg age=$number_minor 910915ffece8Smrg revision=$number_minor 9110a7b590b3Smrg lt_irix_increment=no 9111a7b590b3Smrg ;; 9112a7b590b3Smrg esac 9113a7b590b3Smrg ;; 9114a7b590b3Smrg no) 911515ffece8Smrg current=$1 911615ffece8Smrg revision=$2 911715ffece8Smrg age=$3 9118a7b590b3Smrg ;; 9119a7b590b3Smrg esac 9120a7b590b3Smrg 9121a7b590b3Smrg # Check that each of the things are valid numbers. 9122a7b590b3Smrg case $current in 9123a7b590b3Smrg 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]) ;; 9124a7b590b3Smrg *) 912515ffece8Smrg func_error "CURRENT '$current' must be a nonnegative integer" 912615ffece8Smrg func_fatal_error "'$vinfo' is not valid version information" 9127a7b590b3Smrg ;; 9128a7b590b3Smrg esac 9129a7b590b3Smrg 9130a7b590b3Smrg case $revision in 9131a7b590b3Smrg 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]) ;; 9132a7b590b3Smrg *) 913315ffece8Smrg func_error "REVISION '$revision' must be a nonnegative integer" 913415ffece8Smrg func_fatal_error "'$vinfo' is not valid version information" 9135a7b590b3Smrg ;; 9136a7b590b3Smrg esac 9137a7b590b3Smrg 9138a7b590b3Smrg case $age in 9139a7b590b3Smrg 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]) ;; 9140a7b590b3Smrg *) 914115ffece8Smrg func_error "AGE '$age' must be a nonnegative integer" 914215ffece8Smrg func_fatal_error "'$vinfo' is not valid version information" 9143a7b590b3Smrg ;; 9144a7b590b3Smrg esac 9145a7b590b3Smrg 9146a7b590b3Smrg if test "$age" -gt "$current"; then 914715ffece8Smrg func_error "AGE '$age' is greater than the current interface number '$current'" 914815ffece8Smrg func_fatal_error "'$vinfo' is not valid version information" 9149a7b590b3Smrg fi 9150a7b590b3Smrg 9151a7b590b3Smrg # Calculate the version variables. 9152a7b590b3Smrg major= 9153a7b590b3Smrg versuffix= 9154a7b590b3Smrg verstring= 9155a7b590b3Smrg case $version_type in 9156a7b590b3Smrg none) ;; 9157a7b590b3Smrg 9158a7b590b3Smrg darwin) 9159a7b590b3Smrg # Like Linux, but with the current version available in 9160a7b590b3Smrg # verstring for coding it into the library header 9161a7b590b3Smrg func_arith $current - $age 9162a7b590b3Smrg major=.$func_arith_result 916315ffece8Smrg versuffix=$major.$age.$revision 9164a7b590b3Smrg # Darwin ld doesn't like 0 for these options... 9165a7b590b3Smrg func_arith $current + 1 9166a7b590b3Smrg minor_current=$func_arith_result 916715ffece8Smrg xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" 9168a7b590b3Smrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 916915ffece8Smrg # On Darwin other compilers 917015ffece8Smrg case $CC in 917115ffece8Smrg nagfor*) 917215ffece8Smrg verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" 917315ffece8Smrg ;; 917415ffece8Smrg *) 917515ffece8Smrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 917615ffece8Smrg ;; 917715ffece8Smrg esac 9178a7b590b3Smrg ;; 9179a7b590b3Smrg 9180a7b590b3Smrg freebsd-aout) 918115ffece8Smrg major=.$current 918215ffece8Smrg versuffix=.$current.$revision 9183a7b590b3Smrg ;; 9184a7b590b3Smrg 918515ffece8Smrg freebsd-elf | midnightbsd-elf) 918615ffece8Smrg func_arith $current - $age 918715ffece8Smrg major=.$func_arith_result 918815ffece8Smrg versuffix=$major.$age.$revision 9189a7b590b3Smrg ;; 9190a7b590b3Smrg 9191a7b590b3Smrg irix | nonstopux) 919215ffece8Smrg if test no = "$lt_irix_increment"; then 9193a7b590b3Smrg func_arith $current - $age 9194a7b590b3Smrg else 9195a7b590b3Smrg func_arith $current - $age + 1 9196a7b590b3Smrg fi 9197a7b590b3Smrg major=$func_arith_result 9198a7b590b3Smrg 9199a7b590b3Smrg case $version_type in 9200a7b590b3Smrg nonstopux) verstring_prefix=nonstopux ;; 9201a7b590b3Smrg *) verstring_prefix=sgi ;; 9202a7b590b3Smrg esac 920315ffece8Smrg verstring=$verstring_prefix$major.$revision 9204a7b590b3Smrg 9205a7b590b3Smrg # Add in all the interfaces that we are compatible with. 9206a7b590b3Smrg loop=$revision 920715ffece8Smrg while test 0 -ne "$loop"; do 9208a7b590b3Smrg func_arith $revision - $loop 9209a7b590b3Smrg iface=$func_arith_result 9210a7b590b3Smrg func_arith $loop - 1 9211a7b590b3Smrg loop=$func_arith_result 921215ffece8Smrg verstring=$verstring_prefix$major.$iface:$verstring 9213a7b590b3Smrg done 9214a7b590b3Smrg 921515ffece8Smrg # Before this point, $major must not contain '.'. 9216a7b590b3Smrg major=.$major 921715ffece8Smrg versuffix=$major.$revision 9218a7b590b3Smrg ;; 9219a7b590b3Smrg 92203e51e026Smrg linux) # correct to gnu/linux during the next big refactor 9221a7b590b3Smrg func_arith $current - $age 9222a7b590b3Smrg major=.$func_arith_result 922315ffece8Smrg versuffix=$major.$age.$revision 9224a7b590b3Smrg ;; 9225a7b590b3Smrg 9226a7b590b3Smrg osf) 9227a7b590b3Smrg func_arith $current - $age 9228a7b590b3Smrg major=.$func_arith_result 922915ffece8Smrg versuffix=.$current.$age.$revision 923015ffece8Smrg verstring=$current.$age.$revision 9231a7b590b3Smrg 9232a7b590b3Smrg # Add in all the interfaces that we are compatible with. 9233a7b590b3Smrg loop=$age 923415ffece8Smrg while test 0 -ne "$loop"; do 9235a7b590b3Smrg func_arith $current - $loop 9236a7b590b3Smrg iface=$func_arith_result 9237a7b590b3Smrg func_arith $loop - 1 9238a7b590b3Smrg loop=$func_arith_result 923915ffece8Smrg verstring=$verstring:$iface.0 9240a7b590b3Smrg done 9241a7b590b3Smrg 9242a7b590b3Smrg # Make executables depend on our current version. 924315ffece8Smrg func_append verstring ":$current.0" 9244a7b590b3Smrg ;; 9245a7b590b3Smrg 9246a7b590b3Smrg qnx) 924715ffece8Smrg major=.$current 924815ffece8Smrg versuffix=.$current 924915ffece8Smrg ;; 925015ffece8Smrg 925115ffece8Smrg sco) 925215ffece8Smrg major=.$current 925315ffece8Smrg versuffix=.$current 9254a7b590b3Smrg ;; 9255a7b590b3Smrg 9256a7b590b3Smrg sunos) 925715ffece8Smrg major=.$current 925815ffece8Smrg versuffix=.$current.$revision 9259a7b590b3Smrg ;; 9260a7b590b3Smrg 9261a7b590b3Smrg windows) 9262a7b590b3Smrg # Use '-' rather than '.', since we only want one 926315ffece8Smrg # extension on DOS 8.3 file systems. 9264a7b590b3Smrg func_arith $current - $age 9265a7b590b3Smrg major=$func_arith_result 926615ffece8Smrg versuffix=-$major 9267a7b590b3Smrg ;; 9268a7b590b3Smrg 9269a7b590b3Smrg *) 927015ffece8Smrg func_fatal_configuration "unknown library version type '$version_type'" 9271a7b590b3Smrg ;; 9272a7b590b3Smrg esac 9273a7b590b3Smrg 9274a7b590b3Smrg # Clear the version info if we defaulted, and they specified a release. 9275a7b590b3Smrg if test -z "$vinfo" && test -n "$release"; then 9276a7b590b3Smrg major= 9277a7b590b3Smrg case $version_type in 9278a7b590b3Smrg darwin) 9279a7b590b3Smrg # we can't check for "0.0" in archive_cmds due to quoting 9280a7b590b3Smrg # problems, so we reset it completely 9281a7b590b3Smrg verstring= 9282a7b590b3Smrg ;; 9283a7b590b3Smrg *) 928415ffece8Smrg verstring=0.0 9285a7b590b3Smrg ;; 9286a7b590b3Smrg esac 928715ffece8Smrg if test no = "$need_version"; then 9288a7b590b3Smrg versuffix= 9289a7b590b3Smrg else 929015ffece8Smrg versuffix=.0.0 9291a7b590b3Smrg fi 9292a7b590b3Smrg fi 9293a7b590b3Smrg 9294a7b590b3Smrg # Remove version info from name if versioning should be avoided 929515ffece8Smrg if test yes,no = "$avoid_version,$need_version"; then 9296a7b590b3Smrg major= 9297a7b590b3Smrg versuffix= 929815ffece8Smrg verstring= 9299a7b590b3Smrg fi 9300a7b590b3Smrg 9301a7b590b3Smrg # Check to see if the archive will have undefined symbols. 930215ffece8Smrg if test yes = "$allow_undefined"; then 930315ffece8Smrg if test unsupported = "$allow_undefined_flag"; then 930415ffece8Smrg if test yes = "$build_old_libs"; then 930515ffece8Smrg func_warning "undefined symbols not allowed in $host shared libraries; building static only" 930615ffece8Smrg build_libtool_libs=no 930715ffece8Smrg else 930815ffece8Smrg func_fatal_error "can't build $host shared library unless -no-undefined is specified" 930915ffece8Smrg fi 9310a7b590b3Smrg fi 9311a7b590b3Smrg else 9312a7b590b3Smrg # Don't allow undefined symbols. 931315ffece8Smrg allow_undefined_flag=$no_undefined_flag 9314a7b590b3Smrg fi 9315a7b590b3Smrg 9316a7b590b3Smrg fi 9317a7b590b3Smrg 931815ffece8Smrg func_generate_dlsyms "$libname" "$libname" : 93193e51e026Smrg func_append libobjs " $symfileobj" 932015ffece8Smrg test " " = "$libobjs" && libobjs= 9321a7b590b3Smrg 932215ffece8Smrg if test relink != "$opt_mode"; then 9323a7b590b3Smrg # Remove our outputs, but don't remove object files since they 9324a7b590b3Smrg # may have been created when compiling PIC objects. 9325a7b590b3Smrg removelist= 9326a7b590b3Smrg tempremovelist=`$ECHO "$output_objdir/*"` 9327a7b590b3Smrg for p in $tempremovelist; do 9328a7b590b3Smrg case $p in 9329a7b590b3Smrg *.$objext | *.gcno) 9330a7b590b3Smrg ;; 933115ffece8Smrg $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/$libname$release.*) 933215ffece8Smrg if test -n "$precious_files_regex"; then 9333a7b590b3Smrg if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 9334a7b590b3Smrg then 9335a7b590b3Smrg continue 9336a7b590b3Smrg fi 9337a7b590b3Smrg fi 93383e51e026Smrg func_append removelist " $p" 9339a7b590b3Smrg ;; 9340a7b590b3Smrg *) ;; 9341a7b590b3Smrg esac 9342a7b590b3Smrg done 9343a7b590b3Smrg test -n "$removelist" && \ 9344a7b590b3Smrg func_show_eval "${RM}r \$removelist" 9345a7b590b3Smrg fi 9346a7b590b3Smrg 9347a7b590b3Smrg # Now set the variables for building old libraries. 934815ffece8Smrg if test yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; then 93493e51e026Smrg func_append oldlibs " $output_objdir/$libname.$libext" 9350a7b590b3Smrg 9351a7b590b3Smrg # Transform .lo files to .o files. 935215ffece8Smrg oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; $lo2o" | $NL2SP` 9353a7b590b3Smrg fi 9354a7b590b3Smrg 9355a7b590b3Smrg # Eliminate all temporary directories. 9356a7b590b3Smrg #for path in $notinst_path; do 93573e51e026Smrg # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` 93583e51e026Smrg # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` 93593e51e026Smrg # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` 9360a7b590b3Smrg #done 9361a7b590b3Smrg 9362a7b590b3Smrg if test -n "$xrpath"; then 9363a7b590b3Smrg # If the user specified any rpath flags, then add them. 9364a7b590b3Smrg temp_xrpath= 9365a7b590b3Smrg for libdir in $xrpath; do 93663e51e026Smrg func_replace_sysroot "$libdir" 93673e51e026Smrg func_append temp_xrpath " -R$func_replace_sysroot_result" 9368a7b590b3Smrg case "$finalize_rpath " in 9369a7b590b3Smrg *" $libdir "*) ;; 93703e51e026Smrg *) func_append finalize_rpath " $libdir" ;; 9371a7b590b3Smrg esac 9372a7b590b3Smrg done 937315ffece8Smrg if test yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; then 9374a7b590b3Smrg dependency_libs="$temp_xrpath $dependency_libs" 9375a7b590b3Smrg fi 9376a7b590b3Smrg fi 9377a7b590b3Smrg 9378a7b590b3Smrg # Make sure dlfiles contains only unique files that won't be dlpreopened 937915ffece8Smrg old_dlfiles=$dlfiles 9380a7b590b3Smrg dlfiles= 9381a7b590b3Smrg for lib in $old_dlfiles; do 9382a7b590b3Smrg case " $dlprefiles $dlfiles " in 9383a7b590b3Smrg *" $lib "*) ;; 93843e51e026Smrg *) func_append dlfiles " $lib" ;; 9385a7b590b3Smrg esac 9386a7b590b3Smrg done 9387a7b590b3Smrg 9388a7b590b3Smrg # Make sure dlprefiles contains only unique files 938915ffece8Smrg old_dlprefiles=$dlprefiles 9390a7b590b3Smrg dlprefiles= 9391a7b590b3Smrg for lib in $old_dlprefiles; do 9392a7b590b3Smrg case "$dlprefiles " in 9393a7b590b3Smrg *" $lib "*) ;; 93943e51e026Smrg *) func_append dlprefiles " $lib" ;; 9395a7b590b3Smrg esac 9396a7b590b3Smrg done 9397a7b590b3Smrg 939815ffece8Smrg if test yes = "$build_libtool_libs"; then 9399a7b590b3Smrg if test -n "$rpath"; then 9400a7b590b3Smrg case $host in 94013e51e026Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) 9402a7b590b3Smrg # these systems don't actually have a c library (as such)! 9403a7b590b3Smrg ;; 9404a7b590b3Smrg *-*-rhapsody* | *-*-darwin1.[012]) 9405a7b590b3Smrg # Rhapsody C library is in the System framework 94063e51e026Smrg func_append deplibs " System.ltframework" 9407a7b590b3Smrg ;; 9408a7b590b3Smrg *-*-netbsd*) 9409a7b590b3Smrg # Don't link with libc until the a.out ld.so is fixed. 9410a7b590b3Smrg ;; 941115ffece8Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-midnightbsd*) 9412a7b590b3Smrg # Do not include libc due to us having libc/libc_r. 9413a7b590b3Smrg ;; 9414a7b590b3Smrg *-*-sco3.2v5* | *-*-sco5v6*) 9415a7b590b3Smrg # Causes problems with __ctype 9416a7b590b3Smrg ;; 9417a7b590b3Smrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 9418a7b590b3Smrg # Compiler inserts libc in the correct place for threads to work 9419a7b590b3Smrg ;; 9420a7b590b3Smrg *) 9421a7b590b3Smrg # Add libc to deplibs on all other systems if necessary. 942215ffece8Smrg if test yes = "$build_libtool_need_lc"; then 94233e51e026Smrg func_append deplibs " -lc" 9424a7b590b3Smrg fi 9425a7b590b3Smrg ;; 9426a7b590b3Smrg esac 9427a7b590b3Smrg fi 9428a7b590b3Smrg 9429a7b590b3Smrg # Transform deplibs into only deplibs that can be linked in shared. 9430a7b590b3Smrg name_save=$name 9431a7b590b3Smrg libname_save=$libname 9432a7b590b3Smrg release_save=$release 9433a7b590b3Smrg versuffix_save=$versuffix 9434a7b590b3Smrg major_save=$major 9435a7b590b3Smrg # I'm not sure if I'm treating the release correctly. I think 9436a7b590b3Smrg # release should show up in the -l (ie -lgmp5) so we don't want to 9437a7b590b3Smrg # add it in twice. Is that correct? 943815ffece8Smrg release= 943915ffece8Smrg versuffix= 944015ffece8Smrg major= 9441a7b590b3Smrg newdeplibs= 9442a7b590b3Smrg droppeddeps=no 9443a7b590b3Smrg case $deplibs_check_method in 9444a7b590b3Smrg pass_all) 9445a7b590b3Smrg # Don't check for shared/static. Everything works. 9446a7b590b3Smrg # This might be a little naive. We might want to check 9447a7b590b3Smrg # whether the library exists or not. But this is on 9448a7b590b3Smrg # osf3 & osf4 and I'm not really sure... Just 9449a7b590b3Smrg # implementing what was already the behavior. 9450a7b590b3Smrg newdeplibs=$deplibs 9451a7b590b3Smrg ;; 9452a7b590b3Smrg test_compile) 9453a7b590b3Smrg # This code stresses the "libraries are programs" paradigm to its 9454a7b590b3Smrg # limits. Maybe even breaks it. We compile a program, linking it 9455a7b590b3Smrg # against the deplibs as a proxy for the library. Then we can check 9456a7b590b3Smrg # whether they linked in statically or dynamically with ldd. 9457a7b590b3Smrg $opt_dry_run || $RM conftest.c 9458a7b590b3Smrg cat > conftest.c <<EOF 9459a7b590b3Smrg int main() { return 0; } 9460a7b590b3SmrgEOF 9461a7b590b3Smrg $opt_dry_run || $RM conftest 9462a7b590b3Smrg if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then 9463a7b590b3Smrg ldd_output=`ldd conftest` 9464a7b590b3Smrg for i in $deplibs; do 9465a7b590b3Smrg case $i in 9466a7b590b3Smrg -l*) 9467a7b590b3Smrg func_stripname -l '' "$i" 9468a7b590b3Smrg name=$func_stripname_result 946915ffece8Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9470a7b590b3Smrg case " $predeps $postdeps " in 9471a7b590b3Smrg *" $i "*) 94723e51e026Smrg func_append newdeplibs " $i" 947315ffece8Smrg i= 9474a7b590b3Smrg ;; 9475a7b590b3Smrg esac 9476a7b590b3Smrg fi 947715ffece8Smrg if test -n "$i"; then 9478a7b590b3Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 9479a7b590b3Smrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 9480a7b590b3Smrg set dummy $deplib_matches; shift 9481a7b590b3Smrg deplib_match=$1 948215ffece8Smrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then 94833e51e026Smrg func_append newdeplibs " $i" 9484a7b590b3Smrg else 9485a7b590b3Smrg droppeddeps=yes 94863e51e026Smrg echo 9487a7b590b3Smrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 94883e51e026Smrg echo "*** I have the capability to make that library automatically link in when" 94893e51e026Smrg echo "*** you link to this library. But I can only do this if you have a" 94903e51e026Smrg echo "*** shared version of the library, which I believe you do not have" 94913e51e026Smrg echo "*** because a test_compile did reveal that the linker did not use it for" 94923e51e026Smrg echo "*** its dynamic dependency list that programs get resolved with at runtime." 9493a7b590b3Smrg fi 9494a7b590b3Smrg fi 9495a7b590b3Smrg ;; 9496a7b590b3Smrg *) 94973e51e026Smrg func_append newdeplibs " $i" 9498a7b590b3Smrg ;; 9499a7b590b3Smrg esac 9500a7b590b3Smrg done 9501a7b590b3Smrg else 9502a7b590b3Smrg # Error occurred in the first compile. Let's try to salvage 9503a7b590b3Smrg # the situation: Compile a separate program for each library. 9504a7b590b3Smrg for i in $deplibs; do 9505a7b590b3Smrg case $i in 9506a7b590b3Smrg -l*) 9507a7b590b3Smrg func_stripname -l '' "$i" 9508a7b590b3Smrg name=$func_stripname_result 9509a7b590b3Smrg $opt_dry_run || $RM conftest 9510a7b590b3Smrg if $LTCC $LTCFLAGS -o conftest conftest.c $i; then 9511a7b590b3Smrg ldd_output=`ldd conftest` 951215ffece8Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9513a7b590b3Smrg case " $predeps $postdeps " in 9514a7b590b3Smrg *" $i "*) 95153e51e026Smrg func_append newdeplibs " $i" 951615ffece8Smrg i= 9517a7b590b3Smrg ;; 9518a7b590b3Smrg esac 9519a7b590b3Smrg fi 952015ffece8Smrg if test -n "$i"; then 9521a7b590b3Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 9522a7b590b3Smrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 9523a7b590b3Smrg set dummy $deplib_matches; shift 9524a7b590b3Smrg deplib_match=$1 952515ffece8Smrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then 95263e51e026Smrg func_append newdeplibs " $i" 9527a7b590b3Smrg else 9528a7b590b3Smrg droppeddeps=yes 95293e51e026Smrg echo 9530a7b590b3Smrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 95313e51e026Smrg echo "*** I have the capability to make that library automatically link in when" 95323e51e026Smrg echo "*** you link to this library. But I can only do this if you have a" 95333e51e026Smrg echo "*** shared version of the library, which you do not appear to have" 95343e51e026Smrg echo "*** because a test_compile did reveal that the linker did not use this one" 95353e51e026Smrg echo "*** as a dynamic dependency that programs can get resolved with at runtime." 9536a7b590b3Smrg fi 9537a7b590b3Smrg fi 9538a7b590b3Smrg else 9539a7b590b3Smrg droppeddeps=yes 95403e51e026Smrg echo 9541a7b590b3Smrg $ECHO "*** Warning! Library $i is needed by this library but I was not able to" 95423e51e026Smrg echo "*** make it link in! You will probably need to install it or some" 95433e51e026Smrg echo "*** library that it depends on before this library will be fully" 95443e51e026Smrg echo "*** functional. Installing it before continuing would be even better." 9545a7b590b3Smrg fi 9546a7b590b3Smrg ;; 9547a7b590b3Smrg *) 95483e51e026Smrg func_append newdeplibs " $i" 9549a7b590b3Smrg ;; 9550a7b590b3Smrg esac 9551a7b590b3Smrg done 9552a7b590b3Smrg fi 9553a7b590b3Smrg ;; 9554a7b590b3Smrg file_magic*) 9555a7b590b3Smrg set dummy $deplibs_check_method; shift 9556a7b590b3Smrg file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 9557a7b590b3Smrg for a_deplib in $deplibs; do 9558a7b590b3Smrg case $a_deplib in 9559a7b590b3Smrg -l*) 9560a7b590b3Smrg func_stripname -l '' "$a_deplib" 9561a7b590b3Smrg name=$func_stripname_result 956215ffece8Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9563a7b590b3Smrg case " $predeps $postdeps " in 9564a7b590b3Smrg *" $a_deplib "*) 95653e51e026Smrg func_append newdeplibs " $a_deplib" 956615ffece8Smrg a_deplib= 9567a7b590b3Smrg ;; 9568a7b590b3Smrg esac 9569a7b590b3Smrg fi 957015ffece8Smrg if test -n "$a_deplib"; then 9571a7b590b3Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 95723e51e026Smrg if test -n "$file_magic_glob"; then 95733e51e026Smrg libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob` 95743e51e026Smrg else 95753e51e026Smrg libnameglob=$libname 95763e51e026Smrg fi 957715ffece8Smrg test yes = "$want_nocaseglob" && nocaseglob=`shopt -p nocaseglob` 9578a7b590b3Smrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 957915ffece8Smrg if test yes = "$want_nocaseglob"; then 95803e51e026Smrg shopt -s nocaseglob 95813e51e026Smrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 95823e51e026Smrg $nocaseglob 95833e51e026Smrg else 95843e51e026Smrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 95853e51e026Smrg fi 9586a7b590b3Smrg for potent_lib in $potential_libs; do 9587a7b590b3Smrg # Follow soft links. 9588a7b590b3Smrg if ls -lLd "$potent_lib" 2>/dev/null | 9589a7b590b3Smrg $GREP " -> " >/dev/null; then 9590a7b590b3Smrg continue 9591a7b590b3Smrg fi 9592a7b590b3Smrg # The statement above tries to avoid entering an 9593a7b590b3Smrg # endless loop below, in case of cyclic links. 9594a7b590b3Smrg # We might still enter an endless loop, since a link 9595a7b590b3Smrg # loop can be closed while we follow links, 9596a7b590b3Smrg # but so what? 959715ffece8Smrg potlib=$potent_lib 9598a7b590b3Smrg while test -h "$potlib" 2>/dev/null; do 959915ffece8Smrg potliblink=`ls -ld $potlib | $SED 's/.* -> //'` 9600a7b590b3Smrg case $potliblink in 960115ffece8Smrg [\\/]* | [A-Za-z]:[\\/]*) potlib=$potliblink;; 960215ffece8Smrg *) potlib=`$ECHO "$potlib" | $SED 's|[^/]*$||'`"$potliblink";; 9603a7b590b3Smrg esac 9604a7b590b3Smrg done 9605a7b590b3Smrg if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | 9606a7b590b3Smrg $SED -e 10q | 9607a7b590b3Smrg $EGREP "$file_magic_regex" > /dev/null; then 96083e51e026Smrg func_append newdeplibs " $a_deplib" 960915ffece8Smrg a_deplib= 9610a7b590b3Smrg break 2 9611a7b590b3Smrg fi 9612a7b590b3Smrg done 9613a7b590b3Smrg done 9614a7b590b3Smrg fi 961515ffece8Smrg if test -n "$a_deplib"; then 9616a7b590b3Smrg droppeddeps=yes 96173e51e026Smrg echo 9618a7b590b3Smrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 96193e51e026Smrg echo "*** I have the capability to make that library automatically link in when" 96203e51e026Smrg echo "*** you link to this library. But I can only do this if you have a" 96213e51e026Smrg echo "*** shared version of the library, which you do not appear to have" 96223e51e026Smrg echo "*** because I did check the linker path looking for a file starting" 962315ffece8Smrg if test -z "$potlib"; then 9624a7b590b3Smrg $ECHO "*** with $libname but no candidates were found. (...for file magic test)" 9625a7b590b3Smrg else 9626a7b590b3Smrg $ECHO "*** with $libname and none of the candidates passed a file format test" 9627a7b590b3Smrg $ECHO "*** using a file magic. Last file checked: $potlib" 9628a7b590b3Smrg fi 9629a7b590b3Smrg fi 9630a7b590b3Smrg ;; 9631a7b590b3Smrg *) 9632a7b590b3Smrg # Add a -L argument. 96333e51e026Smrg func_append newdeplibs " $a_deplib" 9634a7b590b3Smrg ;; 9635a7b590b3Smrg esac 9636a7b590b3Smrg done # Gone through all deplibs. 9637a7b590b3Smrg ;; 9638a7b590b3Smrg match_pattern*) 9639a7b590b3Smrg set dummy $deplibs_check_method; shift 9640a7b590b3Smrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 9641a7b590b3Smrg for a_deplib in $deplibs; do 9642a7b590b3Smrg case $a_deplib in 9643a7b590b3Smrg -l*) 9644a7b590b3Smrg func_stripname -l '' "$a_deplib" 9645a7b590b3Smrg name=$func_stripname_result 964615ffece8Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9647a7b590b3Smrg case " $predeps $postdeps " in 9648a7b590b3Smrg *" $a_deplib "*) 96493e51e026Smrg func_append newdeplibs " $a_deplib" 965015ffece8Smrg a_deplib= 9651a7b590b3Smrg ;; 9652a7b590b3Smrg esac 9653a7b590b3Smrg fi 965415ffece8Smrg if test -n "$a_deplib"; then 9655a7b590b3Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 9656a7b590b3Smrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 9657a7b590b3Smrg potential_libs=`ls $i/$libname[.-]* 2>/dev/null` 9658a7b590b3Smrg for potent_lib in $potential_libs; do 965915ffece8Smrg potlib=$potent_lib # see symlink-check above in file_magic test 96603e51e026Smrg if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ 9661a7b590b3Smrg $EGREP "$match_pattern_regex" > /dev/null; then 96623e51e026Smrg func_append newdeplibs " $a_deplib" 966315ffece8Smrg a_deplib= 9664a7b590b3Smrg break 2 9665a7b590b3Smrg fi 9666a7b590b3Smrg done 9667a7b590b3Smrg done 9668a7b590b3Smrg fi 966915ffece8Smrg if test -n "$a_deplib"; then 9670a7b590b3Smrg droppeddeps=yes 96713e51e026Smrg echo 9672a7b590b3Smrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 96733e51e026Smrg echo "*** I have the capability to make that library automatically link in when" 96743e51e026Smrg echo "*** you link to this library. But I can only do this if you have a" 96753e51e026Smrg echo "*** shared version of the library, which you do not appear to have" 96763e51e026Smrg echo "*** because I did check the linker path looking for a file starting" 967715ffece8Smrg if test -z "$potlib"; then 9678a7b590b3Smrg $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" 9679a7b590b3Smrg else 9680a7b590b3Smrg $ECHO "*** with $libname and none of the candidates passed a file format test" 9681a7b590b3Smrg $ECHO "*** using a regex pattern. Last file checked: $potlib" 9682a7b590b3Smrg fi 9683a7b590b3Smrg fi 9684a7b590b3Smrg ;; 9685a7b590b3Smrg *) 9686a7b590b3Smrg # Add a -L argument. 96873e51e026Smrg func_append newdeplibs " $a_deplib" 9688a7b590b3Smrg ;; 9689a7b590b3Smrg esac 9690a7b590b3Smrg done # Gone through all deplibs. 9691a7b590b3Smrg ;; 9692a7b590b3Smrg none | unknown | *) 969315ffece8Smrg newdeplibs= 96943e51e026Smrg tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` 969515ffece8Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 969615ffece8Smrg for i in $predeps $postdeps; do 9697a7b590b3Smrg # can't use Xsed below, because $i might contain '/' 969815ffece8Smrg tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s|$i||"` 9699a7b590b3Smrg done 9700a7b590b3Smrg fi 97013e51e026Smrg case $tmp_deplibs in 97023e51e026Smrg *[!\ \ ]*) 97033e51e026Smrg echo 970415ffece8Smrg if test none = "$deplibs_check_method"; then 97053e51e026Smrg echo "*** Warning: inter-library dependencies are not supported in this platform." 9706a7b590b3Smrg else 97073e51e026Smrg echo "*** Warning: inter-library dependencies are not known to be supported." 9708a7b590b3Smrg fi 97093e51e026Smrg echo "*** All declared inter-library dependencies are being dropped." 9710a7b590b3Smrg droppeddeps=yes 97113e51e026Smrg ;; 97123e51e026Smrg esac 9713a7b590b3Smrg ;; 9714a7b590b3Smrg esac 9715a7b590b3Smrg versuffix=$versuffix_save 9716a7b590b3Smrg major=$major_save 9717a7b590b3Smrg release=$release_save 9718a7b590b3Smrg libname=$libname_save 9719a7b590b3Smrg name=$name_save 9720a7b590b3Smrg 9721a7b590b3Smrg case $host in 9722a7b590b3Smrg *-*-rhapsody* | *-*-darwin1.[012]) 9723a7b590b3Smrg # On Rhapsody replace the C library with the System framework 97243e51e026Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` 9725a7b590b3Smrg ;; 9726a7b590b3Smrg esac 9727a7b590b3Smrg 972815ffece8Smrg if test yes = "$droppeddeps"; then 972915ffece8Smrg if test yes = "$module"; then 97303e51e026Smrg echo 97313e51e026Smrg echo "*** Warning: libtool could not satisfy all declared inter-library" 9732a7b590b3Smrg $ECHO "*** dependencies of module $libname. Therefore, libtool will create" 97333e51e026Smrg echo "*** a static module, that should work as long as the dlopening" 97343e51e026Smrg echo "*** application is linked with the -dlopen flag." 9735a7b590b3Smrg if test -z "$global_symbol_pipe"; then 97363e51e026Smrg echo 97373e51e026Smrg echo "*** However, this would only work if libtool was able to extract symbol" 973815ffece8Smrg echo "*** lists from a program, using 'nm' or equivalent, but libtool could" 97393e51e026Smrg echo "*** not find such a program. So, this module is probably useless." 974015ffece8Smrg echo "*** 'nm' from GNU binutils and a full rebuild may help." 9741a7b590b3Smrg fi 974215ffece8Smrg if test no = "$build_old_libs"; then 974315ffece8Smrg oldlibs=$output_objdir/$libname.$libext 9744a7b590b3Smrg build_libtool_libs=module 9745a7b590b3Smrg build_old_libs=yes 9746a7b590b3Smrg else 9747a7b590b3Smrg build_libtool_libs=no 9748a7b590b3Smrg fi 9749a7b590b3Smrg else 97503e51e026Smrg echo "*** The inter-library dependencies that have been dropped here will be" 97513e51e026Smrg echo "*** automatically added whenever a program is linked with this library" 97523e51e026Smrg echo "*** or is declared to -dlopen it." 9753a7b590b3Smrg 975415ffece8Smrg if test no = "$allow_undefined"; then 97553e51e026Smrg echo 97563e51e026Smrg echo "*** Since this library must not contain undefined symbols," 97573e51e026Smrg echo "*** because either the platform does not support them or" 97583e51e026Smrg echo "*** it was explicitly requested with -no-undefined," 97593e51e026Smrg echo "*** libtool will only create a static version of it." 976015ffece8Smrg if test no = "$build_old_libs"; then 976115ffece8Smrg oldlibs=$output_objdir/$libname.$libext 9762a7b590b3Smrg build_libtool_libs=module 9763a7b590b3Smrg build_old_libs=yes 9764a7b590b3Smrg else 9765a7b590b3Smrg build_libtool_libs=no 9766a7b590b3Smrg fi 9767a7b590b3Smrg fi 9768a7b590b3Smrg fi 9769a7b590b3Smrg fi 9770a7b590b3Smrg # Done checking deplibs! 9771a7b590b3Smrg deplibs=$newdeplibs 9772a7b590b3Smrg fi 9773a7b590b3Smrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 9774a7b590b3Smrg case $host in 9775a7b590b3Smrg *-*-darwin*) 97763e51e026Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 97773e51e026Smrg new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 97783e51e026Smrg deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 9779a7b590b3Smrg ;; 9780a7b590b3Smrg esac 9781a7b590b3Smrg 9782a7b590b3Smrg # move library search paths that coincide with paths to not yet 9783a7b590b3Smrg # installed libraries to the beginning of the library search list 9784a7b590b3Smrg new_libs= 9785a7b590b3Smrg for path in $notinst_path; do 9786a7b590b3Smrg case " $new_libs " in 9787a7b590b3Smrg *" -L$path/$objdir "*) ;; 9788a7b590b3Smrg *) 9789a7b590b3Smrg case " $deplibs " in 9790a7b590b3Smrg *" -L$path/$objdir "*) 97913e51e026Smrg func_append new_libs " -L$path/$objdir" ;; 9792a7b590b3Smrg esac 9793a7b590b3Smrg ;; 9794a7b590b3Smrg esac 9795a7b590b3Smrg done 9796a7b590b3Smrg for deplib in $deplibs; do 9797a7b590b3Smrg case $deplib in 9798a7b590b3Smrg -L*) 9799a7b590b3Smrg case " $new_libs " in 9800a7b590b3Smrg *" $deplib "*) ;; 98013e51e026Smrg *) func_append new_libs " $deplib" ;; 9802a7b590b3Smrg esac 9803a7b590b3Smrg ;; 98043e51e026Smrg *) func_append new_libs " $deplib" ;; 9805a7b590b3Smrg esac 9806a7b590b3Smrg done 980715ffece8Smrg deplibs=$new_libs 9808a7b590b3Smrg 9809a7b590b3Smrg # All the library-specific variables (install_libdir is set above). 9810a7b590b3Smrg library_names= 9811a7b590b3Smrg old_library= 9812a7b590b3Smrg dlname= 9813a7b590b3Smrg 9814a7b590b3Smrg # Test again, we may have decided not to build it any more 981515ffece8Smrg if test yes = "$build_libtool_libs"; then 981615ffece8Smrg # Remove $wl instances when linking with ld. 98173e51e026Smrg # FIXME: should test the right _cmds variable. 98183e51e026Smrg case $archive_cmds in 98193e51e026Smrg *\$LD\ *) wl= ;; 98203e51e026Smrg esac 982115ffece8Smrg if test yes = "$hardcode_into_libs"; then 9822a7b590b3Smrg # Hardcode the library paths 9823a7b590b3Smrg hardcode_libdirs= 9824a7b590b3Smrg dep_rpath= 982515ffece8Smrg rpath=$finalize_rpath 982615ffece8Smrg test relink = "$opt_mode" || rpath=$compile_rpath$rpath 9827a7b590b3Smrg for libdir in $rpath; do 9828a7b590b3Smrg if test -n "$hardcode_libdir_flag_spec"; then 9829a7b590b3Smrg if test -n "$hardcode_libdir_separator"; then 98303e51e026Smrg func_replace_sysroot "$libdir" 98313e51e026Smrg libdir=$func_replace_sysroot_result 9832a7b590b3Smrg if test -z "$hardcode_libdirs"; then 983315ffece8Smrg hardcode_libdirs=$libdir 9834a7b590b3Smrg else 9835a7b590b3Smrg # Just accumulate the unique libdirs. 9836a7b590b3Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 9837a7b590b3Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 9838a7b590b3Smrg ;; 9839a7b590b3Smrg *) 98403e51e026Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 9841a7b590b3Smrg ;; 9842a7b590b3Smrg esac 9843a7b590b3Smrg fi 9844a7b590b3Smrg else 9845a7b590b3Smrg eval flag=\"$hardcode_libdir_flag_spec\" 98463e51e026Smrg func_append dep_rpath " $flag" 9847a7b590b3Smrg fi 9848a7b590b3Smrg elif test -n "$runpath_var"; then 9849a7b590b3Smrg case "$perm_rpath " in 9850a7b590b3Smrg *" $libdir "*) ;; 98513e51e026Smrg *) func_append perm_rpath " $libdir" ;; 9852a7b590b3Smrg esac 9853a7b590b3Smrg fi 9854a7b590b3Smrg done 9855a7b590b3Smrg # Substitute the hardcoded libdirs into the rpath. 9856a7b590b3Smrg if test -n "$hardcode_libdir_separator" && 9857a7b590b3Smrg test -n "$hardcode_libdirs"; then 985815ffece8Smrg libdir=$hardcode_libdirs 98593e51e026Smrg eval "dep_rpath=\"$hardcode_libdir_flag_spec\"" 9860a7b590b3Smrg fi 9861a7b590b3Smrg if test -n "$runpath_var" && test -n "$perm_rpath"; then 9862a7b590b3Smrg # We should set the runpath_var. 9863a7b590b3Smrg rpath= 9864a7b590b3Smrg for dir in $perm_rpath; do 98653e51e026Smrg func_append rpath "$dir:" 9866a7b590b3Smrg done 9867a7b590b3Smrg eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" 9868a7b590b3Smrg fi 9869a7b590b3Smrg test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" 9870a7b590b3Smrg fi 9871943345d3Smrg 987215ffece8Smrg shlibpath=$finalize_shlibpath 987315ffece8Smrg test relink = "$opt_mode" || shlibpath=$compile_shlibpath$shlibpath 9874a7b590b3Smrg if test -n "$shlibpath"; then 9875a7b590b3Smrg eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" 9876a7b590b3Smrg fi 9877943345d3Smrg 9878a7b590b3Smrg # Get the real and link names of the library. 9879a7b590b3Smrg eval shared_ext=\"$shrext_cmds\" 9880a7b590b3Smrg eval library_names=\"$library_names_spec\" 9881a7b590b3Smrg set dummy $library_names 9882a7b590b3Smrg shift 988315ffece8Smrg realname=$1 9884a7b590b3Smrg shift 9885943345d3Smrg 9886a7b590b3Smrg if test -n "$soname_spec"; then 9887a7b590b3Smrg eval soname=\"$soname_spec\" 9888a7b590b3Smrg else 988915ffece8Smrg soname=$realname 9890a7b590b3Smrg fi 9891a7b590b3Smrg if test -z "$dlname"; then 9892a7b590b3Smrg dlname=$soname 9893a7b590b3Smrg fi 9894943345d3Smrg 989515ffece8Smrg lib=$output_objdir/$realname 9896a7b590b3Smrg linknames= 9897a7b590b3Smrg for link 9898a7b590b3Smrg do 98993e51e026Smrg func_append linknames " $link" 9900a7b590b3Smrg done 9901943345d3Smrg 9902a7b590b3Smrg # Use standard objects if they are pic 99033e51e026Smrg test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` 9904a7b590b3Smrg test "X$libobjs" = "X " && libobjs= 9905943345d3Smrg 9906a7b590b3Smrg delfiles= 9907a7b590b3Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 9908a7b590b3Smrg $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" 990915ffece8Smrg export_symbols=$output_objdir/$libname.uexp 99103e51e026Smrg func_append delfiles " $export_symbols" 9911a7b590b3Smrg fi 9912943345d3Smrg 9913a7b590b3Smrg orig_export_symbols= 9914a7b590b3Smrg case $host_os in 9915a7b590b3Smrg cygwin* | mingw* | cegcc*) 9916a7b590b3Smrg if test -n "$export_symbols" && test -z "$export_symbols_regex"; then 9917a7b590b3Smrg # exporting using user supplied symfile 991815ffece8Smrg func_dll_def_p "$export_symbols" || { 9919a7b590b3Smrg # and it's NOT already a .def file. Must figure out 9920a7b590b3Smrg # which of the given symbols are data symbols and tag 9921a7b590b3Smrg # them as such. So, trigger use of export_symbols_cmds. 9922a7b590b3Smrg # export_symbols gets reassigned inside the "prepare 9923a7b590b3Smrg # the list of exported symbols" if statement, so the 9924a7b590b3Smrg # include_expsyms logic still works. 992515ffece8Smrg orig_export_symbols=$export_symbols 9926a7b590b3Smrg export_symbols= 9927a7b590b3Smrg always_export_symbols=yes 992815ffece8Smrg } 9929a7b590b3Smrg fi 9930a7b590b3Smrg ;; 9931a7b590b3Smrg esac 9932943345d3Smrg 9933a7b590b3Smrg # Prepare the list of exported symbols 9934a7b590b3Smrg if test -z "$export_symbols"; then 993515ffece8Smrg if test yes = "$always_export_symbols" || test -n "$export_symbols_regex"; then 993615ffece8Smrg func_verbose "generating symbol list for '$libname.la'" 993715ffece8Smrg export_symbols=$output_objdir/$libname.exp 9938a7b590b3Smrg $opt_dry_run || $RM $export_symbols 9939a7b590b3Smrg cmds=$export_symbols_cmds 994015ffece8Smrg save_ifs=$IFS; IFS='~' 99413e51e026Smrg for cmd1 in $cmds; do 994215ffece8Smrg IFS=$save_ifs 99433e51e026Smrg # Take the normal branch if the nm_file_list_spec branch 99443e51e026Smrg # doesn't work or if tool conversion is not needed. 99453e51e026Smrg case $nm_file_list_spec~$to_tool_file_cmd in 99463e51e026Smrg *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) 99473e51e026Smrg try_normal_branch=yes 99483e51e026Smrg eval cmd=\"$cmd1\" 99493e51e026Smrg func_len " $cmd" 99503e51e026Smrg len=$func_len_result 99513e51e026Smrg ;; 99523e51e026Smrg *) 99533e51e026Smrg try_normal_branch=no 99543e51e026Smrg ;; 99553e51e026Smrg esac 995615ffece8Smrg if test yes = "$try_normal_branch" \ 99573e51e026Smrg && { test "$len" -lt "$max_cmd_len" \ 99583e51e026Smrg || test "$max_cmd_len" -le -1; } 99593e51e026Smrg then 99603e51e026Smrg func_show_eval "$cmd" 'exit $?' 99613e51e026Smrg skipped_export=false 99623e51e026Smrg elif test -n "$nm_file_list_spec"; then 99633e51e026Smrg func_basename "$output" 99643e51e026Smrg output_la=$func_basename_result 99653e51e026Smrg save_libobjs=$libobjs 99663e51e026Smrg save_output=$output 996715ffece8Smrg output=$output_objdir/$output_la.nm 99683e51e026Smrg func_to_tool_file "$output" 99693e51e026Smrg libobjs=$nm_file_list_spec$func_to_tool_file_result 99703e51e026Smrg func_append delfiles " $output" 99713e51e026Smrg func_verbose "creating $NM input file list: $output" 99723e51e026Smrg for obj in $save_libobjs; do 99733e51e026Smrg func_to_tool_file "$obj" 99743e51e026Smrg $ECHO "$func_to_tool_file_result" 99753e51e026Smrg done > "$output" 99763e51e026Smrg eval cmd=\"$cmd1\" 9977a7b590b3Smrg func_show_eval "$cmd" 'exit $?' 99783e51e026Smrg output=$save_output 99793e51e026Smrg libobjs=$save_libobjs 9980a7b590b3Smrg skipped_export=false 9981a7b590b3Smrg else 9982a7b590b3Smrg # The command line is too long to execute in one step. 9983a7b590b3Smrg func_verbose "using reloadable object file for export list..." 9984a7b590b3Smrg skipped_export=: 9985a7b590b3Smrg # Break out early, otherwise skipped_export may be 9986a7b590b3Smrg # set to false by a later but shorter cmd. 9987a7b590b3Smrg break 9988a7b590b3Smrg fi 9989a7b590b3Smrg done 999015ffece8Smrg IFS=$save_ifs 999115ffece8Smrg if test -n "$export_symbols_regex" && test : != "$skipped_export"; then 9992a7b590b3Smrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 9993a7b590b3Smrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 9994a7b590b3Smrg fi 9995a7b590b3Smrg fi 9996943345d3Smrg fi 9997943345d3Smrg 9998a7b590b3Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 999915ffece8Smrg tmp_export_symbols=$export_symbols 1000015ffece8Smrg test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols 100013e51e026Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 10002a7b590b3Smrg fi 10003943345d3Smrg 1000415ffece8Smrg if test : != "$skipped_export" && test -n "$orig_export_symbols"; then 10005a7b590b3Smrg # The given exports_symbols file has to be filtered, so filter it. 1000615ffece8Smrg func_verbose "filter symbol list for '$libname.la' to tag DATA exports" 10007a7b590b3Smrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 1000815ffece8Smrg # 's' commands, which not all seds can handle. GNU sed should be fine 10009a7b590b3Smrg # though. Also, the filter scales superlinearly with the number of 10010a7b590b3Smrg # global variables. join(1) would be nice here, but unfortunately 10011a7b590b3Smrg # isn't a blessed tool. 10012a7b590b3Smrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 100133e51e026Smrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 10014a7b590b3Smrg export_symbols=$output_objdir/$libname.def 10015a7b590b3Smrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 10016a7b590b3Smrg fi 10017943345d3Smrg 10018a7b590b3Smrg tmp_deplibs= 10019a7b590b3Smrg for test_deplib in $deplibs; do 10020a7b590b3Smrg case " $convenience " in 10021a7b590b3Smrg *" $test_deplib "*) ;; 10022a7b590b3Smrg *) 100233e51e026Smrg func_append tmp_deplibs " $test_deplib" 10024a7b590b3Smrg ;; 10025a7b590b3Smrg esac 10026a7b590b3Smrg done 1002715ffece8Smrg deplibs=$tmp_deplibs 10028943345d3Smrg 10029a7b590b3Smrg if test -n "$convenience"; then 10030a7b590b3Smrg if test -n "$whole_archive_flag_spec" && 1003115ffece8Smrg test yes = "$compiler_needs_object" && 10032a7b590b3Smrg test -z "$libobjs"; then 10033a7b590b3Smrg # extract the archives, so we have objects to list. 10034a7b590b3Smrg # TODO: could optimize this to just extract one archive. 10035a7b590b3Smrg whole_archive_flag_spec= 10036a7b590b3Smrg fi 10037a7b590b3Smrg if test -n "$whole_archive_flag_spec"; then 10038a7b590b3Smrg save_libobjs=$libobjs 10039a7b590b3Smrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 10040a7b590b3Smrg test "X$libobjs" = "X " && libobjs= 10041a7b590b3Smrg else 1004215ffece8Smrg gentop=$output_objdir/${outputname}x 100433e51e026Smrg func_append generated " $gentop" 10044943345d3Smrg 10045a7b590b3Smrg func_extract_archives $gentop $convenience 100463e51e026Smrg func_append libobjs " $func_extract_archives_result" 10047a7b590b3Smrg test "X$libobjs" = "X " && libobjs= 10048a7b590b3Smrg fi 10049943345d3Smrg fi 10050943345d3Smrg 1005115ffece8Smrg if test yes = "$thread_safe" && test -n "$thread_safe_flag_spec"; then 10052a7b590b3Smrg eval flag=\"$thread_safe_flag_spec\" 100533e51e026Smrg func_append linker_flags " $flag" 10054943345d3Smrg fi 10055943345d3Smrg 10056a7b590b3Smrg # Make a backup of the uninstalled library when relinking 1005715ffece8Smrg if test relink = "$opt_mode"; then 10058a7b590b3Smrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? 10059a7b590b3Smrg fi 10060943345d3Smrg 10061a7b590b3Smrg # Do each of the archive commands. 1006215ffece8Smrg if test yes = "$module" && test -n "$module_cmds"; then 10063a7b590b3Smrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 10064a7b590b3Smrg eval test_cmds=\"$module_expsym_cmds\" 10065a7b590b3Smrg cmds=$module_expsym_cmds 10066a7b590b3Smrg else 10067a7b590b3Smrg eval test_cmds=\"$module_cmds\" 10068a7b590b3Smrg cmds=$module_cmds 10069a7b590b3Smrg fi 10070943345d3Smrg else 10071a7b590b3Smrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 10072a7b590b3Smrg eval test_cmds=\"$archive_expsym_cmds\" 10073a7b590b3Smrg cmds=$archive_expsym_cmds 10074a7b590b3Smrg else 10075a7b590b3Smrg eval test_cmds=\"$archive_cmds\" 10076a7b590b3Smrg cmds=$archive_cmds 10077a7b590b3Smrg fi 10078943345d3Smrg fi 10079943345d3Smrg 1008015ffece8Smrg if test : != "$skipped_export" && 10081a7b590b3Smrg func_len " $test_cmds" && 10082a7b590b3Smrg len=$func_len_result && 10083a7b590b3Smrg test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 10084a7b590b3Smrg : 10085a7b590b3Smrg else 10086a7b590b3Smrg # The command line is too long to link in one step, link piecewise 10087a7b590b3Smrg # or, if using GNU ld and skipped_export is not :, use a linker 10088a7b590b3Smrg # script. 10089943345d3Smrg 10090a7b590b3Smrg # Save the value of $output and $libobjs because we want to 10091a7b590b3Smrg # use them later. If we have whole_archive_flag_spec, we 10092a7b590b3Smrg # want to use save_libobjs as it was before 10093a7b590b3Smrg # whole_archive_flag_spec was expanded, because we can't 10094a7b590b3Smrg # assume the linker understands whole_archive_flag_spec. 10095a7b590b3Smrg # This may have to be revisited, in case too many 10096a7b590b3Smrg # convenience libraries get linked in and end up exceeding 10097a7b590b3Smrg # the spec. 10098a7b590b3Smrg if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then 10099a7b590b3Smrg save_libobjs=$libobjs 10100a7b590b3Smrg fi 10101a7b590b3Smrg save_output=$output 101023e51e026Smrg func_basename "$output" 101033e51e026Smrg output_la=$func_basename_result 10104943345d3Smrg 10105a7b590b3Smrg # Clear the reloadable object creation command queue and 10106a7b590b3Smrg # initialize k to one. 10107a7b590b3Smrg test_cmds= 10108a7b590b3Smrg concat_cmds= 10109a7b590b3Smrg objlist= 10110a7b590b3Smrg last_robj= 10111a7b590b3Smrg k=1 10112a7b590b3Smrg 1011315ffece8Smrg if test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then 1011415ffece8Smrg output=$output_objdir/$output_la.lnkscript 10115a7b590b3Smrg func_verbose "creating GNU ld script: $output" 101163e51e026Smrg echo 'INPUT (' > $output 10117a7b590b3Smrg for obj in $save_libobjs 10118943345d3Smrg do 101193e51e026Smrg func_to_tool_file "$obj" 101203e51e026Smrg $ECHO "$func_to_tool_file_result" >> $output 10121a7b590b3Smrg done 101223e51e026Smrg echo ')' >> $output 101233e51e026Smrg func_append delfiles " $output" 101243e51e026Smrg func_to_tool_file "$output" 101253e51e026Smrg output=$func_to_tool_file_result 1012615ffece8Smrg elif test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then 1012715ffece8Smrg output=$output_objdir/$output_la.lnk 10128a7b590b3Smrg func_verbose "creating linker input file list: $output" 10129a7b590b3Smrg : > $output 10130a7b590b3Smrg set x $save_libobjs 10131a7b590b3Smrg shift 10132a7b590b3Smrg firstobj= 1013315ffece8Smrg if test yes = "$compiler_needs_object"; then 10134a7b590b3Smrg firstobj="$1 " 10135a7b590b3Smrg shift 10136a7b590b3Smrg fi 10137a7b590b3Smrg for obj 10138a7b590b3Smrg do 101393e51e026Smrg func_to_tool_file "$obj" 101403e51e026Smrg $ECHO "$func_to_tool_file_result" >> $output 10141a7b590b3Smrg done 101423e51e026Smrg func_append delfiles " $output" 101433e51e026Smrg func_to_tool_file "$output" 101443e51e026Smrg output=$firstobj\"$file_list_spec$func_to_tool_file_result\" 10145a7b590b3Smrg else 10146a7b590b3Smrg if test -n "$save_libobjs"; then 10147a7b590b3Smrg func_verbose "creating reloadable object files..." 1014815ffece8Smrg output=$output_objdir/$output_la-$k.$objext 10149a7b590b3Smrg eval test_cmds=\"$reload_cmds\" 10150a7b590b3Smrg func_len " $test_cmds" 10151a7b590b3Smrg len0=$func_len_result 10152a7b590b3Smrg len=$len0 10153a7b590b3Smrg 10154a7b590b3Smrg # Loop over the list of objects to be linked. 10155a7b590b3Smrg for obj in $save_libobjs 10156a7b590b3Smrg do 10157a7b590b3Smrg func_len " $obj" 10158a7b590b3Smrg func_arith $len + $func_len_result 10159a7b590b3Smrg len=$func_arith_result 1016015ffece8Smrg if test -z "$objlist" || 10161a7b590b3Smrg test "$len" -lt "$max_cmd_len"; then 10162a7b590b3Smrg func_append objlist " $obj" 10163a7b590b3Smrg else 10164a7b590b3Smrg # The command $test_cmds is almost too long, add a 10165a7b590b3Smrg # command to the queue. 1016615ffece8Smrg if test 1 -eq "$k"; then 10167a7b590b3Smrg # The first file doesn't have a previous command to add. 101683e51e026Smrg reload_objs=$objlist 101693e51e026Smrg eval concat_cmds=\"$reload_cmds\" 10170a7b590b3Smrg else 10171a7b590b3Smrg # All subsequent reloadable object files will link in 10172a7b590b3Smrg # the last one created. 101733e51e026Smrg reload_objs="$objlist $last_robj" 101743e51e026Smrg eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" 10175a7b590b3Smrg fi 1017615ffece8Smrg last_robj=$output_objdir/$output_la-$k.$objext 10177a7b590b3Smrg func_arith $k + 1 10178a7b590b3Smrg k=$func_arith_result 1017915ffece8Smrg output=$output_objdir/$output_la-$k.$objext 101803e51e026Smrg objlist=" $obj" 10181a7b590b3Smrg func_len " $last_robj" 10182a7b590b3Smrg func_arith $len0 + $func_len_result 10183a7b590b3Smrg len=$func_arith_result 10184a7b590b3Smrg fi 10185a7b590b3Smrg done 10186a7b590b3Smrg # Handle the remaining objects by creating one last 10187a7b590b3Smrg # reloadable object file. All subsequent reloadable object 10188a7b590b3Smrg # files will link in the last one created. 10189a7b590b3Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 101903e51e026Smrg reload_objs="$objlist $last_robj" 1019115ffece8Smrg eval concat_cmds=\"\$concat_cmds$reload_cmds\" 10192a7b590b3Smrg if test -n "$last_robj"; then 1019315ffece8Smrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 10194a7b590b3Smrg fi 101953e51e026Smrg func_append delfiles " $output" 10196943345d3Smrg 10197a7b590b3Smrg else 10198a7b590b3Smrg output= 10199a7b590b3Smrg fi 10200943345d3Smrg 1020115ffece8Smrg ${skipped_export-false} && { 1020215ffece8Smrg func_verbose "generating symbol list for '$libname.la'" 1020315ffece8Smrg export_symbols=$output_objdir/$libname.exp 10204a7b590b3Smrg $opt_dry_run || $RM $export_symbols 10205a7b590b3Smrg libobjs=$output 10206a7b590b3Smrg # Append the command to create the export file. 10207a7b590b3Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 10208a7b590b3Smrg eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" 10209a7b590b3Smrg if test -n "$last_robj"; then 10210a7b590b3Smrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 10211a7b590b3Smrg fi 1021215ffece8Smrg } 10213943345d3Smrg 10214a7b590b3Smrg test -n "$save_libobjs" && 10215a7b590b3Smrg func_verbose "creating a temporary reloadable object file: $output" 10216943345d3Smrg 10217a7b590b3Smrg # Loop through the commands generated above and execute them. 1021815ffece8Smrg save_ifs=$IFS; IFS='~' 10219a7b590b3Smrg for cmd in $concat_cmds; do 1022015ffece8Smrg IFS=$save_ifs 1022115ffece8Smrg $opt_quiet || { 1022215ffece8Smrg func_quote_arg expand,pretty "$cmd" 1022315ffece8Smrg eval "func_echo $func_quote_arg_result" 10224a7b590b3Smrg } 10225a7b590b3Smrg $opt_dry_run || eval "$cmd" || { 10226a7b590b3Smrg lt_exit=$? 10227a7b590b3Smrg 10228a7b590b3Smrg # Restore the uninstalled library and exit 1022915ffece8Smrg if test relink = "$opt_mode"; then 10230a7b590b3Smrg ( cd "$output_objdir" && \ 10231a7b590b3Smrg $RM "${realname}T" && \ 10232a7b590b3Smrg $MV "${realname}U" "$realname" ) 10233a7b590b3Smrg fi 10234943345d3Smrg 10235a7b590b3Smrg exit $lt_exit 10236a7b590b3Smrg } 10237a7b590b3Smrg done 1023815ffece8Smrg IFS=$save_ifs 10239943345d3Smrg 10240a7b590b3Smrg if test -n "$export_symbols_regex" && ${skipped_export-false}; then 10241a7b590b3Smrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 10242a7b590b3Smrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 10243943345d3Smrg fi 10244943345d3Smrg fi 10245943345d3Smrg 1024615ffece8Smrg ${skipped_export-false} && { 10247a7b590b3Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 1024815ffece8Smrg tmp_export_symbols=$export_symbols 1024915ffece8Smrg test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols 102503e51e026Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 10251a7b590b3Smrg fi 10252943345d3Smrg 10253a7b590b3Smrg if test -n "$orig_export_symbols"; then 10254a7b590b3Smrg # The given exports_symbols file has to be filtered, so filter it. 1025515ffece8Smrg func_verbose "filter symbol list for '$libname.la' to tag DATA exports" 10256a7b590b3Smrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 1025715ffece8Smrg # 's' commands, which not all seds can handle. GNU sed should be fine 10258a7b590b3Smrg # though. Also, the filter scales superlinearly with the number of 10259a7b590b3Smrg # global variables. join(1) would be nice here, but unfortunately 10260a7b590b3Smrg # isn't a blessed tool. 10261a7b590b3Smrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 102623e51e026Smrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 10263a7b590b3Smrg export_symbols=$output_objdir/$libname.def 10264a7b590b3Smrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 10265a7b590b3Smrg fi 1026615ffece8Smrg } 10267943345d3Smrg 10268a7b590b3Smrg libobjs=$output 10269a7b590b3Smrg # Restore the value of output. 10270a7b590b3Smrg output=$save_output 10271943345d3Smrg 10272a7b590b3Smrg if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then 10273a7b590b3Smrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 10274a7b590b3Smrg test "X$libobjs" = "X " && libobjs= 10275a7b590b3Smrg fi 10276a7b590b3Smrg # Expand the library linking commands again to reset the 10277a7b590b3Smrg # value of $libobjs for piecewise linking. 10278943345d3Smrg 10279a7b590b3Smrg # Do each of the archive commands. 1028015ffece8Smrg if test yes = "$module" && test -n "$module_cmds"; then 10281a7b590b3Smrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 10282a7b590b3Smrg cmds=$module_expsym_cmds 10283a7b590b3Smrg else 10284a7b590b3Smrg cmds=$module_cmds 10285943345d3Smrg fi 10286943345d3Smrg else 10287a7b590b3Smrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 10288a7b590b3Smrg cmds=$archive_expsym_cmds 10289a7b590b3Smrg else 10290a7b590b3Smrg cmds=$archive_cmds 10291a7b590b3Smrg fi 10292943345d3Smrg fi 10293a7b590b3Smrg fi 10294943345d3Smrg 10295a7b590b3Smrg if test -n "$delfiles"; then 10296a7b590b3Smrg # Append the command to remove temporary files to $cmds. 10297a7b590b3Smrg eval cmds=\"\$cmds~\$RM $delfiles\" 10298a7b590b3Smrg fi 10299943345d3Smrg 10300a7b590b3Smrg # Add any objects from preloaded convenience libraries 10301a7b590b3Smrg if test -n "$dlprefiles"; then 1030215ffece8Smrg gentop=$output_objdir/${outputname}x 103033e51e026Smrg func_append generated " $gentop" 10304943345d3Smrg 10305a7b590b3Smrg func_extract_archives $gentop $dlprefiles 103063e51e026Smrg func_append libobjs " $func_extract_archives_result" 10307a7b590b3Smrg test "X$libobjs" = "X " && libobjs= 10308a7b590b3Smrg fi 10309943345d3Smrg 1031015ffece8Smrg save_ifs=$IFS; IFS='~' 10311a7b590b3Smrg for cmd in $cmds; do 1031215ffece8Smrg IFS=$sp$nl 10313a7b590b3Smrg eval cmd=\"$cmd\" 1031415ffece8Smrg IFS=$save_ifs 1031515ffece8Smrg $opt_quiet || { 1031615ffece8Smrg func_quote_arg expand,pretty "$cmd" 1031715ffece8Smrg eval "func_echo $func_quote_arg_result" 10318a7b590b3Smrg } 10319a7b590b3Smrg $opt_dry_run || eval "$cmd" || { 10320a7b590b3Smrg lt_exit=$? 10321943345d3Smrg 10322a7b590b3Smrg # Restore the uninstalled library and exit 1032315ffece8Smrg if test relink = "$opt_mode"; then 10324a7b590b3Smrg ( cd "$output_objdir" && \ 10325a7b590b3Smrg $RM "${realname}T" && \ 10326a7b590b3Smrg $MV "${realname}U" "$realname" ) 10327a7b590b3Smrg fi 10328943345d3Smrg 10329a7b590b3Smrg exit $lt_exit 10330a7b590b3Smrg } 10331a7b590b3Smrg done 1033215ffece8Smrg IFS=$save_ifs 10333943345d3Smrg 10334a7b590b3Smrg # Restore the uninstalled library and exit 1033515ffece8Smrg if test relink = "$opt_mode"; then 10336a7b590b3Smrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? 10337943345d3Smrg 10338a7b590b3Smrg if test -n "$convenience"; then 10339a7b590b3Smrg if test -z "$whole_archive_flag_spec"; then 10340a7b590b3Smrg func_show_eval '${RM}r "$gentop"' 10341a7b590b3Smrg fi 10342a7b590b3Smrg fi 10343943345d3Smrg 10344a7b590b3Smrg exit $EXIT_SUCCESS 10345a7b590b3Smrg fi 10346a7b590b3Smrg 10347a7b590b3Smrg # Create links to the real library. 10348a7b590b3Smrg for linkname in $linknames; do 10349a7b590b3Smrg if test "$realname" != "$linkname"; then 10350a7b590b3Smrg func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' 10351943345d3Smrg fi 10352943345d3Smrg done 10353943345d3Smrg 10354a7b590b3Smrg # If -module or -export-dynamic was specified, set the dlname. 1035515ffece8Smrg if test yes = "$module" || test yes = "$export_dynamic"; then 10356a7b590b3Smrg # On all known operating systems, these are identical. 1035715ffece8Smrg dlname=$soname 10358a7b590b3Smrg fi 10359a7b590b3Smrg fi 10360943345d3Smrg ;; 10361943345d3Smrg 10362a7b590b3Smrg obj) 1036315ffece8Smrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 1036415ffece8Smrg func_warning "'-dlopen' is ignored for objects" 10365a7b590b3Smrg fi 10366943345d3Smrg 10367a7b590b3Smrg case " $deplibs" in 10368a7b590b3Smrg *\ -l* | *\ -L*) 1036915ffece8Smrg func_warning "'-l' and '-L' are ignored for objects" ;; 10370943345d3Smrg esac 10371943345d3Smrg 10372a7b590b3Smrg test -n "$rpath" && \ 1037315ffece8Smrg func_warning "'-rpath' is ignored for objects" 10374a7b590b3Smrg 10375a7b590b3Smrg test -n "$xrpath" && \ 1037615ffece8Smrg func_warning "'-R' is ignored for objects" 10377943345d3Smrg 10378a7b590b3Smrg test -n "$vinfo" && \ 1037915ffece8Smrg func_warning "'-version-info' is ignored for objects" 10380943345d3Smrg 10381a7b590b3Smrg test -n "$release" && \ 1038215ffece8Smrg func_warning "'-release' is ignored for objects" 10383a7b590b3Smrg 10384a7b590b3Smrg case $output in 10385a7b590b3Smrg *.lo) 10386a7b590b3Smrg test -n "$objs$old_deplibs" && \ 1038715ffece8Smrg func_fatal_error "cannot build library object '$output' from non-libtool objects" 10388a7b590b3Smrg 10389a7b590b3Smrg libobj=$output 10390a7b590b3Smrg func_lo2o "$libobj" 10391a7b590b3Smrg obj=$func_lo2o_result 10392943345d3Smrg ;; 10393943345d3Smrg *) 10394a7b590b3Smrg libobj= 1039515ffece8Smrg obj=$output 10396943345d3Smrg ;; 10397943345d3Smrg esac 10398943345d3Smrg 10399a7b590b3Smrg # Delete the old objects. 10400a7b590b3Smrg $opt_dry_run || $RM $obj $libobj 10401943345d3Smrg 10402a7b590b3Smrg # Objects from convenience libraries. This assumes 10403a7b590b3Smrg # single-version convenience libraries. Whenever we create 10404a7b590b3Smrg # different ones for PIC/non-PIC, this we'll have to duplicate 10405a7b590b3Smrg # the extraction. 10406a7b590b3Smrg reload_conv_objs= 10407a7b590b3Smrg gentop= 1040815ffece8Smrg # if reload_cmds runs $LD directly, get rid of -Wl from 1040915ffece8Smrg # whole_archive_flag_spec and hope we can get by with turning comma 1041015ffece8Smrg # into space. 1041115ffece8Smrg case $reload_cmds in 1041215ffece8Smrg *\$LD[\ \$]*) wl= ;; 1041315ffece8Smrg esac 10414a7b590b3Smrg if test -n "$convenience"; then 10415a7b590b3Smrg if test -n "$whole_archive_flag_spec"; then 10416a7b590b3Smrg eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" 1041715ffece8Smrg test -n "$wl" || tmp_whole_archive_flags=`$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` 1041815ffece8Smrg reload_conv_objs=$reload_objs\ $tmp_whole_archive_flags 10419a7b590b3Smrg else 1042015ffece8Smrg gentop=$output_objdir/${obj}x 104213e51e026Smrg func_append generated " $gentop" 10422943345d3Smrg 10423a7b590b3Smrg func_extract_archives $gentop $convenience 10424a7b590b3Smrg reload_conv_objs="$reload_objs $func_extract_archives_result" 10425a7b590b3Smrg fi 10426943345d3Smrg fi 10427943345d3Smrg 104283e51e026Smrg # If we're not building shared, we need to use non_pic_objs 1042915ffece8Smrg test yes = "$build_libtool_libs" || libobjs=$non_pic_objects 104303e51e026Smrg 10431a7b590b3Smrg # Create the old-style object. 1043215ffece8Smrg reload_objs=$objs$old_deplibs' '`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; /\.lib$/d; $lo2o" | $NL2SP`' '$reload_conv_objs 10433943345d3Smrg 1043415ffece8Smrg output=$obj 10435a7b590b3Smrg func_execute_cmds "$reload_cmds" 'exit $?' 10436943345d3Smrg 10437a7b590b3Smrg # Exit if we aren't doing a library object file. 10438a7b590b3Smrg if test -z "$libobj"; then 10439a7b590b3Smrg if test -n "$gentop"; then 10440a7b590b3Smrg func_show_eval '${RM}r "$gentop"' 10441a7b590b3Smrg fi 10442a7b590b3Smrg 10443a7b590b3Smrg exit $EXIT_SUCCESS 10444943345d3Smrg fi 10445a7b590b3Smrg 1044615ffece8Smrg test yes = "$build_libtool_libs" || { 10447a7b590b3Smrg if test -n "$gentop"; then 10448a7b590b3Smrg func_show_eval '${RM}r "$gentop"' 10449a7b590b3Smrg fi 10450a7b590b3Smrg 10451a7b590b3Smrg # Create an invalid libtool object if no PIC, so that we don't 10452a7b590b3Smrg # accidentally link it into a program. 10453a7b590b3Smrg # $show "echo timestamp > $libobj" 10454a7b590b3Smrg # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? 10455a7b590b3Smrg exit $EXIT_SUCCESS 1045615ffece8Smrg } 10457a7b590b3Smrg 1045815ffece8Smrg if test -n "$pic_flag" || test default != "$pic_mode"; then 10459a7b590b3Smrg # Only do commands if we really have different PIC objects. 10460a7b590b3Smrg reload_objs="$libobjs $reload_conv_objs" 1046115ffece8Smrg output=$libobj 10462a7b590b3Smrg func_execute_cmds "$reload_cmds" 'exit $?' 10463a7b590b3Smrg fi 10464a7b590b3Smrg 10465a7b590b3Smrg if test -n "$gentop"; then 10466a7b590b3Smrg func_show_eval '${RM}r "$gentop"' 10467a7b590b3Smrg fi 10468a7b590b3Smrg 10469a7b590b3Smrg exit $EXIT_SUCCESS 10470943345d3Smrg ;; 10471943345d3Smrg 10472a7b590b3Smrg prog) 10473a7b590b3Smrg case $host in 10474a7b590b3Smrg *cygwin*) func_stripname '' '.exe' "$output" 10475a7b590b3Smrg output=$func_stripname_result.exe;; 10476a7b590b3Smrg esac 10477a7b590b3Smrg test -n "$vinfo" && \ 1047815ffece8Smrg func_warning "'-version-info' is ignored for programs" 10479943345d3Smrg 10480a7b590b3Smrg test -n "$release" && \ 1048115ffece8Smrg func_warning "'-release' is ignored for programs" 10482943345d3Smrg 1048315ffece8Smrg $preload \ 1048415ffece8Smrg && test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \ 1048515ffece8Smrg && func_warning "'LT_INIT([dlopen])' not used. Assuming no dlopen support." 10486a7b590b3Smrg 10487a7b590b3Smrg case $host in 10488a7b590b3Smrg *-*-rhapsody* | *-*-darwin1.[012]) 10489a7b590b3Smrg # On Rhapsody replace the C library is the System framework 104903e51e026Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` 104913e51e026Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` 10492943345d3Smrg ;; 10493a7b590b3Smrg esac 10494943345d3Smrg 10495a7b590b3Smrg case $host in 10496a7b590b3Smrg *-*-darwin*) 10497a7b590b3Smrg # Don't allow lazy linking, it breaks C++ global constructors 10498a7b590b3Smrg # But is supposedly fixed on 10.4 or later (yay!). 1049915ffece8Smrg if test CXX = "$tagname"; then 10500a7b590b3Smrg case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 10501a7b590b3Smrg 10.[0123]) 1050215ffece8Smrg func_append compile_command " $wl-bind_at_load" 1050315ffece8Smrg func_append finalize_command " $wl-bind_at_load" 10504a7b590b3Smrg ;; 10505a7b590b3Smrg esac 10506943345d3Smrg fi 10507a7b590b3Smrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 105083e51e026Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 105093e51e026Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 10510a7b590b3Smrg ;; 10511a7b590b3Smrg esac 10512943345d3Smrg 10513943345d3Smrg 10514a7b590b3Smrg # move library search paths that coincide with paths to not yet 10515a7b590b3Smrg # installed libraries to the beginning of the library search list 10516a7b590b3Smrg new_libs= 10517a7b590b3Smrg for path in $notinst_path; do 10518a7b590b3Smrg case " $new_libs " in 10519a7b590b3Smrg *" -L$path/$objdir "*) ;; 10520a7b590b3Smrg *) 10521a7b590b3Smrg case " $compile_deplibs " in 10522a7b590b3Smrg *" -L$path/$objdir "*) 105233e51e026Smrg func_append new_libs " -L$path/$objdir" ;; 10524943345d3Smrg esac 10525a7b590b3Smrg ;; 10526a7b590b3Smrg esac 10527a7b590b3Smrg done 10528a7b590b3Smrg for deplib in $compile_deplibs; do 10529a7b590b3Smrg case $deplib in 10530a7b590b3Smrg -L*) 10531a7b590b3Smrg case " $new_libs " in 10532a7b590b3Smrg *" $deplib "*) ;; 105333e51e026Smrg *) func_append new_libs " $deplib" ;; 10534943345d3Smrg esac 10535a7b590b3Smrg ;; 105363e51e026Smrg *) func_append new_libs " $deplib" ;; 10537a7b590b3Smrg esac 10538a7b590b3Smrg done 1053915ffece8Smrg compile_deplibs=$new_libs 10540943345d3Smrg 10541943345d3Smrg 105423e51e026Smrg func_append compile_command " $compile_deplibs" 105433e51e026Smrg func_append finalize_command " $finalize_deplibs" 10544943345d3Smrg 10545a7b590b3Smrg if test -n "$rpath$xrpath"; then 10546a7b590b3Smrg # If the user specified any rpath flags, then add them. 10547a7b590b3Smrg for libdir in $rpath $xrpath; do 10548a7b590b3Smrg # This is the magic to use -rpath. 10549a7b590b3Smrg case "$finalize_rpath " in 10550a7b590b3Smrg *" $libdir "*) ;; 105513e51e026Smrg *) func_append finalize_rpath " $libdir" ;; 10552a7b590b3Smrg esac 10553a7b590b3Smrg done 10554a7b590b3Smrg fi 10555943345d3Smrg 10556a7b590b3Smrg # Now hardcode the library paths 10557a7b590b3Smrg rpath= 10558a7b590b3Smrg hardcode_libdirs= 10559a7b590b3Smrg for libdir in $compile_rpath $finalize_rpath; do 10560a7b590b3Smrg if test -n "$hardcode_libdir_flag_spec"; then 10561a7b590b3Smrg if test -n "$hardcode_libdir_separator"; then 10562a7b590b3Smrg if test -z "$hardcode_libdirs"; then 1056315ffece8Smrg hardcode_libdirs=$libdir 10564a7b590b3Smrg else 10565a7b590b3Smrg # Just accumulate the unique libdirs. 10566a7b590b3Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 10567a7b590b3Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 10568a7b590b3Smrg ;; 10569a7b590b3Smrg *) 105703e51e026Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 10571a7b590b3Smrg ;; 10572a7b590b3Smrg esac 10573a7b590b3Smrg fi 10574943345d3Smrg else 10575a7b590b3Smrg eval flag=\"$hardcode_libdir_flag_spec\" 105763e51e026Smrg func_append rpath " $flag" 10577943345d3Smrg fi 10578a7b590b3Smrg elif test -n "$runpath_var"; then 10579a7b590b3Smrg case "$perm_rpath " in 10580a7b590b3Smrg *" $libdir "*) ;; 105813e51e026Smrg *) func_append perm_rpath " $libdir" ;; 10582a7b590b3Smrg esac 10583a7b590b3Smrg fi 10584a7b590b3Smrg case $host in 10585a7b590b3Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 1058615ffece8Smrg testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'` 10587a7b590b3Smrg case :$dllsearchpath: in 10588a7b590b3Smrg *":$libdir:"*) ;; 10589a7b590b3Smrg ::) dllsearchpath=$libdir;; 105903e51e026Smrg *) func_append dllsearchpath ":$libdir";; 10591a7b590b3Smrg esac 10592a7b590b3Smrg case :$dllsearchpath: in 10593a7b590b3Smrg *":$testbindir:"*) ;; 10594a7b590b3Smrg ::) dllsearchpath=$testbindir;; 105953e51e026Smrg *) func_append dllsearchpath ":$testbindir";; 10596a7b590b3Smrg esac 10597a7b590b3Smrg ;; 10598a7b590b3Smrg esac 10599a7b590b3Smrg done 10600a7b590b3Smrg # Substitute the hardcoded libdirs into the rpath. 10601a7b590b3Smrg if test -n "$hardcode_libdir_separator" && 10602a7b590b3Smrg test -n "$hardcode_libdirs"; then 1060315ffece8Smrg libdir=$hardcode_libdirs 10604a7b590b3Smrg eval rpath=\" $hardcode_libdir_flag_spec\" 10605a7b590b3Smrg fi 1060615ffece8Smrg compile_rpath=$rpath 10607943345d3Smrg 10608a7b590b3Smrg rpath= 10609a7b590b3Smrg hardcode_libdirs= 10610a7b590b3Smrg for libdir in $finalize_rpath; do 10611a7b590b3Smrg if test -n "$hardcode_libdir_flag_spec"; then 10612a7b590b3Smrg if test -n "$hardcode_libdir_separator"; then 10613a7b590b3Smrg if test -z "$hardcode_libdirs"; then 1061415ffece8Smrg hardcode_libdirs=$libdir 10615a7b590b3Smrg else 10616a7b590b3Smrg # Just accumulate the unique libdirs. 10617a7b590b3Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 10618a7b590b3Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 10619a7b590b3Smrg ;; 10620a7b590b3Smrg *) 106213e51e026Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 10622a7b590b3Smrg ;; 10623a7b590b3Smrg esac 10624a7b590b3Smrg fi 10625943345d3Smrg else 10626a7b590b3Smrg eval flag=\"$hardcode_libdir_flag_spec\" 106273e51e026Smrg func_append rpath " $flag" 10628943345d3Smrg fi 10629a7b590b3Smrg elif test -n "$runpath_var"; then 10630a7b590b3Smrg case "$finalize_perm_rpath " in 10631a7b590b3Smrg *" $libdir "*) ;; 106323e51e026Smrg *) func_append finalize_perm_rpath " $libdir" ;; 10633a7b590b3Smrg esac 10634943345d3Smrg fi 10635a7b590b3Smrg done 10636a7b590b3Smrg # Substitute the hardcoded libdirs into the rpath. 10637a7b590b3Smrg if test -n "$hardcode_libdir_separator" && 10638a7b590b3Smrg test -n "$hardcode_libdirs"; then 1063915ffece8Smrg libdir=$hardcode_libdirs 10640a7b590b3Smrg eval rpath=\" $hardcode_libdir_flag_spec\" 10641a7b590b3Smrg fi 1064215ffece8Smrg finalize_rpath=$rpath 10643943345d3Smrg 1064415ffece8Smrg if test -n "$libobjs" && test yes = "$build_old_libs"; then 10645a7b590b3Smrg # Transform all the library objects into standard objects. 106463e51e026Smrg compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 106473e51e026Smrg finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 10648a7b590b3Smrg fi 10649943345d3Smrg 1065015ffece8Smrg func_generate_dlsyms "$outputname" "@PROGRAM@" false 10651943345d3Smrg 10652a7b590b3Smrg # template prelinking step 10653a7b590b3Smrg if test -n "$prelink_cmds"; then 10654a7b590b3Smrg func_execute_cmds "$prelink_cmds" 'exit $?' 10655a7b590b3Smrg fi 10656943345d3Smrg 1065715ffece8Smrg wrappers_required=: 10658a7b590b3Smrg case $host in 106593e51e026Smrg *cegcc* | *mingw32ce*) 106603e51e026Smrg # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. 1066115ffece8Smrg wrappers_required=false 106623e51e026Smrg ;; 10663a7b590b3Smrg *cygwin* | *mingw* ) 1066415ffece8Smrg test yes = "$build_libtool_libs" || wrappers_required=false 10665a7b590b3Smrg ;; 10666a7b590b3Smrg *) 1066715ffece8Smrg if test no = "$need_relink" || test yes != "$build_libtool_libs"; then 1066815ffece8Smrg wrappers_required=false 10669a7b590b3Smrg fi 10670a7b590b3Smrg ;; 10671a7b590b3Smrg esac 1067215ffece8Smrg $wrappers_required || { 10673a7b590b3Smrg # Replace the output file specification. 106743e51e026Smrg compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 1067515ffece8Smrg link_command=$compile_command$compile_rpath 10676943345d3Smrg 10677a7b590b3Smrg # We have no uninstalled library dependencies, so finalize right now. 10678a7b590b3Smrg exit_status=0 10679a7b590b3Smrg func_show_eval "$link_command" 'exit_status=$?' 10680943345d3Smrg 106813e51e026Smrg if test -n "$postlink_cmds"; then 106823e51e026Smrg func_to_tool_file "$output" 106833e51e026Smrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 106843e51e026Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 106853e51e026Smrg fi 106863e51e026Smrg 10687a7b590b3Smrg # Delete the generated files. 1068815ffece8Smrg if test -f "$output_objdir/${outputname}S.$objext"; then 1068915ffece8Smrg func_show_eval '$RM "$output_objdir/${outputname}S.$objext"' 10690943345d3Smrg fi 10691943345d3Smrg 10692a7b590b3Smrg exit $exit_status 1069315ffece8Smrg } 10694943345d3Smrg 10695a7b590b3Smrg if test -n "$compile_shlibpath$finalize_shlibpath"; then 10696a7b590b3Smrg compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" 10697a7b590b3Smrg fi 10698a7b590b3Smrg if test -n "$finalize_shlibpath"; then 10699a7b590b3Smrg finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" 10700a7b590b3Smrg fi 10701943345d3Smrg 10702a7b590b3Smrg compile_var= 10703a7b590b3Smrg finalize_var= 10704a7b590b3Smrg if test -n "$runpath_var"; then 10705a7b590b3Smrg if test -n "$perm_rpath"; then 10706a7b590b3Smrg # We should set the runpath_var. 10707a7b590b3Smrg rpath= 10708a7b590b3Smrg for dir in $perm_rpath; do 107093e51e026Smrg func_append rpath "$dir:" 10710a7b590b3Smrg done 10711a7b590b3Smrg compile_var="$runpath_var=\"$rpath\$$runpath_var\" " 10712943345d3Smrg fi 10713a7b590b3Smrg if test -n "$finalize_perm_rpath"; then 10714a7b590b3Smrg # We should set the runpath_var. 10715a7b590b3Smrg rpath= 10716a7b590b3Smrg for dir in $finalize_perm_rpath; do 107173e51e026Smrg func_append rpath "$dir:" 10718a7b590b3Smrg done 10719a7b590b3Smrg finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " 10720943345d3Smrg fi 10721a7b590b3Smrg fi 10722943345d3Smrg 1072315ffece8Smrg if test yes = "$no_install"; then 10724a7b590b3Smrg # We don't need to create a wrapper script. 1072515ffece8Smrg link_command=$compile_var$compile_command$compile_rpath 10726a7b590b3Smrg # Replace the output file specification. 107273e51e026Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 10728a7b590b3Smrg # Delete the old output file. 10729a7b590b3Smrg $opt_dry_run || $RM $output 10730a7b590b3Smrg # Link the executable and exit 10731a7b590b3Smrg func_show_eval "$link_command" 'exit $?' 107323e51e026Smrg 107333e51e026Smrg if test -n "$postlink_cmds"; then 107343e51e026Smrg func_to_tool_file "$output" 107353e51e026Smrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 107363e51e026Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 107373e51e026Smrg fi 107383e51e026Smrg 10739943345d3Smrg exit $EXIT_SUCCESS 10740a7b590b3Smrg fi 10741943345d3Smrg 1074215ffece8Smrg case $hardcode_action,$fast_install in 1074315ffece8Smrg relink,*) 1074415ffece8Smrg # Fast installation is not supported 1074515ffece8Smrg link_command=$compile_var$compile_command$compile_rpath 1074615ffece8Smrg relink_command=$finalize_var$finalize_command$finalize_rpath 10747a7b590b3Smrg 1074815ffece8Smrg func_warning "this platform does not like uninstalled shared libraries" 1074915ffece8Smrg func_warning "'$output' will be relinked during installation" 1075015ffece8Smrg ;; 1075115ffece8Smrg *,yes) 1075215ffece8Smrg link_command=$finalize_var$compile_command$finalize_rpath 1075315ffece8Smrg relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` 1075415ffece8Smrg ;; 1075515ffece8Smrg *,no) 1075615ffece8Smrg link_command=$compile_var$compile_command$compile_rpath 1075715ffece8Smrg relink_command=$finalize_var$finalize_command$finalize_rpath 1075815ffece8Smrg ;; 1075915ffece8Smrg *,needless) 1076015ffece8Smrg link_command=$finalize_var$compile_command$finalize_rpath 1076115ffece8Smrg relink_command= 1076215ffece8Smrg ;; 1076315ffece8Smrg esac 10764943345d3Smrg 10765a7b590b3Smrg # Replace the output file specification. 107663e51e026Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` 10767943345d3Smrg 10768a7b590b3Smrg # Delete the old output files. 10769a7b590b3Smrg $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname 10770943345d3Smrg 10771a7b590b3Smrg func_show_eval "$link_command" 'exit $?' 10772943345d3Smrg 107733e51e026Smrg if test -n "$postlink_cmds"; then 107743e51e026Smrg func_to_tool_file "$output_objdir/$outputname" 107753e51e026Smrg 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'` 107763e51e026Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 107773e51e026Smrg fi 107783e51e026Smrg 10779a7b590b3Smrg # Now create the wrapper script. 10780a7b590b3Smrg func_verbose "creating $output" 10781943345d3Smrg 10782a7b590b3Smrg # Quote the relink command for shipping. 10783a7b590b3Smrg if test -n "$relink_command"; then 10784a7b590b3Smrg # Preserve any variables that may affect compiler behavior 10785a7b590b3Smrg for var in $variables_saved_for_relink; do 10786a7b590b3Smrg if eval test -z \"\${$var+set}\"; then 10787a7b590b3Smrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 10788a7b590b3Smrg elif eval var_value=\$$var; test -z "$var_value"; then 10789a7b590b3Smrg relink_command="$var=; export $var; $relink_command" 10790943345d3Smrg else 1079115ffece8Smrg func_quote_arg pretty "$var_value" 1079215ffece8Smrg relink_command="$var=$func_quote_arg_result; export $var; $relink_command" 10793943345d3Smrg fi 10794a7b590b3Smrg done 1079515ffece8Smrg func_quote eval cd "`pwd`" 1079615ffece8Smrg func_quote_arg pretty,unquoted "($func_quote_result; $relink_command)" 1079715ffece8Smrg relink_command=$func_quote_arg_unquoted_result 10798a7b590b3Smrg fi 10799a7b590b3Smrg 10800a7b590b3Smrg # Only actually do things if not in dry run mode. 10801a7b590b3Smrg $opt_dry_run || { 10802a7b590b3Smrg # win32 will think the script is a binary if it has 10803a7b590b3Smrg # a .exe suffix, so we strip it off here. 10804a7b590b3Smrg case $output in 10805a7b590b3Smrg *.exe) func_stripname '' '.exe' "$output" 10806a7b590b3Smrg output=$func_stripname_result ;; 10807a7b590b3Smrg esac 10808a7b590b3Smrg # test for cygwin because mv fails w/o .exe extensions 10809a7b590b3Smrg case $host in 10810a7b590b3Smrg *cygwin*) 10811a7b590b3Smrg exeext=.exe 10812a7b590b3Smrg func_stripname '' '.exe' "$outputname" 10813a7b590b3Smrg outputname=$func_stripname_result ;; 10814a7b590b3Smrg *) exeext= ;; 10815943345d3Smrg esac 10816a7b590b3Smrg case $host in 10817a7b590b3Smrg *cygwin* | *mingw* ) 10818a7b590b3Smrg func_dirname_and_basename "$output" "" "." 10819a7b590b3Smrg output_name=$func_basename_result 10820a7b590b3Smrg output_path=$func_dirname_result 1082115ffece8Smrg cwrappersource=$output_path/$objdir/lt-$output_name.c 1082215ffece8Smrg cwrapper=$output_path/$output_name.exe 10823a7b590b3Smrg $RM $cwrappersource $cwrapper 10824a7b590b3Smrg trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 10825a7b590b3Smrg 10826a7b590b3Smrg func_emit_cwrapperexe_src > $cwrappersource 10827a7b590b3Smrg 10828a7b590b3Smrg # The wrapper executable is built using the $host compiler, 10829a7b590b3Smrg # because it contains $host paths and files. If cross- 10830a7b590b3Smrg # compiling, it, like the target executable, must be 10831a7b590b3Smrg # executed on the $host or under an emulation environment. 10832a7b590b3Smrg $opt_dry_run || { 10833a7b590b3Smrg $LTCC $LTCFLAGS -o $cwrapper $cwrappersource 10834a7b590b3Smrg $STRIP $cwrapper 10835a7b590b3Smrg } 10836943345d3Smrg 10837a7b590b3Smrg # Now, create the wrapper script for func_source use: 10838a7b590b3Smrg func_ltwrapper_scriptname $cwrapper 10839a7b590b3Smrg $RM $func_ltwrapper_scriptname_result 10840a7b590b3Smrg trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 10841a7b590b3Smrg $opt_dry_run || { 10842a7b590b3Smrg # note: this script will not be executed, so do not chmod. 1084315ffece8Smrg if test "x$build" = "x$host"; then 10844a7b590b3Smrg $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result 10845a7b590b3Smrg else 10846a7b590b3Smrg func_emit_wrapper no > $func_ltwrapper_scriptname_result 10847a7b590b3Smrg fi 10848a7b590b3Smrg } 10849a7b590b3Smrg ;; 10850a7b590b3Smrg * ) 10851a7b590b3Smrg $RM $output 10852a7b590b3Smrg trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 10853943345d3Smrg 10854a7b590b3Smrg func_emit_wrapper no > $output 10855a7b590b3Smrg chmod +x $output 10856a7b590b3Smrg ;; 10857a7b590b3Smrg esac 10858a7b590b3Smrg } 10859a7b590b3Smrg exit $EXIT_SUCCESS 10860a7b590b3Smrg ;; 10861a7b590b3Smrg esac 10862943345d3Smrg 10863a7b590b3Smrg # See if we need to build an old-fashioned archive. 10864a7b590b3Smrg for oldlib in $oldlibs; do 10865943345d3Smrg 1086615ffece8Smrg case $build_libtool_libs in 1086715ffece8Smrg convenience) 1086815ffece8Smrg oldobjs="$libobjs_save $symfileobj" 1086915ffece8Smrg addlibs=$convenience 10870a7b590b3Smrg build_libtool_libs=no 1087115ffece8Smrg ;; 1087215ffece8Smrg module) 1087315ffece8Smrg oldobjs=$libobjs_save 1087415ffece8Smrg addlibs=$old_convenience 1087515ffece8Smrg build_libtool_libs=no 1087615ffece8Smrg ;; 1087715ffece8Smrg *) 10878a7b590b3Smrg oldobjs="$old_deplibs $non_pic_objects" 1087915ffece8Smrg $preload && test -f "$symfileobj" \ 1088015ffece8Smrg && func_append oldobjs " $symfileobj" 1088115ffece8Smrg addlibs=$old_convenience 1088215ffece8Smrg ;; 1088315ffece8Smrg esac 10884943345d3Smrg 10885a7b590b3Smrg if test -n "$addlibs"; then 1088615ffece8Smrg gentop=$output_objdir/${outputname}x 108873e51e026Smrg func_append generated " $gentop" 10888943345d3Smrg 10889a7b590b3Smrg func_extract_archives $gentop $addlibs 108903e51e026Smrg func_append oldobjs " $func_extract_archives_result" 10891a7b590b3Smrg fi 10892943345d3Smrg 10893a7b590b3Smrg # Do each command in the archive commands. 1089415ffece8Smrg if test -n "$old_archive_from_new_cmds" && test yes = "$build_libtool_libs"; then 10895a7b590b3Smrg cmds=$old_archive_from_new_cmds 10896a7b590b3Smrg else 10897943345d3Smrg 10898a7b590b3Smrg # Add any objects from preloaded convenience libraries 10899a7b590b3Smrg if test -n "$dlprefiles"; then 1090015ffece8Smrg gentop=$output_objdir/${outputname}x 109013e51e026Smrg func_append generated " $gentop" 10902943345d3Smrg 10903a7b590b3Smrg func_extract_archives $gentop $dlprefiles 109043e51e026Smrg func_append oldobjs " $func_extract_archives_result" 10905a7b590b3Smrg fi 10906943345d3Smrg 10907a7b590b3Smrg # POSIX demands no paths to be encoded in archives. We have 10908a7b590b3Smrg # to avoid creating archives with duplicate basenames if we 10909a7b590b3Smrg # might have to extract them afterwards, e.g., when creating a 10910a7b590b3Smrg # static archive out of a convenience library, or when linking 10911a7b590b3Smrg # the entirety of a libtool archive into another (currently 10912a7b590b3Smrg # not supported by libtool). 10913a7b590b3Smrg if (for obj in $oldobjs 10914a7b590b3Smrg do 10915a7b590b3Smrg func_basename "$obj" 10916a7b590b3Smrg $ECHO "$func_basename_result" 10917a7b590b3Smrg done | sort | sort -uc >/dev/null 2>&1); then 10918a7b590b3Smrg : 10919a7b590b3Smrg else 109203e51e026Smrg echo "copying selected object files to avoid basename conflicts..." 1092115ffece8Smrg gentop=$output_objdir/${outputname}x 109223e51e026Smrg func_append generated " $gentop" 10923a7b590b3Smrg func_mkdir_p "$gentop" 10924a7b590b3Smrg save_oldobjs=$oldobjs 10925a7b590b3Smrg oldobjs= 10926a7b590b3Smrg counter=1 10927a7b590b3Smrg for obj in $save_oldobjs 10928a7b590b3Smrg do 10929a7b590b3Smrg func_basename "$obj" 1093015ffece8Smrg objbase=$func_basename_result 10931a7b590b3Smrg case " $oldobjs " in 10932a7b590b3Smrg " ") oldobjs=$obj ;; 10933a7b590b3Smrg *[\ /]"$objbase "*) 10934a7b590b3Smrg while :; do 10935a7b590b3Smrg # Make sure we don't pick an alternate name that also 10936a7b590b3Smrg # overlaps. 10937a7b590b3Smrg newobj=lt$counter-$objbase 10938a7b590b3Smrg func_arith $counter + 1 10939a7b590b3Smrg counter=$func_arith_result 10940a7b590b3Smrg case " $oldobjs " in 10941a7b590b3Smrg *[\ /]"$newobj "*) ;; 10942a7b590b3Smrg *) if test ! -f "$gentop/$newobj"; then break; fi ;; 10943a7b590b3Smrg esac 10944a7b590b3Smrg done 10945a7b590b3Smrg func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" 109463e51e026Smrg func_append oldobjs " $gentop/$newobj" 10947a7b590b3Smrg ;; 109483e51e026Smrg *) func_append oldobjs " $obj" ;; 10949a7b590b3Smrg esac 10950943345d3Smrg done 10951943345d3Smrg fi 109523e51e026Smrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 109533e51e026Smrg tool_oldlib=$func_to_tool_file_result 10954a7b590b3Smrg eval cmds=\"$old_archive_cmds\" 10955943345d3Smrg 10956a7b590b3Smrg func_len " $cmds" 10957a7b590b3Smrg len=$func_len_result 10958a7b590b3Smrg if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 10959a7b590b3Smrg cmds=$old_archive_cmds 109603e51e026Smrg elif test -n "$archiver_list_spec"; then 109613e51e026Smrg func_verbose "using command file archive linking..." 109623e51e026Smrg for obj in $oldobjs 109633e51e026Smrg do 109643e51e026Smrg func_to_tool_file "$obj" 109653e51e026Smrg $ECHO "$func_to_tool_file_result" 109663e51e026Smrg done > $output_objdir/$libname.libcmd 109673e51e026Smrg func_to_tool_file "$output_objdir/$libname.libcmd" 109683e51e026Smrg oldobjs=" $archiver_list_spec$func_to_tool_file_result" 109693e51e026Smrg cmds=$old_archive_cmds 10970a7b590b3Smrg else 10971a7b590b3Smrg # the command line is too long to link in one step, link in parts 10972a7b590b3Smrg func_verbose "using piecewise archive linking..." 10973a7b590b3Smrg save_RANLIB=$RANLIB 10974a7b590b3Smrg RANLIB=: 10975a7b590b3Smrg objlist= 10976a7b590b3Smrg concat_cmds= 10977a7b590b3Smrg save_oldobjs=$oldobjs 10978a7b590b3Smrg oldobjs= 10979a7b590b3Smrg # Is there a better way of finding the last object in the list? 10980a7b590b3Smrg for obj in $save_oldobjs 10981a7b590b3Smrg do 10982a7b590b3Smrg last_oldobj=$obj 10983a7b590b3Smrg done 10984a7b590b3Smrg eval test_cmds=\"$old_archive_cmds\" 10985a7b590b3Smrg func_len " $test_cmds" 10986a7b590b3Smrg len0=$func_len_result 10987a7b590b3Smrg len=$len0 10988a7b590b3Smrg for obj in $save_oldobjs 10989a7b590b3Smrg do 10990a7b590b3Smrg func_len " $obj" 10991a7b590b3Smrg func_arith $len + $func_len_result 10992a7b590b3Smrg len=$func_arith_result 10993a7b590b3Smrg func_append objlist " $obj" 10994a7b590b3Smrg if test "$len" -lt "$max_cmd_len"; then 10995a7b590b3Smrg : 10996a7b590b3Smrg else 10997a7b590b3Smrg # the above command should be used before it gets too long 10998a7b590b3Smrg oldobjs=$objlist 1099915ffece8Smrg if test "$obj" = "$last_oldobj"; then 11000a7b590b3Smrg RANLIB=$save_RANLIB 11001a7b590b3Smrg fi 11002a7b590b3Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 1100315ffece8Smrg eval concat_cmds=\"\$concat_cmds$old_archive_cmds\" 11004a7b590b3Smrg objlist= 11005a7b590b3Smrg len=$len0 11006a7b590b3Smrg fi 11007a7b590b3Smrg done 11008a7b590b3Smrg RANLIB=$save_RANLIB 11009a7b590b3Smrg oldobjs=$objlist 1101015ffece8Smrg if test -z "$oldobjs"; then 11011a7b590b3Smrg eval cmds=\"\$concat_cmds\" 11012a7b590b3Smrg else 11013a7b590b3Smrg eval cmds=\"\$concat_cmds~\$old_archive_cmds\" 11014a7b590b3Smrg fi 11015a7b590b3Smrg fi 11016a7b590b3Smrg fi 11017a7b590b3Smrg func_execute_cmds "$cmds" 'exit $?' 11018943345d3Smrg done 11019943345d3Smrg 11020a7b590b3Smrg test -n "$generated" && \ 11021a7b590b3Smrg func_show_eval "${RM}r$generated" 11022943345d3Smrg 11023a7b590b3Smrg # Now create the libtool archive. 11024a7b590b3Smrg case $output in 11025a7b590b3Smrg *.la) 11026a7b590b3Smrg old_library= 1102715ffece8Smrg test yes = "$build_old_libs" && old_library=$libname.$libext 11028a7b590b3Smrg func_verbose "creating $output" 11029943345d3Smrg 11030a7b590b3Smrg # Preserve any variables that may affect compiler behavior 11031a7b590b3Smrg for var in $variables_saved_for_relink; do 11032a7b590b3Smrg if eval test -z \"\${$var+set}\"; then 11033a7b590b3Smrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 11034a7b590b3Smrg elif eval var_value=\$$var; test -z "$var_value"; then 11035a7b590b3Smrg relink_command="$var=; export $var; $relink_command" 11036943345d3Smrg else 1103715ffece8Smrg func_quote_arg pretty,unquoted "$var_value" 1103815ffece8Smrg relink_command="$var=$func_quote_arg_unquoted_result; export $var; $relink_command" 11039943345d3Smrg fi 11040a7b590b3Smrg done 11041a7b590b3Smrg # Quote the link command for shipping. 1104215ffece8Smrg func_quote eval cd "`pwd`" 1104315ffece8Smrg relink_command="($func_quote_result; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" 1104415ffece8Smrg func_quote_arg pretty,unquoted "$relink_command" 1104515ffece8Smrg relink_command=$func_quote_arg_unquoted_result 1104615ffece8Smrg if test yes = "$hardcode_automatic"; then 11047a7b590b3Smrg relink_command= 11048a7b590b3Smrg fi 11049943345d3Smrg 11050a7b590b3Smrg # Only create the output if not a dry run. 11051a7b590b3Smrg $opt_dry_run || { 11052a7b590b3Smrg for installed in no yes; do 1105315ffece8Smrg if test yes = "$installed"; then 11054a7b590b3Smrg if test -z "$install_libdir"; then 11055a7b590b3Smrg break 11056a7b590b3Smrg fi 1105715ffece8Smrg output=$output_objdir/${outputname}i 11058a7b590b3Smrg # Replace all uninstalled libtool libraries with the installed ones 11059a7b590b3Smrg newdependency_libs= 11060a7b590b3Smrg for deplib in $dependency_libs; do 11061a7b590b3Smrg case $deplib in 11062a7b590b3Smrg *.la) 11063a7b590b3Smrg func_basename "$deplib" 1106415ffece8Smrg name=$func_basename_result 110653e51e026Smrg func_resolve_sysroot "$deplib" 1106615ffece8Smrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` 11067a7b590b3Smrg test -z "$libdir" && \ 1106815ffece8Smrg func_fatal_error "'$deplib' is not a valid libtool archive" 110693e51e026Smrg func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" 110703e51e026Smrg ;; 110713e51e026Smrg -L*) 110723e51e026Smrg func_stripname -L '' "$deplib" 110733e51e026Smrg func_replace_sysroot "$func_stripname_result" 110743e51e026Smrg func_append newdependency_libs " -L$func_replace_sysroot_result" 11075a7b590b3Smrg ;; 110763e51e026Smrg -R*) 110773e51e026Smrg func_stripname -R '' "$deplib" 110783e51e026Smrg func_replace_sysroot "$func_stripname_result" 110793e51e026Smrg func_append newdependency_libs " -R$func_replace_sysroot_result" 110803e51e026Smrg ;; 110813e51e026Smrg *) func_append newdependency_libs " $deplib" ;; 11082a7b590b3Smrg esac 11083a7b590b3Smrg done 1108415ffece8Smrg dependency_libs=$newdependency_libs 11085a7b590b3Smrg newdlfiles= 11086a7b590b3Smrg 11087a7b590b3Smrg for lib in $dlfiles; do 11088a7b590b3Smrg case $lib in 11089a7b590b3Smrg *.la) 11090a7b590b3Smrg func_basename "$lib" 1109115ffece8Smrg name=$func_basename_result 1109215ffece8Smrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 11093a7b590b3Smrg test -z "$libdir" && \ 1109415ffece8Smrg func_fatal_error "'$lib' is not a valid libtool archive" 110953e51e026Smrg func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" 11096a7b590b3Smrg ;; 110973e51e026Smrg *) func_append newdlfiles " $lib" ;; 11098a7b590b3Smrg esac 11099a7b590b3Smrg done 1110015ffece8Smrg dlfiles=$newdlfiles 11101a7b590b3Smrg newdlprefiles= 11102a7b590b3Smrg for lib in $dlprefiles; do 11103a7b590b3Smrg case $lib in 11104a7b590b3Smrg *.la) 11105a7b590b3Smrg # Only pass preopened files to the pseudo-archive (for 11106a7b590b3Smrg # eventual linking with the app. that links it) if we 11107a7b590b3Smrg # didn't already link the preopened objects directly into 11108a7b590b3Smrg # the library: 11109a7b590b3Smrg func_basename "$lib" 1111015ffece8Smrg name=$func_basename_result 1111115ffece8Smrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 11112a7b590b3Smrg test -z "$libdir" && \ 1111315ffece8Smrg func_fatal_error "'$lib' is not a valid libtool archive" 111143e51e026Smrg func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" 11115a7b590b3Smrg ;; 11116a7b590b3Smrg esac 11117a7b590b3Smrg done 1111815ffece8Smrg dlprefiles=$newdlprefiles 11119a7b590b3Smrg else 11120a7b590b3Smrg newdlfiles= 11121a7b590b3Smrg for lib in $dlfiles; do 11122a7b590b3Smrg case $lib in 1112315ffece8Smrg [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; 11124a7b590b3Smrg *) abs=`pwd`"/$lib" ;; 11125a7b590b3Smrg esac 111263e51e026Smrg func_append newdlfiles " $abs" 11127a7b590b3Smrg done 1112815ffece8Smrg dlfiles=$newdlfiles 11129a7b590b3Smrg newdlprefiles= 11130a7b590b3Smrg for lib in $dlprefiles; do 11131a7b590b3Smrg case $lib in 1113215ffece8Smrg [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; 11133a7b590b3Smrg *) abs=`pwd`"/$lib" ;; 11134a7b590b3Smrg esac 111353e51e026Smrg func_append newdlprefiles " $abs" 11136a7b590b3Smrg done 1113715ffece8Smrg dlprefiles=$newdlprefiles 11138a7b590b3Smrg fi 11139a7b590b3Smrg $RM $output 11140a7b590b3Smrg # place dlname in correct position for cygwin 111413e51e026Smrg # In fact, it would be nice if we could use this code for all target 111423e51e026Smrg # systems that can't hard-code library paths into their executables 111433e51e026Smrg # and that have no shared library path variable independent of PATH, 111443e51e026Smrg # but it turns out we can't easily determine that from inspecting 111453e51e026Smrg # libtool variables, so we have to hard-code the OSs to which it 111463e51e026Smrg # applies here; at the moment, that means platforms that use the PE 111473e51e026Smrg # object format with DLL files. See the long comment at the top of 111483e51e026Smrg # tests/bindir.at for full details. 11149a7b590b3Smrg tdlname=$dlname 11150a7b590b3Smrg case $host,$output,$installed,$module,$dlname in 111513e51e026Smrg *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) 111523e51e026Smrg # If a -bindir argument was supplied, place the dll there. 1115315ffece8Smrg if test -n "$bindir"; then 111543e51e026Smrg func_relative_path "$install_libdir" "$bindir" 1115515ffece8Smrg tdlname=$func_relative_path_result/$dlname 111563e51e026Smrg else 111573e51e026Smrg # Otherwise fall back on heuristic. 111583e51e026Smrg tdlname=../bin/$dlname 111593e51e026Smrg fi 111603e51e026Smrg ;; 11161a7b590b3Smrg esac 11162a7b590b3Smrg $ECHO > $output "\ 11163a7b590b3Smrg# $outputname - a libtool library file 1116415ffece8Smrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 11165a7b590b3Smrg# 11166a7b590b3Smrg# Please DO NOT delete this file! 11167a7b590b3Smrg# It is necessary for linking the library. 11168943345d3Smrg 11169a7b590b3Smrg# The name that we can dlopen(3). 11170a7b590b3Smrgdlname='$tdlname' 11171943345d3Smrg 11172a7b590b3Smrg# Names of this library. 11173a7b590b3Smrglibrary_names='$library_names' 11174943345d3Smrg 11175a7b590b3Smrg# The name of the static archive. 11176a7b590b3Smrgold_library='$old_library' 11177943345d3Smrg 1117815ffece8Smrg# Linker flags that cannot go in dependency_libs. 11179a7b590b3Smrginherited_linker_flags='$new_inherited_linker_flags' 11180943345d3Smrg 11181a7b590b3Smrg# Libraries that this one depends upon. 11182a7b590b3Smrgdependency_libs='$dependency_libs' 11183943345d3Smrg 11184a7b590b3Smrg# Names of additional weak libraries provided by this library 11185a7b590b3Smrgweak_library_names='$weak_libs' 11186943345d3Smrg 11187a7b590b3Smrg# Version information for $libname. 11188a7b590b3Smrgcurrent=$current 11189a7b590b3Smrgage=$age 11190a7b590b3Smrgrevision=$revision 11191943345d3Smrg 11192a7b590b3Smrg# Is this an already installed library? 11193a7b590b3Smrginstalled=$installed 11194943345d3Smrg 11195a7b590b3Smrg# Should we warn about portability when linking against -modules? 11196a7b590b3Smrgshouldnotlink=$module 11197943345d3Smrg 11198a7b590b3Smrg# Files to dlopen/dlpreopen 11199a7b590b3Smrgdlopen='$dlfiles' 11200a7b590b3Smrgdlpreopen='$dlprefiles' 11201943345d3Smrg 11202a7b590b3Smrg# Directory that this library needs to be installed in: 11203a7b590b3Smrglibdir='$install_libdir'" 1120415ffece8Smrg if test no,yes = "$installed,$need_relink"; then 11205a7b590b3Smrg $ECHO >> $output "\ 11206a7b590b3Smrgrelink_command=\"$relink_command\"" 11207a7b590b3Smrg fi 11208a7b590b3Smrg done 11209a7b590b3Smrg } 11210943345d3Smrg 11211a7b590b3Smrg # Do a symbolic link so that the libtool archive can be found in 11212a7b590b3Smrg # LD_LIBRARY_PATH before the program is installed. 11213a7b590b3Smrg func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' 11214a7b590b3Smrg ;; 11215a7b590b3Smrg esac 11216a7b590b3Smrg exit $EXIT_SUCCESS 11217a7b590b3Smrg} 11218943345d3Smrg 1121915ffece8Smrgif test link = "$opt_mode" || test relink = "$opt_mode"; then 1122015ffece8Smrg func_mode_link ${1+"$@"} 1122115ffece8Smrgfi 11222f67b85aaSmrg 11223943345d3Smrg 11224a7b590b3Smrg# func_mode_uninstall arg... 11225a7b590b3Smrgfunc_mode_uninstall () 11226a7b590b3Smrg{ 1122715ffece8Smrg $debug_cmd 1122815ffece8Smrg 1122915ffece8Smrg RM=$nonopt 11230943345d3Smrg files= 1123115ffece8Smrg rmforce=false 11232943345d3Smrg exit_status=0 11233943345d3Smrg 11234943345d3Smrg # This variable tells wrapper scripts just to set variables rather 11235943345d3Smrg # than running their programs. 1123615ffece8Smrg libtool_install_magic=$magic 11237943345d3Smrg 11238943345d3Smrg for arg 11239943345d3Smrg do 11240943345d3Smrg case $arg in 1124115ffece8Smrg -f) func_append RM " $arg"; rmforce=: ;; 112423e51e026Smrg -*) func_append RM " $arg" ;; 112433e51e026Smrg *) func_append files " $arg" ;; 11244943345d3Smrg esac 11245943345d3Smrg done 11246943345d3Smrg 11247a7b590b3Smrg test -z "$RM" && \ 11248a7b590b3Smrg func_fatal_help "you must specify an RM program" 11249943345d3Smrg 11250943345d3Smrg rmdirs= 11251943345d3Smrg 11252943345d3Smrg for file in $files; do 11253a7b590b3Smrg func_dirname "$file" "" "." 1125415ffece8Smrg dir=$func_dirname_result 1125515ffece8Smrg if test . = "$dir"; then 1125615ffece8Smrg odir=$objdir 11257943345d3Smrg else 1125815ffece8Smrg odir=$dir/$objdir 11259943345d3Smrg fi 11260a7b590b3Smrg func_basename "$file" 1126115ffece8Smrg name=$func_basename_result 1126215ffece8Smrg test uninstall = "$opt_mode" && odir=$dir 11263943345d3Smrg 112643e51e026Smrg # Remember odir for removal later, being careful to avoid duplicates 1126515ffece8Smrg if test clean = "$opt_mode"; then 11266943345d3Smrg case " $rmdirs " in 112673e51e026Smrg *" $odir "*) ;; 112683e51e026Smrg *) func_append rmdirs " $odir" ;; 11269943345d3Smrg esac 11270943345d3Smrg fi 11271943345d3Smrg 11272943345d3Smrg # Don't error if the file doesn't exist and rm -f was used. 11273a7b590b3Smrg if { test -L "$file"; } >/dev/null 2>&1 || 11274a7b590b3Smrg { test -h "$file"; } >/dev/null 2>&1 || 11275a7b590b3Smrg test -f "$file"; then 11276943345d3Smrg : 11277943345d3Smrg elif test -d "$file"; then 11278943345d3Smrg exit_status=1 11279943345d3Smrg continue 1128015ffece8Smrg elif $rmforce; then 11281943345d3Smrg continue 11282943345d3Smrg fi 11283943345d3Smrg 1128415ffece8Smrg rmfiles=$file 11285943345d3Smrg 11286943345d3Smrg case $name in 11287943345d3Smrg *.la) 11288943345d3Smrg # Possibly a libtool archive, so verify it. 11289a7b590b3Smrg if func_lalib_p "$file"; then 11290a7b590b3Smrg func_source $dir/$name 11291943345d3Smrg 11292943345d3Smrg # Delete the libtool libraries and symlinks. 11293943345d3Smrg for n in $library_names; do 112943e51e026Smrg func_append rmfiles " $odir/$n" 11295943345d3Smrg done 112963e51e026Smrg test -n "$old_library" && func_append rmfiles " $odir/$old_library" 11297943345d3Smrg 1129815ffece8Smrg case $opt_mode in 11299943345d3Smrg clean) 113003e51e026Smrg case " $library_names " in 11301943345d3Smrg *" $dlname "*) ;; 113023e51e026Smrg *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; 11303943345d3Smrg esac 113043e51e026Smrg test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" 11305943345d3Smrg ;; 11306943345d3Smrg uninstall) 11307943345d3Smrg if test -n "$library_names"; then 11308943345d3Smrg # Do each command in the postuninstall commands. 1130915ffece8Smrg func_execute_cmds "$postuninstall_cmds" '$rmforce || exit_status=1' 11310943345d3Smrg fi 11311943345d3Smrg 11312943345d3Smrg if test -n "$old_library"; then 11313943345d3Smrg # Do each command in the old_postuninstall commands. 1131415ffece8Smrg func_execute_cmds "$old_postuninstall_cmds" '$rmforce || exit_status=1' 11315943345d3Smrg fi 11316943345d3Smrg # FIXME: should reinstall the best remaining shared library. 11317943345d3Smrg ;; 11318943345d3Smrg esac 11319943345d3Smrg fi 11320943345d3Smrg ;; 11321943345d3Smrg 11322943345d3Smrg *.lo) 11323943345d3Smrg # Possibly a libtool object, so verify it. 11324a7b590b3Smrg if func_lalib_p "$file"; then 11325943345d3Smrg 11326943345d3Smrg # Read the .lo file 11327a7b590b3Smrg func_source $dir/$name 11328943345d3Smrg 11329943345d3Smrg # Add PIC object to the list of files to remove. 1133015ffece8Smrg if test -n "$pic_object" && test none != "$pic_object"; then 113313e51e026Smrg func_append rmfiles " $dir/$pic_object" 11332943345d3Smrg fi 11333943345d3Smrg 11334943345d3Smrg # Add non-PIC object to the list of files to remove. 1133515ffece8Smrg if test -n "$non_pic_object" && test none != "$non_pic_object"; then 113363e51e026Smrg func_append rmfiles " $dir/$non_pic_object" 11337943345d3Smrg fi 11338943345d3Smrg fi 11339943345d3Smrg ;; 11340943345d3Smrg 11341943345d3Smrg *) 1134215ffece8Smrg if test clean = "$opt_mode"; then 11343943345d3Smrg noexename=$name 11344943345d3Smrg case $file in 11345943345d3Smrg *.exe) 11346a7b590b3Smrg func_stripname '' '.exe' "$file" 11347a7b590b3Smrg file=$func_stripname_result 11348a7b590b3Smrg func_stripname '' '.exe' "$name" 11349a7b590b3Smrg noexename=$func_stripname_result 11350943345d3Smrg # $file with .exe has already been added to rmfiles, 11351943345d3Smrg # add $file without .exe 113523e51e026Smrg func_append rmfiles " $file" 11353943345d3Smrg ;; 11354943345d3Smrg esac 11355943345d3Smrg # Do a test to see if this is a libtool program. 11356a7b590b3Smrg if func_ltwrapper_p "$file"; then 11357a7b590b3Smrg if func_ltwrapper_executable_p "$file"; then 11358a7b590b3Smrg func_ltwrapper_scriptname "$file" 11359a7b590b3Smrg relink_command= 11360a7b590b3Smrg func_source $func_ltwrapper_scriptname_result 113613e51e026Smrg func_append rmfiles " $func_ltwrapper_scriptname_result" 11362a7b590b3Smrg else 11363a7b590b3Smrg relink_command= 11364a7b590b3Smrg func_source $dir/$noexename 11365a7b590b3Smrg fi 11366943345d3Smrg 11367943345d3Smrg # note $name still contains .exe if it was in $file originally 11368943345d3Smrg # as does the version of $file that was added into $rmfiles 1136915ffece8Smrg func_append rmfiles " $odir/$name $odir/${name}S.$objext" 1137015ffece8Smrg if test yes = "$fast_install" && test -n "$relink_command"; then 113713e51e026Smrg func_append rmfiles " $odir/lt-$name" 11372943345d3Smrg fi 1137315ffece8Smrg if test "X$noexename" != "X$name"; then 1137415ffece8Smrg func_append rmfiles " $odir/lt-$noexename.c" 11375943345d3Smrg fi 11376943345d3Smrg fi 11377943345d3Smrg fi 11378943345d3Smrg ;; 11379943345d3Smrg esac 11380a7b590b3Smrg func_show_eval "$RM $rmfiles" 'exit_status=1' 11381943345d3Smrg done 11382943345d3Smrg 1138315ffece8Smrg # Try to remove the $objdir's in the directories where we deleted files 11384943345d3Smrg for dir in $rmdirs; do 11385943345d3Smrg if test -d "$dir"; then 11386a7b590b3Smrg func_show_eval "rmdir $dir >/dev/null 2>&1" 11387943345d3Smrg fi 11388943345d3Smrg done 11389943345d3Smrg 11390943345d3Smrg exit $exit_status 11391a7b590b3Smrg} 11392943345d3Smrg 1139315ffece8Smrgif test uninstall = "$opt_mode" || test clean = "$opt_mode"; then 1139415ffece8Smrg func_mode_uninstall ${1+"$@"} 1139515ffece8Smrgfi 11396943345d3Smrg 113973e51e026Smrgtest -z "$opt_mode" && { 1139815ffece8Smrg help=$generic_help 11399a7b590b3Smrg func_fatal_help "you must specify a MODE" 11400a7b590b3Smrg} 11401a7b590b3Smrg 11402a7b590b3Smrgtest -z "$exec_cmd" && \ 1140315ffece8Smrg func_fatal_help "invalid operation mode '$opt_mode'" 11404943345d3Smrg 11405943345d3Smrgif test -n "$exec_cmd"; then 11406a7b590b3Smrg eval exec "$exec_cmd" 11407943345d3Smrg exit $EXIT_FAILURE 11408943345d3Smrgfi 11409943345d3Smrg 11410a7b590b3Smrgexit $exit_status 11411943345d3Smrg 11412943345d3Smrg 11413943345d3Smrg# The TAGs below are defined such that we never get into a situation 1141415ffece8Smrg# where we disable both kinds of libraries. Given conflicting 11415943345d3Smrg# choices, we go for a static library, that is the most portable, 11416943345d3Smrg# since we can't tell whether shared libraries were disabled because 11417943345d3Smrg# the user asked for that or because the platform doesn't support 11418943345d3Smrg# them. This is particularly important on AIX, because we don't 11419943345d3Smrg# support having both static and shared libraries enabled at the same 11420943345d3Smrg# time on that platform, so we default to a shared-only configuration. 11421943345d3Smrg# If a disable-shared tag is given, we'll fallback to a static-only 11422943345d3Smrg# configuration. But we'll never go from static-only to shared-only. 11423943345d3Smrg 11424943345d3Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared 11425a7b590b3Smrgbuild_libtool_libs=no 11426a7b590b3Smrgbuild_old_libs=yes 11427943345d3Smrg# ### END LIBTOOL TAG CONFIG: disable-shared 11428943345d3Smrg 11429943345d3Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static 11430a7b590b3Smrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` 11431943345d3Smrg# ### END LIBTOOL TAG CONFIG: disable-static 11432943345d3Smrg 11433943345d3Smrg# Local Variables: 11434943345d3Smrg# mode:shell-script 11435943345d3Smrg# sh-indentation:2 11436943345d3Smrg# End: 11437