ltmain.sh revision 2a53b785
12a53b785Smrg#! /usr/bin/env sh 252fd71cdSmrg## DO NOT EDIT - This file generated from ./build-aux/ltmain.in 32a53b785Smrg## by inline-source v2019-02-19.15 4d63fdb69Smrg 52a53b785Smrg# libtool (GNU libtool) 2.4.7 652fd71cdSmrg# Provide generalized library-building support services. 7d63fdb69Smrg# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 8d63fdb69Smrg 92a53b785Smrg# Copyright (C) 1996-2019, 2021-2022 Free Software Foundation, Inc. 10d63fdb69Smrg# This is free software; see the source for copying conditions. There is NO 11d63fdb69Smrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12d63fdb69Smrg 13d63fdb69Smrg# GNU Libtool is free software; you can redistribute it and/or modify 143da084b3Smrg# it under the terms of the GNU General Public License as published by 153da084b3Smrg# the Free Software Foundation; either version 2 of the License, or 163da084b3Smrg# (at your option) any later version. 173da084b3Smrg# 18d63fdb69Smrg# As a special exception to the GNU General Public License, 19d63fdb69Smrg# if you distribute this file as part of a program or library that 20d63fdb69Smrg# is built using GNU Libtool, you may include this file under the 21d63fdb69Smrg# same distribution terms that you use for the rest of that program. 22d63fdb69Smrg# 23d63fdb69Smrg# GNU Libtool is distributed in the hope that it will be useful, but 243da084b3Smrg# WITHOUT ANY WARRANTY; without even the implied warranty of 253da084b3Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 263da084b3Smrg# General Public License for more details. 273da084b3Smrg# 283da084b3Smrg# You should have received a copy of the GNU General Public License 2952fd71cdSmrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 30d63fdb69Smrg 31d63fdb69Smrg 3255acc8fcSmrgPROGRAM=libtool 33d63fdb69SmrgPACKAGE=libtool 342a53b785SmrgVERSION=2.4.7 352a53b785Smrgpackage_revision=2.4.7 36d63fdb69Smrg 3752fd71cdSmrg 3852fd71cdSmrg## ------ ## 3952fd71cdSmrg## Usage. ## 4052fd71cdSmrg## ------ ## 4152fd71cdSmrg 4252fd71cdSmrg# Run './libtool --help' for help with using this script from the 4352fd71cdSmrg# command line. 4452fd71cdSmrg 4552fd71cdSmrg 4652fd71cdSmrg## ------------------------------- ## 4752fd71cdSmrg## User overridable command paths. ## 4852fd71cdSmrg## ------------------------------- ## 4952fd71cdSmrg 5052fd71cdSmrg# After configure completes, it has a better idea of some of the 5152fd71cdSmrg# shell tools we need than the defaults used by the functions shared 5252fd71cdSmrg# with bootstrap, so set those here where they can still be over- 5352fd71cdSmrg# ridden by the user, but otherwise take precedence. 5452fd71cdSmrg 5552fd71cdSmrg: ${AUTOCONF="autoconf"} 5652fd71cdSmrg: ${AUTOMAKE="automake"} 5752fd71cdSmrg 5852fd71cdSmrg 5952fd71cdSmrg## -------------------------- ## 6052fd71cdSmrg## Source external libraries. ## 6152fd71cdSmrg## -------------------------- ## 6252fd71cdSmrg 6352fd71cdSmrg# Much of our low-level functionality needs to be sourced from external 6452fd71cdSmrg# libraries, which are installed to $pkgauxdir. 6552fd71cdSmrg 6652fd71cdSmrg# Set a version string for this script. 672a53b785Smrgscriptversion=2019-02-19.15; # UTC 6852fd71cdSmrg 6952fd71cdSmrg# General shell script boiler plate, and helper functions. 7052fd71cdSmrg# Written by Gary V. Vaughan, 2004 7152fd71cdSmrg 722a53b785Smrg# This is free software. There is NO warranty; not even for 732a53b785Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 742a53b785Smrg# 752a53b785Smrg# Copyright (C) 2004-2019, 2021 Bootstrap Authors 762a53b785Smrg# 772a53b785Smrg# This file is dual licensed under the terms of the MIT license 782a53b785Smrg# <https://opensource.org/license/MIT>, and GPL version 2 or later 792a53b785Smrg# <http://www.gnu.org/licenses/gpl-2.0.html>. You must apply one of 802a53b785Smrg# these licenses when using or redistributing this software or any of 812a53b785Smrg# the files within it. See the URLs above, or the file `LICENSE` 822a53b785Smrg# included in the Bootstrap distribution for the full license texts. 8352fd71cdSmrg 842a53b785Smrg# Please report bugs or propose patches to: 852a53b785Smrg# <https://github.com/gnulib-modules/bootstrap/issues> 8652fd71cdSmrg 8752fd71cdSmrg 8852fd71cdSmrg## ------ ## 8952fd71cdSmrg## Usage. ## 9052fd71cdSmrg## ------ ## 9152fd71cdSmrg 9252fd71cdSmrg# Evaluate this file near the top of your script to gain access to 9352fd71cdSmrg# the functions and variables defined here: 9452fd71cdSmrg# 9552fd71cdSmrg# . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh 9652fd71cdSmrg# 9752fd71cdSmrg# If you need to override any of the default environment variable 9852fd71cdSmrg# settings, do that before evaluating this file. 9952fd71cdSmrg 10052fd71cdSmrg 10152fd71cdSmrg## -------------------- ## 10252fd71cdSmrg## Shell normalisation. ## 10352fd71cdSmrg## -------------------- ## 10452fd71cdSmrg 10552fd71cdSmrg# Some shells need a little help to be as Bourne compatible as possible. 10652fd71cdSmrg# Before doing anything else, make sure all that help has been provided! 10752fd71cdSmrg 10852fd71cdSmrgDUALCASE=1; export DUALCASE # for MKS sh 10952fd71cdSmrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : 110d63fdb69Smrg emulate sh 111d63fdb69Smrg NULLCMD=: 11252fd71cdSmrg # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which 113d63fdb69Smrg # is contrary to our usage. Disable this feature. 114d63fdb69Smrg alias -g '${1+"$@"}'='"$@"' 115d63fdb69Smrg setopt NO_GLOB_SUBST 116d63fdb69Smrgelse 11752fd71cdSmrg case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac 118d63fdb69Smrgfi 11955acc8fcSmrg 12052fd71cdSmrg# NLS nuisances: We save the old values in case they are required later. 12152fd71cdSmrg_G_user_locale= 12252fd71cdSmrg_G_safe_locale= 12352fd71cdSmrgfor _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 124d63fdb69Smrgdo 12552fd71cdSmrg eval "if test set = \"\${$_G_var+set}\"; then 12652fd71cdSmrg save_$_G_var=\$$_G_var 12752fd71cdSmrg $_G_var=C 12852fd71cdSmrg export $_G_var 12952fd71cdSmrg _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\" 13052fd71cdSmrg _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\" 131d63fdb69Smrg fi" 132d63fdb69Smrgdone 1332a53b785Smrg# These NLS vars are set unconditionally (bootstrap issue #24). Unset those 1342a53b785Smrg# in case the environment reset is needed later and the $save_* variant is not 1352a53b785Smrg# defined (see the code above). 1362a53b785SmrgLC_ALL=C 1372a53b785SmrgLANGUAGE=C 1382a53b785Smrgexport LANGUAGE LC_ALL 139d63fdb69Smrg 14052fd71cdSmrg# Make sure IFS has a sensible default 14152fd71cdSmrgsp=' ' 14252fd71cdSmrgnl=' 14352fd71cdSmrg' 14452fd71cdSmrgIFS="$sp $nl" 14552fd71cdSmrg 14652fd71cdSmrg# There are apparently some retarded systems that use ';' as a PATH separator! 14752fd71cdSmrgif test "${PATH_SEPARATOR+set}" != set; then 14852fd71cdSmrg PATH_SEPARATOR=: 14952fd71cdSmrg (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { 15052fd71cdSmrg (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || 15152fd71cdSmrg PATH_SEPARATOR=';' 15252fd71cdSmrg } 15352fd71cdSmrgfi 154d63fdb69Smrg 155d63fdb69Smrg 1562a53b785Smrg# func_unset VAR 1572a53b785Smrg# -------------- 1582a53b785Smrg# Portably unset VAR. 1592a53b785Smrg# In some shells, an 'unset VAR' statement leaves a non-zero return 1602a53b785Smrg# status if VAR is already unset, which might be problematic if the 1612a53b785Smrg# statement is used at the end of a function (thus poisoning its return 1622a53b785Smrg# value) or when 'set -e' is active (causing even a spurious abort of 1632a53b785Smrg# the script in this case). 1642a53b785Smrgfunc_unset () 1652a53b785Smrg{ 1662a53b785Smrg { eval $1=; (eval unset $1) >/dev/null 2>&1 && eval unset $1 || : ; } 1672a53b785Smrg} 1682a53b785Smrg 1692a53b785Smrg 1702a53b785Smrg# Make sure CDPATH doesn't cause `cd` commands to output the target dir. 1712a53b785Smrgfunc_unset CDPATH 1722a53b785Smrg 1732a53b785Smrg# Make sure ${,E,F}GREP behave sanely. 1742a53b785Smrgfunc_unset GREP_OPTIONS 1752a53b785Smrg 176d63fdb69Smrg 17752fd71cdSmrg## ------------------------- ## 17852fd71cdSmrg## Locate command utilities. ## 17952fd71cdSmrg## ------------------------- ## 18052fd71cdSmrg 18152fd71cdSmrg 18252fd71cdSmrg# func_executable_p FILE 18352fd71cdSmrg# ---------------------- 18452fd71cdSmrg# Check that FILE is an executable regular file. 18552fd71cdSmrgfunc_executable_p () 18652fd71cdSmrg{ 18752fd71cdSmrg test -f "$1" && test -x "$1" 18852fd71cdSmrg} 18952fd71cdSmrg 19052fd71cdSmrg 19152fd71cdSmrg# func_path_progs PROGS_LIST CHECK_FUNC [PATH] 19252fd71cdSmrg# -------------------------------------------- 19352fd71cdSmrg# Search for either a program that responds to --version with output 19452fd71cdSmrg# containing "GNU", or else returned by CHECK_FUNC otherwise, by 19552fd71cdSmrg# trying all the directories in PATH with each of the elements of 19652fd71cdSmrg# PROGS_LIST. 19752fd71cdSmrg# 19852fd71cdSmrg# CHECK_FUNC should accept the path to a candidate program, and 19952fd71cdSmrg# set $func_check_prog_result if it truncates its output less than 20052fd71cdSmrg# $_G_path_prog_max characters. 20152fd71cdSmrgfunc_path_progs () 20252fd71cdSmrg{ 20352fd71cdSmrg _G_progs_list=$1 20452fd71cdSmrg _G_check_func=$2 20552fd71cdSmrg _G_PATH=${3-"$PATH"} 20652fd71cdSmrg 20752fd71cdSmrg _G_path_prog_max=0 20852fd71cdSmrg _G_path_prog_found=false 20952fd71cdSmrg _G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:} 21052fd71cdSmrg for _G_dir in $_G_PATH; do 21152fd71cdSmrg IFS=$_G_save_IFS 21252fd71cdSmrg test -z "$_G_dir" && _G_dir=. 21352fd71cdSmrg for _G_prog_name in $_G_progs_list; do 21452fd71cdSmrg for _exeext in '' .EXE; do 21552fd71cdSmrg _G_path_prog=$_G_dir/$_G_prog_name$_exeext 21652fd71cdSmrg func_executable_p "$_G_path_prog" || continue 21752fd71cdSmrg case `"$_G_path_prog" --version 2>&1` in 21852fd71cdSmrg *GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;; 21952fd71cdSmrg *) $_G_check_func $_G_path_prog 22052fd71cdSmrg func_path_progs_result=$func_check_prog_result 22152fd71cdSmrg ;; 22252fd71cdSmrg esac 22352fd71cdSmrg $_G_path_prog_found && break 3 22452fd71cdSmrg done 22552fd71cdSmrg done 22652fd71cdSmrg done 22752fd71cdSmrg IFS=$_G_save_IFS 22852fd71cdSmrg test -z "$func_path_progs_result" && { 22952fd71cdSmrg echo "no acceptable sed could be found in \$PATH" >&2 23052fd71cdSmrg exit 1 23152fd71cdSmrg } 23252fd71cdSmrg} 23352fd71cdSmrg 23452fd71cdSmrg 23552fd71cdSmrg# We want to be able to use the functions in this file before configure 23652fd71cdSmrg# has figured out where the best binaries are kept, which means we have 23752fd71cdSmrg# to search for them ourselves - except when the results are already set 23852fd71cdSmrg# where we skip the searches. 23952fd71cdSmrg 24052fd71cdSmrg# Unless the user overrides by setting SED, search the path for either GNU 24152fd71cdSmrg# sed, or the sed that truncates its output the least. 24252fd71cdSmrgtest -z "$SED" && { 24352fd71cdSmrg _G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ 24452fd71cdSmrg for _G_i in 1 2 3 4 5 6 7; do 24552fd71cdSmrg _G_sed_script=$_G_sed_script$nl$_G_sed_script 24652fd71cdSmrg done 24752fd71cdSmrg echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed 24852fd71cdSmrg _G_sed_script= 24952fd71cdSmrg 25052fd71cdSmrg func_check_prog_sed () 25152fd71cdSmrg { 25252fd71cdSmrg _G_path_prog=$1 25352fd71cdSmrg 25452fd71cdSmrg _G_count=0 25552fd71cdSmrg printf 0123456789 >conftest.in 25652fd71cdSmrg while : 25752fd71cdSmrg do 25852fd71cdSmrg cat conftest.in conftest.in >conftest.tmp 25952fd71cdSmrg mv conftest.tmp conftest.in 26052fd71cdSmrg cp conftest.in conftest.nl 26152fd71cdSmrg echo '' >> conftest.nl 26252fd71cdSmrg "$_G_path_prog" -f conftest.sed <conftest.nl >conftest.out 2>/dev/null || break 26352fd71cdSmrg diff conftest.out conftest.nl >/dev/null 2>&1 || break 26452fd71cdSmrg _G_count=`expr $_G_count + 1` 26552fd71cdSmrg if test "$_G_count" -gt "$_G_path_prog_max"; then 26652fd71cdSmrg # Best one so far, save it but keep looking for a better one 26752fd71cdSmrg func_check_prog_result=$_G_path_prog 26852fd71cdSmrg _G_path_prog_max=$_G_count 26952fd71cdSmrg fi 27052fd71cdSmrg # 10*(2^10) chars as input seems more than enough 27152fd71cdSmrg test 10 -lt "$_G_count" && break 27252fd71cdSmrg done 27352fd71cdSmrg rm -f conftest.in conftest.tmp conftest.nl conftest.out 27452fd71cdSmrg } 27552fd71cdSmrg 2762a53b785Smrg func_path_progs "sed gsed" func_check_prog_sed "$PATH:/usr/xpg4/bin" 27752fd71cdSmrg rm -f conftest.sed 27852fd71cdSmrg SED=$func_path_progs_result 27952fd71cdSmrg} 28052fd71cdSmrg 28152fd71cdSmrg 28252fd71cdSmrg# Unless the user overrides by setting GREP, search the path for either GNU 28352fd71cdSmrg# grep, or the grep that truncates its output the least. 28452fd71cdSmrgtest -z "$GREP" && { 28552fd71cdSmrg func_check_prog_grep () 28652fd71cdSmrg { 28752fd71cdSmrg _G_path_prog=$1 28852fd71cdSmrg 28952fd71cdSmrg _G_count=0 29052fd71cdSmrg _G_path_prog_max=0 29152fd71cdSmrg printf 0123456789 >conftest.in 29252fd71cdSmrg while : 29352fd71cdSmrg do 29452fd71cdSmrg cat conftest.in conftest.in >conftest.tmp 29552fd71cdSmrg mv conftest.tmp conftest.in 29652fd71cdSmrg cp conftest.in conftest.nl 29752fd71cdSmrg echo 'GREP' >> conftest.nl 29852fd71cdSmrg "$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' <conftest.nl >conftest.out 2>/dev/null || break 29952fd71cdSmrg diff conftest.out conftest.nl >/dev/null 2>&1 || break 30052fd71cdSmrg _G_count=`expr $_G_count + 1` 30152fd71cdSmrg if test "$_G_count" -gt "$_G_path_prog_max"; then 30252fd71cdSmrg # Best one so far, save it but keep looking for a better one 30352fd71cdSmrg func_check_prog_result=$_G_path_prog 30452fd71cdSmrg _G_path_prog_max=$_G_count 30552fd71cdSmrg fi 30652fd71cdSmrg # 10*(2^10) chars as input seems more than enough 30752fd71cdSmrg test 10 -lt "$_G_count" && break 30852fd71cdSmrg done 30952fd71cdSmrg rm -f conftest.in conftest.tmp conftest.nl conftest.out 31052fd71cdSmrg } 31152fd71cdSmrg 3122a53b785Smrg func_path_progs "grep ggrep" func_check_prog_grep "$PATH:/usr/xpg4/bin" 31352fd71cdSmrg GREP=$func_path_progs_result 31452fd71cdSmrg} 31552fd71cdSmrg 31652fd71cdSmrg 31752fd71cdSmrg## ------------------------------- ## 31852fd71cdSmrg## User overridable command paths. ## 31952fd71cdSmrg## ------------------------------- ## 32052fd71cdSmrg 32152fd71cdSmrg# All uppercase variable names are used for environment variables. These 32252fd71cdSmrg# variables can be overridden by the user before calling a script that 32352fd71cdSmrg# uses them if a suitable command of that name is not already available 32452fd71cdSmrg# in the command search PATH. 325d63fdb69Smrg 326d63fdb69Smrg: ${CP="cp -f"} 32752fd71cdSmrg: ${ECHO="printf %s\n"} 32852fd71cdSmrg: ${EGREP="$GREP -E"} 32952fd71cdSmrg: ${FGREP="$GREP -F"} 33052fd71cdSmrg: ${LN_S="ln -s"} 331d63fdb69Smrg: ${MAKE="make"} 332d63fdb69Smrg: ${MKDIR="mkdir"} 333d63fdb69Smrg: ${MV="mv -f"} 334d63fdb69Smrg: ${RM="rm -f"} 335d63fdb69Smrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"} 336d63fdb69Smrg 337d63fdb69Smrg 33852fd71cdSmrg## -------------------- ## 33952fd71cdSmrg## Useful sed snippets. ## 34052fd71cdSmrg## -------------------- ## 34148c85eb7Smrg 34252fd71cdSmrgsed_dirname='s|/[^/]*$||' 34352fd71cdSmrgsed_basename='s|^.*/||' 34448c85eb7Smrg 34552fd71cdSmrg# Sed substitution that helps us do robust quoting. It backslashifies 34652fd71cdSmrg# metacharacters that are still active within double-quoted strings. 34752fd71cdSmrgsed_quote_subst='s|\([`"$\\]\)|\\\1|g' 34848c85eb7Smrg 34952fd71cdSmrg# Same as above, but do not quote variable references. 35052fd71cdSmrgsed_double_quote_subst='s/\(["`\\]\)/\\\1/g' 35148c85eb7Smrg 35252fd71cdSmrg# Sed substitution that turns a string into a regex matching for the 35352fd71cdSmrg# string literally. 35452fd71cdSmrgsed_make_literal_regex='s|[].[^$\\*\/]|\\&|g' 35548c85eb7Smrg 35652fd71cdSmrg# Sed substitution that converts a w32 file name or path 35752fd71cdSmrg# that contains forward slashes, into one that contains 35852fd71cdSmrg# (escaped) backslashes. A very naive implementation. 35952fd71cdSmrgsed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' 36052fd71cdSmrg 36152fd71cdSmrg# Re-'\' parameter expansions in output of sed_double_quote_subst that 36252fd71cdSmrg# were '\'-ed in input to the same. If an odd number of '\' preceded a 36352fd71cdSmrg# '$' in input to sed_double_quote_subst, that '$' was protected from 36452fd71cdSmrg# expansion. Since each input '\' is now two '\'s, look for any number 36552fd71cdSmrg# of runs of four '\'s followed by two '\'s and then a '$'. '\' that '$'. 36652fd71cdSmrg_G_bs='\\' 36752fd71cdSmrg_G_bs2='\\\\' 36852fd71cdSmrg_G_bs4='\\\\\\\\' 36952fd71cdSmrg_G_dollar='\$' 37052fd71cdSmrgsed_double_backslash="\ 37152fd71cdSmrg s/$_G_bs4/&\\ 37252fd71cdSmrg/g 37352fd71cdSmrg s/^$_G_bs2$_G_dollar/$_G_bs&/ 37452fd71cdSmrg s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g 37552fd71cdSmrg s/\n//g" 37648c85eb7Smrg 3772a53b785Smrg# require_check_ifs_backslash 3782a53b785Smrg# --------------------------- 3792a53b785Smrg# Check if we can use backslash as IFS='\' separator, and set 3802a53b785Smrg# $check_ifs_backshlash_broken to ':' or 'false'. 3812a53b785Smrgrequire_check_ifs_backslash=func_require_check_ifs_backslash 3822a53b785Smrgfunc_require_check_ifs_backslash () 3832a53b785Smrg{ 3842a53b785Smrg _G_save_IFS=$IFS 3852a53b785Smrg IFS='\' 3862a53b785Smrg _G_check_ifs_backshlash='a\\b' 3872a53b785Smrg for _G_i in $_G_check_ifs_backshlash 3882a53b785Smrg do 3892a53b785Smrg case $_G_i in 3902a53b785Smrg a) 3912a53b785Smrg check_ifs_backshlash_broken=false 3922a53b785Smrg ;; 3932a53b785Smrg '') 3942a53b785Smrg break 3952a53b785Smrg ;; 3962a53b785Smrg *) 3972a53b785Smrg check_ifs_backshlash_broken=: 3982a53b785Smrg break 3992a53b785Smrg ;; 4002a53b785Smrg esac 4012a53b785Smrg done 4022a53b785Smrg IFS=$_G_save_IFS 4032a53b785Smrg require_check_ifs_backslash=: 4042a53b785Smrg} 4052a53b785Smrg 406d63fdb69Smrg 40752fd71cdSmrg## ----------------- ## 40852fd71cdSmrg## Global variables. ## 40952fd71cdSmrg## ----------------- ## 4103da084b3Smrg 41152fd71cdSmrg# Except for the global variables explicitly listed below, the following 41252fd71cdSmrg# functions in the '^func_' namespace, and the '^require_' namespace 41352fd71cdSmrg# variables initialised in the 'Resource management' section, sourcing 41452fd71cdSmrg# this file will not pollute your global namespace with anything 41552fd71cdSmrg# else. There's no portable way to scope variables in Bourne shell 41652fd71cdSmrg# though, so actually running these functions will sometimes place 41752fd71cdSmrg# results into a variable named after the function, and often use 41852fd71cdSmrg# temporary variables in the '^_G_' namespace. If you are careful to 41952fd71cdSmrg# avoid using those namespaces casually in your sourcing script, things 42052fd71cdSmrg# should continue to work as you expect. And, of course, you can freely 42152fd71cdSmrg# overwrite any of the functions or variables defined here before 42252fd71cdSmrg# calling anything to customize them. 42355acc8fcSmrg 42452fd71cdSmrgEXIT_SUCCESS=0 42552fd71cdSmrgEXIT_FAILURE=1 42652fd71cdSmrgEXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. 42752fd71cdSmrgEXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. 42855acc8fcSmrg 42952fd71cdSmrg# Allow overriding, eg assuming that you follow the convention of 43052fd71cdSmrg# putting '$debug_cmd' at the start of all your functions, you can get 43152fd71cdSmrg# bash to show function call trace with: 43252fd71cdSmrg# 43352fd71cdSmrg# debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name 43452fd71cdSmrgdebug_cmd=${debug_cmd-":"} 43552fd71cdSmrgexit_cmd=: 43655acc8fcSmrg 43752fd71cdSmrg# By convention, finish your script with: 43852fd71cdSmrg# 43952fd71cdSmrg# exit $exit_status 44052fd71cdSmrg# 44152fd71cdSmrg# so that you can set exit_status to non-zero if you want to indicate 44252fd71cdSmrg# something went wrong during execution without actually bailing out at 44352fd71cdSmrg# the point of failure. 44452fd71cdSmrgexit_status=$EXIT_SUCCESS 44555acc8fcSmrg 44652fd71cdSmrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh 44752fd71cdSmrg# is ksh but when the shell is invoked as "sh" and the current value of 44852fd71cdSmrg# the _XPG environment variable is not equal to 1 (one), the special 44952fd71cdSmrg# positional parameter $0, within a function call, is the name of the 45052fd71cdSmrg# function. 45152fd71cdSmrgprogpath=$0 4523da084b3Smrg 45352fd71cdSmrg# The name of this program. 45452fd71cdSmrgprogname=`$ECHO "$progpath" |$SED "$sed_basename"` 4553da084b3Smrg 45652fd71cdSmrg# Make sure we have an absolute progpath for reexecution: 457d63fdb69Smrgcase $progpath in 458d63fdb69Smrg [\\/]*|[A-Za-z]:\\*) ;; 459d63fdb69Smrg *[\\/]*) 46052fd71cdSmrg progdir=`$ECHO "$progpath" |$SED "$sed_dirname"` 461d63fdb69Smrg progdir=`cd "$progdir" && pwd` 46252fd71cdSmrg progpath=$progdir/$progname 463d63fdb69Smrg ;; 464d63fdb69Smrg *) 46552fd71cdSmrg _G_IFS=$IFS 46648c85eb7Smrg IFS=${PATH_SEPARATOR-:} 467d63fdb69Smrg for progdir in $PATH; do 46852fd71cdSmrg IFS=$_G_IFS 469d63fdb69Smrg test -x "$progdir/$progname" && break 470d63fdb69Smrg done 47152fd71cdSmrg IFS=$_G_IFS 472d63fdb69Smrg test -n "$progdir" || progdir=`pwd` 47352fd71cdSmrg progpath=$progdir/$progname 474d63fdb69Smrg ;; 475d63fdb69Smrgesac 4763da084b3Smrg 477d63fdb69Smrg 47852fd71cdSmrg## ----------------- ## 47952fd71cdSmrg## Standard options. ## 48052fd71cdSmrg## ----------------- ## 48148c85eb7Smrg 48252fd71cdSmrg# The following options affect the operation of the functions defined 48352fd71cdSmrg# below, and should be set appropriately depending on run-time para- 48452fd71cdSmrg# meters passed on the command line. 485d63fdb69Smrg 486d63fdb69Smrgopt_dry_run=false 487d63fdb69Smrgopt_quiet=false 488d63fdb69Smrgopt_verbose=false 489d63fdb69Smrg 49052fd71cdSmrg# Categories 'all' and 'none' are always available. Append any others 49152fd71cdSmrg# you will pass as the first argument to func_warning from your own 49252fd71cdSmrg# code. 49352fd71cdSmrgwarning_categories= 4943da084b3Smrg 49552fd71cdSmrg# By default, display warnings according to 'opt_warning_types'. Set 49652fd71cdSmrg# 'warning_func' to ':' to elide all warnings, or func_fatal_error to 49752fd71cdSmrg# treat the next displayed warning as a fatal error. 49852fd71cdSmrgwarning_func=func_warn_and_continue 4993da084b3Smrg 50052fd71cdSmrg# Set to 'all' to display all warnings, 'none' to suppress all 50152fd71cdSmrg# warnings, or a space delimited list of some subset of 50252fd71cdSmrg# 'warning_categories' to display only the listed warnings. 50352fd71cdSmrgopt_warning_types=all 5043da084b3Smrg 50555acc8fcSmrg 50652fd71cdSmrg## -------------------- ## 50752fd71cdSmrg## Resource management. ## 50852fd71cdSmrg## -------------------- ## 5093da084b3Smrg 51052fd71cdSmrg# This section contains definitions for functions that each ensure a 51152fd71cdSmrg# particular resource (a file, or a non-empty configuration variable for 51252fd71cdSmrg# example) is available, and if appropriate to extract default values 51352fd71cdSmrg# from pertinent package files. Call them using their associated 51452fd71cdSmrg# 'require_*' variable to ensure that they are executed, at most, once. 51552fd71cdSmrg# 51652fd71cdSmrg# It's entirely deliberate that calling these functions can set 51752fd71cdSmrg# variables that don't obey the namespace limitations obeyed by the rest 51852fd71cdSmrg# of this file, in order that that they be as useful as possible to 51952fd71cdSmrg# callers. 5203da084b3Smrg 5213da084b3Smrg 52252fd71cdSmrg# require_term_colors 52352fd71cdSmrg# ------------------- 52452fd71cdSmrg# Allow display of bold text on terminals that support it. 52552fd71cdSmrgrequire_term_colors=func_require_term_colors 52652fd71cdSmrgfunc_require_term_colors () 527d63fdb69Smrg{ 52852fd71cdSmrg $debug_cmd 52952fd71cdSmrg 53052fd71cdSmrg test -t 1 && { 53152fd71cdSmrg # COLORTERM and USE_ANSI_COLORS environment variables take 53252fd71cdSmrg # precedence, because most terminfo databases neglect to describe 53352fd71cdSmrg # whether color sequences are supported. 53452fd71cdSmrg test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"} 53552fd71cdSmrg 53652fd71cdSmrg if test 1 = "$USE_ANSI_COLORS"; then 53752fd71cdSmrg # Standard ANSI escape sequences 53852fd71cdSmrg tc_reset='[0m' 53952fd71cdSmrg tc_bold='[1m'; tc_standout='[7m' 54052fd71cdSmrg tc_red='[31m'; tc_green='[32m' 54152fd71cdSmrg tc_blue='[34m'; tc_cyan='[36m' 54252fd71cdSmrg else 54352fd71cdSmrg # Otherwise trust the terminfo database after all. 54452fd71cdSmrg test -n "`tput sgr0 2>/dev/null`" && { 54552fd71cdSmrg tc_reset=`tput sgr0` 54652fd71cdSmrg test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold` 54752fd71cdSmrg tc_standout=$tc_bold 54852fd71cdSmrg test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso` 54952fd71cdSmrg test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1` 55052fd71cdSmrg test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2` 55152fd71cdSmrg test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4` 55252fd71cdSmrg test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5` 55352fd71cdSmrg } 55452fd71cdSmrg fi 55552fd71cdSmrg } 5563da084b3Smrg 55752fd71cdSmrg require_term_colors=: 558d63fdb69Smrg} 5593da084b3Smrg 5603da084b3Smrg 56152fd71cdSmrg## ----------------- ## 56252fd71cdSmrg## Function library. ## 56352fd71cdSmrg## ----------------- ## 56452fd71cdSmrg 56552fd71cdSmrg# This section contains a variety of useful functions to call in your 56652fd71cdSmrg# scripts. Take note of the portable wrappers for features provided by 56752fd71cdSmrg# some modern shells, which will fall back to slower equivalents on 56852fd71cdSmrg# less featureful shells. 56952fd71cdSmrg 57052fd71cdSmrg 57152fd71cdSmrg# func_append VAR VALUE 57252fd71cdSmrg# --------------------- 57352fd71cdSmrg# Append VALUE onto the existing contents of VAR. 57452fd71cdSmrg 57552fd71cdSmrg # We should try to minimise forks, especially on Windows where they are 57652fd71cdSmrg # unreasonably slow, so skip the feature probes when bash or zsh are 57752fd71cdSmrg # being used: 57852fd71cdSmrg if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then 57952fd71cdSmrg : ${_G_HAVE_ARITH_OP="yes"} 58052fd71cdSmrg : ${_G_HAVE_XSI_OPS="yes"} 58152fd71cdSmrg # The += operator was introduced in bash 3.1 58252fd71cdSmrg case $BASH_VERSION in 58352fd71cdSmrg [12].* | 3.0 | 3.0*) ;; 58452fd71cdSmrg *) 58552fd71cdSmrg : ${_G_HAVE_PLUSEQ_OP="yes"} 58652fd71cdSmrg ;; 58752fd71cdSmrg esac 58852fd71cdSmrg fi 58952fd71cdSmrg 59052fd71cdSmrg # _G_HAVE_PLUSEQ_OP 59152fd71cdSmrg # Can be empty, in which case the shell is probed, "yes" if += is 59252fd71cdSmrg # useable or anything else if it does not work. 59352fd71cdSmrg test -z "$_G_HAVE_PLUSEQ_OP" \ 59452fd71cdSmrg && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \ 59552fd71cdSmrg && _G_HAVE_PLUSEQ_OP=yes 59652fd71cdSmrg 59752fd71cdSmrgif test yes = "$_G_HAVE_PLUSEQ_OP" 59852fd71cdSmrgthen 59952fd71cdSmrg # This is an XSI compatible shell, allowing a faster implementation... 60052fd71cdSmrg eval 'func_append () 60152fd71cdSmrg { 60252fd71cdSmrg $debug_cmd 60352fd71cdSmrg 60452fd71cdSmrg eval "$1+=\$2" 60552fd71cdSmrg }' 60652fd71cdSmrgelse 60752fd71cdSmrg # ...otherwise fall back to using expr, which is often a shell builtin. 60852fd71cdSmrg func_append () 60952fd71cdSmrg { 61052fd71cdSmrg $debug_cmd 61152fd71cdSmrg 61252fd71cdSmrg eval "$1=\$$1\$2" 61352fd71cdSmrg } 61452fd71cdSmrgfi 61552fd71cdSmrg 61652fd71cdSmrg 61752fd71cdSmrg# func_append_quoted VAR VALUE 61852fd71cdSmrg# ---------------------------- 61952fd71cdSmrg# Quote VALUE and append to the end of shell variable VAR, separated 62052fd71cdSmrg# by a space. 62152fd71cdSmrgif test yes = "$_G_HAVE_PLUSEQ_OP"; then 62252fd71cdSmrg eval 'func_append_quoted () 62352fd71cdSmrg { 62452fd71cdSmrg $debug_cmd 62552fd71cdSmrg 6262a53b785Smrg func_quote_arg pretty "$2" 6272a53b785Smrg eval "$1+=\\ \$func_quote_arg_result" 62852fd71cdSmrg }' 62952fd71cdSmrgelse 63052fd71cdSmrg func_append_quoted () 63152fd71cdSmrg { 63252fd71cdSmrg $debug_cmd 63352fd71cdSmrg 6342a53b785Smrg func_quote_arg pretty "$2" 6352a53b785Smrg eval "$1=\$$1\\ \$func_quote_arg_result" 63652fd71cdSmrg } 63752fd71cdSmrgfi 63852fd71cdSmrg 63952fd71cdSmrg 64052fd71cdSmrg# func_append_uniq VAR VALUE 64152fd71cdSmrg# -------------------------- 64252fd71cdSmrg# Append unique VALUE onto the existing contents of VAR, assuming 64352fd71cdSmrg# entries are delimited by the first character of VALUE. For example: 64452fd71cdSmrg# 64552fd71cdSmrg# func_append_uniq options " --another-option option-argument" 64652fd71cdSmrg# 64752fd71cdSmrg# will only append to $options if " --another-option option-argument " 64852fd71cdSmrg# is not already present somewhere in $options already (note spaces at 64952fd71cdSmrg# each end implied by leading space in second argument). 65052fd71cdSmrgfunc_append_uniq () 65152fd71cdSmrg{ 65252fd71cdSmrg $debug_cmd 65352fd71cdSmrg 65452fd71cdSmrg eval _G_current_value='`$ECHO $'$1'`' 65552fd71cdSmrg _G_delim=`expr "$2" : '\(.\)'` 65652fd71cdSmrg 65752fd71cdSmrg case $_G_delim$_G_current_value$_G_delim in 65852fd71cdSmrg *"$2$_G_delim"*) ;; 65952fd71cdSmrg *) func_append "$@" ;; 66052fd71cdSmrg esac 66152fd71cdSmrg} 66252fd71cdSmrg 66352fd71cdSmrg 66452fd71cdSmrg# func_arith TERM... 66552fd71cdSmrg# ------------------ 66652fd71cdSmrg# Set func_arith_result to the result of evaluating TERMs. 66752fd71cdSmrg test -z "$_G_HAVE_ARITH_OP" \ 66852fd71cdSmrg && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \ 66952fd71cdSmrg && _G_HAVE_ARITH_OP=yes 67052fd71cdSmrg 67152fd71cdSmrgif test yes = "$_G_HAVE_ARITH_OP"; then 67252fd71cdSmrg eval 'func_arith () 67352fd71cdSmrg { 67452fd71cdSmrg $debug_cmd 67552fd71cdSmrg 67652fd71cdSmrg func_arith_result=$(( $* )) 67752fd71cdSmrg }' 67852fd71cdSmrgelse 67952fd71cdSmrg func_arith () 68052fd71cdSmrg { 68152fd71cdSmrg $debug_cmd 68252fd71cdSmrg 68352fd71cdSmrg func_arith_result=`expr "$@"` 68452fd71cdSmrg } 68552fd71cdSmrgfi 68652fd71cdSmrg 68752fd71cdSmrg 68852fd71cdSmrg# func_basename FILE 68952fd71cdSmrg# ------------------ 69052fd71cdSmrg# Set func_basename_result to FILE with everything up to and including 69152fd71cdSmrg# the last / stripped. 69252fd71cdSmrgif test yes = "$_G_HAVE_XSI_OPS"; then 69352fd71cdSmrg # If this shell supports suffix pattern removal, then use it to avoid 69452fd71cdSmrg # forking. Hide the definitions single quotes in case the shell chokes 69552fd71cdSmrg # on unsupported syntax... 69652fd71cdSmrg _b='func_basename_result=${1##*/}' 69752fd71cdSmrg _d='case $1 in 69852fd71cdSmrg */*) func_dirname_result=${1%/*}$2 ;; 69952fd71cdSmrg * ) func_dirname_result=$3 ;; 70052fd71cdSmrg esac' 70152fd71cdSmrg 70252fd71cdSmrgelse 70352fd71cdSmrg # ...otherwise fall back to using sed. 70452fd71cdSmrg _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`' 70552fd71cdSmrg _d='func_dirname_result=`$ECHO "$1" |$SED "$sed_dirname"` 70652fd71cdSmrg if test "X$func_dirname_result" = "X$1"; then 70752fd71cdSmrg func_dirname_result=$3 70852fd71cdSmrg else 70952fd71cdSmrg func_append func_dirname_result "$2" 71052fd71cdSmrg fi' 71152fd71cdSmrgfi 71252fd71cdSmrg 71352fd71cdSmrgeval 'func_basename () 71452fd71cdSmrg{ 71552fd71cdSmrg $debug_cmd 71652fd71cdSmrg 71752fd71cdSmrg '"$_b"' 71852fd71cdSmrg}' 71952fd71cdSmrg 72052fd71cdSmrg 72152fd71cdSmrg# func_dirname FILE APPEND NONDIR_REPLACEMENT 72252fd71cdSmrg# ------------------------------------------- 72352fd71cdSmrg# Compute the dirname of FILE. If nonempty, add APPEND to the result, 72452fd71cdSmrg# otherwise set result to NONDIR_REPLACEMENT. 72552fd71cdSmrgeval 'func_dirname () 72652fd71cdSmrg{ 72752fd71cdSmrg $debug_cmd 72852fd71cdSmrg 72952fd71cdSmrg '"$_d"' 73052fd71cdSmrg}' 73152fd71cdSmrg 73252fd71cdSmrg 73352fd71cdSmrg# func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT 73452fd71cdSmrg# -------------------------------------------------------- 73552fd71cdSmrg# Perform func_basename and func_dirname in a single function 73652fd71cdSmrg# call: 73752fd71cdSmrg# dirname: Compute the dirname of FILE. If nonempty, 73852fd71cdSmrg# add APPEND to the result, otherwise set result 73952fd71cdSmrg# to NONDIR_REPLACEMENT. 74052fd71cdSmrg# value returned in "$func_dirname_result" 74152fd71cdSmrg# basename: Compute filename of FILE. 74252fd71cdSmrg# value retuned in "$func_basename_result" 74352fd71cdSmrg# For efficiency, we do not delegate to the functions above but instead 74452fd71cdSmrg# duplicate the functionality here. 74552fd71cdSmrgeval 'func_dirname_and_basename () 74652fd71cdSmrg{ 74752fd71cdSmrg $debug_cmd 74852fd71cdSmrg 74952fd71cdSmrg '"$_b"' 75052fd71cdSmrg '"$_d"' 75152fd71cdSmrg}' 75252fd71cdSmrg 75352fd71cdSmrg 75452fd71cdSmrg# func_echo ARG... 75552fd71cdSmrg# ---------------- 75652fd71cdSmrg# Echo program name prefixed message. 75752fd71cdSmrgfunc_echo () 75852fd71cdSmrg{ 75952fd71cdSmrg $debug_cmd 76052fd71cdSmrg 76152fd71cdSmrg _G_message=$* 76252fd71cdSmrg 76352fd71cdSmrg func_echo_IFS=$IFS 76452fd71cdSmrg IFS=$nl 76552fd71cdSmrg for _G_line in $_G_message; do 76652fd71cdSmrg IFS=$func_echo_IFS 76752fd71cdSmrg $ECHO "$progname: $_G_line" 76852fd71cdSmrg done 76952fd71cdSmrg IFS=$func_echo_IFS 77052fd71cdSmrg} 77152fd71cdSmrg 77252fd71cdSmrg 77352fd71cdSmrg# func_echo_all ARG... 77452fd71cdSmrg# -------------------- 77552fd71cdSmrg# Invoke $ECHO with all args, space-separated. 77652fd71cdSmrgfunc_echo_all () 77752fd71cdSmrg{ 77852fd71cdSmrg $ECHO "$*" 77952fd71cdSmrg} 78052fd71cdSmrg 78152fd71cdSmrg 78252fd71cdSmrg# func_echo_infix_1 INFIX ARG... 78352fd71cdSmrg# ------------------------------ 78452fd71cdSmrg# Echo program name, followed by INFIX on the first line, with any 78552fd71cdSmrg# additional lines not showing INFIX. 78652fd71cdSmrgfunc_echo_infix_1 () 78752fd71cdSmrg{ 78852fd71cdSmrg $debug_cmd 78952fd71cdSmrg 79052fd71cdSmrg $require_term_colors 79152fd71cdSmrg 79252fd71cdSmrg _G_infix=$1; shift 79352fd71cdSmrg _G_indent=$_G_infix 79452fd71cdSmrg _G_prefix="$progname: $_G_infix: " 79552fd71cdSmrg _G_message=$* 79652fd71cdSmrg 79752fd71cdSmrg # Strip color escape sequences before counting printable length 79852fd71cdSmrg for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan" 79952fd71cdSmrg do 80052fd71cdSmrg test -n "$_G_tc" && { 80152fd71cdSmrg _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"` 80252fd71cdSmrg _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"` 80352fd71cdSmrg } 80452fd71cdSmrg done 80552fd71cdSmrg _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`" " ## exclude from sc_prohibit_nested_quotes 80652fd71cdSmrg 80752fd71cdSmrg func_echo_infix_1_IFS=$IFS 80852fd71cdSmrg IFS=$nl 80952fd71cdSmrg for _G_line in $_G_message; do 81052fd71cdSmrg IFS=$func_echo_infix_1_IFS 81152fd71cdSmrg $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2 81252fd71cdSmrg _G_prefix=$_G_indent 81352fd71cdSmrg done 81452fd71cdSmrg IFS=$func_echo_infix_1_IFS 81552fd71cdSmrg} 81652fd71cdSmrg 81752fd71cdSmrg 81852fd71cdSmrg# func_error ARG... 81952fd71cdSmrg# ----------------- 82052fd71cdSmrg# Echo program name prefixed message to standard error. 82152fd71cdSmrgfunc_error () 82252fd71cdSmrg{ 82352fd71cdSmrg $debug_cmd 82452fd71cdSmrg 82552fd71cdSmrg $require_term_colors 82652fd71cdSmrg 82752fd71cdSmrg func_echo_infix_1 " $tc_standout${tc_red}error$tc_reset" "$*" >&2 82852fd71cdSmrg} 82952fd71cdSmrg 83052fd71cdSmrg 83152fd71cdSmrg# func_fatal_error ARG... 83252fd71cdSmrg# ----------------------- 83352fd71cdSmrg# Echo program name prefixed message to standard error, and exit. 83452fd71cdSmrgfunc_fatal_error () 83552fd71cdSmrg{ 83652fd71cdSmrg $debug_cmd 83752fd71cdSmrg 83852fd71cdSmrg func_error "$*" 83952fd71cdSmrg exit $EXIT_FAILURE 84052fd71cdSmrg} 84152fd71cdSmrg 84252fd71cdSmrg 84352fd71cdSmrg# func_grep EXPRESSION FILENAME 84452fd71cdSmrg# ----------------------------- 845d63fdb69Smrg# Check whether EXPRESSION matches any line of FILENAME, without output. 846d63fdb69Smrgfunc_grep () 847d63fdb69Smrg{ 84852fd71cdSmrg $debug_cmd 84952fd71cdSmrg 850d63fdb69Smrg $GREP "$1" "$2" >/dev/null 2>&1 851d63fdb69Smrg} 852d63fdb69Smrg 853d63fdb69Smrg 85452fd71cdSmrg# func_len STRING 85552fd71cdSmrg# --------------- 85652fd71cdSmrg# Set func_len_result to the length of STRING. STRING may not 85752fd71cdSmrg# start with a hyphen. 85852fd71cdSmrg test -z "$_G_HAVE_XSI_OPS" \ 85952fd71cdSmrg && (eval 'x=a/b/c; 86052fd71cdSmrg test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ 86152fd71cdSmrg && _G_HAVE_XSI_OPS=yes 86252fd71cdSmrg 86352fd71cdSmrgif test yes = "$_G_HAVE_XSI_OPS"; then 86452fd71cdSmrg eval 'func_len () 86552fd71cdSmrg { 86652fd71cdSmrg $debug_cmd 86752fd71cdSmrg 86852fd71cdSmrg func_len_result=${#1} 86952fd71cdSmrg }' 87052fd71cdSmrgelse 87152fd71cdSmrg func_len () 87252fd71cdSmrg { 87352fd71cdSmrg $debug_cmd 87452fd71cdSmrg 87552fd71cdSmrg func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len` 87652fd71cdSmrg } 87752fd71cdSmrgfi 87852fd71cdSmrg 87952fd71cdSmrg 88052fd71cdSmrg# func_mkdir_p DIRECTORY-PATH 88152fd71cdSmrg# --------------------------- 882d63fdb69Smrg# Make sure the entire path to DIRECTORY-PATH is available. 883d63fdb69Smrgfunc_mkdir_p () 884d63fdb69Smrg{ 88552fd71cdSmrg $debug_cmd 886d63fdb69Smrg 88752fd71cdSmrg _G_directory_path=$1 88852fd71cdSmrg _G_dir_list= 889d63fdb69Smrg 89052fd71cdSmrg if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then 89152fd71cdSmrg 89252fd71cdSmrg # Protect directory names starting with '-' 89352fd71cdSmrg case $_G_directory_path in 89452fd71cdSmrg -*) _G_directory_path=./$_G_directory_path ;; 895d63fdb69Smrg esac 896d63fdb69Smrg 897d63fdb69Smrg # While some portion of DIR does not yet exist... 89852fd71cdSmrg while test ! -d "$_G_directory_path"; do 899d63fdb69Smrg # ...make a list in topmost first order. Use a colon delimited 900d63fdb69Smrg # list incase some portion of path contains whitespace. 90152fd71cdSmrg _G_dir_list=$_G_directory_path:$_G_dir_list 902d63fdb69Smrg 903d63fdb69Smrg # If the last portion added has no slash in it, the list is done 90452fd71cdSmrg case $_G_directory_path in */*) ;; *) break ;; esac 905d63fdb69Smrg 906d63fdb69Smrg # ...otherwise throw away the child directory and loop 90752fd71cdSmrg _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"` 908d63fdb69Smrg done 90952fd71cdSmrg _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'` 910d63fdb69Smrg 91152fd71cdSmrg func_mkdir_p_IFS=$IFS; IFS=: 91252fd71cdSmrg for _G_dir in $_G_dir_list; do 91352fd71cdSmrg IFS=$func_mkdir_p_IFS 91452fd71cdSmrg # mkdir can fail with a 'File exist' error if two processes 915d63fdb69Smrg # try to create one of the directories concurrently. Don't 916d63fdb69Smrg # stop in that case! 91752fd71cdSmrg $MKDIR "$_G_dir" 2>/dev/null || : 918d63fdb69Smrg done 91952fd71cdSmrg IFS=$func_mkdir_p_IFS 920d63fdb69Smrg 921d63fdb69Smrg # Bail out if we (or some other process) failed to create a directory. 92252fd71cdSmrg test -d "$_G_directory_path" || \ 92352fd71cdSmrg func_fatal_error "Failed to create '$1'" 924d63fdb69Smrg fi 925d63fdb69Smrg} 9263da084b3Smrg 9273da084b3Smrg 92852fd71cdSmrg# func_mktempdir [BASENAME] 92952fd71cdSmrg# ------------------------- 9303da084b3Smrg# Make a temporary directory that won't clash with other running 9313da084b3Smrg# libtool processes, and avoids race conditions if possible. If 93252fd71cdSmrg# given, BASENAME is the basename for that directory. 9333da084b3Smrgfunc_mktempdir () 9343da084b3Smrg{ 93552fd71cdSmrg $debug_cmd 93652fd71cdSmrg 93752fd71cdSmrg _G_template=${TMPDIR-/tmp}/${1-$progname} 9383da084b3Smrg 93952fd71cdSmrg if test : = "$opt_dry_run"; then 9403da084b3Smrg # Return a directory name, but don't create it in dry-run mode 94152fd71cdSmrg _G_tmpdir=$_G_template-$$ 9423da084b3Smrg else 9433da084b3Smrg 9443da084b3Smrg # If mktemp works, use that first and foremost 94552fd71cdSmrg _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null` 9463da084b3Smrg 94752fd71cdSmrg if test ! -d "$_G_tmpdir"; then 948d63fdb69Smrg # Failing that, at least try and use $RANDOM to avoid a race 94952fd71cdSmrg _G_tmpdir=$_G_template-${RANDOM-0}$$ 9503da084b3Smrg 95152fd71cdSmrg func_mktempdir_umask=`umask` 952d63fdb69Smrg umask 0077 95352fd71cdSmrg $MKDIR "$_G_tmpdir" 95452fd71cdSmrg umask $func_mktempdir_umask 9553da084b3Smrg fi 9563da084b3Smrg 9573da084b3Smrg # If we're not in dry-run mode, bomb out on failure 95852fd71cdSmrg test -d "$_G_tmpdir" || \ 95952fd71cdSmrg func_fatal_error "cannot create temporary directory '$_G_tmpdir'" 96052fd71cdSmrg fi 96152fd71cdSmrg 96252fd71cdSmrg $ECHO "$_G_tmpdir" 96352fd71cdSmrg} 96452fd71cdSmrg 96552fd71cdSmrg 96652fd71cdSmrg# func_normal_abspath PATH 96752fd71cdSmrg# ------------------------ 96852fd71cdSmrg# Remove doubled-up and trailing slashes, "." path components, 96952fd71cdSmrg# and cancel out any ".." path components in PATH after making 97052fd71cdSmrg# it an absolute path. 97152fd71cdSmrgfunc_normal_abspath () 97252fd71cdSmrg{ 97352fd71cdSmrg $debug_cmd 97452fd71cdSmrg 97552fd71cdSmrg # These SED scripts presuppose an absolute path with a trailing slash. 97652fd71cdSmrg _G_pathcar='s|^/\([^/]*\).*$|\1|' 97752fd71cdSmrg _G_pathcdr='s|^/[^/]*||' 97852fd71cdSmrg _G_removedotparts=':dotsl 97952fd71cdSmrg s|/\./|/|g 98052fd71cdSmrg t dotsl 98152fd71cdSmrg s|/\.$|/|' 98252fd71cdSmrg _G_collapseslashes='s|/\{1,\}|/|g' 98352fd71cdSmrg _G_finalslash='s|/*$|/|' 98452fd71cdSmrg 98552fd71cdSmrg # Start from root dir and reassemble the path. 98652fd71cdSmrg func_normal_abspath_result= 98752fd71cdSmrg func_normal_abspath_tpath=$1 98852fd71cdSmrg func_normal_abspath_altnamespace= 98952fd71cdSmrg case $func_normal_abspath_tpath in 99052fd71cdSmrg "") 99152fd71cdSmrg # Empty path, that just means $cwd. 99252fd71cdSmrg func_stripname '' '/' "`pwd`" 99352fd71cdSmrg func_normal_abspath_result=$func_stripname_result 99452fd71cdSmrg return 99552fd71cdSmrg ;; 99652fd71cdSmrg # The next three entries are used to spot a run of precisely 99752fd71cdSmrg # two leading slashes without using negated character classes; 99852fd71cdSmrg # we take advantage of case's first-match behaviour. 99952fd71cdSmrg ///*) 100052fd71cdSmrg # Unusual form of absolute path, do nothing. 100152fd71cdSmrg ;; 100252fd71cdSmrg //*) 100352fd71cdSmrg # Not necessarily an ordinary path; POSIX reserves leading '//' 100452fd71cdSmrg # and for example Cygwin uses it to access remote file shares 100552fd71cdSmrg # over CIFS/SMB, so we conserve a leading double slash if found. 100652fd71cdSmrg func_normal_abspath_altnamespace=/ 100752fd71cdSmrg ;; 100852fd71cdSmrg /*) 100952fd71cdSmrg # Absolute path, do nothing. 101052fd71cdSmrg ;; 101152fd71cdSmrg *) 101252fd71cdSmrg # Relative path, prepend $cwd. 101352fd71cdSmrg func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath 101452fd71cdSmrg ;; 101552fd71cdSmrg esac 101652fd71cdSmrg 101752fd71cdSmrg # Cancel out all the simple stuff to save iterations. We also want 101852fd71cdSmrg # the path to end with a slash for ease of parsing, so make sure 101952fd71cdSmrg # there is one (and only one) here. 102052fd71cdSmrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 102152fd71cdSmrg -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"` 102252fd71cdSmrg while :; do 102352fd71cdSmrg # Processed it all yet? 102452fd71cdSmrg if test / = "$func_normal_abspath_tpath"; then 102552fd71cdSmrg # If we ascended to the root using ".." the result may be empty now. 102652fd71cdSmrg if test -z "$func_normal_abspath_result"; then 102752fd71cdSmrg func_normal_abspath_result=/ 102852fd71cdSmrg fi 102952fd71cdSmrg break 103052fd71cdSmrg fi 103152fd71cdSmrg func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ 103252fd71cdSmrg -e "$_G_pathcar"` 103352fd71cdSmrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 103452fd71cdSmrg -e "$_G_pathcdr"` 103552fd71cdSmrg # Figure out what to do with it 103652fd71cdSmrg case $func_normal_abspath_tcomponent in 103752fd71cdSmrg "") 103852fd71cdSmrg # Trailing empty path component, ignore it. 103952fd71cdSmrg ;; 104052fd71cdSmrg ..) 104152fd71cdSmrg # Parent dir; strip last assembled component from result. 104252fd71cdSmrg func_dirname "$func_normal_abspath_result" 104352fd71cdSmrg func_normal_abspath_result=$func_dirname_result 104452fd71cdSmrg ;; 104552fd71cdSmrg *) 104652fd71cdSmrg # Actual path component, append it. 104752fd71cdSmrg func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent" 104852fd71cdSmrg ;; 104952fd71cdSmrg esac 105052fd71cdSmrg done 105152fd71cdSmrg # Restore leading double-slash if one was found on entry. 105252fd71cdSmrg func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result 105352fd71cdSmrg} 105452fd71cdSmrg 105552fd71cdSmrg 105652fd71cdSmrg# func_notquiet ARG... 105752fd71cdSmrg# -------------------- 105852fd71cdSmrg# Echo program name prefixed message only when not in quiet mode. 105952fd71cdSmrgfunc_notquiet () 106052fd71cdSmrg{ 106152fd71cdSmrg $debug_cmd 106252fd71cdSmrg 106352fd71cdSmrg $opt_quiet || func_echo ${1+"$@"} 106452fd71cdSmrg 106552fd71cdSmrg # A bug in bash halts the script if the last line of a function 106652fd71cdSmrg # fails when set -e is in force, so we need another command to 106752fd71cdSmrg # work around that: 106852fd71cdSmrg : 106952fd71cdSmrg} 107052fd71cdSmrg 107152fd71cdSmrg 107252fd71cdSmrg# func_relative_path SRCDIR DSTDIR 107352fd71cdSmrg# -------------------------------- 107452fd71cdSmrg# Set func_relative_path_result to the relative path from SRCDIR to DSTDIR. 107552fd71cdSmrgfunc_relative_path () 107652fd71cdSmrg{ 107752fd71cdSmrg $debug_cmd 107852fd71cdSmrg 107952fd71cdSmrg func_relative_path_result= 108052fd71cdSmrg func_normal_abspath "$1" 108152fd71cdSmrg func_relative_path_tlibdir=$func_normal_abspath_result 108252fd71cdSmrg func_normal_abspath "$2" 108352fd71cdSmrg func_relative_path_tbindir=$func_normal_abspath_result 108452fd71cdSmrg 108552fd71cdSmrg # Ascend the tree starting from libdir 108652fd71cdSmrg while :; do 108752fd71cdSmrg # check if we have found a prefix of bindir 108852fd71cdSmrg case $func_relative_path_tbindir in 108952fd71cdSmrg $func_relative_path_tlibdir) 109052fd71cdSmrg # found an exact match 109152fd71cdSmrg func_relative_path_tcancelled= 109252fd71cdSmrg break 109352fd71cdSmrg ;; 109452fd71cdSmrg $func_relative_path_tlibdir*) 109552fd71cdSmrg # found a matching prefix 109652fd71cdSmrg func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" 109752fd71cdSmrg func_relative_path_tcancelled=$func_stripname_result 109852fd71cdSmrg if test -z "$func_relative_path_result"; then 109952fd71cdSmrg func_relative_path_result=. 110052fd71cdSmrg fi 110152fd71cdSmrg break 110252fd71cdSmrg ;; 110352fd71cdSmrg *) 110452fd71cdSmrg func_dirname $func_relative_path_tlibdir 110552fd71cdSmrg func_relative_path_tlibdir=$func_dirname_result 110652fd71cdSmrg if test -z "$func_relative_path_tlibdir"; then 110752fd71cdSmrg # Have to descend all the way to the root! 110852fd71cdSmrg func_relative_path_result=../$func_relative_path_result 110952fd71cdSmrg func_relative_path_tcancelled=$func_relative_path_tbindir 111052fd71cdSmrg break 111152fd71cdSmrg fi 111252fd71cdSmrg func_relative_path_result=../$func_relative_path_result 111352fd71cdSmrg ;; 111452fd71cdSmrg esac 111552fd71cdSmrg done 111652fd71cdSmrg 111752fd71cdSmrg # Now calculate path; take care to avoid doubling-up slashes. 111852fd71cdSmrg func_stripname '' '/' "$func_relative_path_result" 111952fd71cdSmrg func_relative_path_result=$func_stripname_result 112052fd71cdSmrg func_stripname '/' '/' "$func_relative_path_tcancelled" 112152fd71cdSmrg if test -n "$func_stripname_result"; then 112252fd71cdSmrg func_append func_relative_path_result "/$func_stripname_result" 112352fd71cdSmrg fi 112452fd71cdSmrg 112552fd71cdSmrg # Normalisation. If bindir is libdir, return '.' else relative path. 112652fd71cdSmrg if test -n "$func_relative_path_result"; then 112752fd71cdSmrg func_stripname './' '' "$func_relative_path_result" 112852fd71cdSmrg func_relative_path_result=$func_stripname_result 11293da084b3Smrg fi 11303da084b3Smrg 113152fd71cdSmrg test -n "$func_relative_path_result" || func_relative_path_result=. 113252fd71cdSmrg 113352fd71cdSmrg : 113452fd71cdSmrg} 113552fd71cdSmrg 113652fd71cdSmrg 11372a53b785Smrg# func_quote_portable EVAL ARG 11382a53b785Smrg# ---------------------------- 11392a53b785Smrg# Internal function to portably implement func_quote_arg. Note that we still 11402a53b785Smrg# keep attention to performance here so we as much as possible try to avoid 11412a53b785Smrg# calling sed binary (so far O(N) complexity as long as func_append is O(1)). 11422a53b785Smrgfunc_quote_portable () 114352fd71cdSmrg{ 114452fd71cdSmrg $debug_cmd 114552fd71cdSmrg 11462a53b785Smrg $require_check_ifs_backslash 11472a53b785Smrg 11482a53b785Smrg func_quote_portable_result=$2 11492a53b785Smrg 11502a53b785Smrg # one-time-loop (easy break) 11512a53b785Smrg while true 11522a53b785Smrg do 11532a53b785Smrg if $1; then 11542a53b785Smrg func_quote_portable_result=`$ECHO "$2" | $SED \ 11552a53b785Smrg -e "$sed_double_quote_subst" -e "$sed_double_backslash"` 11562a53b785Smrg break 115752fd71cdSmrg fi 115852fd71cdSmrg 11592a53b785Smrg # Quote for eval. 11602a53b785Smrg case $func_quote_portable_result in 11612a53b785Smrg *[\\\`\"\$]*) 11622a53b785Smrg # Fallback to sed for $func_check_bs_ifs_broken=:, or when the string 11632a53b785Smrg # contains the shell wildcard characters. 11642a53b785Smrg case $check_ifs_backshlash_broken$func_quote_portable_result in 11652a53b785Smrg :*|*[\[\*\?]*) 11662a53b785Smrg func_quote_portable_result=`$ECHO "$func_quote_portable_result" \ 11672a53b785Smrg | $SED "$sed_quote_subst"` 11682a53b785Smrg break 11692a53b785Smrg ;; 11702a53b785Smrg esac 11712a53b785Smrg 11722a53b785Smrg func_quote_portable_old_IFS=$IFS 11732a53b785Smrg for _G_char in '\' '`' '"' '$' 11742a53b785Smrg do 11752a53b785Smrg # STATE($1) PREV($2) SEPARATOR($3) 11762a53b785Smrg set start "" "" 11772a53b785Smrg func_quote_portable_result=dummy"$_G_char$func_quote_portable_result$_G_char"dummy 11782a53b785Smrg IFS=$_G_char 11792a53b785Smrg for _G_part in $func_quote_portable_result 11802a53b785Smrg do 11812a53b785Smrg case $1 in 11822a53b785Smrg quote) 11832a53b785Smrg func_append func_quote_portable_result "$3$2" 11842a53b785Smrg set quote "$_G_part" "\\$_G_char" 11852a53b785Smrg ;; 11862a53b785Smrg start) 11872a53b785Smrg set first "" "" 11882a53b785Smrg func_quote_portable_result= 11892a53b785Smrg ;; 11902a53b785Smrg first) 11912a53b785Smrg set quote "$_G_part" "" 11922a53b785Smrg ;; 11932a53b785Smrg esac 11942a53b785Smrg done 11952a53b785Smrg done 11962a53b785Smrg IFS=$func_quote_portable_old_IFS 119752fd71cdSmrg ;; 11982a53b785Smrg *) ;; 119952fd71cdSmrg esac 12002a53b785Smrg break 120152fd71cdSmrg done 12022a53b785Smrg 12032a53b785Smrg func_quote_portable_unquoted_result=$func_quote_portable_result 12042a53b785Smrg case $func_quote_portable_result in 12052a53b785Smrg # double-quote args containing shell metacharacters to delay 12062a53b785Smrg # word splitting, command substitution and variable expansion 12072a53b785Smrg # for a subsequent eval. 12082a53b785Smrg # many bourne shells cannot handle close brackets correctly 12092a53b785Smrg # in scan sets, so we specify it separately. 12102a53b785Smrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 12112a53b785Smrg func_quote_portable_result=\"$func_quote_portable_result\" 12122a53b785Smrg ;; 12132a53b785Smrg esac 121452fd71cdSmrg} 121552fd71cdSmrg 121652fd71cdSmrg 12172a53b785Smrg# func_quotefast_eval ARG 12182a53b785Smrg# ----------------------- 12192a53b785Smrg# Quote one ARG (internal). This is equivalent to 'func_quote_arg eval ARG', 12202a53b785Smrg# but optimized for speed. Result is stored in $func_quotefast_eval. 12212a53b785Smrgif test xyes = `(x=; printf -v x %q yes; echo x"$x") 2>/dev/null`; then 12222a53b785Smrg printf -v _GL_test_printf_tilde %q '~' 12232a53b785Smrg if test '\~' = "$_GL_test_printf_tilde"; then 12242a53b785Smrg func_quotefast_eval () 12252a53b785Smrg { 12262a53b785Smrg printf -v func_quotefast_eval_result %q "$1" 12272a53b785Smrg } 12282a53b785Smrg else 12292a53b785Smrg # Broken older Bash implementations. Make those faster too if possible. 12302a53b785Smrg func_quotefast_eval () 12312a53b785Smrg { 12322a53b785Smrg case $1 in 12332a53b785Smrg '~'*) 12342a53b785Smrg func_quote_portable false "$1" 12352a53b785Smrg func_quotefast_eval_result=$func_quote_portable_result 12362a53b785Smrg ;; 12372a53b785Smrg *) 12382a53b785Smrg printf -v func_quotefast_eval_result %q "$1" 12392a53b785Smrg ;; 12402a53b785Smrg esac 12412a53b785Smrg } 12422a53b785Smrg fi 12432a53b785Smrgelse 12442a53b785Smrg func_quotefast_eval () 12452a53b785Smrg { 12462a53b785Smrg func_quote_portable false "$1" 12472a53b785Smrg func_quotefast_eval_result=$func_quote_portable_result 12482a53b785Smrg } 12492a53b785Smrgfi 125052fd71cdSmrg 12512a53b785Smrg 12522a53b785Smrg# func_quote_arg MODEs ARG 12532a53b785Smrg# ------------------------ 12542a53b785Smrg# Quote one ARG to be evaled later. MODEs argument may contain zero or more 12552a53b785Smrg# specifiers listed below separated by ',' character. This function returns two 12562a53b785Smrg# values: 12572a53b785Smrg# i) func_quote_arg_result 12582a53b785Smrg# double-quoted (when needed), suitable for a subsequent eval 12592a53b785Smrg# ii) func_quote_arg_unquoted_result 12602a53b785Smrg# has all characters that are still active within double 12612a53b785Smrg# quotes backslashified. Available only if 'unquoted' is specified. 12622a53b785Smrg# 12632a53b785Smrg# Available modes: 12642a53b785Smrg# ---------------- 12652a53b785Smrg# 'eval' (default) 12662a53b785Smrg# - escape shell special characters 12672a53b785Smrg# 'expand' 12682a53b785Smrg# - the same as 'eval'; but do not quote variable references 12692a53b785Smrg# 'pretty' 12702a53b785Smrg# - request aesthetic output, i.e. '"a b"' instead of 'a\ b'. This might 12712a53b785Smrg# be used later in func_quote to get output like: 'echo "a b"' instead 12722a53b785Smrg# of 'echo a\ b'. This is slower than default on some shells. 12732a53b785Smrg# 'unquoted' 12742a53b785Smrg# - produce also $func_quote_arg_unquoted_result which does not contain 12752a53b785Smrg# wrapping double-quotes. 12762a53b785Smrg# 12772a53b785Smrg# Examples for 'func_quote_arg pretty,unquoted string': 12782a53b785Smrg# 12792a53b785Smrg# string | *_result | *_unquoted_result 12802a53b785Smrg# ------------+-----------------------+------------------- 12812a53b785Smrg# " | \" | \" 12822a53b785Smrg# a b | "a b" | a b 12832a53b785Smrg# "a b" | "\"a b\"" | \"a b\" 12842a53b785Smrg# * | "*" | * 12852a53b785Smrg# z="${x-$y}" | "z=\"\${x-\$y}\"" | z=\"\${x-\$y}\" 12862a53b785Smrg# 12872a53b785Smrg# Examples for 'func_quote_arg pretty,unquoted,expand string': 12882a53b785Smrg# 12892a53b785Smrg# string | *_result | *_unquoted_result 12902a53b785Smrg# --------------+---------------------+-------------------- 12912a53b785Smrg# z="${x-$y}" | "z=\"${x-$y}\"" | z=\"${x-$y}\" 12922a53b785Smrgfunc_quote_arg () 12932a53b785Smrg{ 12942a53b785Smrg _G_quote_expand=false 12952a53b785Smrg case ,$1, in 12962a53b785Smrg *,expand,*) 12972a53b785Smrg _G_quote_expand=: 12982a53b785Smrg ;; 129952fd71cdSmrg esac 130052fd71cdSmrg 13012a53b785Smrg case ,$1, in 13022a53b785Smrg *,pretty,*|*,expand,*|*,unquoted,*) 13032a53b785Smrg func_quote_portable $_G_quote_expand "$2" 13042a53b785Smrg func_quote_arg_result=$func_quote_portable_result 13052a53b785Smrg func_quote_arg_unquoted_result=$func_quote_portable_unquoted_result 13062a53b785Smrg ;; 13072a53b785Smrg *) 13082a53b785Smrg # Faster quote-for-eval for some shells. 13092a53b785Smrg func_quotefast_eval "$2" 13102a53b785Smrg func_quote_arg_result=$func_quotefast_eval_result 131152fd71cdSmrg ;; 131252fd71cdSmrg esac 13132a53b785Smrg} 13142a53b785Smrg 131552fd71cdSmrg 13162a53b785Smrg# func_quote MODEs ARGs... 13172a53b785Smrg# ------------------------ 13182a53b785Smrg# Quote all ARGs to be evaled later and join them into single command. See 13192a53b785Smrg# func_quote_arg's description for more info. 13202a53b785Smrgfunc_quote () 13212a53b785Smrg{ 13222a53b785Smrg $debug_cmd 13232a53b785Smrg _G_func_quote_mode=$1 ; shift 13242a53b785Smrg func_quote_result= 13252a53b785Smrg while test 0 -lt $#; do 13262a53b785Smrg func_quote_arg "$_G_func_quote_mode" "$1" 13272a53b785Smrg if test -n "$func_quote_result"; then 13282a53b785Smrg func_append func_quote_result " $func_quote_arg_result" 13292a53b785Smrg else 13302a53b785Smrg func_append func_quote_result "$func_quote_arg_result" 13312a53b785Smrg fi 13322a53b785Smrg shift 13332a53b785Smrg done 133452fd71cdSmrg} 133552fd71cdSmrg 133652fd71cdSmrg 133752fd71cdSmrg# func_stripname PREFIX SUFFIX NAME 133852fd71cdSmrg# --------------------------------- 133952fd71cdSmrg# strip PREFIX and SUFFIX from NAME, and store in func_stripname_result. 134052fd71cdSmrg# PREFIX and SUFFIX must not contain globbing or regex special 134152fd71cdSmrg# characters, hashes, percent signs, but SUFFIX may contain a leading 134252fd71cdSmrg# dot (in which case that matches only a dot). 134352fd71cdSmrgif test yes = "$_G_HAVE_XSI_OPS"; then 134452fd71cdSmrg eval 'func_stripname () 134552fd71cdSmrg { 134652fd71cdSmrg $debug_cmd 134752fd71cdSmrg 134852fd71cdSmrg # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are 134952fd71cdSmrg # positional parameters, so assign one to ordinary variable first. 135052fd71cdSmrg func_stripname_result=$3 135152fd71cdSmrg func_stripname_result=${func_stripname_result#"$1"} 135252fd71cdSmrg func_stripname_result=${func_stripname_result%"$2"} 135352fd71cdSmrg }' 135452fd71cdSmrgelse 135552fd71cdSmrg func_stripname () 135652fd71cdSmrg { 135752fd71cdSmrg $debug_cmd 135852fd71cdSmrg 135952fd71cdSmrg case $2 in 136052fd71cdSmrg .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;; 136152fd71cdSmrg *) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;; 136252fd71cdSmrg esac 136352fd71cdSmrg } 136452fd71cdSmrgfi 136552fd71cdSmrg 136652fd71cdSmrg 136752fd71cdSmrg# func_show_eval CMD [FAIL_EXP] 136852fd71cdSmrg# ----------------------------- 136952fd71cdSmrg# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is 137052fd71cdSmrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 137152fd71cdSmrg# is given, then evaluate it. 137252fd71cdSmrgfunc_show_eval () 137352fd71cdSmrg{ 137452fd71cdSmrg $debug_cmd 137552fd71cdSmrg 137652fd71cdSmrg _G_cmd=$1 137752fd71cdSmrg _G_fail_exp=${2-':'} 137852fd71cdSmrg 13792a53b785Smrg func_quote_arg pretty,expand "$_G_cmd" 13802a53b785Smrg eval "func_notquiet $func_quote_arg_result" 138152fd71cdSmrg 138252fd71cdSmrg $opt_dry_run || { 138352fd71cdSmrg eval "$_G_cmd" 138452fd71cdSmrg _G_status=$? 138552fd71cdSmrg if test 0 -ne "$_G_status"; then 138652fd71cdSmrg eval "(exit $_G_status); $_G_fail_exp" 138752fd71cdSmrg fi 138852fd71cdSmrg } 138952fd71cdSmrg} 139052fd71cdSmrg 139152fd71cdSmrg 139252fd71cdSmrg# func_show_eval_locale CMD [FAIL_EXP] 139352fd71cdSmrg# ------------------------------------ 139452fd71cdSmrg# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is 139552fd71cdSmrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 139652fd71cdSmrg# is given, then evaluate it. Use the saved locale for evaluation. 139752fd71cdSmrgfunc_show_eval_locale () 139852fd71cdSmrg{ 139952fd71cdSmrg $debug_cmd 140052fd71cdSmrg 140152fd71cdSmrg _G_cmd=$1 140252fd71cdSmrg _G_fail_exp=${2-':'} 140352fd71cdSmrg 140452fd71cdSmrg $opt_quiet || { 14052a53b785Smrg func_quote_arg expand,pretty "$_G_cmd" 14062a53b785Smrg eval "func_echo $func_quote_arg_result" 140752fd71cdSmrg } 140852fd71cdSmrg 140952fd71cdSmrg $opt_dry_run || { 141052fd71cdSmrg eval "$_G_user_locale 141152fd71cdSmrg $_G_cmd" 141252fd71cdSmrg _G_status=$? 141352fd71cdSmrg eval "$_G_safe_locale" 141452fd71cdSmrg if test 0 -ne "$_G_status"; then 141552fd71cdSmrg eval "(exit $_G_status); $_G_fail_exp" 141652fd71cdSmrg fi 141752fd71cdSmrg } 141852fd71cdSmrg} 141952fd71cdSmrg 142052fd71cdSmrg 142152fd71cdSmrg# func_tr_sh 142252fd71cdSmrg# ---------- 142352fd71cdSmrg# Turn $1 into a string suitable for a shell variable name. 142452fd71cdSmrg# Result is stored in $func_tr_sh_result. All characters 142552fd71cdSmrg# not in the set a-zA-Z0-9_ are replaced with '_'. Further, 142652fd71cdSmrg# if $1 begins with a digit, a '_' is prepended as well. 142752fd71cdSmrgfunc_tr_sh () 142852fd71cdSmrg{ 142952fd71cdSmrg $debug_cmd 143052fd71cdSmrg 143152fd71cdSmrg case $1 in 143252fd71cdSmrg [0-9]* | *[!a-zA-Z0-9_]*) 143352fd71cdSmrg func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'` 143452fd71cdSmrg ;; 143552fd71cdSmrg * ) 143652fd71cdSmrg func_tr_sh_result=$1 143752fd71cdSmrg ;; 143852fd71cdSmrg esac 143952fd71cdSmrg} 144052fd71cdSmrg 144152fd71cdSmrg 144252fd71cdSmrg# func_verbose ARG... 144352fd71cdSmrg# ------------------- 144452fd71cdSmrg# Echo program name prefixed message in verbose mode only. 144552fd71cdSmrgfunc_verbose () 144652fd71cdSmrg{ 144752fd71cdSmrg $debug_cmd 144852fd71cdSmrg 144952fd71cdSmrg $opt_verbose && func_echo "$*" 145052fd71cdSmrg 145152fd71cdSmrg : 145252fd71cdSmrg} 145352fd71cdSmrg 145452fd71cdSmrg 145552fd71cdSmrg# func_warn_and_continue ARG... 145652fd71cdSmrg# ----------------------------- 145752fd71cdSmrg# Echo program name prefixed warning message to standard error. 145852fd71cdSmrgfunc_warn_and_continue () 145952fd71cdSmrg{ 146052fd71cdSmrg $debug_cmd 146152fd71cdSmrg 146252fd71cdSmrg $require_term_colors 146352fd71cdSmrg 146452fd71cdSmrg func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2 146552fd71cdSmrg} 146652fd71cdSmrg 146752fd71cdSmrg 146852fd71cdSmrg# func_warning CATEGORY ARG... 146952fd71cdSmrg# ---------------------------- 147052fd71cdSmrg# Echo program name prefixed warning message to standard error. Warning 147152fd71cdSmrg# messages can be filtered according to CATEGORY, where this function 147252fd71cdSmrg# elides messages where CATEGORY is not listed in the global variable 147352fd71cdSmrg# 'opt_warning_types'. 147452fd71cdSmrgfunc_warning () 147552fd71cdSmrg{ 147652fd71cdSmrg $debug_cmd 147752fd71cdSmrg 147852fd71cdSmrg # CATEGORY must be in the warning_categories list! 147952fd71cdSmrg case " $warning_categories " in 148052fd71cdSmrg *" $1 "*) ;; 148152fd71cdSmrg *) func_internal_error "invalid warning category '$1'" ;; 148252fd71cdSmrg esac 148352fd71cdSmrg 148452fd71cdSmrg _G_category=$1 148552fd71cdSmrg shift 148652fd71cdSmrg 148752fd71cdSmrg case " $opt_warning_types " in 148852fd71cdSmrg *" $_G_category "*) $warning_func ${1+"$@"} ;; 148952fd71cdSmrg esac 149052fd71cdSmrg} 149152fd71cdSmrg 149252fd71cdSmrg 149352fd71cdSmrg# func_sort_ver VER1 VER2 149452fd71cdSmrg# ----------------------- 149552fd71cdSmrg# 'sort -V' is not generally available. 149652fd71cdSmrg# Note this deviates from the version comparison in automake 149752fd71cdSmrg# in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a 149852fd71cdSmrg# but this should suffice as we won't be specifying old 149952fd71cdSmrg# version formats or redundant trailing .0 in bootstrap.conf. 150052fd71cdSmrg# If we did want full compatibility then we should probably 150152fd71cdSmrg# use m4_version_compare from autoconf. 150252fd71cdSmrgfunc_sort_ver () 150352fd71cdSmrg{ 150452fd71cdSmrg $debug_cmd 150552fd71cdSmrg 150652fd71cdSmrg printf '%s\n%s\n' "$1" "$2" \ 150752fd71cdSmrg | 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 150852fd71cdSmrg} 150952fd71cdSmrg 151052fd71cdSmrg# func_lt_ver PREV CURR 151152fd71cdSmrg# --------------------- 151252fd71cdSmrg# Return true if PREV and CURR are in the correct order according to 151352fd71cdSmrg# func_sort_ver, otherwise false. Use it like this: 151452fd71cdSmrg# 151552fd71cdSmrg# func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..." 151652fd71cdSmrgfunc_lt_ver () 151752fd71cdSmrg{ 151852fd71cdSmrg $debug_cmd 151952fd71cdSmrg 152052fd71cdSmrg test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q` 152152fd71cdSmrg} 152252fd71cdSmrg 152352fd71cdSmrg 152452fd71cdSmrg# Local variables: 152552fd71cdSmrg# mode: shell-script 152652fd71cdSmrg# sh-indentation: 2 152752fd71cdSmrg# eval: (add-hook 'before-save-hook 'time-stamp) 152852fd71cdSmrg# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" 152952fd71cdSmrg# time-stamp-time-zone: "UTC" 153052fd71cdSmrg# End: 153152fd71cdSmrg#! /bin/sh 153252fd71cdSmrg 153352fd71cdSmrg# A portable, pluggable option parser for Bourne shell. 153452fd71cdSmrg# Written by Gary V. Vaughan, 2010 153552fd71cdSmrg 15362a53b785Smrg# This is free software. There is NO warranty; not even for 15372a53b785Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 15382a53b785Smrg# 15392a53b785Smrg# Copyright (C) 2010-2019, 2021 Bootstrap Authors 15402a53b785Smrg# 15412a53b785Smrg# This file is dual licensed under the terms of the MIT license 15422a53b785Smrg# <https://opensource.org/license/MIT>, and GPL version 2 or later 15432a53b785Smrg# <http://www.gnu.org/licenses/gpl-2.0.html>. You must apply one of 15442a53b785Smrg# these licenses when using or redistributing this software or any of 15452a53b785Smrg# the files within it. See the URLs above, or the file `LICENSE` 15462a53b785Smrg# included in the Bootstrap distribution for the full license texts. 154752fd71cdSmrg 15482a53b785Smrg# Please report bugs or propose patches to: 15492a53b785Smrg# <https://github.com/gnulib-modules/bootstrap/issues> 155052fd71cdSmrg 15512a53b785Smrg# Set a version string for this script. 15522a53b785Smrgscriptversion=2019-02-19.15; # UTC 155352fd71cdSmrg 155452fd71cdSmrg 155552fd71cdSmrg## ------ ## 155652fd71cdSmrg## Usage. ## 155752fd71cdSmrg## ------ ## 155852fd71cdSmrg 155952fd71cdSmrg# This file is a library for parsing options in your shell scripts along 156052fd71cdSmrg# with assorted other useful supporting features that you can make use 156152fd71cdSmrg# of too. 156252fd71cdSmrg# 156352fd71cdSmrg# For the simplest scripts you might need only: 156452fd71cdSmrg# 156552fd71cdSmrg# #!/bin/sh 156652fd71cdSmrg# . relative/path/to/funclib.sh 156752fd71cdSmrg# . relative/path/to/options-parser 156852fd71cdSmrg# scriptversion=1.0 156952fd71cdSmrg# func_options ${1+"$@"} 157052fd71cdSmrg# eval set dummy "$func_options_result"; shift 157152fd71cdSmrg# ...rest of your script... 157252fd71cdSmrg# 157352fd71cdSmrg# In order for the '--version' option to work, you will need to have a 157452fd71cdSmrg# suitably formatted comment like the one at the top of this file 15752a53b785Smrg# starting with '# Written by ' and ending with '# Copyright'. 157652fd71cdSmrg# 157752fd71cdSmrg# For '-h' and '--help' to work, you will also need a one line 157852fd71cdSmrg# description of your script's purpose in a comment directly above the 157952fd71cdSmrg# '# Written by ' line, like the one at the top of this file. 158052fd71cdSmrg# 158152fd71cdSmrg# The default options also support '--debug', which will turn on shell 158252fd71cdSmrg# execution tracing (see the comment above debug_cmd below for another 158352fd71cdSmrg# use), and '--verbose' and the func_verbose function to allow your script 158452fd71cdSmrg# to display verbose messages only when your user has specified 158552fd71cdSmrg# '--verbose'. 158652fd71cdSmrg# 15872a53b785Smrg# After sourcing this file, you can plug in processing for additional 158852fd71cdSmrg# options by amending the variables from the 'Configuration' section 158952fd71cdSmrg# below, and following the instructions in the 'Option parsing' 159052fd71cdSmrg# section further down. 159152fd71cdSmrg 159252fd71cdSmrg## -------------- ## 159352fd71cdSmrg## Configuration. ## 159452fd71cdSmrg## -------------- ## 159552fd71cdSmrg 159652fd71cdSmrg# You should override these variables in your script after sourcing this 159752fd71cdSmrg# file so that they reflect the customisations you have added to the 159852fd71cdSmrg# option parser. 159952fd71cdSmrg 160052fd71cdSmrg# The usage line for option parsing errors and the start of '-h' and 160152fd71cdSmrg# '--help' output messages. You can embed shell variables for delayed 160252fd71cdSmrg# expansion at the time the message is displayed, but you will need to 160352fd71cdSmrg# quote other shell meta-characters carefully to prevent them being 160452fd71cdSmrg# expanded when the contents are evaled. 160552fd71cdSmrgusage='$progpath [OPTION]...' 160652fd71cdSmrg 160752fd71cdSmrg# Short help message in response to '-h' and '--help'. Add to this or 160852fd71cdSmrg# override it after sourcing this library to reflect the full set of 160952fd71cdSmrg# options your script accepts. 161052fd71cdSmrgusage_message="\ 161152fd71cdSmrg --debug enable verbose shell tracing 161252fd71cdSmrg -W, --warnings=CATEGORY 161352fd71cdSmrg report the warnings falling in CATEGORY [all] 161452fd71cdSmrg -v, --verbose verbosely report processing 161552fd71cdSmrg --version print version information and exit 161652fd71cdSmrg -h, --help print short or long help message and exit 161752fd71cdSmrg" 161852fd71cdSmrg 161952fd71cdSmrg# Additional text appended to 'usage_message' in response to '--help'. 162052fd71cdSmrglong_help_message=" 162152fd71cdSmrgWarning categories include: 162252fd71cdSmrg 'all' show all warnings 162352fd71cdSmrg 'none' turn off all the warnings 162452fd71cdSmrg 'error' warnings are treated as fatal errors" 162552fd71cdSmrg 162652fd71cdSmrg# Help message printed before fatal option parsing errors. 162752fd71cdSmrgfatal_help="Try '\$progname --help' for more information." 162852fd71cdSmrg 162952fd71cdSmrg 163052fd71cdSmrg 163152fd71cdSmrg## ------------------------- ## 163252fd71cdSmrg## Hook function management. ## 163352fd71cdSmrg## ------------------------- ## 163452fd71cdSmrg 163552fd71cdSmrg# This section contains functions for adding, removing, and running hooks 16362a53b785Smrg# in the main code. A hook is just a list of function names that can be 16372a53b785Smrg# run in order later on. 163852fd71cdSmrg 163952fd71cdSmrg# func_hookable FUNC_NAME 164052fd71cdSmrg# ----------------------- 164152fd71cdSmrg# Declare that FUNC_NAME will run hooks added with 164252fd71cdSmrg# 'func_add_hook FUNC_NAME ...'. 164352fd71cdSmrgfunc_hookable () 164452fd71cdSmrg{ 164552fd71cdSmrg $debug_cmd 164652fd71cdSmrg 164752fd71cdSmrg func_append hookable_fns " $1" 164852fd71cdSmrg} 164952fd71cdSmrg 165052fd71cdSmrg 165152fd71cdSmrg# func_add_hook FUNC_NAME HOOK_FUNC 165252fd71cdSmrg# --------------------------------- 165352fd71cdSmrg# Request that FUNC_NAME call HOOK_FUNC before it returns. FUNC_NAME must 165452fd71cdSmrg# first have been declared "hookable" by a call to 'func_hookable'. 165552fd71cdSmrgfunc_add_hook () 165652fd71cdSmrg{ 165752fd71cdSmrg $debug_cmd 165852fd71cdSmrg 165952fd71cdSmrg case " $hookable_fns " in 166052fd71cdSmrg *" $1 "*) ;; 166152fd71cdSmrg *) func_fatal_error "'$1' does not accept hook functions." ;; 166252fd71cdSmrg esac 166352fd71cdSmrg 166452fd71cdSmrg eval func_append ${1}_hooks '" $2"' 166552fd71cdSmrg} 166652fd71cdSmrg 166752fd71cdSmrg 166852fd71cdSmrg# func_remove_hook FUNC_NAME HOOK_FUNC 166952fd71cdSmrg# ------------------------------------ 16702a53b785Smrg# Remove HOOK_FUNC from the list of hook functions to be called by 16712a53b785Smrg# FUNC_NAME. 167252fd71cdSmrgfunc_remove_hook () 167352fd71cdSmrg{ 167452fd71cdSmrg $debug_cmd 167552fd71cdSmrg 167652fd71cdSmrg eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`' 167752fd71cdSmrg} 167852fd71cdSmrg 167952fd71cdSmrg 16802a53b785Smrg# func_propagate_result FUNC_NAME_A FUNC_NAME_B 16812a53b785Smrg# --------------------------------------------- 16822a53b785Smrg# If the *_result variable of FUNC_NAME_A _is set_, assign its value to 16832a53b785Smrg# *_result variable of FUNC_NAME_B. 16842a53b785Smrgfunc_propagate_result () 16852a53b785Smrg{ 16862a53b785Smrg $debug_cmd 16872a53b785Smrg 16882a53b785Smrg func_propagate_result_result=: 16892a53b785Smrg if eval "test \"\${${1}_result+set}\" = set" 16902a53b785Smrg then 16912a53b785Smrg eval "${2}_result=\$${1}_result" 16922a53b785Smrg else 16932a53b785Smrg func_propagate_result_result=false 16942a53b785Smrg fi 16952a53b785Smrg} 16962a53b785Smrg 16972a53b785Smrg 169852fd71cdSmrg# func_run_hooks FUNC_NAME [ARG]... 169952fd71cdSmrg# --------------------------------- 170052fd71cdSmrg# Run all hook functions registered to FUNC_NAME. 17012a53b785Smrg# It's assumed that the list of hook functions contains nothing more 170252fd71cdSmrg# than a whitespace-delimited list of legal shell function names, and 170352fd71cdSmrg# no effort is wasted trying to catch shell meta-characters or preserve 170452fd71cdSmrg# whitespace. 170552fd71cdSmrgfunc_run_hooks () 170652fd71cdSmrg{ 170752fd71cdSmrg $debug_cmd 170852fd71cdSmrg 170952fd71cdSmrg case " $hookable_fns " in 171052fd71cdSmrg *" $1 "*) ;; 17112a53b785Smrg *) func_fatal_error "'$1' does not support hook functions." ;; 171252fd71cdSmrg esac 171352fd71cdSmrg 171452fd71cdSmrg eval _G_hook_fns=\$$1_hooks; shift 171552fd71cdSmrg 171652fd71cdSmrg for _G_hook in $_G_hook_fns; do 17172a53b785Smrg func_unset "${_G_hook}_result" 17182a53b785Smrg eval $_G_hook '${1+"$@"}' 17192a53b785Smrg func_propagate_result $_G_hook func_run_hooks 17202a53b785Smrg if $func_propagate_result_result; then 17212a53b785Smrg eval set dummy "$func_run_hooks_result"; shift 17222a53b785Smrg fi 172352fd71cdSmrg done 172452fd71cdSmrg} 172552fd71cdSmrg 172652fd71cdSmrg 172752fd71cdSmrg 172852fd71cdSmrg## --------------- ## 172952fd71cdSmrg## Option parsing. ## 173052fd71cdSmrg## --------------- ## 173152fd71cdSmrg 173252fd71cdSmrg# In order to add your own option parsing hooks, you must accept the 17332a53b785Smrg# full positional parameter list from your hook function. You may remove 17342a53b785Smrg# or edit any options that you action, and then pass back the remaining 17352a53b785Smrg# unprocessed options in '<hooked_function_name>_result', escaped 17362a53b785Smrg# suitably for 'eval'. 17372a53b785Smrg# 17382a53b785Smrg# The '<hooked_function_name>_result' variable is automatically unset 17392a53b785Smrg# before your hook gets called; for best performance, only set the 17402a53b785Smrg# *_result variable when necessary (i.e. don't call the 'func_quote' 17412a53b785Smrg# function unnecessarily because it can be an expensive operation on some 17422a53b785Smrg# machines). 17432a53b785Smrg# 17442a53b785Smrg# Like this: 174552fd71cdSmrg# 174652fd71cdSmrg# my_options_prep () 174752fd71cdSmrg# { 174852fd71cdSmrg# $debug_cmd 174952fd71cdSmrg# 175052fd71cdSmrg# # Extend the existing usage message. 175152fd71cdSmrg# usage_message=$usage_message' 175252fd71cdSmrg# -s, --silent don'\''t print informational messages 175352fd71cdSmrg# ' 17542a53b785Smrg# # No change in '$@' (ignored completely by this hook). Leave 17552a53b785Smrg# # my_options_prep_result variable intact. 175652fd71cdSmrg# } 175752fd71cdSmrg# func_add_hook func_options_prep my_options_prep 175852fd71cdSmrg# 175952fd71cdSmrg# 176052fd71cdSmrg# my_silent_option () 176152fd71cdSmrg# { 176252fd71cdSmrg# $debug_cmd 176352fd71cdSmrg# 17642a53b785Smrg# args_changed=false 17652a53b785Smrg# 17662a53b785Smrg# # Note that, for efficiency, we parse as many options as we can 176752fd71cdSmrg# # recognise in a loop before passing the remainder back to the 176852fd71cdSmrg# # caller on the first unrecognised argument we encounter. 176952fd71cdSmrg# while test $# -gt 0; do 177052fd71cdSmrg# opt=$1; shift 177152fd71cdSmrg# case $opt in 17722a53b785Smrg# --silent|-s) opt_silent=: 17732a53b785Smrg# args_changed=: 17742a53b785Smrg# ;; 177552fd71cdSmrg# # Separate non-argument short options: 177652fd71cdSmrg# -s*) func_split_short_opt "$_G_opt" 177752fd71cdSmrg# set dummy "$func_split_short_opt_name" \ 177852fd71cdSmrg# "-$func_split_short_opt_arg" ${1+"$@"} 177952fd71cdSmrg# shift 17802a53b785Smrg# args_changed=: 178152fd71cdSmrg# ;; 17822a53b785Smrg# *) # Make sure the first unrecognised option "$_G_opt" 17832a53b785Smrg# # is added back to "$@" in case we need it later, 17842a53b785Smrg# # if $args_changed was set to 'true'. 17852a53b785Smrg# set dummy "$_G_opt" ${1+"$@"}; shift; break ;; 178652fd71cdSmrg# esac 178752fd71cdSmrg# done 178852fd71cdSmrg# 17892a53b785Smrg# # Only call 'func_quote' here if we processed at least one argument. 17902a53b785Smrg# if $args_changed; then 17912a53b785Smrg# func_quote eval ${1+"$@"} 17922a53b785Smrg# my_silent_option_result=$func_quote_result 17932a53b785Smrg# fi 179452fd71cdSmrg# } 179552fd71cdSmrg# func_add_hook func_parse_options my_silent_option 179652fd71cdSmrg# 179752fd71cdSmrg# 179852fd71cdSmrg# my_option_validation () 179952fd71cdSmrg# { 180052fd71cdSmrg# $debug_cmd 180152fd71cdSmrg# 180252fd71cdSmrg# $opt_silent && $opt_verbose && func_fatal_help "\ 180352fd71cdSmrg# '--silent' and '--verbose' options are mutually exclusive." 180452fd71cdSmrg# } 180552fd71cdSmrg# func_add_hook func_validate_options my_option_validation 180652fd71cdSmrg# 18072a53b785Smrg# You'll also need to manually amend $usage_message to reflect the extra 180852fd71cdSmrg# options you parse. It's preferable to append if you can, so that 180952fd71cdSmrg# multiple option parsing hooks can be added safely. 181052fd71cdSmrg 181152fd71cdSmrg 18122a53b785Smrg# func_options_finish [ARG]... 18132a53b785Smrg# ---------------------------- 18142a53b785Smrg# Finishing the option parse loop (call 'func_options' hooks ATM). 18152a53b785Smrgfunc_options_finish () 18162a53b785Smrg{ 18172a53b785Smrg $debug_cmd 18182a53b785Smrg 18192a53b785Smrg func_run_hooks func_options ${1+"$@"} 18202a53b785Smrg func_propagate_result func_run_hooks func_options_finish 18212a53b785Smrg} 18222a53b785Smrg 18232a53b785Smrg 182452fd71cdSmrg# func_options [ARG]... 182552fd71cdSmrg# --------------------- 182652fd71cdSmrg# All the functions called inside func_options are hookable. See the 182752fd71cdSmrg# individual implementations for details. 182852fd71cdSmrgfunc_hookable func_options 182952fd71cdSmrgfunc_options () 183052fd71cdSmrg{ 183152fd71cdSmrg $debug_cmd 183252fd71cdSmrg 18332a53b785Smrg _G_options_quoted=false 183452fd71cdSmrg 18352a53b785Smrg for my_func in options_prep parse_options validate_options options_finish 18362a53b785Smrg do 18372a53b785Smrg func_unset func_${my_func}_result 18382a53b785Smrg func_unset func_run_hooks_result 18392a53b785Smrg eval func_$my_func '${1+"$@"}' 18402a53b785Smrg func_propagate_result func_$my_func func_options 18412a53b785Smrg if $func_propagate_result_result; then 18422a53b785Smrg eval set dummy "$func_options_result"; shift 18432a53b785Smrg _G_options_quoted=: 18442a53b785Smrg fi 18452a53b785Smrg done 184652fd71cdSmrg 18472a53b785Smrg $_G_options_quoted || { 18482a53b785Smrg # As we (func_options) are top-level options-parser function and 18492a53b785Smrg # nobody quoted "$@" for us yet, we need to do it explicitly for 18502a53b785Smrg # caller. 18512a53b785Smrg func_quote eval ${1+"$@"} 18522a53b785Smrg func_options_result=$func_quote_result 18532a53b785Smrg } 18543da084b3Smrg} 18553da084b3Smrg 18563da084b3Smrg 185752fd71cdSmrg# func_options_prep [ARG]... 185852fd71cdSmrg# -------------------------- 185952fd71cdSmrg# All initialisations required before starting the option parse loop. 186052fd71cdSmrg# Note that when calling hook functions, we pass through the list of 186152fd71cdSmrg# positional parameters. If a hook function modifies that list, and 18622a53b785Smrg# needs to propagate that back to rest of this script, then the complete 18632a53b785Smrg# modified list must be put in 'func_run_hooks_result' before returning. 186452fd71cdSmrgfunc_hookable func_options_prep 186552fd71cdSmrgfunc_options_prep () 18663da084b3Smrg{ 186752fd71cdSmrg $debug_cmd 1868d63fdb69Smrg 186952fd71cdSmrg # Option defaults: 187052fd71cdSmrg opt_verbose=false 187152fd71cdSmrg opt_warning_types= 187252fd71cdSmrg 187352fd71cdSmrg func_run_hooks func_options_prep ${1+"$@"} 18742a53b785Smrg func_propagate_result func_run_hooks func_options_prep 18753da084b3Smrg} 18763da084b3Smrg 18773da084b3Smrg 187852fd71cdSmrg# func_parse_options [ARG]... 187952fd71cdSmrg# --------------------------- 188052fd71cdSmrg# The main option parsing loop. 188152fd71cdSmrgfunc_hookable func_parse_options 188252fd71cdSmrgfunc_parse_options () 18833da084b3Smrg{ 188452fd71cdSmrg $debug_cmd 1885d63fdb69Smrg 18862a53b785Smrg _G_parse_options_requote=false 188752fd71cdSmrg # this just eases exit handling 188852fd71cdSmrg while test $# -gt 0; do 188952fd71cdSmrg # Defer to hook functions for initial option parsing, so they 189052fd71cdSmrg # get priority in the event of reusing an option name. 189152fd71cdSmrg func_run_hooks func_parse_options ${1+"$@"} 18922a53b785Smrg func_propagate_result func_run_hooks func_parse_options 18932a53b785Smrg if $func_propagate_result_result; then 18942a53b785Smrg eval set dummy "$func_parse_options_result"; shift 18952a53b785Smrg # Even though we may have changed "$@", we passed the "$@" array 18962a53b785Smrg # down into the hook and it quoted it for us (because we are in 18972a53b785Smrg # this if-branch). No need to quote it again. 18982a53b785Smrg _G_parse_options_requote=false 18992a53b785Smrg fi 19003da084b3Smrg 190152fd71cdSmrg # Break out of the loop if we already parsed every option. 190252fd71cdSmrg test $# -gt 0 || break 19033da084b3Smrg 19042a53b785Smrg # We expect that one of the options parsed in this function matches 19052a53b785Smrg # and thus we remove _G_opt from "$@" and need to re-quote. 19062a53b785Smrg _G_match_parse_options=: 190752fd71cdSmrg _G_opt=$1 190852fd71cdSmrg shift 190952fd71cdSmrg case $_G_opt in 191052fd71cdSmrg --debug|-x) debug_cmd='set -x' 19112a53b785Smrg func_echo "enabling shell trace mode" >&2 191252fd71cdSmrg $debug_cmd 191352fd71cdSmrg ;; 191452fd71cdSmrg 191552fd71cdSmrg --no-warnings|--no-warning|--no-warn) 191652fd71cdSmrg set dummy --warnings none ${1+"$@"} 191752fd71cdSmrg shift 191852fd71cdSmrg ;; 1919d63fdb69Smrg 192052fd71cdSmrg --warnings|--warning|-W) 19212a53b785Smrg if test $# = 0 && func_missing_arg $_G_opt; then 19222a53b785Smrg _G_parse_options_requote=: 19232a53b785Smrg break 19242a53b785Smrg fi 192552fd71cdSmrg case " $warning_categories $1" in 192652fd71cdSmrg *" $1 "*) 192752fd71cdSmrg # trailing space prevents matching last $1 above 192852fd71cdSmrg func_append_uniq opt_warning_types " $1" 192952fd71cdSmrg ;; 193052fd71cdSmrg *all) 193152fd71cdSmrg opt_warning_types=$warning_categories 193252fd71cdSmrg ;; 193352fd71cdSmrg *none) 193452fd71cdSmrg opt_warning_types=none 193552fd71cdSmrg warning_func=: 193652fd71cdSmrg ;; 193752fd71cdSmrg *error) 193852fd71cdSmrg opt_warning_types=$warning_categories 193952fd71cdSmrg warning_func=func_fatal_error 194052fd71cdSmrg ;; 194152fd71cdSmrg *) 194252fd71cdSmrg func_fatal_error \ 194352fd71cdSmrg "unsupported warning category: '$1'" 194452fd71cdSmrg ;; 194552fd71cdSmrg esac 194652fd71cdSmrg shift 194752fd71cdSmrg ;; 194852fd71cdSmrg 194952fd71cdSmrg --verbose|-v) opt_verbose=: ;; 195052fd71cdSmrg --version) func_version ;; 195152fd71cdSmrg -\?|-h) func_usage ;; 195252fd71cdSmrg --help) func_help ;; 195352fd71cdSmrg 195452fd71cdSmrg # Separate optargs to long options (plugins may need this): 195552fd71cdSmrg --*=*) func_split_equals "$_G_opt" 195652fd71cdSmrg set dummy "$func_split_equals_lhs" \ 195752fd71cdSmrg "$func_split_equals_rhs" ${1+"$@"} 195852fd71cdSmrg shift 195952fd71cdSmrg ;; 196052fd71cdSmrg 196152fd71cdSmrg # Separate optargs to short options: 196252fd71cdSmrg -W*) 196352fd71cdSmrg func_split_short_opt "$_G_opt" 196452fd71cdSmrg set dummy "$func_split_short_opt_name" \ 196552fd71cdSmrg "$func_split_short_opt_arg" ${1+"$@"} 196652fd71cdSmrg shift 196752fd71cdSmrg ;; 196852fd71cdSmrg 196952fd71cdSmrg # Separate non-argument short options: 197052fd71cdSmrg -\?*|-h*|-v*|-x*) 197152fd71cdSmrg func_split_short_opt "$_G_opt" 197252fd71cdSmrg set dummy "$func_split_short_opt_name" \ 197352fd71cdSmrg "-$func_split_short_opt_arg" ${1+"$@"} 197452fd71cdSmrg shift 197552fd71cdSmrg ;; 197652fd71cdSmrg 19772a53b785Smrg --) _G_parse_options_requote=: ; break ;; 197852fd71cdSmrg -*) func_fatal_help "unrecognised option: '$_G_opt'" ;; 19792a53b785Smrg *) set dummy "$_G_opt" ${1+"$@"}; shift 19802a53b785Smrg _G_match_parse_options=false 19812a53b785Smrg break 19822a53b785Smrg ;; 198352fd71cdSmrg esac 19842a53b785Smrg 19852a53b785Smrg if $_G_match_parse_options; then 19862a53b785Smrg _G_parse_options_requote=: 19872a53b785Smrg fi 198852fd71cdSmrg done 198952fd71cdSmrg 19902a53b785Smrg if $_G_parse_options_requote; then 19912a53b785Smrg # save modified positional parameters for caller 19922a53b785Smrg func_quote eval ${1+"$@"} 19932a53b785Smrg func_parse_options_result=$func_quote_result 19942a53b785Smrg fi 19953da084b3Smrg} 19963da084b3Smrg 1997d63fdb69Smrg 199852fd71cdSmrg# func_validate_options [ARG]... 199952fd71cdSmrg# ------------------------------ 200052fd71cdSmrg# Perform any sanity checks on option settings and/or unconsumed 200152fd71cdSmrg# arguments. 200252fd71cdSmrgfunc_hookable func_validate_options 200352fd71cdSmrgfunc_validate_options () 20043da084b3Smrg{ 200552fd71cdSmrg $debug_cmd 20063da084b3Smrg 200752fd71cdSmrg # Display all warnings if -W was not given. 200852fd71cdSmrg test -n "$opt_warning_types" || opt_warning_types=" $warning_categories" 2009d63fdb69Smrg 201052fd71cdSmrg func_run_hooks func_validate_options ${1+"$@"} 20112a53b785Smrg func_propagate_result func_run_hooks func_validate_options 20123da084b3Smrg 201352fd71cdSmrg # Bail if the options were screwed! 201452fd71cdSmrg $exit_cmd $EXIT_FAILURE 201548c85eb7Smrg} 201648c85eb7Smrg 20173da084b3Smrg 201848c85eb7Smrg 201952fd71cdSmrg## ----------------- ## 202052fd71cdSmrg## Helper functions. ## 202152fd71cdSmrg## ----------------- ## 2022d63fdb69Smrg 202352fd71cdSmrg# This section contains the helper functions used by the rest of the 202452fd71cdSmrg# hookable option parser framework in ascii-betical order. 202552fd71cdSmrg 202652fd71cdSmrg 202752fd71cdSmrg# func_fatal_help ARG... 202852fd71cdSmrg# ---------------------- 202952fd71cdSmrg# Echo program name prefixed message to standard error, followed by 203052fd71cdSmrg# a help hint, and exit. 203152fd71cdSmrgfunc_fatal_help () 2032d63fdb69Smrg{ 203352fd71cdSmrg $debug_cmd 203448c85eb7Smrg 203552fd71cdSmrg eval \$ECHO \""Usage: $usage"\" 203652fd71cdSmrg eval \$ECHO \""$fatal_help"\" 203752fd71cdSmrg func_error ${1+"$@"} 203852fd71cdSmrg exit $EXIT_FAILURE 2039d63fdb69Smrg} 2040d63fdb69Smrg 204152fd71cdSmrg 204252fd71cdSmrg# func_help 204352fd71cdSmrg# --------- 204452fd71cdSmrg# Echo long help message to standard output and exit. 2045d63fdb69Smrgfunc_help () 2046d63fdb69Smrg{ 204752fd71cdSmrg $debug_cmd 204852fd71cdSmrg 204952fd71cdSmrg func_usage_message 205052fd71cdSmrg $ECHO "$long_help_message" 205152fd71cdSmrg exit 0 2052d63fdb69Smrg} 2053d63fdb69Smrg 205452fd71cdSmrg 205552fd71cdSmrg# func_missing_arg ARGNAME 205652fd71cdSmrg# ------------------------ 2057d63fdb69Smrg# Echo program name prefixed message to standard error and set global 2058d63fdb69Smrg# exit_cmd. 2059d63fdb69Smrgfunc_missing_arg () 2060d63fdb69Smrg{ 206152fd71cdSmrg $debug_cmd 206248c85eb7Smrg 206352fd71cdSmrg func_error "Missing argument for '$1'." 2064d63fdb69Smrg exit_cmd=exit 2065d63fdb69Smrg} 2066d63fdb69Smrg 2067d63fdb69Smrg 206852fd71cdSmrg# func_split_equals STRING 206952fd71cdSmrg# ------------------------ 20702a53b785Smrg# Set func_split_equals_lhs and func_split_equals_rhs shell variables 20712a53b785Smrg# after splitting STRING at the '=' sign. 207252fd71cdSmrgtest -z "$_G_HAVE_XSI_OPS" \ 207352fd71cdSmrg && (eval 'x=a/b/c; 207452fd71cdSmrg test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ 207552fd71cdSmrg && _G_HAVE_XSI_OPS=yes 207652fd71cdSmrg 207752fd71cdSmrgif test yes = "$_G_HAVE_XSI_OPS" 207852fd71cdSmrgthen 207952fd71cdSmrg # This is an XSI compatible shell, allowing a faster implementation... 208052fd71cdSmrg eval 'func_split_equals () 208152fd71cdSmrg { 208252fd71cdSmrg $debug_cmd 208352fd71cdSmrg 208452fd71cdSmrg func_split_equals_lhs=${1%%=*} 208552fd71cdSmrg func_split_equals_rhs=${1#*=} 20862a53b785Smrg if test "x$func_split_equals_lhs" = "x$1"; then 20872a53b785Smrg func_split_equals_rhs= 20882a53b785Smrg fi 208952fd71cdSmrg }' 209052fd71cdSmrgelse 209152fd71cdSmrg # ...otherwise fall back to using expr, which is often a shell builtin. 209252fd71cdSmrg func_split_equals () 209352fd71cdSmrg { 209452fd71cdSmrg $debug_cmd 209552fd71cdSmrg 209652fd71cdSmrg func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'` 209752fd71cdSmrg func_split_equals_rhs= 20982a53b785Smrg test "x$func_split_equals_lhs=" = "x$1" \ 209952fd71cdSmrg || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'` 210052fd71cdSmrg } 210152fd71cdSmrgfi #func_split_equals 210252fd71cdSmrg 210352fd71cdSmrg 210452fd71cdSmrg# func_split_short_opt SHORTOPT 210552fd71cdSmrg# ----------------------------- 210648c85eb7Smrg# Set func_split_short_opt_name and func_split_short_opt_arg shell 210748c85eb7Smrg# variables after splitting SHORTOPT after the 2nd character. 210852fd71cdSmrgif test yes = "$_G_HAVE_XSI_OPS" 210952fd71cdSmrgthen 211052fd71cdSmrg # This is an XSI compatible shell, allowing a faster implementation... 211152fd71cdSmrg eval 'func_split_short_opt () 211252fd71cdSmrg { 211352fd71cdSmrg $debug_cmd 211452fd71cdSmrg 211552fd71cdSmrg func_split_short_opt_arg=${1#??} 211652fd71cdSmrg func_split_short_opt_name=${1%"$func_split_short_opt_arg"} 211752fd71cdSmrg }' 211852fd71cdSmrgelse 211952fd71cdSmrg # ...otherwise fall back to using expr, which is often a shell builtin. 212052fd71cdSmrg func_split_short_opt () 212152fd71cdSmrg { 212252fd71cdSmrg $debug_cmd 212352fd71cdSmrg 21242a53b785Smrg func_split_short_opt_name=`expr "x$1" : 'x\(-.\)'` 212552fd71cdSmrg func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'` 212652fd71cdSmrg } 212752fd71cdSmrgfi #func_split_short_opt 212852fd71cdSmrg 212952fd71cdSmrg 213052fd71cdSmrg# func_usage 213152fd71cdSmrg# ---------- 213252fd71cdSmrg# Echo short help message to standard output and exit. 213352fd71cdSmrgfunc_usage () 213448c85eb7Smrg{ 213552fd71cdSmrg $debug_cmd 213648c85eb7Smrg 213752fd71cdSmrg func_usage_message 213852fd71cdSmrg $ECHO "Run '$progname --help |${PAGER-more}' for full usage" 213952fd71cdSmrg exit 0 214052fd71cdSmrg} 214148c85eb7Smrg 214248c85eb7Smrg 214352fd71cdSmrg# func_usage_message 214452fd71cdSmrg# ------------------ 214552fd71cdSmrg# Echo short help message to standard output. 214652fd71cdSmrgfunc_usage_message () 214748c85eb7Smrg{ 214852fd71cdSmrg $debug_cmd 214948c85eb7Smrg 215052fd71cdSmrg eval \$ECHO \""Usage: $usage"\" 215152fd71cdSmrg echo 215252fd71cdSmrg $SED -n 's|^# || 215352fd71cdSmrg /^Written by/{ 215452fd71cdSmrg x;p;x 215552fd71cdSmrg } 215652fd71cdSmrg h 215752fd71cdSmrg /^Written by/q' < "$progpath" 215852fd71cdSmrg echo 215952fd71cdSmrg eval \$ECHO \""$usage_message"\" 216052fd71cdSmrg} 216148c85eb7Smrg 2162d63fdb69Smrg 216352fd71cdSmrg# func_version 216452fd71cdSmrg# ------------ 216552fd71cdSmrg# Echo version message to standard output and exit. 21662a53b785Smrg# The version message is extracted from the calling file's header 21672a53b785Smrg# comments, with leading '# ' stripped: 21682a53b785Smrg# 1. First display the progname and version 21692a53b785Smrg# 2. Followed by the header comment line matching /^# Written by / 21702a53b785Smrg# 3. Then a blank line followed by the first following line matching 21712a53b785Smrg# /^# Copyright / 21722a53b785Smrg# 4. Immediately followed by any lines between the previous matches, 21732a53b785Smrg# except lines preceding the intervening completely blank line. 21742a53b785Smrg# For example, see the header comments of this file. 217552fd71cdSmrgfunc_version () 217652fd71cdSmrg{ 217752fd71cdSmrg $debug_cmd 2178d63fdb69Smrg 217952fd71cdSmrg printf '%s\n' "$progname $scriptversion" 218052fd71cdSmrg $SED -n ' 21812a53b785Smrg /^# Written by /!b 21822a53b785Smrg s|^# ||; p; n 21832a53b785Smrg 21842a53b785Smrg :fwd2blnk 21852a53b785Smrg /./ { 21862a53b785Smrg n 21872a53b785Smrg b fwd2blnk 218852fd71cdSmrg } 21892a53b785Smrg p; n 21902a53b785Smrg 21912a53b785Smrg :holdwrnt 21922a53b785Smrg s|^# || 21932a53b785Smrg s|^# *$|| 21942a53b785Smrg /^Copyright /!{ 21952a53b785Smrg /./H 21962a53b785Smrg n 21972a53b785Smrg b holdwrnt 219852fd71cdSmrg } 21992a53b785Smrg 22002a53b785Smrg s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2| 22012a53b785Smrg G 22022a53b785Smrg s|\(\n\)\n*|\1|g 22032a53b785Smrg p; q' < "$progpath" 2204d63fdb69Smrg 220552fd71cdSmrg exit $? 220652fd71cdSmrg} 2207d63fdb69Smrg 22083da084b3Smrg 220952fd71cdSmrg# Local variables: 221052fd71cdSmrg# mode: shell-script 221152fd71cdSmrg# sh-indentation: 2 221252fd71cdSmrg# eval: (add-hook 'before-save-hook 'time-stamp) 22132a53b785Smrg# time-stamp-pattern: "30/scriptversion=%:y-%02m-%02d.%02H; # UTC" 221452fd71cdSmrg# time-stamp-time-zone: "UTC" 221552fd71cdSmrg# End: 22163da084b3Smrg 221752fd71cdSmrg# Set a version string. 22182a53b785Smrgscriptversion='(GNU libtool) 2.4.7' 22193da084b3Smrg 22203da084b3Smrg 222152fd71cdSmrg# func_echo ARG... 222252fd71cdSmrg# ---------------- 222352fd71cdSmrg# Libtool also displays the current mode in messages, so override 222452fd71cdSmrg# funclib.sh func_echo with this custom definition. 222552fd71cdSmrgfunc_echo () 222648c85eb7Smrg{ 222752fd71cdSmrg $debug_cmd 222848c85eb7Smrg 222952fd71cdSmrg _G_message=$* 223048c85eb7Smrg 223152fd71cdSmrg func_echo_IFS=$IFS 223252fd71cdSmrg IFS=$nl 223352fd71cdSmrg for _G_line in $_G_message; do 223452fd71cdSmrg IFS=$func_echo_IFS 223552fd71cdSmrg $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line" 223652fd71cdSmrg done 223752fd71cdSmrg IFS=$func_echo_IFS 223852fd71cdSmrg} 223948c85eb7Smrg 224052fd71cdSmrg 224152fd71cdSmrg# func_warning ARG... 224252fd71cdSmrg# ------------------- 224352fd71cdSmrg# Libtool warnings are not categorized, so override funclib.sh 224452fd71cdSmrg# func_warning with this simpler definition. 224552fd71cdSmrgfunc_warning () 224648c85eb7Smrg{ 224752fd71cdSmrg $debug_cmd 224848c85eb7Smrg 224952fd71cdSmrg $warning_func ${1+"$@"} 225052fd71cdSmrg} 225148c85eb7Smrg 225248c85eb7Smrg 225352fd71cdSmrg## ---------------- ## 225452fd71cdSmrg## Options parsing. ## 225552fd71cdSmrg## ---------------- ## 225652fd71cdSmrg 225752fd71cdSmrg# Hook in the functions to make sure our own options are parsed during 225852fd71cdSmrg# the option parsing loop. 225952fd71cdSmrg 226052fd71cdSmrgusage='$progpath [OPTION]... [MODE-ARG]...' 226152fd71cdSmrg 226252fd71cdSmrg# Short help message in response to '-h'. 226352fd71cdSmrgusage_message="Options: 226452fd71cdSmrg --config show all configuration variables 226552fd71cdSmrg --debug enable verbose shell tracing 226652fd71cdSmrg -n, --dry-run display commands without modifying any files 226752fd71cdSmrg --features display basic configuration information and exit 226852fd71cdSmrg --mode=MODE use operation mode MODE 226952fd71cdSmrg --no-warnings equivalent to '-Wnone' 227052fd71cdSmrg --preserve-dup-deps don't remove duplicate dependency libraries 227152fd71cdSmrg --quiet, --silent don't print informational messages 227252fd71cdSmrg --tag=TAG use configuration variables from tag TAG 227352fd71cdSmrg -v, --verbose print more informational messages than default 227452fd71cdSmrg --version print version information 227552fd71cdSmrg -W, --warnings=CATEGORY report the warnings falling in CATEGORY [all] 227652fd71cdSmrg -h, --help, --help-all print short, long, or detailed help message 227752fd71cdSmrg" 227848c85eb7Smrg 227952fd71cdSmrg# Additional text appended to 'usage_message' in response to '--help'. 228052fd71cdSmrgfunc_help () 228148c85eb7Smrg{ 228252fd71cdSmrg $debug_cmd 228352fd71cdSmrg 228452fd71cdSmrg func_usage_message 228552fd71cdSmrg $ECHO "$long_help_message 228652fd71cdSmrg 228752fd71cdSmrgMODE must be one of the following: 228852fd71cdSmrg 228952fd71cdSmrg clean remove files from the build directory 229052fd71cdSmrg compile compile a source file into a libtool object 229152fd71cdSmrg execute automatically set library path, then run a program 229252fd71cdSmrg finish complete the installation of libtool libraries 229352fd71cdSmrg install install libraries or executables 229452fd71cdSmrg link create a library or an executable 229552fd71cdSmrg uninstall remove libraries from an installed directory 229652fd71cdSmrg 229752fd71cdSmrgMODE-ARGS vary depending on the MODE. When passed as first option, 229852fd71cdSmrg'--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that. 229952fd71cdSmrgTry '$progname --help --mode=MODE' for a more detailed description of MODE. 230052fd71cdSmrg 230152fd71cdSmrgWhen reporting a bug, please describe a test case to reproduce it and 230252fd71cdSmrginclude the following information: 230352fd71cdSmrg 230452fd71cdSmrg host-triplet: $host 230552fd71cdSmrg shell: $SHELL 230652fd71cdSmrg compiler: $LTCC 230752fd71cdSmrg compiler flags: $LTCFLAGS 230852fd71cdSmrg linker: $LD (gnu? $with_gnu_ld) 23092a53b785Smrg version: $progname (GNU libtool) 2.4.7 231052fd71cdSmrg automake: `($AUTOMAKE --version) 2>/dev/null |$SED 1q` 231152fd71cdSmrg autoconf: `($AUTOCONF --version) 2>/dev/null |$SED 1q` 231252fd71cdSmrg 231352fd71cdSmrgReport bugs to <bug-libtool@gnu.org>. 23142a53b785SmrgGNU libtool home page: <http://www.gnu.org/software/libtool/>. 231552fd71cdSmrgGeneral help using GNU software: <http://www.gnu.org/gethelp/>." 231652fd71cdSmrg exit 0 231752fd71cdSmrg} 231848c85eb7Smrg 231948c85eb7Smrg 232052fd71cdSmrg# func_lo2o OBJECT-NAME 232152fd71cdSmrg# --------------------- 232252fd71cdSmrg# Transform OBJECT-NAME from a '.lo' suffix to the platform specific 232352fd71cdSmrg# object suffix. 232452fd71cdSmrg 232552fd71cdSmrglo2o=s/\\.lo\$/.$objext/ 232652fd71cdSmrgo2lo=s/\\.$objext\$/.lo/ 232752fd71cdSmrg 232852fd71cdSmrgif test yes = "$_G_HAVE_XSI_OPS"; then 232952fd71cdSmrg eval 'func_lo2o () 233052fd71cdSmrg { 233152fd71cdSmrg case $1 in 233252fd71cdSmrg *.lo) func_lo2o_result=${1%.lo}.$objext ;; 233352fd71cdSmrg * ) func_lo2o_result=$1 ;; 233452fd71cdSmrg esac 233552fd71cdSmrg }' 233652fd71cdSmrg 233752fd71cdSmrg # func_xform LIBOBJ-OR-SOURCE 233852fd71cdSmrg # --------------------------- 233952fd71cdSmrg # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise) 234052fd71cdSmrg # suffix to a '.lo' libtool-object suffix. 234152fd71cdSmrg eval 'func_xform () 234252fd71cdSmrg { 234352fd71cdSmrg func_xform_result=${1%.*}.lo 234452fd71cdSmrg }' 234552fd71cdSmrgelse 234652fd71cdSmrg # ...otherwise fall back to using sed. 234752fd71cdSmrg func_lo2o () 234852fd71cdSmrg { 234952fd71cdSmrg func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"` 235052fd71cdSmrg } 235152fd71cdSmrg 235252fd71cdSmrg func_xform () 235352fd71cdSmrg { 235452fd71cdSmrg func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'` 235552fd71cdSmrg } 235652fd71cdSmrgfi 235748c85eb7Smrg 235848c85eb7Smrg 235952fd71cdSmrg# func_fatal_configuration ARG... 236052fd71cdSmrg# ------------------------------- 2361d63fdb69Smrg# Echo program name prefixed message to standard error, followed by 2362d63fdb69Smrg# a configuration failure hint, and exit. 2363d63fdb69Smrgfunc_fatal_configuration () 2364d63fdb69Smrg{ 23652a53b785Smrg func_fatal_error ${1+"$@"} \ 236652fd71cdSmrg "See the $PACKAGE documentation for more information." \ 236752fd71cdSmrg "Fatal configuration error." 2368d63fdb69Smrg} 2369d63fdb69Smrg 2370d63fdb69Smrg 2371d63fdb69Smrg# func_config 237252fd71cdSmrg# ----------- 2373d63fdb69Smrg# Display the configuration for all the tags in this script. 2374d63fdb69Smrgfunc_config () 2375d63fdb69Smrg{ 2376d63fdb69Smrg re_begincf='^# ### BEGIN LIBTOOL' 2377d63fdb69Smrg re_endcf='^# ### END LIBTOOL' 2378d63fdb69Smrg 2379d63fdb69Smrg # Default configuration. 2380d63fdb69Smrg $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" 23813da084b3Smrg 23823da084b3Smrg # Now print the configurations for the tags. 23833da084b3Smrg for tagname in $taglist; do 2384d63fdb69Smrg $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" 23853da084b3Smrg done 23863da084b3Smrg 2387d63fdb69Smrg exit $? 2388d63fdb69Smrg} 23893da084b3Smrg 239052fd71cdSmrg 2391d63fdb69Smrg# func_features 239252fd71cdSmrg# ------------- 2393d63fdb69Smrg# Display the features supported by this script. 2394d63fdb69Smrgfunc_features () 2395d63fdb69Smrg{ 239655acc8fcSmrg echo "host: $host" 239752fd71cdSmrg if test yes = "$build_libtool_libs"; then 239855acc8fcSmrg echo "enable shared libraries" 23993da084b3Smrg else 240055acc8fcSmrg echo "disable shared libraries" 24013da084b3Smrg fi 240252fd71cdSmrg if test yes = "$build_old_libs"; then 240355acc8fcSmrg echo "enable static libraries" 24043da084b3Smrg else 240555acc8fcSmrg echo "disable static libraries" 24063da084b3Smrg fi 2407d63fdb69Smrg 24083da084b3Smrg exit $? 2409d63fdb69Smrg} 2410d63fdb69Smrg 241152fd71cdSmrg 241252fd71cdSmrg# func_enable_tag TAGNAME 241352fd71cdSmrg# ----------------------- 2414d63fdb69Smrg# Verify that TAGNAME is valid, and either flag an error and exit, or 2415d63fdb69Smrg# enable the TAGNAME tag. We also add TAGNAME to the global $taglist 2416d63fdb69Smrg# variable here. 2417d63fdb69Smrgfunc_enable_tag () 2418d63fdb69Smrg{ 241952fd71cdSmrg # Global variable: 242052fd71cdSmrg tagname=$1 24213da084b3Smrg 242252fd71cdSmrg re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" 242352fd71cdSmrg re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" 242452fd71cdSmrg sed_extractcf=/$re_begincf/,/$re_endcf/p 24253da084b3Smrg 242652fd71cdSmrg # Validate tagname. 242752fd71cdSmrg case $tagname in 242852fd71cdSmrg *[!-_A-Za-z0-9,/]*) 242952fd71cdSmrg func_fatal_error "invalid tag name: $tagname" 243052fd71cdSmrg ;; 243152fd71cdSmrg esac 24323da084b3Smrg 243352fd71cdSmrg # Don't test for the "default" C tag, as we know it's 243452fd71cdSmrg # there but not specially marked. 243552fd71cdSmrg case $tagname in 243652fd71cdSmrg CC) ;; 2437d63fdb69Smrg *) 243852fd71cdSmrg if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then 243952fd71cdSmrg taglist="$taglist $tagname" 244052fd71cdSmrg 244152fd71cdSmrg # Evaluate the configuration. Be careful to quote the path 244252fd71cdSmrg # and the sed script, to avoid splitting on whitespace, but 244352fd71cdSmrg # also don't use non-portable quotes within backquotes within 244452fd71cdSmrg # quotes we have to do it in 2 steps: 244552fd71cdSmrg extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` 244652fd71cdSmrg eval "$extractedcf" 244752fd71cdSmrg else 244852fd71cdSmrg func_error "ignoring unknown tag $tagname" 244952fd71cdSmrg fi 245052fd71cdSmrg ;; 245152fd71cdSmrg esac 2452d63fdb69Smrg} 24533da084b3Smrg 245452fd71cdSmrg 245548c85eb7Smrg# func_check_version_match 245652fd71cdSmrg# ------------------------ 245748c85eb7Smrg# Ensure that we are using m4 macros, and libtool script from the same 245848c85eb7Smrg# release of libtool. 245948c85eb7Smrgfunc_check_version_match () 2460d63fdb69Smrg{ 246152fd71cdSmrg if test "$package_revision" != "$macro_revision"; then 246252fd71cdSmrg if test "$VERSION" != "$macro_version"; then 246352fd71cdSmrg if test -z "$macro_version"; then 246452fd71cdSmrg cat >&2 <<_LT_EOF 246548c85eb7Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 246648c85eb7Smrg$progname: definition of this LT_INIT comes from an older release. 246748c85eb7Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 246848c85eb7Smrg$progname: and run autoconf again. 246948c85eb7Smrg_LT_EOF 247052fd71cdSmrg else 247152fd71cdSmrg cat >&2 <<_LT_EOF 247248c85eb7Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 247348c85eb7Smrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version. 247448c85eb7Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 247548c85eb7Smrg$progname: and run autoconf again. 247648c85eb7Smrg_LT_EOF 247752fd71cdSmrg fi 247852fd71cdSmrg else 247952fd71cdSmrg cat >&2 <<_LT_EOF 248048c85eb7Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, 248148c85eb7Smrg$progname: but the definition of this LT_INIT comes from revision $macro_revision. 248248c85eb7Smrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision 248348c85eb7Smrg$progname: of $PACKAGE $VERSION and run autoconf again. 248448c85eb7Smrg_LT_EOF 248552fd71cdSmrg fi 248648c85eb7Smrg 248752fd71cdSmrg exit $EXIT_MISMATCH 248852fd71cdSmrg fi 248948c85eb7Smrg} 249048c85eb7Smrg 249148c85eb7Smrg 249252fd71cdSmrg# libtool_options_prep [ARG]... 249352fd71cdSmrg# ----------------------------- 249452fd71cdSmrg# Preparation for options parsed by libtool. 249552fd71cdSmrglibtool_options_prep () 249652fd71cdSmrg{ 249752fd71cdSmrg $debug_mode 249848c85eb7Smrg 249952fd71cdSmrg # Option defaults: 250052fd71cdSmrg opt_config=false 250152fd71cdSmrg opt_dlopen= 250252fd71cdSmrg opt_dry_run=false 250352fd71cdSmrg opt_help=false 250452fd71cdSmrg opt_mode= 250552fd71cdSmrg opt_preserve_dup_deps=false 250652fd71cdSmrg opt_quiet=false 250748c85eb7Smrg 250852fd71cdSmrg nonopt= 250952fd71cdSmrg preserve_args= 251048c85eb7Smrg 25112a53b785Smrg _G_rc_lt_options_prep=: 25122a53b785Smrg 251352fd71cdSmrg # Shorthand for --mode=foo, only valid as the first argument 251452fd71cdSmrg case $1 in 251552fd71cdSmrg clean|clea|cle|cl) 251652fd71cdSmrg shift; set dummy --mode clean ${1+"$@"}; shift 251752fd71cdSmrg ;; 251852fd71cdSmrg compile|compil|compi|comp|com|co|c) 251952fd71cdSmrg shift; set dummy --mode compile ${1+"$@"}; shift 252052fd71cdSmrg ;; 252152fd71cdSmrg execute|execut|execu|exec|exe|ex|e) 252252fd71cdSmrg shift; set dummy --mode execute ${1+"$@"}; shift 252352fd71cdSmrg ;; 252452fd71cdSmrg finish|finis|fini|fin|fi|f) 252552fd71cdSmrg shift; set dummy --mode finish ${1+"$@"}; shift 252652fd71cdSmrg ;; 252752fd71cdSmrg install|instal|insta|inst|ins|in|i) 252852fd71cdSmrg shift; set dummy --mode install ${1+"$@"}; shift 252952fd71cdSmrg ;; 253052fd71cdSmrg link|lin|li|l) 253152fd71cdSmrg shift; set dummy --mode link ${1+"$@"}; shift 253252fd71cdSmrg ;; 253352fd71cdSmrg uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) 253452fd71cdSmrg shift; set dummy --mode uninstall ${1+"$@"}; shift 253552fd71cdSmrg ;; 25362a53b785Smrg *) 25372a53b785Smrg _G_rc_lt_options_prep=false 25382a53b785Smrg ;; 253952fd71cdSmrg esac 254052fd71cdSmrg 25412a53b785Smrg if $_G_rc_lt_options_prep; then 25422a53b785Smrg # Pass back the list of options. 25432a53b785Smrg func_quote eval ${1+"$@"} 25442a53b785Smrg libtool_options_prep_result=$func_quote_result 25452a53b785Smrg fi 254652fd71cdSmrg} 254752fd71cdSmrgfunc_add_hook func_options_prep libtool_options_prep 25483da084b3Smrg 25493da084b3Smrg 255052fd71cdSmrg# libtool_parse_options [ARG]... 255152fd71cdSmrg# --------------------------------- 255252fd71cdSmrg# Provide handling for libtool specific options. 255352fd71cdSmrglibtool_parse_options () 255448c85eb7Smrg{ 255552fd71cdSmrg $debug_cmd 2556d63fdb69Smrg 25572a53b785Smrg _G_rc_lt_parse_options=false 25582a53b785Smrg 255952fd71cdSmrg # Perform our own loop to consume as many options as possible in 256052fd71cdSmrg # each iteration. 256152fd71cdSmrg while test $# -gt 0; do 25622a53b785Smrg _G_match_lt_parse_options=: 256352fd71cdSmrg _G_opt=$1 256452fd71cdSmrg shift 256552fd71cdSmrg case $_G_opt in 256652fd71cdSmrg --dry-run|--dryrun|-n) 256752fd71cdSmrg opt_dry_run=: 256852fd71cdSmrg ;; 256952fd71cdSmrg 257052fd71cdSmrg --config) func_config ;; 257152fd71cdSmrg 257252fd71cdSmrg --dlopen|-dlopen) 257352fd71cdSmrg opt_dlopen="${opt_dlopen+$opt_dlopen 257452fd71cdSmrg}$1" 257552fd71cdSmrg shift 257652fd71cdSmrg ;; 257752fd71cdSmrg 257852fd71cdSmrg --preserve-dup-deps) 257952fd71cdSmrg opt_preserve_dup_deps=: ;; 258052fd71cdSmrg 258152fd71cdSmrg --features) func_features ;; 258252fd71cdSmrg 258352fd71cdSmrg --finish) set dummy --mode finish ${1+"$@"}; shift ;; 258452fd71cdSmrg 258552fd71cdSmrg --help) opt_help=: ;; 258652fd71cdSmrg 258752fd71cdSmrg --help-all) opt_help=': help-all' ;; 258852fd71cdSmrg 258952fd71cdSmrg --mode) test $# = 0 && func_missing_arg $_G_opt && break 259052fd71cdSmrg opt_mode=$1 259152fd71cdSmrg case $1 in 259252fd71cdSmrg # Valid mode arguments: 259352fd71cdSmrg clean|compile|execute|finish|install|link|relink|uninstall) ;; 259452fd71cdSmrg 259552fd71cdSmrg # Catch anything else as an error 259652fd71cdSmrg *) func_error "invalid argument for $_G_opt" 259752fd71cdSmrg exit_cmd=exit 259852fd71cdSmrg break 259952fd71cdSmrg ;; 260052fd71cdSmrg esac 260152fd71cdSmrg shift 260252fd71cdSmrg ;; 260352fd71cdSmrg 260452fd71cdSmrg --no-silent|--no-quiet) 260552fd71cdSmrg opt_quiet=false 260652fd71cdSmrg func_append preserve_args " $_G_opt" 260752fd71cdSmrg ;; 260852fd71cdSmrg 260952fd71cdSmrg --no-warnings|--no-warning|--no-warn) 261052fd71cdSmrg opt_warning=false 261152fd71cdSmrg func_append preserve_args " $_G_opt" 261252fd71cdSmrg ;; 261352fd71cdSmrg 261452fd71cdSmrg --no-verbose) 261552fd71cdSmrg opt_verbose=false 261652fd71cdSmrg func_append preserve_args " $_G_opt" 261752fd71cdSmrg ;; 261852fd71cdSmrg 261952fd71cdSmrg --silent|--quiet) 262052fd71cdSmrg opt_quiet=: 262152fd71cdSmrg opt_verbose=false 262252fd71cdSmrg func_append preserve_args " $_G_opt" 262352fd71cdSmrg ;; 262452fd71cdSmrg 262552fd71cdSmrg --tag) test $# = 0 && func_missing_arg $_G_opt && break 262652fd71cdSmrg opt_tag=$1 262752fd71cdSmrg func_append preserve_args " $_G_opt $1" 262852fd71cdSmrg func_enable_tag "$1" 262952fd71cdSmrg shift 263052fd71cdSmrg ;; 263152fd71cdSmrg 263252fd71cdSmrg --verbose|-v) opt_quiet=false 263352fd71cdSmrg opt_verbose=: 263452fd71cdSmrg func_append preserve_args " $_G_opt" 263552fd71cdSmrg ;; 263652fd71cdSmrg 26372a53b785Smrg # An option not handled by this hook function: 26382a53b785Smrg *) set dummy "$_G_opt" ${1+"$@"} ; shift 26392a53b785Smrg _G_match_lt_parse_options=false 26402a53b785Smrg break 26412a53b785Smrg ;; 264252fd71cdSmrg esac 26432a53b785Smrg $_G_match_lt_parse_options && _G_rc_lt_parse_options=: 264452fd71cdSmrg done 264548c85eb7Smrg 26462a53b785Smrg if $_G_rc_lt_parse_options; then 26472a53b785Smrg # save modified positional parameters for caller 26482a53b785Smrg func_quote eval ${1+"$@"} 26492a53b785Smrg libtool_parse_options_result=$func_quote_result 26502a53b785Smrg fi 265152fd71cdSmrg} 265252fd71cdSmrgfunc_add_hook func_parse_options libtool_parse_options 2653d63fdb69Smrg 26543da084b3Smrg 2655d63fdb69Smrg 265652fd71cdSmrg# libtool_validate_options [ARG]... 265752fd71cdSmrg# --------------------------------- 265852fd71cdSmrg# Perform any sanity checks on option settings and/or unconsumed 265952fd71cdSmrg# arguments. 266052fd71cdSmrglibtool_validate_options () 266152fd71cdSmrg{ 266252fd71cdSmrg # save first non-option argument 266352fd71cdSmrg if test 0 -lt $#; then 266452fd71cdSmrg nonopt=$1 266552fd71cdSmrg shift 2666d63fdb69Smrg fi 2667d63fdb69Smrg 266852fd71cdSmrg # preserve --debug 266952fd71cdSmrg test : = "$debug_cmd" || func_append preserve_args " --debug" 2670d63fdb69Smrg 267152fd71cdSmrg case $host in 267252fd71cdSmrg # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452 267352fd71cdSmrg # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788 267452fd71cdSmrg *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*) 267552fd71cdSmrg # don't eliminate duplications in $postdeps and $predeps 267652fd71cdSmrg opt_duplicate_compiler_generated_deps=: 267752fd71cdSmrg ;; 267852fd71cdSmrg *) 267952fd71cdSmrg opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps 268052fd71cdSmrg ;; 268152fd71cdSmrg esac 2682d63fdb69Smrg 268352fd71cdSmrg $opt_help || { 268452fd71cdSmrg # Sanity checks first: 268552fd71cdSmrg func_check_version_match 268652fd71cdSmrg 268752fd71cdSmrg test yes != "$build_libtool_libs" \ 268852fd71cdSmrg && test yes != "$build_old_libs" \ 268952fd71cdSmrg && func_fatal_configuration "not configured to build any kind of library" 269052fd71cdSmrg 269152fd71cdSmrg # Darwin sucks 269252fd71cdSmrg eval std_shrext=\"$shrext_cmds\" 269352fd71cdSmrg 269452fd71cdSmrg # Only execute mode is allowed to have -dlopen flags. 269552fd71cdSmrg if test -n "$opt_dlopen" && test execute != "$opt_mode"; then 269652fd71cdSmrg func_error "unrecognized option '-dlopen'" 269752fd71cdSmrg $ECHO "$help" 1>&2 269852fd71cdSmrg exit $EXIT_FAILURE 269952fd71cdSmrg fi 2700d63fdb69Smrg 270152fd71cdSmrg # Change the help message to a mode-specific one. 270252fd71cdSmrg generic_help=$help 270352fd71cdSmrg help="Try '$progname --help --mode=$opt_mode' for more information." 270452fd71cdSmrg } 2705d63fdb69Smrg 270652fd71cdSmrg # Pass back the unparsed argument list 27072a53b785Smrg func_quote eval ${1+"$@"} 27082a53b785Smrg libtool_validate_options_result=$func_quote_result 270948c85eb7Smrg} 271052fd71cdSmrgfunc_add_hook func_validate_options libtool_validate_options 2711d63fdb69Smrg 2712d63fdb69Smrg 271352fd71cdSmrg# Process options as early as possible so that --help and --version 271452fd71cdSmrg# can return quickly. 271552fd71cdSmrgfunc_options ${1+"$@"} 271652fd71cdSmrgeval set dummy "$func_options_result"; shift 271752fd71cdSmrg 27183da084b3Smrg 27193da084b3Smrg 272048c85eb7Smrg## ----------- ## 272148c85eb7Smrg## Main. ## 272248c85eb7Smrg## ----------- ## 27233da084b3Smrg 272452fd71cdSmrgmagic='%%%MAGIC variable%%%' 272552fd71cdSmrgmagic_exe='%%%MAGIC EXE variable%%%' 272652fd71cdSmrg 272752fd71cdSmrg# Global variables. 272852fd71cdSmrgextracted_archives= 272952fd71cdSmrgextracted_serial=0 273052fd71cdSmrg 273152fd71cdSmrg# If this variable is set in any of the actions, the command in it 273252fd71cdSmrg# will be execed at the end. This prevents here-documents from being 273352fd71cdSmrg# left over by shells. 273452fd71cdSmrgexec_cmd= 273552fd71cdSmrg 273652fd71cdSmrg 273752fd71cdSmrg# A function that is used when there is no print builtin or printf. 273852fd71cdSmrgfunc_fallback_echo () 273952fd71cdSmrg{ 274052fd71cdSmrg eval 'cat <<_LTECHO_EOF 274152fd71cdSmrg$1 274252fd71cdSmrg_LTECHO_EOF' 274352fd71cdSmrg} 274452fd71cdSmrg 274552fd71cdSmrg# func_generated_by_libtool 274652fd71cdSmrg# True iff stdin has been generated by Libtool. This function is only 274752fd71cdSmrg# a basic sanity check; it will hardly flush out determined imposters. 274852fd71cdSmrgfunc_generated_by_libtool_p () 274952fd71cdSmrg{ 275052fd71cdSmrg $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 275152fd71cdSmrg} 275252fd71cdSmrg 2753d63fdb69Smrg# func_lalib_p file 275452fd71cdSmrg# True iff FILE is a libtool '.la' library or '.lo' object file. 2755d63fdb69Smrg# This function is only a basic sanity check; it will hardly flush out 2756d63fdb69Smrg# determined imposters. 2757d63fdb69Smrgfunc_lalib_p () 2758d63fdb69Smrg{ 2759d63fdb69Smrg test -f "$1" && 276052fd71cdSmrg $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p 2761d63fdb69Smrg} 27623da084b3Smrg 2763d63fdb69Smrg# func_lalib_unsafe_p file 276452fd71cdSmrg# True iff FILE is a libtool '.la' library or '.lo' object file. 2765d63fdb69Smrg# This function implements the same check as func_lalib_p without 2766d63fdb69Smrg# resorting to external programs. To this end, it redirects stdin and 2767d63fdb69Smrg# closes it afterwards, without saving the original file descriptor. 2768d63fdb69Smrg# As a safety measure, use it only where a negative result would be 276952fd71cdSmrg# fatal anyway. Works if 'file' does not exist. 2770d63fdb69Smrgfunc_lalib_unsafe_p () 2771d63fdb69Smrg{ 2772d63fdb69Smrg lalib_p=no 2773d63fdb69Smrg if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then 2774d63fdb69Smrg for lalib_p_l in 1 2 3 4 2775d63fdb69Smrg do 2776d63fdb69Smrg read lalib_p_line 277752fd71cdSmrg case $lalib_p_line in 2778d63fdb69Smrg \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; 2779d63fdb69Smrg esac 2780d63fdb69Smrg done 2781d63fdb69Smrg exec 0<&5 5<&- 2782d63fdb69Smrg fi 278352fd71cdSmrg test yes = "$lalib_p" 2784d63fdb69Smrg} 27853da084b3Smrg 2786d63fdb69Smrg# func_ltwrapper_script_p file 2787d63fdb69Smrg# True iff FILE is a libtool wrapper script 2788d63fdb69Smrg# This function is only a basic sanity check; it will hardly flush out 2789d63fdb69Smrg# determined imposters. 2790d63fdb69Smrgfunc_ltwrapper_script_p () 2791d63fdb69Smrg{ 279252fd71cdSmrg test -f "$1" && 279352fd71cdSmrg $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p 2794d63fdb69Smrg} 27953da084b3Smrg 2796d63fdb69Smrg# func_ltwrapper_executable_p file 2797d63fdb69Smrg# True iff FILE is a libtool wrapper executable 2798d63fdb69Smrg# This function is only a basic sanity check; it will hardly flush out 2799d63fdb69Smrg# determined imposters. 2800d63fdb69Smrgfunc_ltwrapper_executable_p () 2801d63fdb69Smrg{ 2802d63fdb69Smrg func_ltwrapper_exec_suffix= 2803d63fdb69Smrg case $1 in 2804d63fdb69Smrg *.exe) ;; 2805d63fdb69Smrg *) func_ltwrapper_exec_suffix=.exe ;; 2806d63fdb69Smrg esac 2807d63fdb69Smrg $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 2808d63fdb69Smrg} 28093da084b3Smrg 2810d63fdb69Smrg# func_ltwrapper_scriptname file 2811d63fdb69Smrg# Assumes file is an ltwrapper_executable 2812d63fdb69Smrg# uses $file to determine the appropriate filename for a 2813d63fdb69Smrg# temporary ltwrapper_script. 2814d63fdb69Smrgfunc_ltwrapper_scriptname () 2815d63fdb69Smrg{ 281648c85eb7Smrg func_dirname_and_basename "$1" "" "." 281748c85eb7Smrg func_stripname '' '.exe' "$func_basename_result" 281852fd71cdSmrg func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper 2819d63fdb69Smrg} 28203da084b3Smrg 2821d63fdb69Smrg# func_ltwrapper_p file 2822d63fdb69Smrg# True iff FILE is a libtool wrapper script or wrapper executable 2823d63fdb69Smrg# This function is only a basic sanity check; it will hardly flush out 2824d63fdb69Smrg# determined imposters. 2825d63fdb69Smrgfunc_ltwrapper_p () 2826d63fdb69Smrg{ 2827d63fdb69Smrg func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" 2828d63fdb69Smrg} 28293da084b3Smrg 28303da084b3Smrg 2831d63fdb69Smrg# func_execute_cmds commands fail_cmd 2832d63fdb69Smrg# Execute tilde-delimited COMMANDS. 2833d63fdb69Smrg# If FAIL_CMD is given, eval that upon failure. 2834d63fdb69Smrg# FAIL_CMD may read-access the current command in variable CMD! 2835d63fdb69Smrgfunc_execute_cmds () 2836d63fdb69Smrg{ 283752fd71cdSmrg $debug_cmd 283852fd71cdSmrg 2839d63fdb69Smrg save_ifs=$IFS; IFS='~' 2840d63fdb69Smrg for cmd in $1; do 284152fd71cdSmrg IFS=$sp$nl 2842d63fdb69Smrg eval cmd=\"$cmd\" 284352fd71cdSmrg IFS=$save_ifs 2844d63fdb69Smrg func_show_eval "$cmd" "${2-:}" 2845d63fdb69Smrg done 2846d63fdb69Smrg IFS=$save_ifs 2847d63fdb69Smrg} 2848d63fdb69Smrg 2849d63fdb69Smrg 2850d63fdb69Smrg# func_source file 2851d63fdb69Smrg# Source FILE, adding directory component if necessary. 2852d63fdb69Smrg# Note that it is not necessary on cygwin/mingw to append a dot to 2853d63fdb69Smrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe 2854d63fdb69Smrg# behavior happens only for exec(3), not for open(2)! Also, sourcing 285552fd71cdSmrg# 'FILE.' does not work on cygwin managed mounts. 2856d63fdb69Smrgfunc_source () 2857d63fdb69Smrg{ 285852fd71cdSmrg $debug_cmd 285952fd71cdSmrg 2860d63fdb69Smrg case $1 in 2861d63fdb69Smrg */* | *\\*) . "$1" ;; 2862d63fdb69Smrg *) . "./$1" ;; 2863d63fdb69Smrg esac 2864d63fdb69Smrg} 2865d63fdb69Smrg 2866d63fdb69Smrg 286748c85eb7Smrg# func_resolve_sysroot PATH 286848c85eb7Smrg# Replace a leading = in PATH with a sysroot. Store the result into 286948c85eb7Smrg# func_resolve_sysroot_result 287048c85eb7Smrgfunc_resolve_sysroot () 287148c85eb7Smrg{ 287248c85eb7Smrg func_resolve_sysroot_result=$1 287348c85eb7Smrg case $func_resolve_sysroot_result in 287448c85eb7Smrg =*) 287548c85eb7Smrg func_stripname '=' '' "$func_resolve_sysroot_result" 287648c85eb7Smrg func_resolve_sysroot_result=$lt_sysroot$func_stripname_result 287748c85eb7Smrg ;; 287848c85eb7Smrg esac 287948c85eb7Smrg} 288048c85eb7Smrg 288148c85eb7Smrg# func_replace_sysroot PATH 288248c85eb7Smrg# If PATH begins with the sysroot, replace it with = and 288348c85eb7Smrg# store the result into func_replace_sysroot_result. 288448c85eb7Smrgfunc_replace_sysroot () 288548c85eb7Smrg{ 288652fd71cdSmrg case $lt_sysroot:$1 in 288748c85eb7Smrg ?*:"$lt_sysroot"*) 288848c85eb7Smrg func_stripname "$lt_sysroot" '' "$1" 288952fd71cdSmrg func_replace_sysroot_result='='$func_stripname_result 289048c85eb7Smrg ;; 289148c85eb7Smrg *) 289248c85eb7Smrg # Including no sysroot. 289348c85eb7Smrg func_replace_sysroot_result=$1 289448c85eb7Smrg ;; 289548c85eb7Smrg esac 289648c85eb7Smrg} 289748c85eb7Smrg 2898d63fdb69Smrg# func_infer_tag arg 2899d63fdb69Smrg# Infer tagged configuration to use if any are available and 2900d63fdb69Smrg# if one wasn't chosen via the "--tag" command line option. 2901d63fdb69Smrg# Only attempt this if the compiler in the base compile 2902d63fdb69Smrg# command doesn't match the default compiler. 2903d63fdb69Smrg# arg is usually of the form 'gcc ...' 2904d63fdb69Smrgfunc_infer_tag () 2905d63fdb69Smrg{ 290652fd71cdSmrg $debug_cmd 290752fd71cdSmrg 2908d63fdb69Smrg if test -n "$available_tags" && test -z "$tagname"; then 2909d63fdb69Smrg CC_quoted= 2910d63fdb69Smrg for arg in $CC; do 291148c85eb7Smrg func_append_quoted CC_quoted "$arg" 2912d63fdb69Smrg done 291355acc8fcSmrg CC_expanded=`func_echo_all $CC` 291455acc8fcSmrg CC_quoted_expanded=`func_echo_all $CC_quoted` 2915d63fdb69Smrg case $@ in 2916d63fdb69Smrg # Blanks in the command may have been stripped by the calling shell, 2917d63fdb69Smrg # but not from the CC environment variable when configure was run. 291855acc8fcSmrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 291955acc8fcSmrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; 2920d63fdb69Smrg # Blanks at the start of $base_compile will cause this to fail 2921d63fdb69Smrg # if we don't check for them as well. 2922d63fdb69Smrg *) 2923d63fdb69Smrg for z in $available_tags; do 2924d63fdb69Smrg if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then 2925d63fdb69Smrg # Evaluate the configuration. 292652fd71cdSmrg eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" 2927d63fdb69Smrg CC_quoted= 2928d63fdb69Smrg for arg in $CC; do 2929d63fdb69Smrg # Double-quote args containing other shell metacharacters. 293048c85eb7Smrg func_append_quoted CC_quoted "$arg" 2931d63fdb69Smrg done 293255acc8fcSmrg CC_expanded=`func_echo_all $CC` 293355acc8fcSmrg CC_quoted_expanded=`func_echo_all $CC_quoted` 2934d63fdb69Smrg case "$@ " in 293555acc8fcSmrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 293655acc8fcSmrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) 2937d63fdb69Smrg # The compiler in the base compile command matches 2938d63fdb69Smrg # the one in the tagged configuration. 2939d63fdb69Smrg # Assume this is the tagged configuration we want. 2940d63fdb69Smrg tagname=$z 2941d63fdb69Smrg break 2942d63fdb69Smrg ;; 29433da084b3Smrg esac 2944d63fdb69Smrg fi 2945d63fdb69Smrg done 2946d63fdb69Smrg # If $tagname still isn't set, then no tagged configuration 2947d63fdb69Smrg # was found and let the user know that the "--tag" command 2948d63fdb69Smrg # line option must be used. 2949d63fdb69Smrg if test -z "$tagname"; then 2950d63fdb69Smrg func_echo "unable to infer tagged configuration" 295152fd71cdSmrg func_fatal_error "specify a tag with '--tag'" 2952d63fdb69Smrg# else 2953d63fdb69Smrg# func_verbose "using $tagname tagged configuration" 2954d63fdb69Smrg fi 2955d63fdb69Smrg ;; 2956d63fdb69Smrg esac 2957d63fdb69Smrg fi 2958d63fdb69Smrg} 2959d63fdb69Smrg 2960d63fdb69Smrg 296148c85eb7Smrg 296248c85eb7Smrg# func_write_libtool_object output_name pic_name nonpic_name 296348c85eb7Smrg# Create a libtool object file (analogous to a ".la" file), 296448c85eb7Smrg# but don't create it if we're doing a dry run. 296548c85eb7Smrgfunc_write_libtool_object () 296648c85eb7Smrg{ 296752fd71cdSmrg write_libobj=$1 296852fd71cdSmrg if test yes = "$build_libtool_libs"; then 296952fd71cdSmrg write_lobj=\'$2\' 297048c85eb7Smrg else 297148c85eb7Smrg write_lobj=none 297248c85eb7Smrg fi 297348c85eb7Smrg 297452fd71cdSmrg if test yes = "$build_old_libs"; then 297552fd71cdSmrg write_oldobj=\'$3\' 297648c85eb7Smrg else 297748c85eb7Smrg write_oldobj=none 297848c85eb7Smrg fi 297948c85eb7Smrg 298048c85eb7Smrg $opt_dry_run || { 298148c85eb7Smrg cat >${write_libobj}T <<EOF 298248c85eb7Smrg# $write_libobj - a libtool object file 298352fd71cdSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 298448c85eb7Smrg# 298548c85eb7Smrg# Please DO NOT delete this file! 298648c85eb7Smrg# It is necessary for linking the library. 298748c85eb7Smrg 298848c85eb7Smrg# Name of the PIC object. 298948c85eb7Smrgpic_object=$write_lobj 299048c85eb7Smrg 299148c85eb7Smrg# Name of the non-PIC object 299248c85eb7Smrgnon_pic_object=$write_oldobj 299348c85eb7Smrg 299448c85eb7SmrgEOF 299552fd71cdSmrg $MV "${write_libobj}T" "$write_libobj" 299648c85eb7Smrg } 299748c85eb7Smrg} 299848c85eb7Smrg 299948c85eb7Smrg 300048c85eb7Smrg################################################## 300148c85eb7Smrg# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS # 300248c85eb7Smrg################################################## 300348c85eb7Smrg 300448c85eb7Smrg# func_convert_core_file_wine_to_w32 ARG 300548c85eb7Smrg# Helper function used by file name conversion functions when $build is *nix, 300648c85eb7Smrg# and $host is mingw, cygwin, or some other w32 environment. Relies on a 300748c85eb7Smrg# correctly configured wine environment available, with the winepath program 300848c85eb7Smrg# in $build's $PATH. 300948c85eb7Smrg# 301048c85eb7Smrg# ARG is the $build file name to be converted to w32 format. 301148c85eb7Smrg# Result is available in $func_convert_core_file_wine_to_w32_result, and will 301248c85eb7Smrg# be empty on error (or when ARG is empty) 301348c85eb7Smrgfunc_convert_core_file_wine_to_w32 () 301448c85eb7Smrg{ 301552fd71cdSmrg $debug_cmd 301652fd71cdSmrg 301752fd71cdSmrg func_convert_core_file_wine_to_w32_result=$1 301848c85eb7Smrg if test -n "$1"; then 301948c85eb7Smrg # Unfortunately, winepath does not exit with a non-zero error code, so we 302048c85eb7Smrg # are forced to check the contents of stdout. On the other hand, if the 302148c85eb7Smrg # command is not found, the shell will set an exit code of 127 and print 302248c85eb7Smrg # *an error message* to stdout. So we must check for both error code of 302348c85eb7Smrg # zero AND non-empty stdout, which explains the odd construction: 302448c85eb7Smrg func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null` 302552fd71cdSmrg if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then 302648c85eb7Smrg func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | 302752fd71cdSmrg $SED -e "$sed_naive_backslashify"` 302848c85eb7Smrg else 302948c85eb7Smrg func_convert_core_file_wine_to_w32_result= 303048c85eb7Smrg fi 303148c85eb7Smrg fi 303248c85eb7Smrg} 303348c85eb7Smrg# end: func_convert_core_file_wine_to_w32 303448c85eb7Smrg 303548c85eb7Smrg 303648c85eb7Smrg# func_convert_core_path_wine_to_w32 ARG 303748c85eb7Smrg# Helper function used by path conversion functions when $build is *nix, and 303848c85eb7Smrg# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly 303948c85eb7Smrg# configured wine environment available, with the winepath program in $build's 304048c85eb7Smrg# $PATH. Assumes ARG has no leading or trailing path separator characters. 304148c85eb7Smrg# 304248c85eb7Smrg# ARG is path to be converted from $build format to win32. 304348c85eb7Smrg# Result is available in $func_convert_core_path_wine_to_w32_result. 304448c85eb7Smrg# Unconvertible file (directory) names in ARG are skipped; if no directory names 304548c85eb7Smrg# are convertible, then the result may be empty. 304648c85eb7Smrgfunc_convert_core_path_wine_to_w32 () 304748c85eb7Smrg{ 304852fd71cdSmrg $debug_cmd 304952fd71cdSmrg 305048c85eb7Smrg # unfortunately, winepath doesn't convert paths, only file names 305152fd71cdSmrg func_convert_core_path_wine_to_w32_result= 305248c85eb7Smrg if test -n "$1"; then 305348c85eb7Smrg oldIFS=$IFS 305448c85eb7Smrg IFS=: 305548c85eb7Smrg for func_convert_core_path_wine_to_w32_f in $1; do 305648c85eb7Smrg IFS=$oldIFS 305748c85eb7Smrg func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" 305852fd71cdSmrg if test -n "$func_convert_core_file_wine_to_w32_result"; then 305948c85eb7Smrg if test -z "$func_convert_core_path_wine_to_w32_result"; then 306052fd71cdSmrg func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result 306148c85eb7Smrg else 306248c85eb7Smrg func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" 306348c85eb7Smrg fi 306448c85eb7Smrg fi 306548c85eb7Smrg done 306648c85eb7Smrg IFS=$oldIFS 306748c85eb7Smrg fi 306848c85eb7Smrg} 306948c85eb7Smrg# end: func_convert_core_path_wine_to_w32 307048c85eb7Smrg 307148c85eb7Smrg 307248c85eb7Smrg# func_cygpath ARGS... 307348c85eb7Smrg# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when 307448c85eb7Smrg# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) 307548c85eb7Smrg# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or 307648c85eb7Smrg# (2), returns the Cygwin file name or path in func_cygpath_result (input 307748c85eb7Smrg# file name or path is assumed to be in w32 format, as previously converted 307848c85eb7Smrg# from $build's *nix or MSYS format). In case (3), returns the w32 file name 307948c85eb7Smrg# or path in func_cygpath_result (input file name or path is assumed to be in 308048c85eb7Smrg# Cygwin format). Returns an empty string on error. 308148c85eb7Smrg# 308248c85eb7Smrg# ARGS are passed to cygpath, with the last one being the file name or path to 308348c85eb7Smrg# be converted. 308448c85eb7Smrg# 308548c85eb7Smrg# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH 308648c85eb7Smrg# environment variable; do not put it in $PATH. 308748c85eb7Smrgfunc_cygpath () 308848c85eb7Smrg{ 308952fd71cdSmrg $debug_cmd 309052fd71cdSmrg 309148c85eb7Smrg if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then 309248c85eb7Smrg func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` 309348c85eb7Smrg if test "$?" -ne 0; then 309448c85eb7Smrg # on failure, ensure result is empty 309548c85eb7Smrg func_cygpath_result= 309648c85eb7Smrg fi 309748c85eb7Smrg else 309848c85eb7Smrg func_cygpath_result= 309952fd71cdSmrg func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'" 310048c85eb7Smrg fi 310148c85eb7Smrg} 310248c85eb7Smrg#end: func_cygpath 310348c85eb7Smrg 310448c85eb7Smrg 310548c85eb7Smrg# func_convert_core_msys_to_w32 ARG 310648c85eb7Smrg# Convert file name or path ARG from MSYS format to w32 format. Return 310748c85eb7Smrg# result in func_convert_core_msys_to_w32_result. 310848c85eb7Smrgfunc_convert_core_msys_to_w32 () 310948c85eb7Smrg{ 311052fd71cdSmrg $debug_cmd 311152fd71cdSmrg 311248c85eb7Smrg # awkward: cmd appends spaces to result 311348c85eb7Smrg func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | 311452fd71cdSmrg $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"` 311548c85eb7Smrg} 311648c85eb7Smrg#end: func_convert_core_msys_to_w32 311748c85eb7Smrg 311848c85eb7Smrg 311948c85eb7Smrg# func_convert_file_check ARG1 ARG2 312048c85eb7Smrg# Verify that ARG1 (a file name in $build format) was converted to $host 312148c85eb7Smrg# format in ARG2. Otherwise, emit an error message, but continue (resetting 312248c85eb7Smrg# func_to_host_file_result to ARG1). 312348c85eb7Smrgfunc_convert_file_check () 312448c85eb7Smrg{ 312552fd71cdSmrg $debug_cmd 312652fd71cdSmrg 312752fd71cdSmrg if test -z "$2" && test -n "$1"; then 312848c85eb7Smrg func_error "Could not determine host file name corresponding to" 312952fd71cdSmrg func_error " '$1'" 313048c85eb7Smrg func_error "Continuing, but uninstalled executables may not work." 313148c85eb7Smrg # Fallback: 313252fd71cdSmrg func_to_host_file_result=$1 313348c85eb7Smrg fi 313448c85eb7Smrg} 313548c85eb7Smrg# end func_convert_file_check 313648c85eb7Smrg 313748c85eb7Smrg 313848c85eb7Smrg# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH 313948c85eb7Smrg# Verify that FROM_PATH (a path in $build format) was converted to $host 314048c85eb7Smrg# format in TO_PATH. Otherwise, emit an error message, but continue, resetting 314148c85eb7Smrg# func_to_host_file_result to a simplistic fallback value (see below). 314248c85eb7Smrgfunc_convert_path_check () 314348c85eb7Smrg{ 314452fd71cdSmrg $debug_cmd 314552fd71cdSmrg 314648c85eb7Smrg if test -z "$4" && test -n "$3"; then 314748c85eb7Smrg func_error "Could not determine the host path corresponding to" 314852fd71cdSmrg func_error " '$3'" 314948c85eb7Smrg func_error "Continuing, but uninstalled executables may not work." 315048c85eb7Smrg # Fallback. This is a deliberately simplistic "conversion" and 315148c85eb7Smrg # should not be "improved". See libtool.info. 315248c85eb7Smrg if test "x$1" != "x$2"; then 315348c85eb7Smrg lt_replace_pathsep_chars="s|$1|$2|g" 315448c85eb7Smrg func_to_host_path_result=`echo "$3" | 315548c85eb7Smrg $SED -e "$lt_replace_pathsep_chars"` 315648c85eb7Smrg else 315752fd71cdSmrg func_to_host_path_result=$3 315848c85eb7Smrg fi 315948c85eb7Smrg fi 316048c85eb7Smrg} 316148c85eb7Smrg# end func_convert_path_check 316248c85eb7Smrg 316348c85eb7Smrg 316448c85eb7Smrg# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG 316548c85eb7Smrg# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT 316648c85eb7Smrg# and appending REPL if ORIG matches BACKPAT. 316748c85eb7Smrgfunc_convert_path_front_back_pathsep () 316848c85eb7Smrg{ 316952fd71cdSmrg $debug_cmd 317052fd71cdSmrg 317148c85eb7Smrg case $4 in 317252fd71cdSmrg $1 ) func_to_host_path_result=$3$func_to_host_path_result 317348c85eb7Smrg ;; 317448c85eb7Smrg esac 317548c85eb7Smrg case $4 in 317648c85eb7Smrg $2 ) func_append func_to_host_path_result "$3" 317748c85eb7Smrg ;; 317848c85eb7Smrg esac 317948c85eb7Smrg} 318048c85eb7Smrg# end func_convert_path_front_back_pathsep 318148c85eb7Smrg 318248c85eb7Smrg 318348c85eb7Smrg################################################## 318448c85eb7Smrg# $build to $host FILE NAME CONVERSION FUNCTIONS # 318548c85eb7Smrg################################################## 318652fd71cdSmrg# invoked via '$to_host_file_cmd ARG' 318748c85eb7Smrg# 318848c85eb7Smrg# In each case, ARG is the path to be converted from $build to $host format. 318948c85eb7Smrg# Result will be available in $func_to_host_file_result. 319048c85eb7Smrg 319148c85eb7Smrg 319248c85eb7Smrg# func_to_host_file ARG 319348c85eb7Smrg# Converts the file name ARG from $build format to $host format. Return result 319448c85eb7Smrg# in func_to_host_file_result. 319548c85eb7Smrgfunc_to_host_file () 319648c85eb7Smrg{ 319752fd71cdSmrg $debug_cmd 319852fd71cdSmrg 319948c85eb7Smrg $to_host_file_cmd "$1" 320048c85eb7Smrg} 320148c85eb7Smrg# end func_to_host_file 320248c85eb7Smrg 320348c85eb7Smrg 320448c85eb7Smrg# func_to_tool_file ARG LAZY 320548c85eb7Smrg# converts the file name ARG from $build format to toolchain format. Return 320648c85eb7Smrg# result in func_to_tool_file_result. If the conversion in use is listed 320748c85eb7Smrg# in (the comma separated) LAZY, no conversion takes place. 320848c85eb7Smrgfunc_to_tool_file () 320948c85eb7Smrg{ 321052fd71cdSmrg $debug_cmd 321152fd71cdSmrg 321248c85eb7Smrg case ,$2, in 321348c85eb7Smrg *,"$to_tool_file_cmd",*) 321448c85eb7Smrg func_to_tool_file_result=$1 321548c85eb7Smrg ;; 321648c85eb7Smrg *) 321748c85eb7Smrg $to_tool_file_cmd "$1" 321848c85eb7Smrg func_to_tool_file_result=$func_to_host_file_result 321948c85eb7Smrg ;; 322048c85eb7Smrg esac 322148c85eb7Smrg} 322248c85eb7Smrg# end func_to_tool_file 322348c85eb7Smrg 322448c85eb7Smrg 322548c85eb7Smrg# func_convert_file_noop ARG 322648c85eb7Smrg# Copy ARG to func_to_host_file_result. 322748c85eb7Smrgfunc_convert_file_noop () 322848c85eb7Smrg{ 322952fd71cdSmrg func_to_host_file_result=$1 323048c85eb7Smrg} 323148c85eb7Smrg# end func_convert_file_noop 323248c85eb7Smrg 323348c85eb7Smrg 323448c85eb7Smrg# func_convert_file_msys_to_w32 ARG 323548c85eb7Smrg# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic 323648c85eb7Smrg# conversion to w32 is not available inside the cwrapper. Returns result in 323748c85eb7Smrg# func_to_host_file_result. 323848c85eb7Smrgfunc_convert_file_msys_to_w32 () 323948c85eb7Smrg{ 324052fd71cdSmrg $debug_cmd 324152fd71cdSmrg 324252fd71cdSmrg func_to_host_file_result=$1 324348c85eb7Smrg if test -n "$1"; then 324448c85eb7Smrg func_convert_core_msys_to_w32 "$1" 324552fd71cdSmrg func_to_host_file_result=$func_convert_core_msys_to_w32_result 324648c85eb7Smrg fi 324748c85eb7Smrg func_convert_file_check "$1" "$func_to_host_file_result" 324848c85eb7Smrg} 324948c85eb7Smrg# end func_convert_file_msys_to_w32 325048c85eb7Smrg 325148c85eb7Smrg 325248c85eb7Smrg# func_convert_file_cygwin_to_w32 ARG 325348c85eb7Smrg# Convert file name ARG from Cygwin to w32 format. Returns result in 325448c85eb7Smrg# func_to_host_file_result. 325548c85eb7Smrgfunc_convert_file_cygwin_to_w32 () 325648c85eb7Smrg{ 325752fd71cdSmrg $debug_cmd 325852fd71cdSmrg 325952fd71cdSmrg func_to_host_file_result=$1 326048c85eb7Smrg if test -n "$1"; then 326148c85eb7Smrg # because $build is cygwin, we call "the" cygpath in $PATH; no need to use 326248c85eb7Smrg # LT_CYGPATH in this case. 326348c85eb7Smrg func_to_host_file_result=`cygpath -m "$1"` 326448c85eb7Smrg fi 326548c85eb7Smrg func_convert_file_check "$1" "$func_to_host_file_result" 326648c85eb7Smrg} 326748c85eb7Smrg# end func_convert_file_cygwin_to_w32 326848c85eb7Smrg 326948c85eb7Smrg 327048c85eb7Smrg# func_convert_file_nix_to_w32 ARG 327148c85eb7Smrg# Convert file name ARG from *nix to w32 format. Requires a wine environment 327248c85eb7Smrg# and a working winepath. Returns result in func_to_host_file_result. 327348c85eb7Smrgfunc_convert_file_nix_to_w32 () 327448c85eb7Smrg{ 327552fd71cdSmrg $debug_cmd 327652fd71cdSmrg 327752fd71cdSmrg func_to_host_file_result=$1 327848c85eb7Smrg if test -n "$1"; then 327948c85eb7Smrg func_convert_core_file_wine_to_w32 "$1" 328052fd71cdSmrg func_to_host_file_result=$func_convert_core_file_wine_to_w32_result 328148c85eb7Smrg fi 328248c85eb7Smrg func_convert_file_check "$1" "$func_to_host_file_result" 328348c85eb7Smrg} 328448c85eb7Smrg# end func_convert_file_nix_to_w32 328548c85eb7Smrg 328648c85eb7Smrg 328748c85eb7Smrg# func_convert_file_msys_to_cygwin ARG 328848c85eb7Smrg# Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 328948c85eb7Smrg# Returns result in func_to_host_file_result. 329048c85eb7Smrgfunc_convert_file_msys_to_cygwin () 329148c85eb7Smrg{ 329252fd71cdSmrg $debug_cmd 329352fd71cdSmrg 329452fd71cdSmrg func_to_host_file_result=$1 329548c85eb7Smrg if test -n "$1"; then 329648c85eb7Smrg func_convert_core_msys_to_w32 "$1" 329748c85eb7Smrg func_cygpath -u "$func_convert_core_msys_to_w32_result" 329852fd71cdSmrg func_to_host_file_result=$func_cygpath_result 329948c85eb7Smrg fi 330048c85eb7Smrg func_convert_file_check "$1" "$func_to_host_file_result" 330148c85eb7Smrg} 330248c85eb7Smrg# end func_convert_file_msys_to_cygwin 330348c85eb7Smrg 330448c85eb7Smrg 330548c85eb7Smrg# func_convert_file_nix_to_cygwin ARG 330648c85eb7Smrg# Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed 330748c85eb7Smrg# in a wine environment, working winepath, and LT_CYGPATH set. Returns result 330848c85eb7Smrg# in func_to_host_file_result. 330948c85eb7Smrgfunc_convert_file_nix_to_cygwin () 331048c85eb7Smrg{ 331152fd71cdSmrg $debug_cmd 331252fd71cdSmrg 331352fd71cdSmrg func_to_host_file_result=$1 331448c85eb7Smrg if test -n "$1"; then 331548c85eb7Smrg # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. 331648c85eb7Smrg func_convert_core_file_wine_to_w32 "$1" 331748c85eb7Smrg func_cygpath -u "$func_convert_core_file_wine_to_w32_result" 331852fd71cdSmrg func_to_host_file_result=$func_cygpath_result 331948c85eb7Smrg fi 332048c85eb7Smrg func_convert_file_check "$1" "$func_to_host_file_result" 332148c85eb7Smrg} 332248c85eb7Smrg# end func_convert_file_nix_to_cygwin 332348c85eb7Smrg 332448c85eb7Smrg 332548c85eb7Smrg############################################# 332648c85eb7Smrg# $build to $host PATH CONVERSION FUNCTIONS # 332748c85eb7Smrg############################################# 332852fd71cdSmrg# invoked via '$to_host_path_cmd ARG' 332948c85eb7Smrg# 333048c85eb7Smrg# In each case, ARG is the path to be converted from $build to $host format. 333148c85eb7Smrg# The result will be available in $func_to_host_path_result. 333248c85eb7Smrg# 333348c85eb7Smrg# Path separators are also converted from $build format to $host format. If 333448c85eb7Smrg# ARG begins or ends with a path separator character, it is preserved (but 333548c85eb7Smrg# converted to $host format) on output. 333648c85eb7Smrg# 333748c85eb7Smrg# All path conversion functions are named using the following convention: 333848c85eb7Smrg# file name conversion function : func_convert_file_X_to_Y () 333948c85eb7Smrg# path conversion function : func_convert_path_X_to_Y () 334048c85eb7Smrg# where, for any given $build/$host combination the 'X_to_Y' value is the 334148c85eb7Smrg# same. If conversion functions are added for new $build/$host combinations, 334248c85eb7Smrg# the two new functions must follow this pattern, or func_init_to_host_path_cmd 334348c85eb7Smrg# will break. 334448c85eb7Smrg 334548c85eb7Smrg 334648c85eb7Smrg# func_init_to_host_path_cmd 334748c85eb7Smrg# Ensures that function "pointer" variable $to_host_path_cmd is set to the 334848c85eb7Smrg# appropriate value, based on the value of $to_host_file_cmd. 334948c85eb7Smrgto_host_path_cmd= 335048c85eb7Smrgfunc_init_to_host_path_cmd () 335148c85eb7Smrg{ 335252fd71cdSmrg $debug_cmd 335352fd71cdSmrg 335448c85eb7Smrg if test -z "$to_host_path_cmd"; then 335548c85eb7Smrg func_stripname 'func_convert_file_' '' "$to_host_file_cmd" 335652fd71cdSmrg to_host_path_cmd=func_convert_path_$func_stripname_result 335748c85eb7Smrg fi 335848c85eb7Smrg} 335948c85eb7Smrg 336048c85eb7Smrg 336148c85eb7Smrg# func_to_host_path ARG 336248c85eb7Smrg# Converts the path ARG from $build format to $host format. Return result 336348c85eb7Smrg# in func_to_host_path_result. 336448c85eb7Smrgfunc_to_host_path () 336548c85eb7Smrg{ 336652fd71cdSmrg $debug_cmd 336752fd71cdSmrg 336848c85eb7Smrg func_init_to_host_path_cmd 336948c85eb7Smrg $to_host_path_cmd "$1" 337048c85eb7Smrg} 337148c85eb7Smrg# end func_to_host_path 337248c85eb7Smrg 337348c85eb7Smrg 337448c85eb7Smrg# func_convert_path_noop ARG 337548c85eb7Smrg# Copy ARG to func_to_host_path_result. 337648c85eb7Smrgfunc_convert_path_noop () 337748c85eb7Smrg{ 337852fd71cdSmrg func_to_host_path_result=$1 337948c85eb7Smrg} 338048c85eb7Smrg# end func_convert_path_noop 338148c85eb7Smrg 338248c85eb7Smrg 338348c85eb7Smrg# func_convert_path_msys_to_w32 ARG 338448c85eb7Smrg# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic 338548c85eb7Smrg# conversion to w32 is not available inside the cwrapper. Returns result in 338648c85eb7Smrg# func_to_host_path_result. 338748c85eb7Smrgfunc_convert_path_msys_to_w32 () 338848c85eb7Smrg{ 338952fd71cdSmrg $debug_cmd 339052fd71cdSmrg 339152fd71cdSmrg func_to_host_path_result=$1 339248c85eb7Smrg if test -n "$1"; then 339348c85eb7Smrg # Remove leading and trailing path separator characters from ARG. MSYS 339448c85eb7Smrg # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; 339548c85eb7Smrg # and winepath ignores them completely. 339648c85eb7Smrg func_stripname : : "$1" 339748c85eb7Smrg func_to_host_path_tmp1=$func_stripname_result 339848c85eb7Smrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 339952fd71cdSmrg func_to_host_path_result=$func_convert_core_msys_to_w32_result 340048c85eb7Smrg func_convert_path_check : ";" \ 340148c85eb7Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 340248c85eb7Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 340348c85eb7Smrg fi 340448c85eb7Smrg} 340548c85eb7Smrg# end func_convert_path_msys_to_w32 340648c85eb7Smrg 340748c85eb7Smrg 340848c85eb7Smrg# func_convert_path_cygwin_to_w32 ARG 340948c85eb7Smrg# Convert path ARG from Cygwin to w32 format. Returns result in 341048c85eb7Smrg# func_to_host_file_result. 341148c85eb7Smrgfunc_convert_path_cygwin_to_w32 () 341248c85eb7Smrg{ 341352fd71cdSmrg $debug_cmd 341452fd71cdSmrg 341552fd71cdSmrg func_to_host_path_result=$1 341648c85eb7Smrg if test -n "$1"; then 341748c85eb7Smrg # See func_convert_path_msys_to_w32: 341848c85eb7Smrg func_stripname : : "$1" 341948c85eb7Smrg func_to_host_path_tmp1=$func_stripname_result 342048c85eb7Smrg func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` 342148c85eb7Smrg func_convert_path_check : ";" \ 342248c85eb7Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 342348c85eb7Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 342448c85eb7Smrg fi 342548c85eb7Smrg} 342648c85eb7Smrg# end func_convert_path_cygwin_to_w32 342748c85eb7Smrg 342848c85eb7Smrg 342948c85eb7Smrg# func_convert_path_nix_to_w32 ARG 343048c85eb7Smrg# Convert path ARG from *nix to w32 format. Requires a wine environment and 343148c85eb7Smrg# a working winepath. Returns result in func_to_host_file_result. 343248c85eb7Smrgfunc_convert_path_nix_to_w32 () 3433d63fdb69Smrg{ 343452fd71cdSmrg $debug_cmd 343552fd71cdSmrg 343652fd71cdSmrg func_to_host_path_result=$1 343748c85eb7Smrg if test -n "$1"; then 343848c85eb7Smrg # See func_convert_path_msys_to_w32: 343948c85eb7Smrg func_stripname : : "$1" 344048c85eb7Smrg func_to_host_path_tmp1=$func_stripname_result 344148c85eb7Smrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 344252fd71cdSmrg func_to_host_path_result=$func_convert_core_path_wine_to_w32_result 344348c85eb7Smrg func_convert_path_check : ";" \ 344448c85eb7Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 344548c85eb7Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 344648c85eb7Smrg fi 344748c85eb7Smrg} 344848c85eb7Smrg# end func_convert_path_nix_to_w32 3449d63fdb69Smrg 3450d63fdb69Smrg 345148c85eb7Smrg# func_convert_path_msys_to_cygwin ARG 345248c85eb7Smrg# Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 345348c85eb7Smrg# Returns result in func_to_host_file_result. 345448c85eb7Smrgfunc_convert_path_msys_to_cygwin () 345548c85eb7Smrg{ 345652fd71cdSmrg $debug_cmd 345752fd71cdSmrg 345852fd71cdSmrg func_to_host_path_result=$1 345948c85eb7Smrg if test -n "$1"; then 346048c85eb7Smrg # See func_convert_path_msys_to_w32: 346148c85eb7Smrg func_stripname : : "$1" 346248c85eb7Smrg func_to_host_path_tmp1=$func_stripname_result 346348c85eb7Smrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 346448c85eb7Smrg func_cygpath -u -p "$func_convert_core_msys_to_w32_result" 346552fd71cdSmrg func_to_host_path_result=$func_cygpath_result 346648c85eb7Smrg func_convert_path_check : : \ 346748c85eb7Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 346848c85eb7Smrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 346948c85eb7Smrg fi 347048c85eb7Smrg} 347148c85eb7Smrg# end func_convert_path_msys_to_cygwin 3472d63fdb69Smrg 3473d63fdb69Smrg 347448c85eb7Smrg# func_convert_path_nix_to_cygwin ARG 347548c85eb7Smrg# Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a 347648c85eb7Smrg# a wine environment, working winepath, and LT_CYGPATH set. Returns result in 347748c85eb7Smrg# func_to_host_file_result. 347848c85eb7Smrgfunc_convert_path_nix_to_cygwin () 347948c85eb7Smrg{ 348052fd71cdSmrg $debug_cmd 348152fd71cdSmrg 348252fd71cdSmrg func_to_host_path_result=$1 348348c85eb7Smrg if test -n "$1"; then 348448c85eb7Smrg # Remove leading and trailing path separator characters from 348548c85eb7Smrg # ARG. msys behavior is inconsistent here, cygpath turns them 348648c85eb7Smrg # into '.;' and ';.', and winepath ignores them completely. 348748c85eb7Smrg func_stripname : : "$1" 348848c85eb7Smrg func_to_host_path_tmp1=$func_stripname_result 348948c85eb7Smrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 349048c85eb7Smrg func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" 349152fd71cdSmrg func_to_host_path_result=$func_cygpath_result 349248c85eb7Smrg func_convert_path_check : : \ 349348c85eb7Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 349448c85eb7Smrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 349548c85eb7Smrg fi 3496d63fdb69Smrg} 349748c85eb7Smrg# end func_convert_path_nix_to_cygwin 349848c85eb7Smrg 3499d63fdb69Smrg 350052fd71cdSmrg# func_dll_def_p FILE 350152fd71cdSmrg# True iff FILE is a Windows DLL '.def' file. 350252fd71cdSmrg# Keep in sync with _LT_DLL_DEF_P in libtool.m4 350352fd71cdSmrgfunc_dll_def_p () 350452fd71cdSmrg{ 350552fd71cdSmrg $debug_cmd 350652fd71cdSmrg 350752fd71cdSmrg func_dll_def_p_tmp=`$SED -n \ 350852fd71cdSmrg -e 's/^[ ]*//' \ 350952fd71cdSmrg -e '/^\(;.*\)*$/d' \ 351052fd71cdSmrg -e 's/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p' \ 351152fd71cdSmrg -e q \ 351252fd71cdSmrg "$1"` 351352fd71cdSmrg test DEF = "$func_dll_def_p_tmp" 351452fd71cdSmrg} 351552fd71cdSmrg 351652fd71cdSmrg 3517d63fdb69Smrg# func_mode_compile arg... 3518d63fdb69Smrgfunc_mode_compile () 3519d63fdb69Smrg{ 352052fd71cdSmrg $debug_cmd 352152fd71cdSmrg 3522d63fdb69Smrg # Get the compilation command and the source file. 3523d63fdb69Smrg base_compile= 352452fd71cdSmrg srcfile=$nonopt # always keep a non-empty value in "srcfile" 3525d63fdb69Smrg suppress_opt=yes 3526d63fdb69Smrg suppress_output= 3527d63fdb69Smrg arg_mode=normal 3528d63fdb69Smrg libobj= 3529d63fdb69Smrg later= 3530d63fdb69Smrg pie_flag= 3531d63fdb69Smrg 3532d63fdb69Smrg for arg 3533d63fdb69Smrg do 3534d63fdb69Smrg case $arg_mode in 3535d63fdb69Smrg arg ) 3536d63fdb69Smrg # do not "continue". Instead, add this to base_compile 353752fd71cdSmrg lastarg=$arg 3538d63fdb69Smrg arg_mode=normal 3539d63fdb69Smrg ;; 3540d63fdb69Smrg 3541d63fdb69Smrg target ) 354252fd71cdSmrg libobj=$arg 3543d63fdb69Smrg arg_mode=normal 3544d63fdb69Smrg continue 3545d63fdb69Smrg ;; 3546d63fdb69Smrg 3547d63fdb69Smrg normal ) 3548d63fdb69Smrg # Accept any command-line options. 3549d63fdb69Smrg case $arg in 3550d63fdb69Smrg -o) 3551d63fdb69Smrg test -n "$libobj" && \ 355252fd71cdSmrg func_fatal_error "you cannot specify '-o' more than once" 3553d63fdb69Smrg arg_mode=target 3554d63fdb69Smrg continue 3555d63fdb69Smrg ;; 3556d63fdb69Smrg 3557d63fdb69Smrg -pie | -fpie | -fPIE) 355848c85eb7Smrg func_append pie_flag " $arg" 3559d63fdb69Smrg continue 3560d63fdb69Smrg ;; 3561d63fdb69Smrg 3562d63fdb69Smrg -shared | -static | -prefer-pic | -prefer-non-pic) 356348c85eb7Smrg func_append later " $arg" 3564d63fdb69Smrg continue 3565d63fdb69Smrg ;; 3566d63fdb69Smrg 3567d63fdb69Smrg -no-suppress) 3568d63fdb69Smrg suppress_opt=no 3569d63fdb69Smrg continue 3570d63fdb69Smrg ;; 3571d63fdb69Smrg 3572d63fdb69Smrg -Xcompiler) 3573d63fdb69Smrg arg_mode=arg # the next one goes into the "base_compile" arg list 3574d63fdb69Smrg continue # The current "srcfile" will either be retained or 3575d63fdb69Smrg ;; # replaced later. I would guess that would be a bug. 3576d63fdb69Smrg 3577d63fdb69Smrg -Wc,*) 3578d63fdb69Smrg func_stripname '-Wc,' '' "$arg" 3579d63fdb69Smrg args=$func_stripname_result 3580d63fdb69Smrg lastarg= 358152fd71cdSmrg save_ifs=$IFS; IFS=, 3582d63fdb69Smrg for arg in $args; do 358352fd71cdSmrg IFS=$save_ifs 358448c85eb7Smrg func_append_quoted lastarg "$arg" 35853da084b3Smrg done 358652fd71cdSmrg IFS=$save_ifs 3587d63fdb69Smrg func_stripname ' ' '' "$lastarg" 3588d63fdb69Smrg lastarg=$func_stripname_result 35893da084b3Smrg 35903da084b3Smrg # Add the arguments to base_compile. 359148c85eb7Smrg func_append base_compile " $lastarg" 35923da084b3Smrg continue 35933da084b3Smrg ;; 35943da084b3Smrg 3595d63fdb69Smrg *) 35963da084b3Smrg # Accept the current argument as the source file. 35973da084b3Smrg # The previous "srcfile" becomes the current argument. 35983da084b3Smrg # 359952fd71cdSmrg lastarg=$srcfile 360052fd71cdSmrg srcfile=$arg 36013da084b3Smrg ;; 36023da084b3Smrg esac # case $arg 36033da084b3Smrg ;; 36043da084b3Smrg esac # case $arg_mode 36053da084b3Smrg 36063da084b3Smrg # Aesthetically quote the previous argument. 360748c85eb7Smrg func_append_quoted base_compile "$lastarg" 36083da084b3Smrg done # for arg 36093da084b3Smrg 36103da084b3Smrg case $arg_mode in 36113da084b3Smrg arg) 3612d63fdb69Smrg func_fatal_error "you must specify an argument for -Xcompile" 36133da084b3Smrg ;; 36143da084b3Smrg target) 361552fd71cdSmrg func_fatal_error "you must specify a target with '-o'" 36163da084b3Smrg ;; 36173da084b3Smrg *) 36183da084b3Smrg # Get the name of the library object. 3619d63fdb69Smrg test -z "$libobj" && { 3620d63fdb69Smrg func_basename "$srcfile" 362152fd71cdSmrg libobj=$func_basename_result 3622d63fdb69Smrg } 36233da084b3Smrg ;; 36243da084b3Smrg esac 36253da084b3Smrg 36263da084b3Smrg # Recognize several different file suffixes. 36273da084b3Smrg # If the user specifies -o file.o, it is replaced with file.lo 36283da084b3Smrg case $libobj in 3629d63fdb69Smrg *.[cCFSifmso] | \ 3630d63fdb69Smrg *.ada | *.adb | *.ads | *.asm | \ 3631d63fdb69Smrg *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ 363248c85eb7Smrg *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup) 3633d63fdb69Smrg func_xform "$libobj" 3634d63fdb69Smrg libobj=$func_xform_result 3635d63fdb69Smrg ;; 36363da084b3Smrg esac 36373da084b3Smrg 36383da084b3Smrg case $libobj in 3639d63fdb69Smrg *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; 36403da084b3Smrg *) 364152fd71cdSmrg func_fatal_error "cannot determine name of library object from '$libobj'" 36423da084b3Smrg ;; 36433da084b3Smrg esac 36443da084b3Smrg 36453da084b3Smrg func_infer_tag $base_compile 36463da084b3Smrg 36473da084b3Smrg for arg in $later; do 36483da084b3Smrg case $arg in 3649d63fdb69Smrg -shared) 365052fd71cdSmrg test yes = "$build_libtool_libs" \ 365152fd71cdSmrg || func_fatal_configuration "cannot build a shared library" 3652d63fdb69Smrg build_old_libs=no 3653d63fdb69Smrg continue 3654d63fdb69Smrg ;; 3655d63fdb69Smrg 36563da084b3Smrg -static) 3657d63fdb69Smrg build_libtool_libs=no 36583da084b3Smrg build_old_libs=yes 36593da084b3Smrg continue 36603da084b3Smrg ;; 36613da084b3Smrg 36623da084b3Smrg -prefer-pic) 36633da084b3Smrg pic_mode=yes 36643da084b3Smrg continue 36653da084b3Smrg ;; 36663da084b3Smrg 36673da084b3Smrg -prefer-non-pic) 36683da084b3Smrg pic_mode=no 36693da084b3Smrg continue 36703da084b3Smrg ;; 36713da084b3Smrg esac 36723da084b3Smrg done 36733da084b3Smrg 36742a53b785Smrg func_quote_arg pretty "$libobj" 36752a53b785Smrg test "X$libobj" != "X$func_quote_arg_result" \ 3676d63fdb69Smrg && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ 367752fd71cdSmrg && func_warning "libobj name '$libobj' may not contain shell special characters." 3678d63fdb69Smrg func_dirname_and_basename "$obj" "/" "" 367952fd71cdSmrg objname=$func_basename_result 368052fd71cdSmrg xdir=$func_dirname_result 368152fd71cdSmrg lobj=$xdir$objdir/$objname 36823da084b3Smrg 3683d63fdb69Smrg test -z "$base_compile" && \ 3684d63fdb69Smrg func_fatal_help "you must specify a compilation command" 36853da084b3Smrg 36863da084b3Smrg # Delete any leftover library objects. 368752fd71cdSmrg if test yes = "$build_old_libs"; then 36883da084b3Smrg removelist="$obj $lobj $libobj ${libobj}T" 36893da084b3Smrg else 36903da084b3Smrg removelist="$lobj $libobj ${libobj}T" 36913da084b3Smrg fi 36923da084b3Smrg 36933da084b3Smrg # On Cygwin there's no "real" PIC flag so we must build both object types 36943da084b3Smrg case $host_os in 3695d63fdb69Smrg cygwin* | mingw* | pw32* | os2* | cegcc*) 36963da084b3Smrg pic_mode=default 36973da084b3Smrg ;; 36983da084b3Smrg esac 369952fd71cdSmrg if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then 37003da084b3Smrg # non-PIC code in shared libraries is not supported 37013da084b3Smrg pic_mode=default 37023da084b3Smrg fi 37033da084b3Smrg 37043da084b3Smrg # Calculate the filename of the output object if compiler does 37053da084b3Smrg # not support -o with -c 370652fd71cdSmrg if test no = "$compiler_c_o"; then 370752fd71cdSmrg output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext 370852fd71cdSmrg lockfile=$output_obj.lock 37093da084b3Smrg else 37103da084b3Smrg output_obj= 37113da084b3Smrg need_locks=no 37123da084b3Smrg lockfile= 37133da084b3Smrg fi 37143da084b3Smrg 37153da084b3Smrg # Lock this critical section if it is needed 37163da084b3Smrg # We use this script file to make the link, it avoids creating a new file 371752fd71cdSmrg if test yes = "$need_locks"; then 3718d63fdb69Smrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 3719d63fdb69Smrg func_echo "Waiting for $lockfile to be removed" 37203da084b3Smrg sleep 2 37213da084b3Smrg done 372252fd71cdSmrg elif test warn = "$need_locks"; then 37233da084b3Smrg if test -f "$lockfile"; then 3724d63fdb69Smrg $ECHO "\ 37253da084b3Smrg*** ERROR, $lockfile exists and contains: 37263da084b3Smrg`cat $lockfile 2>/dev/null` 37273da084b3Smrg 37283da084b3SmrgThis indicates that another process is trying to use the same 37293da084b3Smrgtemporary object file, and libtool could not work around it because 373052fd71cdSmrgyour compiler does not support '-c' and '-o' together. If you 37313da084b3Smrgrepeat this compilation, it may succeed, by chance, but you had better 37323da084b3Smrgavoid parallel builds (make -j) in this platform, or get a better 37333da084b3Smrgcompiler." 37343da084b3Smrg 3735d63fdb69Smrg $opt_dry_run || $RM $removelist 37363da084b3Smrg exit $EXIT_FAILURE 37373da084b3Smrg fi 373848c85eb7Smrg func_append removelist " $output_obj" 3739d63fdb69Smrg $ECHO "$srcfile" > "$lockfile" 37403da084b3Smrg fi 37413da084b3Smrg 3742d63fdb69Smrg $opt_dry_run || $RM $removelist 374348c85eb7Smrg func_append removelist " $lockfile" 3744d63fdb69Smrg trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 3745d63fdb69Smrg 374648c85eb7Smrg func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 374748c85eb7Smrg srcfile=$func_to_tool_file_result 37482a53b785Smrg func_quote_arg pretty "$srcfile" 37492a53b785Smrg qsrcfile=$func_quote_arg_result 37503da084b3Smrg 37513da084b3Smrg # Only build a PIC object if we are building libtool libraries. 375252fd71cdSmrg if test yes = "$build_libtool_libs"; then 37533da084b3Smrg # Without this assignment, base_compile gets emptied. 37543da084b3Smrg fbsd_hideous_sh_bug=$base_compile 37553da084b3Smrg 375652fd71cdSmrg if test no != "$pic_mode"; then 37573da084b3Smrg command="$base_compile $qsrcfile $pic_flag" 37583da084b3Smrg else 37593da084b3Smrg # Don't build PIC code 37603da084b3Smrg command="$base_compile $qsrcfile" 37613da084b3Smrg fi 37623da084b3Smrg 3763d63fdb69Smrg func_mkdir_p "$xdir$objdir" 37643da084b3Smrg 37653da084b3Smrg if test -z "$output_obj"; then 37663da084b3Smrg # Place PIC objects in $objdir 376748c85eb7Smrg func_append command " -o $lobj" 37683da084b3Smrg fi 37693da084b3Smrg 3770d63fdb69Smrg func_show_eval_locale "$command" \ 3771d63fdb69Smrg 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' 37723da084b3Smrg 377352fd71cdSmrg if test warn = "$need_locks" && 37743da084b3Smrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 3775d63fdb69Smrg $ECHO "\ 37763da084b3Smrg*** ERROR, $lockfile contains: 37773da084b3Smrg`cat $lockfile 2>/dev/null` 37783da084b3Smrg 37793da084b3Smrgbut it should contain: 37803da084b3Smrg$srcfile 37813da084b3Smrg 37823da084b3SmrgThis indicates that another process is trying to use the same 37833da084b3Smrgtemporary object file, and libtool could not work around it because 378452fd71cdSmrgyour compiler does not support '-c' and '-o' together. If you 37853da084b3Smrgrepeat this compilation, it may succeed, by chance, but you had better 37863da084b3Smrgavoid parallel builds (make -j) in this platform, or get a better 37873da084b3Smrgcompiler." 37883da084b3Smrg 3789d63fdb69Smrg $opt_dry_run || $RM $removelist 37903da084b3Smrg exit $EXIT_FAILURE 37913da084b3Smrg fi 37923da084b3Smrg 37933da084b3Smrg # Just move the object if needed, then go on to compile the next one 37943da084b3Smrg if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then 3795d63fdb69Smrg func_show_eval '$MV "$output_obj" "$lobj"' \ 3796d63fdb69Smrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 37973da084b3Smrg fi 37983da084b3Smrg 37993da084b3Smrg # Allow error messages only from the first compilation. 380052fd71cdSmrg if test yes = "$suppress_opt"; then 3801d63fdb69Smrg suppress_output=' >/dev/null 2>&1' 38023da084b3Smrg fi 38033da084b3Smrg fi 38043da084b3Smrg 38053da084b3Smrg # Only build a position-dependent object if we build old libraries. 380652fd71cdSmrg if test yes = "$build_old_libs"; then 380752fd71cdSmrg if test yes != "$pic_mode"; then 38083da084b3Smrg # Don't build PIC code 3809d63fdb69Smrg command="$base_compile $qsrcfile$pie_flag" 38103da084b3Smrg else 38113da084b3Smrg command="$base_compile $qsrcfile $pic_flag" 38123da084b3Smrg fi 381352fd71cdSmrg if test yes = "$compiler_c_o"; then 381448c85eb7Smrg func_append command " -o $obj" 38153da084b3Smrg fi 38163da084b3Smrg 38173da084b3Smrg # Suppress compiler output if we already did a PIC compilation. 381848c85eb7Smrg func_append command "$suppress_output" 3819d63fdb69Smrg func_show_eval_locale "$command" \ 3820d63fdb69Smrg '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 38213da084b3Smrg 382252fd71cdSmrg if test warn = "$need_locks" && 38233da084b3Smrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 3824d63fdb69Smrg $ECHO "\ 38253da084b3Smrg*** ERROR, $lockfile contains: 38263da084b3Smrg`cat $lockfile 2>/dev/null` 38273da084b3Smrg 38283da084b3Smrgbut it should contain: 38293da084b3Smrg$srcfile 38303da084b3Smrg 38313da084b3SmrgThis indicates that another process is trying to use the same 38323da084b3Smrgtemporary object file, and libtool could not work around it because 383352fd71cdSmrgyour compiler does not support '-c' and '-o' together. If you 38343da084b3Smrgrepeat this compilation, it may succeed, by chance, but you had better 38353da084b3Smrgavoid parallel builds (make -j) in this platform, or get a better 38363da084b3Smrgcompiler." 38373da084b3Smrg 3838d63fdb69Smrg $opt_dry_run || $RM $removelist 38393da084b3Smrg exit $EXIT_FAILURE 38403da084b3Smrg fi 38413da084b3Smrg 38423da084b3Smrg # Just move the object if needed 38433da084b3Smrg if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then 3844d63fdb69Smrg func_show_eval '$MV "$output_obj" "$obj"' \ 3845d63fdb69Smrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 38463da084b3Smrg fi 38473da084b3Smrg fi 38483da084b3Smrg 3849d63fdb69Smrg $opt_dry_run || { 3850d63fdb69Smrg func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" 38513da084b3Smrg 3852d63fdb69Smrg # Unlock the critical section if it was locked 385352fd71cdSmrg if test no != "$need_locks"; then 3854d63fdb69Smrg removelist=$lockfile 3855d63fdb69Smrg $RM "$lockfile" 3856d63fdb69Smrg fi 3857d63fdb69Smrg } 38583da084b3Smrg 38593da084b3Smrg exit $EXIT_SUCCESS 3860d63fdb69Smrg} 38613da084b3Smrg 3862d63fdb69Smrg$opt_help || { 386352fd71cdSmrg test compile = "$opt_mode" && func_mode_compile ${1+"$@"} 3864d63fdb69Smrg} 38653da084b3Smrg 3866d63fdb69Smrgfunc_mode_help () 3867d63fdb69Smrg{ 3868d63fdb69Smrg # We need to display help for each of the modes. 386948c85eb7Smrg case $opt_mode in 3870d63fdb69Smrg "") 3871d63fdb69Smrg # Generic help is extracted from the usage comments 3872d63fdb69Smrg # at the start of this file. 3873d63fdb69Smrg func_help 3874d63fdb69Smrg ;; 38753da084b3Smrg 3876d63fdb69Smrg clean) 3877d63fdb69Smrg $ECHO \ 3878d63fdb69Smrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... 38793da084b3Smrg 3880d63fdb69SmrgRemove files from the build directory. 38813da084b3Smrg 3882d63fdb69SmrgRM is the name of the program to use to delete files associated with each FILE 388352fd71cdSmrg(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 3884d63fdb69Smrgto RM. 38853da084b3Smrg 3886d63fdb69SmrgIf FILE is a libtool library, object or program, all the files associated 3887d63fdb69Smrgwith it are deleted. Otherwise, only FILE itself is deleted using RM." 3888d63fdb69Smrg ;; 38893da084b3Smrg 3890d63fdb69Smrg compile) 3891d63fdb69Smrg $ECHO \ 3892d63fdb69Smrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE 38933da084b3Smrg 3894d63fdb69SmrgCompile a source file into a libtool library object. 38953da084b3Smrg 3896d63fdb69SmrgThis mode accepts the following additional options: 38973da084b3Smrg 3898d63fdb69Smrg -o OUTPUT-FILE set the output file name to OUTPUT-FILE 3899d63fdb69Smrg -no-suppress do not suppress compiler output for multiple passes 390055acc8fcSmrg -prefer-pic try to build PIC objects only 390155acc8fcSmrg -prefer-non-pic try to build non-PIC objects only 390252fd71cdSmrg -shared do not build a '.o' file suitable for static linking 390352fd71cdSmrg -static only build a '.o' file suitable for static linking 39042a53b785Smrg -Wc,FLAG 39052a53b785Smrg -Xcompiler FLAG pass FLAG directly to the compiler 39063da084b3Smrg 390752fd71cdSmrgCOMPILE-COMMAND is a command to be used in creating a 'standard' object file 3908d63fdb69Smrgfrom the given SOURCEFILE. 39093da084b3Smrg 3910d63fdb69SmrgThe output file name is determined by removing the directory component from 391152fd71cdSmrgSOURCEFILE, then substituting the C source code suffix '.c' with the 391252fd71cdSmrglibrary object suffix, '.lo'." 3913d63fdb69Smrg ;; 39143da084b3Smrg 3915d63fdb69Smrg execute) 3916d63fdb69Smrg $ECHO \ 3917d63fdb69Smrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... 39183da084b3Smrg 3919d63fdb69SmrgAutomatically set library path, then run a program. 39203da084b3Smrg 3921d63fdb69SmrgThis mode accepts the following additional options: 39223da084b3Smrg 3923d63fdb69Smrg -dlopen FILE add the directory containing FILE to the library path 39243da084b3Smrg 392552fd71cdSmrgThis mode sets the library path environment variable according to '-dlopen' 3926d63fdb69Smrgflags. 39273da084b3Smrg 3928d63fdb69SmrgIf any of the ARGS are libtool executable wrappers, then they are translated 3929d63fdb69Smrginto their corresponding uninstalled binary, and any of their required library 3930d63fdb69Smrgdirectories are added to the library path. 39313da084b3Smrg 3932d63fdb69SmrgThen, COMMAND is executed, with ARGS as arguments." 3933d63fdb69Smrg ;; 39343da084b3Smrg 3935d63fdb69Smrg finish) 3936d63fdb69Smrg $ECHO \ 3937d63fdb69Smrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]... 39383da084b3Smrg 3939d63fdb69SmrgComplete the installation of libtool libraries. 39403da084b3Smrg 3941d63fdb69SmrgEach LIBDIR is a directory that contains libtool libraries. 39423da084b3Smrg 3943d63fdb69SmrgThe commands that this mode executes may require superuser privileges. Use 394452fd71cdSmrgthe '--dry-run' option if you just want to see what would be executed." 3945d63fdb69Smrg ;; 39463da084b3Smrg 3947d63fdb69Smrg install) 3948d63fdb69Smrg $ECHO \ 3949d63fdb69Smrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... 39503da084b3Smrg 3951d63fdb69SmrgInstall executables or libraries. 39523da084b3Smrg 3953d63fdb69SmrgINSTALL-COMMAND is the installation command. The first component should be 395452fd71cdSmrgeither the 'install' or 'cp' program. 39553da084b3Smrg 3956d63fdb69SmrgThe following components of INSTALL-COMMAND are treated specially: 39573da084b3Smrg 395855acc8fcSmrg -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation 39593da084b3Smrg 3960d63fdb69SmrgThe rest of the components are interpreted as arguments to that command (only 3961d63fdb69SmrgBSD-compatible install options are recognized)." 3962d63fdb69Smrg ;; 39633da084b3Smrg 3964d63fdb69Smrg link) 3965d63fdb69Smrg $ECHO \ 3966d63fdb69Smrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND... 39673da084b3Smrg 3968d63fdb69SmrgLink object files or libraries together to form another library, or to 3969d63fdb69Smrgcreate an executable program. 39703da084b3Smrg 3971d63fdb69SmrgLINK-COMMAND is a command using the C compiler that you would use to create 3972d63fdb69Smrga program from several object files. 39733da084b3Smrg 3974d63fdb69SmrgThe following components of LINK-COMMAND are treated specially: 39753da084b3Smrg 3976d63fdb69Smrg -all-static do not do any dynamic linking at all 3977d63fdb69Smrg -avoid-version do not add a version suffix if possible 397855acc8fcSmrg -bindir BINDIR specify path to binaries directory (for systems where 397955acc8fcSmrg libraries must be found in the PATH setting at runtime) 398052fd71cdSmrg -dlopen FILE '-dlpreopen' FILE if it cannot be dlopened at runtime 3981d63fdb69Smrg -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols 3982d63fdb69Smrg -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) 3983d63fdb69Smrg -export-symbols SYMFILE 3984d63fdb69Smrg try to export only the symbols listed in SYMFILE 3985d63fdb69Smrg -export-symbols-regex REGEX 3986d63fdb69Smrg try to export only the symbols matching REGEX 3987d63fdb69Smrg -LLIBDIR search LIBDIR for required installed libraries 3988d63fdb69Smrg -lNAME OUTPUT-FILE requires the installed library libNAME 3989d63fdb69Smrg -module build a library that can dlopened 3990d63fdb69Smrg -no-fast-install disable the fast-install mode 3991d63fdb69Smrg -no-install link a not-installable executable 3992d63fdb69Smrg -no-undefined declare that a library does not refer to external symbols 3993d63fdb69Smrg -o OUTPUT-FILE create OUTPUT-FILE from the specified objects 399452fd71cdSmrg -objectlist FILE use a list of object files found in FILE to specify objects 399552fd71cdSmrg -os2dllname NAME force a short DLL name on OS/2 (no effect on other OSes) 3996d63fdb69Smrg -precious-files-regex REGEX 3997d63fdb69Smrg don't remove output files matching REGEX 3998d63fdb69Smrg -release RELEASE specify package release information 3999d63fdb69Smrg -rpath LIBDIR the created library will eventually be installed in LIBDIR 4000d63fdb69Smrg -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries 4001d63fdb69Smrg -shared only do dynamic linking of libtool libraries 4002d63fdb69Smrg -shrext SUFFIX override the standard shared library file extension 4003d63fdb69Smrg -static do not do any dynamic linking of uninstalled libtool libraries 4004d63fdb69Smrg -static-libtool-libs 4005d63fdb69Smrg do not do any dynamic linking of libtool libraries 4006d63fdb69Smrg -version-info CURRENT[:REVISION[:AGE]] 4007d63fdb69Smrg specify library version info [each variable defaults to 0] 4008d63fdb69Smrg -weak LIBNAME declare that the target provides the LIBNAME interface 400955acc8fcSmrg -Wc,FLAG 401055acc8fcSmrg -Xcompiler FLAG pass linker-specific FLAG directly to the compiler 40112a53b785Smrg -Wa,FLAG 40122a53b785Smrg -Xassembler FLAG pass linker-specific FLAG directly to the assembler 401355acc8fcSmrg -Wl,FLAG 401455acc8fcSmrg -Xlinker FLAG pass linker-specific FLAG directly to the linker 401555acc8fcSmrg -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) 40163da084b3Smrg 401752fd71cdSmrgAll other options (arguments beginning with '-') are ignored. 40183da084b3Smrg 401952fd71cdSmrgEvery other argument is treated as a filename. Files ending in '.la' are 4020d63fdb69Smrgtreated as uninstalled libtool libraries, other files are standard or library 4021d63fdb69Smrgobject files. 40223da084b3Smrg 402352fd71cdSmrgIf the OUTPUT-FILE ends in '.la', then a libtool library is created, 402452fd71cdSmrgonly library objects ('.lo' files) may be specified, and '-rpath' is 4025d63fdb69Smrgrequired, except when creating a convenience library. 40263da084b3Smrg 402752fd71cdSmrgIf OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created 402852fd71cdSmrgusing 'ar' and 'ranlib', or on Windows using 'lib'. 40293da084b3Smrg 403052fd71cdSmrgIf OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file 4031d63fdb69Smrgis created, otherwise an executable program is created." 40323da084b3Smrg ;; 40333da084b3Smrg 4034d63fdb69Smrg uninstall) 4035d63fdb69Smrg $ECHO \ 4036d63fdb69Smrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... 40373da084b3Smrg 4038d63fdb69SmrgRemove libraries from an installation directory. 40393da084b3Smrg 4040d63fdb69SmrgRM is the name of the program to use to delete files associated with each FILE 404152fd71cdSmrg(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 4042d63fdb69Smrgto RM. 40433da084b3Smrg 4044d63fdb69SmrgIf FILE is a libtool library, all the files associated with it are deleted. 4045d63fdb69SmrgOtherwise, only FILE itself is deleted using RM." 4046d63fdb69Smrg ;; 40473da084b3Smrg 4048d63fdb69Smrg *) 404952fd71cdSmrg func_fatal_help "invalid operation mode '$opt_mode'" 4050d63fdb69Smrg ;; 4051d63fdb69Smrg esac 40523da084b3Smrg 405355acc8fcSmrg echo 405452fd71cdSmrg $ECHO "Try '$progname --help' for more information about other modes." 4055d63fdb69Smrg} 40563da084b3Smrg 405755acc8fcSmrg# Now that we've collected a possible --mode arg, show help if necessary 405855acc8fcSmrgif $opt_help; then 405952fd71cdSmrg if test : = "$opt_help"; then 406055acc8fcSmrg func_mode_help 406155acc8fcSmrg else 406255acc8fcSmrg { 406355acc8fcSmrg func_help noexit 406448c85eb7Smrg for opt_mode in compile link execute install finish uninstall clean; do 406555acc8fcSmrg func_mode_help 406655acc8fcSmrg done 406752fd71cdSmrg } | $SED -n '1p; 2,$s/^Usage:/ or: /p' 406855acc8fcSmrg { 406955acc8fcSmrg func_help noexit 407048c85eb7Smrg for opt_mode in compile link execute install finish uninstall clean; do 407155acc8fcSmrg echo 407255acc8fcSmrg func_mode_help 407355acc8fcSmrg done 407455acc8fcSmrg } | 407552fd71cdSmrg $SED '1d 407655acc8fcSmrg /^When reporting/,/^Report/{ 407755acc8fcSmrg H 407855acc8fcSmrg d 407955acc8fcSmrg } 408055acc8fcSmrg $x 408155acc8fcSmrg /information about other modes/d 408255acc8fcSmrg /more detailed .*MODE/d 408355acc8fcSmrg s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' 408455acc8fcSmrg fi 408555acc8fcSmrg exit $? 408655acc8fcSmrgfi 40873da084b3Smrg 40883da084b3Smrg 4089d63fdb69Smrg# func_mode_execute arg... 4090d63fdb69Smrgfunc_mode_execute () 4091d63fdb69Smrg{ 409252fd71cdSmrg $debug_cmd 409352fd71cdSmrg 4094d63fdb69Smrg # The first argument is the command name. 409552fd71cdSmrg cmd=$nonopt 4096d63fdb69Smrg test -z "$cmd" && \ 4097d63fdb69Smrg func_fatal_help "you must specify a COMMAND" 40983da084b3Smrg 4099d63fdb69Smrg # Handle -dlopen flags immediately. 410048c85eb7Smrg for file in $opt_dlopen; do 4101d63fdb69Smrg test -f "$file" \ 410252fd71cdSmrg || func_fatal_help "'$file' is not a file" 41033da084b3Smrg 4104d63fdb69Smrg dir= 4105d63fdb69Smrg case $file in 4106d63fdb69Smrg *.la) 410748c85eb7Smrg func_resolve_sysroot "$file" 410848c85eb7Smrg file=$func_resolve_sysroot_result 410948c85eb7Smrg 4110d63fdb69Smrg # Check to see that this really is a libtool archive. 4111d63fdb69Smrg func_lalib_unsafe_p "$file" \ 411252fd71cdSmrg || func_fatal_help "'$lib' is not a valid libtool archive" 41133da084b3Smrg 4114d63fdb69Smrg # Read the libtool library. 4115d63fdb69Smrg dlname= 4116d63fdb69Smrg library_names= 4117d63fdb69Smrg func_source "$file" 41183da084b3Smrg 4119d63fdb69Smrg # Skip this library if it cannot be dlopened. 4120d63fdb69Smrg if test -z "$dlname"; then 4121d63fdb69Smrg # Warn if it was a shared library. 4122d63fdb69Smrg test -n "$library_names" && \ 412352fd71cdSmrg func_warning "'$file' was not linked with '-export-dynamic'" 4124d63fdb69Smrg continue 4125d63fdb69Smrg fi 41263da084b3Smrg 4127d63fdb69Smrg func_dirname "$file" "" "." 412852fd71cdSmrg dir=$func_dirname_result 41293da084b3Smrg 4130d63fdb69Smrg if test -f "$dir/$objdir/$dlname"; then 413148c85eb7Smrg func_append dir "/$objdir" 4132d63fdb69Smrg else 4133d63fdb69Smrg if test ! -f "$dir/$dlname"; then 413452fd71cdSmrg func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'" 4135d63fdb69Smrg fi 4136d63fdb69Smrg fi 41373da084b3Smrg ;; 41383da084b3Smrg 4139d63fdb69Smrg *.lo) 4140d63fdb69Smrg # Just add the directory containing the .lo file. 4141d63fdb69Smrg func_dirname "$file" "" "." 414252fd71cdSmrg dir=$func_dirname_result 41433da084b3Smrg ;; 41443da084b3Smrg 4145d63fdb69Smrg *) 414652fd71cdSmrg func_warning "'-dlopen' is ignored for non-libtool libraries and objects" 41473da084b3Smrg continue 41483da084b3Smrg ;; 4149d63fdb69Smrg esac 41503da084b3Smrg 4151d63fdb69Smrg # Get the absolute pathname. 4152d63fdb69Smrg absdir=`cd "$dir" && pwd` 415352fd71cdSmrg test -n "$absdir" && dir=$absdir 41543da084b3Smrg 4155d63fdb69Smrg # Now add the directory to shlibpath_var. 4156d63fdb69Smrg if eval "test -z \"\$$shlibpath_var\""; then 4157d63fdb69Smrg eval "$shlibpath_var=\"\$dir\"" 4158d63fdb69Smrg else 4159d63fdb69Smrg eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" 4160d63fdb69Smrg fi 4161d63fdb69Smrg done 41623da084b3Smrg 4163d63fdb69Smrg # This variable tells wrapper scripts just to set shlibpath_var 4164d63fdb69Smrg # rather than running their programs. 416552fd71cdSmrg libtool_execute_magic=$magic 41663da084b3Smrg 4167d63fdb69Smrg # Check if any of the arguments is a wrapper script. 4168d63fdb69Smrg args= 4169d63fdb69Smrg for file 4170d63fdb69Smrg do 4171d63fdb69Smrg case $file in 417255acc8fcSmrg -* | *.la | *.lo ) ;; 4173d63fdb69Smrg *) 4174d63fdb69Smrg # Do a test to see if this is really a libtool program. 4175d63fdb69Smrg if func_ltwrapper_script_p "$file"; then 4176d63fdb69Smrg func_source "$file" 4177d63fdb69Smrg # Transform arg to wrapped name. 417852fd71cdSmrg file=$progdir/$program 4179d63fdb69Smrg elif func_ltwrapper_executable_p "$file"; then 4180d63fdb69Smrg func_ltwrapper_scriptname "$file" 4181d63fdb69Smrg func_source "$func_ltwrapper_scriptname_result" 4182d63fdb69Smrg # Transform arg to wrapped name. 418352fd71cdSmrg file=$progdir/$program 4184d63fdb69Smrg fi 4185d63fdb69Smrg ;; 4186d63fdb69Smrg esac 4187d63fdb69Smrg # Quote arguments (to preserve shell metacharacters). 418848c85eb7Smrg func_append_quoted args "$file" 4189d63fdb69Smrg done 41903da084b3Smrg 419152fd71cdSmrg if $opt_dry_run; then 419252fd71cdSmrg # Display what would be done. 419352fd71cdSmrg if test -n "$shlibpath_var"; then 419452fd71cdSmrg eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" 419552fd71cdSmrg echo "export $shlibpath_var" 419652fd71cdSmrg fi 419752fd71cdSmrg $ECHO "$cmd$args" 419852fd71cdSmrg exit $EXIT_SUCCESS 419952fd71cdSmrg else 4200d63fdb69Smrg if test -n "$shlibpath_var"; then 4201d63fdb69Smrg # Export the shlibpath_var. 4202d63fdb69Smrg eval "export $shlibpath_var" 4203d63fdb69Smrg fi 42043da084b3Smrg 4205d63fdb69Smrg # Restore saved environment variables 4206d63fdb69Smrg for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 4207d63fdb69Smrg do 4208d63fdb69Smrg eval "if test \"\${save_$lt_var+set}\" = set; then 4209d63fdb69Smrg $lt_var=\$save_$lt_var; export $lt_var 4210d63fdb69Smrg else 4211d63fdb69Smrg $lt_unset $lt_var 4212d63fdb69Smrg fi" 4213d63fdb69Smrg done 42143da084b3Smrg 4215d63fdb69Smrg # Now prepare to actually exec the command. 421652fd71cdSmrg exec_cmd=\$cmd$args 4217d63fdb69Smrg fi 4218d63fdb69Smrg} 42193da084b3Smrg 422052fd71cdSmrgtest execute = "$opt_mode" && func_mode_execute ${1+"$@"} 42213da084b3Smrg 42223da084b3Smrg 4223d63fdb69Smrg# func_mode_finish arg... 4224d63fdb69Smrgfunc_mode_finish () 4225d63fdb69Smrg{ 422652fd71cdSmrg $debug_cmd 422752fd71cdSmrg 422848c85eb7Smrg libs= 422948c85eb7Smrg libdirs= 4230d63fdb69Smrg admincmds= 42313da084b3Smrg 423248c85eb7Smrg for opt in "$nonopt" ${1+"$@"} 423348c85eb7Smrg do 423448c85eb7Smrg if test -d "$opt"; then 423548c85eb7Smrg func_append libdirs " $opt" 423648c85eb7Smrg 423748c85eb7Smrg elif test -f "$opt"; then 423848c85eb7Smrg if func_lalib_unsafe_p "$opt"; then 423948c85eb7Smrg func_append libs " $opt" 424048c85eb7Smrg else 424152fd71cdSmrg func_warning "'$opt' is not a valid libtool archive" 424248c85eb7Smrg fi 424348c85eb7Smrg 424448c85eb7Smrg else 424552fd71cdSmrg func_fatal_error "invalid argument '$opt'" 424648c85eb7Smrg fi 424748c85eb7Smrg done 424848c85eb7Smrg 424948c85eb7Smrg if test -n "$libs"; then 425048c85eb7Smrg if test -n "$lt_sysroot"; then 425148c85eb7Smrg sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` 425248c85eb7Smrg sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" 425348c85eb7Smrg else 425448c85eb7Smrg sysroot_cmd= 425548c85eb7Smrg fi 425648c85eb7Smrg 425748c85eb7Smrg # Remove sysroot references 425848c85eb7Smrg if $opt_dry_run; then 425948c85eb7Smrg for lib in $libs; do 426052fd71cdSmrg echo "removing references to $lt_sysroot and '=' prefixes from $lib" 426148c85eb7Smrg done 426248c85eb7Smrg else 426348c85eb7Smrg tmpdir=`func_mktempdir` 426448c85eb7Smrg for lib in $libs; do 426552fd71cdSmrg $SED -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ 426648c85eb7Smrg > $tmpdir/tmp-la 426748c85eb7Smrg mv -f $tmpdir/tmp-la $lib 426848c85eb7Smrg done 426948c85eb7Smrg ${RM}r "$tmpdir" 427048c85eb7Smrg fi 427148c85eb7Smrg fi 42723da084b3Smrg 427348c85eb7Smrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 4274d63fdb69Smrg for libdir in $libdirs; do 4275d63fdb69Smrg if test -n "$finish_cmds"; then 4276d63fdb69Smrg # Do each command in the finish commands. 4277d63fdb69Smrg func_execute_cmds "$finish_cmds" 'admincmds="$admincmds 4278d63fdb69Smrg'"$cmd"'"' 4279d63fdb69Smrg fi 4280d63fdb69Smrg if test -n "$finish_eval"; then 4281d63fdb69Smrg # Do the single finish_eval. 4282d63fdb69Smrg eval cmds=\"$finish_eval\" 428348c85eb7Smrg $opt_dry_run || eval "$cmds" || func_append admincmds " 4284d63fdb69Smrg $cmds" 4285d63fdb69Smrg fi 4286d63fdb69Smrg done 4287d63fdb69Smrg fi 42883da084b3Smrg 4289d63fdb69Smrg # Exit here if they wanted silent mode. 429052fd71cdSmrg $opt_quiet && exit $EXIT_SUCCESS 42913da084b3Smrg 429248c85eb7Smrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 429348c85eb7Smrg echo "----------------------------------------------------------------------" 429448c85eb7Smrg echo "Libraries have been installed in:" 429548c85eb7Smrg for libdir in $libdirs; do 429648c85eb7Smrg $ECHO " $libdir" 429748c85eb7Smrg done 429848c85eb7Smrg echo 429948c85eb7Smrg echo "If you ever happen to want to link against installed libraries" 430048c85eb7Smrg echo "in a given directory, LIBDIR, you must either use libtool, and" 430152fd71cdSmrg echo "specify the full pathname of the library, or use the '-LLIBDIR'" 430248c85eb7Smrg echo "flag during linking and do at least one of the following:" 430348c85eb7Smrg if test -n "$shlibpath_var"; then 430452fd71cdSmrg echo " - add LIBDIR to the '$shlibpath_var' environment variable" 430548c85eb7Smrg echo " during execution" 430648c85eb7Smrg fi 430748c85eb7Smrg if test -n "$runpath_var"; then 430852fd71cdSmrg echo " - add LIBDIR to the '$runpath_var' environment variable" 430948c85eb7Smrg echo " during linking" 431048c85eb7Smrg fi 431148c85eb7Smrg if test -n "$hardcode_libdir_flag_spec"; then 431248c85eb7Smrg libdir=LIBDIR 431348c85eb7Smrg eval flag=\"$hardcode_libdir_flag_spec\" 43143da084b3Smrg 431552fd71cdSmrg $ECHO " - use the '$flag' linker flag" 431648c85eb7Smrg fi 431748c85eb7Smrg if test -n "$admincmds"; then 431848c85eb7Smrg $ECHO " - have your system administrator run these commands:$admincmds" 431948c85eb7Smrg fi 432048c85eb7Smrg if test -f /etc/ld.so.conf; then 432152fd71cdSmrg echo " - have your system administrator add LIBDIR to '/etc/ld.so.conf'" 432248c85eb7Smrg fi 432348c85eb7Smrg echo 43243da084b3Smrg 432548c85eb7Smrg echo "See any operating system documentation about shared libraries for" 432648c85eb7Smrg case $host in 432748c85eb7Smrg solaris2.[6789]|solaris2.1[0-9]) 432848c85eb7Smrg echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" 432948c85eb7Smrg echo "pages." 433048c85eb7Smrg ;; 433148c85eb7Smrg *) 433248c85eb7Smrg echo "more information, such as the ld(1) and ld.so(8) manual pages." 433348c85eb7Smrg ;; 433448c85eb7Smrg esac 433548c85eb7Smrg echo "----------------------------------------------------------------------" 433648c85eb7Smrg fi 4337d63fdb69Smrg exit $EXIT_SUCCESS 4338d63fdb69Smrg} 43393da084b3Smrg 434052fd71cdSmrgtest finish = "$opt_mode" && func_mode_finish ${1+"$@"} 43413da084b3Smrg 43423da084b3Smrg 4343d63fdb69Smrg# func_mode_install arg... 4344d63fdb69Smrgfunc_mode_install () 4345d63fdb69Smrg{ 434652fd71cdSmrg $debug_cmd 434752fd71cdSmrg 4348d63fdb69Smrg # There may be an optional sh(1) argument at the beginning of 4349d63fdb69Smrg # install_prog (especially on Windows NT). 435052fd71cdSmrg if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" || 4351d63fdb69Smrg # Allow the use of GNU shtool's install command. 435252fd71cdSmrg case $nonopt in *shtool*) :;; *) false;; esac 435352fd71cdSmrg then 4354d63fdb69Smrg # Aesthetically quote it. 43552a53b785Smrg func_quote_arg pretty "$nonopt" 43562a53b785Smrg install_prog="$func_quote_arg_result " 4357d63fdb69Smrg arg=$1 4358d63fdb69Smrg shift 4359d63fdb69Smrg else 4360d63fdb69Smrg install_prog= 4361d63fdb69Smrg arg=$nonopt 4362d63fdb69Smrg fi 43633da084b3Smrg 4364d63fdb69Smrg # The real first argument should be the name of the installation program. 4365d63fdb69Smrg # Aesthetically quote it. 43662a53b785Smrg func_quote_arg pretty "$arg" 43672a53b785Smrg func_append install_prog "$func_quote_arg_result" 436855acc8fcSmrg install_shared_prog=$install_prog 436955acc8fcSmrg case " $install_prog " in 437055acc8fcSmrg *[\\\ /]cp\ *) install_cp=: ;; 437155acc8fcSmrg *) install_cp=false ;; 437255acc8fcSmrg esac 4373d63fdb69Smrg 4374d63fdb69Smrg # We need to accept at least all the BSD install flags. 4375d63fdb69Smrg dest= 4376d63fdb69Smrg files= 4377d63fdb69Smrg opts= 4378d63fdb69Smrg prev= 4379d63fdb69Smrg install_type= 438052fd71cdSmrg isdir=false 4381d63fdb69Smrg stripme= 438255acc8fcSmrg no_mode=: 4383d63fdb69Smrg for arg 4384d63fdb69Smrg do 438555acc8fcSmrg arg2= 4386d63fdb69Smrg if test -n "$dest"; then 438748c85eb7Smrg func_append files " $dest" 4388d63fdb69Smrg dest=$arg 4389d63fdb69Smrg continue 43903da084b3Smrg fi 43913da084b3Smrg 4392d63fdb69Smrg case $arg in 439352fd71cdSmrg -d) isdir=: ;; 4394d63fdb69Smrg -f) 439555acc8fcSmrg if $install_cp; then :; else 439655acc8fcSmrg prev=$arg 439755acc8fcSmrg fi 4398d63fdb69Smrg ;; 4399d63fdb69Smrg -g | -m | -o) 4400d63fdb69Smrg prev=$arg 4401d63fdb69Smrg ;; 4402d63fdb69Smrg -s) 4403d63fdb69Smrg stripme=" -s" 4404d63fdb69Smrg continue 4405d63fdb69Smrg ;; 4406d63fdb69Smrg -*) 4407d63fdb69Smrg ;; 4408d63fdb69Smrg *) 4409d63fdb69Smrg # If the previous option needed an argument, then skip it. 4410d63fdb69Smrg if test -n "$prev"; then 441152fd71cdSmrg if test X-m = "X$prev" && test -n "$install_override_mode"; then 441255acc8fcSmrg arg2=$install_override_mode 441355acc8fcSmrg no_mode=false 441455acc8fcSmrg fi 4415d63fdb69Smrg prev= 4416d63fdb69Smrg else 4417d63fdb69Smrg dest=$arg 4418d63fdb69Smrg continue 4419d63fdb69Smrg fi 4420d63fdb69Smrg ;; 4421d63fdb69Smrg esac 44223da084b3Smrg 4423d63fdb69Smrg # Aesthetically quote the argument. 44242a53b785Smrg func_quote_arg pretty "$arg" 44252a53b785Smrg func_append install_prog " $func_quote_arg_result" 442655acc8fcSmrg if test -n "$arg2"; then 44272a53b785Smrg func_quote_arg pretty "$arg2" 442855acc8fcSmrg fi 44292a53b785Smrg func_append install_shared_prog " $func_quote_arg_result" 4430d63fdb69Smrg done 44313da084b3Smrg 4432d63fdb69Smrg test -z "$install_prog" && \ 4433d63fdb69Smrg func_fatal_help "you must specify an install program" 44343da084b3Smrg 4435d63fdb69Smrg test -n "$prev" && \ 443652fd71cdSmrg func_fatal_help "the '$prev' option requires an argument" 44373da084b3Smrg 443855acc8fcSmrg if test -n "$install_override_mode" && $no_mode; then 443955acc8fcSmrg if $install_cp; then :; else 44402a53b785Smrg func_quote_arg pretty "$install_override_mode" 44412a53b785Smrg func_append install_shared_prog " -m $func_quote_arg_result" 444255acc8fcSmrg fi 444355acc8fcSmrg fi 444455acc8fcSmrg 4445d63fdb69Smrg if test -z "$files"; then 4446d63fdb69Smrg if test -z "$dest"; then 4447d63fdb69Smrg func_fatal_help "no file or destination specified" 4448d63fdb69Smrg else 4449d63fdb69Smrg func_fatal_help "you must specify a destination" 44503da084b3Smrg fi 44513da084b3Smrg fi 44523da084b3Smrg 4453d63fdb69Smrg # Strip any trailing slash from the destination. 4454d63fdb69Smrg func_stripname '' '/' "$dest" 4455d63fdb69Smrg dest=$func_stripname_result 44563da084b3Smrg 4457d63fdb69Smrg # Check to see that the destination is a directory. 445852fd71cdSmrg test -d "$dest" && isdir=: 445952fd71cdSmrg if $isdir; then 446052fd71cdSmrg destdir=$dest 4461d63fdb69Smrg destname= 4462d63fdb69Smrg else 4463d63fdb69Smrg func_dirname_and_basename "$dest" "" "." 446452fd71cdSmrg destdir=$func_dirname_result 446552fd71cdSmrg destname=$func_basename_result 4466d63fdb69Smrg 4467d63fdb69Smrg # Not a directory, so check to see that there is only one file specified. 4468d63fdb69Smrg set dummy $files; shift 4469d63fdb69Smrg test "$#" -gt 1 && \ 447052fd71cdSmrg func_fatal_help "'$dest' is not a directory" 4471d63fdb69Smrg fi 4472d63fdb69Smrg case $destdir in 4473d63fdb69Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 44743da084b3Smrg *) 4475d63fdb69Smrg for file in $files; do 4476d63fdb69Smrg case $file in 4477d63fdb69Smrg *.lo) ;; 4478d63fdb69Smrg *) 447952fd71cdSmrg func_fatal_help "'$destdir' must be an absolute directory name" 4480d63fdb69Smrg ;; 4481d63fdb69Smrg esac 4482d63fdb69Smrg done 44833da084b3Smrg ;; 44843da084b3Smrg esac 44853da084b3Smrg 4486d63fdb69Smrg # This variable tells wrapper scripts just to set variables rather 4487d63fdb69Smrg # than running their programs. 448852fd71cdSmrg libtool_install_magic=$magic 44893da084b3Smrg 4490d63fdb69Smrg staticlibs= 4491d63fdb69Smrg future_libdirs= 4492d63fdb69Smrg current_libdirs= 4493d63fdb69Smrg for file in $files; do 44943da084b3Smrg 4495d63fdb69Smrg # Do each installation. 4496d63fdb69Smrg case $file in 4497d63fdb69Smrg *.$libext) 4498d63fdb69Smrg # Do the static libraries later. 449948c85eb7Smrg func_append staticlibs " $file" 4500d63fdb69Smrg ;; 4501d63fdb69Smrg 4502d63fdb69Smrg *.la) 450348c85eb7Smrg func_resolve_sysroot "$file" 450448c85eb7Smrg file=$func_resolve_sysroot_result 450548c85eb7Smrg 4506d63fdb69Smrg # Check to see that this really is a libtool archive. 4507d63fdb69Smrg func_lalib_unsafe_p "$file" \ 450852fd71cdSmrg || func_fatal_help "'$file' is not a valid libtool archive" 4509d63fdb69Smrg 4510d63fdb69Smrg library_names= 4511d63fdb69Smrg old_library= 4512d63fdb69Smrg relink_command= 4513d63fdb69Smrg func_source "$file" 4514d63fdb69Smrg 4515d63fdb69Smrg # Add the libdir to current_libdirs if it is the destination. 4516d63fdb69Smrg if test "X$destdir" = "X$libdir"; then 4517d63fdb69Smrg case "$current_libdirs " in 4518d63fdb69Smrg *" $libdir "*) ;; 451948c85eb7Smrg *) func_append current_libdirs " $libdir" ;; 45203da084b3Smrg esac 4521d63fdb69Smrg else 4522d63fdb69Smrg # Note the libdir as a future libdir. 4523d63fdb69Smrg case "$future_libdirs " in 4524d63fdb69Smrg *" $libdir "*) ;; 452548c85eb7Smrg *) func_append future_libdirs " $libdir" ;; 4526d63fdb69Smrg esac 4527d63fdb69Smrg fi 45283da084b3Smrg 4529d63fdb69Smrg func_dirname "$file" "/" "" 453052fd71cdSmrg dir=$func_dirname_result 453148c85eb7Smrg func_append dir "$objdir" 4532d63fdb69Smrg 4533d63fdb69Smrg if test -n "$relink_command"; then 4534d63fdb69Smrg # Determine the prefix the user has applied to our future dir. 453555acc8fcSmrg inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` 4536d63fdb69Smrg 4537d63fdb69Smrg # Don't allow the user to place us outside of our expected 4538d63fdb69Smrg # location b/c this prevents finding dependent libraries that 4539d63fdb69Smrg # are installed to the same prefix. 4540d63fdb69Smrg # At present, this check doesn't affect windows .dll's that 4541d63fdb69Smrg # are installed into $libdir/../bin (currently, that works fine) 4542d63fdb69Smrg # but it's something to keep an eye on. 4543d63fdb69Smrg test "$inst_prefix_dir" = "$destdir" && \ 454452fd71cdSmrg func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir" 4545d63fdb69Smrg 4546d63fdb69Smrg if test -n "$inst_prefix_dir"; then 4547d63fdb69Smrg # Stick the inst_prefix_dir data into the link command. 454855acc8fcSmrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` 4549d63fdb69Smrg else 455055acc8fcSmrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` 4551d63fdb69Smrg fi 4552d63fdb69Smrg 455352fd71cdSmrg func_warning "relinking '$file'" 4554d63fdb69Smrg func_show_eval "$relink_command" \ 455552fd71cdSmrg 'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"' 4556d63fdb69Smrg fi 4557d63fdb69Smrg 4558d63fdb69Smrg # See the names of the shared library. 4559d63fdb69Smrg set dummy $library_names; shift 4560d63fdb69Smrg if test -n "$1"; then 456152fd71cdSmrg realname=$1 4562d63fdb69Smrg shift 4563d63fdb69Smrg 456452fd71cdSmrg srcname=$realname 456552fd71cdSmrg test -n "$relink_command" && srcname=${realname}T 4566d63fdb69Smrg 4567d63fdb69Smrg # Install the shared library and build the symlinks. 456855acc8fcSmrg func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ 4569d63fdb69Smrg 'exit $?' 457052fd71cdSmrg tstripme=$stripme 4571d63fdb69Smrg case $host_os in 4572d63fdb69Smrg cygwin* | mingw* | pw32* | cegcc*) 4573d63fdb69Smrg case $realname in 4574d63fdb69Smrg *.dll.a) 457552fd71cdSmrg tstripme= 457652fd71cdSmrg ;; 457752fd71cdSmrg esac 457852fd71cdSmrg ;; 457952fd71cdSmrg os2*) 458052fd71cdSmrg case $realname in 458152fd71cdSmrg *_dll.a) 458252fd71cdSmrg tstripme= 4583d63fdb69Smrg ;; 4584d63fdb69Smrg esac 45853da084b3Smrg ;; 45863da084b3Smrg esac 4587d63fdb69Smrg if test -n "$tstripme" && test -n "$striplib"; then 4588d63fdb69Smrg func_show_eval "$striplib $destdir/$realname" 'exit $?' 45893da084b3Smrg fi 4590d63fdb69Smrg 4591d63fdb69Smrg if test "$#" -gt 0; then 4592d63fdb69Smrg # Delete the old symlinks, and create new ones. 459352fd71cdSmrg # Try 'ln -sf' first, because the 'ln' binary might depend on 4594d63fdb69Smrg # the symlink we replace! Solaris /bin/ln does not understand -f, 4595d63fdb69Smrg # so we also need to try rm && ln -s. 4596d63fdb69Smrg for linkname 4597d63fdb69Smrg do 4598d63fdb69Smrg test "$linkname" != "$realname" \ 4599d63fdb69Smrg && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" 46003da084b3Smrg done 46013da084b3Smrg fi 46023da084b3Smrg 4603d63fdb69Smrg # Do each command in the postinstall commands. 460452fd71cdSmrg lib=$destdir/$realname 4605d63fdb69Smrg func_execute_cmds "$postinstall_cmds" 'exit $?' 46063da084b3Smrg fi 46073da084b3Smrg 4608d63fdb69Smrg # Install the pseudo-library for information purposes. 4609d63fdb69Smrg func_basename "$file" 461052fd71cdSmrg name=$func_basename_result 461152fd71cdSmrg instname=$dir/${name}i 4612d63fdb69Smrg func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' 46133da084b3Smrg 4614d63fdb69Smrg # Maybe install the static library, too. 461548c85eb7Smrg test -n "$old_library" && func_append staticlibs " $dir/$old_library" 4616d63fdb69Smrg ;; 46173da084b3Smrg 4618d63fdb69Smrg *.lo) 4619d63fdb69Smrg # Install (i.e. copy) a libtool object. 46203da084b3Smrg 4621d63fdb69Smrg # Figure out destination file name, if it wasn't already specified. 4622d63fdb69Smrg if test -n "$destname"; then 462352fd71cdSmrg destfile=$destdir/$destname 4624d63fdb69Smrg else 4625d63fdb69Smrg func_basename "$file" 462652fd71cdSmrg destfile=$func_basename_result 462752fd71cdSmrg destfile=$destdir/$destfile 4628d63fdb69Smrg fi 4629d63fdb69Smrg 4630d63fdb69Smrg # Deduce the name of the destination old-style object file. 4631d63fdb69Smrg case $destfile in 4632d63fdb69Smrg *.lo) 4633d63fdb69Smrg func_lo2o "$destfile" 4634d63fdb69Smrg staticdest=$func_lo2o_result 4635d63fdb69Smrg ;; 4636d63fdb69Smrg *.$objext) 463752fd71cdSmrg staticdest=$destfile 4638d63fdb69Smrg destfile= 4639d63fdb69Smrg ;; 4640d63fdb69Smrg *) 464152fd71cdSmrg func_fatal_help "cannot copy a libtool object to '$destfile'" 4642d63fdb69Smrg ;; 46433da084b3Smrg esac 46443da084b3Smrg 4645d63fdb69Smrg # Install the libtool object if requested. 4646d63fdb69Smrg test -n "$destfile" && \ 4647d63fdb69Smrg func_show_eval "$install_prog $file $destfile" 'exit $?' 4648d63fdb69Smrg 4649d63fdb69Smrg # Install the old object if enabled. 465052fd71cdSmrg if test yes = "$build_old_libs"; then 4651d63fdb69Smrg # Deduce the name of the old-style object file. 4652d63fdb69Smrg func_lo2o "$file" 4653d63fdb69Smrg staticobj=$func_lo2o_result 4654d63fdb69Smrg func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' 46553da084b3Smrg fi 4656d63fdb69Smrg exit $EXIT_SUCCESS 4657d63fdb69Smrg ;; 46583da084b3Smrg 4659d63fdb69Smrg *) 4660d63fdb69Smrg # Figure out destination file name, if it wasn't already specified. 4661d63fdb69Smrg if test -n "$destname"; then 466252fd71cdSmrg destfile=$destdir/$destname 4663d63fdb69Smrg else 4664d63fdb69Smrg func_basename "$file" 466552fd71cdSmrg destfile=$func_basename_result 466652fd71cdSmrg destfile=$destdir/$destfile 4667d63fdb69Smrg fi 4668d63fdb69Smrg 4669d63fdb69Smrg # If the file is missing, and there is a .exe on the end, strip it 4670d63fdb69Smrg # because it is most likely a libtool script we actually want to 4671d63fdb69Smrg # install 467252fd71cdSmrg stripped_ext= 4673d63fdb69Smrg case $file in 4674d63fdb69Smrg *.exe) 4675d63fdb69Smrg if test ! -f "$file"; then 4676d63fdb69Smrg func_stripname '' '.exe' "$file" 4677d63fdb69Smrg file=$func_stripname_result 467852fd71cdSmrg stripped_ext=.exe 46793da084b3Smrg fi 4680d63fdb69Smrg ;; 4681d63fdb69Smrg esac 46823da084b3Smrg 4683d63fdb69Smrg # Do a test to see if this is really a libtool program. 4684d63fdb69Smrg case $host in 4685d63fdb69Smrg *cygwin* | *mingw*) 4686d63fdb69Smrg if func_ltwrapper_executable_p "$file"; then 4687d63fdb69Smrg func_ltwrapper_scriptname "$file" 4688d63fdb69Smrg wrapper=$func_ltwrapper_scriptname_result 4689d63fdb69Smrg else 4690d63fdb69Smrg func_stripname '' '.exe' "$file" 4691d63fdb69Smrg wrapper=$func_stripname_result 4692d63fdb69Smrg fi 4693d63fdb69Smrg ;; 4694d63fdb69Smrg *) 4695d63fdb69Smrg wrapper=$file 4696d63fdb69Smrg ;; 4697d63fdb69Smrg esac 4698d63fdb69Smrg if func_ltwrapper_script_p "$wrapper"; then 4699d63fdb69Smrg notinst_deplibs= 4700d63fdb69Smrg relink_command= 47013da084b3Smrg 4702d63fdb69Smrg func_source "$wrapper" 47033da084b3Smrg 4704d63fdb69Smrg # Check the variables that should have been set. 4705d63fdb69Smrg test -z "$generated_by_libtool_version" && \ 470652fd71cdSmrg func_fatal_error "invalid libtool wrapper script '$wrapper'" 4707d63fdb69Smrg 470852fd71cdSmrg finalize=: 4709d63fdb69Smrg for lib in $notinst_deplibs; do 4710d63fdb69Smrg # Check to see that each library is installed. 4711d63fdb69Smrg libdir= 4712d63fdb69Smrg if test -f "$lib"; then 4713d63fdb69Smrg func_source "$lib" 4714d63fdb69Smrg fi 471552fd71cdSmrg libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'` 4716d63fdb69Smrg if test -n "$libdir" && test ! -f "$libfile"; then 471752fd71cdSmrg func_warning "'$lib' has not been installed in '$libdir'" 471852fd71cdSmrg finalize=false 4719d63fdb69Smrg fi 4720d63fdb69Smrg done 4721d63fdb69Smrg 4722d63fdb69Smrg relink_command= 4723d63fdb69Smrg func_source "$wrapper" 4724d63fdb69Smrg 4725d63fdb69Smrg outputname= 472652fd71cdSmrg if test no = "$fast_install" && test -n "$relink_command"; then 4727d63fdb69Smrg $opt_dry_run || { 472852fd71cdSmrg if $finalize; then 4729d63fdb69Smrg tmpdir=`func_mktempdir` 4730d63fdb69Smrg func_basename "$file$stripped_ext" 473152fd71cdSmrg file=$func_basename_result 473252fd71cdSmrg outputname=$tmpdir/$file 4733d63fdb69Smrg # Replace the output file specification. 473455acc8fcSmrg relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` 4735d63fdb69Smrg 473652fd71cdSmrg $opt_quiet || { 47372a53b785Smrg func_quote_arg expand,pretty "$relink_command" 47382a53b785Smrg eval "func_echo $func_quote_arg_result" 4739d63fdb69Smrg } 4740d63fdb69Smrg if eval "$relink_command"; then : 4741d63fdb69Smrg else 474252fd71cdSmrg func_error "error: relink '$file' with the above command before installing it" 4743d63fdb69Smrg $opt_dry_run || ${RM}r "$tmpdir" 4744d63fdb69Smrg continue 4745d63fdb69Smrg fi 474652fd71cdSmrg file=$outputname 4747d63fdb69Smrg else 474852fd71cdSmrg func_warning "cannot relink '$file'" 4749d63fdb69Smrg fi 4750d63fdb69Smrg } 47513da084b3Smrg else 4752d63fdb69Smrg # Install the binary that we compiled earlier. 475355acc8fcSmrg file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` 47543da084b3Smrg fi 4755d63fdb69Smrg fi 47563da084b3Smrg 4757d63fdb69Smrg # remove .exe since cygwin /usr/bin/install will append another 4758d63fdb69Smrg # one anyway 4759d63fdb69Smrg case $install_prog,$host in 4760d63fdb69Smrg */usr/bin/install*,*cygwin*) 4761d63fdb69Smrg case $file:$destfile in 4762d63fdb69Smrg *.exe:*.exe) 4763d63fdb69Smrg # this is ok 4764d63fdb69Smrg ;; 4765d63fdb69Smrg *.exe:*) 4766d63fdb69Smrg destfile=$destfile.exe 4767d63fdb69Smrg ;; 4768d63fdb69Smrg *:*.exe) 4769d63fdb69Smrg func_stripname '' '.exe' "$destfile" 4770d63fdb69Smrg destfile=$func_stripname_result 4771d63fdb69Smrg ;; 4772d63fdb69Smrg esac 47733da084b3Smrg ;; 47743da084b3Smrg esac 4775d63fdb69Smrg func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' 4776d63fdb69Smrg $opt_dry_run || if test -n "$outputname"; then 4777d63fdb69Smrg ${RM}r "$tmpdir" 4778d63fdb69Smrg fi 4779d63fdb69Smrg ;; 4780d63fdb69Smrg esac 4781d63fdb69Smrg done 47823da084b3Smrg 4783d63fdb69Smrg for file in $staticlibs; do 4784d63fdb69Smrg func_basename "$file" 478552fd71cdSmrg name=$func_basename_result 47863da084b3Smrg 4787d63fdb69Smrg # Set up the ranlib parameters. 478852fd71cdSmrg oldlib=$destdir/$name 478948c85eb7Smrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 479048c85eb7Smrg tool_oldlib=$func_to_tool_file_result 47913da084b3Smrg 4792d63fdb69Smrg func_show_eval "$install_prog \$file \$oldlib" 'exit $?' 47933da084b3Smrg 4794d63fdb69Smrg if test -n "$stripme" && test -n "$old_striplib"; then 479548c85eb7Smrg func_show_eval "$old_striplib $tool_oldlib" 'exit $?' 4796d63fdb69Smrg fi 47973da084b3Smrg 4798d63fdb69Smrg # Do each command in the postinstall commands. 4799d63fdb69Smrg func_execute_cmds "$old_postinstall_cmds" 'exit $?' 4800d63fdb69Smrg done 48013da084b3Smrg 4802d63fdb69Smrg test -n "$future_libdirs" && \ 480352fd71cdSmrg func_warning "remember to run '$progname --finish$future_libdirs'" 48043da084b3Smrg 4805d63fdb69Smrg if test -n "$current_libdirs"; then 4806d63fdb69Smrg # Maybe just do a dry run. 4807d63fdb69Smrg $opt_dry_run && current_libdirs=" -n$current_libdirs" 480852fd71cdSmrg exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs' 4809d63fdb69Smrg else 4810d63fdb69Smrg exit $EXIT_SUCCESS 4811d63fdb69Smrg fi 4812d63fdb69Smrg} 48133da084b3Smrg 481452fd71cdSmrgtest install = "$opt_mode" && func_mode_install ${1+"$@"} 48153da084b3Smrg 48163da084b3Smrg 4817d63fdb69Smrg# func_generate_dlsyms outputname originator pic_p 4818d63fdb69Smrg# Extract symbols from dlprefiles and create ${outputname}S.o with 4819d63fdb69Smrg# a dlpreopen symbol table. 4820d63fdb69Smrgfunc_generate_dlsyms () 4821d63fdb69Smrg{ 482252fd71cdSmrg $debug_cmd 482352fd71cdSmrg 482452fd71cdSmrg my_outputname=$1 482552fd71cdSmrg my_originator=$2 482652fd71cdSmrg my_pic_p=${3-false} 482752fd71cdSmrg my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'` 4828d63fdb69Smrg my_dlsyms= 4829d63fdb69Smrg 483052fd71cdSmrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 4831d63fdb69Smrg if test -n "$NM" && test -n "$global_symbol_pipe"; then 483252fd71cdSmrg my_dlsyms=${my_outputname}S.c 4833d63fdb69Smrg else 4834d63fdb69Smrg func_error "not configured to extract global symbols from dlpreopened files" 4835d63fdb69Smrg fi 4836d63fdb69Smrg fi 48373da084b3Smrg 4838d63fdb69Smrg if test -n "$my_dlsyms"; then 4839d63fdb69Smrg case $my_dlsyms in 4840d63fdb69Smrg "") ;; 4841d63fdb69Smrg *.c) 4842d63fdb69Smrg # Discover the nlist of each of the dlfiles. 484352fd71cdSmrg nlist=$output_objdir/$my_outputname.nm 4844d63fdb69Smrg 4845d63fdb69Smrg func_show_eval "$RM $nlist ${nlist}S ${nlist}T" 4846d63fdb69Smrg 4847d63fdb69Smrg # Parse the name list into a source file. 4848d63fdb69Smrg func_verbose "creating $output_objdir/$my_dlsyms" 4849d63fdb69Smrg 4850d63fdb69Smrg $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ 485152fd71cdSmrg/* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */ 485252fd71cdSmrg/* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */ 4853d63fdb69Smrg 4854d63fdb69Smrg#ifdef __cplusplus 4855d63fdb69Smrgextern \"C\" { 4856d63fdb69Smrg#endif 4857d63fdb69Smrg 485852fd71cdSmrg#if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) 485955acc8fcSmrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\" 486055acc8fcSmrg#endif 486155acc8fcSmrg 486248c85eb7Smrg/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ 486352fd71cdSmrg#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE 486452fd71cdSmrg/* DATA imports from DLLs on WIN32 can't be const, because runtime 486548c85eb7Smrg relocations are performed -- see ld's documentation on pseudo-relocs. */ 486648c85eb7Smrg# define LT_DLSYM_CONST 486752fd71cdSmrg#elif defined __osf__ 486848c85eb7Smrg/* This system does not cope well with relocations in const data. */ 486948c85eb7Smrg# define LT_DLSYM_CONST 487048c85eb7Smrg#else 487148c85eb7Smrg# define LT_DLSYM_CONST const 487248c85eb7Smrg#endif 487348c85eb7Smrg 487452fd71cdSmrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 487552fd71cdSmrg 4876d63fdb69Smrg/* External symbol declarations for the compiler. */\ 4877d63fdb69Smrg" 4878d63fdb69Smrg 487952fd71cdSmrg if test yes = "$dlself"; then 488052fd71cdSmrg func_verbose "generating symbol list for '$output'" 4881d63fdb69Smrg 4882d63fdb69Smrg $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" 4883d63fdb69Smrg 4884d63fdb69Smrg # Add our own program objects to the symbol list. 488555acc8fcSmrg progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` 4886d63fdb69Smrg for progfile in $progfiles; do 488748c85eb7Smrg func_to_tool_file "$progfile" func_convert_file_msys_to_w32 488852fd71cdSmrg func_verbose "extracting global C symbols from '$func_to_tool_file_result'" 488948c85eb7Smrg $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" 4890d63fdb69Smrg done 4891d63fdb69Smrg 4892d63fdb69Smrg if test -n "$exclude_expsyms"; then 4893d63fdb69Smrg $opt_dry_run || { 4894d63fdb69Smrg eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' 4895d63fdb69Smrg eval '$MV "$nlist"T "$nlist"' 4896d63fdb69Smrg } 48973da084b3Smrg fi 48983da084b3Smrg 4899d63fdb69Smrg if test -n "$export_symbols_regex"; then 4900d63fdb69Smrg $opt_dry_run || { 4901d63fdb69Smrg eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' 4902d63fdb69Smrg eval '$MV "$nlist"T "$nlist"' 4903d63fdb69Smrg } 49043da084b3Smrg fi 4905d63fdb69Smrg 4906d63fdb69Smrg # Prepare the list of exported symbols 4907d63fdb69Smrg if test -z "$export_symbols"; then 490852fd71cdSmrg export_symbols=$output_objdir/$outputname.exp 4909d63fdb69Smrg $opt_dry_run || { 4910d63fdb69Smrg $RM $export_symbols 491152fd71cdSmrg eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' 4912d63fdb69Smrg case $host in 4913d63fdb69Smrg *cygwin* | *mingw* | *cegcc* ) 4914d63fdb69Smrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 4915d63fdb69Smrg eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' 4916d63fdb69Smrg ;; 49173da084b3Smrg esac 4918d63fdb69Smrg } 4919d63fdb69Smrg else 4920d63fdb69Smrg $opt_dry_run || { 492152fd71cdSmrg eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' 4922d63fdb69Smrg eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' 4923d63fdb69Smrg eval '$MV "$nlist"T "$nlist"' 4924d63fdb69Smrg case $host in 492555acc8fcSmrg *cygwin* | *mingw* | *cegcc* ) 4926d63fdb69Smrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 4927d63fdb69Smrg eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' 4928d63fdb69Smrg ;; 49293da084b3Smrg esac 4930d63fdb69Smrg } 49313da084b3Smrg fi 4932d63fdb69Smrg fi 49333da084b3Smrg 4934d63fdb69Smrg for dlprefile in $dlprefiles; do 493552fd71cdSmrg func_verbose "extracting global C symbols from '$dlprefile'" 4936d63fdb69Smrg func_basename "$dlprefile" 493752fd71cdSmrg name=$func_basename_result 493848c85eb7Smrg case $host in 493948c85eb7Smrg *cygwin* | *mingw* | *cegcc* ) 494048c85eb7Smrg # if an import library, we need to obtain dlname 494148c85eb7Smrg if func_win32_import_lib_p "$dlprefile"; then 494248c85eb7Smrg func_tr_sh "$dlprefile" 494348c85eb7Smrg eval "curr_lafile=\$libfile_$func_tr_sh_result" 494452fd71cdSmrg dlprefile_dlbasename= 494548c85eb7Smrg if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then 494648c85eb7Smrg # Use subshell, to avoid clobbering current variable values 494748c85eb7Smrg dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` 494852fd71cdSmrg if test -n "$dlprefile_dlname"; then 494948c85eb7Smrg func_basename "$dlprefile_dlname" 495052fd71cdSmrg dlprefile_dlbasename=$func_basename_result 495148c85eb7Smrg else 495248c85eb7Smrg # no lafile. user explicitly requested -dlpreopen <import library>. 495348c85eb7Smrg $sharedlib_from_linklib_cmd "$dlprefile" 495448c85eb7Smrg dlprefile_dlbasename=$sharedlib_from_linklib_result 495548c85eb7Smrg fi 495648c85eb7Smrg fi 495748c85eb7Smrg $opt_dry_run || { 495852fd71cdSmrg if test -n "$dlprefile_dlbasename"; then 495948c85eb7Smrg eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' 496048c85eb7Smrg else 496148c85eb7Smrg func_warning "Could not compute DLL name from $name" 496248c85eb7Smrg eval '$ECHO ": $name " >> "$nlist"' 496348c85eb7Smrg fi 496448c85eb7Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 496548c85eb7Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | 496648c85eb7Smrg $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" 496748c85eb7Smrg } 496848c85eb7Smrg else # not an import lib 496948c85eb7Smrg $opt_dry_run || { 497048c85eb7Smrg eval '$ECHO ": $name " >> "$nlist"' 497148c85eb7Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 497248c85eb7Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 497348c85eb7Smrg } 497448c85eb7Smrg fi 497548c85eb7Smrg ;; 497648c85eb7Smrg *) 497748c85eb7Smrg $opt_dry_run || { 497848c85eb7Smrg eval '$ECHO ": $name " >> "$nlist"' 497948c85eb7Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 498048c85eb7Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 498148c85eb7Smrg } 498248c85eb7Smrg ;; 498348c85eb7Smrg esac 4984d63fdb69Smrg done 49853da084b3Smrg 4986d63fdb69Smrg $opt_dry_run || { 4987d63fdb69Smrg # Make sure we have at least an empty file. 4988d63fdb69Smrg test -f "$nlist" || : > "$nlist" 49893da084b3Smrg 4990d63fdb69Smrg if test -n "$exclude_expsyms"; then 4991d63fdb69Smrg $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T 4992d63fdb69Smrg $MV "$nlist"T "$nlist" 49933da084b3Smrg fi 49943da084b3Smrg 4995d63fdb69Smrg # Try sorting and uniquifying the output. 4996d63fdb69Smrg if $GREP -v "^: " < "$nlist" | 4997d63fdb69Smrg if sort -k 3 </dev/null >/dev/null 2>&1; then 4998d63fdb69Smrg sort -k 3 49993da084b3Smrg else 5000d63fdb69Smrg sort +2 5001d63fdb69Smrg fi | 5002d63fdb69Smrg uniq > "$nlist"S; then 5003d63fdb69Smrg : 50043da084b3Smrg else 5005d63fdb69Smrg $GREP -v "^: " < "$nlist" > "$nlist"S 50063da084b3Smrg fi 50073da084b3Smrg 5008d63fdb69Smrg if test -f "$nlist"S; then 5009d63fdb69Smrg eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' 50103da084b3Smrg else 501155acc8fcSmrg echo '/* NONE */' >> "$output_objdir/$my_dlsyms" 50123da084b3Smrg fi 50133da084b3Smrg 501452fd71cdSmrg func_show_eval '$RM "${nlist}I"' 501552fd71cdSmrg if test -n "$global_symbol_to_import"; then 501652fd71cdSmrg eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I' 501752fd71cdSmrg fi 501852fd71cdSmrg 501955acc8fcSmrg echo >> "$output_objdir/$my_dlsyms" "\ 50203da084b3Smrg 5021d63fdb69Smrg/* The mapping between symbol names and symbols. */ 5022d63fdb69Smrgtypedef struct { 5023d63fdb69Smrg const char *name; 5024d63fdb69Smrg void *address; 5025d63fdb69Smrg} lt_dlsymlist; 502648c85eb7Smrgextern LT_DLSYM_CONST lt_dlsymlist 502752fd71cdSmrglt_${my_prefix}_LTX_preloaded_symbols[];\ 502852fd71cdSmrg" 502952fd71cdSmrg 503052fd71cdSmrg if test -s "$nlist"I; then 503152fd71cdSmrg echo >> "$output_objdir/$my_dlsyms" "\ 503252fd71cdSmrgstatic void lt_syminit(void) 503352fd71cdSmrg{ 503452fd71cdSmrg LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols; 503552fd71cdSmrg for (; symbol->name; ++symbol) 503652fd71cdSmrg {" 503752fd71cdSmrg $SED 's/.*/ if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms" 503852fd71cdSmrg echo >> "$output_objdir/$my_dlsyms" "\ 503952fd71cdSmrg } 504052fd71cdSmrg}" 504152fd71cdSmrg fi 504252fd71cdSmrg echo >> "$output_objdir/$my_dlsyms" "\ 504348c85eb7SmrgLT_DLSYM_CONST lt_dlsymlist 5044d63fdb69Smrglt_${my_prefix}_LTX_preloaded_symbols[] = 504552fd71cdSmrg{ {\"$my_originator\", (void *) 0}," 504652fd71cdSmrg 504752fd71cdSmrg if test -s "$nlist"I; then 504852fd71cdSmrg echo >> "$output_objdir/$my_dlsyms" "\ 504952fd71cdSmrg {\"@INIT@\", (void *) <_syminit}," 505052fd71cdSmrg fi 5051d63fdb69Smrg 5052d63fdb69Smrg case $need_lib_prefix in 5053d63fdb69Smrg no) 5054d63fdb69Smrg eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" 5055d63fdb69Smrg ;; 5056d63fdb69Smrg *) 5057d63fdb69Smrg eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" 5058d63fdb69Smrg ;; 5059d63fdb69Smrg esac 506055acc8fcSmrg echo >> "$output_objdir/$my_dlsyms" "\ 5061d63fdb69Smrg {0, (void *) 0} 5062d63fdb69Smrg}; 5063d63fdb69Smrg 5064d63fdb69Smrg/* This works around a problem in FreeBSD linker */ 5065d63fdb69Smrg#ifdef FREEBSD_WORKAROUND 5066d63fdb69Smrgstatic const void *lt_preloaded_setup() { 5067d63fdb69Smrg return lt_${my_prefix}_LTX_preloaded_symbols; 5068d63fdb69Smrg} 5069d63fdb69Smrg#endif 5070d63fdb69Smrg 5071d63fdb69Smrg#ifdef __cplusplus 5072d63fdb69Smrg} 5073d63fdb69Smrg#endif\ 5074d63fdb69Smrg" 5075d63fdb69Smrg } # !$opt_dry_run 5076d63fdb69Smrg 5077d63fdb69Smrg pic_flag_for_symtable= 5078d63fdb69Smrg case "$compile_command " in 5079d63fdb69Smrg *" -static "*) ;; 5080d63fdb69Smrg *) 5081d63fdb69Smrg case $host in 5082d63fdb69Smrg # compiling the symbol table file with pic_flag works around 5083d63fdb69Smrg # a FreeBSD bug that causes programs to crash when -lm is 5084d63fdb69Smrg # linked before any other PIC object. But we must not use 5085d63fdb69Smrg # pic_flag when linking with -static. The problem exists in 5086d63fdb69Smrg # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. 508748c85eb7Smrg *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) 5088d63fdb69Smrg pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; 5089d63fdb69Smrg *-*-hpux*) 5090d63fdb69Smrg pic_flag_for_symtable=" $pic_flag" ;; 5091d63fdb69Smrg *) 509252fd71cdSmrg $my_pic_p && pic_flag_for_symtable=" $pic_flag" 5093d63fdb69Smrg ;; 5094d63fdb69Smrg esac 5095d63fdb69Smrg ;; 5096d63fdb69Smrg esac 5097d63fdb69Smrg symtab_cflags= 5098d63fdb69Smrg for arg in $LTCFLAGS; do 5099d63fdb69Smrg case $arg in 5100d63fdb69Smrg -pie | -fpie | -fPIE) ;; 510148c85eb7Smrg *) func_append symtab_cflags " $arg" ;; 5102d63fdb69Smrg esac 5103d63fdb69Smrg done 51043da084b3Smrg 5105d63fdb69Smrg # Now compile the dynamic symbol file. 5106d63fdb69Smrg func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' 51073da084b3Smrg 5108d63fdb69Smrg # Clean up the generated files. 510952fd71cdSmrg func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"' 5110d63fdb69Smrg 5111d63fdb69Smrg # Transform the symbol file into the correct name. 511252fd71cdSmrg symfileobj=$output_objdir/${my_outputname}S.$objext 5113d63fdb69Smrg case $host in 5114d63fdb69Smrg *cygwin* | *mingw* | *cegcc* ) 5115d63fdb69Smrg if test -f "$output_objdir/$my_outputname.def"; then 511655acc8fcSmrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 511755acc8fcSmrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 5118d63fdb69Smrg else 511955acc8fcSmrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 512055acc8fcSmrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 5121d63fdb69Smrg fi 5122d63fdb69Smrg ;; 5123d63fdb69Smrg *) 512455acc8fcSmrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 512555acc8fcSmrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 51263da084b3Smrg ;; 51273da084b3Smrg esac 5128d63fdb69Smrg ;; 5129d63fdb69Smrg *) 513052fd71cdSmrg func_fatal_error "unknown suffix for '$my_dlsyms'" 5131d63fdb69Smrg ;; 5132d63fdb69Smrg esac 5133d63fdb69Smrg else 5134d63fdb69Smrg # We keep going just in case the user didn't refer to 5135d63fdb69Smrg # lt_preloaded_symbols. The linker will fail if global_symbol_pipe 5136d63fdb69Smrg # really was required. 5137d63fdb69Smrg 5138d63fdb69Smrg # Nullify the symbol file. 513955acc8fcSmrg compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` 514055acc8fcSmrg finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` 51413da084b3Smrg fi 5142d63fdb69Smrg} 51433da084b3Smrg 514452fd71cdSmrg# func_cygming_gnu_implib_p ARG 514552fd71cdSmrg# This predicate returns with zero status (TRUE) if 514652fd71cdSmrg# ARG is a GNU/binutils-style import library. Returns 514752fd71cdSmrg# with nonzero status (FALSE) otherwise. 514852fd71cdSmrgfunc_cygming_gnu_implib_p () 514952fd71cdSmrg{ 515052fd71cdSmrg $debug_cmd 515152fd71cdSmrg 515252fd71cdSmrg func_to_tool_file "$1" func_convert_file_msys_to_w32 515352fd71cdSmrg 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)$'` 515452fd71cdSmrg test -n "$func_cygming_gnu_implib_tmp" 515552fd71cdSmrg} 515652fd71cdSmrg 515752fd71cdSmrg# func_cygming_ms_implib_p ARG 515852fd71cdSmrg# This predicate returns with zero status (TRUE) if 515952fd71cdSmrg# ARG is an MS-style import library. Returns 516052fd71cdSmrg# with nonzero status (FALSE) otherwise. 516152fd71cdSmrgfunc_cygming_ms_implib_p () 516252fd71cdSmrg{ 516352fd71cdSmrg $debug_cmd 516452fd71cdSmrg 516552fd71cdSmrg func_to_tool_file "$1" func_convert_file_msys_to_w32 516652fd71cdSmrg func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` 516752fd71cdSmrg test -n "$func_cygming_ms_implib_tmp" 516852fd71cdSmrg} 516952fd71cdSmrg 5170d63fdb69Smrg# func_win32_libid arg 5171d63fdb69Smrg# return the library type of file 'arg' 5172d63fdb69Smrg# 5173d63fdb69Smrg# Need a lot of goo to handle *both* DLLs and import libs 5174d63fdb69Smrg# Has to be a shell function in order to 'eat' the argument 5175d63fdb69Smrg# that is supplied when $file_magic_command is called. 517655acc8fcSmrg# Despite the name, also deal with 64 bit binaries. 5177d63fdb69Smrgfunc_win32_libid () 5178d63fdb69Smrg{ 517952fd71cdSmrg $debug_cmd 518052fd71cdSmrg 518152fd71cdSmrg win32_libid_type=unknown 5182d63fdb69Smrg win32_fileres=`file -L $1 2>/dev/null` 5183d63fdb69Smrg case $win32_fileres in 5184d63fdb69Smrg *ar\ archive\ import\ library*) # definitely import 5185d63fdb69Smrg win32_libid_type="x86 archive import" 5186d63fdb69Smrg ;; 5187d63fdb69Smrg *ar\ archive*) # could be an import, or static 518855acc8fcSmrg # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. 5189d63fdb69Smrg if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | 519055acc8fcSmrg $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then 519152fd71cdSmrg case $nm_interface in 519252fd71cdSmrg "MS dumpbin") 519352fd71cdSmrg if func_cygming_ms_implib_p "$1" || 519452fd71cdSmrg func_cygming_gnu_implib_p "$1" 519552fd71cdSmrg then 519652fd71cdSmrg win32_nmres=import 519752fd71cdSmrg else 519852fd71cdSmrg win32_nmres= 519952fd71cdSmrg fi 520052fd71cdSmrg ;; 520152fd71cdSmrg *) 520252fd71cdSmrg func_to_tool_file "$1" func_convert_file_msys_to_w32 520352fd71cdSmrg win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | 520452fd71cdSmrg $SED -n -e ' 5205d63fdb69Smrg 1,100{ 5206d63fdb69Smrg / I /{ 520752fd71cdSmrg s|.*|import| 5208d63fdb69Smrg p 5209d63fdb69Smrg q 5210d63fdb69Smrg } 5211d63fdb69Smrg }'` 521252fd71cdSmrg ;; 521352fd71cdSmrg esac 5214d63fdb69Smrg case $win32_nmres in 5215d63fdb69Smrg import*) win32_libid_type="x86 archive import";; 5216d63fdb69Smrg *) win32_libid_type="x86 archive static";; 5217d63fdb69Smrg esac 5218d63fdb69Smrg fi 5219d63fdb69Smrg ;; 5220d63fdb69Smrg *DLL*) 5221d63fdb69Smrg win32_libid_type="x86 DLL" 5222d63fdb69Smrg ;; 5223d63fdb69Smrg *executable*) # but shell scripts are "executable" too... 5224d63fdb69Smrg case $win32_fileres in 5225d63fdb69Smrg *MS\ Windows\ PE\ Intel*) 5226d63fdb69Smrg win32_libid_type="x86 DLL" 5227d63fdb69Smrg ;; 5228d63fdb69Smrg esac 5229d63fdb69Smrg ;; 5230d63fdb69Smrg esac 5231d63fdb69Smrg $ECHO "$win32_libid_type" 5232d63fdb69Smrg} 52333da084b3Smrg 523448c85eb7Smrg# func_cygming_dll_for_implib ARG 523548c85eb7Smrg# 523648c85eb7Smrg# Platform-specific function to extract the 523748c85eb7Smrg# name of the DLL associated with the specified 523848c85eb7Smrg# import library ARG. 523948c85eb7Smrg# Invoked by eval'ing the libtool variable 524048c85eb7Smrg# $sharedlib_from_linklib_cmd 524148c85eb7Smrg# Result is available in the variable 524248c85eb7Smrg# $sharedlib_from_linklib_result 524348c85eb7Smrgfunc_cygming_dll_for_implib () 524448c85eb7Smrg{ 524552fd71cdSmrg $debug_cmd 524652fd71cdSmrg 524748c85eb7Smrg sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` 524848c85eb7Smrg} 524948c85eb7Smrg 525048c85eb7Smrg# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs 525148c85eb7Smrg# 525248c85eb7Smrg# The is the core of a fallback implementation of a 525348c85eb7Smrg# platform-specific function to extract the name of the 525448c85eb7Smrg# DLL associated with the specified import library LIBNAME. 525548c85eb7Smrg# 525648c85eb7Smrg# SECTION_NAME is either .idata$6 or .idata$7, depending 525748c85eb7Smrg# on the platform and compiler that created the implib. 525848c85eb7Smrg# 525948c85eb7Smrg# Echos the name of the DLL associated with the 526048c85eb7Smrg# specified import library. 526148c85eb7Smrgfunc_cygming_dll_for_implib_fallback_core () 526248c85eb7Smrg{ 526352fd71cdSmrg $debug_cmd 526452fd71cdSmrg 526548c85eb7Smrg match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` 526648c85eb7Smrg $OBJDUMP -s --section "$1" "$2" 2>/dev/null | 526748c85eb7Smrg $SED '/^Contents of section '"$match_literal"':/{ 526848c85eb7Smrg # Place marker at beginning of archive member dllname section 526948c85eb7Smrg s/.*/====MARK====/ 527048c85eb7Smrg p 527148c85eb7Smrg d 527248c85eb7Smrg } 527348c85eb7Smrg # These lines can sometimes be longer than 43 characters, but 527448c85eb7Smrg # are always uninteresting 527548c85eb7Smrg /:[ ]*file format pe[i]\{,1\}-/d 527648c85eb7Smrg /^In archive [^:]*:/d 527748c85eb7Smrg # Ensure marker is printed 527848c85eb7Smrg /^====MARK====/p 527948c85eb7Smrg # Remove all lines with less than 43 characters 528048c85eb7Smrg /^.\{43\}/!d 528148c85eb7Smrg # From remaining lines, remove first 43 characters 528248c85eb7Smrg s/^.\{43\}//' | 528348c85eb7Smrg $SED -n ' 528448c85eb7Smrg # Join marker and all lines until next marker into a single line 528548c85eb7Smrg /^====MARK====/ b para 528648c85eb7Smrg H 528748c85eb7Smrg $ b para 528848c85eb7Smrg b 528948c85eb7Smrg :para 529048c85eb7Smrg x 529148c85eb7Smrg s/\n//g 529248c85eb7Smrg # Remove the marker 529348c85eb7Smrg s/^====MARK====// 529448c85eb7Smrg # Remove trailing dots and whitespace 529548c85eb7Smrg s/[\. \t]*$// 529648c85eb7Smrg # Print 529748c85eb7Smrg /./p' | 529848c85eb7Smrg # we now have a list, one entry per line, of the stringified 529948c85eb7Smrg # contents of the appropriate section of all members of the 530052fd71cdSmrg # archive that possess that section. Heuristic: eliminate 530152fd71cdSmrg # all those that have a first or second character that is 530248c85eb7Smrg # a '.' (that is, objdump's representation of an unprintable 530348c85eb7Smrg # character.) This should work for all archives with less than 530448c85eb7Smrg # 0x302f exports -- but will fail for DLLs whose name actually 530548c85eb7Smrg # begins with a literal '.' or a single character followed by 530648c85eb7Smrg # a '.'. 530748c85eb7Smrg # 530848c85eb7Smrg # Of those that remain, print the first one. 530948c85eb7Smrg $SED -e '/^\./d;/^.\./d;q' 531048c85eb7Smrg} 531148c85eb7Smrg 531248c85eb7Smrg# func_cygming_dll_for_implib_fallback ARG 531348c85eb7Smrg# Platform-specific function to extract the 531448c85eb7Smrg# name of the DLL associated with the specified 531548c85eb7Smrg# import library ARG. 531648c85eb7Smrg# 531748c85eb7Smrg# This fallback implementation is for use when $DLLTOOL 531848c85eb7Smrg# does not support the --identify-strict option. 531948c85eb7Smrg# Invoked by eval'ing the libtool variable 532048c85eb7Smrg# $sharedlib_from_linklib_cmd 532148c85eb7Smrg# Result is available in the variable 532248c85eb7Smrg# $sharedlib_from_linklib_result 532348c85eb7Smrgfunc_cygming_dll_for_implib_fallback () 532448c85eb7Smrg{ 532552fd71cdSmrg $debug_cmd 532652fd71cdSmrg 532752fd71cdSmrg if func_cygming_gnu_implib_p "$1"; then 532848c85eb7Smrg # binutils import library 532948c85eb7Smrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` 533052fd71cdSmrg elif func_cygming_ms_implib_p "$1"; then 533148c85eb7Smrg # ms-generated import library 533248c85eb7Smrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` 533348c85eb7Smrg else 533448c85eb7Smrg # unknown 533552fd71cdSmrg sharedlib_from_linklib_result= 533648c85eb7Smrg fi 533748c85eb7Smrg} 53383da084b3Smrg 53393da084b3Smrg 5340d63fdb69Smrg# func_extract_an_archive dir oldlib 5341d63fdb69Smrgfunc_extract_an_archive () 5342d63fdb69Smrg{ 534352fd71cdSmrg $debug_cmd 534452fd71cdSmrg 534552fd71cdSmrg f_ex_an_ar_dir=$1; shift 534652fd71cdSmrg f_ex_an_ar_oldlib=$1 534752fd71cdSmrg if test yes = "$lock_old_archive_extraction"; then 534855acc8fcSmrg lockfile=$f_ex_an_ar_oldlib.lock 534955acc8fcSmrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 535055acc8fcSmrg func_echo "Waiting for $lockfile to be removed" 535155acc8fcSmrg sleep 2 535255acc8fcSmrg done 535355acc8fcSmrg fi 535455acc8fcSmrg func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ 535555acc8fcSmrg 'stat=$?; rm -f "$lockfile"; exit $stat' 535652fd71cdSmrg if test yes = "$lock_old_archive_extraction"; then 535755acc8fcSmrg $opt_dry_run || rm -f "$lockfile" 535855acc8fcSmrg fi 5359d63fdb69Smrg if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then 5360d63fdb69Smrg : 5361d63fdb69Smrg else 5362d63fdb69Smrg func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 5363d63fdb69Smrg fi 5364d63fdb69Smrg} 53653da084b3Smrg 53663da084b3Smrg 5367d63fdb69Smrg# func_extract_archives gentop oldlib ... 5368d63fdb69Smrgfunc_extract_archives () 5369d63fdb69Smrg{ 537052fd71cdSmrg $debug_cmd 537152fd71cdSmrg 537252fd71cdSmrg my_gentop=$1; shift 5373d63fdb69Smrg my_oldlibs=${1+"$@"} 537452fd71cdSmrg my_oldobjs= 537552fd71cdSmrg my_xlib= 537652fd71cdSmrg my_xabs= 537752fd71cdSmrg my_xdir= 53783da084b3Smrg 5379d63fdb69Smrg for my_xlib in $my_oldlibs; do 5380d63fdb69Smrg # Extract the objects. 5381d63fdb69Smrg case $my_xlib in 538252fd71cdSmrg [\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;; 5383d63fdb69Smrg *) my_xabs=`pwd`"/$my_xlib" ;; 5384d63fdb69Smrg esac 5385d63fdb69Smrg func_basename "$my_xlib" 538652fd71cdSmrg my_xlib=$func_basename_result 5387d63fdb69Smrg my_xlib_u=$my_xlib 5388d63fdb69Smrg while :; do 5389d63fdb69Smrg case " $extracted_archives " in 5390d63fdb69Smrg *" $my_xlib_u "*) 5391d63fdb69Smrg func_arith $extracted_serial + 1 5392d63fdb69Smrg extracted_serial=$func_arith_result 5393d63fdb69Smrg my_xlib_u=lt$extracted_serial-$my_xlib ;; 5394d63fdb69Smrg *) break ;; 5395d63fdb69Smrg esac 5396d63fdb69Smrg done 5397d63fdb69Smrg extracted_archives="$extracted_archives $my_xlib_u" 539852fd71cdSmrg my_xdir=$my_gentop/$my_xlib_u 53993da084b3Smrg 5400d63fdb69Smrg func_mkdir_p "$my_xdir" 54013da084b3Smrg 5402d63fdb69Smrg case $host in 5403d63fdb69Smrg *-darwin*) 5404d63fdb69Smrg func_verbose "Extracting $my_xabs" 5405d63fdb69Smrg # Do not bother doing anything if just a dry run 5406d63fdb69Smrg $opt_dry_run || { 5407d63fdb69Smrg darwin_orig_dir=`pwd` 5408d63fdb69Smrg cd $my_xdir || exit $? 5409d63fdb69Smrg darwin_archive=$my_xabs 5410d63fdb69Smrg darwin_curdir=`pwd` 541152fd71cdSmrg func_basename "$darwin_archive" 541252fd71cdSmrg darwin_base_archive=$func_basename_result 5413d63fdb69Smrg darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` 5414d63fdb69Smrg if test -n "$darwin_arches"; then 5415d63fdb69Smrg darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` 5416d63fdb69Smrg darwin_arch= 5417d63fdb69Smrg func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" 541852fd71cdSmrg for darwin_arch in $darwin_arches; do 541952fd71cdSmrg func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch" 542052fd71cdSmrg $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive" 542152fd71cdSmrg cd "unfat-$$/$darwin_base_archive-$darwin_arch" 542252fd71cdSmrg func_extract_an_archive "`pwd`" "$darwin_base_archive" 5423d63fdb69Smrg cd "$darwin_curdir" 542452fd71cdSmrg $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" 5425d63fdb69Smrg done # $darwin_arches 5426d63fdb69Smrg ## Okay now we've a bunch of thin objects, gotta fatten them up :) 542752fd71cdSmrg darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$sed_basename" | sort -u` 5428d63fdb69Smrg darwin_file= 5429d63fdb69Smrg darwin_files= 5430d63fdb69Smrg for darwin_file in $darwin_filelist; do 543155acc8fcSmrg darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` 5432d63fdb69Smrg $LIPO -create -output "$darwin_file" $darwin_files 5433d63fdb69Smrg done # $darwin_filelist 5434d63fdb69Smrg $RM -rf unfat-$$ 5435d63fdb69Smrg cd "$darwin_orig_dir" 5436d63fdb69Smrg else 5437d63fdb69Smrg cd $darwin_orig_dir 5438d63fdb69Smrg func_extract_an_archive "$my_xdir" "$my_xabs" 5439d63fdb69Smrg fi # $darwin_arches 5440d63fdb69Smrg } # !$opt_dry_run 5441d63fdb69Smrg ;; 5442d63fdb69Smrg *) 5443d63fdb69Smrg func_extract_an_archive "$my_xdir" "$my_xabs" 5444d63fdb69Smrg ;; 54453da084b3Smrg esac 544655acc8fcSmrg my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` 5447d63fdb69Smrg done 54483da084b3Smrg 544952fd71cdSmrg func_extract_archives_result=$my_oldobjs 5450d63fdb69Smrg} 54513da084b3Smrg 54523da084b3Smrg 545355acc8fcSmrg# func_emit_wrapper [arg=no] 545455acc8fcSmrg# 545555acc8fcSmrg# Emit a libtool wrapper script on stdout. 545655acc8fcSmrg# Don't directly open a file because we may want to 545755acc8fcSmrg# incorporate the script contents within a cygwin/mingw 545855acc8fcSmrg# wrapper executable. Must ONLY be called from within 545955acc8fcSmrg# func_mode_link because it depends on a number of variables 546055acc8fcSmrg# set therein. 5461d63fdb69Smrg# 546255acc8fcSmrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR 546355acc8fcSmrg# variable will take. If 'yes', then the emitted script 546452fd71cdSmrg# will assume that the directory where it is stored is 546555acc8fcSmrg# the $objdir directory. This is a cygwin/mingw-specific 546655acc8fcSmrg# behavior. 546755acc8fcSmrgfunc_emit_wrapper () 5468d63fdb69Smrg{ 546955acc8fcSmrg func_emit_wrapper_arg1=${1-no} 54703da084b3Smrg 5471d63fdb69Smrg $ECHO "\ 5472d63fdb69Smrg#! $SHELL 54733da084b3Smrg 5474d63fdb69Smrg# $output - temporary wrapper script for $objdir/$outputname 547552fd71cdSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 5476d63fdb69Smrg# 5477d63fdb69Smrg# The $output program cannot be directly executed until all the libtool 5478d63fdb69Smrg# libraries that it depends on are installed. 5479d63fdb69Smrg# 5480d63fdb69Smrg# This wrapper script should never be moved out of the build directory. 5481d63fdb69Smrg# If it is, it will not operate correctly. 54823da084b3Smrg 5483d63fdb69Smrg# Sed substitution that helps us do robust quoting. It backslashifies 5484d63fdb69Smrg# metacharacters that are still active within double-quoted strings. 5485d63fdb69Smrgsed_quote_subst='$sed_quote_subst' 54863da084b3Smrg 5487d63fdb69Smrg# Be Bourne compatible 5488d63fdb69Smrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then 5489d63fdb69Smrg emulate sh 5490d63fdb69Smrg NULLCMD=: 5491d63fdb69Smrg # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which 5492d63fdb69Smrg # is contrary to our usage. Disable this feature. 5493d63fdb69Smrg alias -g '\${1+\"\$@\"}'='\"\$@\"' 5494d63fdb69Smrg setopt NO_GLOB_SUBST 5495d63fdb69Smrgelse 5496d63fdb69Smrg case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac 5497d63fdb69Smrgfi 5498d63fdb69SmrgBIN_SH=xpg4; export BIN_SH # for Tru64 5499d63fdb69SmrgDUALCASE=1; export DUALCASE # for MKS sh 55003da084b3Smrg 5501d63fdb69Smrg# The HP-UX ksh and POSIX shell print the target directory to stdout 5502d63fdb69Smrg# if CDPATH is set. 5503d63fdb69Smrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 55043da084b3Smrg 5505d63fdb69Smrgrelink_command=\"$relink_command\" 55063da084b3Smrg 5507d63fdb69Smrg# This environment variable determines our operation mode. 5508d63fdb69Smrgif test \"\$libtool_install_magic\" = \"$magic\"; then 5509d63fdb69Smrg # install mode needs the following variables: 5510d63fdb69Smrg generated_by_libtool_version='$macro_version' 5511d63fdb69Smrg notinst_deplibs='$notinst_deplibs' 5512d63fdb69Smrgelse 5513d63fdb69Smrg # When we are sourced in execute mode, \$file and \$ECHO are already set. 5514d63fdb69Smrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 551555acc8fcSmrg file=\"\$0\"" 551655acc8fcSmrg 55172a53b785Smrg func_quote_arg pretty "$ECHO" 55182a53b785Smrg qECHO=$func_quote_arg_result 551955acc8fcSmrg $ECHO "\ 552055acc8fcSmrg 552155acc8fcSmrg# A function that is used when there is no print builtin or printf. 552255acc8fcSmrgfunc_fallback_echo () 552355acc8fcSmrg{ 552455acc8fcSmrg eval 'cat <<_LTECHO_EOF 552555acc8fcSmrg\$1 552655acc8fcSmrg_LTECHO_EOF' 552755acc8fcSmrg} 55282a53b785Smrg ECHO=$qECHO 552955acc8fcSmrg fi 553055acc8fcSmrg 553155acc8fcSmrg# Very basic option parsing. These options are (a) specific to 553255acc8fcSmrg# the libtool wrapper, (b) are identical between the wrapper 553352fd71cdSmrg# /script/ and the wrapper /executable/ that is used only on 553455acc8fcSmrg# windows platforms, and (c) all begin with the string "--lt-" 553552fd71cdSmrg# (application programs are unlikely to have options that match 553655acc8fcSmrg# this pattern). 553755acc8fcSmrg# 553855acc8fcSmrg# There are only two supported options: --lt-debug and 553955acc8fcSmrg# --lt-dump-script. There is, deliberately, no --lt-help. 554055acc8fcSmrg# 554155acc8fcSmrg# The first argument to this parsing function should be the 554255acc8fcSmrg# script's $0 value, followed by "$@". 554355acc8fcSmrglt_option_debug= 554455acc8fcSmrgfunc_parse_lt_options () 554555acc8fcSmrg{ 554655acc8fcSmrg lt_script_arg0=\$0 554755acc8fcSmrg shift 554855acc8fcSmrg for lt_opt 554955acc8fcSmrg do 555055acc8fcSmrg case \"\$lt_opt\" in 555155acc8fcSmrg --lt-debug) lt_option_debug=1 ;; 555255acc8fcSmrg --lt-dump-script) 555355acc8fcSmrg lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` 555455acc8fcSmrg test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. 555555acc8fcSmrg lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` 555655acc8fcSmrg cat \"\$lt_dump_D/\$lt_dump_F\" 555755acc8fcSmrg exit 0 555855acc8fcSmrg ;; 555955acc8fcSmrg --lt-*) 556055acc8fcSmrg \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 556155acc8fcSmrg exit 1 556255acc8fcSmrg ;; 556355acc8fcSmrg esac 556455acc8fcSmrg done 556555acc8fcSmrg 556655acc8fcSmrg # Print the debug banner immediately: 556755acc8fcSmrg if test -n \"\$lt_option_debug\"; then 556852fd71cdSmrg echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2 556955acc8fcSmrg fi 557055acc8fcSmrg} 557155acc8fcSmrg 557255acc8fcSmrg# Used when --lt-debug. Prints its arguments to stdout 557355acc8fcSmrg# (redirection is the responsibility of the caller) 557455acc8fcSmrgfunc_lt_dump_args () 557555acc8fcSmrg{ 557655acc8fcSmrg lt_dump_args_N=1; 557755acc8fcSmrg for lt_arg 557855acc8fcSmrg do 557952fd71cdSmrg \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\" 558055acc8fcSmrg lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` 558155acc8fcSmrg done 558255acc8fcSmrg} 558355acc8fcSmrg 558455acc8fcSmrg# Core function for launching the target application 558555acc8fcSmrgfunc_exec_program_core () 558655acc8fcSmrg{ 5587d63fdb69Smrg" 558855acc8fcSmrg case $host in 558955acc8fcSmrg # Backslashes separate directories on plain windows 559055acc8fcSmrg *-*-mingw | *-*-os2* | *-cegcc*) 559155acc8fcSmrg $ECHO "\ 559255acc8fcSmrg if test -n \"\$lt_option_debug\"; then 559352fd71cdSmrg \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2 559455acc8fcSmrg func_lt_dump_args \${1+\"\$@\"} 1>&2 559555acc8fcSmrg fi 559655acc8fcSmrg exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} 559755acc8fcSmrg" 559855acc8fcSmrg ;; 559955acc8fcSmrg 560055acc8fcSmrg *) 560155acc8fcSmrg $ECHO "\ 560255acc8fcSmrg if test -n \"\$lt_option_debug\"; then 560352fd71cdSmrg \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2 560455acc8fcSmrg func_lt_dump_args \${1+\"\$@\"} 1>&2 560555acc8fcSmrg fi 560655acc8fcSmrg exec \"\$progdir/\$program\" \${1+\"\$@\"} 560755acc8fcSmrg" 560855acc8fcSmrg ;; 560955acc8fcSmrg esac 561055acc8fcSmrg $ECHO "\ 561155acc8fcSmrg \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 561255acc8fcSmrg exit 1 561355acc8fcSmrg} 561455acc8fcSmrg 561555acc8fcSmrg# A function to encapsulate launching the target application 561655acc8fcSmrg# Strips options in the --lt-* namespace from \$@ and 561755acc8fcSmrg# launches target application with the remaining arguments. 561855acc8fcSmrgfunc_exec_program () 561955acc8fcSmrg{ 562048c85eb7Smrg case \" \$* \" in 562148c85eb7Smrg *\\ --lt-*) 562248c85eb7Smrg for lt_wr_arg 562348c85eb7Smrg do 562448c85eb7Smrg case \$lt_wr_arg in 562548c85eb7Smrg --lt-*) ;; 562648c85eb7Smrg *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; 562748c85eb7Smrg esac 562848c85eb7Smrg shift 562948c85eb7Smrg done ;; 563048c85eb7Smrg esac 563155acc8fcSmrg func_exec_program_core \${1+\"\$@\"} 563255acc8fcSmrg} 563355acc8fcSmrg 563455acc8fcSmrg # Parse options 563555acc8fcSmrg func_parse_lt_options \"\$0\" \${1+\"\$@\"} 56363da084b3Smrg 5637d63fdb69Smrg # Find the directory that this script lives in. 563855acc8fcSmrg thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` 5639d63fdb69Smrg test \"x\$thisdir\" = \"x\$file\" && thisdir=. 56403da084b3Smrg 5641d63fdb69Smrg # Follow symbolic links until we get to the real thisdir. 564255acc8fcSmrg file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` 5643d63fdb69Smrg while test -n \"\$file\"; do 564455acc8fcSmrg destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` 56453da084b3Smrg 5646d63fdb69Smrg # If there was a directory component, then change thisdir. 5647d63fdb69Smrg if test \"x\$destdir\" != \"x\$file\"; then 5648d63fdb69Smrg case \"\$destdir\" in 5649d63fdb69Smrg [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; 5650d63fdb69Smrg *) thisdir=\"\$thisdir/\$destdir\" ;; 5651d63fdb69Smrg esac 5652d63fdb69Smrg fi 56533da084b3Smrg 565455acc8fcSmrg file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` 565555acc8fcSmrg file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` 5656d63fdb69Smrg done 56573da084b3Smrg 5658d63fdb69Smrg # Usually 'no', except on cygwin/mingw when embedded into 5659d63fdb69Smrg # the cwrapper. 566055acc8fcSmrg WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 5661d63fdb69Smrg if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then 5662d63fdb69Smrg # special case for '.' 5663d63fdb69Smrg if test \"\$thisdir\" = \".\"; then 5664d63fdb69Smrg thisdir=\`pwd\` 5665d63fdb69Smrg fi 5666d63fdb69Smrg # remove .libs from thisdir 5667d63fdb69Smrg case \"\$thisdir\" in 566855acc8fcSmrg *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; 5669d63fdb69Smrg $objdir ) thisdir=. ;; 5670d63fdb69Smrg esac 5671d63fdb69Smrg fi 56723da084b3Smrg 5673d63fdb69Smrg # Try to get the absolute directory name. 5674d63fdb69Smrg absdir=\`cd \"\$thisdir\" && pwd\` 5675d63fdb69Smrg test -n \"\$absdir\" && thisdir=\"\$absdir\" 5676d63fdb69Smrg" 56773da084b3Smrg 567852fd71cdSmrg if test yes = "$fast_install"; then 5679d63fdb69Smrg $ECHO "\ 5680d63fdb69Smrg program=lt-'$outputname'$exeext 5681d63fdb69Smrg progdir=\"\$thisdir/$objdir\" 56823da084b3Smrg 5683d63fdb69Smrg if test ! -f \"\$progdir/\$program\" || 568452fd71cdSmrg { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\ 5685d63fdb69Smrg test \"X\$file\" != \"X\$progdir/\$program\"; }; then 56863da084b3Smrg 5687d63fdb69Smrg file=\"\$\$-\$program\" 56883da084b3Smrg 5689d63fdb69Smrg if test ! -d \"\$progdir\"; then 5690d63fdb69Smrg $MKDIR \"\$progdir\" 5691d63fdb69Smrg else 5692d63fdb69Smrg $RM \"\$progdir/\$file\" 5693d63fdb69Smrg fi" 56943da084b3Smrg 5695d63fdb69Smrg $ECHO "\ 56963da084b3Smrg 5697d63fdb69Smrg # relink executable if necessary 5698d63fdb69Smrg if test -n \"\$relink_command\"; then 5699d63fdb69Smrg if relink_command_output=\`eval \$relink_command 2>&1\`; then : 5700d63fdb69Smrg else 570152fd71cdSmrg \$ECHO \"\$relink_command_output\" >&2 5702d63fdb69Smrg $RM \"\$progdir/\$file\" 5703d63fdb69Smrg exit 1 5704d63fdb69Smrg fi 5705d63fdb69Smrg fi 57063da084b3Smrg 5707d63fdb69Smrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || 5708d63fdb69Smrg { $RM \"\$progdir/\$program\"; 5709d63fdb69Smrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } 5710d63fdb69Smrg $RM \"\$progdir/\$file\" 5711d63fdb69Smrg fi" 5712d63fdb69Smrg else 5713d63fdb69Smrg $ECHO "\ 5714d63fdb69Smrg program='$outputname' 5715d63fdb69Smrg progdir=\"\$thisdir/$objdir\" 5716d63fdb69Smrg" 5717d63fdb69Smrg fi 57183da084b3Smrg 5719d63fdb69Smrg $ECHO "\ 57203da084b3Smrg 5721d63fdb69Smrg if test -f \"\$progdir/\$program\"; then" 57223da084b3Smrg 572348c85eb7Smrg # fixup the dll searchpath if we need to. 572448c85eb7Smrg # 572548c85eb7Smrg # Fix the DLL searchpath if we need to. Do this before prepending 572648c85eb7Smrg # to shlibpath, because on Windows, both are PATH and uninstalled 572748c85eb7Smrg # libraries must come first. 572848c85eb7Smrg if test -n "$dllsearchpath"; then 572948c85eb7Smrg $ECHO "\ 573048c85eb7Smrg # Add the dll search path components to the executable PATH 573148c85eb7Smrg PATH=$dllsearchpath:\$PATH 573248c85eb7Smrg" 573348c85eb7Smrg fi 573448c85eb7Smrg 5735d63fdb69Smrg # Export our shlibpath_var if we have one. 573652fd71cdSmrg if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 5737d63fdb69Smrg $ECHO "\ 5738d63fdb69Smrg # Add our own library path to $shlibpath_var 5739d63fdb69Smrg $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" 57403da084b3Smrg 5741d63fdb69Smrg # Some systems cannot cope with colon-terminated $shlibpath_var 5742d63fdb69Smrg # The second colon is a workaround for a bug in BeOS R4 sed 574355acc8fcSmrg $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` 57443da084b3Smrg 5745d63fdb69Smrg export $shlibpath_var 5746d63fdb69Smrg" 57473da084b3Smrg fi 57483da084b3Smrg 5749d63fdb69Smrg $ECHO "\ 5750d63fdb69Smrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 5751d63fdb69Smrg # Run the actual program with our arguments. 575255acc8fcSmrg func_exec_program \${1+\"\$@\"} 5753d63fdb69Smrg fi 5754d63fdb69Smrg else 5755d63fdb69Smrg # The program doesn't exist. 575652fd71cdSmrg \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2 5757d63fdb69Smrg \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 575855acc8fcSmrg \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 5759d63fdb69Smrg exit 1 5760d63fdb69Smrg fi 5761d63fdb69Smrgfi\ 5762d63fdb69Smrg" 5763d63fdb69Smrg} 57643da084b3Smrg 57653da084b3Smrg 5766d63fdb69Smrg# func_emit_cwrapperexe_src 5767d63fdb69Smrg# emit the source code for a wrapper executable on stdout 5768d63fdb69Smrg# Must ONLY be called from within func_mode_link because 5769d63fdb69Smrg# it depends on a number of variable set therein. 5770d63fdb69Smrgfunc_emit_cwrapperexe_src () 5771d63fdb69Smrg{ 5772d63fdb69Smrg cat <<EOF 57733da084b3Smrg 5774d63fdb69Smrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname 577552fd71cdSmrg Generated by $PROGRAM (GNU $PACKAGE) $VERSION 57763da084b3Smrg 5777d63fdb69Smrg The $output program cannot be directly executed until all the libtool 5778d63fdb69Smrg libraries that it depends on are installed. 57793da084b3Smrg 5780d63fdb69Smrg This wrapper executable should never be moved out of the build directory. 5781d63fdb69Smrg If it is, it will not operate correctly. 5782d63fdb69Smrg*/ 5783d63fdb69SmrgEOF 5784d63fdb69Smrg cat <<"EOF" 578555acc8fcSmrg#ifdef _MSC_VER 578655acc8fcSmrg# define _CRT_SECURE_NO_DEPRECATE 1 578755acc8fcSmrg#endif 5788d63fdb69Smrg#include <stdio.h> 5789d63fdb69Smrg#include <stdlib.h> 5790d63fdb69Smrg#ifdef _MSC_VER 5791d63fdb69Smrg# include <direct.h> 5792d63fdb69Smrg# include <process.h> 5793d63fdb69Smrg# include <io.h> 5794d63fdb69Smrg#else 5795d63fdb69Smrg# include <unistd.h> 5796d63fdb69Smrg# include <stdint.h> 5797d63fdb69Smrg# ifdef __CYGWIN__ 5798d63fdb69Smrg# include <io.h> 5799d63fdb69Smrg# endif 5800d63fdb69Smrg#endif 5801d63fdb69Smrg#include <malloc.h> 5802d63fdb69Smrg#include <stdarg.h> 5803d63fdb69Smrg#include <assert.h> 5804d63fdb69Smrg#include <string.h> 5805d63fdb69Smrg#include <ctype.h> 5806d63fdb69Smrg#include <errno.h> 5807d63fdb69Smrg#include <fcntl.h> 5808d63fdb69Smrg#include <sys/stat.h> 5809d63fdb69Smrg 581052fd71cdSmrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 581152fd71cdSmrg 581255acc8fcSmrg/* declarations of non-ANSI functions */ 581352fd71cdSmrg#if defined __MINGW32__ 581455acc8fcSmrg# ifdef __STRICT_ANSI__ 581555acc8fcSmrgint _putenv (const char *); 581655acc8fcSmrg# endif 581752fd71cdSmrg#elif defined __CYGWIN__ 581855acc8fcSmrg# ifdef __STRICT_ANSI__ 581955acc8fcSmrgchar *realpath (const char *, char *); 582055acc8fcSmrgint putenv (char *); 582155acc8fcSmrgint setenv (const char *, const char *, int); 582255acc8fcSmrg# endif 582352fd71cdSmrg/* #elif defined other_platform || defined ... */ 582455acc8fcSmrg#endif 582555acc8fcSmrg 582655acc8fcSmrg/* portability defines, excluding path handling macros */ 582752fd71cdSmrg#if defined _MSC_VER 582855acc8fcSmrg# define setmode _setmode 582955acc8fcSmrg# define stat _stat 583055acc8fcSmrg# define chmod _chmod 583155acc8fcSmrg# define getcwd _getcwd 583255acc8fcSmrg# define putenv _putenv 583355acc8fcSmrg# define S_IXUSR _S_IEXEC 583452fd71cdSmrg#elif defined __MINGW32__ 583555acc8fcSmrg# define setmode _setmode 583655acc8fcSmrg# define stat _stat 583755acc8fcSmrg# define chmod _chmod 583855acc8fcSmrg# define getcwd _getcwd 583955acc8fcSmrg# define putenv _putenv 584052fd71cdSmrg#elif defined __CYGWIN__ 584155acc8fcSmrg# define HAVE_SETENV 584255acc8fcSmrg# define FOPEN_WB "wb" 584352fd71cdSmrg/* #elif defined other platforms ... */ 584455acc8fcSmrg#endif 584555acc8fcSmrg 584652fd71cdSmrg#if defined PATH_MAX 5847d63fdb69Smrg# define LT_PATHMAX PATH_MAX 584852fd71cdSmrg#elif defined MAXPATHLEN 5849d63fdb69Smrg# define LT_PATHMAX MAXPATHLEN 5850d63fdb69Smrg#else 5851d63fdb69Smrg# define LT_PATHMAX 1024 5852d63fdb69Smrg#endif 5853d63fdb69Smrg 5854d63fdb69Smrg#ifndef S_IXOTH 5855d63fdb69Smrg# define S_IXOTH 0 5856d63fdb69Smrg#endif 5857d63fdb69Smrg#ifndef S_IXGRP 5858d63fdb69Smrg# define S_IXGRP 0 5859d63fdb69Smrg#endif 5860d63fdb69Smrg 586155acc8fcSmrg/* path handling portability macros */ 5862d63fdb69Smrg#ifndef DIR_SEPARATOR 5863d63fdb69Smrg# define DIR_SEPARATOR '/' 5864d63fdb69Smrg# define PATH_SEPARATOR ':' 5865d63fdb69Smrg#endif 5866d63fdb69Smrg 586752fd71cdSmrg#if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \ 586852fd71cdSmrg defined __OS2__ 5869d63fdb69Smrg# define HAVE_DOS_BASED_FILE_SYSTEM 5870d63fdb69Smrg# define FOPEN_WB "wb" 5871d63fdb69Smrg# ifndef DIR_SEPARATOR_2 5872d63fdb69Smrg# define DIR_SEPARATOR_2 '\\' 5873d63fdb69Smrg# endif 5874d63fdb69Smrg# ifndef PATH_SEPARATOR_2 5875d63fdb69Smrg# define PATH_SEPARATOR_2 ';' 5876d63fdb69Smrg# endif 5877d63fdb69Smrg#endif 5878d63fdb69Smrg 5879d63fdb69Smrg#ifndef DIR_SEPARATOR_2 5880d63fdb69Smrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) 5881d63fdb69Smrg#else /* DIR_SEPARATOR_2 */ 5882d63fdb69Smrg# define IS_DIR_SEPARATOR(ch) \ 5883d63fdb69Smrg (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) 5884d63fdb69Smrg#endif /* DIR_SEPARATOR_2 */ 5885d63fdb69Smrg 5886d63fdb69Smrg#ifndef PATH_SEPARATOR_2 5887d63fdb69Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) 5888d63fdb69Smrg#else /* PATH_SEPARATOR_2 */ 5889d63fdb69Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) 5890d63fdb69Smrg#endif /* PATH_SEPARATOR_2 */ 5891d63fdb69Smrg 5892d63fdb69Smrg#ifndef FOPEN_WB 5893d63fdb69Smrg# define FOPEN_WB "w" 5894d63fdb69Smrg#endif 5895d63fdb69Smrg#ifndef _O_BINARY 5896d63fdb69Smrg# define _O_BINARY 0 5897d63fdb69Smrg#endif 5898d63fdb69Smrg 5899d63fdb69Smrg#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) 5900d63fdb69Smrg#define XFREE(stale) do { \ 590152fd71cdSmrg if (stale) { free (stale); stale = 0; } \ 5902d63fdb69Smrg} while (0) 5903d63fdb69Smrg 590452fd71cdSmrg#if defined LT_DEBUGWRAPPER 590555acc8fcSmrgstatic int lt_debug = 1; 5906d63fdb69Smrg#else 590755acc8fcSmrgstatic int lt_debug = 0; 5908d63fdb69Smrg#endif 5909d63fdb69Smrg 591055acc8fcSmrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ 5911d63fdb69Smrg 5912d63fdb69Smrgvoid *xmalloc (size_t num); 5913d63fdb69Smrgchar *xstrdup (const char *string); 5914d63fdb69Smrgconst char *base_name (const char *name); 5915d63fdb69Smrgchar *find_executable (const char *wrapper); 5916d63fdb69Smrgchar *chase_symlinks (const char *pathspec); 5917d63fdb69Smrgint make_executable (const char *path); 5918d63fdb69Smrgint check_executable (const char *path); 5919d63fdb69Smrgchar *strendzap (char *str, const char *pat); 592055acc8fcSmrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...); 592155acc8fcSmrgvoid lt_fatal (const char *file, int line, const char *message, ...); 592255acc8fcSmrgstatic const char *nonnull (const char *s); 592355acc8fcSmrgstatic const char *nonempty (const char *s); 5924d63fdb69Smrgvoid lt_setenv (const char *name, const char *value); 5925d63fdb69Smrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end); 5926d63fdb69Smrgvoid lt_update_exe_path (const char *name, const char *value); 5927d63fdb69Smrgvoid lt_update_lib_path (const char *name, const char *value); 592855acc8fcSmrgchar **prepare_spawn (char **argv); 592955acc8fcSmrgvoid lt_dump_script (FILE *f); 5930d63fdb69SmrgEOF 5931d63fdb69Smrg 5932d63fdb69Smrg cat <<EOF 593352fd71cdSmrg#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5) 593452fd71cdSmrg# define externally_visible volatile 593552fd71cdSmrg#else 593652fd71cdSmrg# define externally_visible __attribute__((externally_visible)) volatile 593752fd71cdSmrg#endif 593852fd71cdSmrgexternally_visible const char * MAGIC_EXE = "$magic_exe"; 5939d63fdb69Smrgconst char * LIB_PATH_VARNAME = "$shlibpath_var"; 5940d63fdb69SmrgEOF 5941d63fdb69Smrg 594252fd71cdSmrg if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 594348c85eb7Smrg func_to_host_path "$temp_rpath" 5944d63fdb69Smrg cat <<EOF 594548c85eb7Smrgconst char * LIB_PATH_VALUE = "$func_to_host_path_result"; 59463da084b3SmrgEOF 59473da084b3Smrg else 5948d63fdb69Smrg cat <<"EOF" 5949d63fdb69Smrgconst char * LIB_PATH_VALUE = ""; 5950d63fdb69SmrgEOF 59513da084b3Smrg fi 5952d63fdb69Smrg 5953d63fdb69Smrg if test -n "$dllsearchpath"; then 595448c85eb7Smrg func_to_host_path "$dllsearchpath:" 5955d63fdb69Smrg cat <<EOF 5956d63fdb69Smrgconst char * EXE_PATH_VARNAME = "PATH"; 595748c85eb7Smrgconst char * EXE_PATH_VALUE = "$func_to_host_path_result"; 5958d63fdb69SmrgEOF 59593da084b3Smrg else 5960d63fdb69Smrg cat <<"EOF" 5961d63fdb69Smrgconst char * EXE_PATH_VARNAME = ""; 5962d63fdb69Smrgconst char * EXE_PATH_VALUE = ""; 5963d63fdb69SmrgEOF 59643da084b3Smrg fi 5965d63fdb69Smrg 596652fd71cdSmrg if test yes = "$fast_install"; then 5967d63fdb69Smrg cat <<EOF 5968d63fdb69Smrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */ 5969d63fdb69SmrgEOF 59703da084b3Smrg else 5971d63fdb69Smrg cat <<EOF 5972d63fdb69Smrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */ 5973d63fdb69SmrgEOF 59743da084b3Smrg fi 59753da084b3Smrg 59763da084b3Smrg 5977d63fdb69Smrg cat <<"EOF" 59783da084b3Smrg 5979d63fdb69Smrg#define LTWRAPPER_OPTION_PREFIX "--lt-" 59803da084b3Smrg 5981d63fdb69Smrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX; 5982d63fdb69Smrgstatic const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script"; 598355acc8fcSmrgstatic const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug"; 59843da084b3Smrg 5985d63fdb69Smrgint 5986d63fdb69Smrgmain (int argc, char *argv[]) 5987d63fdb69Smrg{ 5988d63fdb69Smrg char **newargz; 5989d63fdb69Smrg int newargc; 5990d63fdb69Smrg char *tmp_pathspec; 5991d63fdb69Smrg char *actual_cwrapper_path; 5992d63fdb69Smrg char *actual_cwrapper_name; 5993d63fdb69Smrg char *target_name; 5994d63fdb69Smrg char *lt_argv_zero; 599552fd71cdSmrg int rval = 127; 59963da084b3Smrg 5997d63fdb69Smrg int i; 59983da084b3Smrg 5999d63fdb69Smrg program_name = (char *) xstrdup (base_name (argv[0])); 600052fd71cdSmrg newargz = XMALLOC (char *, (size_t) argc + 1); 60013da084b3Smrg 600255acc8fcSmrg /* very simple arg parsing; don't want to rely on getopt 600355acc8fcSmrg * also, copy all non cwrapper options to newargz, except 600455acc8fcSmrg * argz[0], which is handled differently 600555acc8fcSmrg */ 600655acc8fcSmrg newargc=0; 6007d63fdb69Smrg for (i = 1; i < argc; i++) 6008d63fdb69Smrg { 600952fd71cdSmrg if (STREQ (argv[i], dumpscript_opt)) 6010d63fdb69Smrg { 6011d63fdb69SmrgEOF 601252fd71cdSmrg case $host in 6013d63fdb69Smrg *mingw* | *cygwin* ) 6014d63fdb69Smrg # make stdout use "unix" line endings 6015d63fdb69Smrg echo " setmode(1,_O_BINARY);" 6016d63fdb69Smrg ;; 6017d63fdb69Smrg esac 60183da084b3Smrg 6019d63fdb69Smrg cat <<"EOF" 602055acc8fcSmrg lt_dump_script (stdout); 6021d63fdb69Smrg return 0; 6022d63fdb69Smrg } 602352fd71cdSmrg if (STREQ (argv[i], debug_opt)) 602455acc8fcSmrg { 602555acc8fcSmrg lt_debug = 1; 602655acc8fcSmrg continue; 602755acc8fcSmrg } 602852fd71cdSmrg if (STREQ (argv[i], ltwrapper_option_prefix)) 602955acc8fcSmrg { 603055acc8fcSmrg /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX 603155acc8fcSmrg namespace, but it is not one of the ones we know about and 603255acc8fcSmrg have already dealt with, above (inluding dump-script), then 603355acc8fcSmrg report an error. Otherwise, targets might begin to believe 603455acc8fcSmrg they are allowed to use options in the LTWRAPPER_OPTION_PREFIX 603555acc8fcSmrg namespace. The first time any user complains about this, we'll 603655acc8fcSmrg need to make LTWRAPPER_OPTION_PREFIX a configure-time option 603755acc8fcSmrg or a configure.ac-settable value. 603855acc8fcSmrg */ 603955acc8fcSmrg lt_fatal (__FILE__, __LINE__, 604055acc8fcSmrg "unrecognized %s option: '%s'", 604155acc8fcSmrg ltwrapper_option_prefix, argv[i]); 604255acc8fcSmrg } 604355acc8fcSmrg /* otherwise ... */ 604455acc8fcSmrg newargz[++newargc] = xstrdup (argv[i]); 6045d63fdb69Smrg } 604655acc8fcSmrg newargz[++newargc] = NULL; 604755acc8fcSmrg 604855acc8fcSmrgEOF 604955acc8fcSmrg cat <<EOF 605055acc8fcSmrg /* The GNU banner must be the first non-error debug message */ 605152fd71cdSmrg lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE) $VERSION\n"); 605255acc8fcSmrgEOF 605355acc8fcSmrg cat <<"EOF" 605455acc8fcSmrg lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]); 605555acc8fcSmrg lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name); 60563da084b3Smrg 6057d63fdb69Smrg tmp_pathspec = find_executable (argv[0]); 6058d63fdb69Smrg if (tmp_pathspec == NULL) 605955acc8fcSmrg lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]); 606055acc8fcSmrg lt_debugprintf (__FILE__, __LINE__, 606155acc8fcSmrg "(main) found exe (before symlink chase) at: %s\n", 606255acc8fcSmrg tmp_pathspec); 6063d63fdb69Smrg 6064d63fdb69Smrg actual_cwrapper_path = chase_symlinks (tmp_pathspec); 606555acc8fcSmrg lt_debugprintf (__FILE__, __LINE__, 606655acc8fcSmrg "(main) found exe (after symlink chase) at: %s\n", 606755acc8fcSmrg actual_cwrapper_path); 6068d63fdb69Smrg XFREE (tmp_pathspec); 6069d63fdb69Smrg 607055acc8fcSmrg actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path)); 6071d63fdb69Smrg strendzap (actual_cwrapper_path, actual_cwrapper_name); 6072d63fdb69Smrg 6073d63fdb69Smrg /* wrapper name transforms */ 6074d63fdb69Smrg strendzap (actual_cwrapper_name, ".exe"); 6075d63fdb69Smrg tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1); 6076d63fdb69Smrg XFREE (actual_cwrapper_name); 6077d63fdb69Smrg actual_cwrapper_name = tmp_pathspec; 6078d63fdb69Smrg tmp_pathspec = 0; 6079d63fdb69Smrg 6080d63fdb69Smrg /* target_name transforms -- use actual target program name; might have lt- prefix */ 6081d63fdb69Smrg target_name = xstrdup (base_name (TARGET_PROGRAM_NAME)); 6082d63fdb69Smrg strendzap (target_name, ".exe"); 6083d63fdb69Smrg tmp_pathspec = lt_extend_str (target_name, ".exe", 1); 6084d63fdb69Smrg XFREE (target_name); 6085d63fdb69Smrg target_name = tmp_pathspec; 6086d63fdb69Smrg tmp_pathspec = 0; 6087d63fdb69Smrg 608855acc8fcSmrg lt_debugprintf (__FILE__, __LINE__, 608955acc8fcSmrg "(main) libtool target name: %s\n", 609055acc8fcSmrg target_name); 6091d63fdb69SmrgEOF 60923da084b3Smrg 6093d63fdb69Smrg cat <<EOF 6094d63fdb69Smrg newargz[0] = 6095d63fdb69Smrg XMALLOC (char, (strlen (actual_cwrapper_path) + 6096d63fdb69Smrg strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1)); 6097d63fdb69Smrg strcpy (newargz[0], actual_cwrapper_path); 6098d63fdb69Smrg strcat (newargz[0], "$objdir"); 6099d63fdb69Smrg strcat (newargz[0], "/"); 6100d63fdb69SmrgEOF 61013da084b3Smrg 6102d63fdb69Smrg cat <<"EOF" 6103d63fdb69Smrg /* stop here, and copy so we don't have to do this twice */ 6104d63fdb69Smrg tmp_pathspec = xstrdup (newargz[0]); 61053da084b3Smrg 6106d63fdb69Smrg /* do NOT want the lt- prefix here, so use actual_cwrapper_name */ 6107d63fdb69Smrg strcat (newargz[0], actual_cwrapper_name); 61083da084b3Smrg 6109d63fdb69Smrg /* DO want the lt- prefix here if it exists, so use target_name */ 6110d63fdb69Smrg lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1); 6111d63fdb69Smrg XFREE (tmp_pathspec); 6112d63fdb69Smrg tmp_pathspec = NULL; 6113d63fdb69SmrgEOF 61143da084b3Smrg 6115d63fdb69Smrg case $host_os in 6116d63fdb69Smrg mingw*) 6117d63fdb69Smrg cat <<"EOF" 6118d63fdb69Smrg { 6119d63fdb69Smrg char* p; 6120d63fdb69Smrg while ((p = strchr (newargz[0], '\\')) != NULL) 6121d63fdb69Smrg { 6122d63fdb69Smrg *p = '/'; 6123d63fdb69Smrg } 6124d63fdb69Smrg while ((p = strchr (lt_argv_zero, '\\')) != NULL) 6125d63fdb69Smrg { 6126d63fdb69Smrg *p = '/'; 6127d63fdb69Smrg } 6128d63fdb69Smrg } 6129d63fdb69SmrgEOF 6130d63fdb69Smrg ;; 6131d63fdb69Smrg esac 61323da084b3Smrg 6133d63fdb69Smrg cat <<"EOF" 6134d63fdb69Smrg XFREE (target_name); 6135d63fdb69Smrg XFREE (actual_cwrapper_path); 6136d63fdb69Smrg XFREE (actual_cwrapper_name); 61373da084b3Smrg 6138d63fdb69Smrg lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */ 6139d63fdb69Smrg lt_setenv ("DUALCASE", "1"); /* for MSK sh */ 614048c85eb7Smrg /* Update the DLL searchpath. EXE_PATH_VALUE ($dllsearchpath) must 614148c85eb7Smrg be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath) 614248c85eb7Smrg because on Windows, both *_VARNAMEs are PATH but uninstalled 614348c85eb7Smrg libraries must come first. */ 6144d63fdb69Smrg lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE); 614548c85eb7Smrg lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE); 61463da084b3Smrg 614755acc8fcSmrg lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n", 614855acc8fcSmrg nonnull (lt_argv_zero)); 6149d63fdb69Smrg for (i = 0; i < newargc; i++) 6150d63fdb69Smrg { 615155acc8fcSmrg lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n", 615255acc8fcSmrg i, nonnull (newargz[i])); 6153d63fdb69Smrg } 61543da084b3Smrg 6155d63fdb69SmrgEOF 61563da084b3Smrg 6157d63fdb69Smrg case $host_os in 6158d63fdb69Smrg mingw*) 6159d63fdb69Smrg cat <<"EOF" 6160d63fdb69Smrg /* execv doesn't actually work on mingw as expected on unix */ 616155acc8fcSmrg newargz = prepare_spawn (newargz); 616252fd71cdSmrg rval = (int) _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz); 6163d63fdb69Smrg if (rval == -1) 6164d63fdb69Smrg { 6165d63fdb69Smrg /* failed to start process */ 616655acc8fcSmrg lt_debugprintf (__FILE__, __LINE__, 616755acc8fcSmrg "(main) failed to launch target \"%s\": %s\n", 616855acc8fcSmrg lt_argv_zero, nonnull (strerror (errno))); 6169d63fdb69Smrg return 127; 6170d63fdb69Smrg } 6171d63fdb69Smrg return rval; 6172d63fdb69SmrgEOF 6173d63fdb69Smrg ;; 6174d63fdb69Smrg *) 6175d63fdb69Smrg cat <<"EOF" 6176d63fdb69Smrg execv (lt_argv_zero, newargz); 6177d63fdb69Smrg return rval; /* =127, but avoids unused variable warning */ 6178d63fdb69SmrgEOF 6179d63fdb69Smrg ;; 6180d63fdb69Smrg esac 61813da084b3Smrg 6182d63fdb69Smrg cat <<"EOF" 6183d63fdb69Smrg} 61843da084b3Smrg 6185d63fdb69Smrgvoid * 6186d63fdb69Smrgxmalloc (size_t num) 6187d63fdb69Smrg{ 6188d63fdb69Smrg void *p = (void *) malloc (num); 6189d63fdb69Smrg if (!p) 619055acc8fcSmrg lt_fatal (__FILE__, __LINE__, "memory exhausted"); 61913da084b3Smrg 6192d63fdb69Smrg return p; 6193d63fdb69Smrg} 61943da084b3Smrg 6195d63fdb69Smrgchar * 6196d63fdb69Smrgxstrdup (const char *string) 6197d63fdb69Smrg{ 6198d63fdb69Smrg return string ? strcpy ((char *) xmalloc (strlen (string) + 1), 6199d63fdb69Smrg string) : NULL; 6200d63fdb69Smrg} 62013da084b3Smrg 6202d63fdb69Smrgconst char * 6203d63fdb69Smrgbase_name (const char *name) 6204d63fdb69Smrg{ 6205d63fdb69Smrg const char *base; 62063da084b3Smrg 620752fd71cdSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 6208d63fdb69Smrg /* Skip over the disk name in MSDOS pathnames. */ 6209d63fdb69Smrg if (isalpha ((unsigned char) name[0]) && name[1] == ':') 6210d63fdb69Smrg name += 2; 6211d63fdb69Smrg#endif 62123da084b3Smrg 6213d63fdb69Smrg for (base = name; *name; name++) 6214d63fdb69Smrg if (IS_DIR_SEPARATOR (*name)) 6215d63fdb69Smrg base = name + 1; 6216d63fdb69Smrg return base; 6217d63fdb69Smrg} 62183da084b3Smrg 6219d63fdb69Smrgint 6220d63fdb69Smrgcheck_executable (const char *path) 6221d63fdb69Smrg{ 6222d63fdb69Smrg struct stat st; 62233da084b3Smrg 622455acc8fcSmrg lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n", 622555acc8fcSmrg nonempty (path)); 6226d63fdb69Smrg if ((!path) || (!*path)) 6227d63fdb69Smrg return 0; 62283da084b3Smrg 6229d63fdb69Smrg if ((stat (path, &st) >= 0) 6230d63fdb69Smrg && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) 6231d63fdb69Smrg return 1; 6232d63fdb69Smrg else 6233d63fdb69Smrg return 0; 6234d63fdb69Smrg} 62353da084b3Smrg 6236d63fdb69Smrgint 6237d63fdb69Smrgmake_executable (const char *path) 6238d63fdb69Smrg{ 6239d63fdb69Smrg int rval = 0; 6240d63fdb69Smrg struct stat st; 62413da084b3Smrg 624255acc8fcSmrg lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", 624355acc8fcSmrg nonempty (path)); 6244d63fdb69Smrg if ((!path) || (!*path)) 6245d63fdb69Smrg return 0; 62463da084b3Smrg 6247d63fdb69Smrg if (stat (path, &st) >= 0) 6248d63fdb69Smrg { 6249d63fdb69Smrg rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); 6250d63fdb69Smrg } 6251d63fdb69Smrg return rval; 6252d63fdb69Smrg} 62533da084b3Smrg 6254d63fdb69Smrg/* Searches for the full path of the wrapper. Returns 6255d63fdb69Smrg newly allocated full path name if found, NULL otherwise 6256d63fdb69Smrg Does not chase symlinks, even on platforms that support them. 6257d63fdb69Smrg*/ 6258d63fdb69Smrgchar * 6259d63fdb69Smrgfind_executable (const char *wrapper) 6260d63fdb69Smrg{ 6261d63fdb69Smrg int has_slash = 0; 6262d63fdb69Smrg const char *p; 6263d63fdb69Smrg const char *p_next; 6264d63fdb69Smrg /* static buffer for getcwd */ 6265d63fdb69Smrg char tmp[LT_PATHMAX + 1]; 626652fd71cdSmrg size_t tmp_len; 6267d63fdb69Smrg char *concat_name; 62683da084b3Smrg 626955acc8fcSmrg lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", 627055acc8fcSmrg nonempty (wrapper)); 62713da084b3Smrg 6272d63fdb69Smrg if ((wrapper == NULL) || (*wrapper == '\0')) 6273d63fdb69Smrg return NULL; 62743da084b3Smrg 6275d63fdb69Smrg /* Absolute path? */ 627652fd71cdSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 6277d63fdb69Smrg if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') 6278d63fdb69Smrg { 6279d63fdb69Smrg concat_name = xstrdup (wrapper); 6280d63fdb69Smrg if (check_executable (concat_name)) 6281d63fdb69Smrg return concat_name; 6282d63fdb69Smrg XFREE (concat_name); 6283d63fdb69Smrg } 6284d63fdb69Smrg else 6285d63fdb69Smrg { 6286d63fdb69Smrg#endif 6287d63fdb69Smrg if (IS_DIR_SEPARATOR (wrapper[0])) 6288d63fdb69Smrg { 6289d63fdb69Smrg concat_name = xstrdup (wrapper); 6290d63fdb69Smrg if (check_executable (concat_name)) 6291d63fdb69Smrg return concat_name; 6292d63fdb69Smrg XFREE (concat_name); 6293d63fdb69Smrg } 629452fd71cdSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 6295d63fdb69Smrg } 6296d63fdb69Smrg#endif 62973da084b3Smrg 6298d63fdb69Smrg for (p = wrapper; *p; p++) 6299d63fdb69Smrg if (*p == '/') 6300d63fdb69Smrg { 6301d63fdb69Smrg has_slash = 1; 6302d63fdb69Smrg break; 6303d63fdb69Smrg } 6304d63fdb69Smrg if (!has_slash) 6305d63fdb69Smrg { 6306d63fdb69Smrg /* no slashes; search PATH */ 6307d63fdb69Smrg const char *path = getenv ("PATH"); 6308d63fdb69Smrg if (path != NULL) 6309d63fdb69Smrg { 6310d63fdb69Smrg for (p = path; *p; p = p_next) 6311d63fdb69Smrg { 6312d63fdb69Smrg const char *q; 6313d63fdb69Smrg size_t p_len; 6314d63fdb69Smrg for (q = p; *q; q++) 6315d63fdb69Smrg if (IS_PATH_SEPARATOR (*q)) 6316d63fdb69Smrg break; 631752fd71cdSmrg p_len = (size_t) (q - p); 6318d63fdb69Smrg p_next = (*q == '\0' ? q : q + 1); 6319d63fdb69Smrg if (p_len == 0) 6320d63fdb69Smrg { 6321d63fdb69Smrg /* empty path: current directory */ 6322d63fdb69Smrg if (getcwd (tmp, LT_PATHMAX) == NULL) 632355acc8fcSmrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 632455acc8fcSmrg nonnull (strerror (errno))); 6325d63fdb69Smrg tmp_len = strlen (tmp); 6326d63fdb69Smrg concat_name = 6327d63fdb69Smrg XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 6328d63fdb69Smrg memcpy (concat_name, tmp, tmp_len); 6329d63fdb69Smrg concat_name[tmp_len] = '/'; 6330d63fdb69Smrg strcpy (concat_name + tmp_len + 1, wrapper); 6331d63fdb69Smrg } 6332d63fdb69Smrg else 6333d63fdb69Smrg { 6334d63fdb69Smrg concat_name = 6335d63fdb69Smrg XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); 6336d63fdb69Smrg memcpy (concat_name, p, p_len); 6337d63fdb69Smrg concat_name[p_len] = '/'; 6338d63fdb69Smrg strcpy (concat_name + p_len + 1, wrapper); 6339d63fdb69Smrg } 6340d63fdb69Smrg if (check_executable (concat_name)) 6341d63fdb69Smrg return concat_name; 6342d63fdb69Smrg XFREE (concat_name); 6343d63fdb69Smrg } 6344d63fdb69Smrg } 6345d63fdb69Smrg /* not found in PATH; assume curdir */ 6346d63fdb69Smrg } 6347d63fdb69Smrg /* Relative path | not found in path: prepend cwd */ 6348d63fdb69Smrg if (getcwd (tmp, LT_PATHMAX) == NULL) 634955acc8fcSmrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 635055acc8fcSmrg nonnull (strerror (errno))); 6351d63fdb69Smrg tmp_len = strlen (tmp); 6352d63fdb69Smrg concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 6353d63fdb69Smrg memcpy (concat_name, tmp, tmp_len); 6354d63fdb69Smrg concat_name[tmp_len] = '/'; 6355d63fdb69Smrg strcpy (concat_name + tmp_len + 1, wrapper); 63563da084b3Smrg 6357d63fdb69Smrg if (check_executable (concat_name)) 6358d63fdb69Smrg return concat_name; 6359d63fdb69Smrg XFREE (concat_name); 6360d63fdb69Smrg return NULL; 6361d63fdb69Smrg} 63623da084b3Smrg 6363d63fdb69Smrgchar * 6364d63fdb69Smrgchase_symlinks (const char *pathspec) 6365d63fdb69Smrg{ 6366d63fdb69Smrg#ifndef S_ISLNK 6367d63fdb69Smrg return xstrdup (pathspec); 6368d63fdb69Smrg#else 6369d63fdb69Smrg char buf[LT_PATHMAX]; 6370d63fdb69Smrg struct stat s; 6371d63fdb69Smrg char *tmp_pathspec = xstrdup (pathspec); 6372d63fdb69Smrg char *p; 6373d63fdb69Smrg int has_symlinks = 0; 6374d63fdb69Smrg while (strlen (tmp_pathspec) && !has_symlinks) 6375d63fdb69Smrg { 637655acc8fcSmrg lt_debugprintf (__FILE__, __LINE__, 637755acc8fcSmrg "checking path component for symlinks: %s\n", 637855acc8fcSmrg tmp_pathspec); 6379d63fdb69Smrg if (lstat (tmp_pathspec, &s) == 0) 6380d63fdb69Smrg { 6381d63fdb69Smrg if (S_ISLNK (s.st_mode) != 0) 6382d63fdb69Smrg { 6383d63fdb69Smrg has_symlinks = 1; 6384d63fdb69Smrg break; 6385d63fdb69Smrg } 63863da084b3Smrg 6387d63fdb69Smrg /* search backwards for last DIR_SEPARATOR */ 6388d63fdb69Smrg p = tmp_pathspec + strlen (tmp_pathspec) - 1; 6389d63fdb69Smrg while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 6390d63fdb69Smrg p--; 6391d63fdb69Smrg if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 6392d63fdb69Smrg { 6393d63fdb69Smrg /* no more DIR_SEPARATORS left */ 6394d63fdb69Smrg break; 6395d63fdb69Smrg } 6396d63fdb69Smrg *p = '\0'; 6397d63fdb69Smrg } 6398d63fdb69Smrg else 6399d63fdb69Smrg { 640055acc8fcSmrg lt_fatal (__FILE__, __LINE__, 640155acc8fcSmrg "error accessing file \"%s\": %s", 640255acc8fcSmrg tmp_pathspec, nonnull (strerror (errno))); 6403d63fdb69Smrg } 6404d63fdb69Smrg } 6405d63fdb69Smrg XFREE (tmp_pathspec); 64063da084b3Smrg 6407d63fdb69Smrg if (!has_symlinks) 6408d63fdb69Smrg { 6409d63fdb69Smrg return xstrdup (pathspec); 6410d63fdb69Smrg } 64113da084b3Smrg 6412d63fdb69Smrg tmp_pathspec = realpath (pathspec, buf); 6413d63fdb69Smrg if (tmp_pathspec == 0) 6414d63fdb69Smrg { 641555acc8fcSmrg lt_fatal (__FILE__, __LINE__, 641655acc8fcSmrg "could not follow symlinks for %s", pathspec); 6417d63fdb69Smrg } 6418d63fdb69Smrg return xstrdup (tmp_pathspec); 6419d63fdb69Smrg#endif 6420d63fdb69Smrg} 64213da084b3Smrg 6422d63fdb69Smrgchar * 6423d63fdb69Smrgstrendzap (char *str, const char *pat) 6424d63fdb69Smrg{ 6425d63fdb69Smrg size_t len, patlen; 64263da084b3Smrg 6427d63fdb69Smrg assert (str != NULL); 6428d63fdb69Smrg assert (pat != NULL); 64293da084b3Smrg 6430d63fdb69Smrg len = strlen (str); 6431d63fdb69Smrg patlen = strlen (pat); 64323da084b3Smrg 6433d63fdb69Smrg if (patlen <= len) 6434d63fdb69Smrg { 6435d63fdb69Smrg str += len - patlen; 643652fd71cdSmrg if (STREQ (str, pat)) 6437d63fdb69Smrg *str = '\0'; 6438d63fdb69Smrg } 6439d63fdb69Smrg return str; 6440d63fdb69Smrg} 64413da084b3Smrg 644255acc8fcSmrgvoid 644355acc8fcSmrglt_debugprintf (const char *file, int line, const char *fmt, ...) 644455acc8fcSmrg{ 644555acc8fcSmrg va_list args; 644655acc8fcSmrg if (lt_debug) 644755acc8fcSmrg { 644855acc8fcSmrg (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); 644955acc8fcSmrg va_start (args, fmt); 645055acc8fcSmrg (void) vfprintf (stderr, fmt, args); 645155acc8fcSmrg va_end (args); 645255acc8fcSmrg } 645355acc8fcSmrg} 645455acc8fcSmrg 6455d63fdb69Smrgstatic void 645655acc8fcSmrglt_error_core (int exit_status, const char *file, 645755acc8fcSmrg int line, const char *mode, 6458d63fdb69Smrg const char *message, va_list ap) 6459d63fdb69Smrg{ 646055acc8fcSmrg fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); 6461d63fdb69Smrg vfprintf (stderr, message, ap); 6462d63fdb69Smrg fprintf (stderr, ".\n"); 64633da084b3Smrg 6464d63fdb69Smrg if (exit_status >= 0) 6465d63fdb69Smrg exit (exit_status); 6466d63fdb69Smrg} 64673da084b3Smrg 6468d63fdb69Smrgvoid 646955acc8fcSmrglt_fatal (const char *file, int line, const char *message, ...) 6470d63fdb69Smrg{ 6471d63fdb69Smrg va_list ap; 6472d63fdb69Smrg va_start (ap, message); 647355acc8fcSmrg lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); 6474d63fdb69Smrg va_end (ap); 6475d63fdb69Smrg} 64763da084b3Smrg 647755acc8fcSmrgstatic const char * 647855acc8fcSmrgnonnull (const char *s) 647955acc8fcSmrg{ 648055acc8fcSmrg return s ? s : "(null)"; 648155acc8fcSmrg} 648255acc8fcSmrg 648355acc8fcSmrgstatic const char * 648455acc8fcSmrgnonempty (const char *s) 648555acc8fcSmrg{ 648655acc8fcSmrg return (s && !*s) ? "(empty)" : nonnull (s); 648755acc8fcSmrg} 648855acc8fcSmrg 6489d63fdb69Smrgvoid 6490d63fdb69Smrglt_setenv (const char *name, const char *value) 6491d63fdb69Smrg{ 649255acc8fcSmrg lt_debugprintf (__FILE__, __LINE__, 649355acc8fcSmrg "(lt_setenv) setting '%s' to '%s'\n", 649455acc8fcSmrg nonnull (name), nonnull (value)); 6495d63fdb69Smrg { 6496d63fdb69Smrg#ifdef HAVE_SETENV 6497d63fdb69Smrg /* always make a copy, for consistency with !HAVE_SETENV */ 6498d63fdb69Smrg char *str = xstrdup (value); 6499d63fdb69Smrg setenv (name, str, 1); 6500d63fdb69Smrg#else 650152fd71cdSmrg size_t len = strlen (name) + 1 + strlen (value) + 1; 6502d63fdb69Smrg char *str = XMALLOC (char, len); 6503d63fdb69Smrg sprintf (str, "%s=%s", name, value); 6504d63fdb69Smrg if (putenv (str) != EXIT_SUCCESS) 6505d63fdb69Smrg { 6506d63fdb69Smrg XFREE (str); 6507d63fdb69Smrg } 6508d63fdb69Smrg#endif 6509d63fdb69Smrg } 6510d63fdb69Smrg} 65113da084b3Smrg 6512d63fdb69Smrgchar * 6513d63fdb69Smrglt_extend_str (const char *orig_value, const char *add, int to_end) 6514d63fdb69Smrg{ 6515d63fdb69Smrg char *new_value; 6516d63fdb69Smrg if (orig_value && *orig_value) 6517d63fdb69Smrg { 651852fd71cdSmrg size_t orig_value_len = strlen (orig_value); 651952fd71cdSmrg size_t add_len = strlen (add); 6520d63fdb69Smrg new_value = XMALLOC (char, add_len + orig_value_len + 1); 6521d63fdb69Smrg if (to_end) 6522d63fdb69Smrg { 6523d63fdb69Smrg strcpy (new_value, orig_value); 6524d63fdb69Smrg strcpy (new_value + orig_value_len, add); 6525d63fdb69Smrg } 6526d63fdb69Smrg else 6527d63fdb69Smrg { 6528d63fdb69Smrg strcpy (new_value, add); 6529d63fdb69Smrg strcpy (new_value + add_len, orig_value); 6530d63fdb69Smrg } 6531d63fdb69Smrg } 6532d63fdb69Smrg else 6533d63fdb69Smrg { 6534d63fdb69Smrg new_value = xstrdup (add); 6535d63fdb69Smrg } 6536d63fdb69Smrg return new_value; 6537d63fdb69Smrg} 65383da084b3Smrg 6539d63fdb69Smrgvoid 6540d63fdb69Smrglt_update_exe_path (const char *name, const char *value) 6541d63fdb69Smrg{ 654255acc8fcSmrg lt_debugprintf (__FILE__, __LINE__, 654355acc8fcSmrg "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", 654455acc8fcSmrg nonnull (name), nonnull (value)); 65453da084b3Smrg 6546d63fdb69Smrg if (name && *name && value && *value) 6547d63fdb69Smrg { 6548d63fdb69Smrg char *new_value = lt_extend_str (getenv (name), value, 0); 6549d63fdb69Smrg /* some systems can't cope with a ':'-terminated path #' */ 655052fd71cdSmrg size_t len = strlen (new_value); 655152fd71cdSmrg while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1])) 6552d63fdb69Smrg { 655352fd71cdSmrg new_value[--len] = '\0'; 6554d63fdb69Smrg } 6555d63fdb69Smrg lt_setenv (name, new_value); 6556d63fdb69Smrg XFREE (new_value); 6557d63fdb69Smrg } 6558d63fdb69Smrg} 65593da084b3Smrg 6560d63fdb69Smrgvoid 6561d63fdb69Smrglt_update_lib_path (const char *name, const char *value) 6562d63fdb69Smrg{ 656355acc8fcSmrg lt_debugprintf (__FILE__, __LINE__, 656455acc8fcSmrg "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", 656555acc8fcSmrg nonnull (name), nonnull (value)); 65663da084b3Smrg 6567d63fdb69Smrg if (name && *name && value && *value) 6568d63fdb69Smrg { 6569d63fdb69Smrg char *new_value = lt_extend_str (getenv (name), value, 0); 6570d63fdb69Smrg lt_setenv (name, new_value); 6571d63fdb69Smrg XFREE (new_value); 6572d63fdb69Smrg } 6573d63fdb69Smrg} 65743da084b3Smrg 657555acc8fcSmrgEOF 657655acc8fcSmrg case $host_os in 657755acc8fcSmrg mingw*) 657855acc8fcSmrg cat <<"EOF" 657955acc8fcSmrg 658055acc8fcSmrg/* Prepares an argument vector before calling spawn(). 658155acc8fcSmrg Note that spawn() does not by itself call the command interpreter 658255acc8fcSmrg (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : 658355acc8fcSmrg ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); 658455acc8fcSmrg GetVersionEx(&v); 658555acc8fcSmrg v.dwPlatformId == VER_PLATFORM_WIN32_NT; 658655acc8fcSmrg }) ? "cmd.exe" : "command.com"). 658755acc8fcSmrg Instead it simply concatenates the arguments, separated by ' ', and calls 658855acc8fcSmrg CreateProcess(). We must quote the arguments since Win32 CreateProcess() 658955acc8fcSmrg interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a 659055acc8fcSmrg special way: 659155acc8fcSmrg - Space and tab are interpreted as delimiters. They are not treated as 659255acc8fcSmrg delimiters if they are surrounded by double quotes: "...". 659355acc8fcSmrg - Unescaped double quotes are removed from the input. Their only effect is 659455acc8fcSmrg that within double quotes, space and tab are treated like normal 659555acc8fcSmrg characters. 659655acc8fcSmrg - Backslashes not followed by double quotes are not special. 659755acc8fcSmrg - But 2*n+1 backslashes followed by a double quote become 659855acc8fcSmrg n backslashes followed by a double quote (n >= 0): 659955acc8fcSmrg \" -> " 660055acc8fcSmrg \\\" -> \" 660155acc8fcSmrg \\\\\" -> \\" 660255acc8fcSmrg */ 660355acc8fcSmrg#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" 660455acc8fcSmrg#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" 660555acc8fcSmrgchar ** 660655acc8fcSmrgprepare_spawn (char **argv) 660755acc8fcSmrg{ 660855acc8fcSmrg size_t argc; 660955acc8fcSmrg char **new_argv; 661055acc8fcSmrg size_t i; 661155acc8fcSmrg 661255acc8fcSmrg /* Count number of arguments. */ 661355acc8fcSmrg for (argc = 0; argv[argc] != NULL; argc++) 661455acc8fcSmrg ; 661555acc8fcSmrg 661655acc8fcSmrg /* Allocate new argument vector. */ 661755acc8fcSmrg new_argv = XMALLOC (char *, argc + 1); 661855acc8fcSmrg 661955acc8fcSmrg /* Put quoted arguments into the new argument vector. */ 662055acc8fcSmrg for (i = 0; i < argc; i++) 662155acc8fcSmrg { 662255acc8fcSmrg const char *string = argv[i]; 662355acc8fcSmrg 662455acc8fcSmrg if (string[0] == '\0') 662555acc8fcSmrg new_argv[i] = xstrdup ("\"\""); 662655acc8fcSmrg else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) 662755acc8fcSmrg { 662855acc8fcSmrg int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); 662955acc8fcSmrg size_t length; 663055acc8fcSmrg unsigned int backslashes; 663155acc8fcSmrg const char *s; 663255acc8fcSmrg char *quoted_string; 663355acc8fcSmrg char *p; 663455acc8fcSmrg 663555acc8fcSmrg length = 0; 663655acc8fcSmrg backslashes = 0; 663755acc8fcSmrg if (quote_around) 663855acc8fcSmrg length++; 663955acc8fcSmrg for (s = string; *s != '\0'; s++) 664055acc8fcSmrg { 664155acc8fcSmrg char c = *s; 664255acc8fcSmrg if (c == '"') 664355acc8fcSmrg length += backslashes + 1; 664455acc8fcSmrg length++; 664555acc8fcSmrg if (c == '\\') 664655acc8fcSmrg backslashes++; 664755acc8fcSmrg else 664855acc8fcSmrg backslashes = 0; 664955acc8fcSmrg } 665055acc8fcSmrg if (quote_around) 665155acc8fcSmrg length += backslashes + 1; 665255acc8fcSmrg 665355acc8fcSmrg quoted_string = XMALLOC (char, length + 1); 665455acc8fcSmrg 665555acc8fcSmrg p = quoted_string; 665655acc8fcSmrg backslashes = 0; 665755acc8fcSmrg if (quote_around) 665855acc8fcSmrg *p++ = '"'; 665955acc8fcSmrg for (s = string; *s != '\0'; s++) 666055acc8fcSmrg { 666155acc8fcSmrg char c = *s; 666255acc8fcSmrg if (c == '"') 666355acc8fcSmrg { 666455acc8fcSmrg unsigned int j; 666555acc8fcSmrg for (j = backslashes + 1; j > 0; j--) 666655acc8fcSmrg *p++ = '\\'; 666755acc8fcSmrg } 666855acc8fcSmrg *p++ = c; 666955acc8fcSmrg if (c == '\\') 667055acc8fcSmrg backslashes++; 667155acc8fcSmrg else 667255acc8fcSmrg backslashes = 0; 667355acc8fcSmrg } 667455acc8fcSmrg if (quote_around) 667555acc8fcSmrg { 667655acc8fcSmrg unsigned int j; 667755acc8fcSmrg for (j = backslashes; j > 0; j--) 667855acc8fcSmrg *p++ = '\\'; 667955acc8fcSmrg *p++ = '"'; 668055acc8fcSmrg } 668155acc8fcSmrg *p = '\0'; 668255acc8fcSmrg 668355acc8fcSmrg new_argv[i] = quoted_string; 668455acc8fcSmrg } 668555acc8fcSmrg else 668655acc8fcSmrg new_argv[i] = (char *) string; 668755acc8fcSmrg } 668855acc8fcSmrg new_argv[argc] = NULL; 668955acc8fcSmrg 669055acc8fcSmrg return new_argv; 669155acc8fcSmrg} 669255acc8fcSmrgEOF 669355acc8fcSmrg ;; 669455acc8fcSmrg esac 669555acc8fcSmrg 669655acc8fcSmrg cat <<"EOF" 669755acc8fcSmrgvoid lt_dump_script (FILE* f) 669855acc8fcSmrg{ 669955acc8fcSmrgEOF 670055acc8fcSmrg func_emit_wrapper yes | 670148c85eb7Smrg $SED -n -e ' 670248c85eb7Smrgs/^\(.\{79\}\)\(..*\)/\1\ 670348c85eb7Smrg\2/ 670448c85eb7Smrgh 670548c85eb7Smrgs/\([\\"]\)/\\\1/g 670648c85eb7Smrgs/$/\\n/ 670748c85eb7Smrgs/\([^\n]*\).*/ fputs ("\1", f);/p 670848c85eb7Smrgg 670948c85eb7SmrgD' 671055acc8fcSmrg cat <<"EOF" 671155acc8fcSmrg} 6712d63fdb69SmrgEOF 6713d63fdb69Smrg} 6714d63fdb69Smrg# end: func_emit_cwrapperexe_src 67153da084b3Smrg 671655acc8fcSmrg# func_win32_import_lib_p ARG 671755acc8fcSmrg# True if ARG is an import lib, as indicated by $file_magic_cmd 671855acc8fcSmrgfunc_win32_import_lib_p () 671955acc8fcSmrg{ 672052fd71cdSmrg $debug_cmd 672152fd71cdSmrg 672255acc8fcSmrg case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in 672355acc8fcSmrg *import*) : ;; 672455acc8fcSmrg *) false ;; 672555acc8fcSmrg esac 672655acc8fcSmrg} 672755acc8fcSmrg 672852fd71cdSmrg# func_suncc_cstd_abi 672952fd71cdSmrg# !!ONLY CALL THIS FOR SUN CC AFTER $compile_command IS FULLY EXPANDED!! 673052fd71cdSmrg# Several compiler flags select an ABI that is incompatible with the 673152fd71cdSmrg# Cstd library. Avoid specifying it if any are in CXXFLAGS. 673252fd71cdSmrgfunc_suncc_cstd_abi () 673352fd71cdSmrg{ 673452fd71cdSmrg $debug_cmd 673552fd71cdSmrg 673652fd71cdSmrg case " $compile_command " in 673752fd71cdSmrg *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*) 673852fd71cdSmrg suncc_use_cstd_abi=no 673952fd71cdSmrg ;; 674052fd71cdSmrg *) 674152fd71cdSmrg suncc_use_cstd_abi=yes 674252fd71cdSmrg ;; 674352fd71cdSmrg esac 674452fd71cdSmrg} 674552fd71cdSmrg 6746d63fdb69Smrg# func_mode_link arg... 6747d63fdb69Smrgfunc_mode_link () 6748d63fdb69Smrg{ 674952fd71cdSmrg $debug_cmd 675052fd71cdSmrg 6751d63fdb69Smrg case $host in 6752d63fdb69Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 6753d63fdb69Smrg # It is impossible to link a dll without this setting, and 6754d63fdb69Smrg # we shouldn't force the makefile maintainer to figure out 675552fd71cdSmrg # what system we are compiling for in order to pass an extra 6756d63fdb69Smrg # flag for every libtool invocation. 6757d63fdb69Smrg # allow_undefined=no 67583da084b3Smrg 6759d63fdb69Smrg # FIXME: Unfortunately, there are problems with the above when trying 676052fd71cdSmrg # to make a dll that has undefined symbols, in which case not 6761d63fdb69Smrg # even a static library is built. For now, we need to specify 6762d63fdb69Smrg # -no-undefined on the libtool link line when we can be certain 6763d63fdb69Smrg # that all symbols are satisfied, otherwise we get a static library. 6764d63fdb69Smrg allow_undefined=yes 6765d63fdb69Smrg ;; 6766d63fdb69Smrg *) 6767d63fdb69Smrg allow_undefined=yes 6768d63fdb69Smrg ;; 6769d63fdb69Smrg esac 6770d63fdb69Smrg libtool_args=$nonopt 6771d63fdb69Smrg base_compile="$nonopt $@" 6772d63fdb69Smrg compile_command=$nonopt 6773d63fdb69Smrg finalize_command=$nonopt 67743da084b3Smrg 6775d63fdb69Smrg compile_rpath= 6776d63fdb69Smrg finalize_rpath= 6777d63fdb69Smrg compile_shlibpath= 6778d63fdb69Smrg finalize_shlibpath= 6779d63fdb69Smrg convenience= 6780d63fdb69Smrg old_convenience= 6781d63fdb69Smrg deplibs= 6782d63fdb69Smrg old_deplibs= 6783d63fdb69Smrg compiler_flags= 6784d63fdb69Smrg linker_flags= 6785d63fdb69Smrg dllsearchpath= 6786d63fdb69Smrg lib_search_path=`pwd` 6787d63fdb69Smrg inst_prefix_dir= 6788d63fdb69Smrg new_inherited_linker_flags= 67893da084b3Smrg 6790d63fdb69Smrg avoid_version=no 679155acc8fcSmrg bindir= 6792d63fdb69Smrg dlfiles= 6793d63fdb69Smrg dlprefiles= 6794d63fdb69Smrg dlself=no 6795d63fdb69Smrg export_dynamic=no 6796d63fdb69Smrg export_symbols= 6797d63fdb69Smrg export_symbols_regex= 6798d63fdb69Smrg generated= 6799d63fdb69Smrg libobjs= 6800d63fdb69Smrg ltlibs= 6801d63fdb69Smrg module=no 6802d63fdb69Smrg no_install=no 6803d63fdb69Smrg objs= 680452fd71cdSmrg os2dllname= 6805d63fdb69Smrg non_pic_objects= 6806d63fdb69Smrg precious_files_regex= 6807d63fdb69Smrg prefer_static_libs=no 680852fd71cdSmrg preload=false 6809d63fdb69Smrg prev= 6810d63fdb69Smrg prevarg= 6811d63fdb69Smrg release= 6812d63fdb69Smrg rpath= 6813d63fdb69Smrg xrpath= 6814d63fdb69Smrg perm_rpath= 6815d63fdb69Smrg temp_rpath= 6816d63fdb69Smrg thread_safe=no 6817d63fdb69Smrg vinfo= 6818d63fdb69Smrg vinfo_number=no 6819d63fdb69Smrg weak_libs= 682052fd71cdSmrg single_module=$wl-single_module 6821d63fdb69Smrg func_infer_tag $base_compile 68223da084b3Smrg 6823d63fdb69Smrg # We need to know -static, to get the right output filenames. 6824d63fdb69Smrg for arg 6825d63fdb69Smrg do 6826d63fdb69Smrg case $arg in 6827d63fdb69Smrg -shared) 682852fd71cdSmrg test yes != "$build_libtool_libs" \ 682952fd71cdSmrg && func_fatal_configuration "cannot build a shared library" 6830d63fdb69Smrg build_old_libs=no 6831d63fdb69Smrg break 6832d63fdb69Smrg ;; 6833d63fdb69Smrg -all-static | -static | -static-libtool-libs) 6834d63fdb69Smrg case $arg in 6835d63fdb69Smrg -all-static) 683652fd71cdSmrg if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then 6837d63fdb69Smrg func_warning "complete static linking is impossible in this configuration" 68383da084b3Smrg fi 6839d63fdb69Smrg if test -n "$link_static_flag"; then 6840d63fdb69Smrg dlopen_self=$dlopen_self_static 68413da084b3Smrg fi 6842d63fdb69Smrg prefer_static_libs=yes 68433da084b3Smrg ;; 6844d63fdb69Smrg -static) 6845d63fdb69Smrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 6846d63fdb69Smrg dlopen_self=$dlopen_self_static 6847d63fdb69Smrg fi 6848d63fdb69Smrg prefer_static_libs=built 6849d63fdb69Smrg ;; 6850d63fdb69Smrg -static-libtool-libs) 6851d63fdb69Smrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 6852d63fdb69Smrg dlopen_self=$dlopen_self_static 6853d63fdb69Smrg fi 6854d63fdb69Smrg prefer_static_libs=yes 68553da084b3Smrg ;; 68563da084b3Smrg esac 6857d63fdb69Smrg build_libtool_libs=no 6858d63fdb69Smrg build_old_libs=yes 6859d63fdb69Smrg break 6860d63fdb69Smrg ;; 6861d63fdb69Smrg esac 6862d63fdb69Smrg done 68633da084b3Smrg 6864d63fdb69Smrg # See if our shared archives depend on static archives. 6865d63fdb69Smrg test -n "$old_archive_from_new_cmds" && build_old_libs=yes 68663da084b3Smrg 6867d63fdb69Smrg # Go through the arguments, transforming them on the way. 6868d63fdb69Smrg while test "$#" -gt 0; do 686952fd71cdSmrg arg=$1 6870d63fdb69Smrg shift 68712a53b785Smrg func_quote_arg pretty,unquoted "$arg" 68722a53b785Smrg qarg=$func_quote_arg_unquoted_result 68732a53b785Smrg func_append libtool_args " $func_quote_arg_result" 68743da084b3Smrg 6875d63fdb69Smrg # If the previous option needs an argument, assign it. 6876d63fdb69Smrg if test -n "$prev"; then 6877d63fdb69Smrg case $prev in 6878d63fdb69Smrg output) 6879d63fdb69Smrg func_append compile_command " @OUTPUT@" 6880d63fdb69Smrg func_append finalize_command " @OUTPUT@" 6881d63fdb69Smrg ;; 6882d63fdb69Smrg esac 68833da084b3Smrg 6884d63fdb69Smrg case $prev in 688555acc8fcSmrg bindir) 688652fd71cdSmrg bindir=$arg 688755acc8fcSmrg prev= 688855acc8fcSmrg continue 688955acc8fcSmrg ;; 6890d63fdb69Smrg dlfiles|dlprefiles) 689152fd71cdSmrg $preload || { 6892d63fdb69Smrg # Add the symbol object into the linking commands. 6893d63fdb69Smrg func_append compile_command " @SYMFILE@" 6894d63fdb69Smrg func_append finalize_command " @SYMFILE@" 689552fd71cdSmrg preload=: 689652fd71cdSmrg } 6897d63fdb69Smrg case $arg in 6898d63fdb69Smrg *.la | *.lo) ;; # We handle these cases below. 6899d63fdb69Smrg force) 690052fd71cdSmrg if test no = "$dlself"; then 6901d63fdb69Smrg dlself=needless 6902d63fdb69Smrg export_dynamic=yes 6903d63fdb69Smrg fi 6904d63fdb69Smrg prev= 6905d63fdb69Smrg continue 6906d63fdb69Smrg ;; 6907d63fdb69Smrg self) 690852fd71cdSmrg if test dlprefiles = "$prev"; then 6909d63fdb69Smrg dlself=yes 691052fd71cdSmrg elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then 6911d63fdb69Smrg dlself=yes 6912d63fdb69Smrg else 6913d63fdb69Smrg dlself=needless 6914d63fdb69Smrg export_dynamic=yes 6915d63fdb69Smrg fi 6916d63fdb69Smrg prev= 6917d63fdb69Smrg continue 69183da084b3Smrg ;; 69193da084b3Smrg *) 692052fd71cdSmrg if test dlfiles = "$prev"; then 692148c85eb7Smrg func_append dlfiles " $arg" 6922d63fdb69Smrg else 692348c85eb7Smrg func_append dlprefiles " $arg" 6924d63fdb69Smrg fi 6925d63fdb69Smrg prev= 6926d63fdb69Smrg continue 69273da084b3Smrg ;; 69283da084b3Smrg esac 6929d63fdb69Smrg ;; 6930d63fdb69Smrg expsyms) 693152fd71cdSmrg export_symbols=$arg 6932d63fdb69Smrg test -f "$arg" \ 693352fd71cdSmrg || func_fatal_error "symbol file '$arg' does not exist" 6934d63fdb69Smrg prev= 6935d63fdb69Smrg continue 6936d63fdb69Smrg ;; 6937d63fdb69Smrg expsyms_regex) 693852fd71cdSmrg export_symbols_regex=$arg 6939d63fdb69Smrg prev= 6940d63fdb69Smrg continue 6941d63fdb69Smrg ;; 6942d63fdb69Smrg framework) 6943d63fdb69Smrg case $host in 6944d63fdb69Smrg *-*-darwin*) 6945d63fdb69Smrg case "$deplibs " in 6946d63fdb69Smrg *" $qarg.ltframework "*) ;; 694748c85eb7Smrg *) func_append deplibs " $qarg.ltframework" # this is fixed later 6948d63fdb69Smrg ;; 6949d63fdb69Smrg esac 6950d63fdb69Smrg ;; 6951d63fdb69Smrg esac 6952d63fdb69Smrg prev= 6953d63fdb69Smrg continue 6954d63fdb69Smrg ;; 6955d63fdb69Smrg inst_prefix) 695652fd71cdSmrg inst_prefix_dir=$arg 695752fd71cdSmrg prev= 695852fd71cdSmrg continue 695952fd71cdSmrg ;; 696052fd71cdSmrg mllvm) 696152fd71cdSmrg # Clang does not use LLVM to link, so we can simply discard any 696252fd71cdSmrg # '-mllvm $arg' options when doing the link step. 6963d63fdb69Smrg prev= 6964d63fdb69Smrg continue 6965d63fdb69Smrg ;; 6966d63fdb69Smrg objectlist) 6967d63fdb69Smrg if test -f "$arg"; then 6968d63fdb69Smrg save_arg=$arg 6969d63fdb69Smrg moreargs= 6970d63fdb69Smrg for fil in `cat "$save_arg"` 6971d63fdb69Smrg do 697248c85eb7Smrg# func_append moreargs " $fil" 6973d63fdb69Smrg arg=$fil 6974d63fdb69Smrg # A libtool-controlled object. 69753da084b3Smrg 6976d63fdb69Smrg # Check to see that this really is a libtool object. 6977d63fdb69Smrg if func_lalib_unsafe_p "$arg"; then 6978d63fdb69Smrg pic_object= 6979d63fdb69Smrg non_pic_object= 69803da084b3Smrg 6981d63fdb69Smrg # Read the .lo file 6982d63fdb69Smrg func_source "$arg" 69833da084b3Smrg 6984d63fdb69Smrg if test -z "$pic_object" || 6985d63fdb69Smrg test -z "$non_pic_object" || 698652fd71cdSmrg test none = "$pic_object" && 698752fd71cdSmrg test none = "$non_pic_object"; then 698852fd71cdSmrg func_fatal_error "cannot find name of object for '$arg'" 6989d63fdb69Smrg fi 69903da084b3Smrg 6991d63fdb69Smrg # Extract subdirectory from the argument. 6992d63fdb69Smrg func_dirname "$arg" "/" "" 699352fd71cdSmrg xdir=$func_dirname_result 69943da084b3Smrg 699552fd71cdSmrg if test none != "$pic_object"; then 6996d63fdb69Smrg # Prepend the subdirectory the object is found in. 699752fd71cdSmrg pic_object=$xdir$pic_object 69983da084b3Smrg 699952fd71cdSmrg if test dlfiles = "$prev"; then 700052fd71cdSmrg if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 700148c85eb7Smrg func_append dlfiles " $pic_object" 7002d63fdb69Smrg prev= 7003d63fdb69Smrg continue 7004d63fdb69Smrg else 7005d63fdb69Smrg # If libtool objects are unsupported, then we need to preload. 7006d63fdb69Smrg prev=dlprefiles 7007d63fdb69Smrg fi 7008d63fdb69Smrg fi 70093da084b3Smrg 7010d63fdb69Smrg # CHECK ME: I think I busted this. -Ossama 701152fd71cdSmrg if test dlprefiles = "$prev"; then 7012d63fdb69Smrg # Preload the old-style object. 701348c85eb7Smrg func_append dlprefiles " $pic_object" 7014d63fdb69Smrg prev= 7015d63fdb69Smrg fi 70163da084b3Smrg 7017d63fdb69Smrg # A PIC object. 7018d63fdb69Smrg func_append libobjs " $pic_object" 701952fd71cdSmrg arg=$pic_object 7020d63fdb69Smrg fi 70213da084b3Smrg 7022d63fdb69Smrg # Non-PIC object. 702352fd71cdSmrg if test none != "$non_pic_object"; then 7024d63fdb69Smrg # Prepend the subdirectory the object is found in. 702552fd71cdSmrg non_pic_object=$xdir$non_pic_object 70263da084b3Smrg 7027d63fdb69Smrg # A standard non-PIC object 7028d63fdb69Smrg func_append non_pic_objects " $non_pic_object" 702952fd71cdSmrg if test -z "$pic_object" || test none = "$pic_object"; then 703052fd71cdSmrg arg=$non_pic_object 7031d63fdb69Smrg fi 7032d63fdb69Smrg else 7033d63fdb69Smrg # If the PIC object exists, use it instead. 7034d63fdb69Smrg # $xdir was prepended to $pic_object above. 703552fd71cdSmrg non_pic_object=$pic_object 7036d63fdb69Smrg func_append non_pic_objects " $non_pic_object" 7037d63fdb69Smrg fi 7038d63fdb69Smrg else 7039d63fdb69Smrg # Only an error if not doing a dry-run. 7040d63fdb69Smrg if $opt_dry_run; then 7041d63fdb69Smrg # Extract subdirectory from the argument. 7042d63fdb69Smrg func_dirname "$arg" "/" "" 704352fd71cdSmrg xdir=$func_dirname_result 7044d63fdb69Smrg 7045d63fdb69Smrg func_lo2o "$arg" 7046d63fdb69Smrg pic_object=$xdir$objdir/$func_lo2o_result 7047d63fdb69Smrg non_pic_object=$xdir$func_lo2o_result 7048d63fdb69Smrg func_append libobjs " $pic_object" 7049d63fdb69Smrg func_append non_pic_objects " $non_pic_object" 7050d63fdb69Smrg else 705152fd71cdSmrg func_fatal_error "'$arg' is not a valid libtool object" 7052d63fdb69Smrg fi 7053d63fdb69Smrg fi 7054d63fdb69Smrg done 7055d63fdb69Smrg else 705652fd71cdSmrg func_fatal_error "link input file '$arg' does not exist" 7057d63fdb69Smrg fi 7058d63fdb69Smrg arg=$save_arg 7059d63fdb69Smrg prev= 7060d63fdb69Smrg continue 7061d63fdb69Smrg ;; 706252fd71cdSmrg os2dllname) 706352fd71cdSmrg os2dllname=$arg 706452fd71cdSmrg prev= 706552fd71cdSmrg continue 706652fd71cdSmrg ;; 7067d63fdb69Smrg precious_regex) 706852fd71cdSmrg precious_files_regex=$arg 7069d63fdb69Smrg prev= 7070d63fdb69Smrg continue 7071d63fdb69Smrg ;; 7072d63fdb69Smrg release) 707352fd71cdSmrg release=-$arg 7074d63fdb69Smrg prev= 7075d63fdb69Smrg continue 7076d63fdb69Smrg ;; 7077d63fdb69Smrg rpath | xrpath) 7078d63fdb69Smrg # We need an absolute path. 7079d63fdb69Smrg case $arg in 7080d63fdb69Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 7081d63fdb69Smrg *) 7082d63fdb69Smrg func_fatal_error "only absolute run-paths are allowed" 7083d63fdb69Smrg ;; 7084d63fdb69Smrg esac 708552fd71cdSmrg if test rpath = "$prev"; then 7086d63fdb69Smrg case "$rpath " in 7087d63fdb69Smrg *" $arg "*) ;; 708848c85eb7Smrg *) func_append rpath " $arg" ;; 7089d63fdb69Smrg esac 7090d63fdb69Smrg else 7091d63fdb69Smrg case "$xrpath " in 7092d63fdb69Smrg *" $arg "*) ;; 709348c85eb7Smrg *) func_append xrpath " $arg" ;; 7094d63fdb69Smrg esac 7095d63fdb69Smrg fi 7096d63fdb69Smrg prev= 7097d63fdb69Smrg continue 7098d63fdb69Smrg ;; 7099d63fdb69Smrg shrext) 710052fd71cdSmrg shrext_cmds=$arg 7101d63fdb69Smrg prev= 7102d63fdb69Smrg continue 7103d63fdb69Smrg ;; 7104d63fdb69Smrg weak) 710548c85eb7Smrg func_append weak_libs " $arg" 7106d63fdb69Smrg prev= 7107d63fdb69Smrg continue 7108d63fdb69Smrg ;; 71092a53b785Smrg xassembler) 71102a53b785Smrg func_append compiler_flags " -Xassembler $qarg" 71112a53b785Smrg prev= 71122a53b785Smrg func_append compile_command " -Xassembler $qarg" 71132a53b785Smrg func_append finalize_command " -Xassembler $qarg" 71142a53b785Smrg continue 71152a53b785Smrg ;; 7116d63fdb69Smrg xcclinker) 711748c85eb7Smrg func_append linker_flags " $qarg" 711848c85eb7Smrg func_append compiler_flags " $qarg" 7119d63fdb69Smrg prev= 7120d63fdb69Smrg func_append compile_command " $qarg" 7121d63fdb69Smrg func_append finalize_command " $qarg" 7122d63fdb69Smrg continue 7123d63fdb69Smrg ;; 7124d63fdb69Smrg xcompiler) 712548c85eb7Smrg func_append compiler_flags " $qarg" 7126d63fdb69Smrg prev= 7127d63fdb69Smrg func_append compile_command " $qarg" 7128d63fdb69Smrg func_append finalize_command " $qarg" 7129d63fdb69Smrg continue 7130d63fdb69Smrg ;; 7131d63fdb69Smrg xlinker) 713248c85eb7Smrg func_append linker_flags " $qarg" 713348c85eb7Smrg func_append compiler_flags " $wl$qarg" 7134d63fdb69Smrg prev= 7135d63fdb69Smrg func_append compile_command " $wl$qarg" 7136d63fdb69Smrg func_append finalize_command " $wl$qarg" 7137d63fdb69Smrg continue 7138d63fdb69Smrg ;; 7139d63fdb69Smrg *) 7140d63fdb69Smrg eval "$prev=\"\$arg\"" 7141d63fdb69Smrg prev= 7142d63fdb69Smrg continue 7143d63fdb69Smrg ;; 71443da084b3Smrg esac 7145d63fdb69Smrg fi # test -n "$prev" 71463da084b3Smrg 714752fd71cdSmrg prevarg=$arg 71483da084b3Smrg 7149d63fdb69Smrg case $arg in 7150d63fdb69Smrg -all-static) 7151d63fdb69Smrg if test -n "$link_static_flag"; then 7152d63fdb69Smrg # See comment for -static flag below, for more details. 7153d63fdb69Smrg func_append compile_command " $link_static_flag" 7154d63fdb69Smrg func_append finalize_command " $link_static_flag" 7155d63fdb69Smrg fi 7156d63fdb69Smrg continue 7157d63fdb69Smrg ;; 71583da084b3Smrg 7159d63fdb69Smrg -allow-undefined) 7160d63fdb69Smrg # FIXME: remove this flag sometime in the future. 716152fd71cdSmrg func_fatal_error "'-allow-undefined' must not be used because it is the default" 7162d63fdb69Smrg ;; 71633da084b3Smrg 7164d63fdb69Smrg -avoid-version) 7165d63fdb69Smrg avoid_version=yes 7166d63fdb69Smrg continue 7167d63fdb69Smrg ;; 71683da084b3Smrg 716955acc8fcSmrg -bindir) 717055acc8fcSmrg prev=bindir 717155acc8fcSmrg continue 717255acc8fcSmrg ;; 717355acc8fcSmrg 7174d63fdb69Smrg -dlopen) 7175d63fdb69Smrg prev=dlfiles 7176d63fdb69Smrg continue 7177d63fdb69Smrg ;; 71783da084b3Smrg 7179d63fdb69Smrg -dlpreopen) 7180d63fdb69Smrg prev=dlprefiles 7181d63fdb69Smrg continue 7182d63fdb69Smrg ;; 71833da084b3Smrg 7184d63fdb69Smrg -export-dynamic) 7185d63fdb69Smrg export_dynamic=yes 7186d63fdb69Smrg continue 7187d63fdb69Smrg ;; 71883da084b3Smrg 7189d63fdb69Smrg -export-symbols | -export-symbols-regex) 7190d63fdb69Smrg if test -n "$export_symbols" || test -n "$export_symbols_regex"; then 7191d63fdb69Smrg func_fatal_error "more than one -exported-symbols argument is not allowed" 7192d63fdb69Smrg fi 719352fd71cdSmrg if test X-export-symbols = "X$arg"; then 7194d63fdb69Smrg prev=expsyms 7195d63fdb69Smrg else 7196d63fdb69Smrg prev=expsyms_regex 7197d63fdb69Smrg fi 7198d63fdb69Smrg continue 7199d63fdb69Smrg ;; 72003da084b3Smrg 7201d63fdb69Smrg -framework) 7202d63fdb69Smrg prev=framework 7203d63fdb69Smrg continue 7204d63fdb69Smrg ;; 72053da084b3Smrg 7206d63fdb69Smrg -inst-prefix-dir) 7207d63fdb69Smrg prev=inst_prefix 7208d63fdb69Smrg continue 7209d63fdb69Smrg ;; 72103da084b3Smrg 7211d63fdb69Smrg # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* 7212d63fdb69Smrg # so, if we see these flags be careful not to treat them like -L 7213d63fdb69Smrg -L[A-Z][A-Z]*:*) 7214d63fdb69Smrg case $with_gcc/$host in 7215d63fdb69Smrg no/*-*-irix* | /*-*-irix*) 7216d63fdb69Smrg func_append compile_command " $arg" 7217d63fdb69Smrg func_append finalize_command " $arg" 7218d63fdb69Smrg ;; 7219d63fdb69Smrg esac 7220d63fdb69Smrg continue 7221d63fdb69Smrg ;; 72223da084b3Smrg 7223d63fdb69Smrg -L*) 722448c85eb7Smrg func_stripname "-L" '' "$arg" 722548c85eb7Smrg if test -z "$func_stripname_result"; then 7226d63fdb69Smrg if test "$#" -gt 0; then 722752fd71cdSmrg func_fatal_error "require no space between '-L' and '$1'" 7228d63fdb69Smrg else 722952fd71cdSmrg func_fatal_error "need path for '-L' option" 7230d63fdb69Smrg fi 7231d63fdb69Smrg fi 723248c85eb7Smrg func_resolve_sysroot "$func_stripname_result" 723348c85eb7Smrg dir=$func_resolve_sysroot_result 7234d63fdb69Smrg # We need an absolute path. 7235d63fdb69Smrg case $dir in 7236d63fdb69Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 7237d63fdb69Smrg *) 7238d63fdb69Smrg absdir=`cd "$dir" && pwd` 7239d63fdb69Smrg test -z "$absdir" && \ 724052fd71cdSmrg func_fatal_error "cannot determine absolute directory name of '$dir'" 724152fd71cdSmrg dir=$absdir 7242d63fdb69Smrg ;; 7243d63fdb69Smrg esac 7244d63fdb69Smrg case "$deplibs " in 724548c85eb7Smrg *" -L$dir "* | *" $arg "*) 724648c85eb7Smrg # Will only happen for absolute or sysroot arguments 724748c85eb7Smrg ;; 7248d63fdb69Smrg *) 724948c85eb7Smrg # Preserve sysroot, but never include relative directories 725048c85eb7Smrg case $dir in 725148c85eb7Smrg [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; 725248c85eb7Smrg *) func_append deplibs " -L$dir" ;; 725348c85eb7Smrg esac 725448c85eb7Smrg func_append lib_search_path " $dir" 7255d63fdb69Smrg ;; 7256d63fdb69Smrg esac 7257d63fdb69Smrg case $host in 7258d63fdb69Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 725955acc8fcSmrg testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` 7260d63fdb69Smrg case :$dllsearchpath: in 7261d63fdb69Smrg *":$dir:"*) ;; 7262d63fdb69Smrg ::) dllsearchpath=$dir;; 726348c85eb7Smrg *) func_append dllsearchpath ":$dir";; 7264d63fdb69Smrg esac 7265d63fdb69Smrg case :$dllsearchpath: in 7266d63fdb69Smrg *":$testbindir:"*) ;; 7267d63fdb69Smrg ::) dllsearchpath=$testbindir;; 726848c85eb7Smrg *) func_append dllsearchpath ":$testbindir";; 7269d63fdb69Smrg esac 7270d63fdb69Smrg ;; 7271d63fdb69Smrg esac 7272d63fdb69Smrg continue 7273d63fdb69Smrg ;; 72743da084b3Smrg 7275d63fdb69Smrg -l*) 727652fd71cdSmrg if test X-lc = "X$arg" || test X-lm = "X$arg"; then 7277d63fdb69Smrg case $host in 727855acc8fcSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) 7279d63fdb69Smrg # These systems don't actually have a C or math library (as such) 7280d63fdb69Smrg continue 7281d63fdb69Smrg ;; 7282d63fdb69Smrg *-*-os2*) 7283d63fdb69Smrg # These systems don't actually have a C library (as such) 728452fd71cdSmrg test X-lc = "X$arg" && continue 7285d63fdb69Smrg ;; 72862a53b785Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig* | *-*-midnightbsd*) 7287d63fdb69Smrg # Do not include libc due to us having libc/libc_r. 728852fd71cdSmrg test X-lc = "X$arg" && continue 7289d63fdb69Smrg ;; 7290d63fdb69Smrg *-*-rhapsody* | *-*-darwin1.[012]) 7291d63fdb69Smrg # Rhapsody C and math libraries are in the System framework 729248c85eb7Smrg func_append deplibs " System.ltframework" 7293d63fdb69Smrg continue 7294d63fdb69Smrg ;; 7295d63fdb69Smrg *-*-sco3.2v5* | *-*-sco5v6*) 7296d63fdb69Smrg # Causes problems with __ctype 729752fd71cdSmrg test X-lc = "X$arg" && continue 7298d63fdb69Smrg ;; 7299d63fdb69Smrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 7300d63fdb69Smrg # Compiler inserts libc in the correct place for threads to work 730152fd71cdSmrg test X-lc = "X$arg" && continue 7302d63fdb69Smrg ;; 7303d63fdb69Smrg esac 730452fd71cdSmrg elif test X-lc_r = "X$arg"; then 7305d63fdb69Smrg case $host in 73062a53b785Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig* | *-*-midnightbsd*) 7307d63fdb69Smrg # Do not include libc_r directly, use -pthread flag. 7308d63fdb69Smrg continue 7309d63fdb69Smrg ;; 7310d63fdb69Smrg esac 7311d63fdb69Smrg fi 731248c85eb7Smrg func_append deplibs " $arg" 7313d63fdb69Smrg continue 7314d63fdb69Smrg ;; 73153da084b3Smrg 731652fd71cdSmrg -mllvm) 731752fd71cdSmrg prev=mllvm 731852fd71cdSmrg continue 731952fd71cdSmrg ;; 732052fd71cdSmrg 7321d63fdb69Smrg -module) 7322d63fdb69Smrg module=yes 7323d63fdb69Smrg continue 7324d63fdb69Smrg ;; 73253da084b3Smrg 7326d63fdb69Smrg # Tru64 UNIX uses -model [arg] to determine the layout of C++ 7327d63fdb69Smrg # classes, name mangling, and exception handling. 7328d63fdb69Smrg # Darwin uses the -arch flag to determine output architecture. 732948c85eb7Smrg -model|-arch|-isysroot|--sysroot) 733048c85eb7Smrg func_append compiler_flags " $arg" 7331d63fdb69Smrg func_append compile_command " $arg" 7332d63fdb69Smrg func_append finalize_command " $arg" 7333d63fdb69Smrg prev=xcompiler 7334d63fdb69Smrg continue 7335d63fdb69Smrg ;; 73362a53b785Smrg # Solaris ld rejects as of 11.4. Refer to Oracle bug 22985199. 73372a53b785Smrg -pthread) 73382a53b785Smrg case $host in 73392a53b785Smrg *solaris2*) ;; 73402a53b785Smrg *) 73412a53b785Smrg case "$new_inherited_linker_flags " in 73422a53b785Smrg *" $arg "*) ;; 73432a53b785Smrg * ) func_append new_inherited_linker_flags " $arg" ;; 73442a53b785Smrg esac 73452a53b785Smrg ;; 73462a53b785Smrg esac 73472a53b785Smrg continue 73482a53b785Smrg ;; 73492a53b785Smrg -mt|-mthreads|-kthread|-Kthread|-pthreads|--thread-safe \ 735048c85eb7Smrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 735148c85eb7Smrg func_append compiler_flags " $arg" 7352d63fdb69Smrg func_append compile_command " $arg" 7353d63fdb69Smrg func_append finalize_command " $arg" 7354d63fdb69Smrg case "$new_inherited_linker_flags " in 7355d63fdb69Smrg *" $arg "*) ;; 735648c85eb7Smrg * ) func_append new_inherited_linker_flags " $arg" ;; 7357d63fdb69Smrg esac 7358d63fdb69Smrg continue 7359d63fdb69Smrg ;; 73603da084b3Smrg 7361d63fdb69Smrg -multi_module) 736252fd71cdSmrg single_module=$wl-multi_module 7363d63fdb69Smrg continue 7364d63fdb69Smrg ;; 73653da084b3Smrg 7366d63fdb69Smrg -no-fast-install) 7367d63fdb69Smrg fast_install=no 7368d63fdb69Smrg continue 7369d63fdb69Smrg ;; 73703da084b3Smrg 7371d63fdb69Smrg -no-install) 7372d63fdb69Smrg case $host in 7373d63fdb69Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) 7374d63fdb69Smrg # The PATH hackery in wrapper scripts is required on Windows 7375d63fdb69Smrg # and Darwin in order for the loader to find any dlls it needs. 737652fd71cdSmrg func_warning "'-no-install' is ignored for $host" 737752fd71cdSmrg func_warning "assuming '-no-fast-install' instead" 7378d63fdb69Smrg fast_install=no 7379d63fdb69Smrg ;; 7380d63fdb69Smrg *) no_install=yes ;; 7381d63fdb69Smrg esac 7382d63fdb69Smrg continue 7383d63fdb69Smrg ;; 73843da084b3Smrg 7385d63fdb69Smrg -no-undefined) 7386d63fdb69Smrg allow_undefined=no 7387d63fdb69Smrg continue 7388d63fdb69Smrg ;; 73893da084b3Smrg 7390d63fdb69Smrg -objectlist) 7391d63fdb69Smrg prev=objectlist 7392d63fdb69Smrg continue 7393d63fdb69Smrg ;; 73943da084b3Smrg 739552fd71cdSmrg -os2dllname) 739652fd71cdSmrg prev=os2dllname 739752fd71cdSmrg continue 739852fd71cdSmrg ;; 739952fd71cdSmrg 7400d63fdb69Smrg -o) prev=output ;; 74013da084b3Smrg 7402d63fdb69Smrg -precious-files-regex) 7403d63fdb69Smrg prev=precious_regex 7404d63fdb69Smrg continue 7405d63fdb69Smrg ;; 74063da084b3Smrg 7407d63fdb69Smrg -release) 7408d63fdb69Smrg prev=release 7409d63fdb69Smrg continue 7410d63fdb69Smrg ;; 74113da084b3Smrg 7412d63fdb69Smrg -rpath) 7413d63fdb69Smrg prev=rpath 7414d63fdb69Smrg continue 7415d63fdb69Smrg ;; 74163da084b3Smrg 7417d63fdb69Smrg -R) 7418d63fdb69Smrg prev=xrpath 7419d63fdb69Smrg continue 7420d63fdb69Smrg ;; 74213da084b3Smrg 7422d63fdb69Smrg -R*) 7423d63fdb69Smrg func_stripname '-R' '' "$arg" 7424d63fdb69Smrg dir=$func_stripname_result 7425d63fdb69Smrg # We need an absolute path. 7426d63fdb69Smrg case $dir in 7427d63fdb69Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 742848c85eb7Smrg =*) 742948c85eb7Smrg func_stripname '=' '' "$dir" 743048c85eb7Smrg dir=$lt_sysroot$func_stripname_result 743148c85eb7Smrg ;; 7432d63fdb69Smrg *) 7433d63fdb69Smrg func_fatal_error "only absolute run-paths are allowed" 7434d63fdb69Smrg ;; 7435d63fdb69Smrg esac 7436d63fdb69Smrg case "$xrpath " in 7437d63fdb69Smrg *" $dir "*) ;; 743848c85eb7Smrg *) func_append xrpath " $dir" ;; 7439d63fdb69Smrg esac 7440d63fdb69Smrg continue 7441d63fdb69Smrg ;; 74423da084b3Smrg 7443d63fdb69Smrg -shared) 7444d63fdb69Smrg # The effects of -shared are defined in a previous loop. 7445d63fdb69Smrg continue 7446d63fdb69Smrg ;; 74473da084b3Smrg 7448d63fdb69Smrg -shrext) 7449d63fdb69Smrg prev=shrext 7450d63fdb69Smrg continue 7451d63fdb69Smrg ;; 74523da084b3Smrg 7453d63fdb69Smrg -static | -static-libtool-libs) 7454d63fdb69Smrg # The effects of -static are defined in a previous loop. 7455d63fdb69Smrg # We used to do the same as -all-static on platforms that 7456d63fdb69Smrg # didn't have a PIC flag, but the assumption that the effects 7457d63fdb69Smrg # would be equivalent was wrong. It would break on at least 7458d63fdb69Smrg # Digital Unix and AIX. 7459d63fdb69Smrg continue 7460d63fdb69Smrg ;; 74613da084b3Smrg 7462d63fdb69Smrg -thread-safe) 7463d63fdb69Smrg thread_safe=yes 7464d63fdb69Smrg continue 7465d63fdb69Smrg ;; 74663da084b3Smrg 7467d63fdb69Smrg -version-info) 7468d63fdb69Smrg prev=vinfo 7469d63fdb69Smrg continue 7470d63fdb69Smrg ;; 74713da084b3Smrg 7472d63fdb69Smrg -version-number) 7473d63fdb69Smrg prev=vinfo 7474d63fdb69Smrg vinfo_number=yes 7475d63fdb69Smrg continue 7476d63fdb69Smrg ;; 74773da084b3Smrg 7478d63fdb69Smrg -weak) 7479d63fdb69Smrg prev=weak 7480d63fdb69Smrg continue 7481d63fdb69Smrg ;; 74823da084b3Smrg 7483d63fdb69Smrg -Wc,*) 7484d63fdb69Smrg func_stripname '-Wc,' '' "$arg" 7485d63fdb69Smrg args=$func_stripname_result 7486d63fdb69Smrg arg= 748752fd71cdSmrg save_ifs=$IFS; IFS=, 7488d63fdb69Smrg for flag in $args; do 748952fd71cdSmrg IFS=$save_ifs 74902a53b785Smrg func_quote_arg pretty "$flag" 74912a53b785Smrg func_append arg " $func_quote_arg_result" 74922a53b785Smrg func_append compiler_flags " $func_quote_arg_result" 7493d63fdb69Smrg done 749452fd71cdSmrg IFS=$save_ifs 7495d63fdb69Smrg func_stripname ' ' '' "$arg" 7496d63fdb69Smrg arg=$func_stripname_result 7497d63fdb69Smrg ;; 74983da084b3Smrg 7499d63fdb69Smrg -Wl,*) 7500d63fdb69Smrg func_stripname '-Wl,' '' "$arg" 7501d63fdb69Smrg args=$func_stripname_result 7502d63fdb69Smrg arg= 750352fd71cdSmrg save_ifs=$IFS; IFS=, 7504d63fdb69Smrg for flag in $args; do 750552fd71cdSmrg IFS=$save_ifs 75062a53b785Smrg func_quote_arg pretty "$flag" 75072a53b785Smrg func_append arg " $wl$func_quote_arg_result" 75082a53b785Smrg func_append compiler_flags " $wl$func_quote_arg_result" 75092a53b785Smrg func_append linker_flags " $func_quote_arg_result" 7510d63fdb69Smrg done 751152fd71cdSmrg IFS=$save_ifs 7512d63fdb69Smrg func_stripname ' ' '' "$arg" 7513d63fdb69Smrg arg=$func_stripname_result 7514d63fdb69Smrg ;; 75153da084b3Smrg 75162a53b785Smrg -Xassembler) 75172a53b785Smrg prev=xassembler 75182a53b785Smrg continue 75192a53b785Smrg ;; 75202a53b785Smrg 7521d63fdb69Smrg -Xcompiler) 7522d63fdb69Smrg prev=xcompiler 7523d63fdb69Smrg continue 7524d63fdb69Smrg ;; 75253da084b3Smrg 7526d63fdb69Smrg -Xlinker) 7527d63fdb69Smrg prev=xlinker 7528d63fdb69Smrg continue 7529d63fdb69Smrg ;; 75303da084b3Smrg 7531d63fdb69Smrg -XCClinker) 7532d63fdb69Smrg prev=xcclinker 7533d63fdb69Smrg continue 7534d63fdb69Smrg ;; 75353da084b3Smrg 7536d63fdb69Smrg # -msg_* for osf cc 7537d63fdb69Smrg -msg_*) 75382a53b785Smrg func_quote_arg pretty "$arg" 75392a53b785Smrg arg=$func_quote_arg_result 7540d63fdb69Smrg ;; 75413da084b3Smrg 754255acc8fcSmrg # Flags to be passed through unchanged, with rationale: 754355acc8fcSmrg # -64, -mips[0-9] enable 64-bit mode for the SGI compiler 754455acc8fcSmrg # -r[0-9][0-9]* specify processor for the SGI compiler 754555acc8fcSmrg # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler 754655acc8fcSmrg # +DA*, +DD* enable 64-bit mode for the HP compiler 754755acc8fcSmrg # -q* compiler args for the IBM compiler 754855acc8fcSmrg # -m*, -t[45]*, -txscale* architecture-specific flags for GCC 754955acc8fcSmrg # -F/path path to uninstalled frameworks, gcc on darwin 755055acc8fcSmrg # -p, -pg, --coverage, -fprofile-* profiling flags for GCC 755152fd71cdSmrg # -fstack-protector* stack protector flags for GCC 755255acc8fcSmrg # @file GCC response files 755355acc8fcSmrg # -tp=* Portland pgcc target processor selection 755448c85eb7Smrg # --sysroot=* for sysroot support 755552fd71cdSmrg # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization 75562a53b785Smrg # -specs=* GCC specs files 755752fd71cdSmrg # -stdlib=* select c++ std lib with clang 75582a53b785Smrg # -fsanitize=* Clang/GCC memory and address sanitizer 75592a53b785Smrg # -fuse-ld=* Linker select flags for GCC 75602a53b785Smrg # -Wa,* Pass flags directly to the assembler 7561d63fdb69Smrg -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ 756248c85eb7Smrg -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ 75632a53b785Smrg -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*| \ 75642a53b785Smrg -specs=*|-fsanitize=*|-fuse-ld=*|-Wa,*) 75652a53b785Smrg func_quote_arg pretty "$arg" 75662a53b785Smrg arg=$func_quote_arg_result 7567d63fdb69Smrg func_append compile_command " $arg" 7568d63fdb69Smrg func_append finalize_command " $arg" 756948c85eb7Smrg func_append compiler_flags " $arg" 7570d63fdb69Smrg continue 7571d63fdb69Smrg ;; 75723da084b3Smrg 757352fd71cdSmrg -Z*) 757452fd71cdSmrg if test os2 = "`expr $host : '.*\(os2\)'`"; then 757552fd71cdSmrg # OS/2 uses -Zxxx to specify OS/2-specific options 757652fd71cdSmrg compiler_flags="$compiler_flags $arg" 757752fd71cdSmrg func_append compile_command " $arg" 757852fd71cdSmrg func_append finalize_command " $arg" 757952fd71cdSmrg case $arg in 758052fd71cdSmrg -Zlinker | -Zstack) 758152fd71cdSmrg prev=xcompiler 758252fd71cdSmrg ;; 758352fd71cdSmrg esac 758452fd71cdSmrg continue 758552fd71cdSmrg else 758652fd71cdSmrg # Otherwise treat like 'Some other compiler flag' below 75872a53b785Smrg func_quote_arg pretty "$arg" 75882a53b785Smrg arg=$func_quote_arg_result 758952fd71cdSmrg fi 759052fd71cdSmrg ;; 759152fd71cdSmrg 7592d63fdb69Smrg # Some other compiler flag. 7593d63fdb69Smrg -* | +*) 75942a53b785Smrg func_quote_arg pretty "$arg" 75952a53b785Smrg arg=$func_quote_arg_result 7596d63fdb69Smrg ;; 75973da084b3Smrg 7598d63fdb69Smrg *.$objext) 7599d63fdb69Smrg # A standard object. 760048c85eb7Smrg func_append objs " $arg" 7601d63fdb69Smrg ;; 76023da084b3Smrg 7603d63fdb69Smrg *.lo) 7604d63fdb69Smrg # A libtool-controlled object. 76053da084b3Smrg 7606d63fdb69Smrg # Check to see that this really is a libtool object. 7607d63fdb69Smrg if func_lalib_unsafe_p "$arg"; then 7608d63fdb69Smrg pic_object= 7609d63fdb69Smrg non_pic_object= 7610d63fdb69Smrg 7611d63fdb69Smrg # Read the .lo file 7612d63fdb69Smrg func_source "$arg" 7613d63fdb69Smrg 7614d63fdb69Smrg if test -z "$pic_object" || 7615d63fdb69Smrg test -z "$non_pic_object" || 761652fd71cdSmrg test none = "$pic_object" && 761752fd71cdSmrg test none = "$non_pic_object"; then 761852fd71cdSmrg func_fatal_error "cannot find name of object for '$arg'" 7619d63fdb69Smrg fi 7620d63fdb69Smrg 7621d63fdb69Smrg # Extract subdirectory from the argument. 7622d63fdb69Smrg func_dirname "$arg" "/" "" 762352fd71cdSmrg xdir=$func_dirname_result 7624d63fdb69Smrg 762552fd71cdSmrg test none = "$pic_object" || { 7626d63fdb69Smrg # Prepend the subdirectory the object is found in. 762752fd71cdSmrg pic_object=$xdir$pic_object 7628d63fdb69Smrg 762952fd71cdSmrg if test dlfiles = "$prev"; then 763052fd71cdSmrg if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 763148c85eb7Smrg func_append dlfiles " $pic_object" 7632d63fdb69Smrg prev= 7633d63fdb69Smrg continue 7634d63fdb69Smrg else 7635d63fdb69Smrg # If libtool objects are unsupported, then we need to preload. 7636d63fdb69Smrg prev=dlprefiles 7637d63fdb69Smrg fi 7638d63fdb69Smrg fi 7639d63fdb69Smrg 7640d63fdb69Smrg # CHECK ME: I think I busted this. -Ossama 764152fd71cdSmrg if test dlprefiles = "$prev"; then 7642d63fdb69Smrg # Preload the old-style object. 764348c85eb7Smrg func_append dlprefiles " $pic_object" 7644d63fdb69Smrg prev= 7645d63fdb69Smrg fi 7646d63fdb69Smrg 7647d63fdb69Smrg # A PIC object. 7648d63fdb69Smrg func_append libobjs " $pic_object" 764952fd71cdSmrg arg=$pic_object 765052fd71cdSmrg } 7651d63fdb69Smrg 7652d63fdb69Smrg # Non-PIC object. 765352fd71cdSmrg if test none != "$non_pic_object"; then 7654d63fdb69Smrg # Prepend the subdirectory the object is found in. 765552fd71cdSmrg non_pic_object=$xdir$non_pic_object 7656d63fdb69Smrg 7657d63fdb69Smrg # A standard non-PIC object 7658d63fdb69Smrg func_append non_pic_objects " $non_pic_object" 765952fd71cdSmrg if test -z "$pic_object" || test none = "$pic_object"; then 766052fd71cdSmrg arg=$non_pic_object 7661d63fdb69Smrg fi 7662d63fdb69Smrg else 7663d63fdb69Smrg # If the PIC object exists, use it instead. 7664d63fdb69Smrg # $xdir was prepended to $pic_object above. 766552fd71cdSmrg non_pic_object=$pic_object 7666d63fdb69Smrg func_append non_pic_objects " $non_pic_object" 7667d63fdb69Smrg fi 7668d63fdb69Smrg else 7669d63fdb69Smrg # Only an error if not doing a dry-run. 7670d63fdb69Smrg if $opt_dry_run; then 7671d63fdb69Smrg # Extract subdirectory from the argument. 7672d63fdb69Smrg func_dirname "$arg" "/" "" 767352fd71cdSmrg xdir=$func_dirname_result 7674d63fdb69Smrg 7675d63fdb69Smrg func_lo2o "$arg" 7676d63fdb69Smrg pic_object=$xdir$objdir/$func_lo2o_result 7677d63fdb69Smrg non_pic_object=$xdir$func_lo2o_result 7678d63fdb69Smrg func_append libobjs " $pic_object" 7679d63fdb69Smrg func_append non_pic_objects " $non_pic_object" 7680d63fdb69Smrg else 768152fd71cdSmrg func_fatal_error "'$arg' is not a valid libtool object" 7682d63fdb69Smrg fi 7683d63fdb69Smrg fi 7684d63fdb69Smrg ;; 7685d63fdb69Smrg 7686d63fdb69Smrg *.$libext) 7687d63fdb69Smrg # An archive. 768848c85eb7Smrg func_append deplibs " $arg" 768948c85eb7Smrg func_append old_deplibs " $arg" 7690d63fdb69Smrg continue 7691d63fdb69Smrg ;; 7692d63fdb69Smrg 7693d63fdb69Smrg *.la) 7694d63fdb69Smrg # A libtool-controlled library. 7695d63fdb69Smrg 769648c85eb7Smrg func_resolve_sysroot "$arg" 769752fd71cdSmrg if test dlfiles = "$prev"; then 7698d63fdb69Smrg # This library was specified with -dlopen. 769948c85eb7Smrg func_append dlfiles " $func_resolve_sysroot_result" 7700d63fdb69Smrg prev= 770152fd71cdSmrg elif test dlprefiles = "$prev"; then 7702d63fdb69Smrg # The library was specified with -dlpreopen. 770348c85eb7Smrg func_append dlprefiles " $func_resolve_sysroot_result" 7704d63fdb69Smrg prev= 7705d63fdb69Smrg else 770648c85eb7Smrg func_append deplibs " $func_resolve_sysroot_result" 7707d63fdb69Smrg fi 7708d63fdb69Smrg continue 7709d63fdb69Smrg ;; 7710d63fdb69Smrg 7711d63fdb69Smrg # Some other compiler argument. 7712d63fdb69Smrg *) 7713d63fdb69Smrg # Unknown arguments in both finalize_command and compile_command need 7714d63fdb69Smrg # to be aesthetically quoted because they are evaled later. 77152a53b785Smrg func_quote_arg pretty "$arg" 77162a53b785Smrg arg=$func_quote_arg_result 7717d63fdb69Smrg ;; 7718d63fdb69Smrg esac # arg 7719d63fdb69Smrg 7720d63fdb69Smrg # Now actually substitute the argument into the commands. 7721d63fdb69Smrg if test -n "$arg"; then 7722d63fdb69Smrg func_append compile_command " $arg" 7723d63fdb69Smrg func_append finalize_command " $arg" 7724d63fdb69Smrg fi 7725d63fdb69Smrg done # argument parsing loop 7726d63fdb69Smrg 7727d63fdb69Smrg test -n "$prev" && \ 772852fd71cdSmrg func_fatal_help "the '$prevarg' option requires an argument" 7729d63fdb69Smrg 773052fd71cdSmrg if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then 7731d63fdb69Smrg eval arg=\"$export_dynamic_flag_spec\" 7732d63fdb69Smrg func_append compile_command " $arg" 7733d63fdb69Smrg func_append finalize_command " $arg" 7734d63fdb69Smrg fi 7735d63fdb69Smrg 7736d63fdb69Smrg oldlibs= 7737d63fdb69Smrg # calculate the name of the file, without its directory 7738d63fdb69Smrg func_basename "$output" 773952fd71cdSmrg outputname=$func_basename_result 774052fd71cdSmrg libobjs_save=$libobjs 7741d63fdb69Smrg 7742d63fdb69Smrg if test -n "$shlibpath_var"; then 7743d63fdb69Smrg # get the directories listed in $shlibpath_var 774452fd71cdSmrg eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\` 77453da084b3Smrg else 7746d63fdb69Smrg shlib_search_path= 77473da084b3Smrg fi 7748d63fdb69Smrg eval sys_lib_search_path=\"$sys_lib_search_path_spec\" 7749d63fdb69Smrg eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" 77503da084b3Smrg 775152fd71cdSmrg # Definition is injected by LT_CONFIG during libtool generation. 775252fd71cdSmrg func_munge_path_list sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH" 775352fd71cdSmrg 7754d63fdb69Smrg func_dirname "$output" "/" "" 775552fd71cdSmrg output_objdir=$func_dirname_result$objdir 775648c85eb7Smrg func_to_tool_file "$output_objdir/" 775748c85eb7Smrg tool_output_objdir=$func_to_tool_file_result 7758d63fdb69Smrg # Create the object directory. 7759d63fdb69Smrg func_mkdir_p "$output_objdir" 77603da084b3Smrg 7761d63fdb69Smrg # Determine the type of output 7762d63fdb69Smrg case $output in 7763d63fdb69Smrg "") 7764d63fdb69Smrg func_fatal_help "you must specify an output file" 7765d63fdb69Smrg ;; 7766d63fdb69Smrg *.$libext) linkmode=oldlib ;; 7767d63fdb69Smrg *.lo | *.$objext) linkmode=obj ;; 7768d63fdb69Smrg *.la) linkmode=lib ;; 7769d63fdb69Smrg *) linkmode=prog ;; # Anything else should be a program. 7770d63fdb69Smrg esac 7771d63fdb69Smrg 7772d63fdb69Smrg specialdeplibs= 7773d63fdb69Smrg 7774d63fdb69Smrg libs= 7775d63fdb69Smrg # Find all interdependent deplibs by searching for libraries 7776d63fdb69Smrg # that are linked more than once (e.g. -la -lb -la) 7777d63fdb69Smrg for deplib in $deplibs; do 777852fd71cdSmrg if $opt_preserve_dup_deps; then 7779d63fdb69Smrg case "$libs " in 778048c85eb7Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 7781d63fdb69Smrg esac 7782d63fdb69Smrg fi 778348c85eb7Smrg func_append libs " $deplib" 7784d63fdb69Smrg done 7785d63fdb69Smrg 778652fd71cdSmrg if test lib = "$linkmode"; then 7787d63fdb69Smrg libs="$predeps $libs $compiler_lib_search_path $postdeps" 7788d63fdb69Smrg 7789d63fdb69Smrg # Compute libraries that are listed more than once in $predeps 7790d63fdb69Smrg # $postdeps and mark them as special (i.e., whose duplicates are 7791d63fdb69Smrg # not to be eliminated). 7792d63fdb69Smrg pre_post_deps= 7793d63fdb69Smrg if $opt_duplicate_compiler_generated_deps; then 7794d63fdb69Smrg for pre_post_dep in $predeps $postdeps; do 7795d63fdb69Smrg case "$pre_post_deps " in 779648c85eb7Smrg *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; 7797d63fdb69Smrg esac 779848c85eb7Smrg func_append pre_post_deps " $pre_post_dep" 7799d63fdb69Smrg done 7800d63fdb69Smrg fi 7801d63fdb69Smrg pre_post_deps= 7802d63fdb69Smrg fi 7803d63fdb69Smrg 7804d63fdb69Smrg deplibs= 7805d63fdb69Smrg newdependency_libs= 7806d63fdb69Smrg newlib_search_path= 7807d63fdb69Smrg need_relink=no # whether we're linking any uninstalled libtool libraries 7808d63fdb69Smrg notinst_deplibs= # not-installed libtool libraries 7809d63fdb69Smrg notinst_path= # paths that contain not-installed libtool libraries 7810d63fdb69Smrg 7811d63fdb69Smrg case $linkmode in 7812d63fdb69Smrg lib) 7813d63fdb69Smrg passes="conv dlpreopen link" 7814d63fdb69Smrg for file in $dlfiles $dlprefiles; do 7815d63fdb69Smrg case $file in 7816d63fdb69Smrg *.la) ;; 7817d63fdb69Smrg *) 781852fd71cdSmrg func_fatal_help "libraries can '-dlopen' only libtool libraries: $file" 7819d63fdb69Smrg ;; 7820d63fdb69Smrg esac 7821d63fdb69Smrg done 7822d63fdb69Smrg ;; 7823d63fdb69Smrg prog) 7824d63fdb69Smrg compile_deplibs= 7825d63fdb69Smrg finalize_deplibs= 782652fd71cdSmrg alldeplibs=false 7827d63fdb69Smrg newdlfiles= 7828d63fdb69Smrg newdlprefiles= 7829d63fdb69Smrg passes="conv scan dlopen dlpreopen link" 7830d63fdb69Smrg ;; 7831d63fdb69Smrg *) passes="conv" 7832d63fdb69Smrg ;; 7833d63fdb69Smrg esac 7834d63fdb69Smrg 7835d63fdb69Smrg for pass in $passes; do 7836d63fdb69Smrg # The preopen pass in lib mode reverses $deplibs; put it back here 7837d63fdb69Smrg # so that -L comes before libs that need it for instance... 783852fd71cdSmrg if test lib,link = "$linkmode,$pass"; then 7839d63fdb69Smrg ## FIXME: Find the place where the list is rebuilt in the wrong 7840d63fdb69Smrg ## order, and fix it there properly 7841d63fdb69Smrg tmp_deplibs= 7842d63fdb69Smrg for deplib in $deplibs; do 7843d63fdb69Smrg tmp_deplibs="$deplib $tmp_deplibs" 7844d63fdb69Smrg done 784552fd71cdSmrg deplibs=$tmp_deplibs 7846d63fdb69Smrg fi 7847d63fdb69Smrg 784852fd71cdSmrg if test lib,link = "$linkmode,$pass" || 784952fd71cdSmrg test prog,scan = "$linkmode,$pass"; then 785052fd71cdSmrg libs=$deplibs 7851d63fdb69Smrg deplibs= 7852d63fdb69Smrg fi 785352fd71cdSmrg if test prog = "$linkmode"; then 7854d63fdb69Smrg case $pass in 785552fd71cdSmrg dlopen) libs=$dlfiles ;; 785652fd71cdSmrg dlpreopen) libs=$dlprefiles ;; 7857d63fdb69Smrg link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; 7858d63fdb69Smrg esac 7859d63fdb69Smrg fi 786052fd71cdSmrg if test lib,dlpreopen = "$linkmode,$pass"; then 7861d63fdb69Smrg # Collect and forward deplibs of preopened libtool libs 7862d63fdb69Smrg for lib in $dlprefiles; do 7863d63fdb69Smrg # Ignore non-libtool-libs 7864d63fdb69Smrg dependency_libs= 786548c85eb7Smrg func_resolve_sysroot "$lib" 7866d63fdb69Smrg case $lib in 786748c85eb7Smrg *.la) func_source "$func_resolve_sysroot_result" ;; 7868d63fdb69Smrg esac 7869d63fdb69Smrg 7870d63fdb69Smrg # Collect preopened libtool deplibs, except any this library 7871d63fdb69Smrg # has declared as weak libs 7872d63fdb69Smrg for deplib in $dependency_libs; do 787355acc8fcSmrg func_basename "$deplib" 787455acc8fcSmrg deplib_base=$func_basename_result 7875d63fdb69Smrg case " $weak_libs " in 7876d63fdb69Smrg *" $deplib_base "*) ;; 787748c85eb7Smrg *) func_append deplibs " $deplib" ;; 7878d63fdb69Smrg esac 7879d63fdb69Smrg done 7880d63fdb69Smrg done 788152fd71cdSmrg libs=$dlprefiles 7882d63fdb69Smrg fi 788352fd71cdSmrg if test dlopen = "$pass"; then 7884d63fdb69Smrg # Collect dlpreopened libraries 788552fd71cdSmrg save_deplibs=$deplibs 7886d63fdb69Smrg deplibs= 7887d63fdb69Smrg fi 7888d63fdb69Smrg 7889d63fdb69Smrg for deplib in $libs; do 7890d63fdb69Smrg lib= 789152fd71cdSmrg found=false 7892d63fdb69Smrg case $deplib in 789348c85eb7Smrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 789448c85eb7Smrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 789552fd71cdSmrg if test prog,link = "$linkmode,$pass"; then 7896d63fdb69Smrg compile_deplibs="$deplib $compile_deplibs" 7897d63fdb69Smrg finalize_deplibs="$deplib $finalize_deplibs" 7898d63fdb69Smrg else 789948c85eb7Smrg func_append compiler_flags " $deplib" 790052fd71cdSmrg if test lib = "$linkmode"; then 7901d63fdb69Smrg case "$new_inherited_linker_flags " in 7902d63fdb69Smrg *" $deplib "*) ;; 790348c85eb7Smrg * ) func_append new_inherited_linker_flags " $deplib" ;; 7904d63fdb69Smrg esac 7905d63fdb69Smrg fi 7906d63fdb69Smrg fi 7907d63fdb69Smrg continue 7908d63fdb69Smrg ;; 7909d63fdb69Smrg -l*) 791052fd71cdSmrg if test lib != "$linkmode" && test prog != "$linkmode"; then 791152fd71cdSmrg func_warning "'-l' is ignored for archives/objects" 7912d63fdb69Smrg continue 7913d63fdb69Smrg fi 7914d63fdb69Smrg func_stripname '-l' '' "$deplib" 7915d63fdb69Smrg name=$func_stripname_result 791652fd71cdSmrg if test lib = "$linkmode"; then 7917d63fdb69Smrg searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" 7918d63fdb69Smrg else 7919d63fdb69Smrg searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" 7920d63fdb69Smrg fi 7921d63fdb69Smrg for searchdir in $searchdirs; do 7922d63fdb69Smrg for search_ext in .la $std_shrext .so .a; do 7923d63fdb69Smrg # Search the libtool library 792452fd71cdSmrg lib=$searchdir/lib$name$search_ext 7925d63fdb69Smrg if test -f "$lib"; then 792652fd71cdSmrg if test .la = "$search_ext"; then 792752fd71cdSmrg found=: 7928d63fdb69Smrg else 792952fd71cdSmrg found=false 7930d63fdb69Smrg fi 7931d63fdb69Smrg break 2 7932d63fdb69Smrg fi 7933d63fdb69Smrg done 7934d63fdb69Smrg done 793552fd71cdSmrg if $found; then 793652fd71cdSmrg # deplib is a libtool library 7937d63fdb69Smrg # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, 7938d63fdb69Smrg # We need to do some special things here, and not later. 793952fd71cdSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 7940d63fdb69Smrg case " $predeps $postdeps " in 7941d63fdb69Smrg *" $deplib "*) 7942d63fdb69Smrg if func_lalib_p "$lib"; then 7943d63fdb69Smrg library_names= 7944d63fdb69Smrg old_library= 7945d63fdb69Smrg func_source "$lib" 7946d63fdb69Smrg for l in $old_library $library_names; do 794752fd71cdSmrg ll=$l 7948d63fdb69Smrg done 794952fd71cdSmrg if test "X$ll" = "X$old_library"; then # only static version available 795052fd71cdSmrg found=false 7951d63fdb69Smrg func_dirname "$lib" "" "." 795252fd71cdSmrg ladir=$func_dirname_result 7953d63fdb69Smrg lib=$ladir/$old_library 795452fd71cdSmrg if test prog,link = "$linkmode,$pass"; then 7955d63fdb69Smrg compile_deplibs="$deplib $compile_deplibs" 7956d63fdb69Smrg finalize_deplibs="$deplib $finalize_deplibs" 7957d63fdb69Smrg else 7958d63fdb69Smrg deplibs="$deplib $deplibs" 795952fd71cdSmrg test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 7960d63fdb69Smrg fi 7961d63fdb69Smrg continue 7962d63fdb69Smrg fi 7963d63fdb69Smrg fi 7964d63fdb69Smrg ;; 7965d63fdb69Smrg *) ;; 7966d63fdb69Smrg esac 7967d63fdb69Smrg fi 796852fd71cdSmrg else 796952fd71cdSmrg # deplib doesn't seem to be a libtool library 797052fd71cdSmrg if test prog,link = "$linkmode,$pass"; then 797152fd71cdSmrg compile_deplibs="$deplib $compile_deplibs" 797252fd71cdSmrg finalize_deplibs="$deplib $finalize_deplibs" 797352fd71cdSmrg else 797452fd71cdSmrg deplibs="$deplib $deplibs" 797552fd71cdSmrg test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 797652fd71cdSmrg fi 797752fd71cdSmrg continue 7978d63fdb69Smrg fi 7979d63fdb69Smrg ;; # -l 7980d63fdb69Smrg *.ltframework) 798152fd71cdSmrg if test prog,link = "$linkmode,$pass"; then 7982d63fdb69Smrg compile_deplibs="$deplib $compile_deplibs" 7983d63fdb69Smrg finalize_deplibs="$deplib $finalize_deplibs" 7984d63fdb69Smrg else 7985d63fdb69Smrg deplibs="$deplib $deplibs" 798652fd71cdSmrg if test lib = "$linkmode"; then 7987d63fdb69Smrg case "$new_inherited_linker_flags " in 7988d63fdb69Smrg *" $deplib "*) ;; 798948c85eb7Smrg * ) func_append new_inherited_linker_flags " $deplib" ;; 7990d63fdb69Smrg esac 7991d63fdb69Smrg fi 7992d63fdb69Smrg fi 7993d63fdb69Smrg continue 7994d63fdb69Smrg ;; 7995d63fdb69Smrg -L*) 7996d63fdb69Smrg case $linkmode in 7997d63fdb69Smrg lib) 7998d63fdb69Smrg deplibs="$deplib $deplibs" 799952fd71cdSmrg test conv = "$pass" && continue 8000d63fdb69Smrg newdependency_libs="$deplib $newdependency_libs" 8001d63fdb69Smrg func_stripname '-L' '' "$deplib" 800248c85eb7Smrg func_resolve_sysroot "$func_stripname_result" 800348c85eb7Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 8004d63fdb69Smrg ;; 8005d63fdb69Smrg prog) 800652fd71cdSmrg if test conv = "$pass"; then 8007d63fdb69Smrg deplibs="$deplib $deplibs" 8008d63fdb69Smrg continue 8009d63fdb69Smrg fi 801052fd71cdSmrg if test scan = "$pass"; then 8011d63fdb69Smrg deplibs="$deplib $deplibs" 8012d63fdb69Smrg else 8013d63fdb69Smrg compile_deplibs="$deplib $compile_deplibs" 8014d63fdb69Smrg finalize_deplibs="$deplib $finalize_deplibs" 8015d63fdb69Smrg fi 8016d63fdb69Smrg func_stripname '-L' '' "$deplib" 801748c85eb7Smrg func_resolve_sysroot "$func_stripname_result" 801848c85eb7Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 8019d63fdb69Smrg ;; 8020d63fdb69Smrg *) 802152fd71cdSmrg func_warning "'-L' is ignored for archives/objects" 8022d63fdb69Smrg ;; 8023d63fdb69Smrg esac # linkmode 8024d63fdb69Smrg continue 8025d63fdb69Smrg ;; # -L 8026d63fdb69Smrg -R*) 802752fd71cdSmrg if test link = "$pass"; then 8028d63fdb69Smrg func_stripname '-R' '' "$deplib" 802948c85eb7Smrg func_resolve_sysroot "$func_stripname_result" 803048c85eb7Smrg dir=$func_resolve_sysroot_result 8031d63fdb69Smrg # Make sure the xrpath contains only unique directories. 8032d63fdb69Smrg case "$xrpath " in 8033d63fdb69Smrg *" $dir "*) ;; 803448c85eb7Smrg *) func_append xrpath " $dir" ;; 8035d63fdb69Smrg esac 8036d63fdb69Smrg fi 8037d63fdb69Smrg deplibs="$deplib $deplibs" 8038d63fdb69Smrg continue 8039d63fdb69Smrg ;; 804048c85eb7Smrg *.la) 804148c85eb7Smrg func_resolve_sysroot "$deplib" 804248c85eb7Smrg lib=$func_resolve_sysroot_result 804348c85eb7Smrg ;; 8044d63fdb69Smrg *.$libext) 804552fd71cdSmrg if test conv = "$pass"; then 8046d63fdb69Smrg deplibs="$deplib $deplibs" 8047d63fdb69Smrg continue 8048d63fdb69Smrg fi 8049d63fdb69Smrg case $linkmode in 8050d63fdb69Smrg lib) 8051d63fdb69Smrg # Linking convenience modules into shared libraries is allowed, 8052d63fdb69Smrg # but linking other static libraries is non-portable. 8053d63fdb69Smrg case " $dlpreconveniencelibs " in 8054d63fdb69Smrg *" $deplib "*) ;; 8055d63fdb69Smrg *) 805652fd71cdSmrg valid_a_lib=false 8057d63fdb69Smrg case $deplibs_check_method in 8058d63fdb69Smrg match_pattern*) 8059d63fdb69Smrg set dummy $deplibs_check_method; shift 8060d63fdb69Smrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 806155acc8fcSmrg if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ 8062d63fdb69Smrg | $EGREP "$match_pattern_regex" > /dev/null; then 806352fd71cdSmrg valid_a_lib=: 8064d63fdb69Smrg fi 8065d63fdb69Smrg ;; 8066d63fdb69Smrg pass_all) 806752fd71cdSmrg valid_a_lib=: 8068d63fdb69Smrg ;; 8069d63fdb69Smrg esac 807052fd71cdSmrg if $valid_a_lib; then 807152fd71cdSmrg echo 807252fd71cdSmrg $ECHO "*** Warning: Linking the shared library $output against the" 807352fd71cdSmrg $ECHO "*** static library $deplib is not portable!" 807452fd71cdSmrg deplibs="$deplib $deplibs" 807552fd71cdSmrg else 807655acc8fcSmrg echo 8077d63fdb69Smrg $ECHO "*** Warning: Trying to link with static lib archive $deplib." 807855acc8fcSmrg echo "*** I have the capability to make that library automatically link in when" 807955acc8fcSmrg echo "*** you link to this library. But I can only do this if you have a" 808055acc8fcSmrg echo "*** shared version of the library, which you do not appear to have" 808155acc8fcSmrg echo "*** because the file extensions .$libext of this argument makes me believe" 808255acc8fcSmrg echo "*** that it is just a static archive that I should not use here." 8083d63fdb69Smrg fi 8084d63fdb69Smrg ;; 8085d63fdb69Smrg esac 8086d63fdb69Smrg continue 8087d63fdb69Smrg ;; 8088d63fdb69Smrg prog) 808952fd71cdSmrg if test link != "$pass"; then 8090d63fdb69Smrg deplibs="$deplib $deplibs" 8091d63fdb69Smrg else 8092d63fdb69Smrg compile_deplibs="$deplib $compile_deplibs" 8093d63fdb69Smrg finalize_deplibs="$deplib $finalize_deplibs" 8094d63fdb69Smrg fi 8095d63fdb69Smrg continue 8096d63fdb69Smrg ;; 8097d63fdb69Smrg esac # linkmode 8098d63fdb69Smrg ;; # *.$libext 8099d63fdb69Smrg *.lo | *.$objext) 810052fd71cdSmrg if test conv = "$pass"; then 8101d63fdb69Smrg deplibs="$deplib $deplibs" 810252fd71cdSmrg elif test prog = "$linkmode"; then 810352fd71cdSmrg if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then 8104d63fdb69Smrg # If there is no dlopen support or we're linking statically, 8105d63fdb69Smrg # we need to preload. 810648c85eb7Smrg func_append newdlprefiles " $deplib" 8107d63fdb69Smrg compile_deplibs="$deplib $compile_deplibs" 8108d63fdb69Smrg finalize_deplibs="$deplib $finalize_deplibs" 8109d63fdb69Smrg else 811048c85eb7Smrg func_append newdlfiles " $deplib" 8111d63fdb69Smrg fi 8112d63fdb69Smrg fi 8113d63fdb69Smrg continue 8114d63fdb69Smrg ;; 8115d63fdb69Smrg %DEPLIBS%) 811652fd71cdSmrg alldeplibs=: 8117d63fdb69Smrg continue 8118d63fdb69Smrg ;; 8119d63fdb69Smrg esac # case $deplib 8120d63fdb69Smrg 812152fd71cdSmrg $found || test -f "$lib" \ 812252fd71cdSmrg || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'" 8123d63fdb69Smrg 8124d63fdb69Smrg # Check to see that this really is a libtool archive. 8125d63fdb69Smrg func_lalib_unsafe_p "$lib" \ 812652fd71cdSmrg || func_fatal_error "'$lib' is not a valid libtool archive" 8127d63fdb69Smrg 8128d63fdb69Smrg func_dirname "$lib" "" "." 812952fd71cdSmrg ladir=$func_dirname_result 8130d63fdb69Smrg 8131d63fdb69Smrg dlname= 8132d63fdb69Smrg dlopen= 8133d63fdb69Smrg dlpreopen= 8134d63fdb69Smrg libdir= 8135d63fdb69Smrg library_names= 8136d63fdb69Smrg old_library= 8137d63fdb69Smrg inherited_linker_flags= 8138d63fdb69Smrg # If the library was installed with an old release of libtool, 8139d63fdb69Smrg # it will not redefine variables installed, or shouldnotlink 8140d63fdb69Smrg installed=yes 8141d63fdb69Smrg shouldnotlink=no 8142d63fdb69Smrg avoidtemprpath= 8143d63fdb69Smrg 8144d63fdb69Smrg 8145d63fdb69Smrg # Read the .la file 8146d63fdb69Smrg func_source "$lib" 8147d63fdb69Smrg 8148d63fdb69Smrg # Convert "-framework foo" to "foo.ltframework" 8149d63fdb69Smrg if test -n "$inherited_linker_flags"; then 815055acc8fcSmrg tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` 8151d63fdb69Smrg for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do 8152d63fdb69Smrg case " $new_inherited_linker_flags " in 8153d63fdb69Smrg *" $tmp_inherited_linker_flag "*) ;; 815448c85eb7Smrg *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; 8155d63fdb69Smrg esac 8156d63fdb69Smrg done 8157d63fdb69Smrg fi 815855acc8fcSmrg dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 815952fd71cdSmrg if test lib,link = "$linkmode,$pass" || 816052fd71cdSmrg test prog,scan = "$linkmode,$pass" || 816152fd71cdSmrg { test prog != "$linkmode" && test lib != "$linkmode"; }; then 816248c85eb7Smrg test -n "$dlopen" && func_append dlfiles " $dlopen" 816348c85eb7Smrg test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" 8164d63fdb69Smrg fi 8165d63fdb69Smrg 816652fd71cdSmrg if test conv = "$pass"; then 8167d63fdb69Smrg # Only check for convenience libraries 8168d63fdb69Smrg deplibs="$lib $deplibs" 8169d63fdb69Smrg if test -z "$libdir"; then 8170d63fdb69Smrg if test -z "$old_library"; then 817152fd71cdSmrg func_fatal_error "cannot find name of link library for '$lib'" 8172d63fdb69Smrg fi 8173d63fdb69Smrg # It is a libtool convenience library, so add in its objects. 817448c85eb7Smrg func_append convenience " $ladir/$objdir/$old_library" 817548c85eb7Smrg func_append old_convenience " $ladir/$objdir/$old_library" 817652fd71cdSmrg elif test prog != "$linkmode" && test lib != "$linkmode"; then 817752fd71cdSmrg func_fatal_error "'$lib' is not a convenience library" 8178d63fdb69Smrg fi 8179d63fdb69Smrg tmp_libs= 8180d63fdb69Smrg for deplib in $dependency_libs; do 8181d63fdb69Smrg deplibs="$deplib $deplibs" 818252fd71cdSmrg if $opt_preserve_dup_deps; then 8183d63fdb69Smrg case "$tmp_libs " in 818448c85eb7Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 8185d63fdb69Smrg esac 8186d63fdb69Smrg fi 818748c85eb7Smrg func_append tmp_libs " $deplib" 8188d63fdb69Smrg done 8189d63fdb69Smrg continue 8190d63fdb69Smrg fi # $pass = conv 8191d63fdb69Smrg 8192d63fdb69Smrg 8193d63fdb69Smrg # Get the name of the library we link against. 8194d63fdb69Smrg linklib= 819548c85eb7Smrg if test -n "$old_library" && 819652fd71cdSmrg { test yes = "$prefer_static_libs" || 819752fd71cdSmrg test built,no = "$prefer_static_libs,$installed"; }; then 819848c85eb7Smrg linklib=$old_library 819948c85eb7Smrg else 820048c85eb7Smrg for l in $old_library $library_names; do 820152fd71cdSmrg linklib=$l 820248c85eb7Smrg done 820348c85eb7Smrg fi 8204d63fdb69Smrg if test -z "$linklib"; then 820552fd71cdSmrg func_fatal_error "cannot find name of link library for '$lib'" 8206d63fdb69Smrg fi 8207d63fdb69Smrg 8208d63fdb69Smrg # This library was specified with -dlopen. 820952fd71cdSmrg if test dlopen = "$pass"; then 821052fd71cdSmrg test -z "$libdir" \ 821152fd71cdSmrg && func_fatal_error "cannot -dlopen a convenience library: '$lib'" 8212d63fdb69Smrg if test -z "$dlname" || 821352fd71cdSmrg test yes != "$dlopen_support" || 821452fd71cdSmrg test no = "$build_libtool_libs" 821552fd71cdSmrg then 8216d63fdb69Smrg # If there is no dlname, no dlopen support or we're linking 8217d63fdb69Smrg # statically, we need to preload. We also need to preload any 8218d63fdb69Smrg # dependent libraries so libltdl's deplib preloader doesn't 8219d63fdb69Smrg # bomb out in the load deplibs phase. 822048c85eb7Smrg func_append dlprefiles " $lib $dependency_libs" 8221d63fdb69Smrg else 822248c85eb7Smrg func_append newdlfiles " $lib" 8223d63fdb69Smrg fi 8224d63fdb69Smrg continue 8225d63fdb69Smrg fi # $pass = dlopen 8226d63fdb69Smrg 8227d63fdb69Smrg # We need an absolute path. 8228d63fdb69Smrg case $ladir in 822952fd71cdSmrg [\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;; 8230d63fdb69Smrg *) 8231d63fdb69Smrg abs_ladir=`cd "$ladir" && pwd` 8232d63fdb69Smrg if test -z "$abs_ladir"; then 823352fd71cdSmrg func_warning "cannot determine absolute directory name of '$ladir'" 8234d63fdb69Smrg func_warning "passing it literally to the linker, although it might fail" 823552fd71cdSmrg abs_ladir=$ladir 8236d63fdb69Smrg fi 8237d63fdb69Smrg ;; 8238d63fdb69Smrg esac 8239d63fdb69Smrg func_basename "$lib" 824052fd71cdSmrg laname=$func_basename_result 8241d63fdb69Smrg 8242d63fdb69Smrg # Find the relevant object directory and library name. 824352fd71cdSmrg if test yes = "$installed"; then 824448c85eb7Smrg if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then 824552fd71cdSmrg func_warning "library '$lib' was moved." 824652fd71cdSmrg dir=$ladir 824752fd71cdSmrg absdir=$abs_ladir 824852fd71cdSmrg libdir=$abs_ladir 8249d63fdb69Smrg else 825052fd71cdSmrg dir=$lt_sysroot$libdir 825152fd71cdSmrg absdir=$lt_sysroot$libdir 8252d63fdb69Smrg fi 825352fd71cdSmrg test yes = "$hardcode_automatic" && avoidtemprpath=yes 8254d63fdb69Smrg else 8255d63fdb69Smrg if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then 825652fd71cdSmrg dir=$ladir 825752fd71cdSmrg absdir=$abs_ladir 8258d63fdb69Smrg # Remove this search path later 825948c85eb7Smrg func_append notinst_path " $abs_ladir" 8260d63fdb69Smrg else 826152fd71cdSmrg dir=$ladir/$objdir 826252fd71cdSmrg absdir=$abs_ladir/$objdir 8263d63fdb69Smrg # Remove this search path later 826448c85eb7Smrg func_append notinst_path " $abs_ladir" 8265d63fdb69Smrg fi 8266d63fdb69Smrg fi # $installed = yes 8267d63fdb69Smrg func_stripname 'lib' '.la' "$laname" 8268d63fdb69Smrg name=$func_stripname_result 8269d63fdb69Smrg 8270d63fdb69Smrg # This library was specified with -dlpreopen. 827152fd71cdSmrg if test dlpreopen = "$pass"; then 827252fd71cdSmrg if test -z "$libdir" && test prog = "$linkmode"; then 827352fd71cdSmrg func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'" 8274d63fdb69Smrg fi 827552fd71cdSmrg case $host in 827648c85eb7Smrg # special handling for platforms with PE-DLLs. 827748c85eb7Smrg *cygwin* | *mingw* | *cegcc* ) 827848c85eb7Smrg # Linker will automatically link against shared library if both 827948c85eb7Smrg # static and shared are present. Therefore, ensure we extract 828048c85eb7Smrg # symbols from the import library if a shared library is present 828148c85eb7Smrg # (otherwise, the dlopen module name will be incorrect). We do 828248c85eb7Smrg # this by putting the import library name into $newdlprefiles. 828348c85eb7Smrg # We recover the dlopen module name by 'saving' the la file 828448c85eb7Smrg # name in a special purpose variable, and (later) extracting the 828548c85eb7Smrg # dlname from the la file. 828648c85eb7Smrg if test -n "$dlname"; then 828748c85eb7Smrg func_tr_sh "$dir/$linklib" 828848c85eb7Smrg eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" 828948c85eb7Smrg func_append newdlprefiles " $dir/$linklib" 829048c85eb7Smrg else 829148c85eb7Smrg func_append newdlprefiles " $dir/$old_library" 829248c85eb7Smrg # Keep a list of preopened convenience libraries to check 829348c85eb7Smrg # that they are being used correctly in the link pass. 829448c85eb7Smrg test -z "$libdir" && \ 829548c85eb7Smrg func_append dlpreconveniencelibs " $dir/$old_library" 829648c85eb7Smrg fi 829748c85eb7Smrg ;; 829848c85eb7Smrg * ) 829948c85eb7Smrg # Prefer using a static library (so that no silly _DYNAMIC symbols 830048c85eb7Smrg # are required to link). 830148c85eb7Smrg if test -n "$old_library"; then 830248c85eb7Smrg func_append newdlprefiles " $dir/$old_library" 830348c85eb7Smrg # Keep a list of preopened convenience libraries to check 830448c85eb7Smrg # that they are being used correctly in the link pass. 830548c85eb7Smrg test -z "$libdir" && \ 830648c85eb7Smrg func_append dlpreconveniencelibs " $dir/$old_library" 830748c85eb7Smrg # Otherwise, use the dlname, so that lt_dlopen finds it. 830848c85eb7Smrg elif test -n "$dlname"; then 830948c85eb7Smrg func_append newdlprefiles " $dir/$dlname" 831048c85eb7Smrg else 831148c85eb7Smrg func_append newdlprefiles " $dir/$linklib" 831248c85eb7Smrg fi 831348c85eb7Smrg ;; 831448c85eb7Smrg esac 8315d63fdb69Smrg fi # $pass = dlpreopen 8316d63fdb69Smrg 8317d63fdb69Smrg if test -z "$libdir"; then 8318d63fdb69Smrg # Link the convenience library 831952fd71cdSmrg if test lib = "$linkmode"; then 8320d63fdb69Smrg deplibs="$dir/$old_library $deplibs" 832152fd71cdSmrg elif test prog,link = "$linkmode,$pass"; then 8322d63fdb69Smrg compile_deplibs="$dir/$old_library $compile_deplibs" 8323d63fdb69Smrg finalize_deplibs="$dir/$old_library $finalize_deplibs" 8324d63fdb69Smrg else 8325d63fdb69Smrg deplibs="$lib $deplibs" # used for prog,scan pass 8326d63fdb69Smrg fi 8327d63fdb69Smrg continue 8328d63fdb69Smrg fi 8329d63fdb69Smrg 8330d63fdb69Smrg 833152fd71cdSmrg if test prog = "$linkmode" && test link != "$pass"; then 833248c85eb7Smrg func_append newlib_search_path " $ladir" 8333d63fdb69Smrg deplibs="$lib $deplibs" 8334d63fdb69Smrg 833552fd71cdSmrg linkalldeplibs=false 833652fd71cdSmrg if test no != "$link_all_deplibs" || test -z "$library_names" || 833752fd71cdSmrg test no = "$build_libtool_libs"; then 833852fd71cdSmrg linkalldeplibs=: 8339d63fdb69Smrg fi 8340d63fdb69Smrg 8341d63fdb69Smrg tmp_libs= 8342d63fdb69Smrg for deplib in $dependency_libs; do 8343d63fdb69Smrg case $deplib in 8344d63fdb69Smrg -L*) func_stripname '-L' '' "$deplib" 834548c85eb7Smrg func_resolve_sysroot "$func_stripname_result" 834648c85eb7Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 8347d63fdb69Smrg ;; 8348d63fdb69Smrg esac 8349d63fdb69Smrg # Need to link against all dependency_libs? 835052fd71cdSmrg if $linkalldeplibs; then 8351d63fdb69Smrg deplibs="$deplib $deplibs" 8352d63fdb69Smrg else 8353d63fdb69Smrg # Need to hardcode shared library paths 8354d63fdb69Smrg # or/and link against static libraries 8355d63fdb69Smrg newdependency_libs="$deplib $newdependency_libs" 8356d63fdb69Smrg fi 835752fd71cdSmrg if $opt_preserve_dup_deps; then 8358d63fdb69Smrg case "$tmp_libs " in 835948c85eb7Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 8360d63fdb69Smrg esac 8361d63fdb69Smrg fi 836248c85eb7Smrg func_append tmp_libs " $deplib" 8363d63fdb69Smrg done # for deplib 8364d63fdb69Smrg continue 8365d63fdb69Smrg fi # $linkmode = prog... 8366d63fdb69Smrg 836752fd71cdSmrg if test prog,link = "$linkmode,$pass"; then 8368d63fdb69Smrg if test -n "$library_names" && 836952fd71cdSmrg { { test no = "$prefer_static_libs" || 837052fd71cdSmrg test built,yes = "$prefer_static_libs,$installed"; } || 8371d63fdb69Smrg test -z "$old_library"; }; then 8372d63fdb69Smrg # We need to hardcode the library path 837352fd71cdSmrg if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then 8374d63fdb69Smrg # Make sure the rpath contains only unique directories. 837552fd71cdSmrg case $temp_rpath: in 8376d63fdb69Smrg *"$absdir:"*) ;; 837748c85eb7Smrg *) func_append temp_rpath "$absdir:" ;; 8378d63fdb69Smrg esac 8379d63fdb69Smrg fi 8380d63fdb69Smrg 8381d63fdb69Smrg # Hardcode the library path. 8382d63fdb69Smrg # Skip directories that are in the system default run-time 8383d63fdb69Smrg # search path. 8384d63fdb69Smrg case " $sys_lib_dlsearch_path " in 8385d63fdb69Smrg *" $absdir "*) ;; 8386d63fdb69Smrg *) 8387d63fdb69Smrg case "$compile_rpath " in 8388d63fdb69Smrg *" $absdir "*) ;; 838948c85eb7Smrg *) func_append compile_rpath " $absdir" ;; 8390d63fdb69Smrg esac 8391d63fdb69Smrg ;; 8392d63fdb69Smrg esac 8393d63fdb69Smrg case " $sys_lib_dlsearch_path " in 8394d63fdb69Smrg *" $libdir "*) ;; 8395d63fdb69Smrg *) 8396d63fdb69Smrg case "$finalize_rpath " in 8397d63fdb69Smrg *" $libdir "*) ;; 839848c85eb7Smrg *) func_append finalize_rpath " $libdir" ;; 8399d63fdb69Smrg esac 8400d63fdb69Smrg ;; 8401d63fdb69Smrg esac 8402d63fdb69Smrg fi # $linkmode,$pass = prog,link... 8403d63fdb69Smrg 840452fd71cdSmrg if $alldeplibs && 840552fd71cdSmrg { test pass_all = "$deplibs_check_method" || 840652fd71cdSmrg { test yes = "$build_libtool_libs" && 8407d63fdb69Smrg test -n "$library_names"; }; }; then 8408d63fdb69Smrg # We only need to search for static libraries 8409d63fdb69Smrg continue 8410d63fdb69Smrg fi 8411d63fdb69Smrg fi 8412d63fdb69Smrg 8413d63fdb69Smrg link_static=no # Whether the deplib will be linked statically 8414d63fdb69Smrg use_static_libs=$prefer_static_libs 841552fd71cdSmrg if test built = "$use_static_libs" && test yes = "$installed"; then 8416d63fdb69Smrg use_static_libs=no 8417d63fdb69Smrg fi 8418d63fdb69Smrg if test -n "$library_names" && 841952fd71cdSmrg { test no = "$use_static_libs" || test -z "$old_library"; }; then 8420d63fdb69Smrg case $host in 842152fd71cdSmrg *cygwin* | *mingw* | *cegcc* | *os2*) 8422d63fdb69Smrg # No point in relinking DLLs because paths are not encoded 842348c85eb7Smrg func_append notinst_deplibs " $lib" 8424d63fdb69Smrg need_relink=no 8425d63fdb69Smrg ;; 8426d63fdb69Smrg *) 842752fd71cdSmrg if test no = "$installed"; then 842848c85eb7Smrg func_append notinst_deplibs " $lib" 8429d63fdb69Smrg need_relink=yes 8430d63fdb69Smrg fi 8431d63fdb69Smrg ;; 8432d63fdb69Smrg esac 8433d63fdb69Smrg # This is a shared library 8434d63fdb69Smrg 8435d63fdb69Smrg # Warn about portability, can't link against -module's on some 8436d63fdb69Smrg # systems (darwin). Don't bleat about dlopened modules though! 843752fd71cdSmrg dlopenmodule= 8438d63fdb69Smrg for dlpremoduletest in $dlprefiles; do 8439d63fdb69Smrg if test "X$dlpremoduletest" = "X$lib"; then 844052fd71cdSmrg dlopenmodule=$dlpremoduletest 8441d63fdb69Smrg break 8442d63fdb69Smrg fi 8443d63fdb69Smrg done 844452fd71cdSmrg if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then 844555acc8fcSmrg echo 844652fd71cdSmrg if test prog = "$linkmode"; then 8447d63fdb69Smrg $ECHO "*** Warning: Linking the executable $output against the loadable module" 8448d63fdb69Smrg else 8449d63fdb69Smrg $ECHO "*** Warning: Linking the shared library $output against the loadable module" 8450d63fdb69Smrg fi 8451d63fdb69Smrg $ECHO "*** $linklib is not portable!" 8452d63fdb69Smrg fi 845352fd71cdSmrg if test lib = "$linkmode" && 845452fd71cdSmrg test yes = "$hardcode_into_libs"; then 8455d63fdb69Smrg # Hardcode the library path. 8456d63fdb69Smrg # Skip directories that are in the system default run-time 8457d63fdb69Smrg # search path. 8458d63fdb69Smrg case " $sys_lib_dlsearch_path " in 8459d63fdb69Smrg *" $absdir "*) ;; 8460d63fdb69Smrg *) 8461d63fdb69Smrg case "$compile_rpath " in 8462d63fdb69Smrg *" $absdir "*) ;; 846348c85eb7Smrg *) func_append compile_rpath " $absdir" ;; 8464d63fdb69Smrg esac 8465d63fdb69Smrg ;; 8466d63fdb69Smrg esac 8467d63fdb69Smrg case " $sys_lib_dlsearch_path " in 8468d63fdb69Smrg *" $libdir "*) ;; 8469d63fdb69Smrg *) 8470d63fdb69Smrg case "$finalize_rpath " in 8471d63fdb69Smrg *" $libdir "*) ;; 847248c85eb7Smrg *) func_append finalize_rpath " $libdir" ;; 8473d63fdb69Smrg esac 8474d63fdb69Smrg ;; 8475d63fdb69Smrg esac 8476d63fdb69Smrg fi 8477d63fdb69Smrg 8478d63fdb69Smrg if test -n "$old_archive_from_expsyms_cmds"; then 8479d63fdb69Smrg # figure out the soname 8480d63fdb69Smrg set dummy $library_names 8481d63fdb69Smrg shift 848252fd71cdSmrg realname=$1 8483d63fdb69Smrg shift 8484d63fdb69Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 8485d63fdb69Smrg # use dlname if we got it. it's perfectly good, no? 8486d63fdb69Smrg if test -n "$dlname"; then 848752fd71cdSmrg soname=$dlname 8488d63fdb69Smrg elif test -n "$soname_spec"; then 8489d63fdb69Smrg # bleh windows 8490d63fdb69Smrg case $host in 849152fd71cdSmrg *cygwin* | mingw* | *cegcc* | *os2*) 8492d63fdb69Smrg func_arith $current - $age 8493d63fdb69Smrg major=$func_arith_result 849452fd71cdSmrg versuffix=-$major 8495d63fdb69Smrg ;; 8496d63fdb69Smrg esac 8497d63fdb69Smrg eval soname=\"$soname_spec\" 8498d63fdb69Smrg else 849952fd71cdSmrg soname=$realname 8500d63fdb69Smrg fi 8501d63fdb69Smrg 8502d63fdb69Smrg # Make a new name for the extract_expsyms_cmds to use 850352fd71cdSmrg soroot=$soname 8504d63fdb69Smrg func_basename "$soroot" 850552fd71cdSmrg soname=$func_basename_result 8506d63fdb69Smrg func_stripname 'lib' '.dll' "$soname" 8507d63fdb69Smrg newlib=libimp-$func_stripname_result.a 8508d63fdb69Smrg 8509d63fdb69Smrg # If the library has no export list, then create one now 8510d63fdb69Smrg if test -f "$output_objdir/$soname-def"; then : 8511d63fdb69Smrg else 851252fd71cdSmrg func_verbose "extracting exported symbol list from '$soname'" 8513d63fdb69Smrg func_execute_cmds "$extract_expsyms_cmds" 'exit $?' 8514d63fdb69Smrg fi 8515d63fdb69Smrg 8516d63fdb69Smrg # Create $newlib 8517d63fdb69Smrg if test -f "$output_objdir/$newlib"; then :; else 851852fd71cdSmrg func_verbose "generating import library for '$soname'" 8519d63fdb69Smrg func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' 8520d63fdb69Smrg fi 8521d63fdb69Smrg # make sure the library variables are pointing to the new library 8522d63fdb69Smrg dir=$output_objdir 8523d63fdb69Smrg linklib=$newlib 8524d63fdb69Smrg fi # test -n "$old_archive_from_expsyms_cmds" 8525d63fdb69Smrg 852652fd71cdSmrg if test prog = "$linkmode" || test relink != "$opt_mode"; then 8527d63fdb69Smrg add_shlibpath= 8528d63fdb69Smrg add_dir= 8529d63fdb69Smrg add= 8530d63fdb69Smrg lib_linked=yes 8531d63fdb69Smrg case $hardcode_action in 8532d63fdb69Smrg immediate | unsupported) 853352fd71cdSmrg if test no = "$hardcode_direct"; then 853452fd71cdSmrg add=$dir/$linklib 8535d63fdb69Smrg case $host in 853652fd71cdSmrg *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;; 853752fd71cdSmrg *-*-sysv4*uw2*) add_dir=-L$dir ;; 8538d63fdb69Smrg *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ 853952fd71cdSmrg *-*-unixware7*) add_dir=-L$dir ;; 8540d63fdb69Smrg *-*-darwin* ) 854152fd71cdSmrg # if the lib is a (non-dlopened) module then we cannot 8542d63fdb69Smrg # link against it, someone is ignoring the earlier warnings 8543d63fdb69Smrg if /usr/bin/file -L $add 2> /dev/null | 854452fd71cdSmrg $GREP ": [^:]* bundle" >/dev/null; then 8545d63fdb69Smrg if test "X$dlopenmodule" != "X$lib"; then 8546d63fdb69Smrg $ECHO "*** Warning: lib $linklib is a module, not a shared library" 854752fd71cdSmrg if test -z "$old_library"; then 854855acc8fcSmrg echo 854955acc8fcSmrg echo "*** And there doesn't seem to be a static archive available" 855055acc8fcSmrg echo "*** The link will probably fail, sorry" 8551d63fdb69Smrg else 855252fd71cdSmrg add=$dir/$old_library 8553d63fdb69Smrg fi 8554d63fdb69Smrg elif test -n "$old_library"; then 855552fd71cdSmrg add=$dir/$old_library 8556d63fdb69Smrg fi 8557d63fdb69Smrg fi 8558d63fdb69Smrg esac 855952fd71cdSmrg elif test no = "$hardcode_minus_L"; then 8560d63fdb69Smrg case $host in 856152fd71cdSmrg *-*-sunos*) add_shlibpath=$dir ;; 8562d63fdb69Smrg esac 856352fd71cdSmrg add_dir=-L$dir 856452fd71cdSmrg add=-l$name 856552fd71cdSmrg elif test no = "$hardcode_shlibpath_var"; then 856652fd71cdSmrg add_shlibpath=$dir 856752fd71cdSmrg add=-l$name 8568d63fdb69Smrg else 8569d63fdb69Smrg lib_linked=no 8570d63fdb69Smrg fi 8571d63fdb69Smrg ;; 8572d63fdb69Smrg relink) 857352fd71cdSmrg if test yes = "$hardcode_direct" && 857452fd71cdSmrg test no = "$hardcode_direct_absolute"; then 857552fd71cdSmrg add=$dir/$linklib 857652fd71cdSmrg elif test yes = "$hardcode_minus_L"; then 857752fd71cdSmrg add_dir=-L$absdir 8578d63fdb69Smrg # Try looking first in the location we're being installed to. 8579d63fdb69Smrg if test -n "$inst_prefix_dir"; then 8580d63fdb69Smrg case $libdir in 8581d63fdb69Smrg [\\/]*) 858248c85eb7Smrg func_append add_dir " -L$inst_prefix_dir$libdir" 8583d63fdb69Smrg ;; 8584d63fdb69Smrg esac 8585d63fdb69Smrg fi 858652fd71cdSmrg add=-l$name 858752fd71cdSmrg elif test yes = "$hardcode_shlibpath_var"; then 858852fd71cdSmrg add_shlibpath=$dir 858952fd71cdSmrg add=-l$name 8590d63fdb69Smrg else 8591d63fdb69Smrg lib_linked=no 8592d63fdb69Smrg fi 8593d63fdb69Smrg ;; 8594d63fdb69Smrg *) lib_linked=no ;; 8595d63fdb69Smrg esac 8596d63fdb69Smrg 859752fd71cdSmrg if test yes != "$lib_linked"; then 8598d63fdb69Smrg func_fatal_configuration "unsupported hardcode properties" 8599d63fdb69Smrg fi 8600d63fdb69Smrg 8601d63fdb69Smrg if test -n "$add_shlibpath"; then 8602d63fdb69Smrg case :$compile_shlibpath: in 8603d63fdb69Smrg *":$add_shlibpath:"*) ;; 860448c85eb7Smrg *) func_append compile_shlibpath "$add_shlibpath:" ;; 8605d63fdb69Smrg esac 8606d63fdb69Smrg fi 860752fd71cdSmrg if test prog = "$linkmode"; then 8608d63fdb69Smrg test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" 8609d63fdb69Smrg test -n "$add" && compile_deplibs="$add $compile_deplibs" 8610d63fdb69Smrg else 8611d63fdb69Smrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 8612d63fdb69Smrg test -n "$add" && deplibs="$add $deplibs" 861352fd71cdSmrg if test yes != "$hardcode_direct" && 861452fd71cdSmrg test yes != "$hardcode_minus_L" && 861552fd71cdSmrg test yes = "$hardcode_shlibpath_var"; then 8616d63fdb69Smrg case :$finalize_shlibpath: in 8617d63fdb69Smrg *":$libdir:"*) ;; 861848c85eb7Smrg *) func_append finalize_shlibpath "$libdir:" ;; 8619d63fdb69Smrg esac 8620d63fdb69Smrg fi 8621d63fdb69Smrg fi 8622d63fdb69Smrg fi 8623d63fdb69Smrg 862452fd71cdSmrg if test prog = "$linkmode" || test relink = "$opt_mode"; then 8625d63fdb69Smrg add_shlibpath= 8626d63fdb69Smrg add_dir= 8627d63fdb69Smrg add= 8628d63fdb69Smrg # Finalize command for both is simple: just hardcode it. 862952fd71cdSmrg if test yes = "$hardcode_direct" && 863052fd71cdSmrg test no = "$hardcode_direct_absolute"; then 863152fd71cdSmrg add=$libdir/$linklib 863252fd71cdSmrg elif test yes = "$hardcode_minus_L"; then 863352fd71cdSmrg add_dir=-L$libdir 863452fd71cdSmrg add=-l$name 863552fd71cdSmrg elif test yes = "$hardcode_shlibpath_var"; then 8636d63fdb69Smrg case :$finalize_shlibpath: in 8637d63fdb69Smrg *":$libdir:"*) ;; 863848c85eb7Smrg *) func_append finalize_shlibpath "$libdir:" ;; 8639d63fdb69Smrg esac 864052fd71cdSmrg add=-l$name 864152fd71cdSmrg elif test yes = "$hardcode_automatic"; then 8642d63fdb69Smrg if test -n "$inst_prefix_dir" && 864352fd71cdSmrg test -f "$inst_prefix_dir$libdir/$linklib"; then 864452fd71cdSmrg add=$inst_prefix_dir$libdir/$linklib 8645d63fdb69Smrg else 864652fd71cdSmrg add=$libdir/$linklib 8647d63fdb69Smrg fi 8648d63fdb69Smrg else 8649d63fdb69Smrg # We cannot seem to hardcode it, guess we'll fake it. 865052fd71cdSmrg add_dir=-L$libdir 8651d63fdb69Smrg # Try looking first in the location we're being installed to. 8652d63fdb69Smrg if test -n "$inst_prefix_dir"; then 8653d63fdb69Smrg case $libdir in 8654d63fdb69Smrg [\\/]*) 865548c85eb7Smrg func_append add_dir " -L$inst_prefix_dir$libdir" 8656d63fdb69Smrg ;; 8657d63fdb69Smrg esac 8658d63fdb69Smrg fi 865952fd71cdSmrg add=-l$name 8660d63fdb69Smrg fi 8661d63fdb69Smrg 866252fd71cdSmrg if test prog = "$linkmode"; then 8663d63fdb69Smrg test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" 8664d63fdb69Smrg test -n "$add" && finalize_deplibs="$add $finalize_deplibs" 8665d63fdb69Smrg else 8666d63fdb69Smrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 8667d63fdb69Smrg test -n "$add" && deplibs="$add $deplibs" 8668d63fdb69Smrg fi 8669d63fdb69Smrg fi 867052fd71cdSmrg elif test prog = "$linkmode"; then 8671d63fdb69Smrg # Here we assume that one of hardcode_direct or hardcode_minus_L 8672d63fdb69Smrg # is not unsupported. This is valid on all known static and 8673d63fdb69Smrg # shared platforms. 867452fd71cdSmrg if test unsupported != "$hardcode_direct"; then 867552fd71cdSmrg test -n "$old_library" && linklib=$old_library 8676d63fdb69Smrg compile_deplibs="$dir/$linklib $compile_deplibs" 8677d63fdb69Smrg finalize_deplibs="$dir/$linklib $finalize_deplibs" 8678d63fdb69Smrg else 8679d63fdb69Smrg compile_deplibs="-l$name -L$dir $compile_deplibs" 8680d63fdb69Smrg finalize_deplibs="-l$name -L$dir $finalize_deplibs" 8681d63fdb69Smrg fi 868252fd71cdSmrg elif test yes = "$build_libtool_libs"; then 8683d63fdb69Smrg # Not a shared library 868452fd71cdSmrg if test pass_all != "$deplibs_check_method"; then 8685d63fdb69Smrg # We're trying link a shared library against a static one 8686d63fdb69Smrg # but the system doesn't support it. 8687d63fdb69Smrg 8688d63fdb69Smrg # Just print a warning and add the library to dependency_libs so 8689d63fdb69Smrg # that the program can be linked against the static library. 869055acc8fcSmrg echo 869152fd71cdSmrg $ECHO "*** Warning: This system cannot link to static lib archive $lib." 869255acc8fcSmrg echo "*** I have the capability to make that library automatically link in when" 869355acc8fcSmrg echo "*** you link to this library. But I can only do this if you have a" 869455acc8fcSmrg echo "*** shared version of the library, which you do not appear to have." 869552fd71cdSmrg if test yes = "$module"; then 869655acc8fcSmrg echo "*** But as you try to build a module library, libtool will still create " 869755acc8fcSmrg echo "*** a static module, that should work as long as the dlopening application" 869855acc8fcSmrg echo "*** is linked with the -dlopen flag to resolve symbols at runtime." 8699d63fdb69Smrg if test -z "$global_symbol_pipe"; then 870055acc8fcSmrg echo 870155acc8fcSmrg echo "*** However, this would only work if libtool was able to extract symbol" 870252fd71cdSmrg echo "*** lists from a program, using 'nm' or equivalent, but libtool could" 870355acc8fcSmrg echo "*** not find such a program. So, this module is probably useless." 870452fd71cdSmrg echo "*** 'nm' from GNU binutils and a full rebuild may help." 8705d63fdb69Smrg fi 870652fd71cdSmrg if test no = "$build_old_libs"; then 8707d63fdb69Smrg build_libtool_libs=module 8708d63fdb69Smrg build_old_libs=yes 8709d63fdb69Smrg else 8710d63fdb69Smrg build_libtool_libs=no 8711d63fdb69Smrg fi 8712d63fdb69Smrg fi 8713d63fdb69Smrg else 8714d63fdb69Smrg deplibs="$dir/$old_library $deplibs" 8715d63fdb69Smrg link_static=yes 8716d63fdb69Smrg fi 8717d63fdb69Smrg fi # link shared/static library? 8718d63fdb69Smrg 871952fd71cdSmrg if test lib = "$linkmode"; then 8720d63fdb69Smrg if test -n "$dependency_libs" && 872152fd71cdSmrg { test yes != "$hardcode_into_libs" || 872252fd71cdSmrg test yes = "$build_old_libs" || 872352fd71cdSmrg test yes = "$link_static"; }; then 8724d63fdb69Smrg # Extract -R from dependency_libs 8725d63fdb69Smrg temp_deplibs= 8726d63fdb69Smrg for libdir in $dependency_libs; do 8727d63fdb69Smrg case $libdir in 8728d63fdb69Smrg -R*) func_stripname '-R' '' "$libdir" 8729d63fdb69Smrg temp_xrpath=$func_stripname_result 8730d63fdb69Smrg case " $xrpath " in 8731d63fdb69Smrg *" $temp_xrpath "*) ;; 873248c85eb7Smrg *) func_append xrpath " $temp_xrpath";; 8733d63fdb69Smrg esac;; 873448c85eb7Smrg *) func_append temp_deplibs " $libdir";; 8735d63fdb69Smrg esac 8736d63fdb69Smrg done 873752fd71cdSmrg dependency_libs=$temp_deplibs 8738d63fdb69Smrg fi 8739d63fdb69Smrg 874048c85eb7Smrg func_append newlib_search_path " $absdir" 8741d63fdb69Smrg # Link against this library 874252fd71cdSmrg test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs" 8743d63fdb69Smrg # ... and its dependency_libs 8744d63fdb69Smrg tmp_libs= 8745d63fdb69Smrg for deplib in $dependency_libs; do 8746d63fdb69Smrg newdependency_libs="$deplib $newdependency_libs" 874748c85eb7Smrg case $deplib in 874848c85eb7Smrg -L*) func_stripname '-L' '' "$deplib" 874948c85eb7Smrg func_resolve_sysroot "$func_stripname_result";; 875048c85eb7Smrg *) func_resolve_sysroot "$deplib" ;; 875148c85eb7Smrg esac 875252fd71cdSmrg if $opt_preserve_dup_deps; then 8753d63fdb69Smrg case "$tmp_libs " in 875448c85eb7Smrg *" $func_resolve_sysroot_result "*) 875548c85eb7Smrg func_append specialdeplibs " $func_resolve_sysroot_result" ;; 8756d63fdb69Smrg esac 8757d63fdb69Smrg fi 875848c85eb7Smrg func_append tmp_libs " $func_resolve_sysroot_result" 8759d63fdb69Smrg done 8760d63fdb69Smrg 876152fd71cdSmrg if test no != "$link_all_deplibs"; then 8762d63fdb69Smrg # Add the search paths of all dependency libraries 8763d63fdb69Smrg for deplib in $dependency_libs; do 876455acc8fcSmrg path= 8765d63fdb69Smrg case $deplib in 876652fd71cdSmrg -L*) path=$deplib ;; 8767d63fdb69Smrg *.la) 876848c85eb7Smrg func_resolve_sysroot "$deplib" 876948c85eb7Smrg deplib=$func_resolve_sysroot_result 8770d63fdb69Smrg func_dirname "$deplib" "" "." 877148c85eb7Smrg dir=$func_dirname_result 8772d63fdb69Smrg # We need an absolute path. 8773d63fdb69Smrg case $dir in 877452fd71cdSmrg [\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;; 8775d63fdb69Smrg *) 8776d63fdb69Smrg absdir=`cd "$dir" && pwd` 8777d63fdb69Smrg if test -z "$absdir"; then 877852fd71cdSmrg func_warning "cannot determine absolute directory name of '$dir'" 877952fd71cdSmrg absdir=$dir 8780d63fdb69Smrg fi 8781d63fdb69Smrg ;; 8782d63fdb69Smrg esac 8783d63fdb69Smrg if $GREP "^installed=no" $deplib > /dev/null; then 8784d63fdb69Smrg case $host in 8785d63fdb69Smrg *-*-darwin*) 8786d63fdb69Smrg depdepl= 878752fd71cdSmrg eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` 878852fd71cdSmrg if test -n "$deplibrary_names"; then 878952fd71cdSmrg for tmp in $deplibrary_names; do 8790d63fdb69Smrg depdepl=$tmp 8791d63fdb69Smrg done 879252fd71cdSmrg if test -f "$absdir/$objdir/$depdepl"; then 879352fd71cdSmrg depdepl=$absdir/$objdir/$depdepl 879452fd71cdSmrg darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 8795d63fdb69Smrg if test -z "$darwin_install_name"; then 879652fd71cdSmrg darwin_install_name=`$OTOOL64 -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 8797d63fdb69Smrg fi 879852fd71cdSmrg func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl" 879952fd71cdSmrg func_append linker_flags " -dylib_file $darwin_install_name:$depdepl" 8800d63fdb69Smrg path= 8801d63fdb69Smrg fi 8802d63fdb69Smrg fi 8803d63fdb69Smrg ;; 8804d63fdb69Smrg *) 880552fd71cdSmrg path=-L$absdir/$objdir 8806d63fdb69Smrg ;; 8807d63fdb69Smrg esac 8808d63fdb69Smrg else 880952fd71cdSmrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` 8810d63fdb69Smrg test -z "$libdir" && \ 881152fd71cdSmrg func_fatal_error "'$deplib' is not a valid libtool archive" 8812d63fdb69Smrg test "$absdir" != "$libdir" && \ 881352fd71cdSmrg func_warning "'$deplib' seems to be moved" 8814d63fdb69Smrg 881552fd71cdSmrg path=-L$absdir 8816d63fdb69Smrg fi 8817d63fdb69Smrg ;; 8818d63fdb69Smrg esac 8819d63fdb69Smrg case " $deplibs " in 8820d63fdb69Smrg *" $path "*) ;; 8821d63fdb69Smrg *) deplibs="$path $deplibs" ;; 8822d63fdb69Smrg esac 8823d63fdb69Smrg done 8824d63fdb69Smrg fi # link_all_deplibs != no 8825d63fdb69Smrg fi # linkmode = lib 8826d63fdb69Smrg done # for deplib in $libs 882752fd71cdSmrg if test link = "$pass"; then 882852fd71cdSmrg if test prog = "$linkmode"; then 8829d63fdb69Smrg compile_deplibs="$new_inherited_linker_flags $compile_deplibs" 8830d63fdb69Smrg finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" 8831d63fdb69Smrg else 883255acc8fcSmrg compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 8833d63fdb69Smrg fi 8834d63fdb69Smrg fi 883552fd71cdSmrg dependency_libs=$newdependency_libs 883652fd71cdSmrg if test dlpreopen = "$pass"; then 8837d63fdb69Smrg # Link the dlpreopened libraries before other libraries 8838d63fdb69Smrg for deplib in $save_deplibs; do 8839d63fdb69Smrg deplibs="$deplib $deplibs" 8840d63fdb69Smrg done 8841d63fdb69Smrg fi 884252fd71cdSmrg if test dlopen != "$pass"; then 884352fd71cdSmrg test conv = "$pass" || { 8844d63fdb69Smrg # Make sure lib_search_path contains only unique directories. 8845d63fdb69Smrg lib_search_path= 8846d63fdb69Smrg for dir in $newlib_search_path; do 8847d63fdb69Smrg case "$lib_search_path " in 8848d63fdb69Smrg *" $dir "*) ;; 884948c85eb7Smrg *) func_append lib_search_path " $dir" ;; 8850d63fdb69Smrg esac 8851d63fdb69Smrg done 8852d63fdb69Smrg newlib_search_path= 885352fd71cdSmrg } 8854d63fdb69Smrg 885552fd71cdSmrg if test prog,link = "$linkmode,$pass"; then 8856d63fdb69Smrg vars="compile_deplibs finalize_deplibs" 885752fd71cdSmrg else 885852fd71cdSmrg vars=deplibs 8859d63fdb69Smrg fi 8860d63fdb69Smrg for var in $vars dependency_libs; do 8861d63fdb69Smrg # Add libraries to $var in reverse order 8862d63fdb69Smrg eval tmp_libs=\"\$$var\" 8863d63fdb69Smrg new_libs= 8864d63fdb69Smrg for deplib in $tmp_libs; do 8865d63fdb69Smrg # FIXME: Pedantically, this is the right thing to do, so 8866d63fdb69Smrg # that some nasty dependency loop isn't accidentally 8867d63fdb69Smrg # broken: 8868d63fdb69Smrg #new_libs="$deplib $new_libs" 8869d63fdb69Smrg # Pragmatically, this seems to cause very few problems in 8870d63fdb69Smrg # practice: 8871d63fdb69Smrg case $deplib in 8872d63fdb69Smrg -L*) new_libs="$deplib $new_libs" ;; 8873d63fdb69Smrg -R*) ;; 8874d63fdb69Smrg *) 8875d63fdb69Smrg # And here is the reason: when a library appears more 8876d63fdb69Smrg # than once as an explicit dependence of a library, or 8877d63fdb69Smrg # is implicitly linked in more than once by the 8878d63fdb69Smrg # compiler, it is considered special, and multiple 8879d63fdb69Smrg # occurrences thereof are not removed. Compare this 8880d63fdb69Smrg # with having the same library being listed as a 8881d63fdb69Smrg # dependency of multiple other libraries: in this case, 8882d63fdb69Smrg # we know (pedantically, we assume) the library does not 8883d63fdb69Smrg # need to be listed more than once, so we keep only the 8884d63fdb69Smrg # last copy. This is not always right, but it is rare 8885d63fdb69Smrg # enough that we require users that really mean to play 8886d63fdb69Smrg # such unportable linking tricks to link the library 8887d63fdb69Smrg # using -Wl,-lname, so that libtool does not consider it 8888d63fdb69Smrg # for duplicate removal. 8889d63fdb69Smrg case " $specialdeplibs " in 8890d63fdb69Smrg *" $deplib "*) new_libs="$deplib $new_libs" ;; 8891d63fdb69Smrg *) 8892d63fdb69Smrg case " $new_libs " in 8893d63fdb69Smrg *" $deplib "*) ;; 8894d63fdb69Smrg *) new_libs="$deplib $new_libs" ;; 8895d63fdb69Smrg esac 8896d63fdb69Smrg ;; 8897d63fdb69Smrg esac 8898d63fdb69Smrg ;; 8899d63fdb69Smrg esac 8900d63fdb69Smrg done 8901d63fdb69Smrg tmp_libs= 8902d63fdb69Smrg for deplib in $new_libs; do 8903d63fdb69Smrg case $deplib in 8904d63fdb69Smrg -L*) 8905d63fdb69Smrg case " $tmp_libs " in 8906d63fdb69Smrg *" $deplib "*) ;; 890748c85eb7Smrg *) func_append tmp_libs " $deplib" ;; 8908d63fdb69Smrg esac 8909d63fdb69Smrg ;; 891048c85eb7Smrg *) func_append tmp_libs " $deplib" ;; 8911d63fdb69Smrg esac 8912d63fdb69Smrg done 8913d63fdb69Smrg eval $var=\"$tmp_libs\" 8914d63fdb69Smrg done # for var 8915d63fdb69Smrg fi 891652fd71cdSmrg 891752fd71cdSmrg # Add Sun CC postdeps if required: 891852fd71cdSmrg test CXX = "$tagname" && { 891952fd71cdSmrg case $host_os in 892052fd71cdSmrg linux*) 89212a53b785Smrg case `$CC -V 2>&1 | $SED 5q` in 892252fd71cdSmrg *Sun\ C*) # Sun C++ 5.9 892352fd71cdSmrg func_suncc_cstd_abi 892452fd71cdSmrg 892552fd71cdSmrg if test no != "$suncc_use_cstd_abi"; then 892652fd71cdSmrg func_append postdeps ' -library=Cstd -library=Crun' 892752fd71cdSmrg fi 892852fd71cdSmrg ;; 892952fd71cdSmrg esac 893052fd71cdSmrg ;; 893152fd71cdSmrg 893252fd71cdSmrg solaris*) 893352fd71cdSmrg func_cc_basename "$CC" 893452fd71cdSmrg case $func_cc_basename_result in 893552fd71cdSmrg CC* | sunCC*) 893652fd71cdSmrg func_suncc_cstd_abi 893752fd71cdSmrg 893852fd71cdSmrg if test no != "$suncc_use_cstd_abi"; then 893952fd71cdSmrg func_append postdeps ' -library=Cstd -library=Crun' 894052fd71cdSmrg fi 894152fd71cdSmrg ;; 894252fd71cdSmrg esac 894352fd71cdSmrg ;; 894452fd71cdSmrg esac 894552fd71cdSmrg } 894652fd71cdSmrg 8947d63fdb69Smrg # Last step: remove runtime libs from dependency_libs 8948d63fdb69Smrg # (they stay in deplibs) 8949d63fdb69Smrg tmp_libs= 895052fd71cdSmrg for i in $dependency_libs; do 8951d63fdb69Smrg case " $predeps $postdeps $compiler_lib_search_path " in 8952d63fdb69Smrg *" $i "*) 895352fd71cdSmrg i= 8954d63fdb69Smrg ;; 8955d63fdb69Smrg esac 895652fd71cdSmrg if test -n "$i"; then 895748c85eb7Smrg func_append tmp_libs " $i" 8958d63fdb69Smrg fi 8959d63fdb69Smrg done 8960d63fdb69Smrg dependency_libs=$tmp_libs 8961d63fdb69Smrg done # for pass 896252fd71cdSmrg if test prog = "$linkmode"; then 896352fd71cdSmrg dlfiles=$newdlfiles 8964d63fdb69Smrg fi 896552fd71cdSmrg if test prog = "$linkmode" || test lib = "$linkmode"; then 896652fd71cdSmrg dlprefiles=$newdlprefiles 8967d63fdb69Smrg fi 8968d63fdb69Smrg 8969d63fdb69Smrg case $linkmode in 8970d63fdb69Smrg oldlib) 897152fd71cdSmrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 897252fd71cdSmrg func_warning "'-dlopen' is ignored for archives" 8973d63fdb69Smrg fi 8974d63fdb69Smrg 8975d63fdb69Smrg case " $deplibs" in 8976d63fdb69Smrg *\ -l* | *\ -L*) 897752fd71cdSmrg func_warning "'-l' and '-L' are ignored for archives" ;; 8978d63fdb69Smrg esac 8979d63fdb69Smrg 8980d63fdb69Smrg test -n "$rpath" && \ 898152fd71cdSmrg func_warning "'-rpath' is ignored for archives" 8982d63fdb69Smrg 8983d63fdb69Smrg test -n "$xrpath" && \ 898452fd71cdSmrg func_warning "'-R' is ignored for archives" 8985d63fdb69Smrg 8986d63fdb69Smrg test -n "$vinfo" && \ 898752fd71cdSmrg func_warning "'-version-info/-version-number' is ignored for archives" 8988d63fdb69Smrg 8989d63fdb69Smrg test -n "$release" && \ 899052fd71cdSmrg func_warning "'-release' is ignored for archives" 8991d63fdb69Smrg 8992d63fdb69Smrg test -n "$export_symbols$export_symbols_regex" && \ 899352fd71cdSmrg func_warning "'-export-symbols' is ignored for archives" 8994d63fdb69Smrg 8995d63fdb69Smrg # Now set the variables for building old libraries. 8996d63fdb69Smrg build_libtool_libs=no 899752fd71cdSmrg oldlibs=$output 899848c85eb7Smrg func_append objs "$old_deplibs" 8999d63fdb69Smrg ;; 9000d63fdb69Smrg 9001d63fdb69Smrg lib) 900252fd71cdSmrg # Make sure we only generate libraries of the form 'libNAME.la'. 9003d63fdb69Smrg case $outputname in 9004d63fdb69Smrg lib*) 9005d63fdb69Smrg func_stripname 'lib' '.la' "$outputname" 9006d63fdb69Smrg name=$func_stripname_result 9007d63fdb69Smrg eval shared_ext=\"$shrext_cmds\" 9008d63fdb69Smrg eval libname=\"$libname_spec\" 9009d63fdb69Smrg ;; 9010d63fdb69Smrg *) 901152fd71cdSmrg test no = "$module" \ 901252fd71cdSmrg && func_fatal_help "libtool library '$output' must begin with 'lib'" 9013d63fdb69Smrg 901452fd71cdSmrg if test no != "$need_lib_prefix"; then 9015d63fdb69Smrg # Add the "lib" prefix for modules if required 9016d63fdb69Smrg func_stripname '' '.la' "$outputname" 9017d63fdb69Smrg name=$func_stripname_result 9018d63fdb69Smrg eval shared_ext=\"$shrext_cmds\" 9019d63fdb69Smrg eval libname=\"$libname_spec\" 9020d63fdb69Smrg else 9021d63fdb69Smrg func_stripname '' '.la' "$outputname" 9022d63fdb69Smrg libname=$func_stripname_result 9023d63fdb69Smrg fi 9024d63fdb69Smrg ;; 9025d63fdb69Smrg esac 9026d63fdb69Smrg 9027d63fdb69Smrg if test -n "$objs"; then 902852fd71cdSmrg if test pass_all != "$deplibs_check_method"; then 902952fd71cdSmrg func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs" 9030d63fdb69Smrg else 903155acc8fcSmrg echo 9032d63fdb69Smrg $ECHO "*** Warning: Linking the shared library $output against the non-libtool" 9033d63fdb69Smrg $ECHO "*** objects $objs is not portable!" 903448c85eb7Smrg func_append libobjs " $objs" 9035d63fdb69Smrg fi 9036d63fdb69Smrg fi 9037d63fdb69Smrg 903852fd71cdSmrg test no = "$dlself" \ 903952fd71cdSmrg || func_warning "'-dlopen self' is ignored for libtool libraries" 9040d63fdb69Smrg 9041d63fdb69Smrg set dummy $rpath 9042d63fdb69Smrg shift 904352fd71cdSmrg test 1 -lt "$#" \ 904452fd71cdSmrg && func_warning "ignoring multiple '-rpath's for a libtool library" 9045d63fdb69Smrg 904652fd71cdSmrg install_libdir=$1 9047d63fdb69Smrg 9048d63fdb69Smrg oldlibs= 9049d63fdb69Smrg if test -z "$rpath"; then 905052fd71cdSmrg if test yes = "$build_libtool_libs"; then 9051d63fdb69Smrg # Building a libtool convenience library. 905252fd71cdSmrg # Some compilers have problems with a '.al' extension so 9053d63fdb69Smrg # convenience libraries should have the same extension an 9054d63fdb69Smrg # archive normally would. 9055d63fdb69Smrg oldlibs="$output_objdir/$libname.$libext $oldlibs" 9056d63fdb69Smrg build_libtool_libs=convenience 9057d63fdb69Smrg build_old_libs=yes 9058d63fdb69Smrg fi 9059d63fdb69Smrg 9060d63fdb69Smrg test -n "$vinfo" && \ 906152fd71cdSmrg func_warning "'-version-info/-version-number' is ignored for convenience libraries" 9062d63fdb69Smrg 9063d63fdb69Smrg test -n "$release" && \ 906452fd71cdSmrg func_warning "'-release' is ignored for convenience libraries" 9065d63fdb69Smrg else 9066d63fdb69Smrg 9067d63fdb69Smrg # Parse the version information argument. 906852fd71cdSmrg save_ifs=$IFS; IFS=: 9069d63fdb69Smrg set dummy $vinfo 0 0 0 9070d63fdb69Smrg shift 907152fd71cdSmrg IFS=$save_ifs 9072d63fdb69Smrg 9073d63fdb69Smrg test -n "$7" && \ 907452fd71cdSmrg func_fatal_help "too many parameters to '-version-info'" 9075d63fdb69Smrg 9076d63fdb69Smrg # convert absolute version numbers to libtool ages 9077d63fdb69Smrg # this retains compatibility with .la files and attempts 9078d63fdb69Smrg # to make the code below a bit more comprehensible 9079d63fdb69Smrg 9080d63fdb69Smrg case $vinfo_number in 9081d63fdb69Smrg yes) 908252fd71cdSmrg number_major=$1 908352fd71cdSmrg number_minor=$2 908452fd71cdSmrg number_revision=$3 9085d63fdb69Smrg # 9086d63fdb69Smrg # There are really only two kinds -- those that 9087d63fdb69Smrg # use the current revision as the major version 9088d63fdb69Smrg # and those that subtract age and use age as 9089d63fdb69Smrg # a minor version. But, then there is irix 909052fd71cdSmrg # that has an extra 1 added just for fun 9091d63fdb69Smrg # 9092d63fdb69Smrg case $version_type in 909348c85eb7Smrg # correct linux to gnu/linux during the next big refactor 90942a53b785Smrg darwin|freebsd-elf|linux|midnightbsd-elf|osf|windows|none) 9095d63fdb69Smrg func_arith $number_major + $number_minor 9096d63fdb69Smrg current=$func_arith_result 909752fd71cdSmrg age=$number_minor 909852fd71cdSmrg revision=$number_revision 9099d63fdb69Smrg ;; 910052fd71cdSmrg freebsd-aout|qnx|sunos) 910152fd71cdSmrg current=$number_major 910252fd71cdSmrg revision=$number_minor 910352fd71cdSmrg age=0 9104d63fdb69Smrg ;; 9105d63fdb69Smrg irix|nonstopux) 9106d63fdb69Smrg func_arith $number_major + $number_minor 9107d63fdb69Smrg current=$func_arith_result 910852fd71cdSmrg age=$number_minor 910952fd71cdSmrg revision=$number_minor 9110d63fdb69Smrg lt_irix_increment=no 9111d63fdb69Smrg ;; 9112d63fdb69Smrg esac 9113d63fdb69Smrg ;; 9114d63fdb69Smrg no) 911552fd71cdSmrg current=$1 911652fd71cdSmrg revision=$2 911752fd71cdSmrg age=$3 9118d63fdb69Smrg ;; 9119d63fdb69Smrg esac 9120d63fdb69Smrg 9121d63fdb69Smrg # Check that each of the things are valid numbers. 9122d63fdb69Smrg case $current in 9123d63fdb69Smrg 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]) ;; 9124d63fdb69Smrg *) 912552fd71cdSmrg func_error "CURRENT '$current' must be a nonnegative integer" 912652fd71cdSmrg func_fatal_error "'$vinfo' is not valid version information" 9127d63fdb69Smrg ;; 9128d63fdb69Smrg esac 9129d63fdb69Smrg 9130d63fdb69Smrg case $revision in 9131d63fdb69Smrg 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]) ;; 9132d63fdb69Smrg *) 913352fd71cdSmrg func_error "REVISION '$revision' must be a nonnegative integer" 913452fd71cdSmrg func_fatal_error "'$vinfo' is not valid version information" 9135d63fdb69Smrg ;; 9136d63fdb69Smrg esac 9137d63fdb69Smrg 9138d63fdb69Smrg case $age in 9139d63fdb69Smrg 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]) ;; 9140d63fdb69Smrg *) 914152fd71cdSmrg func_error "AGE '$age' must be a nonnegative integer" 914252fd71cdSmrg func_fatal_error "'$vinfo' is not valid version information" 9143d63fdb69Smrg ;; 9144d63fdb69Smrg esac 9145d63fdb69Smrg 9146d63fdb69Smrg if test "$age" -gt "$current"; then 914752fd71cdSmrg func_error "AGE '$age' is greater than the current interface number '$current'" 914852fd71cdSmrg func_fatal_error "'$vinfo' is not valid version information" 9149d63fdb69Smrg fi 9150d63fdb69Smrg 9151d63fdb69Smrg # Calculate the version variables. 9152d63fdb69Smrg major= 9153d63fdb69Smrg versuffix= 9154d63fdb69Smrg verstring= 9155d63fdb69Smrg case $version_type in 9156d63fdb69Smrg none) ;; 9157d63fdb69Smrg 9158d63fdb69Smrg darwin) 9159d63fdb69Smrg # Like Linux, but with the current version available in 9160d63fdb69Smrg # verstring for coding it into the library header 9161d63fdb69Smrg func_arith $current - $age 9162d63fdb69Smrg major=.$func_arith_result 916352fd71cdSmrg versuffix=$major.$age.$revision 9164d63fdb69Smrg # Darwin ld doesn't like 0 for these options... 9165d63fdb69Smrg func_arith $current + 1 9166d63fdb69Smrg minor_current=$func_arith_result 916752fd71cdSmrg xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" 9168d63fdb69Smrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 916952fd71cdSmrg # On Darwin other compilers 917052fd71cdSmrg case $CC in 917152fd71cdSmrg nagfor*) 917252fd71cdSmrg verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" 917352fd71cdSmrg ;; 917452fd71cdSmrg *) 917552fd71cdSmrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 917652fd71cdSmrg ;; 917752fd71cdSmrg esac 9178d63fdb69Smrg ;; 9179d63fdb69Smrg 9180d63fdb69Smrg freebsd-aout) 918152fd71cdSmrg major=.$current 918252fd71cdSmrg versuffix=.$current.$revision 9183d63fdb69Smrg ;; 9184d63fdb69Smrg 91852a53b785Smrg freebsd-elf | midnightbsd-elf) 918652fd71cdSmrg func_arith $current - $age 918752fd71cdSmrg major=.$func_arith_result 918852fd71cdSmrg versuffix=$major.$age.$revision 9189d63fdb69Smrg ;; 9190d63fdb69Smrg 9191d63fdb69Smrg irix | nonstopux) 919252fd71cdSmrg if test no = "$lt_irix_increment"; then 9193d63fdb69Smrg func_arith $current - $age 9194d63fdb69Smrg else 9195d63fdb69Smrg func_arith $current - $age + 1 9196d63fdb69Smrg fi 9197d63fdb69Smrg major=$func_arith_result 9198d63fdb69Smrg 9199d63fdb69Smrg case $version_type in 9200d63fdb69Smrg nonstopux) verstring_prefix=nonstopux ;; 9201d63fdb69Smrg *) verstring_prefix=sgi ;; 9202d63fdb69Smrg esac 920352fd71cdSmrg verstring=$verstring_prefix$major.$revision 9204d63fdb69Smrg 9205d63fdb69Smrg # Add in all the interfaces that we are compatible with. 9206d63fdb69Smrg loop=$revision 920752fd71cdSmrg while test 0 -ne "$loop"; do 9208d63fdb69Smrg func_arith $revision - $loop 9209d63fdb69Smrg iface=$func_arith_result 9210d63fdb69Smrg func_arith $loop - 1 9211d63fdb69Smrg loop=$func_arith_result 921252fd71cdSmrg verstring=$verstring_prefix$major.$iface:$verstring 9213d63fdb69Smrg done 9214d63fdb69Smrg 921552fd71cdSmrg # Before this point, $major must not contain '.'. 9216d63fdb69Smrg major=.$major 921752fd71cdSmrg versuffix=$major.$revision 9218d63fdb69Smrg ;; 9219d63fdb69Smrg 922048c85eb7Smrg linux) # correct to gnu/linux during the next big refactor 9221d63fdb69Smrg func_arith $current - $age 9222d63fdb69Smrg major=.$func_arith_result 922352fd71cdSmrg versuffix=$major.$age.$revision 9224d63fdb69Smrg ;; 9225d63fdb69Smrg 9226d63fdb69Smrg osf) 9227d63fdb69Smrg func_arith $current - $age 9228d63fdb69Smrg major=.$func_arith_result 922952fd71cdSmrg versuffix=.$current.$age.$revision 923052fd71cdSmrg verstring=$current.$age.$revision 9231d63fdb69Smrg 9232d63fdb69Smrg # Add in all the interfaces that we are compatible with. 9233d63fdb69Smrg loop=$age 923452fd71cdSmrg while test 0 -ne "$loop"; do 9235d63fdb69Smrg func_arith $current - $loop 9236d63fdb69Smrg iface=$func_arith_result 9237d63fdb69Smrg func_arith $loop - 1 9238d63fdb69Smrg loop=$func_arith_result 923952fd71cdSmrg verstring=$verstring:$iface.0 9240d63fdb69Smrg done 9241d63fdb69Smrg 9242d63fdb69Smrg # Make executables depend on our current version. 924352fd71cdSmrg func_append verstring ":$current.0" 9244d63fdb69Smrg ;; 9245d63fdb69Smrg 9246d63fdb69Smrg qnx) 924752fd71cdSmrg major=.$current 924852fd71cdSmrg versuffix=.$current 924952fd71cdSmrg ;; 925052fd71cdSmrg 925152fd71cdSmrg sco) 925252fd71cdSmrg major=.$current 925352fd71cdSmrg versuffix=.$current 9254d63fdb69Smrg ;; 9255d63fdb69Smrg 9256d63fdb69Smrg sunos) 925752fd71cdSmrg major=.$current 925852fd71cdSmrg versuffix=.$current.$revision 9259d63fdb69Smrg ;; 9260d63fdb69Smrg 9261d63fdb69Smrg windows) 9262d63fdb69Smrg # Use '-' rather than '.', since we only want one 926352fd71cdSmrg # extension on DOS 8.3 file systems. 9264d63fdb69Smrg func_arith $current - $age 9265d63fdb69Smrg major=$func_arith_result 926652fd71cdSmrg versuffix=-$major 9267d63fdb69Smrg ;; 9268d63fdb69Smrg 9269d63fdb69Smrg *) 927052fd71cdSmrg func_fatal_configuration "unknown library version type '$version_type'" 9271d63fdb69Smrg ;; 9272d63fdb69Smrg esac 9273d63fdb69Smrg 9274d63fdb69Smrg # Clear the version info if we defaulted, and they specified a release. 9275d63fdb69Smrg if test -z "$vinfo" && test -n "$release"; then 9276d63fdb69Smrg major= 9277d63fdb69Smrg case $version_type in 9278d63fdb69Smrg darwin) 9279d63fdb69Smrg # we can't check for "0.0" in archive_cmds due to quoting 9280d63fdb69Smrg # problems, so we reset it completely 9281d63fdb69Smrg verstring= 9282d63fdb69Smrg ;; 9283d63fdb69Smrg *) 928452fd71cdSmrg verstring=0.0 9285d63fdb69Smrg ;; 9286d63fdb69Smrg esac 928752fd71cdSmrg if test no = "$need_version"; then 9288d63fdb69Smrg versuffix= 9289d63fdb69Smrg else 929052fd71cdSmrg versuffix=.0.0 9291d63fdb69Smrg fi 9292d63fdb69Smrg fi 9293d63fdb69Smrg 9294d63fdb69Smrg # Remove version info from name if versioning should be avoided 929552fd71cdSmrg if test yes,no = "$avoid_version,$need_version"; then 9296d63fdb69Smrg major= 9297d63fdb69Smrg versuffix= 929852fd71cdSmrg verstring= 9299d63fdb69Smrg fi 9300d63fdb69Smrg 9301d63fdb69Smrg # Check to see if the archive will have undefined symbols. 930252fd71cdSmrg if test yes = "$allow_undefined"; then 930352fd71cdSmrg if test unsupported = "$allow_undefined_flag"; then 930452fd71cdSmrg if test yes = "$build_old_libs"; then 930552fd71cdSmrg func_warning "undefined symbols not allowed in $host shared libraries; building static only" 930652fd71cdSmrg build_libtool_libs=no 930752fd71cdSmrg else 930852fd71cdSmrg func_fatal_error "can't build $host shared library unless -no-undefined is specified" 930952fd71cdSmrg fi 9310d63fdb69Smrg fi 9311d63fdb69Smrg else 9312d63fdb69Smrg # Don't allow undefined symbols. 931352fd71cdSmrg allow_undefined_flag=$no_undefined_flag 9314d63fdb69Smrg fi 9315d63fdb69Smrg 9316d63fdb69Smrg fi 9317d63fdb69Smrg 931852fd71cdSmrg func_generate_dlsyms "$libname" "$libname" : 931948c85eb7Smrg func_append libobjs " $symfileobj" 932052fd71cdSmrg test " " = "$libobjs" && libobjs= 9321d63fdb69Smrg 932252fd71cdSmrg if test relink != "$opt_mode"; then 9323d63fdb69Smrg # Remove our outputs, but don't remove object files since they 9324d63fdb69Smrg # may have been created when compiling PIC objects. 9325d63fdb69Smrg removelist= 9326d63fdb69Smrg tempremovelist=`$ECHO "$output_objdir/*"` 9327d63fdb69Smrg for p in $tempremovelist; do 9328d63fdb69Smrg case $p in 9329d63fdb69Smrg *.$objext | *.gcno) 9330d63fdb69Smrg ;; 933152fd71cdSmrg $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/$libname$release.*) 933252fd71cdSmrg if test -n "$precious_files_regex"; then 9333d63fdb69Smrg if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 9334d63fdb69Smrg then 9335d63fdb69Smrg continue 9336d63fdb69Smrg fi 9337d63fdb69Smrg fi 933848c85eb7Smrg func_append removelist " $p" 9339d63fdb69Smrg ;; 9340d63fdb69Smrg *) ;; 9341d63fdb69Smrg esac 9342d63fdb69Smrg done 9343d63fdb69Smrg test -n "$removelist" && \ 9344d63fdb69Smrg func_show_eval "${RM}r \$removelist" 9345d63fdb69Smrg fi 9346d63fdb69Smrg 9347d63fdb69Smrg # Now set the variables for building old libraries. 934852fd71cdSmrg if test yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; then 934948c85eb7Smrg func_append oldlibs " $output_objdir/$libname.$libext" 9350d63fdb69Smrg 9351d63fdb69Smrg # Transform .lo files to .o files. 935252fd71cdSmrg oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; $lo2o" | $NL2SP` 9353d63fdb69Smrg fi 9354d63fdb69Smrg 9355d63fdb69Smrg # Eliminate all temporary directories. 9356d63fdb69Smrg #for path in $notinst_path; do 935755acc8fcSmrg # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` 935855acc8fcSmrg # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` 935955acc8fcSmrg # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` 9360d63fdb69Smrg #done 9361d63fdb69Smrg 9362d63fdb69Smrg if test -n "$xrpath"; then 9363d63fdb69Smrg # If the user specified any rpath flags, then add them. 9364d63fdb69Smrg temp_xrpath= 9365d63fdb69Smrg for libdir in $xrpath; do 936648c85eb7Smrg func_replace_sysroot "$libdir" 936748c85eb7Smrg func_append temp_xrpath " -R$func_replace_sysroot_result" 9368d63fdb69Smrg case "$finalize_rpath " in 9369d63fdb69Smrg *" $libdir "*) ;; 937048c85eb7Smrg *) func_append finalize_rpath " $libdir" ;; 9371d63fdb69Smrg esac 9372d63fdb69Smrg done 937352fd71cdSmrg if test yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; then 9374d63fdb69Smrg dependency_libs="$temp_xrpath $dependency_libs" 9375d63fdb69Smrg fi 9376d63fdb69Smrg fi 9377d63fdb69Smrg 9378d63fdb69Smrg # Make sure dlfiles contains only unique files that won't be dlpreopened 937952fd71cdSmrg old_dlfiles=$dlfiles 9380d63fdb69Smrg dlfiles= 9381d63fdb69Smrg for lib in $old_dlfiles; do 9382d63fdb69Smrg case " $dlprefiles $dlfiles " in 9383d63fdb69Smrg *" $lib "*) ;; 938448c85eb7Smrg *) func_append dlfiles " $lib" ;; 9385d63fdb69Smrg esac 9386d63fdb69Smrg done 9387d63fdb69Smrg 9388d63fdb69Smrg # Make sure dlprefiles contains only unique files 938952fd71cdSmrg old_dlprefiles=$dlprefiles 9390d63fdb69Smrg dlprefiles= 9391d63fdb69Smrg for lib in $old_dlprefiles; do 9392d63fdb69Smrg case "$dlprefiles " in 9393d63fdb69Smrg *" $lib "*) ;; 939448c85eb7Smrg *) func_append dlprefiles " $lib" ;; 9395d63fdb69Smrg esac 9396d63fdb69Smrg done 9397d63fdb69Smrg 939852fd71cdSmrg if test yes = "$build_libtool_libs"; then 9399d63fdb69Smrg if test -n "$rpath"; then 9400d63fdb69Smrg case $host in 940155acc8fcSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) 9402d63fdb69Smrg # these systems don't actually have a c library (as such)! 9403d63fdb69Smrg ;; 9404d63fdb69Smrg *-*-rhapsody* | *-*-darwin1.[012]) 9405d63fdb69Smrg # Rhapsody C library is in the System framework 940648c85eb7Smrg func_append deplibs " System.ltframework" 9407d63fdb69Smrg ;; 9408d63fdb69Smrg *-*-netbsd*) 9409d63fdb69Smrg # Don't link with libc until the a.out ld.so is fixed. 9410d63fdb69Smrg ;; 94112a53b785Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-midnightbsd*) 9412d63fdb69Smrg # Do not include libc due to us having libc/libc_r. 9413d63fdb69Smrg ;; 9414d63fdb69Smrg *-*-sco3.2v5* | *-*-sco5v6*) 9415d63fdb69Smrg # Causes problems with __ctype 9416d63fdb69Smrg ;; 9417d63fdb69Smrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 9418d63fdb69Smrg # Compiler inserts libc in the correct place for threads to work 9419d63fdb69Smrg ;; 9420d63fdb69Smrg *) 9421d63fdb69Smrg # Add libc to deplibs on all other systems if necessary. 942252fd71cdSmrg if test yes = "$build_libtool_need_lc"; then 942348c85eb7Smrg func_append deplibs " -lc" 9424d63fdb69Smrg fi 9425d63fdb69Smrg ;; 9426d63fdb69Smrg esac 9427d63fdb69Smrg fi 9428d63fdb69Smrg 9429d63fdb69Smrg # Transform deplibs into only deplibs that can be linked in shared. 9430d63fdb69Smrg name_save=$name 9431d63fdb69Smrg libname_save=$libname 9432d63fdb69Smrg release_save=$release 9433d63fdb69Smrg versuffix_save=$versuffix 9434d63fdb69Smrg major_save=$major 9435d63fdb69Smrg # I'm not sure if I'm treating the release correctly. I think 9436d63fdb69Smrg # release should show up in the -l (ie -lgmp5) so we don't want to 9437d63fdb69Smrg # add it in twice. Is that correct? 943852fd71cdSmrg release= 943952fd71cdSmrg versuffix= 944052fd71cdSmrg major= 9441d63fdb69Smrg newdeplibs= 9442d63fdb69Smrg droppeddeps=no 9443d63fdb69Smrg case $deplibs_check_method in 9444d63fdb69Smrg pass_all) 9445d63fdb69Smrg # Don't check for shared/static. Everything works. 9446d63fdb69Smrg # This might be a little naive. We might want to check 9447d63fdb69Smrg # whether the library exists or not. But this is on 9448d63fdb69Smrg # osf3 & osf4 and I'm not really sure... Just 9449d63fdb69Smrg # implementing what was already the behavior. 9450d63fdb69Smrg newdeplibs=$deplibs 9451d63fdb69Smrg ;; 9452d63fdb69Smrg test_compile) 9453d63fdb69Smrg # This code stresses the "libraries are programs" paradigm to its 9454d63fdb69Smrg # limits. Maybe even breaks it. We compile a program, linking it 9455d63fdb69Smrg # against the deplibs as a proxy for the library. Then we can check 9456d63fdb69Smrg # whether they linked in statically or dynamically with ldd. 9457d63fdb69Smrg $opt_dry_run || $RM conftest.c 9458d63fdb69Smrg cat > conftest.c <<EOF 9459d63fdb69Smrg int main() { return 0; } 9460d63fdb69SmrgEOF 9461d63fdb69Smrg $opt_dry_run || $RM conftest 9462d63fdb69Smrg if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then 9463d63fdb69Smrg ldd_output=`ldd conftest` 9464d63fdb69Smrg for i in $deplibs; do 9465d63fdb69Smrg case $i in 9466d63fdb69Smrg -l*) 9467d63fdb69Smrg func_stripname -l '' "$i" 9468d63fdb69Smrg name=$func_stripname_result 946952fd71cdSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9470d63fdb69Smrg case " $predeps $postdeps " in 9471d63fdb69Smrg *" $i "*) 947248c85eb7Smrg func_append newdeplibs " $i" 947352fd71cdSmrg i= 9474d63fdb69Smrg ;; 9475d63fdb69Smrg esac 9476d63fdb69Smrg fi 947752fd71cdSmrg if test -n "$i"; then 9478d63fdb69Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 9479d63fdb69Smrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 9480d63fdb69Smrg set dummy $deplib_matches; shift 9481d63fdb69Smrg deplib_match=$1 948252fd71cdSmrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then 948348c85eb7Smrg func_append newdeplibs " $i" 9484d63fdb69Smrg else 9485d63fdb69Smrg droppeddeps=yes 948655acc8fcSmrg echo 9487d63fdb69Smrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 948855acc8fcSmrg echo "*** I have the capability to make that library automatically link in when" 948955acc8fcSmrg echo "*** you link to this library. But I can only do this if you have a" 949055acc8fcSmrg echo "*** shared version of the library, which I believe you do not have" 949155acc8fcSmrg echo "*** because a test_compile did reveal that the linker did not use it for" 949255acc8fcSmrg echo "*** its dynamic dependency list that programs get resolved with at runtime." 9493d63fdb69Smrg fi 9494d63fdb69Smrg fi 9495d63fdb69Smrg ;; 9496d63fdb69Smrg *) 949748c85eb7Smrg func_append newdeplibs " $i" 9498d63fdb69Smrg ;; 9499d63fdb69Smrg esac 9500d63fdb69Smrg done 9501d63fdb69Smrg else 9502d63fdb69Smrg # Error occurred in the first compile. Let's try to salvage 9503d63fdb69Smrg # the situation: Compile a separate program for each library. 9504d63fdb69Smrg for i in $deplibs; do 9505d63fdb69Smrg case $i in 9506d63fdb69Smrg -l*) 9507d63fdb69Smrg func_stripname -l '' "$i" 9508d63fdb69Smrg name=$func_stripname_result 9509d63fdb69Smrg $opt_dry_run || $RM conftest 9510d63fdb69Smrg if $LTCC $LTCFLAGS -o conftest conftest.c $i; then 9511d63fdb69Smrg ldd_output=`ldd conftest` 951252fd71cdSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9513d63fdb69Smrg case " $predeps $postdeps " in 9514d63fdb69Smrg *" $i "*) 951548c85eb7Smrg func_append newdeplibs " $i" 951652fd71cdSmrg i= 9517d63fdb69Smrg ;; 9518d63fdb69Smrg esac 9519d63fdb69Smrg fi 952052fd71cdSmrg if test -n "$i"; then 9521d63fdb69Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 9522d63fdb69Smrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 9523d63fdb69Smrg set dummy $deplib_matches; shift 9524d63fdb69Smrg deplib_match=$1 952552fd71cdSmrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then 952648c85eb7Smrg func_append newdeplibs " $i" 9527d63fdb69Smrg else 9528d63fdb69Smrg droppeddeps=yes 952955acc8fcSmrg echo 9530d63fdb69Smrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 953155acc8fcSmrg echo "*** I have the capability to make that library automatically link in when" 953255acc8fcSmrg echo "*** you link to this library. But I can only do this if you have a" 953355acc8fcSmrg echo "*** shared version of the library, which you do not appear to have" 953455acc8fcSmrg echo "*** because a test_compile did reveal that the linker did not use this one" 953555acc8fcSmrg echo "*** as a dynamic dependency that programs can get resolved with at runtime." 9536d63fdb69Smrg fi 9537d63fdb69Smrg fi 9538d63fdb69Smrg else 9539d63fdb69Smrg droppeddeps=yes 954055acc8fcSmrg echo 9541d63fdb69Smrg $ECHO "*** Warning! Library $i is needed by this library but I was not able to" 954255acc8fcSmrg echo "*** make it link in! You will probably need to install it or some" 954355acc8fcSmrg echo "*** library that it depends on before this library will be fully" 954455acc8fcSmrg echo "*** functional. Installing it before continuing would be even better." 9545d63fdb69Smrg fi 9546d63fdb69Smrg ;; 9547d63fdb69Smrg *) 954848c85eb7Smrg func_append newdeplibs " $i" 9549d63fdb69Smrg ;; 9550d63fdb69Smrg esac 9551d63fdb69Smrg done 9552d63fdb69Smrg fi 9553d63fdb69Smrg ;; 9554d63fdb69Smrg file_magic*) 9555d63fdb69Smrg set dummy $deplibs_check_method; shift 9556d63fdb69Smrg file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 9557d63fdb69Smrg for a_deplib in $deplibs; do 9558d63fdb69Smrg case $a_deplib in 9559d63fdb69Smrg -l*) 9560d63fdb69Smrg func_stripname -l '' "$a_deplib" 9561d63fdb69Smrg name=$func_stripname_result 956252fd71cdSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9563d63fdb69Smrg case " $predeps $postdeps " in 9564d63fdb69Smrg *" $a_deplib "*) 956548c85eb7Smrg func_append newdeplibs " $a_deplib" 956652fd71cdSmrg a_deplib= 9567d63fdb69Smrg ;; 9568d63fdb69Smrg esac 9569d63fdb69Smrg fi 957052fd71cdSmrg if test -n "$a_deplib"; then 9571d63fdb69Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 957248c85eb7Smrg if test -n "$file_magic_glob"; then 957348c85eb7Smrg libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob` 957448c85eb7Smrg else 957548c85eb7Smrg libnameglob=$libname 957648c85eb7Smrg fi 957752fd71cdSmrg test yes = "$want_nocaseglob" && nocaseglob=`shopt -p nocaseglob` 9578d63fdb69Smrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 957952fd71cdSmrg if test yes = "$want_nocaseglob"; then 958048c85eb7Smrg shopt -s nocaseglob 958148c85eb7Smrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 958248c85eb7Smrg $nocaseglob 958348c85eb7Smrg else 958448c85eb7Smrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 958548c85eb7Smrg fi 9586d63fdb69Smrg for potent_lib in $potential_libs; do 9587d63fdb69Smrg # Follow soft links. 9588d63fdb69Smrg if ls -lLd "$potent_lib" 2>/dev/null | 9589d63fdb69Smrg $GREP " -> " >/dev/null; then 9590d63fdb69Smrg continue 9591d63fdb69Smrg fi 9592d63fdb69Smrg # The statement above tries to avoid entering an 9593d63fdb69Smrg # endless loop below, in case of cyclic links. 9594d63fdb69Smrg # We might still enter an endless loop, since a link 9595d63fdb69Smrg # loop can be closed while we follow links, 9596d63fdb69Smrg # but so what? 959752fd71cdSmrg potlib=$potent_lib 9598d63fdb69Smrg while test -h "$potlib" 2>/dev/null; do 959952fd71cdSmrg potliblink=`ls -ld $potlib | $SED 's/.* -> //'` 9600d63fdb69Smrg case $potliblink in 960152fd71cdSmrg [\\/]* | [A-Za-z]:[\\/]*) potlib=$potliblink;; 960252fd71cdSmrg *) potlib=`$ECHO "$potlib" | $SED 's|[^/]*$||'`"$potliblink";; 9603d63fdb69Smrg esac 9604d63fdb69Smrg done 9605d63fdb69Smrg if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | 9606d63fdb69Smrg $SED -e 10q | 9607d63fdb69Smrg $EGREP "$file_magic_regex" > /dev/null; then 960848c85eb7Smrg func_append newdeplibs " $a_deplib" 960952fd71cdSmrg a_deplib= 9610d63fdb69Smrg break 2 9611d63fdb69Smrg fi 9612d63fdb69Smrg done 9613d63fdb69Smrg done 9614d63fdb69Smrg fi 961552fd71cdSmrg if test -n "$a_deplib"; then 9616d63fdb69Smrg droppeddeps=yes 961755acc8fcSmrg echo 9618d63fdb69Smrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 961955acc8fcSmrg echo "*** I have the capability to make that library automatically link in when" 962055acc8fcSmrg echo "*** you link to this library. But I can only do this if you have a" 962155acc8fcSmrg echo "*** shared version of the library, which you do not appear to have" 962255acc8fcSmrg echo "*** because I did check the linker path looking for a file starting" 962352fd71cdSmrg if test -z "$potlib"; then 9624d63fdb69Smrg $ECHO "*** with $libname but no candidates were found. (...for file magic test)" 9625d63fdb69Smrg else 9626d63fdb69Smrg $ECHO "*** with $libname and none of the candidates passed a file format test" 9627d63fdb69Smrg $ECHO "*** using a file magic. Last file checked: $potlib" 9628d63fdb69Smrg fi 9629d63fdb69Smrg fi 9630d63fdb69Smrg ;; 9631d63fdb69Smrg *) 9632d63fdb69Smrg # Add a -L argument. 963348c85eb7Smrg func_append newdeplibs " $a_deplib" 9634d63fdb69Smrg ;; 9635d63fdb69Smrg esac 9636d63fdb69Smrg done # Gone through all deplibs. 9637d63fdb69Smrg ;; 9638d63fdb69Smrg match_pattern*) 9639d63fdb69Smrg set dummy $deplibs_check_method; shift 9640d63fdb69Smrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 9641d63fdb69Smrg for a_deplib in $deplibs; do 9642d63fdb69Smrg case $a_deplib in 9643d63fdb69Smrg -l*) 9644d63fdb69Smrg func_stripname -l '' "$a_deplib" 9645d63fdb69Smrg name=$func_stripname_result 964652fd71cdSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9647d63fdb69Smrg case " $predeps $postdeps " in 9648d63fdb69Smrg *" $a_deplib "*) 964948c85eb7Smrg func_append newdeplibs " $a_deplib" 965052fd71cdSmrg a_deplib= 9651d63fdb69Smrg ;; 9652d63fdb69Smrg esac 9653d63fdb69Smrg fi 965452fd71cdSmrg if test -n "$a_deplib"; then 9655d63fdb69Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 9656d63fdb69Smrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 9657d63fdb69Smrg potential_libs=`ls $i/$libname[.-]* 2>/dev/null` 9658d63fdb69Smrg for potent_lib in $potential_libs; do 965952fd71cdSmrg potlib=$potent_lib # see symlink-check above in file_magic test 966055acc8fcSmrg if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ 9661d63fdb69Smrg $EGREP "$match_pattern_regex" > /dev/null; then 966248c85eb7Smrg func_append newdeplibs " $a_deplib" 966352fd71cdSmrg a_deplib= 9664d63fdb69Smrg break 2 9665d63fdb69Smrg fi 9666d63fdb69Smrg done 9667d63fdb69Smrg done 9668d63fdb69Smrg fi 966952fd71cdSmrg if test -n "$a_deplib"; then 9670d63fdb69Smrg droppeddeps=yes 967155acc8fcSmrg echo 9672d63fdb69Smrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 967355acc8fcSmrg echo "*** I have the capability to make that library automatically link in when" 967455acc8fcSmrg echo "*** you link to this library. But I can only do this if you have a" 967555acc8fcSmrg echo "*** shared version of the library, which you do not appear to have" 967655acc8fcSmrg echo "*** because I did check the linker path looking for a file starting" 967752fd71cdSmrg if test -z "$potlib"; then 9678d63fdb69Smrg $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" 9679d63fdb69Smrg else 9680d63fdb69Smrg $ECHO "*** with $libname and none of the candidates passed a file format test" 9681d63fdb69Smrg $ECHO "*** using a regex pattern. Last file checked: $potlib" 9682d63fdb69Smrg fi 9683d63fdb69Smrg fi 9684d63fdb69Smrg ;; 9685d63fdb69Smrg *) 9686d63fdb69Smrg # Add a -L argument. 968748c85eb7Smrg func_append newdeplibs " $a_deplib" 9688d63fdb69Smrg ;; 9689d63fdb69Smrg esac 9690d63fdb69Smrg done # Gone through all deplibs. 9691d63fdb69Smrg ;; 9692d63fdb69Smrg none | unknown | *) 969352fd71cdSmrg newdeplibs= 969455acc8fcSmrg tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` 969552fd71cdSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 969652fd71cdSmrg for i in $predeps $postdeps; do 9697d63fdb69Smrg # can't use Xsed below, because $i might contain '/' 969852fd71cdSmrg tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s|$i||"` 9699d63fdb69Smrg done 9700d63fdb69Smrg fi 970155acc8fcSmrg case $tmp_deplibs in 970255acc8fcSmrg *[!\ \ ]*) 970355acc8fcSmrg echo 970452fd71cdSmrg if test none = "$deplibs_check_method"; then 970555acc8fcSmrg echo "*** Warning: inter-library dependencies are not supported in this platform." 9706d63fdb69Smrg else 970755acc8fcSmrg echo "*** Warning: inter-library dependencies are not known to be supported." 9708d63fdb69Smrg fi 970955acc8fcSmrg echo "*** All declared inter-library dependencies are being dropped." 9710d63fdb69Smrg droppeddeps=yes 971155acc8fcSmrg ;; 971255acc8fcSmrg esac 9713d63fdb69Smrg ;; 9714d63fdb69Smrg esac 9715d63fdb69Smrg versuffix=$versuffix_save 9716d63fdb69Smrg major=$major_save 9717d63fdb69Smrg release=$release_save 9718d63fdb69Smrg libname=$libname_save 9719d63fdb69Smrg name=$name_save 9720d63fdb69Smrg 9721d63fdb69Smrg case $host in 9722d63fdb69Smrg *-*-rhapsody* | *-*-darwin1.[012]) 9723d63fdb69Smrg # On Rhapsody replace the C library with the System framework 972455acc8fcSmrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` 9725d63fdb69Smrg ;; 9726d63fdb69Smrg esac 9727d63fdb69Smrg 972852fd71cdSmrg if test yes = "$droppeddeps"; then 972952fd71cdSmrg if test yes = "$module"; then 973055acc8fcSmrg echo 973155acc8fcSmrg echo "*** Warning: libtool could not satisfy all declared inter-library" 9732d63fdb69Smrg $ECHO "*** dependencies of module $libname. Therefore, libtool will create" 973355acc8fcSmrg echo "*** a static module, that should work as long as the dlopening" 973455acc8fcSmrg echo "*** application is linked with the -dlopen flag." 9735d63fdb69Smrg if test -z "$global_symbol_pipe"; then 973655acc8fcSmrg echo 973755acc8fcSmrg echo "*** However, this would only work if libtool was able to extract symbol" 973852fd71cdSmrg echo "*** lists from a program, using 'nm' or equivalent, but libtool could" 973955acc8fcSmrg echo "*** not find such a program. So, this module is probably useless." 974052fd71cdSmrg echo "*** 'nm' from GNU binutils and a full rebuild may help." 9741d63fdb69Smrg fi 974252fd71cdSmrg if test no = "$build_old_libs"; then 974352fd71cdSmrg oldlibs=$output_objdir/$libname.$libext 9744d63fdb69Smrg build_libtool_libs=module 9745d63fdb69Smrg build_old_libs=yes 9746d63fdb69Smrg else 9747d63fdb69Smrg build_libtool_libs=no 9748d63fdb69Smrg fi 9749d63fdb69Smrg else 975055acc8fcSmrg echo "*** The inter-library dependencies that have been dropped here will be" 975155acc8fcSmrg echo "*** automatically added whenever a program is linked with this library" 975255acc8fcSmrg echo "*** or is declared to -dlopen it." 9753d63fdb69Smrg 975452fd71cdSmrg if test no = "$allow_undefined"; then 975555acc8fcSmrg echo 975655acc8fcSmrg echo "*** Since this library must not contain undefined symbols," 975755acc8fcSmrg echo "*** because either the platform does not support them or" 975855acc8fcSmrg echo "*** it was explicitly requested with -no-undefined," 975955acc8fcSmrg echo "*** libtool will only create a static version of it." 976052fd71cdSmrg if test no = "$build_old_libs"; then 976152fd71cdSmrg oldlibs=$output_objdir/$libname.$libext 9762d63fdb69Smrg build_libtool_libs=module 9763d63fdb69Smrg build_old_libs=yes 9764d63fdb69Smrg else 9765d63fdb69Smrg build_libtool_libs=no 9766d63fdb69Smrg fi 9767d63fdb69Smrg fi 9768d63fdb69Smrg fi 9769d63fdb69Smrg fi 9770d63fdb69Smrg # Done checking deplibs! 9771d63fdb69Smrg deplibs=$newdeplibs 9772d63fdb69Smrg fi 9773d63fdb69Smrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 9774d63fdb69Smrg case $host in 9775d63fdb69Smrg *-*-darwin*) 977655acc8fcSmrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 977755acc8fcSmrg new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 977855acc8fcSmrg deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 9779d63fdb69Smrg ;; 9780d63fdb69Smrg esac 9781d63fdb69Smrg 9782d63fdb69Smrg # move library search paths that coincide with paths to not yet 9783d63fdb69Smrg # installed libraries to the beginning of the library search list 9784d63fdb69Smrg new_libs= 9785d63fdb69Smrg for path in $notinst_path; do 9786d63fdb69Smrg case " $new_libs " in 9787d63fdb69Smrg *" -L$path/$objdir "*) ;; 9788d63fdb69Smrg *) 9789d63fdb69Smrg case " $deplibs " in 9790d63fdb69Smrg *" -L$path/$objdir "*) 979148c85eb7Smrg func_append new_libs " -L$path/$objdir" ;; 9792d63fdb69Smrg esac 9793d63fdb69Smrg ;; 9794d63fdb69Smrg esac 9795d63fdb69Smrg done 9796d63fdb69Smrg for deplib in $deplibs; do 9797d63fdb69Smrg case $deplib in 9798d63fdb69Smrg -L*) 9799d63fdb69Smrg case " $new_libs " in 9800d63fdb69Smrg *" $deplib "*) ;; 980148c85eb7Smrg *) func_append new_libs " $deplib" ;; 9802d63fdb69Smrg esac 9803d63fdb69Smrg ;; 980448c85eb7Smrg *) func_append new_libs " $deplib" ;; 9805d63fdb69Smrg esac 9806d63fdb69Smrg done 980752fd71cdSmrg deplibs=$new_libs 9808d63fdb69Smrg 9809d63fdb69Smrg # All the library-specific variables (install_libdir is set above). 9810d63fdb69Smrg library_names= 9811d63fdb69Smrg old_library= 9812d63fdb69Smrg dlname= 9813d63fdb69Smrg 9814d63fdb69Smrg # Test again, we may have decided not to build it any more 981552fd71cdSmrg if test yes = "$build_libtool_libs"; then 981652fd71cdSmrg # Remove $wl instances when linking with ld. 981748c85eb7Smrg # FIXME: should test the right _cmds variable. 981848c85eb7Smrg case $archive_cmds in 981948c85eb7Smrg *\$LD\ *) wl= ;; 982048c85eb7Smrg esac 982152fd71cdSmrg if test yes = "$hardcode_into_libs"; then 9822d63fdb69Smrg # Hardcode the library paths 9823d63fdb69Smrg hardcode_libdirs= 9824d63fdb69Smrg dep_rpath= 982552fd71cdSmrg rpath=$finalize_rpath 982652fd71cdSmrg test relink = "$opt_mode" || rpath=$compile_rpath$rpath 9827d63fdb69Smrg for libdir in $rpath; do 9828d63fdb69Smrg if test -n "$hardcode_libdir_flag_spec"; then 9829d63fdb69Smrg if test -n "$hardcode_libdir_separator"; then 983048c85eb7Smrg func_replace_sysroot "$libdir" 983148c85eb7Smrg libdir=$func_replace_sysroot_result 9832d63fdb69Smrg if test -z "$hardcode_libdirs"; then 983352fd71cdSmrg hardcode_libdirs=$libdir 9834d63fdb69Smrg else 9835d63fdb69Smrg # Just accumulate the unique libdirs. 9836d63fdb69Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 9837d63fdb69Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 9838d63fdb69Smrg ;; 9839d63fdb69Smrg *) 984048c85eb7Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 9841d63fdb69Smrg ;; 9842d63fdb69Smrg esac 9843d63fdb69Smrg fi 9844d63fdb69Smrg else 9845d63fdb69Smrg eval flag=\"$hardcode_libdir_flag_spec\" 984648c85eb7Smrg func_append dep_rpath " $flag" 9847d63fdb69Smrg fi 9848d63fdb69Smrg elif test -n "$runpath_var"; then 9849d63fdb69Smrg case "$perm_rpath " in 9850d63fdb69Smrg *" $libdir "*) ;; 985148c85eb7Smrg *) func_append perm_rpath " $libdir" ;; 9852d63fdb69Smrg esac 9853d63fdb69Smrg fi 9854d63fdb69Smrg done 9855d63fdb69Smrg # Substitute the hardcoded libdirs into the rpath. 9856d63fdb69Smrg if test -n "$hardcode_libdir_separator" && 9857d63fdb69Smrg test -n "$hardcode_libdirs"; then 985852fd71cdSmrg libdir=$hardcode_libdirs 985948c85eb7Smrg eval "dep_rpath=\"$hardcode_libdir_flag_spec\"" 9860d63fdb69Smrg fi 9861d63fdb69Smrg if test -n "$runpath_var" && test -n "$perm_rpath"; then 9862d63fdb69Smrg # We should set the runpath_var. 9863d63fdb69Smrg rpath= 9864d63fdb69Smrg for dir in $perm_rpath; do 986548c85eb7Smrg func_append rpath "$dir:" 9866d63fdb69Smrg done 9867d63fdb69Smrg eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" 9868d63fdb69Smrg fi 9869d63fdb69Smrg test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" 9870d63fdb69Smrg fi 98713da084b3Smrg 987252fd71cdSmrg shlibpath=$finalize_shlibpath 987352fd71cdSmrg test relink = "$opt_mode" || shlibpath=$compile_shlibpath$shlibpath 9874d63fdb69Smrg if test -n "$shlibpath"; then 9875d63fdb69Smrg eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" 9876d63fdb69Smrg fi 98773da084b3Smrg 9878d63fdb69Smrg # Get the real and link names of the library. 9879d63fdb69Smrg eval shared_ext=\"$shrext_cmds\" 9880d63fdb69Smrg eval library_names=\"$library_names_spec\" 9881d63fdb69Smrg set dummy $library_names 9882d63fdb69Smrg shift 988352fd71cdSmrg realname=$1 9884d63fdb69Smrg shift 98853da084b3Smrg 9886d63fdb69Smrg if test -n "$soname_spec"; then 9887d63fdb69Smrg eval soname=\"$soname_spec\" 9888d63fdb69Smrg else 988952fd71cdSmrg soname=$realname 9890d63fdb69Smrg fi 9891d63fdb69Smrg if test -z "$dlname"; then 9892d63fdb69Smrg dlname=$soname 9893d63fdb69Smrg fi 98943da084b3Smrg 989552fd71cdSmrg lib=$output_objdir/$realname 9896d63fdb69Smrg linknames= 9897d63fdb69Smrg for link 9898d63fdb69Smrg do 989948c85eb7Smrg func_append linknames " $link" 9900d63fdb69Smrg done 99013da084b3Smrg 9902d63fdb69Smrg # Use standard objects if they are pic 990355acc8fcSmrg test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` 9904d63fdb69Smrg test "X$libobjs" = "X " && libobjs= 99053da084b3Smrg 9906d63fdb69Smrg delfiles= 9907d63fdb69Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 9908d63fdb69Smrg $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" 990952fd71cdSmrg export_symbols=$output_objdir/$libname.uexp 991048c85eb7Smrg func_append delfiles " $export_symbols" 9911d63fdb69Smrg fi 99123da084b3Smrg 9913d63fdb69Smrg orig_export_symbols= 9914d63fdb69Smrg case $host_os in 9915d63fdb69Smrg cygwin* | mingw* | cegcc*) 9916d63fdb69Smrg if test -n "$export_symbols" && test -z "$export_symbols_regex"; then 9917d63fdb69Smrg # exporting using user supplied symfile 991852fd71cdSmrg func_dll_def_p "$export_symbols" || { 9919d63fdb69Smrg # and it's NOT already a .def file. Must figure out 9920d63fdb69Smrg # which of the given symbols are data symbols and tag 9921d63fdb69Smrg # them as such. So, trigger use of export_symbols_cmds. 9922d63fdb69Smrg # export_symbols gets reassigned inside the "prepare 9923d63fdb69Smrg # the list of exported symbols" if statement, so the 9924d63fdb69Smrg # include_expsyms logic still works. 992552fd71cdSmrg orig_export_symbols=$export_symbols 9926d63fdb69Smrg export_symbols= 9927d63fdb69Smrg always_export_symbols=yes 992852fd71cdSmrg } 9929d63fdb69Smrg fi 9930d63fdb69Smrg ;; 9931d63fdb69Smrg esac 99323da084b3Smrg 9933d63fdb69Smrg # Prepare the list of exported symbols 9934d63fdb69Smrg if test -z "$export_symbols"; then 993552fd71cdSmrg if test yes = "$always_export_symbols" || test -n "$export_symbols_regex"; then 993652fd71cdSmrg func_verbose "generating symbol list for '$libname.la'" 993752fd71cdSmrg export_symbols=$output_objdir/$libname.exp 9938d63fdb69Smrg $opt_dry_run || $RM $export_symbols 9939d63fdb69Smrg cmds=$export_symbols_cmds 994052fd71cdSmrg save_ifs=$IFS; IFS='~' 994148c85eb7Smrg for cmd1 in $cmds; do 994252fd71cdSmrg IFS=$save_ifs 994348c85eb7Smrg # Take the normal branch if the nm_file_list_spec branch 994448c85eb7Smrg # doesn't work or if tool conversion is not needed. 994548c85eb7Smrg case $nm_file_list_spec~$to_tool_file_cmd in 994648c85eb7Smrg *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) 994748c85eb7Smrg try_normal_branch=yes 994848c85eb7Smrg eval cmd=\"$cmd1\" 994948c85eb7Smrg func_len " $cmd" 995048c85eb7Smrg len=$func_len_result 995148c85eb7Smrg ;; 995248c85eb7Smrg *) 995348c85eb7Smrg try_normal_branch=no 995448c85eb7Smrg ;; 995548c85eb7Smrg esac 995652fd71cdSmrg if test yes = "$try_normal_branch" \ 995748c85eb7Smrg && { test "$len" -lt "$max_cmd_len" \ 995848c85eb7Smrg || test "$max_cmd_len" -le -1; } 995948c85eb7Smrg then 996048c85eb7Smrg func_show_eval "$cmd" 'exit $?' 996148c85eb7Smrg skipped_export=false 996248c85eb7Smrg elif test -n "$nm_file_list_spec"; then 996348c85eb7Smrg func_basename "$output" 996448c85eb7Smrg output_la=$func_basename_result 996548c85eb7Smrg save_libobjs=$libobjs 996648c85eb7Smrg save_output=$output 996752fd71cdSmrg output=$output_objdir/$output_la.nm 996848c85eb7Smrg func_to_tool_file "$output" 996948c85eb7Smrg libobjs=$nm_file_list_spec$func_to_tool_file_result 997048c85eb7Smrg func_append delfiles " $output" 997148c85eb7Smrg func_verbose "creating $NM input file list: $output" 997248c85eb7Smrg for obj in $save_libobjs; do 997348c85eb7Smrg func_to_tool_file "$obj" 997448c85eb7Smrg $ECHO "$func_to_tool_file_result" 997548c85eb7Smrg done > "$output" 997648c85eb7Smrg eval cmd=\"$cmd1\" 9977d63fdb69Smrg func_show_eval "$cmd" 'exit $?' 997848c85eb7Smrg output=$save_output 997948c85eb7Smrg libobjs=$save_libobjs 9980d63fdb69Smrg skipped_export=false 9981d63fdb69Smrg else 9982d63fdb69Smrg # The command line is too long to execute in one step. 9983d63fdb69Smrg func_verbose "using reloadable object file for export list..." 9984d63fdb69Smrg skipped_export=: 9985d63fdb69Smrg # Break out early, otherwise skipped_export may be 9986d63fdb69Smrg # set to false by a later but shorter cmd. 9987d63fdb69Smrg break 9988d63fdb69Smrg fi 9989d63fdb69Smrg done 999052fd71cdSmrg IFS=$save_ifs 999152fd71cdSmrg if test -n "$export_symbols_regex" && test : != "$skipped_export"; then 9992d63fdb69Smrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 9993d63fdb69Smrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 9994d63fdb69Smrg fi 9995d63fdb69Smrg fi 9996d63fdb69Smrg fi 99973da084b3Smrg 9998d63fdb69Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 999952fd71cdSmrg tmp_export_symbols=$export_symbols 1000052fd71cdSmrg test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols 1000155acc8fcSmrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 10002d63fdb69Smrg fi 100033da084b3Smrg 1000452fd71cdSmrg if test : != "$skipped_export" && test -n "$orig_export_symbols"; then 10005d63fdb69Smrg # The given exports_symbols file has to be filtered, so filter it. 1000652fd71cdSmrg func_verbose "filter symbol list for '$libname.la' to tag DATA exports" 10007d63fdb69Smrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 1000852fd71cdSmrg # 's' commands, which not all seds can handle. GNU sed should be fine 10009d63fdb69Smrg # though. Also, the filter scales superlinearly with the number of 10010d63fdb69Smrg # global variables. join(1) would be nice here, but unfortunately 10011d63fdb69Smrg # isn't a blessed tool. 10012d63fdb69Smrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 1001348c85eb7Smrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 10014d63fdb69Smrg export_symbols=$output_objdir/$libname.def 10015d63fdb69Smrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 100163da084b3Smrg fi 100173da084b3Smrg 10018d63fdb69Smrg tmp_deplibs= 10019d63fdb69Smrg for test_deplib in $deplibs; do 10020d63fdb69Smrg case " $convenience " in 10021d63fdb69Smrg *" $test_deplib "*) ;; 10022d63fdb69Smrg *) 1002348c85eb7Smrg func_append tmp_deplibs " $test_deplib" 10024d63fdb69Smrg ;; 10025d63fdb69Smrg esac 10026d63fdb69Smrg done 1002752fd71cdSmrg deplibs=$tmp_deplibs 100283da084b3Smrg 10029d63fdb69Smrg if test -n "$convenience"; then 10030d63fdb69Smrg if test -n "$whole_archive_flag_spec" && 1003152fd71cdSmrg test yes = "$compiler_needs_object" && 10032d63fdb69Smrg test -z "$libobjs"; then 10033d63fdb69Smrg # extract the archives, so we have objects to list. 10034d63fdb69Smrg # TODO: could optimize this to just extract one archive. 10035d63fdb69Smrg whole_archive_flag_spec= 10036d63fdb69Smrg fi 10037d63fdb69Smrg if test -n "$whole_archive_flag_spec"; then 10038d63fdb69Smrg save_libobjs=$libobjs 10039d63fdb69Smrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 10040d63fdb69Smrg test "X$libobjs" = "X " && libobjs= 10041d63fdb69Smrg else 1004252fd71cdSmrg gentop=$output_objdir/${outputname}x 1004348c85eb7Smrg func_append generated " $gentop" 100443da084b3Smrg 10045d63fdb69Smrg func_extract_archives $gentop $convenience 1004648c85eb7Smrg func_append libobjs " $func_extract_archives_result" 10047d63fdb69Smrg test "X$libobjs" = "X " && libobjs= 10048d63fdb69Smrg fi 10049d63fdb69Smrg fi 100503da084b3Smrg 1005152fd71cdSmrg if test yes = "$thread_safe" && test -n "$thread_safe_flag_spec"; then 10052d63fdb69Smrg eval flag=\"$thread_safe_flag_spec\" 1005348c85eb7Smrg func_append linker_flags " $flag" 10054d63fdb69Smrg fi 100553da084b3Smrg 10056d63fdb69Smrg # Make a backup of the uninstalled library when relinking 1005752fd71cdSmrg if test relink = "$opt_mode"; then 10058d63fdb69Smrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? 100593da084b3Smrg fi 100603da084b3Smrg 10061d63fdb69Smrg # Do each of the archive commands. 1006252fd71cdSmrg if test yes = "$module" && test -n "$module_cmds"; then 10063d63fdb69Smrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 10064d63fdb69Smrg eval test_cmds=\"$module_expsym_cmds\" 10065d63fdb69Smrg cmds=$module_expsym_cmds 10066d63fdb69Smrg else 10067d63fdb69Smrg eval test_cmds=\"$module_cmds\" 10068d63fdb69Smrg cmds=$module_cmds 10069d63fdb69Smrg fi 10070d63fdb69Smrg else 10071d63fdb69Smrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 10072d63fdb69Smrg eval test_cmds=\"$archive_expsym_cmds\" 10073d63fdb69Smrg cmds=$archive_expsym_cmds 10074d63fdb69Smrg else 10075d63fdb69Smrg eval test_cmds=\"$archive_cmds\" 10076d63fdb69Smrg cmds=$archive_cmds 10077d63fdb69Smrg fi 100783da084b3Smrg fi 100793da084b3Smrg 1008052fd71cdSmrg if test : != "$skipped_export" && 10081d63fdb69Smrg func_len " $test_cmds" && 10082d63fdb69Smrg len=$func_len_result && 10083d63fdb69Smrg test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 10084d63fdb69Smrg : 10085d63fdb69Smrg else 10086d63fdb69Smrg # The command line is too long to link in one step, link piecewise 10087d63fdb69Smrg # or, if using GNU ld and skipped_export is not :, use a linker 10088d63fdb69Smrg # script. 100893da084b3Smrg 10090d63fdb69Smrg # Save the value of $output and $libobjs because we want to 10091d63fdb69Smrg # use them later. If we have whole_archive_flag_spec, we 10092d63fdb69Smrg # want to use save_libobjs as it was before 10093d63fdb69Smrg # whole_archive_flag_spec was expanded, because we can't 10094d63fdb69Smrg # assume the linker understands whole_archive_flag_spec. 10095d63fdb69Smrg # This may have to be revisited, in case too many 10096d63fdb69Smrg # convenience libraries get linked in and end up exceeding 10097d63fdb69Smrg # the spec. 10098d63fdb69Smrg if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then 10099d63fdb69Smrg save_libobjs=$libobjs 10100d63fdb69Smrg fi 10101d63fdb69Smrg save_output=$output 1010255acc8fcSmrg func_basename "$output" 1010355acc8fcSmrg output_la=$func_basename_result 101043da084b3Smrg 10105d63fdb69Smrg # Clear the reloadable object creation command queue and 10106d63fdb69Smrg # initialize k to one. 10107d63fdb69Smrg test_cmds= 10108d63fdb69Smrg concat_cmds= 10109d63fdb69Smrg objlist= 10110d63fdb69Smrg last_robj= 10111d63fdb69Smrg k=1 101123da084b3Smrg 1011352fd71cdSmrg if test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then 1011452fd71cdSmrg output=$output_objdir/$output_la.lnkscript 10115d63fdb69Smrg func_verbose "creating GNU ld script: $output" 1011655acc8fcSmrg echo 'INPUT (' > $output 10117d63fdb69Smrg for obj in $save_libobjs 10118d63fdb69Smrg do 1011948c85eb7Smrg func_to_tool_file "$obj" 1012048c85eb7Smrg $ECHO "$func_to_tool_file_result" >> $output 10121d63fdb69Smrg done 1012255acc8fcSmrg echo ')' >> $output 1012348c85eb7Smrg func_append delfiles " $output" 1012448c85eb7Smrg func_to_tool_file "$output" 1012548c85eb7Smrg output=$func_to_tool_file_result 1012652fd71cdSmrg elif test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then 1012752fd71cdSmrg output=$output_objdir/$output_la.lnk 10128d63fdb69Smrg func_verbose "creating linker input file list: $output" 10129d63fdb69Smrg : > $output 10130d63fdb69Smrg set x $save_libobjs 10131d63fdb69Smrg shift 10132d63fdb69Smrg firstobj= 1013352fd71cdSmrg if test yes = "$compiler_needs_object"; then 10134d63fdb69Smrg firstobj="$1 " 10135d63fdb69Smrg shift 10136d63fdb69Smrg fi 10137d63fdb69Smrg for obj 10138d63fdb69Smrg do 1013948c85eb7Smrg func_to_tool_file "$obj" 1014048c85eb7Smrg $ECHO "$func_to_tool_file_result" >> $output 10141d63fdb69Smrg done 1014248c85eb7Smrg func_append delfiles " $output" 1014348c85eb7Smrg func_to_tool_file "$output" 1014448c85eb7Smrg output=$firstobj\"$file_list_spec$func_to_tool_file_result\" 10145d63fdb69Smrg else 10146d63fdb69Smrg if test -n "$save_libobjs"; then 10147d63fdb69Smrg func_verbose "creating reloadable object files..." 1014852fd71cdSmrg output=$output_objdir/$output_la-$k.$objext 10149d63fdb69Smrg eval test_cmds=\"$reload_cmds\" 10150d63fdb69Smrg func_len " $test_cmds" 10151d63fdb69Smrg len0=$func_len_result 10152d63fdb69Smrg len=$len0 10153d63fdb69Smrg 10154d63fdb69Smrg # Loop over the list of objects to be linked. 10155d63fdb69Smrg for obj in $save_libobjs 10156d63fdb69Smrg do 10157d63fdb69Smrg func_len " $obj" 10158d63fdb69Smrg func_arith $len + $func_len_result 10159d63fdb69Smrg len=$func_arith_result 1016052fd71cdSmrg if test -z "$objlist" || 10161d63fdb69Smrg test "$len" -lt "$max_cmd_len"; then 10162d63fdb69Smrg func_append objlist " $obj" 10163d63fdb69Smrg else 10164d63fdb69Smrg # The command $test_cmds is almost too long, add a 10165d63fdb69Smrg # command to the queue. 1016652fd71cdSmrg if test 1 -eq "$k"; then 10167d63fdb69Smrg # The first file doesn't have a previous command to add. 1016855acc8fcSmrg reload_objs=$objlist 1016955acc8fcSmrg eval concat_cmds=\"$reload_cmds\" 10170d63fdb69Smrg else 10171d63fdb69Smrg # All subsequent reloadable object files will link in 10172d63fdb69Smrg # the last one created. 1017355acc8fcSmrg reload_objs="$objlist $last_robj" 1017455acc8fcSmrg eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" 10175d63fdb69Smrg fi 1017652fd71cdSmrg last_robj=$output_objdir/$output_la-$k.$objext 10177d63fdb69Smrg func_arith $k + 1 10178d63fdb69Smrg k=$func_arith_result 1017952fd71cdSmrg output=$output_objdir/$output_la-$k.$objext 1018055acc8fcSmrg objlist=" $obj" 10181d63fdb69Smrg func_len " $last_robj" 10182d63fdb69Smrg func_arith $len0 + $func_len_result 10183d63fdb69Smrg len=$func_arith_result 10184d63fdb69Smrg fi 10185d63fdb69Smrg done 10186d63fdb69Smrg # Handle the remaining objects by creating one last 10187d63fdb69Smrg # reloadable object file. All subsequent reloadable object 10188d63fdb69Smrg # files will link in the last one created. 10189d63fdb69Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 1019055acc8fcSmrg reload_objs="$objlist $last_robj" 1019152fd71cdSmrg eval concat_cmds=\"\$concat_cmds$reload_cmds\" 10192d63fdb69Smrg if test -n "$last_robj"; then 1019352fd71cdSmrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 10194d63fdb69Smrg fi 1019548c85eb7Smrg func_append delfiles " $output" 101963da084b3Smrg 10197d63fdb69Smrg else 10198d63fdb69Smrg output= 10199d63fdb69Smrg fi 102003da084b3Smrg 1020152fd71cdSmrg ${skipped_export-false} && { 1020252fd71cdSmrg func_verbose "generating symbol list for '$libname.la'" 1020352fd71cdSmrg export_symbols=$output_objdir/$libname.exp 10204d63fdb69Smrg $opt_dry_run || $RM $export_symbols 10205d63fdb69Smrg libobjs=$output 10206d63fdb69Smrg # Append the command to create the export file. 10207d63fdb69Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 10208d63fdb69Smrg eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" 10209d63fdb69Smrg if test -n "$last_robj"; then 10210d63fdb69Smrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 10211d63fdb69Smrg fi 1021252fd71cdSmrg } 102133da084b3Smrg 10214d63fdb69Smrg test -n "$save_libobjs" && 10215d63fdb69Smrg func_verbose "creating a temporary reloadable object file: $output" 102163da084b3Smrg 10217d63fdb69Smrg # Loop through the commands generated above and execute them. 1021852fd71cdSmrg save_ifs=$IFS; IFS='~' 10219d63fdb69Smrg for cmd in $concat_cmds; do 1022052fd71cdSmrg IFS=$save_ifs 1022152fd71cdSmrg $opt_quiet || { 102222a53b785Smrg func_quote_arg expand,pretty "$cmd" 102232a53b785Smrg eval "func_echo $func_quote_arg_result" 10224d63fdb69Smrg } 10225d63fdb69Smrg $opt_dry_run || eval "$cmd" || { 10226d63fdb69Smrg lt_exit=$? 10227d63fdb69Smrg 10228d63fdb69Smrg # Restore the uninstalled library and exit 1022952fd71cdSmrg if test relink = "$opt_mode"; then 10230d63fdb69Smrg ( cd "$output_objdir" && \ 10231d63fdb69Smrg $RM "${realname}T" && \ 10232d63fdb69Smrg $MV "${realname}U" "$realname" ) 10233d63fdb69Smrg fi 102343da084b3Smrg 10235d63fdb69Smrg exit $lt_exit 10236d63fdb69Smrg } 10237d63fdb69Smrg done 1023852fd71cdSmrg IFS=$save_ifs 10239d63fdb69Smrg 10240d63fdb69Smrg if test -n "$export_symbols_regex" && ${skipped_export-false}; then 10241d63fdb69Smrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 10242d63fdb69Smrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 102433da084b3Smrg fi 102443da084b3Smrg fi 102453da084b3Smrg 1024652fd71cdSmrg ${skipped_export-false} && { 10247d63fdb69Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 1024852fd71cdSmrg tmp_export_symbols=$export_symbols 1024952fd71cdSmrg test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols 1025055acc8fcSmrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 10251d63fdb69Smrg fi 102523da084b3Smrg 10253d63fdb69Smrg if test -n "$orig_export_symbols"; then 10254d63fdb69Smrg # The given exports_symbols file has to be filtered, so filter it. 1025552fd71cdSmrg func_verbose "filter symbol list for '$libname.la' to tag DATA exports" 10256d63fdb69Smrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 1025752fd71cdSmrg # 's' commands, which not all seds can handle. GNU sed should be fine 10258d63fdb69Smrg # though. Also, the filter scales superlinearly with the number of 10259d63fdb69Smrg # global variables. join(1) would be nice here, but unfortunately 10260d63fdb69Smrg # isn't a blessed tool. 10261d63fdb69Smrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 1026248c85eb7Smrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 10263d63fdb69Smrg export_symbols=$output_objdir/$libname.def 10264d63fdb69Smrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 10265d63fdb69Smrg fi 1026652fd71cdSmrg } 102673da084b3Smrg 10268d63fdb69Smrg libobjs=$output 10269d63fdb69Smrg # Restore the value of output. 10270d63fdb69Smrg output=$save_output 102713da084b3Smrg 10272d63fdb69Smrg if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then 10273d63fdb69Smrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 10274d63fdb69Smrg test "X$libobjs" = "X " && libobjs= 10275d63fdb69Smrg fi 10276d63fdb69Smrg # Expand the library linking commands again to reset the 10277d63fdb69Smrg # value of $libobjs for piecewise linking. 10278d63fdb69Smrg 10279d63fdb69Smrg # Do each of the archive commands. 1028052fd71cdSmrg if test yes = "$module" && test -n "$module_cmds"; then 10281d63fdb69Smrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 10282d63fdb69Smrg cmds=$module_expsym_cmds 102833da084b3Smrg else 10284d63fdb69Smrg cmds=$module_cmds 102853da084b3Smrg fi 102863da084b3Smrg else 10287d63fdb69Smrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 10288d63fdb69Smrg cmds=$archive_expsym_cmds 10289d63fdb69Smrg else 10290d63fdb69Smrg cmds=$archive_cmds 10291d63fdb69Smrg fi 102923da084b3Smrg fi 102933da084b3Smrg fi 102943da084b3Smrg 10295d63fdb69Smrg if test -n "$delfiles"; then 10296d63fdb69Smrg # Append the command to remove temporary files to $cmds. 10297d63fdb69Smrg eval cmds=\"\$cmds~\$RM $delfiles\" 10298d63fdb69Smrg fi 102993da084b3Smrg 10300d63fdb69Smrg # Add any objects from preloaded convenience libraries 10301d63fdb69Smrg if test -n "$dlprefiles"; then 1030252fd71cdSmrg gentop=$output_objdir/${outputname}x 1030348c85eb7Smrg func_append generated " $gentop" 103043da084b3Smrg 10305d63fdb69Smrg func_extract_archives $gentop $dlprefiles 1030648c85eb7Smrg func_append libobjs " $func_extract_archives_result" 10307d63fdb69Smrg test "X$libobjs" = "X " && libobjs= 103083da084b3Smrg fi 103093da084b3Smrg 1031052fd71cdSmrg save_ifs=$IFS; IFS='~' 10311d63fdb69Smrg for cmd in $cmds; do 1031252fd71cdSmrg IFS=$sp$nl 10313d63fdb69Smrg eval cmd=\"$cmd\" 1031452fd71cdSmrg IFS=$save_ifs 1031552fd71cdSmrg $opt_quiet || { 103162a53b785Smrg func_quote_arg expand,pretty "$cmd" 103172a53b785Smrg eval "func_echo $func_quote_arg_result" 10318d63fdb69Smrg } 10319d63fdb69Smrg $opt_dry_run || eval "$cmd" || { 10320d63fdb69Smrg lt_exit=$? 103213da084b3Smrg 10322d63fdb69Smrg # Restore the uninstalled library and exit 1032352fd71cdSmrg if test relink = "$opt_mode"; then 10324d63fdb69Smrg ( cd "$output_objdir" && \ 10325d63fdb69Smrg $RM "${realname}T" && \ 10326d63fdb69Smrg $MV "${realname}U" "$realname" ) 10327d63fdb69Smrg fi 10328d63fdb69Smrg 10329d63fdb69Smrg exit $lt_exit 10330d63fdb69Smrg } 10331d63fdb69Smrg done 1033252fd71cdSmrg IFS=$save_ifs 10333d63fdb69Smrg 10334d63fdb69Smrg # Restore the uninstalled library and exit 1033552fd71cdSmrg if test relink = "$opt_mode"; then 10336d63fdb69Smrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? 10337d63fdb69Smrg 10338d63fdb69Smrg if test -n "$convenience"; then 10339d63fdb69Smrg if test -z "$whole_archive_flag_spec"; then 10340d63fdb69Smrg func_show_eval '${RM}r "$gentop"' 103413da084b3Smrg fi 103423da084b3Smrg fi 103433da084b3Smrg 10344d63fdb69Smrg exit $EXIT_SUCCESS 10345d63fdb69Smrg fi 103463da084b3Smrg 10347d63fdb69Smrg # Create links to the real library. 10348d63fdb69Smrg for linkname in $linknames; do 10349d63fdb69Smrg if test "$realname" != "$linkname"; then 10350d63fdb69Smrg func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' 10351d63fdb69Smrg fi 10352d63fdb69Smrg done 10353d63fdb69Smrg 10354d63fdb69Smrg # If -module or -export-dynamic was specified, set the dlname. 1035552fd71cdSmrg if test yes = "$module" || test yes = "$export_dynamic"; then 10356d63fdb69Smrg # On all known operating systems, these are identical. 1035752fd71cdSmrg dlname=$soname 10358d63fdb69Smrg fi 10359d63fdb69Smrg fi 10360d63fdb69Smrg ;; 10361d63fdb69Smrg 10362d63fdb69Smrg obj) 1036352fd71cdSmrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 1036452fd71cdSmrg func_warning "'-dlopen' is ignored for objects" 10365d63fdb69Smrg fi 10366d63fdb69Smrg 10367d63fdb69Smrg case " $deplibs" in 10368d63fdb69Smrg *\ -l* | *\ -L*) 1036952fd71cdSmrg func_warning "'-l' and '-L' are ignored for objects" ;; 10370d63fdb69Smrg esac 10371d63fdb69Smrg 10372d63fdb69Smrg test -n "$rpath" && \ 1037352fd71cdSmrg func_warning "'-rpath' is ignored for objects" 10374d63fdb69Smrg 10375d63fdb69Smrg test -n "$xrpath" && \ 1037652fd71cdSmrg func_warning "'-R' is ignored for objects" 10377d63fdb69Smrg 10378d63fdb69Smrg test -n "$vinfo" && \ 1037952fd71cdSmrg func_warning "'-version-info' is ignored for objects" 10380d63fdb69Smrg 10381d63fdb69Smrg test -n "$release" && \ 1038252fd71cdSmrg func_warning "'-release' is ignored for objects" 10383d63fdb69Smrg 10384d63fdb69Smrg case $output in 10385d63fdb69Smrg *.lo) 10386d63fdb69Smrg test -n "$objs$old_deplibs" && \ 1038752fd71cdSmrg func_fatal_error "cannot build library object '$output' from non-libtool objects" 10388d63fdb69Smrg 10389d63fdb69Smrg libobj=$output 10390d63fdb69Smrg func_lo2o "$libobj" 10391d63fdb69Smrg obj=$func_lo2o_result 10392d63fdb69Smrg ;; 10393d63fdb69Smrg *) 10394d63fdb69Smrg libobj= 1039552fd71cdSmrg obj=$output 10396d63fdb69Smrg ;; 10397d63fdb69Smrg esac 10398d63fdb69Smrg 10399d63fdb69Smrg # Delete the old objects. 10400d63fdb69Smrg $opt_dry_run || $RM $obj $libobj 10401d63fdb69Smrg 10402d63fdb69Smrg # Objects from convenience libraries. This assumes 10403d63fdb69Smrg # single-version convenience libraries. Whenever we create 10404d63fdb69Smrg # different ones for PIC/non-PIC, this we'll have to duplicate 10405d63fdb69Smrg # the extraction. 10406d63fdb69Smrg reload_conv_objs= 10407d63fdb69Smrg gentop= 1040852fd71cdSmrg # if reload_cmds runs $LD directly, get rid of -Wl from 1040952fd71cdSmrg # whole_archive_flag_spec and hope we can get by with turning comma 1041052fd71cdSmrg # into space. 1041152fd71cdSmrg case $reload_cmds in 1041252fd71cdSmrg *\$LD[\ \$]*) wl= ;; 1041352fd71cdSmrg esac 10414d63fdb69Smrg if test -n "$convenience"; then 10415d63fdb69Smrg if test -n "$whole_archive_flag_spec"; then 10416d63fdb69Smrg eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" 1041752fd71cdSmrg test -n "$wl" || tmp_whole_archive_flags=`$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` 1041852fd71cdSmrg reload_conv_objs=$reload_objs\ $tmp_whole_archive_flags 10419d63fdb69Smrg else 1042052fd71cdSmrg gentop=$output_objdir/${obj}x 1042148c85eb7Smrg func_append generated " $gentop" 10422d63fdb69Smrg 10423d63fdb69Smrg func_extract_archives $gentop $convenience 10424d63fdb69Smrg reload_conv_objs="$reload_objs $func_extract_archives_result" 10425d63fdb69Smrg fi 10426d63fdb69Smrg fi 104273da084b3Smrg 1042848c85eb7Smrg # If we're not building shared, we need to use non_pic_objs 1042952fd71cdSmrg test yes = "$build_libtool_libs" || libobjs=$non_pic_objects 1043048c85eb7Smrg 10431d63fdb69Smrg # Create the old-style object. 1043252fd71cdSmrg reload_objs=$objs$old_deplibs' '`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; /\.lib$/d; $lo2o" | $NL2SP`' '$reload_conv_objs 104333da084b3Smrg 1043452fd71cdSmrg output=$obj 10435d63fdb69Smrg func_execute_cmds "$reload_cmds" 'exit $?' 104363da084b3Smrg 10437d63fdb69Smrg # Exit if we aren't doing a library object file. 10438d63fdb69Smrg if test -z "$libobj"; then 10439d63fdb69Smrg if test -n "$gentop"; then 10440d63fdb69Smrg func_show_eval '${RM}r "$gentop"' 10441d63fdb69Smrg fi 104423da084b3Smrg 10443d63fdb69Smrg exit $EXIT_SUCCESS 10444d63fdb69Smrg fi 104453da084b3Smrg 1044652fd71cdSmrg test yes = "$build_libtool_libs" || { 10447d63fdb69Smrg if test -n "$gentop"; then 10448d63fdb69Smrg func_show_eval '${RM}r "$gentop"' 10449d63fdb69Smrg fi 104503da084b3Smrg 10451d63fdb69Smrg # Create an invalid libtool object if no PIC, so that we don't 10452d63fdb69Smrg # accidentally link it into a program. 10453d63fdb69Smrg # $show "echo timestamp > $libobj" 10454d63fdb69Smrg # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? 10455d63fdb69Smrg exit $EXIT_SUCCESS 1045652fd71cdSmrg } 104573da084b3Smrg 1045852fd71cdSmrg if test -n "$pic_flag" || test default != "$pic_mode"; then 10459d63fdb69Smrg # Only do commands if we really have different PIC objects. 10460d63fdb69Smrg reload_objs="$libobjs $reload_conv_objs" 1046152fd71cdSmrg output=$libobj 10462d63fdb69Smrg func_execute_cmds "$reload_cmds" 'exit $?' 104633da084b3Smrg fi 104643da084b3Smrg 10465d63fdb69Smrg if test -n "$gentop"; then 10466d63fdb69Smrg func_show_eval '${RM}r "$gentop"' 10467d63fdb69Smrg fi 104683da084b3Smrg 10469d63fdb69Smrg exit $EXIT_SUCCESS 10470d63fdb69Smrg ;; 104713da084b3Smrg 10472d63fdb69Smrg prog) 10473d63fdb69Smrg case $host in 10474d63fdb69Smrg *cygwin*) func_stripname '' '.exe' "$output" 10475d63fdb69Smrg output=$func_stripname_result.exe;; 104763da084b3Smrg esac 10477d63fdb69Smrg test -n "$vinfo" && \ 1047852fd71cdSmrg func_warning "'-version-info' is ignored for programs" 104793da084b3Smrg 10480d63fdb69Smrg test -n "$release" && \ 1048152fd71cdSmrg func_warning "'-release' is ignored for programs" 104823da084b3Smrg 1048352fd71cdSmrg $preload \ 1048452fd71cdSmrg && test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \ 1048552fd71cdSmrg && func_warning "'LT_INIT([dlopen])' not used. Assuming no dlopen support." 104863da084b3Smrg 10487d63fdb69Smrg case $host in 10488d63fdb69Smrg *-*-rhapsody* | *-*-darwin1.[012]) 10489d63fdb69Smrg # On Rhapsody replace the C library is the System framework 1049055acc8fcSmrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` 1049155acc8fcSmrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` 104923da084b3Smrg ;; 104933da084b3Smrg esac 104943da084b3Smrg 10495d63fdb69Smrg case $host in 10496d63fdb69Smrg *-*-darwin*) 10497d63fdb69Smrg # Don't allow lazy linking, it breaks C++ global constructors 10498d63fdb69Smrg # But is supposedly fixed on 10.4 or later (yay!). 1049952fd71cdSmrg if test CXX = "$tagname"; then 10500d63fdb69Smrg case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 10501d63fdb69Smrg 10.[0123]) 1050252fd71cdSmrg func_append compile_command " $wl-bind_at_load" 1050352fd71cdSmrg func_append finalize_command " $wl-bind_at_load" 10504d63fdb69Smrg ;; 10505d63fdb69Smrg esac 10506d63fdb69Smrg fi 10507d63fdb69Smrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 1050855acc8fcSmrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 1050955acc8fcSmrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 105103da084b3Smrg ;; 105113da084b3Smrg esac 105123da084b3Smrg 105133da084b3Smrg 10514d63fdb69Smrg # move library search paths that coincide with paths to not yet 10515d63fdb69Smrg # installed libraries to the beginning of the library search list 10516d63fdb69Smrg new_libs= 10517d63fdb69Smrg for path in $notinst_path; do 10518d63fdb69Smrg case " $new_libs " in 10519d63fdb69Smrg *" -L$path/$objdir "*) ;; 105203da084b3Smrg *) 10521d63fdb69Smrg case " $compile_deplibs " in 10522d63fdb69Smrg *" -L$path/$objdir "*) 1052348c85eb7Smrg func_append new_libs " -L$path/$objdir" ;; 10524d63fdb69Smrg esac 105253da084b3Smrg ;; 105263da084b3Smrg esac 105273da084b3Smrg done 10528d63fdb69Smrg for deplib in $compile_deplibs; do 10529d63fdb69Smrg case $deplib in 10530d63fdb69Smrg -L*) 10531d63fdb69Smrg case " $new_libs " in 10532d63fdb69Smrg *" $deplib "*) ;; 1053348c85eb7Smrg *) func_append new_libs " $deplib" ;; 10534d63fdb69Smrg esac 10535d63fdb69Smrg ;; 1053648c85eb7Smrg *) func_append new_libs " $deplib" ;; 10537d63fdb69Smrg esac 10538d63fdb69Smrg done 1053952fd71cdSmrg compile_deplibs=$new_libs 105403da084b3Smrg 105413da084b3Smrg 1054248c85eb7Smrg func_append compile_command " $compile_deplibs" 1054348c85eb7Smrg func_append finalize_command " $finalize_deplibs" 105443da084b3Smrg 10545d63fdb69Smrg if test -n "$rpath$xrpath"; then 10546d63fdb69Smrg # If the user specified any rpath flags, then add them. 10547d63fdb69Smrg for libdir in $rpath $xrpath; do 10548d63fdb69Smrg # This is the magic to use -rpath. 10549d63fdb69Smrg case "$finalize_rpath " in 10550d63fdb69Smrg *" $libdir "*) ;; 1055148c85eb7Smrg *) func_append finalize_rpath " $libdir" ;; 10552d63fdb69Smrg esac 10553d63fdb69Smrg done 10554d63fdb69Smrg fi 105553da084b3Smrg 10556d63fdb69Smrg # Now hardcode the library paths 10557d63fdb69Smrg rpath= 10558d63fdb69Smrg hardcode_libdirs= 10559d63fdb69Smrg for libdir in $compile_rpath $finalize_rpath; do 10560d63fdb69Smrg if test -n "$hardcode_libdir_flag_spec"; then 10561d63fdb69Smrg if test -n "$hardcode_libdir_separator"; then 10562d63fdb69Smrg if test -z "$hardcode_libdirs"; then 1056352fd71cdSmrg hardcode_libdirs=$libdir 10564d63fdb69Smrg else 10565d63fdb69Smrg # Just accumulate the unique libdirs. 10566d63fdb69Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 10567d63fdb69Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 10568d63fdb69Smrg ;; 10569d63fdb69Smrg *) 1057048c85eb7Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 10571d63fdb69Smrg ;; 10572d63fdb69Smrg esac 10573d63fdb69Smrg fi 10574d63fdb69Smrg else 10575d63fdb69Smrg eval flag=\"$hardcode_libdir_flag_spec\" 1057648c85eb7Smrg func_append rpath " $flag" 10577d63fdb69Smrg fi 10578d63fdb69Smrg elif test -n "$runpath_var"; then 10579d63fdb69Smrg case "$perm_rpath " in 105803da084b3Smrg *" $libdir "*) ;; 1058148c85eb7Smrg *) func_append perm_rpath " $libdir" ;; 105823da084b3Smrg esac 10583d63fdb69Smrg fi 10584d63fdb69Smrg case $host in 10585d63fdb69Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 1058652fd71cdSmrg testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'` 10587d63fdb69Smrg case :$dllsearchpath: in 10588d63fdb69Smrg *":$libdir:"*) ;; 10589d63fdb69Smrg ::) dllsearchpath=$libdir;; 1059048c85eb7Smrg *) func_append dllsearchpath ":$libdir";; 10591d63fdb69Smrg esac 10592d63fdb69Smrg case :$dllsearchpath: in 10593d63fdb69Smrg *":$testbindir:"*) ;; 10594d63fdb69Smrg ::) dllsearchpath=$testbindir;; 1059548c85eb7Smrg *) func_append dllsearchpath ":$testbindir";; 10596d63fdb69Smrg esac 10597d63fdb69Smrg ;; 10598d63fdb69Smrg esac 10599d63fdb69Smrg done 10600d63fdb69Smrg # Substitute the hardcoded libdirs into the rpath. 10601d63fdb69Smrg if test -n "$hardcode_libdir_separator" && 10602d63fdb69Smrg test -n "$hardcode_libdirs"; then 1060352fd71cdSmrg libdir=$hardcode_libdirs 10604d63fdb69Smrg eval rpath=\" $hardcode_libdir_flag_spec\" 10605d63fdb69Smrg fi 1060652fd71cdSmrg compile_rpath=$rpath 10607d63fdb69Smrg 10608d63fdb69Smrg rpath= 10609d63fdb69Smrg hardcode_libdirs= 10610d63fdb69Smrg for libdir in $finalize_rpath; do 10611d63fdb69Smrg if test -n "$hardcode_libdir_flag_spec"; then 10612d63fdb69Smrg if test -n "$hardcode_libdir_separator"; then 10613d63fdb69Smrg if test -z "$hardcode_libdirs"; then 1061452fd71cdSmrg hardcode_libdirs=$libdir 10615d63fdb69Smrg else 10616d63fdb69Smrg # Just accumulate the unique libdirs. 10617d63fdb69Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 10618d63fdb69Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 10619d63fdb69Smrg ;; 10620d63fdb69Smrg *) 1062148c85eb7Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 10622d63fdb69Smrg ;; 10623d63fdb69Smrg esac 10624d63fdb69Smrg fi 10625d63fdb69Smrg else 10626d63fdb69Smrg eval flag=\"$hardcode_libdir_flag_spec\" 1062748c85eb7Smrg func_append rpath " $flag" 10628d63fdb69Smrg fi 10629d63fdb69Smrg elif test -n "$runpath_var"; then 10630d63fdb69Smrg case "$finalize_perm_rpath " in 106313da084b3Smrg *" $libdir "*) ;; 1063248c85eb7Smrg *) func_append finalize_perm_rpath " $libdir" ;; 106333da084b3Smrg esac 106343da084b3Smrg fi 10635d63fdb69Smrg done 10636d63fdb69Smrg # Substitute the hardcoded libdirs into the rpath. 10637d63fdb69Smrg if test -n "$hardcode_libdir_separator" && 10638d63fdb69Smrg test -n "$hardcode_libdirs"; then 1063952fd71cdSmrg libdir=$hardcode_libdirs 10640d63fdb69Smrg eval rpath=\" $hardcode_libdir_flag_spec\" 10641d63fdb69Smrg fi 1064252fd71cdSmrg finalize_rpath=$rpath 106433da084b3Smrg 1064452fd71cdSmrg if test -n "$libobjs" && test yes = "$build_old_libs"; then 10645d63fdb69Smrg # Transform all the library objects into standard objects. 1064655acc8fcSmrg compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 1064755acc8fcSmrg finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 10648d63fdb69Smrg fi 106493da084b3Smrg 1065052fd71cdSmrg func_generate_dlsyms "$outputname" "@PROGRAM@" false 106513da084b3Smrg 10652d63fdb69Smrg # template prelinking step 10653d63fdb69Smrg if test -n "$prelink_cmds"; then 10654d63fdb69Smrg func_execute_cmds "$prelink_cmds" 'exit $?' 10655d63fdb69Smrg fi 106563da084b3Smrg 1065752fd71cdSmrg wrappers_required=: 10658d63fdb69Smrg case $host in 1065955acc8fcSmrg *cegcc* | *mingw32ce*) 1066055acc8fcSmrg # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. 1066152fd71cdSmrg wrappers_required=false 1066255acc8fcSmrg ;; 10663d63fdb69Smrg *cygwin* | *mingw* ) 1066452fd71cdSmrg test yes = "$build_libtool_libs" || wrappers_required=false 10665d63fdb69Smrg ;; 10666d63fdb69Smrg *) 1066752fd71cdSmrg if test no = "$need_relink" || test yes != "$build_libtool_libs"; then 1066852fd71cdSmrg wrappers_required=false 10669d63fdb69Smrg fi 10670d63fdb69Smrg ;; 10671d63fdb69Smrg esac 1067252fd71cdSmrg $wrappers_required || { 10673d63fdb69Smrg # Replace the output file specification. 1067455acc8fcSmrg compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 1067552fd71cdSmrg link_command=$compile_command$compile_rpath 106763da084b3Smrg 10677d63fdb69Smrg # We have no uninstalled library dependencies, so finalize right now. 10678d63fdb69Smrg exit_status=0 10679d63fdb69Smrg func_show_eval "$link_command" 'exit_status=$?' 106803da084b3Smrg 1068148c85eb7Smrg if test -n "$postlink_cmds"; then 1068248c85eb7Smrg func_to_tool_file "$output" 1068348c85eb7Smrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 1068448c85eb7Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 1068548c85eb7Smrg fi 1068648c85eb7Smrg 10687d63fdb69Smrg # Delete the generated files. 1068852fd71cdSmrg if test -f "$output_objdir/${outputname}S.$objext"; then 1068952fd71cdSmrg func_show_eval '$RM "$output_objdir/${outputname}S.$objext"' 10690d63fdb69Smrg fi 106913da084b3Smrg 10692d63fdb69Smrg exit $exit_status 1069352fd71cdSmrg } 106943da084b3Smrg 10695d63fdb69Smrg if test -n "$compile_shlibpath$finalize_shlibpath"; then 10696d63fdb69Smrg compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" 10697d63fdb69Smrg fi 10698d63fdb69Smrg if test -n "$finalize_shlibpath"; then 10699d63fdb69Smrg finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" 10700d63fdb69Smrg fi 107013da084b3Smrg 10702d63fdb69Smrg compile_var= 10703d63fdb69Smrg finalize_var= 10704d63fdb69Smrg if test -n "$runpath_var"; then 10705d63fdb69Smrg if test -n "$perm_rpath"; then 10706d63fdb69Smrg # We should set the runpath_var. 10707d63fdb69Smrg rpath= 10708d63fdb69Smrg for dir in $perm_rpath; do 1070948c85eb7Smrg func_append rpath "$dir:" 107103da084b3Smrg done 10711d63fdb69Smrg compile_var="$runpath_var=\"$rpath\$$runpath_var\" " 107123da084b3Smrg fi 10713d63fdb69Smrg if test -n "$finalize_perm_rpath"; then 10714d63fdb69Smrg # We should set the runpath_var. 10715d63fdb69Smrg rpath= 10716d63fdb69Smrg for dir in $finalize_perm_rpath; do 1071748c85eb7Smrg func_append rpath "$dir:" 10718d63fdb69Smrg done 10719d63fdb69Smrg finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " 10720d63fdb69Smrg fi 10721d63fdb69Smrg fi 107223da084b3Smrg 1072352fd71cdSmrg if test yes = "$no_install"; then 10724d63fdb69Smrg # We don't need to create a wrapper script. 1072552fd71cdSmrg link_command=$compile_var$compile_command$compile_rpath 10726d63fdb69Smrg # Replace the output file specification. 1072755acc8fcSmrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 10728d63fdb69Smrg # Delete the old output file. 10729d63fdb69Smrg $opt_dry_run || $RM $output 10730d63fdb69Smrg # Link the executable and exit 10731d63fdb69Smrg func_show_eval "$link_command" 'exit $?' 1073248c85eb7Smrg 1073348c85eb7Smrg if test -n "$postlink_cmds"; then 1073448c85eb7Smrg func_to_tool_file "$output" 1073548c85eb7Smrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 1073648c85eb7Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 1073748c85eb7Smrg fi 1073848c85eb7Smrg 10739d63fdb69Smrg exit $EXIT_SUCCESS 10740d63fdb69Smrg fi 107413da084b3Smrg 1074252fd71cdSmrg case $hardcode_action,$fast_install in 1074352fd71cdSmrg relink,*) 1074452fd71cdSmrg # Fast installation is not supported 1074552fd71cdSmrg link_command=$compile_var$compile_command$compile_rpath 1074652fd71cdSmrg relink_command=$finalize_var$finalize_command$finalize_rpath 107473da084b3Smrg 1074852fd71cdSmrg func_warning "this platform does not like uninstalled shared libraries" 1074952fd71cdSmrg func_warning "'$output' will be relinked during installation" 1075052fd71cdSmrg ;; 1075152fd71cdSmrg *,yes) 1075252fd71cdSmrg link_command=$finalize_var$compile_command$finalize_rpath 1075352fd71cdSmrg relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` 1075452fd71cdSmrg ;; 1075552fd71cdSmrg *,no) 1075652fd71cdSmrg link_command=$compile_var$compile_command$compile_rpath 1075752fd71cdSmrg relink_command=$finalize_var$finalize_command$finalize_rpath 1075852fd71cdSmrg ;; 1075952fd71cdSmrg *,needless) 1076052fd71cdSmrg link_command=$finalize_var$compile_command$finalize_rpath 1076152fd71cdSmrg relink_command= 1076252fd71cdSmrg ;; 1076352fd71cdSmrg esac 107643da084b3Smrg 10765d63fdb69Smrg # Replace the output file specification. 1076655acc8fcSmrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` 107673da084b3Smrg 10768d63fdb69Smrg # Delete the old output files. 10769d63fdb69Smrg $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname 107703da084b3Smrg 10771d63fdb69Smrg func_show_eval "$link_command" 'exit $?' 107723da084b3Smrg 1077348c85eb7Smrg if test -n "$postlink_cmds"; then 1077448c85eb7Smrg func_to_tool_file "$output_objdir/$outputname" 1077548c85eb7Smrg 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'` 1077648c85eb7Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 1077748c85eb7Smrg fi 1077848c85eb7Smrg 10779d63fdb69Smrg # Now create the wrapper script. 10780d63fdb69Smrg func_verbose "creating $output" 107813da084b3Smrg 10782d63fdb69Smrg # Quote the relink command for shipping. 10783d63fdb69Smrg if test -n "$relink_command"; then 10784d63fdb69Smrg # Preserve any variables that may affect compiler behavior 10785d63fdb69Smrg for var in $variables_saved_for_relink; do 10786d63fdb69Smrg if eval test -z \"\${$var+set}\"; then 10787d63fdb69Smrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 10788d63fdb69Smrg elif eval var_value=\$$var; test -z "$var_value"; then 10789d63fdb69Smrg relink_command="$var=; export $var; $relink_command" 10790d63fdb69Smrg else 107912a53b785Smrg func_quote_arg pretty "$var_value" 107922a53b785Smrg relink_command="$var=$func_quote_arg_result; export $var; $relink_command" 10793d63fdb69Smrg fi 10794d63fdb69Smrg done 107952a53b785Smrg func_quote eval cd "`pwd`" 107962a53b785Smrg func_quote_arg pretty,unquoted "($func_quote_result; $relink_command)" 107972a53b785Smrg relink_command=$func_quote_arg_unquoted_result 10798d63fdb69Smrg fi 107993da084b3Smrg 10800d63fdb69Smrg # Only actually do things if not in dry run mode. 10801d63fdb69Smrg $opt_dry_run || { 10802d63fdb69Smrg # win32 will think the script is a binary if it has 10803d63fdb69Smrg # a .exe suffix, so we strip it off here. 10804d63fdb69Smrg case $output in 10805d63fdb69Smrg *.exe) func_stripname '' '.exe' "$output" 10806d63fdb69Smrg output=$func_stripname_result ;; 10807d63fdb69Smrg esac 10808d63fdb69Smrg # test for cygwin because mv fails w/o .exe extensions 108093da084b3Smrg case $host in 10810d63fdb69Smrg *cygwin*) 10811d63fdb69Smrg exeext=.exe 10812d63fdb69Smrg func_stripname '' '.exe' "$outputname" 10813d63fdb69Smrg outputname=$func_stripname_result ;; 10814d63fdb69Smrg *) exeext= ;; 108153da084b3Smrg esac 10816d63fdb69Smrg case $host in 10817d63fdb69Smrg *cygwin* | *mingw* ) 10818d63fdb69Smrg func_dirname_and_basename "$output" "" "." 10819d63fdb69Smrg output_name=$func_basename_result 10820d63fdb69Smrg output_path=$func_dirname_result 1082152fd71cdSmrg cwrappersource=$output_path/$objdir/lt-$output_name.c 1082252fd71cdSmrg cwrapper=$output_path/$output_name.exe 10823d63fdb69Smrg $RM $cwrappersource $cwrapper 10824d63fdb69Smrg trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 10825d63fdb69Smrg 10826d63fdb69Smrg func_emit_cwrapperexe_src > $cwrappersource 10827d63fdb69Smrg 10828d63fdb69Smrg # The wrapper executable is built using the $host compiler, 10829d63fdb69Smrg # because it contains $host paths and files. If cross- 10830d63fdb69Smrg # compiling, it, like the target executable, must be 10831d63fdb69Smrg # executed on the $host or under an emulation environment. 10832d63fdb69Smrg $opt_dry_run || { 10833d63fdb69Smrg $LTCC $LTCFLAGS -o $cwrapper $cwrappersource 10834d63fdb69Smrg $STRIP $cwrapper 10835d63fdb69Smrg } 108363da084b3Smrg 10837d63fdb69Smrg # Now, create the wrapper script for func_source use: 10838d63fdb69Smrg func_ltwrapper_scriptname $cwrapper 10839d63fdb69Smrg $RM $func_ltwrapper_scriptname_result 10840d63fdb69Smrg trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 10841d63fdb69Smrg $opt_dry_run || { 10842d63fdb69Smrg # note: this script will not be executed, so do not chmod. 1084352fd71cdSmrg if test "x$build" = "x$host"; then 10844d63fdb69Smrg $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result 108453da084b3Smrg else 10846d63fdb69Smrg func_emit_wrapper no > $func_ltwrapper_scriptname_result 108473da084b3Smrg fi 10848d63fdb69Smrg } 10849d63fdb69Smrg ;; 10850d63fdb69Smrg * ) 10851d63fdb69Smrg $RM $output 10852d63fdb69Smrg trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 108533da084b3Smrg 10854d63fdb69Smrg func_emit_wrapper no > $output 10855d63fdb69Smrg chmod +x $output 108563da084b3Smrg ;; 108573da084b3Smrg esac 10858d63fdb69Smrg } 10859d63fdb69Smrg exit $EXIT_SUCCESS 10860d63fdb69Smrg ;; 10861d63fdb69Smrg esac 108623da084b3Smrg 10863d63fdb69Smrg # See if we need to build an old-fashioned archive. 10864d63fdb69Smrg for oldlib in $oldlibs; do 108653da084b3Smrg 1086652fd71cdSmrg case $build_libtool_libs in 1086752fd71cdSmrg convenience) 1086852fd71cdSmrg oldobjs="$libobjs_save $symfileobj" 1086952fd71cdSmrg addlibs=$convenience 10870d63fdb69Smrg build_libtool_libs=no 1087152fd71cdSmrg ;; 1087252fd71cdSmrg module) 1087352fd71cdSmrg oldobjs=$libobjs_save 1087452fd71cdSmrg addlibs=$old_convenience 1087552fd71cdSmrg build_libtool_libs=no 1087652fd71cdSmrg ;; 1087752fd71cdSmrg *) 10878d63fdb69Smrg oldobjs="$old_deplibs $non_pic_objects" 1087952fd71cdSmrg $preload && test -f "$symfileobj" \ 1088052fd71cdSmrg && func_append oldobjs " $symfileobj" 1088152fd71cdSmrg addlibs=$old_convenience 1088252fd71cdSmrg ;; 1088352fd71cdSmrg esac 108843da084b3Smrg 10885d63fdb69Smrg if test -n "$addlibs"; then 1088652fd71cdSmrg gentop=$output_objdir/${outputname}x 1088748c85eb7Smrg func_append generated " $gentop" 108883da084b3Smrg 10889d63fdb69Smrg func_extract_archives $gentop $addlibs 1089048c85eb7Smrg func_append oldobjs " $func_extract_archives_result" 10891d63fdb69Smrg fi 108923da084b3Smrg 10893d63fdb69Smrg # Do each command in the archive commands. 1089452fd71cdSmrg if test -n "$old_archive_from_new_cmds" && test yes = "$build_libtool_libs"; then 10895d63fdb69Smrg cmds=$old_archive_from_new_cmds 10896d63fdb69Smrg else 108973da084b3Smrg 10898d63fdb69Smrg # Add any objects from preloaded convenience libraries 10899d63fdb69Smrg if test -n "$dlprefiles"; then 1090052fd71cdSmrg gentop=$output_objdir/${outputname}x 1090148c85eb7Smrg func_append generated " $gentop" 109023da084b3Smrg 10903d63fdb69Smrg func_extract_archives $gentop $dlprefiles 1090448c85eb7Smrg func_append oldobjs " $func_extract_archives_result" 10905d63fdb69Smrg fi 109063da084b3Smrg 10907d63fdb69Smrg # POSIX demands no paths to be encoded in archives. We have 10908d63fdb69Smrg # to avoid creating archives with duplicate basenames if we 10909d63fdb69Smrg # might have to extract them afterwards, e.g., when creating a 10910d63fdb69Smrg # static archive out of a convenience library, or when linking 10911d63fdb69Smrg # the entirety of a libtool archive into another (currently 10912d63fdb69Smrg # not supported by libtool). 10913d63fdb69Smrg if (for obj in $oldobjs 10914d63fdb69Smrg do 10915d63fdb69Smrg func_basename "$obj" 10916d63fdb69Smrg $ECHO "$func_basename_result" 10917d63fdb69Smrg done | sort | sort -uc >/dev/null 2>&1); then 10918d63fdb69Smrg : 10919d63fdb69Smrg else 1092055acc8fcSmrg echo "copying selected object files to avoid basename conflicts..." 1092152fd71cdSmrg gentop=$output_objdir/${outputname}x 1092248c85eb7Smrg func_append generated " $gentop" 10923d63fdb69Smrg func_mkdir_p "$gentop" 10924d63fdb69Smrg save_oldobjs=$oldobjs 10925d63fdb69Smrg oldobjs= 10926d63fdb69Smrg counter=1 10927d63fdb69Smrg for obj in $save_oldobjs 10928d63fdb69Smrg do 10929d63fdb69Smrg func_basename "$obj" 1093052fd71cdSmrg objbase=$func_basename_result 10931d63fdb69Smrg case " $oldobjs " in 10932d63fdb69Smrg " ") oldobjs=$obj ;; 10933d63fdb69Smrg *[\ /]"$objbase "*) 10934d63fdb69Smrg while :; do 10935d63fdb69Smrg # Make sure we don't pick an alternate name that also 10936d63fdb69Smrg # overlaps. 10937d63fdb69Smrg newobj=lt$counter-$objbase 10938d63fdb69Smrg func_arith $counter + 1 10939d63fdb69Smrg counter=$func_arith_result 10940d63fdb69Smrg case " $oldobjs " in 10941d63fdb69Smrg *[\ /]"$newobj "*) ;; 10942d63fdb69Smrg *) if test ! -f "$gentop/$newobj"; then break; fi ;; 10943d63fdb69Smrg esac 10944d63fdb69Smrg done 10945d63fdb69Smrg func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" 1094648c85eb7Smrg func_append oldobjs " $gentop/$newobj" 10947d63fdb69Smrg ;; 1094848c85eb7Smrg *) func_append oldobjs " $obj" ;; 10949d63fdb69Smrg esac 109503da084b3Smrg done 109513da084b3Smrg fi 1095248c85eb7Smrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 1095348c85eb7Smrg tool_oldlib=$func_to_tool_file_result 10954d63fdb69Smrg eval cmds=\"$old_archive_cmds\" 109553da084b3Smrg 10956d63fdb69Smrg func_len " $cmds" 10957d63fdb69Smrg len=$func_len_result 10958d63fdb69Smrg if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 10959d63fdb69Smrg cmds=$old_archive_cmds 1096048c85eb7Smrg elif test -n "$archiver_list_spec"; then 1096148c85eb7Smrg func_verbose "using command file archive linking..." 1096248c85eb7Smrg for obj in $oldobjs 1096348c85eb7Smrg do 1096448c85eb7Smrg func_to_tool_file "$obj" 1096548c85eb7Smrg $ECHO "$func_to_tool_file_result" 1096648c85eb7Smrg done > $output_objdir/$libname.libcmd 1096748c85eb7Smrg func_to_tool_file "$output_objdir/$libname.libcmd" 1096848c85eb7Smrg oldobjs=" $archiver_list_spec$func_to_tool_file_result" 1096948c85eb7Smrg cmds=$old_archive_cmds 10970d63fdb69Smrg else 10971d63fdb69Smrg # the command line is too long to link in one step, link in parts 10972d63fdb69Smrg func_verbose "using piecewise archive linking..." 10973d63fdb69Smrg save_RANLIB=$RANLIB 10974d63fdb69Smrg RANLIB=: 10975d63fdb69Smrg objlist= 10976d63fdb69Smrg concat_cmds= 10977d63fdb69Smrg save_oldobjs=$oldobjs 10978d63fdb69Smrg oldobjs= 10979d63fdb69Smrg # Is there a better way of finding the last object in the list? 10980d63fdb69Smrg for obj in $save_oldobjs 10981d63fdb69Smrg do 10982d63fdb69Smrg last_oldobj=$obj 10983d63fdb69Smrg done 10984d63fdb69Smrg eval test_cmds=\"$old_archive_cmds\" 10985d63fdb69Smrg func_len " $test_cmds" 10986d63fdb69Smrg len0=$func_len_result 10987d63fdb69Smrg len=$len0 10988d63fdb69Smrg for obj in $save_oldobjs 10989d63fdb69Smrg do 10990d63fdb69Smrg func_len " $obj" 10991d63fdb69Smrg func_arith $len + $func_len_result 10992d63fdb69Smrg len=$func_arith_result 10993d63fdb69Smrg func_append objlist " $obj" 10994d63fdb69Smrg if test "$len" -lt "$max_cmd_len"; then 10995d63fdb69Smrg : 10996d63fdb69Smrg else 10997d63fdb69Smrg # the above command should be used before it gets too long 10998d63fdb69Smrg oldobjs=$objlist 1099952fd71cdSmrg if test "$obj" = "$last_oldobj"; then 11000d63fdb69Smrg RANLIB=$save_RANLIB 11001d63fdb69Smrg fi 11002d63fdb69Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 1100352fd71cdSmrg eval concat_cmds=\"\$concat_cmds$old_archive_cmds\" 11004d63fdb69Smrg objlist= 11005d63fdb69Smrg len=$len0 11006d63fdb69Smrg fi 11007d63fdb69Smrg done 11008d63fdb69Smrg RANLIB=$save_RANLIB 11009d63fdb69Smrg oldobjs=$objlist 1101052fd71cdSmrg if test -z "$oldobjs"; then 11011d63fdb69Smrg eval cmds=\"\$concat_cmds\" 11012d63fdb69Smrg else 11013d63fdb69Smrg eval cmds=\"\$concat_cmds~\$old_archive_cmds\" 11014d63fdb69Smrg fi 11015d63fdb69Smrg fi 11016d63fdb69Smrg fi 11017d63fdb69Smrg func_execute_cmds "$cmds" 'exit $?' 110183da084b3Smrg done 110193da084b3Smrg 11020d63fdb69Smrg test -n "$generated" && \ 11021d63fdb69Smrg func_show_eval "${RM}r$generated" 110223da084b3Smrg 11023d63fdb69Smrg # Now create the libtool archive. 11024d63fdb69Smrg case $output in 11025d63fdb69Smrg *.la) 11026d63fdb69Smrg old_library= 1102752fd71cdSmrg test yes = "$build_old_libs" && old_library=$libname.$libext 11028d63fdb69Smrg func_verbose "creating $output" 110293da084b3Smrg 11030d63fdb69Smrg # Preserve any variables that may affect compiler behavior 11031d63fdb69Smrg for var in $variables_saved_for_relink; do 11032d63fdb69Smrg if eval test -z \"\${$var+set}\"; then 11033d63fdb69Smrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 11034d63fdb69Smrg elif eval var_value=\$$var; test -z "$var_value"; then 11035d63fdb69Smrg relink_command="$var=; export $var; $relink_command" 110363da084b3Smrg else 110372a53b785Smrg func_quote_arg pretty,unquoted "$var_value" 110382a53b785Smrg relink_command="$var=$func_quote_arg_unquoted_result; export $var; $relink_command" 110393da084b3Smrg fi 11040d63fdb69Smrg done 11041d63fdb69Smrg # Quote the link command for shipping. 110422a53b785Smrg func_quote eval cd "`pwd`" 110432a53b785Smrg relink_command="($func_quote_result; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" 110442a53b785Smrg func_quote_arg pretty,unquoted "$relink_command" 110452a53b785Smrg relink_command=$func_quote_arg_unquoted_result 1104652fd71cdSmrg if test yes = "$hardcode_automatic"; then 11047d63fdb69Smrg relink_command= 11048d63fdb69Smrg fi 110493da084b3Smrg 11050d63fdb69Smrg # Only create the output if not a dry run. 11051d63fdb69Smrg $opt_dry_run || { 11052d63fdb69Smrg for installed in no yes; do 1105352fd71cdSmrg if test yes = "$installed"; then 11054d63fdb69Smrg if test -z "$install_libdir"; then 11055d63fdb69Smrg break 11056d63fdb69Smrg fi 1105752fd71cdSmrg output=$output_objdir/${outputname}i 11058d63fdb69Smrg # Replace all uninstalled libtool libraries with the installed ones 11059d63fdb69Smrg newdependency_libs= 11060d63fdb69Smrg for deplib in $dependency_libs; do 11061d63fdb69Smrg case $deplib in 11062d63fdb69Smrg *.la) 11063d63fdb69Smrg func_basename "$deplib" 1106452fd71cdSmrg name=$func_basename_result 1106548c85eb7Smrg func_resolve_sysroot "$deplib" 1106652fd71cdSmrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` 11067d63fdb69Smrg test -z "$libdir" && \ 1106852fd71cdSmrg func_fatal_error "'$deplib' is not a valid libtool archive" 1106948c85eb7Smrg func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" 1107048c85eb7Smrg ;; 1107148c85eb7Smrg -L*) 1107248c85eb7Smrg func_stripname -L '' "$deplib" 1107348c85eb7Smrg func_replace_sysroot "$func_stripname_result" 1107448c85eb7Smrg func_append newdependency_libs " -L$func_replace_sysroot_result" 1107548c85eb7Smrg ;; 1107648c85eb7Smrg -R*) 1107748c85eb7Smrg func_stripname -R '' "$deplib" 1107848c85eb7Smrg func_replace_sysroot "$func_stripname_result" 1107948c85eb7Smrg func_append newdependency_libs " -R$func_replace_sysroot_result" 11080d63fdb69Smrg ;; 1108148c85eb7Smrg *) func_append newdependency_libs " $deplib" ;; 11082d63fdb69Smrg esac 11083d63fdb69Smrg done 1108452fd71cdSmrg dependency_libs=$newdependency_libs 11085d63fdb69Smrg newdlfiles= 11086d63fdb69Smrg 11087d63fdb69Smrg for lib in $dlfiles; do 11088d63fdb69Smrg case $lib in 11089d63fdb69Smrg *.la) 11090d63fdb69Smrg func_basename "$lib" 1109152fd71cdSmrg name=$func_basename_result 1109252fd71cdSmrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 11093d63fdb69Smrg test -z "$libdir" && \ 1109452fd71cdSmrg func_fatal_error "'$lib' is not a valid libtool archive" 1109548c85eb7Smrg func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" 11096d63fdb69Smrg ;; 1109748c85eb7Smrg *) func_append newdlfiles " $lib" ;; 11098d63fdb69Smrg esac 11099d63fdb69Smrg done 1110052fd71cdSmrg dlfiles=$newdlfiles 11101d63fdb69Smrg newdlprefiles= 11102d63fdb69Smrg for lib in $dlprefiles; do 11103d63fdb69Smrg case $lib in 11104d63fdb69Smrg *.la) 11105d63fdb69Smrg # Only pass preopened files to the pseudo-archive (for 11106d63fdb69Smrg # eventual linking with the app. that links it) if we 11107d63fdb69Smrg # didn't already link the preopened objects directly into 11108d63fdb69Smrg # the library: 11109d63fdb69Smrg func_basename "$lib" 1111052fd71cdSmrg name=$func_basename_result 1111152fd71cdSmrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 11112d63fdb69Smrg test -z "$libdir" && \ 1111352fd71cdSmrg func_fatal_error "'$lib' is not a valid libtool archive" 1111448c85eb7Smrg func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" 11115d63fdb69Smrg ;; 11116d63fdb69Smrg esac 11117d63fdb69Smrg done 1111852fd71cdSmrg dlprefiles=$newdlprefiles 11119d63fdb69Smrg else 11120d63fdb69Smrg newdlfiles= 11121d63fdb69Smrg for lib in $dlfiles; do 11122d63fdb69Smrg case $lib in 1112352fd71cdSmrg [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; 11124d63fdb69Smrg *) abs=`pwd`"/$lib" ;; 11125d63fdb69Smrg esac 1112648c85eb7Smrg func_append newdlfiles " $abs" 11127d63fdb69Smrg done 1112852fd71cdSmrg dlfiles=$newdlfiles 11129d63fdb69Smrg newdlprefiles= 11130d63fdb69Smrg for lib in $dlprefiles; do 11131d63fdb69Smrg case $lib in 1113252fd71cdSmrg [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; 11133d63fdb69Smrg *) abs=`pwd`"/$lib" ;; 11134d63fdb69Smrg esac 1113548c85eb7Smrg func_append newdlprefiles " $abs" 11136d63fdb69Smrg done 1113752fd71cdSmrg dlprefiles=$newdlprefiles 11138d63fdb69Smrg fi 11139d63fdb69Smrg $RM $output 11140d63fdb69Smrg # place dlname in correct position for cygwin 1114155acc8fcSmrg # In fact, it would be nice if we could use this code for all target 1114255acc8fcSmrg # systems that can't hard-code library paths into their executables 1114355acc8fcSmrg # and that have no shared library path variable independent of PATH, 1114455acc8fcSmrg # but it turns out we can't easily determine that from inspecting 1114555acc8fcSmrg # libtool variables, so we have to hard-code the OSs to which it 1114655acc8fcSmrg # applies here; at the moment, that means platforms that use the PE 1114755acc8fcSmrg # object format with DLL files. See the long comment at the top of 1114855acc8fcSmrg # tests/bindir.at for full details. 11149d63fdb69Smrg tdlname=$dlname 11150d63fdb69Smrg case $host,$output,$installed,$module,$dlname in 1115155acc8fcSmrg *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) 1115255acc8fcSmrg # If a -bindir argument was supplied, place the dll there. 1115352fd71cdSmrg if test -n "$bindir"; then 1115455acc8fcSmrg func_relative_path "$install_libdir" "$bindir" 1115552fd71cdSmrg tdlname=$func_relative_path_result/$dlname 1115655acc8fcSmrg else 1115755acc8fcSmrg # Otherwise fall back on heuristic. 1115855acc8fcSmrg tdlname=../bin/$dlname 1115955acc8fcSmrg fi 1116055acc8fcSmrg ;; 11161d63fdb69Smrg esac 11162d63fdb69Smrg $ECHO > $output "\ 11163d63fdb69Smrg# $outputname - a libtool library file 1116452fd71cdSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 11165d63fdb69Smrg# 11166d63fdb69Smrg# Please DO NOT delete this file! 11167d63fdb69Smrg# It is necessary for linking the library. 111683da084b3Smrg 11169d63fdb69Smrg# The name that we can dlopen(3). 11170d63fdb69Smrgdlname='$tdlname' 111713da084b3Smrg 11172d63fdb69Smrg# Names of this library. 11173d63fdb69Smrglibrary_names='$library_names' 111743da084b3Smrg 11175d63fdb69Smrg# The name of the static archive. 11176d63fdb69Smrgold_library='$old_library' 111773da084b3Smrg 1117852fd71cdSmrg# Linker flags that cannot go in dependency_libs. 11179d63fdb69Smrginherited_linker_flags='$new_inherited_linker_flags' 111803da084b3Smrg 11181d63fdb69Smrg# Libraries that this one depends upon. 11182d63fdb69Smrgdependency_libs='$dependency_libs' 111833da084b3Smrg 11184d63fdb69Smrg# Names of additional weak libraries provided by this library 11185d63fdb69Smrgweak_library_names='$weak_libs' 111863da084b3Smrg 11187d63fdb69Smrg# Version information for $libname. 11188d63fdb69Smrgcurrent=$current 11189d63fdb69Smrgage=$age 11190d63fdb69Smrgrevision=$revision 111913da084b3Smrg 11192d63fdb69Smrg# Is this an already installed library? 11193d63fdb69Smrginstalled=$installed 111943da084b3Smrg 11195d63fdb69Smrg# Should we warn about portability when linking against -modules? 11196d63fdb69Smrgshouldnotlink=$module 111973da084b3Smrg 11198d63fdb69Smrg# Files to dlopen/dlpreopen 11199d63fdb69Smrgdlopen='$dlfiles' 11200d63fdb69Smrgdlpreopen='$dlprefiles' 112013da084b3Smrg 11202d63fdb69Smrg# Directory that this library needs to be installed in: 11203d63fdb69Smrglibdir='$install_libdir'" 1120452fd71cdSmrg if test no,yes = "$installed,$need_relink"; then 11205d63fdb69Smrg $ECHO >> $output "\ 11206d63fdb69Smrgrelink_command=\"$relink_command\"" 11207d63fdb69Smrg fi 11208d63fdb69Smrg done 11209d63fdb69Smrg } 112103da084b3Smrg 11211d63fdb69Smrg # Do a symbolic link so that the libtool archive can be found in 11212d63fdb69Smrg # LD_LIBRARY_PATH before the program is installed. 11213d63fdb69Smrg func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' 11214d63fdb69Smrg ;; 11215d63fdb69Smrg esac 11216d63fdb69Smrg exit $EXIT_SUCCESS 11217d63fdb69Smrg} 112183da084b3Smrg 1121952fd71cdSmrgif test link = "$opt_mode" || test relink = "$opt_mode"; then 1122052fd71cdSmrg func_mode_link ${1+"$@"} 1122152fd71cdSmrgfi 112223da084b3Smrg 112233da084b3Smrg 11224d63fdb69Smrg# func_mode_uninstall arg... 11225d63fdb69Smrgfunc_mode_uninstall () 11226d63fdb69Smrg{ 1122752fd71cdSmrg $debug_cmd 1122852fd71cdSmrg 1122952fd71cdSmrg RM=$nonopt 112303da084b3Smrg files= 1123152fd71cdSmrg rmforce=false 112323da084b3Smrg exit_status=0 112333da084b3Smrg 112343da084b3Smrg # This variable tells wrapper scripts just to set variables rather 112353da084b3Smrg # than running their programs. 1123652fd71cdSmrg libtool_install_magic=$magic 112373da084b3Smrg 112383da084b3Smrg for arg 112393da084b3Smrg do 112403da084b3Smrg case $arg in 1124152fd71cdSmrg -f) func_append RM " $arg"; rmforce=: ;; 1124248c85eb7Smrg -*) func_append RM " $arg" ;; 1124348c85eb7Smrg *) func_append files " $arg" ;; 112443da084b3Smrg esac 112453da084b3Smrg done 112463da084b3Smrg 11247d63fdb69Smrg test -z "$RM" && \ 11248d63fdb69Smrg func_fatal_help "you must specify an RM program" 112493da084b3Smrg 112503da084b3Smrg rmdirs= 112513da084b3Smrg 112523da084b3Smrg for file in $files; do 11253d63fdb69Smrg func_dirname "$file" "" "." 1125452fd71cdSmrg dir=$func_dirname_result 1125552fd71cdSmrg if test . = "$dir"; then 1125652fd71cdSmrg odir=$objdir 112573da084b3Smrg else 1125852fd71cdSmrg odir=$dir/$objdir 112593da084b3Smrg fi 11260d63fdb69Smrg func_basename "$file" 1126152fd71cdSmrg name=$func_basename_result 1126252fd71cdSmrg test uninstall = "$opt_mode" && odir=$dir 112633da084b3Smrg 1126448c85eb7Smrg # Remember odir for removal later, being careful to avoid duplicates 1126552fd71cdSmrg if test clean = "$opt_mode"; then 112663da084b3Smrg case " $rmdirs " in 1126748c85eb7Smrg *" $odir "*) ;; 1126848c85eb7Smrg *) func_append rmdirs " $odir" ;; 112693da084b3Smrg esac 112703da084b3Smrg fi 112713da084b3Smrg 112723da084b3Smrg # Don't error if the file doesn't exist and rm -f was used. 11273d63fdb69Smrg if { test -L "$file"; } >/dev/null 2>&1 || 11274d63fdb69Smrg { test -h "$file"; } >/dev/null 2>&1 || 11275d63fdb69Smrg test -f "$file"; then 112763da084b3Smrg : 112773da084b3Smrg elif test -d "$file"; then 112783da084b3Smrg exit_status=1 112793da084b3Smrg continue 1128052fd71cdSmrg elif $rmforce; then 112813da084b3Smrg continue 112823da084b3Smrg fi 112833da084b3Smrg 1128452fd71cdSmrg rmfiles=$file 112853da084b3Smrg 112863da084b3Smrg case $name in 112873da084b3Smrg *.la) 112883da084b3Smrg # Possibly a libtool archive, so verify it. 11289d63fdb69Smrg if func_lalib_p "$file"; then 11290d63fdb69Smrg func_source $dir/$name 112913da084b3Smrg 112923da084b3Smrg # Delete the libtool libraries and symlinks. 112933da084b3Smrg for n in $library_names; do 1129448c85eb7Smrg func_append rmfiles " $odir/$n" 112953da084b3Smrg done 1129648c85eb7Smrg test -n "$old_library" && func_append rmfiles " $odir/$old_library" 112973da084b3Smrg 1129852fd71cdSmrg case $opt_mode in 112993da084b3Smrg clean) 1130048c85eb7Smrg case " $library_names " in 113013da084b3Smrg *" $dlname "*) ;; 1130248c85eb7Smrg *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; 113033da084b3Smrg esac 1130448c85eb7Smrg test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" 113053da084b3Smrg ;; 113063da084b3Smrg uninstall) 113073da084b3Smrg if test -n "$library_names"; then 113083da084b3Smrg # Do each command in the postuninstall commands. 1130952fd71cdSmrg func_execute_cmds "$postuninstall_cmds" '$rmforce || exit_status=1' 113103da084b3Smrg fi 113113da084b3Smrg 113123da084b3Smrg if test -n "$old_library"; then 113133da084b3Smrg # Do each command in the old_postuninstall commands. 1131452fd71cdSmrg func_execute_cmds "$old_postuninstall_cmds" '$rmforce || exit_status=1' 113153da084b3Smrg fi 113163da084b3Smrg # FIXME: should reinstall the best remaining shared library. 113173da084b3Smrg ;; 113183da084b3Smrg esac 113193da084b3Smrg fi 113203da084b3Smrg ;; 113213da084b3Smrg 113223da084b3Smrg *.lo) 113233da084b3Smrg # Possibly a libtool object, so verify it. 11324d63fdb69Smrg if func_lalib_p "$file"; then 113253da084b3Smrg 113263da084b3Smrg # Read the .lo file 11327d63fdb69Smrg func_source $dir/$name 113283da084b3Smrg 113293da084b3Smrg # Add PIC object to the list of files to remove. 1133052fd71cdSmrg if test -n "$pic_object" && test none != "$pic_object"; then 1133148c85eb7Smrg func_append rmfiles " $dir/$pic_object" 113323da084b3Smrg fi 113333da084b3Smrg 113343da084b3Smrg # Add non-PIC object to the list of files to remove. 1133552fd71cdSmrg if test -n "$non_pic_object" && test none != "$non_pic_object"; then 1133648c85eb7Smrg func_append rmfiles " $dir/$non_pic_object" 113373da084b3Smrg fi 113383da084b3Smrg fi 113393da084b3Smrg ;; 113403da084b3Smrg 113413da084b3Smrg *) 1134252fd71cdSmrg if test clean = "$opt_mode"; then 113433da084b3Smrg noexename=$name 113443da084b3Smrg case $file in 113453da084b3Smrg *.exe) 11346d63fdb69Smrg func_stripname '' '.exe' "$file" 11347d63fdb69Smrg file=$func_stripname_result 11348d63fdb69Smrg func_stripname '' '.exe' "$name" 11349d63fdb69Smrg noexename=$func_stripname_result 113503da084b3Smrg # $file with .exe has already been added to rmfiles, 113513da084b3Smrg # add $file without .exe 1135248c85eb7Smrg func_append rmfiles " $file" 113533da084b3Smrg ;; 113543da084b3Smrg esac 113553da084b3Smrg # Do a test to see if this is a libtool program. 11356d63fdb69Smrg if func_ltwrapper_p "$file"; then 11357d63fdb69Smrg if func_ltwrapper_executable_p "$file"; then 11358d63fdb69Smrg func_ltwrapper_scriptname "$file" 11359d63fdb69Smrg relink_command= 11360d63fdb69Smrg func_source $func_ltwrapper_scriptname_result 1136148c85eb7Smrg func_append rmfiles " $func_ltwrapper_scriptname_result" 11362d63fdb69Smrg else 11363d63fdb69Smrg relink_command= 11364d63fdb69Smrg func_source $dir/$noexename 11365d63fdb69Smrg fi 113663da084b3Smrg 113673da084b3Smrg # note $name still contains .exe if it was in $file originally 113683da084b3Smrg # as does the version of $file that was added into $rmfiles 1136952fd71cdSmrg func_append rmfiles " $odir/$name $odir/${name}S.$objext" 1137052fd71cdSmrg if test yes = "$fast_install" && test -n "$relink_command"; then 1137148c85eb7Smrg func_append rmfiles " $odir/lt-$name" 113723da084b3Smrg fi 1137352fd71cdSmrg if test "X$noexename" != "X$name"; then 1137452fd71cdSmrg func_append rmfiles " $odir/lt-$noexename.c" 113753da084b3Smrg fi 113763da084b3Smrg fi 113773da084b3Smrg fi 113783da084b3Smrg ;; 113793da084b3Smrg esac 11380d63fdb69Smrg func_show_eval "$RM $rmfiles" 'exit_status=1' 113813da084b3Smrg done 113823da084b3Smrg 1138352fd71cdSmrg # Try to remove the $objdir's in the directories where we deleted files 113843da084b3Smrg for dir in $rmdirs; do 113853da084b3Smrg if test -d "$dir"; then 11386d63fdb69Smrg func_show_eval "rmdir $dir >/dev/null 2>&1" 113873da084b3Smrg fi 113883da084b3Smrg done 113893da084b3Smrg 113903da084b3Smrg exit $exit_status 11391d63fdb69Smrg} 113923da084b3Smrg 1139352fd71cdSmrgif test uninstall = "$opt_mode" || test clean = "$opt_mode"; then 1139452fd71cdSmrg func_mode_uninstall ${1+"$@"} 1139552fd71cdSmrgfi 113963da084b3Smrg 1139748c85eb7Smrgtest -z "$opt_mode" && { 1139852fd71cdSmrg help=$generic_help 11399d63fdb69Smrg func_fatal_help "you must specify a MODE" 11400d63fdb69Smrg} 11401d63fdb69Smrg 11402d63fdb69Smrgtest -z "$exec_cmd" && \ 1140352fd71cdSmrg func_fatal_help "invalid operation mode '$opt_mode'" 114043da084b3Smrg 114053da084b3Smrgif test -n "$exec_cmd"; then 11406d63fdb69Smrg eval exec "$exec_cmd" 114073da084b3Smrg exit $EXIT_FAILURE 114083da084b3Smrgfi 114093da084b3Smrg 11410d63fdb69Smrgexit $exit_status 114113da084b3Smrg 114123da084b3Smrg 114133da084b3Smrg# The TAGs below are defined such that we never get into a situation 1141452fd71cdSmrg# where we disable both kinds of libraries. Given conflicting 114153da084b3Smrg# choices, we go for a static library, that is the most portable, 114163da084b3Smrg# since we can't tell whether shared libraries were disabled because 114173da084b3Smrg# the user asked for that or because the platform doesn't support 114183da084b3Smrg# them. This is particularly important on AIX, because we don't 114193da084b3Smrg# support having both static and shared libraries enabled at the same 114203da084b3Smrg# time on that platform, so we default to a shared-only configuration. 114213da084b3Smrg# If a disable-shared tag is given, we'll fallback to a static-only 114223da084b3Smrg# configuration. But we'll never go from static-only to shared-only. 114233da084b3Smrg 114243da084b3Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared 11425d63fdb69Smrgbuild_libtool_libs=no 11426d63fdb69Smrgbuild_old_libs=yes 114273da084b3Smrg# ### END LIBTOOL TAG CONFIG: disable-shared 114283da084b3Smrg 114293da084b3Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static 11430d63fdb69Smrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` 114313da084b3Smrg# ### END LIBTOOL TAG CONFIG: disable-static 114323da084b3Smrg 114333da084b3Smrg# Local Variables: 114343da084b3Smrg# mode:shell-script 114353da084b3Smrg# sh-indentation:2 114363da084b3Smrg# End: 11437