ltmain.sh revision 58cf2af7
1c82838c1Smrg#! /usr/bin/env sh 235c4bbdfSmrg## DO NOT EDIT - This file generated from ./build-aux/ltmain.in 3c82838c1Smrg## by inline-source v2019-02-19.15 44642e01fSmrg 5c82838c1Smrg# libtool (GNU libtool) 2.4.7 635c4bbdfSmrg# Provide generalized library-building support services. 74642e01fSmrg# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 84642e01fSmrg 9c82838c1Smrg# Copyright (C) 1996-2019, 2021-2022 Free Software Foundation, Inc. 104642e01fSmrg# This is free software; see the source for copying conditions. There is NO 114642e01fSmrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 124642e01fSmrg 134642e01fSmrg# GNU Libtool is free software; you can redistribute it and/or modify 1405b261ecSmrg# it under the terms of the GNU General Public License as published by 1505b261ecSmrg# the Free Software Foundation; either version 2 of the License, or 1605b261ecSmrg# (at your option) any later version. 1705b261ecSmrg# 184642e01fSmrg# As a special exception to the GNU General Public License, 194642e01fSmrg# if you distribute this file as part of a program or library that 204642e01fSmrg# is built using GNU Libtool, you may include this file under the 214642e01fSmrg# same distribution terms that you use for the rest of that program. 224642e01fSmrg# 234642e01fSmrg# GNU Libtool is distributed in the hope that it will be useful, but 2405b261ecSmrg# WITHOUT ANY WARRANTY; without even the implied warranty of 2505b261ecSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 2605b261ecSmrg# General Public License for more details. 2705b261ecSmrg# 2805b261ecSmrg# You should have received a copy of the GNU General Public License 2935c4bbdfSmrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 3005b261ecSmrg 3105b261ecSmrg 326747b715SmrgPROGRAM=libtool 3305b261ecSmrgPACKAGE=libtool 34c82838c1SmrgVERSION=2.4.7 35c82838c1Smrgpackage_revision=2.4.7 3605b261ecSmrg 3735c4bbdfSmrg 3835c4bbdfSmrg## ------ ## 3935c4bbdfSmrg## Usage. ## 4035c4bbdfSmrg## ------ ## 4135c4bbdfSmrg 4235c4bbdfSmrg# Run './libtool --help' for help with using this script from the 4335c4bbdfSmrg# command line. 4435c4bbdfSmrg 4535c4bbdfSmrg 4635c4bbdfSmrg## ------------------------------- ## 4735c4bbdfSmrg## User overridable command paths. ## 4835c4bbdfSmrg## ------------------------------- ## 4935c4bbdfSmrg 5035c4bbdfSmrg# After configure completes, it has a better idea of some of the 5135c4bbdfSmrg# shell tools we need than the defaults used by the functions shared 5235c4bbdfSmrg# with bootstrap, so set those here where they can still be over- 5335c4bbdfSmrg# ridden by the user, but otherwise take precedence. 5435c4bbdfSmrg 5535c4bbdfSmrg: ${AUTOCONF="autoconf"} 5635c4bbdfSmrg: ${AUTOMAKE="automake"} 5735c4bbdfSmrg 5835c4bbdfSmrg 5935c4bbdfSmrg## -------------------------- ## 6035c4bbdfSmrg## Source external libraries. ## 6135c4bbdfSmrg## -------------------------- ## 6235c4bbdfSmrg 6335c4bbdfSmrg# Much of our low-level functionality needs to be sourced from external 6435c4bbdfSmrg# libraries, which are installed to $pkgauxdir. 6535c4bbdfSmrg 6635c4bbdfSmrg# Set a version string for this script. 67c82838c1Smrgscriptversion=2019-02-19.15; # UTC 6835c4bbdfSmrg 6935c4bbdfSmrg# General shell script boiler plate, and helper functions. 7035c4bbdfSmrg# Written by Gary V. Vaughan, 2004 7135c4bbdfSmrg 72c82838c1Smrg# This is free software. There is NO warranty; not even for 73c82838c1Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 74c82838c1Smrg# 75c82838c1Smrg# Copyright (C) 2004-2019, 2021 Bootstrap Authors 76c82838c1Smrg# 77c82838c1Smrg# This file is dual licensed under the terms of the MIT license 78c82838c1Smrg# <https://opensource.org/license/MIT>, and GPL version 2 or later 79c82838c1Smrg# <http://www.gnu.org/licenses/gpl-2.0.html>. You must apply one of 80c82838c1Smrg# these licenses when using or redistributing this software or any of 81c82838c1Smrg# the files within it. See the URLs above, or the file `LICENSE` 82c82838c1Smrg# included in the Bootstrap distribution for the full license texts. 8335c4bbdfSmrg 84c82838c1Smrg# Please report bugs or propose patches to: 85c82838c1Smrg# <https://github.com/gnulib-modules/bootstrap/issues> 8635c4bbdfSmrg 8735c4bbdfSmrg 8835c4bbdfSmrg## ------ ## 8935c4bbdfSmrg## Usage. ## 9035c4bbdfSmrg## ------ ## 9135c4bbdfSmrg 9235c4bbdfSmrg# Evaluate this file near the top of your script to gain access to 9335c4bbdfSmrg# the functions and variables defined here: 9435c4bbdfSmrg# 9535c4bbdfSmrg# . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh 9635c4bbdfSmrg# 9735c4bbdfSmrg# If you need to override any of the default environment variable 9835c4bbdfSmrg# settings, do that before evaluating this file. 9935c4bbdfSmrg 10035c4bbdfSmrg 10135c4bbdfSmrg## -------------------- ## 10235c4bbdfSmrg## Shell normalisation. ## 10335c4bbdfSmrg## -------------------- ## 10435c4bbdfSmrg 10535c4bbdfSmrg# Some shells need a little help to be as Bourne compatible as possible. 10635c4bbdfSmrg# Before doing anything else, make sure all that help has been provided! 10735c4bbdfSmrg 10835c4bbdfSmrgDUALCASE=1; export DUALCASE # for MKS sh 10935c4bbdfSmrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : 11005b261ecSmrg emulate sh 11105b261ecSmrg NULLCMD=: 11235c4bbdfSmrg # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which 11305b261ecSmrg # is contrary to our usage. Disable this feature. 11405b261ecSmrg alias -g '${1+"$@"}'='"$@"' 11505b261ecSmrg setopt NO_GLOB_SUBST 11605b261ecSmrgelse 11735c4bbdfSmrg case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac 11805b261ecSmrgfi 1196747b715Smrg 12035c4bbdfSmrg# NLS nuisances: We save the old values in case they are required later. 12135c4bbdfSmrg_G_user_locale= 12235c4bbdfSmrg_G_safe_locale= 12335c4bbdfSmrgfor _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 12405b261ecSmrgdo 12535c4bbdfSmrg eval "if test set = \"\${$_G_var+set}\"; then 12635c4bbdfSmrg save_$_G_var=\$$_G_var 12735c4bbdfSmrg $_G_var=C 12835c4bbdfSmrg export $_G_var 12935c4bbdfSmrg _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\" 13035c4bbdfSmrg _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\" 13105b261ecSmrg fi" 13205b261ecSmrgdone 133c82838c1Smrg# These NLS vars are set unconditionally (bootstrap issue #24). Unset those 134c82838c1Smrg# in case the environment reset is needed later and the $save_* variant is not 135c82838c1Smrg# defined (see the code above). 136c82838c1SmrgLC_ALL=C 137c82838c1SmrgLANGUAGE=C 138c82838c1Smrgexport LANGUAGE LC_ALL 1394642e01fSmrg 14035c4bbdfSmrg# Make sure IFS has a sensible default 14135c4bbdfSmrgsp=' ' 14235c4bbdfSmrgnl=' 14335c4bbdfSmrg' 14435c4bbdfSmrgIFS="$sp $nl" 14535c4bbdfSmrg 14635c4bbdfSmrg# There are apparently some retarded systems that use ';' as a PATH separator! 14735c4bbdfSmrgif test "${PATH_SEPARATOR+set}" != set; then 14835c4bbdfSmrg PATH_SEPARATOR=: 14935c4bbdfSmrg (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { 15035c4bbdfSmrg (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || 15135c4bbdfSmrg PATH_SEPARATOR=';' 15235c4bbdfSmrg } 15335c4bbdfSmrgfi 1544642e01fSmrg 1554642e01fSmrg 156c82838c1Smrg# func_unset VAR 157c82838c1Smrg# -------------- 158c82838c1Smrg# Portably unset VAR. 159c82838c1Smrg# In some shells, an 'unset VAR' statement leaves a non-zero return 160c82838c1Smrg# status if VAR is already unset, which might be problematic if the 161c82838c1Smrg# statement is used at the end of a function (thus poisoning its return 162c82838c1Smrg# value) or when 'set -e' is active (causing even a spurious abort of 163c82838c1Smrg# the script in this case). 164c82838c1Smrgfunc_unset () 165c82838c1Smrg{ 166c82838c1Smrg { eval $1=; (eval unset $1) >/dev/null 2>&1 && eval unset $1 || : ; } 167c82838c1Smrg} 168c82838c1Smrg 169c82838c1Smrg 170c82838c1Smrg# Make sure CDPATH doesn't cause `cd` commands to output the target dir. 171c82838c1Smrgfunc_unset CDPATH 172c82838c1Smrg 173c82838c1Smrg# Make sure ${,E,F}GREP behave sanely. 174c82838c1Smrgfunc_unset GREP_OPTIONS 175c82838c1Smrg 1764642e01fSmrg 17735c4bbdfSmrg## ------------------------- ## 17835c4bbdfSmrg## Locate command utilities. ## 17935c4bbdfSmrg## ------------------------- ## 18035c4bbdfSmrg 18135c4bbdfSmrg 18235c4bbdfSmrg# func_executable_p FILE 18335c4bbdfSmrg# ---------------------- 18435c4bbdfSmrg# Check that FILE is an executable regular file. 18535c4bbdfSmrgfunc_executable_p () 18635c4bbdfSmrg{ 18735c4bbdfSmrg test -f "$1" && test -x "$1" 18835c4bbdfSmrg} 18935c4bbdfSmrg 19035c4bbdfSmrg 19135c4bbdfSmrg# func_path_progs PROGS_LIST CHECK_FUNC [PATH] 19235c4bbdfSmrg# -------------------------------------------- 19335c4bbdfSmrg# Search for either a program that responds to --version with output 19435c4bbdfSmrg# containing "GNU", or else returned by CHECK_FUNC otherwise, by 19535c4bbdfSmrg# trying all the directories in PATH with each of the elements of 19635c4bbdfSmrg# PROGS_LIST. 19735c4bbdfSmrg# 19835c4bbdfSmrg# CHECK_FUNC should accept the path to a candidate program, and 19935c4bbdfSmrg# set $func_check_prog_result if it truncates its output less than 20035c4bbdfSmrg# $_G_path_prog_max characters. 20135c4bbdfSmrgfunc_path_progs () 20235c4bbdfSmrg{ 20335c4bbdfSmrg _G_progs_list=$1 20435c4bbdfSmrg _G_check_func=$2 20535c4bbdfSmrg _G_PATH=${3-"$PATH"} 20635c4bbdfSmrg 20735c4bbdfSmrg _G_path_prog_max=0 20835c4bbdfSmrg _G_path_prog_found=false 20935c4bbdfSmrg _G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:} 21035c4bbdfSmrg for _G_dir in $_G_PATH; do 21135c4bbdfSmrg IFS=$_G_save_IFS 21235c4bbdfSmrg test -z "$_G_dir" && _G_dir=. 21335c4bbdfSmrg for _G_prog_name in $_G_progs_list; do 21435c4bbdfSmrg for _exeext in '' .EXE; do 21535c4bbdfSmrg _G_path_prog=$_G_dir/$_G_prog_name$_exeext 21635c4bbdfSmrg func_executable_p "$_G_path_prog" || continue 21735c4bbdfSmrg case `"$_G_path_prog" --version 2>&1` in 21835c4bbdfSmrg *GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;; 21935c4bbdfSmrg *) $_G_check_func $_G_path_prog 22035c4bbdfSmrg func_path_progs_result=$func_check_prog_result 22135c4bbdfSmrg ;; 22235c4bbdfSmrg esac 22335c4bbdfSmrg $_G_path_prog_found && break 3 22435c4bbdfSmrg done 22535c4bbdfSmrg done 22635c4bbdfSmrg done 22735c4bbdfSmrg IFS=$_G_save_IFS 22835c4bbdfSmrg test -z "$func_path_progs_result" && { 22935c4bbdfSmrg echo "no acceptable sed could be found in \$PATH" >&2 23035c4bbdfSmrg exit 1 23135c4bbdfSmrg } 23235c4bbdfSmrg} 23335c4bbdfSmrg 23435c4bbdfSmrg 23535c4bbdfSmrg# We want to be able to use the functions in this file before configure 23635c4bbdfSmrg# has figured out where the best binaries are kept, which means we have 23735c4bbdfSmrg# to search for them ourselves - except when the results are already set 23835c4bbdfSmrg# where we skip the searches. 23935c4bbdfSmrg 24035c4bbdfSmrg# Unless the user overrides by setting SED, search the path for either GNU 24135c4bbdfSmrg# sed, or the sed that truncates its output the least. 24235c4bbdfSmrgtest -z "$SED" && { 24335c4bbdfSmrg _G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ 24435c4bbdfSmrg for _G_i in 1 2 3 4 5 6 7; do 24535c4bbdfSmrg _G_sed_script=$_G_sed_script$nl$_G_sed_script 24635c4bbdfSmrg done 24735c4bbdfSmrg echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed 24835c4bbdfSmrg _G_sed_script= 24935c4bbdfSmrg 25035c4bbdfSmrg func_check_prog_sed () 25135c4bbdfSmrg { 25235c4bbdfSmrg _G_path_prog=$1 25335c4bbdfSmrg 25435c4bbdfSmrg _G_count=0 25535c4bbdfSmrg printf 0123456789 >conftest.in 25635c4bbdfSmrg while : 25735c4bbdfSmrg do 25835c4bbdfSmrg cat conftest.in conftest.in >conftest.tmp 25935c4bbdfSmrg mv conftest.tmp conftest.in 26035c4bbdfSmrg cp conftest.in conftest.nl 26135c4bbdfSmrg echo '' >> conftest.nl 26235c4bbdfSmrg "$_G_path_prog" -f conftest.sed <conftest.nl >conftest.out 2>/dev/null || break 26335c4bbdfSmrg diff conftest.out conftest.nl >/dev/null 2>&1 || break 26435c4bbdfSmrg _G_count=`expr $_G_count + 1` 26535c4bbdfSmrg if test "$_G_count" -gt "$_G_path_prog_max"; then 26635c4bbdfSmrg # Best one so far, save it but keep looking for a better one 26735c4bbdfSmrg func_check_prog_result=$_G_path_prog 26835c4bbdfSmrg _G_path_prog_max=$_G_count 26935c4bbdfSmrg fi 27035c4bbdfSmrg # 10*(2^10) chars as input seems more than enough 27135c4bbdfSmrg test 10 -lt "$_G_count" && break 27235c4bbdfSmrg done 27335c4bbdfSmrg rm -f conftest.in conftest.tmp conftest.nl conftest.out 27435c4bbdfSmrg } 27535c4bbdfSmrg 276c82838c1Smrg func_path_progs "sed gsed" func_check_prog_sed "$PATH:/usr/xpg4/bin" 27735c4bbdfSmrg rm -f conftest.sed 27835c4bbdfSmrg SED=$func_path_progs_result 27935c4bbdfSmrg} 28035c4bbdfSmrg 28135c4bbdfSmrg 28235c4bbdfSmrg# Unless the user overrides by setting GREP, search the path for either GNU 28335c4bbdfSmrg# grep, or the grep that truncates its output the least. 28435c4bbdfSmrgtest -z "$GREP" && { 28535c4bbdfSmrg func_check_prog_grep () 28635c4bbdfSmrg { 28735c4bbdfSmrg _G_path_prog=$1 28835c4bbdfSmrg 28935c4bbdfSmrg _G_count=0 29035c4bbdfSmrg _G_path_prog_max=0 29135c4bbdfSmrg printf 0123456789 >conftest.in 29235c4bbdfSmrg while : 29335c4bbdfSmrg do 29435c4bbdfSmrg cat conftest.in conftest.in >conftest.tmp 29535c4bbdfSmrg mv conftest.tmp conftest.in 29635c4bbdfSmrg cp conftest.in conftest.nl 29735c4bbdfSmrg echo 'GREP' >> conftest.nl 29835c4bbdfSmrg "$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' <conftest.nl >conftest.out 2>/dev/null || break 29935c4bbdfSmrg diff conftest.out conftest.nl >/dev/null 2>&1 || break 30035c4bbdfSmrg _G_count=`expr $_G_count + 1` 30135c4bbdfSmrg if test "$_G_count" -gt "$_G_path_prog_max"; then 30235c4bbdfSmrg # Best one so far, save it but keep looking for a better one 30335c4bbdfSmrg func_check_prog_result=$_G_path_prog 30435c4bbdfSmrg _G_path_prog_max=$_G_count 30535c4bbdfSmrg fi 30635c4bbdfSmrg # 10*(2^10) chars as input seems more than enough 30735c4bbdfSmrg test 10 -lt "$_G_count" && break 30835c4bbdfSmrg done 30935c4bbdfSmrg rm -f conftest.in conftest.tmp conftest.nl conftest.out 31035c4bbdfSmrg } 31135c4bbdfSmrg 312c82838c1Smrg func_path_progs "grep ggrep" func_check_prog_grep "$PATH:/usr/xpg4/bin" 31335c4bbdfSmrg GREP=$func_path_progs_result 31435c4bbdfSmrg} 31535c4bbdfSmrg 31635c4bbdfSmrg 31735c4bbdfSmrg## ------------------------------- ## 31835c4bbdfSmrg## User overridable command paths. ## 31935c4bbdfSmrg## ------------------------------- ## 32035c4bbdfSmrg 32135c4bbdfSmrg# All uppercase variable names are used for environment variables. These 32235c4bbdfSmrg# variables can be overridden by the user before calling a script that 32335c4bbdfSmrg# uses them if a suitable command of that name is not already available 32435c4bbdfSmrg# in the command search PATH. 3254642e01fSmrg 3264642e01fSmrg: ${CP="cp -f"} 32735c4bbdfSmrg: ${ECHO="printf %s\n"} 32835c4bbdfSmrg: ${EGREP="$GREP -E"} 32935c4bbdfSmrg: ${FGREP="$GREP -F"} 3304642e01fSmrg: ${LN_S="ln -s"} 3314642e01fSmrg: ${MAKE="make"} 3324642e01fSmrg: ${MKDIR="mkdir"} 3334642e01fSmrg: ${MV="mv -f"} 3344642e01fSmrg: ${RM="rm -f"} 3354642e01fSmrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"} 3364642e01fSmrg 3374642e01fSmrg 33835c4bbdfSmrg## -------------------- ## 33935c4bbdfSmrg## Useful sed snippets. ## 34035c4bbdfSmrg## -------------------- ## 34105b261ecSmrg 34235c4bbdfSmrgsed_dirname='s|/[^/]*$||' 34335c4bbdfSmrgsed_basename='s|^.*/||' 34405b261ecSmrg 34535c4bbdfSmrg# Sed substitution that helps us do robust quoting. It backslashifies 34635c4bbdfSmrg# metacharacters that are still active within double-quoted strings. 34735c4bbdfSmrgsed_quote_subst='s|\([`"$\\]\)|\\\1|g' 3484642e01fSmrg 34935c4bbdfSmrg# Same as above, but do not quote variable references. 35035c4bbdfSmrgsed_double_quote_subst='s/\(["`\\]\)/\\\1/g' 35135c4bbdfSmrg 35235c4bbdfSmrg# Sed substitution that turns a string into a regex matching for the 35335c4bbdfSmrg# string literally. 35435c4bbdfSmrgsed_make_literal_regex='s|[].[^$\\*\/]|\\&|g' 35535c4bbdfSmrg 35635c4bbdfSmrg# Sed substitution that converts a w32 file name or path 35735c4bbdfSmrg# that contains forward slashes, into one that contains 35835c4bbdfSmrg# (escaped) backslashes. A very naive implementation. 35935c4bbdfSmrgsed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' 36035c4bbdfSmrg 36135c4bbdfSmrg# Re-'\' parameter expansions in output of sed_double_quote_subst that 36235c4bbdfSmrg# were '\'-ed in input to the same. If an odd number of '\' preceded a 36335c4bbdfSmrg# '$' in input to sed_double_quote_subst, that '$' was protected from 36435c4bbdfSmrg# expansion. Since each input '\' is now two '\'s, look for any number 36535c4bbdfSmrg# of runs of four '\'s followed by two '\'s and then a '$'. '\' that '$'. 36635c4bbdfSmrg_G_bs='\\' 36735c4bbdfSmrg_G_bs2='\\\\' 36835c4bbdfSmrg_G_bs4='\\\\\\\\' 36935c4bbdfSmrg_G_dollar='\$' 37035c4bbdfSmrgsed_double_backslash="\ 37135c4bbdfSmrg s/$_G_bs4/&\\ 37235c4bbdfSmrg/g 37335c4bbdfSmrg s/^$_G_bs2$_G_dollar/$_G_bs&/ 37435c4bbdfSmrg s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g 37535c4bbdfSmrg s/\n//g" 3766747b715Smrg 377c82838c1Smrg# require_check_ifs_backslash 378c82838c1Smrg# --------------------------- 379c82838c1Smrg# Check if we can use backslash as IFS='\' separator, and set 380c82838c1Smrg# $check_ifs_backshlash_broken to ':' or 'false'. 381c82838c1Smrgrequire_check_ifs_backslash=func_require_check_ifs_backslash 382c82838c1Smrgfunc_require_check_ifs_backslash () 383c82838c1Smrg{ 384c82838c1Smrg _G_save_IFS=$IFS 385c82838c1Smrg IFS='\' 386c82838c1Smrg _G_check_ifs_backshlash='a\\b' 387c82838c1Smrg for _G_i in $_G_check_ifs_backshlash 388c82838c1Smrg do 389c82838c1Smrg case $_G_i in 390c82838c1Smrg a) 391c82838c1Smrg check_ifs_backshlash_broken=false 392c82838c1Smrg ;; 393c82838c1Smrg '') 394c82838c1Smrg break 395c82838c1Smrg ;; 396c82838c1Smrg *) 397c82838c1Smrg check_ifs_backshlash_broken=: 398c82838c1Smrg break 399c82838c1Smrg ;; 400c82838c1Smrg esac 401c82838c1Smrg done 402c82838c1Smrg IFS=$_G_save_IFS 403c82838c1Smrg require_check_ifs_backslash=: 404c82838c1Smrg} 405c82838c1Smrg 4066747b715Smrg 40735c4bbdfSmrg## ----------------- ## 40835c4bbdfSmrg## Global variables. ## 40935c4bbdfSmrg## ----------------- ## 4106747b715Smrg 41135c4bbdfSmrg# Except for the global variables explicitly listed below, the following 41235c4bbdfSmrg# functions in the '^func_' namespace, and the '^require_' namespace 41335c4bbdfSmrg# variables initialised in the 'Resource management' section, sourcing 41435c4bbdfSmrg# this file will not pollute your global namespace with anything 41535c4bbdfSmrg# else. There's no portable way to scope variables in Bourne shell 41635c4bbdfSmrg# though, so actually running these functions will sometimes place 41735c4bbdfSmrg# results into a variable named after the function, and often use 41835c4bbdfSmrg# temporary variables in the '^_G_' namespace. If you are careful to 41935c4bbdfSmrg# avoid using those namespaces casually in your sourcing script, things 42035c4bbdfSmrg# should continue to work as you expect. And, of course, you can freely 42135c4bbdfSmrg# overwrite any of the functions or variables defined here before 42235c4bbdfSmrg# calling anything to customize them. 42305b261ecSmrg 42435c4bbdfSmrgEXIT_SUCCESS=0 42535c4bbdfSmrgEXIT_FAILURE=1 42635c4bbdfSmrgEXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. 42735c4bbdfSmrgEXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. 4284642e01fSmrg 42935c4bbdfSmrg# Allow overriding, eg assuming that you follow the convention of 43035c4bbdfSmrg# putting '$debug_cmd' at the start of all your functions, you can get 43135c4bbdfSmrg# bash to show function call trace with: 43235c4bbdfSmrg# 433c82838c1Smrg# debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name 43435c4bbdfSmrgdebug_cmd=${debug_cmd-":"} 43535c4bbdfSmrgexit_cmd=: 4366747b715Smrg 43735c4bbdfSmrg# By convention, finish your script with: 43835c4bbdfSmrg# 43935c4bbdfSmrg# exit $exit_status 44035c4bbdfSmrg# 44135c4bbdfSmrg# so that you can set exit_status to non-zero if you want to indicate 44235c4bbdfSmrg# something went wrong during execution without actually bailing out at 44335c4bbdfSmrg# the point of failure. 44435c4bbdfSmrgexit_status=$EXIT_SUCCESS 44535c4bbdfSmrg 44635c4bbdfSmrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh 44735c4bbdfSmrg# is ksh but when the shell is invoked as "sh" and the current value of 44835c4bbdfSmrg# the _XPG environment variable is not equal to 1 (one), the special 44935c4bbdfSmrg# positional parameter $0, within a function call, is the name of the 45035c4bbdfSmrg# function. 45135c4bbdfSmrgprogpath=$0 4524642e01fSmrg 45335c4bbdfSmrg# The name of this program. 45435c4bbdfSmrgprogname=`$ECHO "$progpath" |$SED "$sed_basename"` 4554642e01fSmrg 45635c4bbdfSmrg# Make sure we have an absolute progpath for reexecution: 4574642e01fSmrgcase $progpath in 4584642e01fSmrg [\\/]*|[A-Za-z]:\\*) ;; 4594642e01fSmrg *[\\/]*) 46035c4bbdfSmrg progdir=`$ECHO "$progpath" |$SED "$sed_dirname"` 4614642e01fSmrg progdir=`cd "$progdir" && pwd` 46235c4bbdfSmrg progpath=$progdir/$progname 4634642e01fSmrg ;; 4644642e01fSmrg *) 46535c4bbdfSmrg _G_IFS=$IFS 46635c4bbdfSmrg IFS=${PATH_SEPARATOR-:} 4674642e01fSmrg for progdir in $PATH; do 46835c4bbdfSmrg IFS=$_G_IFS 4694642e01fSmrg test -x "$progdir/$progname" && break 4704642e01fSmrg done 47135c4bbdfSmrg IFS=$_G_IFS 4724642e01fSmrg test -n "$progdir" || progdir=`pwd` 47335c4bbdfSmrg progpath=$progdir/$progname 4744642e01fSmrg ;; 4754642e01fSmrgesac 4764642e01fSmrg 4774642e01fSmrg 47835c4bbdfSmrg## ----------------- ## 47935c4bbdfSmrg## Standard options. ## 48035c4bbdfSmrg## ----------------- ## 48135c4bbdfSmrg 48235c4bbdfSmrg# The following options affect the operation of the functions defined 48335c4bbdfSmrg# below, and should be set appropriately depending on run-time para- 48435c4bbdfSmrg# meters passed on the command line. 4854642e01fSmrg 4864642e01fSmrgopt_dry_run=false 4874642e01fSmrgopt_quiet=false 4884642e01fSmrgopt_verbose=false 4894642e01fSmrg 49035c4bbdfSmrg# Categories 'all' and 'none' are always available. Append any others 49135c4bbdfSmrg# you will pass as the first argument to func_warning from your own 49235c4bbdfSmrg# code. 49335c4bbdfSmrgwarning_categories= 4944642e01fSmrg 49535c4bbdfSmrg# By default, display warnings according to 'opt_warning_types'. Set 49635c4bbdfSmrg# 'warning_func' to ':' to elide all warnings, or func_fatal_error to 49735c4bbdfSmrg# treat the next displayed warning as a fatal error. 49835c4bbdfSmrgwarning_func=func_warn_and_continue 4994642e01fSmrg 50035c4bbdfSmrg# Set to 'all' to display all warnings, 'none' to suppress all 50135c4bbdfSmrg# warnings, or a space delimited list of some subset of 50235c4bbdfSmrg# 'warning_categories' to display only the listed warnings. 50335c4bbdfSmrgopt_warning_types=all 5044642e01fSmrg 5056747b715Smrg 50635c4bbdfSmrg## -------------------- ## 50735c4bbdfSmrg## Resource management. ## 50835c4bbdfSmrg## -------------------- ## 5094642e01fSmrg 51035c4bbdfSmrg# This section contains definitions for functions that each ensure a 51135c4bbdfSmrg# particular resource (a file, or a non-empty configuration variable for 51235c4bbdfSmrg# example) is available, and if appropriate to extract default values 51335c4bbdfSmrg# from pertinent package files. Call them using their associated 51435c4bbdfSmrg# 'require_*' variable to ensure that they are executed, at most, once. 51535c4bbdfSmrg# 51635c4bbdfSmrg# It's entirely deliberate that calling these functions can set 51735c4bbdfSmrg# variables that don't obey the namespace limitations obeyed by the rest 51835c4bbdfSmrg# of this file, in order that that they be as useful as possible to 51935c4bbdfSmrg# callers. 5204642e01fSmrg 5214642e01fSmrg 52235c4bbdfSmrg# require_term_colors 52335c4bbdfSmrg# ------------------- 52435c4bbdfSmrg# Allow display of bold text on terminals that support it. 52535c4bbdfSmrgrequire_term_colors=func_require_term_colors 52635c4bbdfSmrgfunc_require_term_colors () 5274642e01fSmrg{ 52835c4bbdfSmrg $debug_cmd 52935c4bbdfSmrg 53035c4bbdfSmrg test -t 1 && { 53135c4bbdfSmrg # COLORTERM and USE_ANSI_COLORS environment variables take 53235c4bbdfSmrg # precedence, because most terminfo databases neglect to describe 53335c4bbdfSmrg # whether color sequences are supported. 53435c4bbdfSmrg test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"} 53535c4bbdfSmrg 53635c4bbdfSmrg if test 1 = "$USE_ANSI_COLORS"; then 53735c4bbdfSmrg # Standard ANSI escape sequences 53835c4bbdfSmrg tc_reset='[0m' 53935c4bbdfSmrg tc_bold='[1m'; tc_standout='[7m' 54035c4bbdfSmrg tc_red='[31m'; tc_green='[32m' 54135c4bbdfSmrg tc_blue='[34m'; tc_cyan='[36m' 54235c4bbdfSmrg else 54335c4bbdfSmrg # Otherwise trust the terminfo database after all. 54435c4bbdfSmrg test -n "`tput sgr0 2>/dev/null`" && { 54535c4bbdfSmrg tc_reset=`tput sgr0` 54635c4bbdfSmrg test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold` 54735c4bbdfSmrg tc_standout=$tc_bold 54835c4bbdfSmrg test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso` 54935c4bbdfSmrg test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1` 55035c4bbdfSmrg test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2` 55135c4bbdfSmrg test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4` 55235c4bbdfSmrg test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5` 55335c4bbdfSmrg } 55435c4bbdfSmrg fi 55535c4bbdfSmrg } 5564642e01fSmrg 55735c4bbdfSmrg require_term_colors=: 5584642e01fSmrg} 5594642e01fSmrg 5604642e01fSmrg 56135c4bbdfSmrg## ----------------- ## 56235c4bbdfSmrg## Function library. ## 56335c4bbdfSmrg## ----------------- ## 5644642e01fSmrg 56535c4bbdfSmrg# This section contains a variety of useful functions to call in your 56635c4bbdfSmrg# scripts. Take note of the portable wrappers for features provided by 56735c4bbdfSmrg# some modern shells, which will fall back to slower equivalents on 56835c4bbdfSmrg# less featureful shells. 5694642e01fSmrg 5704642e01fSmrg 57135c4bbdfSmrg# func_append VAR VALUE 57235c4bbdfSmrg# --------------------- 57335c4bbdfSmrg# Append VALUE onto the existing contents of VAR. 5744642e01fSmrg 57535c4bbdfSmrg # We should try to minimise forks, especially on Windows where they are 57635c4bbdfSmrg # unreasonably slow, so skip the feature probes when bash or zsh are 57735c4bbdfSmrg # being used: 57835c4bbdfSmrg if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then 57935c4bbdfSmrg : ${_G_HAVE_ARITH_OP="yes"} 58035c4bbdfSmrg : ${_G_HAVE_XSI_OPS="yes"} 58135c4bbdfSmrg # The += operator was introduced in bash 3.1 58235c4bbdfSmrg case $BASH_VERSION in 58335c4bbdfSmrg [12].* | 3.0 | 3.0*) ;; 58435c4bbdfSmrg *) 58535c4bbdfSmrg : ${_G_HAVE_PLUSEQ_OP="yes"} 58635c4bbdfSmrg ;; 58735c4bbdfSmrg esac 58835c4bbdfSmrg fi 5894642e01fSmrg 59035c4bbdfSmrg # _G_HAVE_PLUSEQ_OP 59135c4bbdfSmrg # Can be empty, in which case the shell is probed, "yes" if += is 59235c4bbdfSmrg # useable or anything else if it does not work. 59335c4bbdfSmrg test -z "$_G_HAVE_PLUSEQ_OP" \ 59435c4bbdfSmrg && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \ 59535c4bbdfSmrg && _G_HAVE_PLUSEQ_OP=yes 59635c4bbdfSmrg 59735c4bbdfSmrgif test yes = "$_G_HAVE_PLUSEQ_OP" 59835c4bbdfSmrgthen 59935c4bbdfSmrg # This is an XSI compatible shell, allowing a faster implementation... 60035c4bbdfSmrg eval 'func_append () 60135c4bbdfSmrg { 60235c4bbdfSmrg $debug_cmd 6034642e01fSmrg 60435c4bbdfSmrg eval "$1+=\$2" 60535c4bbdfSmrg }' 60635c4bbdfSmrgelse 60735c4bbdfSmrg # ...otherwise fall back to using expr, which is often a shell builtin. 60835c4bbdfSmrg func_append () 60935c4bbdfSmrg { 61035c4bbdfSmrg $debug_cmd 6114642e01fSmrg 61235c4bbdfSmrg eval "$1=\$$1\$2" 61335c4bbdfSmrg } 61435c4bbdfSmrgfi 61535c4bbdfSmrg 61635c4bbdfSmrg 61735c4bbdfSmrg# func_append_quoted VAR VALUE 61835c4bbdfSmrg# ---------------------------- 61935c4bbdfSmrg# Quote VALUE and append to the end of shell variable VAR, separated 62035c4bbdfSmrg# by a space. 62135c4bbdfSmrgif test yes = "$_G_HAVE_PLUSEQ_OP"; then 62235c4bbdfSmrg eval 'func_append_quoted () 62335c4bbdfSmrg { 62435c4bbdfSmrg $debug_cmd 62535c4bbdfSmrg 626c82838c1Smrg func_quote_arg pretty "$2" 627c82838c1Smrg eval "$1+=\\ \$func_quote_arg_result" 62835c4bbdfSmrg }' 62935c4bbdfSmrgelse 63035c4bbdfSmrg func_append_quoted () 63135c4bbdfSmrg { 63235c4bbdfSmrg $debug_cmd 63335c4bbdfSmrg 634c82838c1Smrg func_quote_arg pretty "$2" 635c82838c1Smrg eval "$1=\$$1\\ \$func_quote_arg_result" 63635c4bbdfSmrg } 63735c4bbdfSmrgfi 63835c4bbdfSmrg 63935c4bbdfSmrg 64035c4bbdfSmrg# func_append_uniq VAR VALUE 64135c4bbdfSmrg# -------------------------- 64235c4bbdfSmrg# Append unique VALUE onto the existing contents of VAR, assuming 64335c4bbdfSmrg# entries are delimited by the first character of VALUE. For example: 64435c4bbdfSmrg# 64535c4bbdfSmrg# func_append_uniq options " --another-option option-argument" 64635c4bbdfSmrg# 64735c4bbdfSmrg# will only append to $options if " --another-option option-argument " 64835c4bbdfSmrg# is not already present somewhere in $options already (note spaces at 64935c4bbdfSmrg# each end implied by leading space in second argument). 65035c4bbdfSmrgfunc_append_uniq () 65135c4bbdfSmrg{ 65235c4bbdfSmrg $debug_cmd 65335c4bbdfSmrg 65435c4bbdfSmrg eval _G_current_value='`$ECHO $'$1'`' 65535c4bbdfSmrg _G_delim=`expr "$2" : '\(.\)'` 65635c4bbdfSmrg 65735c4bbdfSmrg case $_G_delim$_G_current_value$_G_delim in 65835c4bbdfSmrg *"$2$_G_delim"*) ;; 65935c4bbdfSmrg *) func_append "$@" ;; 66035c4bbdfSmrg esac 66135c4bbdfSmrg} 66235c4bbdfSmrg 66335c4bbdfSmrg 66435c4bbdfSmrg# func_arith TERM... 66535c4bbdfSmrg# ------------------ 66635c4bbdfSmrg# Set func_arith_result to the result of evaluating TERMs. 66735c4bbdfSmrg test -z "$_G_HAVE_ARITH_OP" \ 66835c4bbdfSmrg && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \ 66935c4bbdfSmrg && _G_HAVE_ARITH_OP=yes 67035c4bbdfSmrg 67135c4bbdfSmrgif test yes = "$_G_HAVE_ARITH_OP"; then 67235c4bbdfSmrg eval 'func_arith () 67335c4bbdfSmrg { 67435c4bbdfSmrg $debug_cmd 67535c4bbdfSmrg 67635c4bbdfSmrg func_arith_result=$(( $* )) 67735c4bbdfSmrg }' 67835c4bbdfSmrgelse 67935c4bbdfSmrg func_arith () 68035c4bbdfSmrg { 68135c4bbdfSmrg $debug_cmd 68235c4bbdfSmrg 68335c4bbdfSmrg func_arith_result=`expr "$@"` 68435c4bbdfSmrg } 68535c4bbdfSmrgfi 68635c4bbdfSmrg 68735c4bbdfSmrg 68835c4bbdfSmrg# func_basename FILE 68935c4bbdfSmrg# ------------------ 69035c4bbdfSmrg# Set func_basename_result to FILE with everything up to and including 69135c4bbdfSmrg# the last / stripped. 69235c4bbdfSmrgif test yes = "$_G_HAVE_XSI_OPS"; then 69335c4bbdfSmrg # If this shell supports suffix pattern removal, then use it to avoid 69435c4bbdfSmrg # forking. Hide the definitions single quotes in case the shell chokes 69535c4bbdfSmrg # on unsupported syntax... 69635c4bbdfSmrg _b='func_basename_result=${1##*/}' 69735c4bbdfSmrg _d='case $1 in 69835c4bbdfSmrg */*) func_dirname_result=${1%/*}$2 ;; 69935c4bbdfSmrg * ) func_dirname_result=$3 ;; 70035c4bbdfSmrg esac' 70135c4bbdfSmrg 70235c4bbdfSmrgelse 70335c4bbdfSmrg # ...otherwise fall back to using sed. 70435c4bbdfSmrg _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`' 70535c4bbdfSmrg _d='func_dirname_result=`$ECHO "$1" |$SED "$sed_dirname"` 70635c4bbdfSmrg if test "X$func_dirname_result" = "X$1"; then 70735c4bbdfSmrg func_dirname_result=$3 70835c4bbdfSmrg else 70935c4bbdfSmrg func_append func_dirname_result "$2" 71035c4bbdfSmrg fi' 71135c4bbdfSmrgfi 71235c4bbdfSmrg 71335c4bbdfSmrgeval 'func_basename () 71435c4bbdfSmrg{ 71535c4bbdfSmrg $debug_cmd 71635c4bbdfSmrg 71735c4bbdfSmrg '"$_b"' 71835c4bbdfSmrg}' 71935c4bbdfSmrg 72035c4bbdfSmrg 72135c4bbdfSmrg# func_dirname FILE APPEND NONDIR_REPLACEMENT 72235c4bbdfSmrg# ------------------------------------------- 72335c4bbdfSmrg# Compute the dirname of FILE. If nonempty, add APPEND to the result, 72435c4bbdfSmrg# otherwise set result to NONDIR_REPLACEMENT. 72535c4bbdfSmrgeval 'func_dirname () 72635c4bbdfSmrg{ 72735c4bbdfSmrg $debug_cmd 72835c4bbdfSmrg 72935c4bbdfSmrg '"$_d"' 73035c4bbdfSmrg}' 73135c4bbdfSmrg 73235c4bbdfSmrg 73335c4bbdfSmrg# func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT 73435c4bbdfSmrg# -------------------------------------------------------- 73535c4bbdfSmrg# Perform func_basename and func_dirname in a single function 73635c4bbdfSmrg# call: 73735c4bbdfSmrg# dirname: Compute the dirname of FILE. If nonempty, 73835c4bbdfSmrg# add APPEND to the result, otherwise set result 73935c4bbdfSmrg# to NONDIR_REPLACEMENT. 74035c4bbdfSmrg# value returned in "$func_dirname_result" 74135c4bbdfSmrg# basename: Compute filename of FILE. 74235c4bbdfSmrg# value retuned in "$func_basename_result" 74335c4bbdfSmrg# For efficiency, we do not delegate to the functions above but instead 74435c4bbdfSmrg# duplicate the functionality here. 74535c4bbdfSmrgeval 'func_dirname_and_basename () 74635c4bbdfSmrg{ 74735c4bbdfSmrg $debug_cmd 74835c4bbdfSmrg 74935c4bbdfSmrg '"$_b"' 75035c4bbdfSmrg '"$_d"' 75135c4bbdfSmrg}' 75235c4bbdfSmrg 75335c4bbdfSmrg 75435c4bbdfSmrg# func_echo ARG... 75535c4bbdfSmrg# ---------------- 75635c4bbdfSmrg# Echo program name prefixed message. 75735c4bbdfSmrgfunc_echo () 75835c4bbdfSmrg{ 75935c4bbdfSmrg $debug_cmd 76035c4bbdfSmrg 76135c4bbdfSmrg _G_message=$* 76235c4bbdfSmrg 76335c4bbdfSmrg func_echo_IFS=$IFS 76435c4bbdfSmrg IFS=$nl 76535c4bbdfSmrg for _G_line in $_G_message; do 76635c4bbdfSmrg IFS=$func_echo_IFS 76735c4bbdfSmrg $ECHO "$progname: $_G_line" 76835c4bbdfSmrg done 76935c4bbdfSmrg IFS=$func_echo_IFS 77035c4bbdfSmrg} 77135c4bbdfSmrg 77235c4bbdfSmrg 77335c4bbdfSmrg# func_echo_all ARG... 77435c4bbdfSmrg# -------------------- 77535c4bbdfSmrg# Invoke $ECHO with all args, space-separated. 77635c4bbdfSmrgfunc_echo_all () 77735c4bbdfSmrg{ 77835c4bbdfSmrg $ECHO "$*" 77935c4bbdfSmrg} 78035c4bbdfSmrg 78135c4bbdfSmrg 78235c4bbdfSmrg# func_echo_infix_1 INFIX ARG... 78335c4bbdfSmrg# ------------------------------ 78435c4bbdfSmrg# Echo program name, followed by INFIX on the first line, with any 78535c4bbdfSmrg# additional lines not showing INFIX. 78635c4bbdfSmrgfunc_echo_infix_1 () 78735c4bbdfSmrg{ 78835c4bbdfSmrg $debug_cmd 78935c4bbdfSmrg 79035c4bbdfSmrg $require_term_colors 79135c4bbdfSmrg 79235c4bbdfSmrg _G_infix=$1; shift 79335c4bbdfSmrg _G_indent=$_G_infix 79435c4bbdfSmrg _G_prefix="$progname: $_G_infix: " 79535c4bbdfSmrg _G_message=$* 79635c4bbdfSmrg 79735c4bbdfSmrg # Strip color escape sequences before counting printable length 79835c4bbdfSmrg for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan" 79935c4bbdfSmrg do 80035c4bbdfSmrg test -n "$_G_tc" && { 80135c4bbdfSmrg _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"` 80235c4bbdfSmrg _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"` 80335c4bbdfSmrg } 80435c4bbdfSmrg done 80535c4bbdfSmrg _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`" " ## exclude from sc_prohibit_nested_quotes 80635c4bbdfSmrg 80735c4bbdfSmrg func_echo_infix_1_IFS=$IFS 80835c4bbdfSmrg IFS=$nl 80935c4bbdfSmrg for _G_line in $_G_message; do 81035c4bbdfSmrg IFS=$func_echo_infix_1_IFS 81135c4bbdfSmrg $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2 81235c4bbdfSmrg _G_prefix=$_G_indent 81335c4bbdfSmrg done 81435c4bbdfSmrg IFS=$func_echo_infix_1_IFS 81535c4bbdfSmrg} 81635c4bbdfSmrg 81735c4bbdfSmrg 81835c4bbdfSmrg# func_error ARG... 81935c4bbdfSmrg# ----------------- 82035c4bbdfSmrg# Echo program name prefixed message to standard error. 82135c4bbdfSmrgfunc_error () 82235c4bbdfSmrg{ 82335c4bbdfSmrg $debug_cmd 82435c4bbdfSmrg 82535c4bbdfSmrg $require_term_colors 82635c4bbdfSmrg 82735c4bbdfSmrg func_echo_infix_1 " $tc_standout${tc_red}error$tc_reset" "$*" >&2 82835c4bbdfSmrg} 82935c4bbdfSmrg 83035c4bbdfSmrg 83135c4bbdfSmrg# func_fatal_error ARG... 83235c4bbdfSmrg# ----------------------- 83335c4bbdfSmrg# Echo program name prefixed message to standard error, and exit. 83435c4bbdfSmrgfunc_fatal_error () 83535c4bbdfSmrg{ 83635c4bbdfSmrg $debug_cmd 83735c4bbdfSmrg 83835c4bbdfSmrg func_error "$*" 83935c4bbdfSmrg exit $EXIT_FAILURE 84035c4bbdfSmrg} 84135c4bbdfSmrg 84235c4bbdfSmrg 84335c4bbdfSmrg# func_grep EXPRESSION FILENAME 84435c4bbdfSmrg# ----------------------------- 84535c4bbdfSmrg# Check whether EXPRESSION matches any line of FILENAME, without output. 84635c4bbdfSmrgfunc_grep () 84735c4bbdfSmrg{ 84835c4bbdfSmrg $debug_cmd 84935c4bbdfSmrg 85035c4bbdfSmrg $GREP "$1" "$2" >/dev/null 2>&1 85135c4bbdfSmrg} 85235c4bbdfSmrg 85335c4bbdfSmrg 85435c4bbdfSmrg# func_len STRING 85535c4bbdfSmrg# --------------- 85635c4bbdfSmrg# Set func_len_result to the length of STRING. STRING may not 85735c4bbdfSmrg# start with a hyphen. 85835c4bbdfSmrg test -z "$_G_HAVE_XSI_OPS" \ 85935c4bbdfSmrg && (eval 'x=a/b/c; 86035c4bbdfSmrg test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ 86135c4bbdfSmrg && _G_HAVE_XSI_OPS=yes 86235c4bbdfSmrg 86335c4bbdfSmrgif test yes = "$_G_HAVE_XSI_OPS"; then 86435c4bbdfSmrg eval 'func_len () 86535c4bbdfSmrg { 86635c4bbdfSmrg $debug_cmd 86735c4bbdfSmrg 86835c4bbdfSmrg func_len_result=${#1} 86935c4bbdfSmrg }' 87035c4bbdfSmrgelse 87135c4bbdfSmrg func_len () 87235c4bbdfSmrg { 87335c4bbdfSmrg $debug_cmd 87435c4bbdfSmrg 87535c4bbdfSmrg func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len` 87635c4bbdfSmrg } 87735c4bbdfSmrgfi 87835c4bbdfSmrg 87935c4bbdfSmrg 88035c4bbdfSmrg# func_mkdir_p DIRECTORY-PATH 88135c4bbdfSmrg# --------------------------- 88235c4bbdfSmrg# Make sure the entire path to DIRECTORY-PATH is available. 88335c4bbdfSmrgfunc_mkdir_p () 88435c4bbdfSmrg{ 88535c4bbdfSmrg $debug_cmd 88635c4bbdfSmrg 88735c4bbdfSmrg _G_directory_path=$1 88835c4bbdfSmrg _G_dir_list= 88935c4bbdfSmrg 89035c4bbdfSmrg if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then 89135c4bbdfSmrg 89235c4bbdfSmrg # Protect directory names starting with '-' 89335c4bbdfSmrg case $_G_directory_path in 89435c4bbdfSmrg -*) _G_directory_path=./$_G_directory_path ;; 89535c4bbdfSmrg esac 89635c4bbdfSmrg 89735c4bbdfSmrg # While some portion of DIR does not yet exist... 89835c4bbdfSmrg while test ! -d "$_G_directory_path"; do 89935c4bbdfSmrg # ...make a list in topmost first order. Use a colon delimited 90035c4bbdfSmrg # list incase some portion of path contains whitespace. 90135c4bbdfSmrg _G_dir_list=$_G_directory_path:$_G_dir_list 90235c4bbdfSmrg 90335c4bbdfSmrg # If the last portion added has no slash in it, the list is done 90435c4bbdfSmrg case $_G_directory_path in */*) ;; *) break ;; esac 90535c4bbdfSmrg 90635c4bbdfSmrg # ...otherwise throw away the child directory and loop 90735c4bbdfSmrg _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"` 90835c4bbdfSmrg done 90935c4bbdfSmrg _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'` 9104642e01fSmrg 91135c4bbdfSmrg func_mkdir_p_IFS=$IFS; IFS=: 91235c4bbdfSmrg for _G_dir in $_G_dir_list; do 91335c4bbdfSmrg IFS=$func_mkdir_p_IFS 91435c4bbdfSmrg # mkdir can fail with a 'File exist' error if two processes 9154642e01fSmrg # try to create one of the directories concurrently. Don't 9164642e01fSmrg # stop in that case! 91735c4bbdfSmrg $MKDIR "$_G_dir" 2>/dev/null || : 9184642e01fSmrg done 91935c4bbdfSmrg IFS=$func_mkdir_p_IFS 9204642e01fSmrg 9214642e01fSmrg # Bail out if we (or some other process) failed to create a directory. 92235c4bbdfSmrg test -d "$_G_directory_path" || \ 92335c4bbdfSmrg func_fatal_error "Failed to create '$1'" 9244642e01fSmrg fi 9254642e01fSmrg} 92605b261ecSmrg 92705b261ecSmrg 92835c4bbdfSmrg# func_mktempdir [BASENAME] 92935c4bbdfSmrg# ------------------------- 93005b261ecSmrg# Make a temporary directory that won't clash with other running 93105b261ecSmrg# libtool processes, and avoids race conditions if possible. If 93235c4bbdfSmrg# given, BASENAME is the basename for that directory. 93305b261ecSmrgfunc_mktempdir () 93405b261ecSmrg{ 93535c4bbdfSmrg $debug_cmd 93605b261ecSmrg 93735c4bbdfSmrg _G_template=${TMPDIR-/tmp}/${1-$progname} 93835c4bbdfSmrg 93935c4bbdfSmrg if test : = "$opt_dry_run"; then 94005b261ecSmrg # Return a directory name, but don't create it in dry-run mode 94135c4bbdfSmrg _G_tmpdir=$_G_template-$$ 94205b261ecSmrg else 94305b261ecSmrg 94405b261ecSmrg # If mktemp works, use that first and foremost 94535c4bbdfSmrg _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null` 94605b261ecSmrg 94735c4bbdfSmrg if test ! -d "$_G_tmpdir"; then 9484642e01fSmrg # Failing that, at least try and use $RANDOM to avoid a race 94935c4bbdfSmrg _G_tmpdir=$_G_template-${RANDOM-0}$$ 95005b261ecSmrg 95135c4bbdfSmrg func_mktempdir_umask=`umask` 9524642e01fSmrg umask 0077 95335c4bbdfSmrg $MKDIR "$_G_tmpdir" 95435c4bbdfSmrg umask $func_mktempdir_umask 95505b261ecSmrg fi 95605b261ecSmrg 95705b261ecSmrg # If we're not in dry-run mode, bomb out on failure 95835c4bbdfSmrg test -d "$_G_tmpdir" || \ 95935c4bbdfSmrg func_fatal_error "cannot create temporary directory '$_G_tmpdir'" 96005b261ecSmrg fi 96105b261ecSmrg 96235c4bbdfSmrg $ECHO "$_G_tmpdir" 96305b261ecSmrg} 96405b261ecSmrg 96505b261ecSmrg 96635c4bbdfSmrg# func_normal_abspath PATH 96735c4bbdfSmrg# ------------------------ 96835c4bbdfSmrg# Remove doubled-up and trailing slashes, "." path components, 96935c4bbdfSmrg# and cancel out any ".." path components in PATH after making 97035c4bbdfSmrg# it an absolute path. 97135c4bbdfSmrgfunc_normal_abspath () 97205b261ecSmrg{ 97335c4bbdfSmrg $debug_cmd 9744642e01fSmrg 97535c4bbdfSmrg # These SED scripts presuppose an absolute path with a trailing slash. 97635c4bbdfSmrg _G_pathcar='s|^/\([^/]*\).*$|\1|' 97735c4bbdfSmrg _G_pathcdr='s|^/[^/]*||' 97835c4bbdfSmrg _G_removedotparts=':dotsl 97935c4bbdfSmrg s|/\./|/|g 98035c4bbdfSmrg t dotsl 98135c4bbdfSmrg s|/\.$|/|' 98235c4bbdfSmrg _G_collapseslashes='s|/\{1,\}|/|g' 98335c4bbdfSmrg _G_finalslash='s|/*$|/|' 98435c4bbdfSmrg 98535c4bbdfSmrg # Start from root dir and reassemble the path. 98635c4bbdfSmrg func_normal_abspath_result= 98735c4bbdfSmrg func_normal_abspath_tpath=$1 98835c4bbdfSmrg func_normal_abspath_altnamespace= 98935c4bbdfSmrg case $func_normal_abspath_tpath in 99035c4bbdfSmrg "") 99135c4bbdfSmrg # Empty path, that just means $cwd. 99235c4bbdfSmrg func_stripname '' '/' "`pwd`" 99335c4bbdfSmrg func_normal_abspath_result=$func_stripname_result 99435c4bbdfSmrg return 99535c4bbdfSmrg ;; 99635c4bbdfSmrg # The next three entries are used to spot a run of precisely 99735c4bbdfSmrg # two leading slashes without using negated character classes; 99835c4bbdfSmrg # we take advantage of case's first-match behaviour. 99935c4bbdfSmrg ///*) 100035c4bbdfSmrg # Unusual form of absolute path, do nothing. 100135c4bbdfSmrg ;; 100235c4bbdfSmrg //*) 100335c4bbdfSmrg # Not necessarily an ordinary path; POSIX reserves leading '//' 100435c4bbdfSmrg # and for example Cygwin uses it to access remote file shares 100535c4bbdfSmrg # over CIFS/SMB, so we conserve a leading double slash if found. 100635c4bbdfSmrg func_normal_abspath_altnamespace=/ 100735c4bbdfSmrg ;; 100835c4bbdfSmrg /*) 100935c4bbdfSmrg # Absolute path, do nothing. 10104642e01fSmrg ;; 10114642e01fSmrg *) 101235c4bbdfSmrg # Relative path, prepend $cwd. 101335c4bbdfSmrg func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath 101435c4bbdfSmrg ;; 101505b261ecSmrg esac 101635c4bbdfSmrg 101735c4bbdfSmrg # Cancel out all the simple stuff to save iterations. We also want 101835c4bbdfSmrg # the path to end with a slash for ease of parsing, so make sure 101935c4bbdfSmrg # there is one (and only one) here. 102035c4bbdfSmrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 102135c4bbdfSmrg -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"` 102235c4bbdfSmrg while :; do 102335c4bbdfSmrg # Processed it all yet? 102435c4bbdfSmrg if test / = "$func_normal_abspath_tpath"; then 102535c4bbdfSmrg # If we ascended to the root using ".." the result may be empty now. 102635c4bbdfSmrg if test -z "$func_normal_abspath_result"; then 102735c4bbdfSmrg func_normal_abspath_result=/ 102835c4bbdfSmrg fi 102935c4bbdfSmrg break 103035c4bbdfSmrg fi 103135c4bbdfSmrg func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ 103235c4bbdfSmrg -e "$_G_pathcar"` 103335c4bbdfSmrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 103435c4bbdfSmrg -e "$_G_pathcdr"` 103535c4bbdfSmrg # Figure out what to do with it 103635c4bbdfSmrg case $func_normal_abspath_tcomponent in 103735c4bbdfSmrg "") 103835c4bbdfSmrg # Trailing empty path component, ignore it. 103935c4bbdfSmrg ;; 104035c4bbdfSmrg ..) 104135c4bbdfSmrg # Parent dir; strip last assembled component from result. 104235c4bbdfSmrg func_dirname "$func_normal_abspath_result" 104335c4bbdfSmrg func_normal_abspath_result=$func_dirname_result 104435c4bbdfSmrg ;; 104535c4bbdfSmrg *) 104635c4bbdfSmrg # Actual path component, append it. 104735c4bbdfSmrg func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent" 104835c4bbdfSmrg ;; 104935c4bbdfSmrg esac 105035c4bbdfSmrg done 105135c4bbdfSmrg # Restore leading double-slash if one was found on entry. 105235c4bbdfSmrg func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result 105335c4bbdfSmrg} 105435c4bbdfSmrg 105535c4bbdfSmrg 105635c4bbdfSmrg# func_notquiet ARG... 105735c4bbdfSmrg# -------------------- 105835c4bbdfSmrg# Echo program name prefixed message only when not in quiet mode. 105935c4bbdfSmrgfunc_notquiet () 106035c4bbdfSmrg{ 106135c4bbdfSmrg $debug_cmd 106235c4bbdfSmrg 106335c4bbdfSmrg $opt_quiet || func_echo ${1+"$@"} 106435c4bbdfSmrg 106535c4bbdfSmrg # A bug in bash halts the script if the last line of a function 106635c4bbdfSmrg # fails when set -e is in force, so we need another command to 106735c4bbdfSmrg # work around that: 106835c4bbdfSmrg : 106935c4bbdfSmrg} 107035c4bbdfSmrg 107135c4bbdfSmrg 107235c4bbdfSmrg# func_relative_path SRCDIR DSTDIR 107335c4bbdfSmrg# -------------------------------- 107435c4bbdfSmrg# Set func_relative_path_result to the relative path from SRCDIR to DSTDIR. 107535c4bbdfSmrgfunc_relative_path () 107635c4bbdfSmrg{ 107735c4bbdfSmrg $debug_cmd 107835c4bbdfSmrg 107935c4bbdfSmrg func_relative_path_result= 108035c4bbdfSmrg func_normal_abspath "$1" 108135c4bbdfSmrg func_relative_path_tlibdir=$func_normal_abspath_result 108235c4bbdfSmrg func_normal_abspath "$2" 108335c4bbdfSmrg func_relative_path_tbindir=$func_normal_abspath_result 108435c4bbdfSmrg 108535c4bbdfSmrg # Ascend the tree starting from libdir 108635c4bbdfSmrg while :; do 108735c4bbdfSmrg # check if we have found a prefix of bindir 108835c4bbdfSmrg case $func_relative_path_tbindir in 108935c4bbdfSmrg $func_relative_path_tlibdir) 109035c4bbdfSmrg # found an exact match 109135c4bbdfSmrg func_relative_path_tcancelled= 109235c4bbdfSmrg break 109335c4bbdfSmrg ;; 109435c4bbdfSmrg $func_relative_path_tlibdir*) 109535c4bbdfSmrg # found a matching prefix 109635c4bbdfSmrg func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" 109735c4bbdfSmrg func_relative_path_tcancelled=$func_stripname_result 109835c4bbdfSmrg if test -z "$func_relative_path_result"; then 109935c4bbdfSmrg func_relative_path_result=. 110035c4bbdfSmrg fi 110135c4bbdfSmrg break 110235c4bbdfSmrg ;; 110335c4bbdfSmrg *) 110435c4bbdfSmrg func_dirname $func_relative_path_tlibdir 110535c4bbdfSmrg func_relative_path_tlibdir=$func_dirname_result 110635c4bbdfSmrg if test -z "$func_relative_path_tlibdir"; then 110735c4bbdfSmrg # Have to descend all the way to the root! 110835c4bbdfSmrg func_relative_path_result=../$func_relative_path_result 110935c4bbdfSmrg func_relative_path_tcancelled=$func_relative_path_tbindir 111035c4bbdfSmrg break 111135c4bbdfSmrg fi 111235c4bbdfSmrg func_relative_path_result=../$func_relative_path_result 111335c4bbdfSmrg ;; 111435c4bbdfSmrg esac 111535c4bbdfSmrg done 111635c4bbdfSmrg 111735c4bbdfSmrg # Now calculate path; take care to avoid doubling-up slashes. 111835c4bbdfSmrg func_stripname '' '/' "$func_relative_path_result" 111935c4bbdfSmrg func_relative_path_result=$func_stripname_result 112035c4bbdfSmrg func_stripname '/' '/' "$func_relative_path_tcancelled" 112135c4bbdfSmrg if test -n "$func_stripname_result"; then 112235c4bbdfSmrg func_append func_relative_path_result "/$func_stripname_result" 112335c4bbdfSmrg fi 112435c4bbdfSmrg 112535c4bbdfSmrg # Normalisation. If bindir is libdir, return '.' else relative path. 112635c4bbdfSmrg if test -n "$func_relative_path_result"; then 112735c4bbdfSmrg func_stripname './' '' "$func_relative_path_result" 112835c4bbdfSmrg func_relative_path_result=$func_stripname_result 112935c4bbdfSmrg fi 113035c4bbdfSmrg 113135c4bbdfSmrg test -n "$func_relative_path_result" || func_relative_path_result=. 113235c4bbdfSmrg 113335c4bbdfSmrg : 113435c4bbdfSmrg} 113535c4bbdfSmrg 113635c4bbdfSmrg 1137c82838c1Smrg# func_quote_portable EVAL ARG 1138c82838c1Smrg# ---------------------------- 1139c82838c1Smrg# Internal function to portably implement func_quote_arg. Note that we still 1140c82838c1Smrg# keep attention to performance here so we as much as possible try to avoid 1141c82838c1Smrg# calling sed binary (so far O(N) complexity as long as func_append is O(1)). 1142c82838c1Smrgfunc_quote_portable () 114335c4bbdfSmrg{ 114435c4bbdfSmrg $debug_cmd 114535c4bbdfSmrg 1146c82838c1Smrg $require_check_ifs_backslash 1147c82838c1Smrg 1148c82838c1Smrg func_quote_portable_result=$2 1149c82838c1Smrg 1150c82838c1Smrg # one-time-loop (easy break) 1151c82838c1Smrg while true 1152c82838c1Smrg do 1153c82838c1Smrg if $1; then 1154c82838c1Smrg func_quote_portable_result=`$ECHO "$2" | $SED \ 1155c82838c1Smrg -e "$sed_double_quote_subst" -e "$sed_double_backslash"` 1156c82838c1Smrg break 115735c4bbdfSmrg fi 115835c4bbdfSmrg 1159c82838c1Smrg # Quote for eval. 1160c82838c1Smrg case $func_quote_portable_result in 1161c82838c1Smrg *[\\\`\"\$]*) 1162c82838c1Smrg # Fallback to sed for $func_check_bs_ifs_broken=:, or when the string 1163c82838c1Smrg # contains the shell wildcard characters. 1164c82838c1Smrg case $check_ifs_backshlash_broken$func_quote_portable_result in 1165c82838c1Smrg :*|*[\[\*\?]*) 1166c82838c1Smrg func_quote_portable_result=`$ECHO "$func_quote_portable_result" \ 1167c82838c1Smrg | $SED "$sed_quote_subst"` 1168c82838c1Smrg break 1169c82838c1Smrg ;; 1170c82838c1Smrg esac 1171c82838c1Smrg 1172c82838c1Smrg func_quote_portable_old_IFS=$IFS 1173c82838c1Smrg for _G_char in '\' '`' '"' '$' 1174c82838c1Smrg do 1175c82838c1Smrg # STATE($1) PREV($2) SEPARATOR($3) 1176c82838c1Smrg set start "" "" 1177c82838c1Smrg func_quote_portable_result=dummy"$_G_char$func_quote_portable_result$_G_char"dummy 1178c82838c1Smrg IFS=$_G_char 1179c82838c1Smrg for _G_part in $func_quote_portable_result 1180c82838c1Smrg do 1181c82838c1Smrg case $1 in 1182c82838c1Smrg quote) 1183c82838c1Smrg func_append func_quote_portable_result "$3$2" 1184c82838c1Smrg set quote "$_G_part" "\\$_G_char" 1185c82838c1Smrg ;; 1186c82838c1Smrg start) 1187c82838c1Smrg set first "" "" 1188c82838c1Smrg func_quote_portable_result= 1189c82838c1Smrg ;; 1190c82838c1Smrg first) 1191c82838c1Smrg set quote "$_G_part" "" 1192c82838c1Smrg ;; 1193c82838c1Smrg esac 1194c82838c1Smrg done 1195c82838c1Smrg done 1196c82838c1Smrg IFS=$func_quote_portable_old_IFS 119735c4bbdfSmrg ;; 1198c82838c1Smrg *) ;; 119935c4bbdfSmrg esac 1200c82838c1Smrg break 120135c4bbdfSmrg done 1202c82838c1Smrg 1203c82838c1Smrg func_quote_portable_unquoted_result=$func_quote_portable_result 1204c82838c1Smrg case $func_quote_portable_result in 1205c82838c1Smrg # double-quote args containing shell metacharacters to delay 1206c82838c1Smrg # word splitting, command substitution and variable expansion 1207c82838c1Smrg # for a subsequent eval. 1208c82838c1Smrg # many bourne shells cannot handle close brackets correctly 1209c82838c1Smrg # in scan sets, so we specify it separately. 1210c82838c1Smrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 1211c82838c1Smrg func_quote_portable_result=\"$func_quote_portable_result\" 1212c82838c1Smrg ;; 1213c82838c1Smrg esac 121405b261ecSmrg} 121505b261ecSmrg 121605b261ecSmrg 1217c82838c1Smrg# func_quotefast_eval ARG 1218c82838c1Smrg# ----------------------- 1219c82838c1Smrg# Quote one ARG (internal). This is equivalent to 'func_quote_arg eval ARG', 1220c82838c1Smrg# but optimized for speed. Result is stored in $func_quotefast_eval. 1221c82838c1Smrgif test xyes = `(x=; printf -v x %q yes; echo x"$x") 2>/dev/null`; then 1222c82838c1Smrg printf -v _GL_test_printf_tilde %q '~' 1223c82838c1Smrg if test '\~' = "$_GL_test_printf_tilde"; then 1224c82838c1Smrg func_quotefast_eval () 1225c82838c1Smrg { 1226c82838c1Smrg printf -v func_quotefast_eval_result %q "$1" 1227c82838c1Smrg } 1228c82838c1Smrg else 1229c82838c1Smrg # Broken older Bash implementations. Make those faster too if possible. 1230c82838c1Smrg func_quotefast_eval () 1231c82838c1Smrg { 1232c82838c1Smrg case $1 in 1233c82838c1Smrg '~'*) 1234c82838c1Smrg func_quote_portable false "$1" 1235c82838c1Smrg func_quotefast_eval_result=$func_quote_portable_result 1236c82838c1Smrg ;; 1237c82838c1Smrg *) 1238c82838c1Smrg printf -v func_quotefast_eval_result %q "$1" 1239c82838c1Smrg ;; 1240c82838c1Smrg esac 1241c82838c1Smrg } 1242c82838c1Smrg fi 1243c82838c1Smrgelse 1244c82838c1Smrg func_quotefast_eval () 1245c82838c1Smrg { 1246c82838c1Smrg func_quote_portable false "$1" 1247c82838c1Smrg func_quotefast_eval_result=$func_quote_portable_result 1248c82838c1Smrg } 1249c82838c1Smrgfi 125035c4bbdfSmrg 1251c82838c1Smrg 1252c82838c1Smrg# func_quote_arg MODEs ARG 1253c82838c1Smrg# ------------------------ 1254c82838c1Smrg# Quote one ARG to be evaled later. MODEs argument may contain zero or more 1255c82838c1Smrg# specifiers listed below separated by ',' character. This function returns two 1256c82838c1Smrg# values: 1257c82838c1Smrg# i) func_quote_arg_result 1258c82838c1Smrg# double-quoted (when needed), suitable for a subsequent eval 1259c82838c1Smrg# ii) func_quote_arg_unquoted_result 1260c82838c1Smrg# has all characters that are still active within double 1261c82838c1Smrg# quotes backslashified. Available only if 'unquoted' is specified. 1262c82838c1Smrg# 1263c82838c1Smrg# Available modes: 1264c82838c1Smrg# ---------------- 1265c82838c1Smrg# 'eval' (default) 1266c82838c1Smrg# - escape shell special characters 1267c82838c1Smrg# 'expand' 1268c82838c1Smrg# - the same as 'eval'; but do not quote variable references 1269c82838c1Smrg# 'pretty' 1270c82838c1Smrg# - request aesthetic output, i.e. '"a b"' instead of 'a\ b'. This might 1271c82838c1Smrg# be used later in func_quote to get output like: 'echo "a b"' instead 1272c82838c1Smrg# of 'echo a\ b'. This is slower than default on some shells. 1273c82838c1Smrg# 'unquoted' 1274c82838c1Smrg# - produce also $func_quote_arg_unquoted_result which does not contain 1275c82838c1Smrg# wrapping double-quotes. 1276c82838c1Smrg# 1277c82838c1Smrg# Examples for 'func_quote_arg pretty,unquoted string': 1278c82838c1Smrg# 1279c82838c1Smrg# string | *_result | *_unquoted_result 1280c82838c1Smrg# ------------+-----------------------+------------------- 1281c82838c1Smrg# " | \" | \" 1282c82838c1Smrg# a b | "a b" | a b 1283c82838c1Smrg# "a b" | "\"a b\"" | \"a b\" 1284c82838c1Smrg# * | "*" | * 1285c82838c1Smrg# z="${x-$y}" | "z=\"\${x-\$y}\"" | z=\"\${x-\$y}\" 1286c82838c1Smrg# 1287c82838c1Smrg# Examples for 'func_quote_arg pretty,unquoted,expand string': 1288c82838c1Smrg# 1289c82838c1Smrg# string | *_result | *_unquoted_result 1290c82838c1Smrg# --------------+---------------------+-------------------- 1291c82838c1Smrg# z="${x-$y}" | "z=\"${x-$y}\"" | z=\"${x-$y}\" 1292c82838c1Smrgfunc_quote_arg () 1293c82838c1Smrg{ 1294c82838c1Smrg _G_quote_expand=false 1295c82838c1Smrg case ,$1, in 1296c82838c1Smrg *,expand,*) 1297c82838c1Smrg _G_quote_expand=: 1298c82838c1Smrg ;; 12994642e01fSmrg esac 13004642e01fSmrg 1301c82838c1Smrg case ,$1, in 1302c82838c1Smrg *,pretty,*|*,expand,*|*,unquoted,*) 1303c82838c1Smrg func_quote_portable $_G_quote_expand "$2" 1304c82838c1Smrg func_quote_arg_result=$func_quote_portable_result 1305c82838c1Smrg func_quote_arg_unquoted_result=$func_quote_portable_unquoted_result 1306c82838c1Smrg ;; 1307c82838c1Smrg *) 1308c82838c1Smrg # Faster quote-for-eval for some shells. 1309c82838c1Smrg func_quotefast_eval "$2" 1310c82838c1Smrg func_quote_arg_result=$func_quotefast_eval_result 13114642e01fSmrg ;; 13124642e01fSmrg esac 1313c82838c1Smrg} 13144642e01fSmrg 1315c82838c1Smrg 1316c82838c1Smrg# func_quote MODEs ARGs... 1317c82838c1Smrg# ------------------------ 1318c82838c1Smrg# Quote all ARGs to be evaled later and join them into single command. See 1319c82838c1Smrg# func_quote_arg's description for more info. 1320c82838c1Smrgfunc_quote () 1321c82838c1Smrg{ 1322c82838c1Smrg $debug_cmd 1323c82838c1Smrg _G_func_quote_mode=$1 ; shift 1324c82838c1Smrg func_quote_result= 1325c82838c1Smrg while test 0 -lt $#; do 1326c82838c1Smrg func_quote_arg "$_G_func_quote_mode" "$1" 1327c82838c1Smrg if test -n "$func_quote_result"; then 1328c82838c1Smrg func_append func_quote_result " $func_quote_arg_result" 1329c82838c1Smrg else 1330c82838c1Smrg func_append func_quote_result "$func_quote_arg_result" 1331c82838c1Smrg fi 1332c82838c1Smrg shift 1333c82838c1Smrg done 133405b261ecSmrg} 133505b261ecSmrg 133605b261ecSmrg 133735c4bbdfSmrg# func_stripname PREFIX SUFFIX NAME 133835c4bbdfSmrg# --------------------------------- 133935c4bbdfSmrg# strip PREFIX and SUFFIX from NAME, and store in func_stripname_result. 134035c4bbdfSmrg# PREFIX and SUFFIX must not contain globbing or regex special 134135c4bbdfSmrg# characters, hashes, percent signs, but SUFFIX may contain a leading 134235c4bbdfSmrg# dot (in which case that matches only a dot). 134335c4bbdfSmrgif test yes = "$_G_HAVE_XSI_OPS"; then 134435c4bbdfSmrg eval 'func_stripname () 134535c4bbdfSmrg { 134635c4bbdfSmrg $debug_cmd 134735c4bbdfSmrg 134835c4bbdfSmrg # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are 134935c4bbdfSmrg # positional parameters, so assign one to ordinary variable first. 135035c4bbdfSmrg func_stripname_result=$3 135135c4bbdfSmrg func_stripname_result=${func_stripname_result#"$1"} 135235c4bbdfSmrg func_stripname_result=${func_stripname_result%"$2"} 135335c4bbdfSmrg }' 135435c4bbdfSmrgelse 135535c4bbdfSmrg func_stripname () 135635c4bbdfSmrg { 135735c4bbdfSmrg $debug_cmd 135835c4bbdfSmrg 135935c4bbdfSmrg case $2 in 136035c4bbdfSmrg .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;; 136135c4bbdfSmrg *) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;; 136235c4bbdfSmrg esac 136335c4bbdfSmrg } 136435c4bbdfSmrgfi 136535c4bbdfSmrg 136635c4bbdfSmrg 136735c4bbdfSmrg# func_show_eval CMD [FAIL_EXP] 136835c4bbdfSmrg# ----------------------------- 136935c4bbdfSmrg# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is 13704642e01fSmrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 13714642e01fSmrg# is given, then evaluate it. 13724642e01fSmrgfunc_show_eval () 137305b261ecSmrg{ 137435c4bbdfSmrg $debug_cmd 137505b261ecSmrg 137635c4bbdfSmrg _G_cmd=$1 137735c4bbdfSmrg _G_fail_exp=${2-':'} 13784642e01fSmrg 1379c82838c1Smrg func_quote_arg pretty,expand "$_G_cmd" 1380c82838c1Smrg eval "func_notquiet $func_quote_arg_result" 138135c4bbdfSmrg 138235c4bbdfSmrg $opt_dry_run || { 138335c4bbdfSmrg eval "$_G_cmd" 138435c4bbdfSmrg _G_status=$? 138535c4bbdfSmrg if test 0 -ne "$_G_status"; then 138635c4bbdfSmrg eval "(exit $_G_status); $_G_fail_exp" 13874642e01fSmrg fi 138835c4bbdfSmrg } 138905b261ecSmrg} 139005b261ecSmrg 13914642e01fSmrg 139235c4bbdfSmrg# func_show_eval_locale CMD [FAIL_EXP] 139335c4bbdfSmrg# ------------------------------------ 139435c4bbdfSmrg# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is 13954642e01fSmrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 13964642e01fSmrg# is given, then evaluate it. Use the saved locale for evaluation. 13974642e01fSmrgfunc_show_eval_locale () 139805b261ecSmrg{ 139935c4bbdfSmrg $debug_cmd 14004642e01fSmrg 140135c4bbdfSmrg _G_cmd=$1 140235c4bbdfSmrg _G_fail_exp=${2-':'} 140335c4bbdfSmrg 140435c4bbdfSmrg $opt_quiet || { 1405c82838c1Smrg func_quote_arg expand,pretty "$_G_cmd" 1406c82838c1Smrg eval "func_echo $func_quote_arg_result" 14074642e01fSmrg } 14084642e01fSmrg 140935c4bbdfSmrg $opt_dry_run || { 141035c4bbdfSmrg eval "$_G_user_locale 141135c4bbdfSmrg $_G_cmd" 141235c4bbdfSmrg _G_status=$? 141335c4bbdfSmrg eval "$_G_safe_locale" 141435c4bbdfSmrg if test 0 -ne "$_G_status"; then 141535c4bbdfSmrg eval "(exit $_G_status); $_G_fail_exp" 14164642e01fSmrg fi 141735c4bbdfSmrg } 14184642e01fSmrg} 141905b261ecSmrg 14204642e01fSmrg 142135c4bbdfSmrg# func_tr_sh 142235c4bbdfSmrg# ---------- 142335c4bbdfSmrg# Turn $1 into a string suitable for a shell variable name. 142435c4bbdfSmrg# Result is stored in $func_tr_sh_result. All characters 142535c4bbdfSmrg# not in the set a-zA-Z0-9_ are replaced with '_'. Further, 142635c4bbdfSmrg# if $1 begins with a digit, a '_' is prepended as well. 142735c4bbdfSmrgfunc_tr_sh () 14284642e01fSmrg{ 142935c4bbdfSmrg $debug_cmd 14304642e01fSmrg 143135c4bbdfSmrg case $1 in 143235c4bbdfSmrg [0-9]* | *[!a-zA-Z0-9_]*) 143335c4bbdfSmrg func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'` 143435c4bbdfSmrg ;; 143535c4bbdfSmrg * ) 143635c4bbdfSmrg func_tr_sh_result=$1 143735c4bbdfSmrg ;; 143835c4bbdfSmrg esac 14394642e01fSmrg} 14404642e01fSmrg 14414642e01fSmrg 144235c4bbdfSmrg# func_verbose ARG... 144335c4bbdfSmrg# ------------------- 144435c4bbdfSmrg# Echo program name prefixed message in verbose mode only. 144535c4bbdfSmrgfunc_verbose () 14464642e01fSmrg{ 144735c4bbdfSmrg $debug_cmd 144805b261ecSmrg 144935c4bbdfSmrg $opt_verbose && func_echo "$*" 14506747b715Smrg 145135c4bbdfSmrg : 145235c4bbdfSmrg} 14534642e01fSmrg 14544642e01fSmrg 145535c4bbdfSmrg# func_warn_and_continue ARG... 145635c4bbdfSmrg# ----------------------------- 145735c4bbdfSmrg# Echo program name prefixed warning message to standard error. 145835c4bbdfSmrgfunc_warn_and_continue () 145935c4bbdfSmrg{ 146035c4bbdfSmrg $debug_cmd 146105b261ecSmrg 146235c4bbdfSmrg $require_term_colors 146305b261ecSmrg 146435c4bbdfSmrg func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2 146535c4bbdfSmrg} 1466475c125cSmrg 146735c4bbdfSmrg 146835c4bbdfSmrg# func_warning CATEGORY ARG... 146935c4bbdfSmrg# ---------------------------- 147035c4bbdfSmrg# Echo program name prefixed warning message to standard error. Warning 147135c4bbdfSmrg# messages can be filtered according to CATEGORY, where this function 147235c4bbdfSmrg# elides messages where CATEGORY is not listed in the global variable 147335c4bbdfSmrg# 'opt_warning_types'. 147435c4bbdfSmrgfunc_warning () 147535c4bbdfSmrg{ 147635c4bbdfSmrg $debug_cmd 147735c4bbdfSmrg 147835c4bbdfSmrg # CATEGORY must be in the warning_categories list! 147935c4bbdfSmrg case " $warning_categories " in 148035c4bbdfSmrg *" $1 "*) ;; 148135c4bbdfSmrg *) func_internal_error "invalid warning category '$1'" ;; 148235c4bbdfSmrg esac 148335c4bbdfSmrg 148435c4bbdfSmrg _G_category=$1 148535c4bbdfSmrg shift 148635c4bbdfSmrg 148735c4bbdfSmrg case " $opt_warning_types " in 148835c4bbdfSmrg *" $_G_category "*) $warning_func ${1+"$@"} ;; 148935c4bbdfSmrg esac 149035c4bbdfSmrg} 149135c4bbdfSmrg 149235c4bbdfSmrg 149335c4bbdfSmrg# func_sort_ver VER1 VER2 149435c4bbdfSmrg# ----------------------- 149535c4bbdfSmrg# 'sort -V' is not generally available. 149635c4bbdfSmrg# Note this deviates from the version comparison in automake 149735c4bbdfSmrg# in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a 149835c4bbdfSmrg# but this should suffice as we won't be specifying old 149935c4bbdfSmrg# version formats or redundant trailing .0 in bootstrap.conf. 150035c4bbdfSmrg# If we did want full compatibility then we should probably 150135c4bbdfSmrg# use m4_version_compare from autoconf. 150235c4bbdfSmrgfunc_sort_ver () 150335c4bbdfSmrg{ 150435c4bbdfSmrg $debug_cmd 150535c4bbdfSmrg 150635c4bbdfSmrg printf '%s\n%s\n' "$1" "$2" \ 150735c4bbdfSmrg | 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 150835c4bbdfSmrg} 150935c4bbdfSmrg 151035c4bbdfSmrg# func_lt_ver PREV CURR 151135c4bbdfSmrg# --------------------- 151235c4bbdfSmrg# Return true if PREV and CURR are in the correct order according to 151335c4bbdfSmrg# func_sort_ver, otherwise false. Use it like this: 151435c4bbdfSmrg# 151535c4bbdfSmrg# func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..." 151635c4bbdfSmrgfunc_lt_ver () 151735c4bbdfSmrg{ 151835c4bbdfSmrg $debug_cmd 151935c4bbdfSmrg 152035c4bbdfSmrg test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q` 152135c4bbdfSmrg} 152235c4bbdfSmrg 152335c4bbdfSmrg 152435c4bbdfSmrg# Local variables: 152535c4bbdfSmrg# mode: shell-script 152635c4bbdfSmrg# sh-indentation: 2 152735c4bbdfSmrg# eval: (add-hook 'before-save-hook 'time-stamp) 152835c4bbdfSmrg# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" 152935c4bbdfSmrg# time-stamp-time-zone: "UTC" 153035c4bbdfSmrg# End: 153135c4bbdfSmrg#! /bin/sh 153235c4bbdfSmrg 153335c4bbdfSmrg# A portable, pluggable option parser for Bourne shell. 153435c4bbdfSmrg# Written by Gary V. Vaughan, 2010 153535c4bbdfSmrg 1536c82838c1Smrg# This is free software. There is NO warranty; not even for 1537c82838c1Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 1538c82838c1Smrg# 1539c82838c1Smrg# Copyright (C) 2010-2019, 2021 Bootstrap Authors 1540c82838c1Smrg# 1541c82838c1Smrg# This file is dual licensed under the terms of the MIT license 1542c82838c1Smrg# <https://opensource.org/license/MIT>, and GPL version 2 or later 1543c82838c1Smrg# <http://www.gnu.org/licenses/gpl-2.0.html>. You must apply one of 1544c82838c1Smrg# these licenses when using or redistributing this software or any of 1545c82838c1Smrg# the files within it. See the URLs above, or the file `LICENSE` 1546c82838c1Smrg# included in the Bootstrap distribution for the full license texts. 154735c4bbdfSmrg 1548c82838c1Smrg# Please report bugs or propose patches to: 1549c82838c1Smrg# <https://github.com/gnulib-modules/bootstrap/issues> 155035c4bbdfSmrg 1551c82838c1Smrg# Set a version string for this script. 1552c82838c1Smrgscriptversion=2019-02-19.15; # UTC 155335c4bbdfSmrg 155435c4bbdfSmrg 155535c4bbdfSmrg## ------ ## 155635c4bbdfSmrg## Usage. ## 155735c4bbdfSmrg## ------ ## 155835c4bbdfSmrg 155935c4bbdfSmrg# This file is a library for parsing options in your shell scripts along 156035c4bbdfSmrg# with assorted other useful supporting features that you can make use 156135c4bbdfSmrg# of too. 156235c4bbdfSmrg# 156335c4bbdfSmrg# For the simplest scripts you might need only: 156435c4bbdfSmrg# 156535c4bbdfSmrg# #!/bin/sh 156635c4bbdfSmrg# . relative/path/to/funclib.sh 156735c4bbdfSmrg# . relative/path/to/options-parser 156835c4bbdfSmrg# scriptversion=1.0 156935c4bbdfSmrg# func_options ${1+"$@"} 157035c4bbdfSmrg# eval set dummy "$func_options_result"; shift 157135c4bbdfSmrg# ...rest of your script... 157235c4bbdfSmrg# 157335c4bbdfSmrg# In order for the '--version' option to work, you will need to have a 157435c4bbdfSmrg# suitably formatted comment like the one at the top of this file 1575c82838c1Smrg# starting with '# Written by ' and ending with '# Copyright'. 157635c4bbdfSmrg# 157735c4bbdfSmrg# For '-h' and '--help' to work, you will also need a one line 157835c4bbdfSmrg# description of your script's purpose in a comment directly above the 157935c4bbdfSmrg# '# Written by ' line, like the one at the top of this file. 158035c4bbdfSmrg# 158135c4bbdfSmrg# The default options also support '--debug', which will turn on shell 158235c4bbdfSmrg# execution tracing (see the comment above debug_cmd below for another 158335c4bbdfSmrg# use), and '--verbose' and the func_verbose function to allow your script 158435c4bbdfSmrg# to display verbose messages only when your user has specified 158535c4bbdfSmrg# '--verbose'. 158635c4bbdfSmrg# 1587c82838c1Smrg# After sourcing this file, you can plug in processing for additional 158835c4bbdfSmrg# options by amending the variables from the 'Configuration' section 158935c4bbdfSmrg# below, and following the instructions in the 'Option parsing' 159035c4bbdfSmrg# section further down. 159135c4bbdfSmrg 159235c4bbdfSmrg## -------------- ## 159335c4bbdfSmrg## Configuration. ## 159435c4bbdfSmrg## -------------- ## 159535c4bbdfSmrg 159635c4bbdfSmrg# You should override these variables in your script after sourcing this 159735c4bbdfSmrg# file so that they reflect the customisations you have added to the 159835c4bbdfSmrg# option parser. 159935c4bbdfSmrg 160035c4bbdfSmrg# The usage line for option parsing errors and the start of '-h' and 160135c4bbdfSmrg# '--help' output messages. You can embed shell variables for delayed 160235c4bbdfSmrg# expansion at the time the message is displayed, but you will need to 160335c4bbdfSmrg# quote other shell meta-characters carefully to prevent them being 160435c4bbdfSmrg# expanded when the contents are evaled. 160535c4bbdfSmrgusage='$progpath [OPTION]...' 160635c4bbdfSmrg 160735c4bbdfSmrg# Short help message in response to '-h' and '--help'. Add to this or 160835c4bbdfSmrg# override it after sourcing this library to reflect the full set of 160935c4bbdfSmrg# options your script accepts. 161035c4bbdfSmrgusage_message="\ 161135c4bbdfSmrg --debug enable verbose shell tracing 161235c4bbdfSmrg -W, --warnings=CATEGORY 161335c4bbdfSmrg report the warnings falling in CATEGORY [all] 161435c4bbdfSmrg -v, --verbose verbosely report processing 161535c4bbdfSmrg --version print version information and exit 161635c4bbdfSmrg -h, --help print short or long help message and exit 161735c4bbdfSmrg" 161835c4bbdfSmrg 161935c4bbdfSmrg# Additional text appended to 'usage_message' in response to '--help'. 162035c4bbdfSmrglong_help_message=" 162135c4bbdfSmrgWarning categories include: 162235c4bbdfSmrg 'all' show all warnings 162335c4bbdfSmrg 'none' turn off all the warnings 162435c4bbdfSmrg 'error' warnings are treated as fatal errors" 162535c4bbdfSmrg 162635c4bbdfSmrg# Help message printed before fatal option parsing errors. 162735c4bbdfSmrgfatal_help="Try '\$progname --help' for more information." 162835c4bbdfSmrg 162935c4bbdfSmrg 163035c4bbdfSmrg 163135c4bbdfSmrg## ------------------------- ## 163235c4bbdfSmrg## Hook function management. ## 163335c4bbdfSmrg## ------------------------- ## 163435c4bbdfSmrg 163535c4bbdfSmrg# This section contains functions for adding, removing, and running hooks 1636c82838c1Smrg# in the main code. A hook is just a list of function names that can be 1637c82838c1Smrg# run in order later on. 163835c4bbdfSmrg 163935c4bbdfSmrg# func_hookable FUNC_NAME 164035c4bbdfSmrg# ----------------------- 164135c4bbdfSmrg# Declare that FUNC_NAME will run hooks added with 164235c4bbdfSmrg# 'func_add_hook FUNC_NAME ...'. 164335c4bbdfSmrgfunc_hookable () 164435c4bbdfSmrg{ 164535c4bbdfSmrg $debug_cmd 164635c4bbdfSmrg 164735c4bbdfSmrg func_append hookable_fns " $1" 164835c4bbdfSmrg} 164935c4bbdfSmrg 165035c4bbdfSmrg 165135c4bbdfSmrg# func_add_hook FUNC_NAME HOOK_FUNC 165235c4bbdfSmrg# --------------------------------- 165335c4bbdfSmrg# Request that FUNC_NAME call HOOK_FUNC before it returns. FUNC_NAME must 165435c4bbdfSmrg# first have been declared "hookable" by a call to 'func_hookable'. 165535c4bbdfSmrgfunc_add_hook () 165635c4bbdfSmrg{ 165735c4bbdfSmrg $debug_cmd 165835c4bbdfSmrg 165935c4bbdfSmrg case " $hookable_fns " in 166035c4bbdfSmrg *" $1 "*) ;; 166135c4bbdfSmrg *) func_fatal_error "'$1' does not accept hook functions." ;; 166235c4bbdfSmrg esac 166335c4bbdfSmrg 166435c4bbdfSmrg eval func_append ${1}_hooks '" $2"' 166535c4bbdfSmrg} 166635c4bbdfSmrg 166735c4bbdfSmrg 166835c4bbdfSmrg# func_remove_hook FUNC_NAME HOOK_FUNC 166935c4bbdfSmrg# ------------------------------------ 1670c82838c1Smrg# Remove HOOK_FUNC from the list of hook functions to be called by 1671c82838c1Smrg# FUNC_NAME. 167235c4bbdfSmrgfunc_remove_hook () 167335c4bbdfSmrg{ 167435c4bbdfSmrg $debug_cmd 167535c4bbdfSmrg 167635c4bbdfSmrg eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`' 167735c4bbdfSmrg} 167835c4bbdfSmrg 167935c4bbdfSmrg 1680c82838c1Smrg# func_propagate_result FUNC_NAME_A FUNC_NAME_B 1681c82838c1Smrg# --------------------------------------------- 1682c82838c1Smrg# If the *_result variable of FUNC_NAME_A _is set_, assign its value to 1683c82838c1Smrg# *_result variable of FUNC_NAME_B. 1684c82838c1Smrgfunc_propagate_result () 1685c82838c1Smrg{ 1686c82838c1Smrg $debug_cmd 1687c82838c1Smrg 1688c82838c1Smrg func_propagate_result_result=: 1689c82838c1Smrg if eval "test \"\${${1}_result+set}\" = set" 1690c82838c1Smrg then 1691c82838c1Smrg eval "${2}_result=\$${1}_result" 1692c82838c1Smrg else 1693c82838c1Smrg func_propagate_result_result=false 1694c82838c1Smrg fi 1695c82838c1Smrg} 1696c82838c1Smrg 1697c82838c1Smrg 169835c4bbdfSmrg# func_run_hooks FUNC_NAME [ARG]... 169935c4bbdfSmrg# --------------------------------- 170035c4bbdfSmrg# Run all hook functions registered to FUNC_NAME. 1701c82838c1Smrg# It's assumed that the list of hook functions contains nothing more 170235c4bbdfSmrg# than a whitespace-delimited list of legal shell function names, and 170335c4bbdfSmrg# no effort is wasted trying to catch shell meta-characters or preserve 170435c4bbdfSmrg# whitespace. 170535c4bbdfSmrgfunc_run_hooks () 170635c4bbdfSmrg{ 170735c4bbdfSmrg $debug_cmd 170835c4bbdfSmrg 170935c4bbdfSmrg case " $hookable_fns " in 171035c4bbdfSmrg *" $1 "*) ;; 1711c82838c1Smrg *) func_fatal_error "'$1' does not support hook functions." ;; 171235c4bbdfSmrg esac 171335c4bbdfSmrg 171435c4bbdfSmrg eval _G_hook_fns=\$$1_hooks; shift 171535c4bbdfSmrg 171635c4bbdfSmrg for _G_hook in $_G_hook_fns; do 1717c82838c1Smrg func_unset "${_G_hook}_result" 1718c82838c1Smrg eval $_G_hook '${1+"$@"}' 1719c82838c1Smrg func_propagate_result $_G_hook func_run_hooks 1720c82838c1Smrg if $func_propagate_result_result; then 1721c82838c1Smrg eval set dummy "$func_run_hooks_result"; shift 1722ed6184dfSmrg fi 172335c4bbdfSmrg done 172435c4bbdfSmrg} 172535c4bbdfSmrg 172635c4bbdfSmrg 172735c4bbdfSmrg 172835c4bbdfSmrg## --------------- ## 172935c4bbdfSmrg## Option parsing. ## 173035c4bbdfSmrg## --------------- ## 173135c4bbdfSmrg 173235c4bbdfSmrg# In order to add your own option parsing hooks, you must accept the 1733c82838c1Smrg# full positional parameter list from your hook function. You may remove 1734c82838c1Smrg# or edit any options that you action, and then pass back the remaining 1735c82838c1Smrg# unprocessed options in '<hooked_function_name>_result', escaped 1736c82838c1Smrg# suitably for 'eval'. 1737c82838c1Smrg# 1738c82838c1Smrg# The '<hooked_function_name>_result' variable is automatically unset 1739c82838c1Smrg# before your hook gets called; for best performance, only set the 1740c82838c1Smrg# *_result variable when necessary (i.e. don't call the 'func_quote' 1741c82838c1Smrg# function unnecessarily because it can be an expensive operation on some 1742c82838c1Smrg# machines). 1743ed6184dfSmrg# 1744ed6184dfSmrg# Like this: 174535c4bbdfSmrg# 174635c4bbdfSmrg# my_options_prep () 174735c4bbdfSmrg# { 174835c4bbdfSmrg# $debug_cmd 174935c4bbdfSmrg# 175035c4bbdfSmrg# # Extend the existing usage message. 175135c4bbdfSmrg# usage_message=$usage_message' 175235c4bbdfSmrg# -s, --silent don'\''t print informational messages 175335c4bbdfSmrg# ' 1754c82838c1Smrg# # No change in '$@' (ignored completely by this hook). Leave 1755c82838c1Smrg# # my_options_prep_result variable intact. 175635c4bbdfSmrg# } 175735c4bbdfSmrg# func_add_hook func_options_prep my_options_prep 175835c4bbdfSmrg# 175935c4bbdfSmrg# 176035c4bbdfSmrg# my_silent_option () 176135c4bbdfSmrg# { 176235c4bbdfSmrg# $debug_cmd 176335c4bbdfSmrg# 1764ed6184dfSmrg# args_changed=false 1765ed6184dfSmrg# 1766c82838c1Smrg# # Note that, for efficiency, we parse as many options as we can 176735c4bbdfSmrg# # recognise in a loop before passing the remainder back to the 176835c4bbdfSmrg# # caller on the first unrecognised argument we encounter. 176935c4bbdfSmrg# while test $# -gt 0; do 177035c4bbdfSmrg# opt=$1; shift 177135c4bbdfSmrg# case $opt in 1772ed6184dfSmrg# --silent|-s) opt_silent=: 1773ed6184dfSmrg# args_changed=: 1774ed6184dfSmrg# ;; 177535c4bbdfSmrg# # Separate non-argument short options: 177635c4bbdfSmrg# -s*) func_split_short_opt "$_G_opt" 177735c4bbdfSmrg# set dummy "$func_split_short_opt_name" \ 177835c4bbdfSmrg# "-$func_split_short_opt_arg" ${1+"$@"} 177935c4bbdfSmrg# shift 1780ed6184dfSmrg# args_changed=: 178135c4bbdfSmrg# ;; 1782ed6184dfSmrg# *) # Make sure the first unrecognised option "$_G_opt" 1783c82838c1Smrg# # is added back to "$@" in case we need it later, 1784c82838c1Smrg# # if $args_changed was set to 'true'. 1785ed6184dfSmrg# set dummy "$_G_opt" ${1+"$@"}; shift; break ;; 178635c4bbdfSmrg# esac 178735c4bbdfSmrg# done 178835c4bbdfSmrg# 1789c82838c1Smrg# # Only call 'func_quote' here if we processed at least one argument. 1790ed6184dfSmrg# if $args_changed; then 1791c82838c1Smrg# func_quote eval ${1+"$@"} 1792c82838c1Smrg# my_silent_option_result=$func_quote_result 1793ed6184dfSmrg# fi 179435c4bbdfSmrg# } 179535c4bbdfSmrg# func_add_hook func_parse_options my_silent_option 179635c4bbdfSmrg# 179735c4bbdfSmrg# 179835c4bbdfSmrg# my_option_validation () 179935c4bbdfSmrg# { 180035c4bbdfSmrg# $debug_cmd 180135c4bbdfSmrg# 180235c4bbdfSmrg# $opt_silent && $opt_verbose && func_fatal_help "\ 180335c4bbdfSmrg# '--silent' and '--verbose' options are mutually exclusive." 180435c4bbdfSmrg# } 180535c4bbdfSmrg# func_add_hook func_validate_options my_option_validation 180635c4bbdfSmrg# 1807ed6184dfSmrg# You'll also need to manually amend $usage_message to reflect the extra 180835c4bbdfSmrg# options you parse. It's preferable to append if you can, so that 180935c4bbdfSmrg# multiple option parsing hooks can be added safely. 181035c4bbdfSmrg 181135c4bbdfSmrg 1812ed6184dfSmrg# func_options_finish [ARG]... 1813ed6184dfSmrg# ---------------------------- 1814ed6184dfSmrg# Finishing the option parse loop (call 'func_options' hooks ATM). 1815ed6184dfSmrgfunc_options_finish () 1816ed6184dfSmrg{ 1817ed6184dfSmrg $debug_cmd 1818ed6184dfSmrg 1819c82838c1Smrg func_run_hooks func_options ${1+"$@"} 1820c82838c1Smrg func_propagate_result func_run_hooks func_options_finish 1821ed6184dfSmrg} 1822ed6184dfSmrg 1823ed6184dfSmrg 182435c4bbdfSmrg# func_options [ARG]... 182535c4bbdfSmrg# --------------------- 182635c4bbdfSmrg# All the functions called inside func_options are hookable. See the 182735c4bbdfSmrg# individual implementations for details. 182835c4bbdfSmrgfunc_hookable func_options 182935c4bbdfSmrgfunc_options () 183035c4bbdfSmrg{ 183135c4bbdfSmrg $debug_cmd 183235c4bbdfSmrg 1833c82838c1Smrg _G_options_quoted=false 1834ed6184dfSmrg 1835ed6184dfSmrg for my_func in options_prep parse_options validate_options options_finish 1836ed6184dfSmrg do 1837c82838c1Smrg func_unset func_${my_func}_result 1838c82838c1Smrg func_unset func_run_hooks_result 1839c82838c1Smrg eval func_$my_func '${1+"$@"}' 1840c82838c1Smrg func_propagate_result func_$my_func func_options 1841c82838c1Smrg if $func_propagate_result_result; then 1842c82838c1Smrg eval set dummy "$func_options_result"; shift 1843c82838c1Smrg _G_options_quoted=: 1844ed6184dfSmrg fi 1845ed6184dfSmrg done 184635c4bbdfSmrg 1847c82838c1Smrg $_G_options_quoted || { 1848c82838c1Smrg # As we (func_options) are top-level options-parser function and 1849c82838c1Smrg # nobody quoted "$@" for us yet, we need to do it explicitly for 1850c82838c1Smrg # caller. 1851c82838c1Smrg func_quote eval ${1+"$@"} 1852c82838c1Smrg func_options_result=$func_quote_result 1853c82838c1Smrg } 185435c4bbdfSmrg} 185535c4bbdfSmrg 185635c4bbdfSmrg 185735c4bbdfSmrg# func_options_prep [ARG]... 185835c4bbdfSmrg# -------------------------- 185935c4bbdfSmrg# All initialisations required before starting the option parse loop. 186035c4bbdfSmrg# Note that when calling hook functions, we pass through the list of 186135c4bbdfSmrg# positional parameters. If a hook function modifies that list, and 1862ed6184dfSmrg# needs to propagate that back to rest of this script, then the complete 1863c82838c1Smrg# modified list must be put in 'func_run_hooks_result' before returning. 186435c4bbdfSmrgfunc_hookable func_options_prep 186535c4bbdfSmrgfunc_options_prep () 186635c4bbdfSmrg{ 186735c4bbdfSmrg $debug_cmd 186835c4bbdfSmrg 186935c4bbdfSmrg # Option defaults: 187035c4bbdfSmrg opt_verbose=false 187135c4bbdfSmrg opt_warning_types= 187235c4bbdfSmrg 1873c82838c1Smrg func_run_hooks func_options_prep ${1+"$@"} 1874c82838c1Smrg func_propagate_result func_run_hooks func_options_prep 187535c4bbdfSmrg} 187635c4bbdfSmrg 187735c4bbdfSmrg 187835c4bbdfSmrg# func_parse_options [ARG]... 187935c4bbdfSmrg# --------------------------- 188035c4bbdfSmrg# The main option parsing loop. 188135c4bbdfSmrgfunc_hookable func_parse_options 188235c4bbdfSmrgfunc_parse_options () 188335c4bbdfSmrg{ 188435c4bbdfSmrg $debug_cmd 188535c4bbdfSmrg 1886c82838c1Smrg _G_parse_options_requote=false 188735c4bbdfSmrg # this just eases exit handling 188835c4bbdfSmrg while test $# -gt 0; do 188935c4bbdfSmrg # Defer to hook functions for initial option parsing, so they 189035c4bbdfSmrg # get priority in the event of reusing an option name. 1891c82838c1Smrg func_run_hooks func_parse_options ${1+"$@"} 1892c82838c1Smrg func_propagate_result func_run_hooks func_parse_options 1893c82838c1Smrg if $func_propagate_result_result; then 1894c82838c1Smrg eval set dummy "$func_parse_options_result"; shift 1895c82838c1Smrg # Even though we may have changed "$@", we passed the "$@" array 1896c82838c1Smrg # down into the hook and it quoted it for us (because we are in 1897c82838c1Smrg # this if-branch). No need to quote it again. 1898c82838c1Smrg _G_parse_options_requote=false 1899ed6184dfSmrg fi 190035c4bbdfSmrg 190135c4bbdfSmrg # Break out of the loop if we already parsed every option. 190235c4bbdfSmrg test $# -gt 0 || break 190335c4bbdfSmrg 1904c82838c1Smrg # We expect that one of the options parsed in this function matches 1905c82838c1Smrg # and thus we remove _G_opt from "$@" and need to re-quote. 1906ed6184dfSmrg _G_match_parse_options=: 190735c4bbdfSmrg _G_opt=$1 190835c4bbdfSmrg shift 190935c4bbdfSmrg case $_G_opt in 191035c4bbdfSmrg --debug|-x) debug_cmd='set -x' 1911c82838c1Smrg func_echo "enabling shell trace mode" >&2 191235c4bbdfSmrg $debug_cmd 191335c4bbdfSmrg ;; 191435c4bbdfSmrg 191535c4bbdfSmrg --no-warnings|--no-warning|--no-warn) 191635c4bbdfSmrg set dummy --warnings none ${1+"$@"} 191735c4bbdfSmrg shift 191835c4bbdfSmrg ;; 191935c4bbdfSmrg 192035c4bbdfSmrg --warnings|--warning|-W) 1921ed6184dfSmrg if test $# = 0 && func_missing_arg $_G_opt; then 1922c82838c1Smrg _G_parse_options_requote=: 1923ed6184dfSmrg break 1924ed6184dfSmrg fi 192535c4bbdfSmrg case " $warning_categories $1" in 192635c4bbdfSmrg *" $1 "*) 192735c4bbdfSmrg # trailing space prevents matching last $1 above 192835c4bbdfSmrg func_append_uniq opt_warning_types " $1" 192935c4bbdfSmrg ;; 193035c4bbdfSmrg *all) 193135c4bbdfSmrg opt_warning_types=$warning_categories 193235c4bbdfSmrg ;; 193335c4bbdfSmrg *none) 193435c4bbdfSmrg opt_warning_types=none 193535c4bbdfSmrg warning_func=: 193635c4bbdfSmrg ;; 193735c4bbdfSmrg *error) 193835c4bbdfSmrg opt_warning_types=$warning_categories 193935c4bbdfSmrg warning_func=func_fatal_error 194035c4bbdfSmrg ;; 194135c4bbdfSmrg *) 194235c4bbdfSmrg func_fatal_error \ 194335c4bbdfSmrg "unsupported warning category: '$1'" 194435c4bbdfSmrg ;; 194535c4bbdfSmrg esac 194635c4bbdfSmrg shift 194735c4bbdfSmrg ;; 194835c4bbdfSmrg 194935c4bbdfSmrg --verbose|-v) opt_verbose=: ;; 195035c4bbdfSmrg --version) func_version ;; 195135c4bbdfSmrg -\?|-h) func_usage ;; 195235c4bbdfSmrg --help) func_help ;; 195335c4bbdfSmrg 195435c4bbdfSmrg # Separate optargs to long options (plugins may need this): 195535c4bbdfSmrg --*=*) func_split_equals "$_G_opt" 195635c4bbdfSmrg set dummy "$func_split_equals_lhs" \ 195735c4bbdfSmrg "$func_split_equals_rhs" ${1+"$@"} 195835c4bbdfSmrg shift 195935c4bbdfSmrg ;; 196035c4bbdfSmrg 196135c4bbdfSmrg # Separate optargs to short options: 196235c4bbdfSmrg -W*) 196335c4bbdfSmrg func_split_short_opt "$_G_opt" 196435c4bbdfSmrg set dummy "$func_split_short_opt_name" \ 196535c4bbdfSmrg "$func_split_short_opt_arg" ${1+"$@"} 196635c4bbdfSmrg shift 196735c4bbdfSmrg ;; 196835c4bbdfSmrg 196935c4bbdfSmrg # Separate non-argument short options: 197035c4bbdfSmrg -\?*|-h*|-v*|-x*) 197135c4bbdfSmrg func_split_short_opt "$_G_opt" 197235c4bbdfSmrg set dummy "$func_split_short_opt_name" \ 197335c4bbdfSmrg "-$func_split_short_opt_arg" ${1+"$@"} 197435c4bbdfSmrg shift 197535c4bbdfSmrg ;; 197635c4bbdfSmrg 1977c82838c1Smrg --) _G_parse_options_requote=: ; break ;; 197835c4bbdfSmrg -*) func_fatal_help "unrecognised option: '$_G_opt'" ;; 1979ed6184dfSmrg *) set dummy "$_G_opt" ${1+"$@"}; shift 1980ed6184dfSmrg _G_match_parse_options=false 1981ed6184dfSmrg break 1982ed6184dfSmrg ;; 198335c4bbdfSmrg esac 1984ed6184dfSmrg 1985c82838c1Smrg if $_G_match_parse_options; then 1986c82838c1Smrg _G_parse_options_requote=: 1987c82838c1Smrg fi 198835c4bbdfSmrg done 198935c4bbdfSmrg 1990c82838c1Smrg if $_G_parse_options_requote; then 1991ed6184dfSmrg # save modified positional parameters for caller 1992c82838c1Smrg func_quote eval ${1+"$@"} 1993c82838c1Smrg func_parse_options_result=$func_quote_result 1994ed6184dfSmrg fi 199535c4bbdfSmrg} 199635c4bbdfSmrg 199735c4bbdfSmrg 199835c4bbdfSmrg# func_validate_options [ARG]... 199935c4bbdfSmrg# ------------------------------ 200035c4bbdfSmrg# Perform any sanity checks on option settings and/or unconsumed 200135c4bbdfSmrg# arguments. 200235c4bbdfSmrgfunc_hookable func_validate_options 200335c4bbdfSmrgfunc_validate_options () 200435c4bbdfSmrg{ 200535c4bbdfSmrg $debug_cmd 200635c4bbdfSmrg 200735c4bbdfSmrg # Display all warnings if -W was not given. 200835c4bbdfSmrg test -n "$opt_warning_types" || opt_warning_types=" $warning_categories" 200935c4bbdfSmrg 2010c82838c1Smrg func_run_hooks func_validate_options ${1+"$@"} 2011c82838c1Smrg func_propagate_result func_run_hooks func_validate_options 201235c4bbdfSmrg 201335c4bbdfSmrg # Bail if the options were screwed! 201435c4bbdfSmrg $exit_cmd $EXIT_FAILURE 201535c4bbdfSmrg} 201635c4bbdfSmrg 201735c4bbdfSmrg 201835c4bbdfSmrg 201935c4bbdfSmrg## ----------------- ## 202035c4bbdfSmrg## Helper functions. ## 202135c4bbdfSmrg## ----------------- ## 202235c4bbdfSmrg 202335c4bbdfSmrg# This section contains the helper functions used by the rest of the 202435c4bbdfSmrg# hookable option parser framework in ascii-betical order. 202535c4bbdfSmrg 202635c4bbdfSmrg 202735c4bbdfSmrg# func_fatal_help ARG... 202835c4bbdfSmrg# ---------------------- 202935c4bbdfSmrg# Echo program name prefixed message to standard error, followed by 203035c4bbdfSmrg# a help hint, and exit. 203135c4bbdfSmrgfunc_fatal_help () 203235c4bbdfSmrg{ 203335c4bbdfSmrg $debug_cmd 203435c4bbdfSmrg 203535c4bbdfSmrg eval \$ECHO \""Usage: $usage"\" 203635c4bbdfSmrg eval \$ECHO \""$fatal_help"\" 203735c4bbdfSmrg func_error ${1+"$@"} 203835c4bbdfSmrg exit $EXIT_FAILURE 203935c4bbdfSmrg} 204035c4bbdfSmrg 204135c4bbdfSmrg 204235c4bbdfSmrg# func_help 204335c4bbdfSmrg# --------- 204435c4bbdfSmrg# Echo long help message to standard output and exit. 204535c4bbdfSmrgfunc_help () 204635c4bbdfSmrg{ 204735c4bbdfSmrg $debug_cmd 204835c4bbdfSmrg 204935c4bbdfSmrg func_usage_message 205035c4bbdfSmrg $ECHO "$long_help_message" 205135c4bbdfSmrg exit 0 205235c4bbdfSmrg} 205335c4bbdfSmrg 205435c4bbdfSmrg 205535c4bbdfSmrg# func_missing_arg ARGNAME 205635c4bbdfSmrg# ------------------------ 205735c4bbdfSmrg# Echo program name prefixed message to standard error and set global 205835c4bbdfSmrg# exit_cmd. 205935c4bbdfSmrgfunc_missing_arg () 206035c4bbdfSmrg{ 206135c4bbdfSmrg $debug_cmd 206235c4bbdfSmrg 206335c4bbdfSmrg func_error "Missing argument for '$1'." 206435c4bbdfSmrg exit_cmd=exit 206535c4bbdfSmrg} 206635c4bbdfSmrg 206735c4bbdfSmrg 206835c4bbdfSmrg# func_split_equals STRING 206935c4bbdfSmrg# ------------------------ 2070c82838c1Smrg# Set func_split_equals_lhs and func_split_equals_rhs shell variables 2071c82838c1Smrg# after splitting STRING at the '=' sign. 207235c4bbdfSmrgtest -z "$_G_HAVE_XSI_OPS" \ 207335c4bbdfSmrg && (eval 'x=a/b/c; 207435c4bbdfSmrg test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ 207535c4bbdfSmrg && _G_HAVE_XSI_OPS=yes 207635c4bbdfSmrg 207735c4bbdfSmrgif test yes = "$_G_HAVE_XSI_OPS" 207835c4bbdfSmrgthen 207935c4bbdfSmrg # This is an XSI compatible shell, allowing a faster implementation... 208035c4bbdfSmrg eval 'func_split_equals () 208135c4bbdfSmrg { 208235c4bbdfSmrg $debug_cmd 208335c4bbdfSmrg 208435c4bbdfSmrg func_split_equals_lhs=${1%%=*} 208535c4bbdfSmrg func_split_equals_rhs=${1#*=} 2086c82838c1Smrg if test "x$func_split_equals_lhs" = "x$1"; then 2087c82838c1Smrg func_split_equals_rhs= 2088c82838c1Smrg fi 208935c4bbdfSmrg }' 209035c4bbdfSmrgelse 209135c4bbdfSmrg # ...otherwise fall back to using expr, which is often a shell builtin. 209235c4bbdfSmrg func_split_equals () 209335c4bbdfSmrg { 209435c4bbdfSmrg $debug_cmd 209535c4bbdfSmrg 209635c4bbdfSmrg func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'` 209735c4bbdfSmrg func_split_equals_rhs= 2098c82838c1Smrg test "x$func_split_equals_lhs=" = "x$1" \ 209935c4bbdfSmrg || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'` 210035c4bbdfSmrg } 210135c4bbdfSmrgfi #func_split_equals 210235c4bbdfSmrg 210335c4bbdfSmrg 210435c4bbdfSmrg# func_split_short_opt SHORTOPT 210535c4bbdfSmrg# ----------------------------- 210635c4bbdfSmrg# Set func_split_short_opt_name and func_split_short_opt_arg shell 210735c4bbdfSmrg# variables after splitting SHORTOPT after the 2nd character. 210835c4bbdfSmrgif test yes = "$_G_HAVE_XSI_OPS" 210935c4bbdfSmrgthen 211035c4bbdfSmrg # This is an XSI compatible shell, allowing a faster implementation... 211135c4bbdfSmrg eval 'func_split_short_opt () 211235c4bbdfSmrg { 211335c4bbdfSmrg $debug_cmd 211435c4bbdfSmrg 211535c4bbdfSmrg func_split_short_opt_arg=${1#??} 211635c4bbdfSmrg func_split_short_opt_name=${1%"$func_split_short_opt_arg"} 211735c4bbdfSmrg }' 211835c4bbdfSmrgelse 211935c4bbdfSmrg # ...otherwise fall back to using expr, which is often a shell builtin. 212035c4bbdfSmrg func_split_short_opt () 212135c4bbdfSmrg { 212235c4bbdfSmrg $debug_cmd 212335c4bbdfSmrg 2124c82838c1Smrg func_split_short_opt_name=`expr "x$1" : 'x\(-.\)'` 212535c4bbdfSmrg func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'` 212635c4bbdfSmrg } 212735c4bbdfSmrgfi #func_split_short_opt 212835c4bbdfSmrg 212935c4bbdfSmrg 213035c4bbdfSmrg# func_usage 213135c4bbdfSmrg# ---------- 213235c4bbdfSmrg# Echo short help message to standard output and exit. 213335c4bbdfSmrgfunc_usage () 213435c4bbdfSmrg{ 213535c4bbdfSmrg $debug_cmd 213635c4bbdfSmrg 213735c4bbdfSmrg func_usage_message 213835c4bbdfSmrg $ECHO "Run '$progname --help |${PAGER-more}' for full usage" 213935c4bbdfSmrg exit 0 214035c4bbdfSmrg} 214135c4bbdfSmrg 214235c4bbdfSmrg 214335c4bbdfSmrg# func_usage_message 214435c4bbdfSmrg# ------------------ 214535c4bbdfSmrg# Echo short help message to standard output. 214635c4bbdfSmrgfunc_usage_message () 214735c4bbdfSmrg{ 214835c4bbdfSmrg $debug_cmd 214935c4bbdfSmrg 215035c4bbdfSmrg eval \$ECHO \""Usage: $usage"\" 215135c4bbdfSmrg echo 215235c4bbdfSmrg $SED -n 's|^# || 215335c4bbdfSmrg /^Written by/{ 215435c4bbdfSmrg x;p;x 215535c4bbdfSmrg } 215635c4bbdfSmrg h 215735c4bbdfSmrg /^Written by/q' < "$progpath" 215835c4bbdfSmrg echo 215935c4bbdfSmrg eval \$ECHO \""$usage_message"\" 216035c4bbdfSmrg} 216135c4bbdfSmrg 216235c4bbdfSmrg 216335c4bbdfSmrg# func_version 216435c4bbdfSmrg# ------------ 216535c4bbdfSmrg# Echo version message to standard output and exit. 2166c82838c1Smrg# The version message is extracted from the calling file's header 2167c82838c1Smrg# comments, with leading '# ' stripped: 2168c82838c1Smrg# 1. First display the progname and version 2169c82838c1Smrg# 2. Followed by the header comment line matching /^# Written by / 2170c82838c1Smrg# 3. Then a blank line followed by the first following line matching 2171c82838c1Smrg# /^# Copyright / 2172c82838c1Smrg# 4. Immediately followed by any lines between the previous matches, 2173c82838c1Smrg# except lines preceding the intervening completely blank line. 2174c82838c1Smrg# For example, see the header comments of this file. 217535c4bbdfSmrgfunc_version () 217635c4bbdfSmrg{ 217735c4bbdfSmrg $debug_cmd 217835c4bbdfSmrg 217935c4bbdfSmrg printf '%s\n' "$progname $scriptversion" 218035c4bbdfSmrg $SED -n ' 2181c82838c1Smrg /^# Written by /!b 2182c82838c1Smrg s|^# ||; p; n 2183c82838c1Smrg 2184c82838c1Smrg :fwd2blnk 2185c82838c1Smrg /./ { 2186c82838c1Smrg n 2187c82838c1Smrg b fwd2blnk 218835c4bbdfSmrg } 2189c82838c1Smrg p; n 2190c82838c1Smrg 2191c82838c1Smrg :holdwrnt 2192c82838c1Smrg s|^# || 2193c82838c1Smrg s|^# *$|| 2194c82838c1Smrg /^Copyright /!{ 2195c82838c1Smrg /./H 2196c82838c1Smrg n 2197c82838c1Smrg b holdwrnt 219835c4bbdfSmrg } 2199c82838c1Smrg 2200c82838c1Smrg s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2| 2201c82838c1Smrg G 2202c82838c1Smrg s|\(\n\)\n*|\1|g 2203c82838c1Smrg p; q' < "$progpath" 220435c4bbdfSmrg 220535c4bbdfSmrg exit $? 220635c4bbdfSmrg} 220735c4bbdfSmrg 220835c4bbdfSmrg 220935c4bbdfSmrg# Local variables: 221035c4bbdfSmrg# mode: shell-script 221135c4bbdfSmrg# sh-indentation: 2 221235c4bbdfSmrg# eval: (add-hook 'before-save-hook 'time-stamp) 2213c82838c1Smrg# time-stamp-pattern: "30/scriptversion=%:y-%02m-%02d.%02H; # UTC" 221435c4bbdfSmrg# time-stamp-time-zone: "UTC" 221535c4bbdfSmrg# End: 221635c4bbdfSmrg 221735c4bbdfSmrg# Set a version string. 2218c82838c1Smrgscriptversion='(GNU libtool) 2.4.7' 221935c4bbdfSmrg 222035c4bbdfSmrg 222135c4bbdfSmrg# func_echo ARG... 222235c4bbdfSmrg# ---------------- 222335c4bbdfSmrg# Libtool also displays the current mode in messages, so override 222435c4bbdfSmrg# funclib.sh func_echo with this custom definition. 222535c4bbdfSmrgfunc_echo () 222635c4bbdfSmrg{ 222735c4bbdfSmrg $debug_cmd 222835c4bbdfSmrg 222935c4bbdfSmrg _G_message=$* 223035c4bbdfSmrg 223135c4bbdfSmrg func_echo_IFS=$IFS 223235c4bbdfSmrg IFS=$nl 223335c4bbdfSmrg for _G_line in $_G_message; do 223435c4bbdfSmrg IFS=$func_echo_IFS 223535c4bbdfSmrg $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line" 223635c4bbdfSmrg done 223735c4bbdfSmrg IFS=$func_echo_IFS 223835c4bbdfSmrg} 223935c4bbdfSmrg 224035c4bbdfSmrg 224135c4bbdfSmrg# func_warning ARG... 224235c4bbdfSmrg# ------------------- 224335c4bbdfSmrg# Libtool warnings are not categorized, so override funclib.sh 224435c4bbdfSmrg# func_warning with this simpler definition. 224535c4bbdfSmrgfunc_warning () 224635c4bbdfSmrg{ 224735c4bbdfSmrg $debug_cmd 224835c4bbdfSmrg 224935c4bbdfSmrg $warning_func ${1+"$@"} 225035c4bbdfSmrg} 225135c4bbdfSmrg 225235c4bbdfSmrg 225335c4bbdfSmrg## ---------------- ## 225435c4bbdfSmrg## Options parsing. ## 225535c4bbdfSmrg## ---------------- ## 225635c4bbdfSmrg 225735c4bbdfSmrg# Hook in the functions to make sure our own options are parsed during 225835c4bbdfSmrg# the option parsing loop. 225935c4bbdfSmrg 226035c4bbdfSmrgusage='$progpath [OPTION]... [MODE-ARG]...' 226135c4bbdfSmrg 226235c4bbdfSmrg# Short help message in response to '-h'. 226335c4bbdfSmrgusage_message="Options: 226435c4bbdfSmrg --config show all configuration variables 226535c4bbdfSmrg --debug enable verbose shell tracing 226635c4bbdfSmrg -n, --dry-run display commands without modifying any files 226735c4bbdfSmrg --features display basic configuration information and exit 226835c4bbdfSmrg --mode=MODE use operation mode MODE 226935c4bbdfSmrg --no-warnings equivalent to '-Wnone' 227035c4bbdfSmrg --preserve-dup-deps don't remove duplicate dependency libraries 227135c4bbdfSmrg --quiet, --silent don't print informational messages 227235c4bbdfSmrg --tag=TAG use configuration variables from tag TAG 227335c4bbdfSmrg -v, --verbose print more informational messages than default 227435c4bbdfSmrg --version print version information 227535c4bbdfSmrg -W, --warnings=CATEGORY report the warnings falling in CATEGORY [all] 227635c4bbdfSmrg -h, --help, --help-all print short, long, or detailed help message 227735c4bbdfSmrg" 227835c4bbdfSmrg 227935c4bbdfSmrg# Additional text appended to 'usage_message' in response to '--help'. 228035c4bbdfSmrgfunc_help () 228135c4bbdfSmrg{ 228235c4bbdfSmrg $debug_cmd 228335c4bbdfSmrg 228435c4bbdfSmrg func_usage_message 228535c4bbdfSmrg $ECHO "$long_help_message 228635c4bbdfSmrg 228735c4bbdfSmrgMODE must be one of the following: 228835c4bbdfSmrg 228935c4bbdfSmrg clean remove files from the build directory 229035c4bbdfSmrg compile compile a source file into a libtool object 229135c4bbdfSmrg execute automatically set library path, then run a program 229235c4bbdfSmrg finish complete the installation of libtool libraries 229335c4bbdfSmrg install install libraries or executables 229435c4bbdfSmrg link create a library or an executable 229535c4bbdfSmrg uninstall remove libraries from an installed directory 229635c4bbdfSmrg 229735c4bbdfSmrgMODE-ARGS vary depending on the MODE. When passed as first option, 229835c4bbdfSmrg'--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that. 229935c4bbdfSmrgTry '$progname --help --mode=MODE' for a more detailed description of MODE. 230035c4bbdfSmrg 230135c4bbdfSmrgWhen reporting a bug, please describe a test case to reproduce it and 230235c4bbdfSmrginclude the following information: 230335c4bbdfSmrg 230435c4bbdfSmrg host-triplet: $host 230535c4bbdfSmrg shell: $SHELL 230635c4bbdfSmrg compiler: $LTCC 230735c4bbdfSmrg compiler flags: $LTCFLAGS 230835c4bbdfSmrg linker: $LD (gnu? $with_gnu_ld) 2309c82838c1Smrg version: $progname (GNU libtool) 2.4.7 231035c4bbdfSmrg automake: `($AUTOMAKE --version) 2>/dev/null |$SED 1q` 231135c4bbdfSmrg autoconf: `($AUTOCONF --version) 2>/dev/null |$SED 1q` 231235c4bbdfSmrg 231335c4bbdfSmrgReport bugs to <bug-libtool@gnu.org>. 2314c82838c1SmrgGNU libtool home page: <http://www.gnu.org/software/libtool/>. 231535c4bbdfSmrgGeneral help using GNU software: <http://www.gnu.org/gethelp/>." 231635c4bbdfSmrg exit 0 231735c4bbdfSmrg} 231835c4bbdfSmrg 231935c4bbdfSmrg 232035c4bbdfSmrg# func_lo2o OBJECT-NAME 232135c4bbdfSmrg# --------------------- 232235c4bbdfSmrg# Transform OBJECT-NAME from a '.lo' suffix to the platform specific 232335c4bbdfSmrg# object suffix. 232435c4bbdfSmrg 232535c4bbdfSmrglo2o=s/\\.lo\$/.$objext/ 232635c4bbdfSmrgo2lo=s/\\.$objext\$/.lo/ 232735c4bbdfSmrg 232835c4bbdfSmrgif test yes = "$_G_HAVE_XSI_OPS"; then 232935c4bbdfSmrg eval 'func_lo2o () 233035c4bbdfSmrg { 233135c4bbdfSmrg case $1 in 233235c4bbdfSmrg *.lo) func_lo2o_result=${1%.lo}.$objext ;; 233335c4bbdfSmrg * ) func_lo2o_result=$1 ;; 233435c4bbdfSmrg esac 233535c4bbdfSmrg }' 233635c4bbdfSmrg 233735c4bbdfSmrg # func_xform LIBOBJ-OR-SOURCE 233835c4bbdfSmrg # --------------------------- 233935c4bbdfSmrg # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise) 234035c4bbdfSmrg # suffix to a '.lo' libtool-object suffix. 234135c4bbdfSmrg eval 'func_xform () 234235c4bbdfSmrg { 234335c4bbdfSmrg func_xform_result=${1%.*}.lo 234435c4bbdfSmrg }' 234535c4bbdfSmrgelse 234635c4bbdfSmrg # ...otherwise fall back to using sed. 234735c4bbdfSmrg func_lo2o () 234835c4bbdfSmrg { 234935c4bbdfSmrg func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"` 235035c4bbdfSmrg } 235135c4bbdfSmrg 235235c4bbdfSmrg func_xform () 235335c4bbdfSmrg { 235435c4bbdfSmrg func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'` 235535c4bbdfSmrg } 235635c4bbdfSmrgfi 235735c4bbdfSmrg 235835c4bbdfSmrg 235935c4bbdfSmrg# func_fatal_configuration ARG... 236035c4bbdfSmrg# ------------------------------- 236135c4bbdfSmrg# Echo program name prefixed message to standard error, followed by 236235c4bbdfSmrg# a configuration failure hint, and exit. 236335c4bbdfSmrgfunc_fatal_configuration () 236435c4bbdfSmrg{ 2365c82838c1Smrg func_fatal_error ${1+"$@"} \ 236635c4bbdfSmrg "See the $PACKAGE documentation for more information." \ 236735c4bbdfSmrg "Fatal configuration error." 236835c4bbdfSmrg} 236935c4bbdfSmrg 237035c4bbdfSmrg 237135c4bbdfSmrg# func_config 237235c4bbdfSmrg# ----------- 237335c4bbdfSmrg# Display the configuration for all the tags in this script. 237435c4bbdfSmrgfunc_config () 237535c4bbdfSmrg{ 237635c4bbdfSmrg re_begincf='^# ### BEGIN LIBTOOL' 237735c4bbdfSmrg re_endcf='^# ### END LIBTOOL' 237835c4bbdfSmrg 237935c4bbdfSmrg # Default configuration. 238035c4bbdfSmrg $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" 238135c4bbdfSmrg 238235c4bbdfSmrg # Now print the configurations for the tags. 238335c4bbdfSmrg for tagname in $taglist; do 238435c4bbdfSmrg $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" 238535c4bbdfSmrg done 238635c4bbdfSmrg 238735c4bbdfSmrg exit $? 238835c4bbdfSmrg} 238935c4bbdfSmrg 239035c4bbdfSmrg 239135c4bbdfSmrg# func_features 239235c4bbdfSmrg# ------------- 239335c4bbdfSmrg# Display the features supported by this script. 239435c4bbdfSmrgfunc_features () 239535c4bbdfSmrg{ 239635c4bbdfSmrg echo "host: $host" 239735c4bbdfSmrg if test yes = "$build_libtool_libs"; then 239835c4bbdfSmrg echo "enable shared libraries" 239935c4bbdfSmrg else 240035c4bbdfSmrg echo "disable shared libraries" 240135c4bbdfSmrg fi 240235c4bbdfSmrg if test yes = "$build_old_libs"; then 240335c4bbdfSmrg echo "enable static libraries" 240435c4bbdfSmrg else 240535c4bbdfSmrg echo "disable static libraries" 240635c4bbdfSmrg fi 240735c4bbdfSmrg 240835c4bbdfSmrg exit $? 240935c4bbdfSmrg} 241035c4bbdfSmrg 241135c4bbdfSmrg 241235c4bbdfSmrg# func_enable_tag TAGNAME 241335c4bbdfSmrg# ----------------------- 241435c4bbdfSmrg# Verify that TAGNAME is valid, and either flag an error and exit, or 241535c4bbdfSmrg# enable the TAGNAME tag. We also add TAGNAME to the global $taglist 241635c4bbdfSmrg# variable here. 241735c4bbdfSmrgfunc_enable_tag () 241835c4bbdfSmrg{ 241935c4bbdfSmrg # Global variable: 242035c4bbdfSmrg tagname=$1 242135c4bbdfSmrg 242235c4bbdfSmrg re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" 242335c4bbdfSmrg re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" 242435c4bbdfSmrg sed_extractcf=/$re_begincf/,/$re_endcf/p 242535c4bbdfSmrg 242635c4bbdfSmrg # Validate tagname. 242735c4bbdfSmrg case $tagname in 242835c4bbdfSmrg *[!-_A-Za-z0-9,/]*) 242935c4bbdfSmrg func_fatal_error "invalid tag name: $tagname" 243035c4bbdfSmrg ;; 243135c4bbdfSmrg esac 243235c4bbdfSmrg 243335c4bbdfSmrg # Don't test for the "default" C tag, as we know it's 243435c4bbdfSmrg # there but not specially marked. 243535c4bbdfSmrg case $tagname in 243635c4bbdfSmrg CC) ;; 243735c4bbdfSmrg *) 243835c4bbdfSmrg if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then 243935c4bbdfSmrg taglist="$taglist $tagname" 244035c4bbdfSmrg 244135c4bbdfSmrg # Evaluate the configuration. Be careful to quote the path 244235c4bbdfSmrg # and the sed script, to avoid splitting on whitespace, but 244335c4bbdfSmrg # also don't use non-portable quotes within backquotes within 244435c4bbdfSmrg # quotes we have to do it in 2 steps: 244535c4bbdfSmrg extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` 244635c4bbdfSmrg eval "$extractedcf" 244735c4bbdfSmrg else 244835c4bbdfSmrg func_error "ignoring unknown tag $tagname" 244935c4bbdfSmrg fi 245035c4bbdfSmrg ;; 245135c4bbdfSmrg esac 245235c4bbdfSmrg} 245335c4bbdfSmrg 245435c4bbdfSmrg 245535c4bbdfSmrg# func_check_version_match 245635c4bbdfSmrg# ------------------------ 245735c4bbdfSmrg# Ensure that we are using m4 macros, and libtool script from the same 245835c4bbdfSmrg# release of libtool. 245935c4bbdfSmrgfunc_check_version_match () 246035c4bbdfSmrg{ 246135c4bbdfSmrg if test "$package_revision" != "$macro_revision"; then 246235c4bbdfSmrg if test "$VERSION" != "$macro_version"; then 246335c4bbdfSmrg if test -z "$macro_version"; then 246435c4bbdfSmrg cat >&2 <<_LT_EOF 246535c4bbdfSmrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 246635c4bbdfSmrg$progname: definition of this LT_INIT comes from an older release. 246735c4bbdfSmrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 246835c4bbdfSmrg$progname: and run autoconf again. 246935c4bbdfSmrg_LT_EOF 247035c4bbdfSmrg else 247135c4bbdfSmrg cat >&2 <<_LT_EOF 247235c4bbdfSmrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 247335c4bbdfSmrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version. 247435c4bbdfSmrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 247535c4bbdfSmrg$progname: and run autoconf again. 247635c4bbdfSmrg_LT_EOF 247735c4bbdfSmrg fi 247835c4bbdfSmrg else 247935c4bbdfSmrg cat >&2 <<_LT_EOF 248035c4bbdfSmrg$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, 248135c4bbdfSmrg$progname: but the definition of this LT_INIT comes from revision $macro_revision. 248235c4bbdfSmrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision 248335c4bbdfSmrg$progname: of $PACKAGE $VERSION and run autoconf again. 248435c4bbdfSmrg_LT_EOF 248535c4bbdfSmrg fi 248635c4bbdfSmrg 248735c4bbdfSmrg exit $EXIT_MISMATCH 248835c4bbdfSmrg fi 248935c4bbdfSmrg} 249035c4bbdfSmrg 249135c4bbdfSmrg 249235c4bbdfSmrg# libtool_options_prep [ARG]... 249335c4bbdfSmrg# ----------------------------- 249435c4bbdfSmrg# Preparation for options parsed by libtool. 249535c4bbdfSmrglibtool_options_prep () 249635c4bbdfSmrg{ 249735c4bbdfSmrg $debug_mode 249835c4bbdfSmrg 249935c4bbdfSmrg # Option defaults: 250035c4bbdfSmrg opt_config=false 250135c4bbdfSmrg opt_dlopen= 250235c4bbdfSmrg opt_dry_run=false 250335c4bbdfSmrg opt_help=false 250435c4bbdfSmrg opt_mode= 250535c4bbdfSmrg opt_preserve_dup_deps=false 250635c4bbdfSmrg opt_quiet=false 250735c4bbdfSmrg 250835c4bbdfSmrg nonopt= 250935c4bbdfSmrg preserve_args= 251035c4bbdfSmrg 2511ed6184dfSmrg _G_rc_lt_options_prep=: 2512ed6184dfSmrg 251335c4bbdfSmrg # Shorthand for --mode=foo, only valid as the first argument 251435c4bbdfSmrg case $1 in 251535c4bbdfSmrg clean|clea|cle|cl) 251635c4bbdfSmrg shift; set dummy --mode clean ${1+"$@"}; shift 251735c4bbdfSmrg ;; 251835c4bbdfSmrg compile|compil|compi|comp|com|co|c) 251935c4bbdfSmrg shift; set dummy --mode compile ${1+"$@"}; shift 252035c4bbdfSmrg ;; 252135c4bbdfSmrg execute|execut|execu|exec|exe|ex|e) 252235c4bbdfSmrg shift; set dummy --mode execute ${1+"$@"}; shift 252335c4bbdfSmrg ;; 252435c4bbdfSmrg finish|finis|fini|fin|fi|f) 252535c4bbdfSmrg shift; set dummy --mode finish ${1+"$@"}; shift 252635c4bbdfSmrg ;; 252735c4bbdfSmrg install|instal|insta|inst|ins|in|i) 252835c4bbdfSmrg shift; set dummy --mode install ${1+"$@"}; shift 252935c4bbdfSmrg ;; 253035c4bbdfSmrg link|lin|li|l) 253135c4bbdfSmrg shift; set dummy --mode link ${1+"$@"}; shift 253235c4bbdfSmrg ;; 253335c4bbdfSmrg uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) 253435c4bbdfSmrg shift; set dummy --mode uninstall ${1+"$@"}; shift 253535c4bbdfSmrg ;; 2536ed6184dfSmrg *) 2537ed6184dfSmrg _G_rc_lt_options_prep=false 2538ed6184dfSmrg ;; 253935c4bbdfSmrg esac 254035c4bbdfSmrg 2541ed6184dfSmrg if $_G_rc_lt_options_prep; then 2542ed6184dfSmrg # Pass back the list of options. 2543c82838c1Smrg func_quote eval ${1+"$@"} 2544c82838c1Smrg libtool_options_prep_result=$func_quote_result 2545ed6184dfSmrg fi 254635c4bbdfSmrg} 254735c4bbdfSmrgfunc_add_hook func_options_prep libtool_options_prep 254835c4bbdfSmrg 254935c4bbdfSmrg 255035c4bbdfSmrg# libtool_parse_options [ARG]... 255135c4bbdfSmrg# --------------------------------- 255235c4bbdfSmrg# Provide handling for libtool specific options. 255335c4bbdfSmrglibtool_parse_options () 255435c4bbdfSmrg{ 255535c4bbdfSmrg $debug_cmd 255635c4bbdfSmrg 2557ed6184dfSmrg _G_rc_lt_parse_options=false 2558ed6184dfSmrg 255935c4bbdfSmrg # Perform our own loop to consume as many options as possible in 256035c4bbdfSmrg # each iteration. 256135c4bbdfSmrg while test $# -gt 0; do 2562ed6184dfSmrg _G_match_lt_parse_options=: 256335c4bbdfSmrg _G_opt=$1 256435c4bbdfSmrg shift 256535c4bbdfSmrg case $_G_opt in 256635c4bbdfSmrg --dry-run|--dryrun|-n) 256735c4bbdfSmrg opt_dry_run=: 256835c4bbdfSmrg ;; 256935c4bbdfSmrg 257035c4bbdfSmrg --config) func_config ;; 257135c4bbdfSmrg 257235c4bbdfSmrg --dlopen|-dlopen) 257335c4bbdfSmrg opt_dlopen="${opt_dlopen+$opt_dlopen 257435c4bbdfSmrg}$1" 257535c4bbdfSmrg shift 257635c4bbdfSmrg ;; 257735c4bbdfSmrg 257835c4bbdfSmrg --preserve-dup-deps) 257935c4bbdfSmrg opt_preserve_dup_deps=: ;; 258035c4bbdfSmrg 258135c4bbdfSmrg --features) func_features ;; 258235c4bbdfSmrg 258335c4bbdfSmrg --finish) set dummy --mode finish ${1+"$@"}; shift ;; 258435c4bbdfSmrg 258535c4bbdfSmrg --help) opt_help=: ;; 258635c4bbdfSmrg 258735c4bbdfSmrg --help-all) opt_help=': help-all' ;; 258835c4bbdfSmrg 258935c4bbdfSmrg --mode) test $# = 0 && func_missing_arg $_G_opt && break 259035c4bbdfSmrg opt_mode=$1 259135c4bbdfSmrg case $1 in 259235c4bbdfSmrg # Valid mode arguments: 259335c4bbdfSmrg clean|compile|execute|finish|install|link|relink|uninstall) ;; 259435c4bbdfSmrg 259535c4bbdfSmrg # Catch anything else as an error 259635c4bbdfSmrg *) func_error "invalid argument for $_G_opt" 259735c4bbdfSmrg exit_cmd=exit 259835c4bbdfSmrg break 259935c4bbdfSmrg ;; 260035c4bbdfSmrg esac 260135c4bbdfSmrg shift 260235c4bbdfSmrg ;; 260335c4bbdfSmrg 260435c4bbdfSmrg --no-silent|--no-quiet) 260535c4bbdfSmrg opt_quiet=false 260635c4bbdfSmrg func_append preserve_args " $_G_opt" 260735c4bbdfSmrg ;; 260835c4bbdfSmrg 260935c4bbdfSmrg --no-warnings|--no-warning|--no-warn) 261035c4bbdfSmrg opt_warning=false 261135c4bbdfSmrg func_append preserve_args " $_G_opt" 261235c4bbdfSmrg ;; 261335c4bbdfSmrg 261435c4bbdfSmrg --no-verbose) 261535c4bbdfSmrg opt_verbose=false 261635c4bbdfSmrg func_append preserve_args " $_G_opt" 261735c4bbdfSmrg ;; 261835c4bbdfSmrg 261935c4bbdfSmrg --silent|--quiet) 262035c4bbdfSmrg opt_quiet=: 262135c4bbdfSmrg opt_verbose=false 262235c4bbdfSmrg func_append preserve_args " $_G_opt" 262335c4bbdfSmrg ;; 262435c4bbdfSmrg 262535c4bbdfSmrg --tag) test $# = 0 && func_missing_arg $_G_opt && break 262635c4bbdfSmrg opt_tag=$1 262735c4bbdfSmrg func_append preserve_args " $_G_opt $1" 262835c4bbdfSmrg func_enable_tag "$1" 262935c4bbdfSmrg shift 263035c4bbdfSmrg ;; 263135c4bbdfSmrg 263235c4bbdfSmrg --verbose|-v) opt_quiet=false 263335c4bbdfSmrg opt_verbose=: 263435c4bbdfSmrg func_append preserve_args " $_G_opt" 263535c4bbdfSmrg ;; 263635c4bbdfSmrg 2637ed6184dfSmrg # An option not handled by this hook function: 2638ed6184dfSmrg *) set dummy "$_G_opt" ${1+"$@"} ; shift 2639ed6184dfSmrg _G_match_lt_parse_options=false 2640ed6184dfSmrg break 2641ed6184dfSmrg ;; 264235c4bbdfSmrg esac 2643ed6184dfSmrg $_G_match_lt_parse_options && _G_rc_lt_parse_options=: 264435c4bbdfSmrg done 264535c4bbdfSmrg 2646ed6184dfSmrg if $_G_rc_lt_parse_options; then 2647ed6184dfSmrg # save modified positional parameters for caller 2648c82838c1Smrg func_quote eval ${1+"$@"} 2649c82838c1Smrg libtool_parse_options_result=$func_quote_result 2650ed6184dfSmrg fi 265135c4bbdfSmrg} 265235c4bbdfSmrgfunc_add_hook func_parse_options libtool_parse_options 265335c4bbdfSmrg 265435c4bbdfSmrg 265535c4bbdfSmrg 265635c4bbdfSmrg# libtool_validate_options [ARG]... 265735c4bbdfSmrg# --------------------------------- 265835c4bbdfSmrg# Perform any sanity checks on option settings and/or unconsumed 265935c4bbdfSmrg# arguments. 266035c4bbdfSmrglibtool_validate_options () 266135c4bbdfSmrg{ 266235c4bbdfSmrg # save first non-option argument 266335c4bbdfSmrg if test 0 -lt $#; then 266435c4bbdfSmrg nonopt=$1 266535c4bbdfSmrg shift 266635c4bbdfSmrg fi 266735c4bbdfSmrg 266835c4bbdfSmrg # preserve --debug 266935c4bbdfSmrg test : = "$debug_cmd" || func_append preserve_args " --debug" 267035c4bbdfSmrg 267158cf2af7Smrg # Keeping compiler generated duplicates in $postdeps and $predeps is not 267258cf2af7Smrg # harmful, and is necessary in a majority of systems that use it to satisfy 267358cf2af7Smrg # symbol dependencies. 267458cf2af7Smrg opt_duplicate_compiler_generated_deps=: 267535c4bbdfSmrg 267635c4bbdfSmrg $opt_help || { 267735c4bbdfSmrg # Sanity checks first: 267835c4bbdfSmrg func_check_version_match 267935c4bbdfSmrg 268035c4bbdfSmrg test yes != "$build_libtool_libs" \ 268135c4bbdfSmrg && test yes != "$build_old_libs" \ 268235c4bbdfSmrg && func_fatal_configuration "not configured to build any kind of library" 268335c4bbdfSmrg 268435c4bbdfSmrg # Darwin sucks 268535c4bbdfSmrg eval std_shrext=\"$shrext_cmds\" 268635c4bbdfSmrg 268735c4bbdfSmrg # Only execute mode is allowed to have -dlopen flags. 268835c4bbdfSmrg if test -n "$opt_dlopen" && test execute != "$opt_mode"; then 268935c4bbdfSmrg func_error "unrecognized option '-dlopen'" 269035c4bbdfSmrg $ECHO "$help" 1>&2 269135c4bbdfSmrg exit $EXIT_FAILURE 269235c4bbdfSmrg fi 269335c4bbdfSmrg 269435c4bbdfSmrg # Change the help message to a mode-specific one. 269535c4bbdfSmrg generic_help=$help 269635c4bbdfSmrg help="Try '$progname --help --mode=$opt_mode' for more information." 269735c4bbdfSmrg } 269835c4bbdfSmrg 269935c4bbdfSmrg # Pass back the unparsed argument list 2700c82838c1Smrg func_quote eval ${1+"$@"} 2701c82838c1Smrg libtool_validate_options_result=$func_quote_result 270235c4bbdfSmrg} 270335c4bbdfSmrgfunc_add_hook func_validate_options libtool_validate_options 270435c4bbdfSmrg 270535c4bbdfSmrg 270635c4bbdfSmrg# Process options as early as possible so that --help and --version 270735c4bbdfSmrg# can return quickly. 270835c4bbdfSmrgfunc_options ${1+"$@"} 270935c4bbdfSmrgeval set dummy "$func_options_result"; shift 271035c4bbdfSmrg 271135c4bbdfSmrg 271235c4bbdfSmrg 271335c4bbdfSmrg## ----------- ## 271435c4bbdfSmrg## Main. ## 271535c4bbdfSmrg## ----------- ## 271635c4bbdfSmrg 271735c4bbdfSmrgmagic='%%%MAGIC variable%%%' 271835c4bbdfSmrgmagic_exe='%%%MAGIC EXE variable%%%' 271905b261ecSmrg 27204642e01fSmrg# Global variables. 27214642e01fSmrgextracted_archives= 27224642e01fSmrgextracted_serial=0 272305b261ecSmrg 272435c4bbdfSmrg# If this variable is set in any of the actions, the command in it 272535c4bbdfSmrg# will be execed at the end. This prevents here-documents from being 272635c4bbdfSmrg# left over by shells. 272735c4bbdfSmrgexec_cmd= 272835c4bbdfSmrg 272935c4bbdfSmrg 273035c4bbdfSmrg# A function that is used when there is no print builtin or printf. 273135c4bbdfSmrgfunc_fallback_echo () 273235c4bbdfSmrg{ 273335c4bbdfSmrg eval 'cat <<_LTECHO_EOF 273435c4bbdfSmrg$1 273535c4bbdfSmrg_LTECHO_EOF' 273635c4bbdfSmrg} 273735c4bbdfSmrg 273835c4bbdfSmrg# func_generated_by_libtool 273935c4bbdfSmrg# True iff stdin has been generated by Libtool. This function is only 274035c4bbdfSmrg# a basic sanity check; it will hardly flush out determined imposters. 274135c4bbdfSmrgfunc_generated_by_libtool_p () 274235c4bbdfSmrg{ 274335c4bbdfSmrg $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 274435c4bbdfSmrg} 274535c4bbdfSmrg 274635c4bbdfSmrg# func_lalib_p file 274735c4bbdfSmrg# True iff FILE is a libtool '.la' library or '.lo' object file. 274835c4bbdfSmrg# This function is only a basic sanity check; it will hardly flush out 274935c4bbdfSmrg# determined imposters. 275035c4bbdfSmrgfunc_lalib_p () 275135c4bbdfSmrg{ 275235c4bbdfSmrg test -f "$1" && 275335c4bbdfSmrg $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p 275435c4bbdfSmrg} 275535c4bbdfSmrg 275635c4bbdfSmrg# func_lalib_unsafe_p file 275735c4bbdfSmrg# True iff FILE is a libtool '.la' library or '.lo' object file. 275835c4bbdfSmrg# This function implements the same check as func_lalib_p without 275935c4bbdfSmrg# resorting to external programs. To this end, it redirects stdin and 276035c4bbdfSmrg# closes it afterwards, without saving the original file descriptor. 276135c4bbdfSmrg# As a safety measure, use it only where a negative result would be 276235c4bbdfSmrg# fatal anyway. Works if 'file' does not exist. 276335c4bbdfSmrgfunc_lalib_unsafe_p () 276435c4bbdfSmrg{ 276535c4bbdfSmrg lalib_p=no 276635c4bbdfSmrg if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then 276735c4bbdfSmrg for lalib_p_l in 1 2 3 4 276835c4bbdfSmrg do 276935c4bbdfSmrg read lalib_p_line 277035c4bbdfSmrg case $lalib_p_line in 277135c4bbdfSmrg \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; 277235c4bbdfSmrg esac 277335c4bbdfSmrg done 277435c4bbdfSmrg exec 0<&5 5<&- 277535c4bbdfSmrg fi 277635c4bbdfSmrg test yes = "$lalib_p" 277735c4bbdfSmrg} 277835c4bbdfSmrg 277935c4bbdfSmrg# func_ltwrapper_script_p file 278035c4bbdfSmrg# True iff FILE is a libtool wrapper script 278135c4bbdfSmrg# This function is only a basic sanity check; it will hardly flush out 278235c4bbdfSmrg# determined imposters. 278335c4bbdfSmrgfunc_ltwrapper_script_p () 278435c4bbdfSmrg{ 278535c4bbdfSmrg test -f "$1" && 278635c4bbdfSmrg $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p 278735c4bbdfSmrg} 278835c4bbdfSmrg 278935c4bbdfSmrg# func_ltwrapper_executable_p file 279035c4bbdfSmrg# True iff FILE is a libtool wrapper executable 279135c4bbdfSmrg# This function is only a basic sanity check; it will hardly flush out 279235c4bbdfSmrg# determined imposters. 279335c4bbdfSmrgfunc_ltwrapper_executable_p () 279435c4bbdfSmrg{ 279535c4bbdfSmrg func_ltwrapper_exec_suffix= 279635c4bbdfSmrg case $1 in 279735c4bbdfSmrg *.exe) ;; 279835c4bbdfSmrg *) func_ltwrapper_exec_suffix=.exe ;; 279935c4bbdfSmrg esac 280035c4bbdfSmrg $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 280135c4bbdfSmrg} 280235c4bbdfSmrg 280335c4bbdfSmrg# func_ltwrapper_scriptname file 280435c4bbdfSmrg# Assumes file is an ltwrapper_executable 280535c4bbdfSmrg# uses $file to determine the appropriate filename for a 280635c4bbdfSmrg# temporary ltwrapper_script. 280735c4bbdfSmrgfunc_ltwrapper_scriptname () 280835c4bbdfSmrg{ 280935c4bbdfSmrg func_dirname_and_basename "$1" "" "." 281035c4bbdfSmrg func_stripname '' '.exe' "$func_basename_result" 281135c4bbdfSmrg func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper 281235c4bbdfSmrg} 281335c4bbdfSmrg 281435c4bbdfSmrg# func_ltwrapper_p file 281535c4bbdfSmrg# True iff FILE is a libtool wrapper script or wrapper executable 281635c4bbdfSmrg# This function is only a basic sanity check; it will hardly flush out 281735c4bbdfSmrg# determined imposters. 281835c4bbdfSmrgfunc_ltwrapper_p () 281935c4bbdfSmrg{ 282035c4bbdfSmrg func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" 282135c4bbdfSmrg} 282235c4bbdfSmrg 282335c4bbdfSmrg 282435c4bbdfSmrg# func_execute_cmds commands fail_cmd 282535c4bbdfSmrg# Execute tilde-delimited COMMANDS. 282635c4bbdfSmrg# If FAIL_CMD is given, eval that upon failure. 282735c4bbdfSmrg# FAIL_CMD may read-access the current command in variable CMD! 282835c4bbdfSmrgfunc_execute_cmds () 282935c4bbdfSmrg{ 283035c4bbdfSmrg $debug_cmd 283135c4bbdfSmrg 283235c4bbdfSmrg save_ifs=$IFS; IFS='~' 283335c4bbdfSmrg for cmd in $1; do 283435c4bbdfSmrg IFS=$sp$nl 283535c4bbdfSmrg eval cmd=\"$cmd\" 283635c4bbdfSmrg IFS=$save_ifs 283735c4bbdfSmrg func_show_eval "$cmd" "${2-:}" 283835c4bbdfSmrg done 283935c4bbdfSmrg IFS=$save_ifs 284035c4bbdfSmrg} 284135c4bbdfSmrg 284235c4bbdfSmrg 284335c4bbdfSmrg# func_source file 284435c4bbdfSmrg# Source FILE, adding directory component if necessary. 284535c4bbdfSmrg# Note that it is not necessary on cygwin/mingw to append a dot to 284635c4bbdfSmrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe 284735c4bbdfSmrg# behavior happens only for exec(3), not for open(2)! Also, sourcing 284835c4bbdfSmrg# 'FILE.' does not work on cygwin managed mounts. 284935c4bbdfSmrgfunc_source () 285035c4bbdfSmrg{ 285135c4bbdfSmrg $debug_cmd 285235c4bbdfSmrg 285335c4bbdfSmrg case $1 in 285435c4bbdfSmrg */* | *\\*) . "$1" ;; 285535c4bbdfSmrg *) . "./$1" ;; 285635c4bbdfSmrg esac 285735c4bbdfSmrg} 285835c4bbdfSmrg 285935c4bbdfSmrg 286035c4bbdfSmrg# func_resolve_sysroot PATH 286135c4bbdfSmrg# Replace a leading = in PATH with a sysroot. Store the result into 286235c4bbdfSmrg# func_resolve_sysroot_result 286335c4bbdfSmrgfunc_resolve_sysroot () 286435c4bbdfSmrg{ 286535c4bbdfSmrg func_resolve_sysroot_result=$1 286635c4bbdfSmrg case $func_resolve_sysroot_result in 286735c4bbdfSmrg =*) 286835c4bbdfSmrg func_stripname '=' '' "$func_resolve_sysroot_result" 286935c4bbdfSmrg func_resolve_sysroot_result=$lt_sysroot$func_stripname_result 287035c4bbdfSmrg ;; 287135c4bbdfSmrg esac 287235c4bbdfSmrg} 287335c4bbdfSmrg 287435c4bbdfSmrg# func_replace_sysroot PATH 287535c4bbdfSmrg# If PATH begins with the sysroot, replace it with = and 287635c4bbdfSmrg# store the result into func_replace_sysroot_result. 287735c4bbdfSmrgfunc_replace_sysroot () 287835c4bbdfSmrg{ 287935c4bbdfSmrg case $lt_sysroot:$1 in 288035c4bbdfSmrg ?*:"$lt_sysroot"*) 288135c4bbdfSmrg func_stripname "$lt_sysroot" '' "$1" 288235c4bbdfSmrg func_replace_sysroot_result='='$func_stripname_result 288335c4bbdfSmrg ;; 288435c4bbdfSmrg *) 288535c4bbdfSmrg # Including no sysroot. 288635c4bbdfSmrg func_replace_sysroot_result=$1 288735c4bbdfSmrg ;; 288835c4bbdfSmrg esac 288935c4bbdfSmrg} 289035c4bbdfSmrg 289135c4bbdfSmrg# func_infer_tag arg 289235c4bbdfSmrg# Infer tagged configuration to use if any are available and 289335c4bbdfSmrg# if one wasn't chosen via the "--tag" command line option. 289435c4bbdfSmrg# Only attempt this if the compiler in the base compile 289535c4bbdfSmrg# command doesn't match the default compiler. 289635c4bbdfSmrg# arg is usually of the form 'gcc ...' 289735c4bbdfSmrgfunc_infer_tag () 289835c4bbdfSmrg{ 289935c4bbdfSmrg $debug_cmd 290035c4bbdfSmrg 290135c4bbdfSmrg if test -n "$available_tags" && test -z "$tagname"; then 290235c4bbdfSmrg CC_quoted= 290335c4bbdfSmrg for arg in $CC; do 290435c4bbdfSmrg func_append_quoted CC_quoted "$arg" 290535c4bbdfSmrg done 290635c4bbdfSmrg CC_expanded=`func_echo_all $CC` 290735c4bbdfSmrg CC_quoted_expanded=`func_echo_all $CC_quoted` 290835c4bbdfSmrg case $@ in 290935c4bbdfSmrg # Blanks in the command may have been stripped by the calling shell, 291035c4bbdfSmrg # but not from the CC environment variable when configure was run. 291135c4bbdfSmrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 291235c4bbdfSmrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; 291335c4bbdfSmrg # Blanks at the start of $base_compile will cause this to fail 291435c4bbdfSmrg # if we don't check for them as well. 291535c4bbdfSmrg *) 291635c4bbdfSmrg for z in $available_tags; do 291735c4bbdfSmrg if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then 291835c4bbdfSmrg # Evaluate the configuration. 291935c4bbdfSmrg eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" 292035c4bbdfSmrg CC_quoted= 292135c4bbdfSmrg for arg in $CC; do 292235c4bbdfSmrg # Double-quote args containing other shell metacharacters. 292335c4bbdfSmrg func_append_quoted CC_quoted "$arg" 292435c4bbdfSmrg done 292535c4bbdfSmrg CC_expanded=`func_echo_all $CC` 292635c4bbdfSmrg CC_quoted_expanded=`func_echo_all $CC_quoted` 292735c4bbdfSmrg case "$@ " in 292835c4bbdfSmrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 292935c4bbdfSmrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) 293035c4bbdfSmrg # The compiler in the base compile command matches 293135c4bbdfSmrg # the one in the tagged configuration. 293235c4bbdfSmrg # Assume this is the tagged configuration we want. 293335c4bbdfSmrg tagname=$z 293435c4bbdfSmrg break 293535c4bbdfSmrg ;; 293635c4bbdfSmrg esac 293735c4bbdfSmrg fi 293835c4bbdfSmrg done 293935c4bbdfSmrg # If $tagname still isn't set, then no tagged configuration 294035c4bbdfSmrg # was found and let the user know that the "--tag" command 294135c4bbdfSmrg # line option must be used. 294235c4bbdfSmrg if test -z "$tagname"; then 294335c4bbdfSmrg func_echo "unable to infer tagged configuration" 294435c4bbdfSmrg func_fatal_error "specify a tag with '--tag'" 294535c4bbdfSmrg# else 294635c4bbdfSmrg# func_verbose "using $tagname tagged configuration" 294735c4bbdfSmrg fi 294835c4bbdfSmrg ;; 294935c4bbdfSmrg esac 295035c4bbdfSmrg fi 295135c4bbdfSmrg} 295235c4bbdfSmrg 2953475c125cSmrg 29544642e01fSmrg 295535c4bbdfSmrg# func_write_libtool_object output_name pic_name nonpic_name 295635c4bbdfSmrg# Create a libtool object file (analogous to a ".la" file), 295735c4bbdfSmrg# but don't create it if we're doing a dry run. 295835c4bbdfSmrgfunc_write_libtool_object () 29594642e01fSmrg{ 296035c4bbdfSmrg write_libobj=$1 296135c4bbdfSmrg if test yes = "$build_libtool_libs"; then 296235c4bbdfSmrg write_lobj=\'$2\' 296335c4bbdfSmrg else 296435c4bbdfSmrg write_lobj=none 296535c4bbdfSmrg fi 296605b261ecSmrg 296735c4bbdfSmrg if test yes = "$build_old_libs"; then 296835c4bbdfSmrg write_oldobj=\'$3\' 296935c4bbdfSmrg else 297035c4bbdfSmrg write_oldobj=none 297135c4bbdfSmrg fi 297205b261ecSmrg 297335c4bbdfSmrg $opt_dry_run || { 297435c4bbdfSmrg cat >${write_libobj}T <<EOF 297535c4bbdfSmrg# $write_libobj - a libtool object file 297635c4bbdfSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 297735c4bbdfSmrg# 297835c4bbdfSmrg# Please DO NOT delete this file! 297935c4bbdfSmrg# It is necessary for linking the library. 29804642e01fSmrg 298135c4bbdfSmrg# Name of the PIC object. 298235c4bbdfSmrgpic_object=$write_lobj 298305b261ecSmrg 298435c4bbdfSmrg# Name of the non-PIC object 298535c4bbdfSmrgnon_pic_object=$write_oldobj 298605b261ecSmrg 298735c4bbdfSmrgEOF 298835c4bbdfSmrg $MV "${write_libobj}T" "$write_libobj" 298935c4bbdfSmrg } 29904642e01fSmrg} 299105b261ecSmrg 299235c4bbdfSmrg 299335c4bbdfSmrg################################################## 299435c4bbdfSmrg# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS # 299535c4bbdfSmrg################################################## 299635c4bbdfSmrg 299735c4bbdfSmrg# func_convert_core_file_wine_to_w32 ARG 299835c4bbdfSmrg# Helper function used by file name conversion functions when $build is *nix, 299935c4bbdfSmrg# and $host is mingw, cygwin, or some other w32 environment. Relies on a 300035c4bbdfSmrg# correctly configured wine environment available, with the winepath program 300135c4bbdfSmrg# in $build's $PATH. 300235c4bbdfSmrg# 300335c4bbdfSmrg# ARG is the $build file name to be converted to w32 format. 300435c4bbdfSmrg# Result is available in $func_convert_core_file_wine_to_w32_result, and will 300535c4bbdfSmrg# be empty on error (or when ARG is empty) 300635c4bbdfSmrgfunc_convert_core_file_wine_to_w32 () 30074642e01fSmrg{ 300835c4bbdfSmrg $debug_cmd 300935c4bbdfSmrg 301035c4bbdfSmrg func_convert_core_file_wine_to_w32_result=$1 301135c4bbdfSmrg if test -n "$1"; then 301235c4bbdfSmrg # Unfortunately, winepath does not exit with a non-zero error code, so we 301335c4bbdfSmrg # are forced to check the contents of stdout. On the other hand, if the 301435c4bbdfSmrg # command is not found, the shell will set an exit code of 127 and print 301535c4bbdfSmrg # *an error message* to stdout. So we must check for both error code of 301635c4bbdfSmrg # zero AND non-empty stdout, which explains the odd construction: 301735c4bbdfSmrg func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null` 301835c4bbdfSmrg if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then 301935c4bbdfSmrg func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | 302035c4bbdfSmrg $SED -e "$sed_naive_backslashify"` 302105b261ecSmrg else 302235c4bbdfSmrg func_convert_core_file_wine_to_w32_result= 302305b261ecSmrg fi 302435c4bbdfSmrg fi 302535c4bbdfSmrg} 302635c4bbdfSmrg# end: func_convert_core_file_wine_to_w32 30274642e01fSmrg 302835c4bbdfSmrg 302935c4bbdfSmrg# func_convert_core_path_wine_to_w32 ARG 303035c4bbdfSmrg# Helper function used by path conversion functions when $build is *nix, and 303135c4bbdfSmrg# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly 303235c4bbdfSmrg# configured wine environment available, with the winepath program in $build's 303335c4bbdfSmrg# $PATH. Assumes ARG has no leading or trailing path separator characters. 303435c4bbdfSmrg# 303535c4bbdfSmrg# ARG is path to be converted from $build format to win32. 303635c4bbdfSmrg# Result is available in $func_convert_core_path_wine_to_w32_result. 303735c4bbdfSmrg# Unconvertible file (directory) names in ARG are skipped; if no directory names 303835c4bbdfSmrg# are convertible, then the result may be empty. 303935c4bbdfSmrgfunc_convert_core_path_wine_to_w32 () 304035c4bbdfSmrg{ 304135c4bbdfSmrg $debug_cmd 304235c4bbdfSmrg 304335c4bbdfSmrg # unfortunately, winepath doesn't convert paths, only file names 304435c4bbdfSmrg func_convert_core_path_wine_to_w32_result= 304535c4bbdfSmrg if test -n "$1"; then 304635c4bbdfSmrg oldIFS=$IFS 304735c4bbdfSmrg IFS=: 304835c4bbdfSmrg for func_convert_core_path_wine_to_w32_f in $1; do 304935c4bbdfSmrg IFS=$oldIFS 305035c4bbdfSmrg func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" 305135c4bbdfSmrg if test -n "$func_convert_core_file_wine_to_w32_result"; then 305235c4bbdfSmrg if test -z "$func_convert_core_path_wine_to_w32_result"; then 305335c4bbdfSmrg func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result 305435c4bbdfSmrg else 305535c4bbdfSmrg func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" 305635c4bbdfSmrg fi 305735c4bbdfSmrg fi 305835c4bbdfSmrg done 305935c4bbdfSmrg IFS=$oldIFS 306035c4bbdfSmrg fi 30614642e01fSmrg} 306235c4bbdfSmrg# end: func_convert_core_path_wine_to_w32 306335c4bbdfSmrg 306435c4bbdfSmrg 306535c4bbdfSmrg# func_cygpath ARGS... 306635c4bbdfSmrg# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when 306735c4bbdfSmrg# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) 306835c4bbdfSmrg# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or 306935c4bbdfSmrg# (2), returns the Cygwin file name or path in func_cygpath_result (input 307035c4bbdfSmrg# file name or path is assumed to be in w32 format, as previously converted 307135c4bbdfSmrg# from $build's *nix or MSYS format). In case (3), returns the w32 file name 307235c4bbdfSmrg# or path in func_cygpath_result (input file name or path is assumed to be in 307335c4bbdfSmrg# Cygwin format). Returns an empty string on error. 307435c4bbdfSmrg# 307535c4bbdfSmrg# ARGS are passed to cygpath, with the last one being the file name or path to 307635c4bbdfSmrg# be converted. 307735c4bbdfSmrg# 307835c4bbdfSmrg# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH 307935c4bbdfSmrg# environment variable; do not put it in $PATH. 308035c4bbdfSmrgfunc_cygpath () 308135c4bbdfSmrg{ 308235c4bbdfSmrg $debug_cmd 308305b261ecSmrg 308435c4bbdfSmrg if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then 308535c4bbdfSmrg func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` 308635c4bbdfSmrg if test "$?" -ne 0; then 308735c4bbdfSmrg # on failure, ensure result is empty 308835c4bbdfSmrg func_cygpath_result= 308935c4bbdfSmrg fi 309035c4bbdfSmrg else 309135c4bbdfSmrg func_cygpath_result= 309235c4bbdfSmrg func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'" 309335c4bbdfSmrg fi 309435c4bbdfSmrg} 309535c4bbdfSmrg#end: func_cygpath 309635c4bbdfSmrg 309735c4bbdfSmrg 309835c4bbdfSmrg# func_convert_core_msys_to_w32 ARG 309935c4bbdfSmrg# Convert file name or path ARG from MSYS format to w32 format. Return 310035c4bbdfSmrg# result in func_convert_core_msys_to_w32_result. 310135c4bbdfSmrgfunc_convert_core_msys_to_w32 () 31024642e01fSmrg{ 310335c4bbdfSmrg $debug_cmd 310405b261ecSmrg 310535c4bbdfSmrg # awkward: cmd appends spaces to result 310635c4bbdfSmrg func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | 310735c4bbdfSmrg $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"` 310835c4bbdfSmrg} 310935c4bbdfSmrg#end: func_convert_core_msys_to_w32 311005b261ecSmrg 311105b261ecSmrg 311235c4bbdfSmrg# func_convert_file_check ARG1 ARG2 311335c4bbdfSmrg# Verify that ARG1 (a file name in $build format) was converted to $host 311435c4bbdfSmrg# format in ARG2. Otherwise, emit an error message, but continue (resetting 311535c4bbdfSmrg# func_to_host_file_result to ARG1). 311635c4bbdfSmrgfunc_convert_file_check () 311735c4bbdfSmrg{ 311835c4bbdfSmrg $debug_cmd 311935c4bbdfSmrg 312035c4bbdfSmrg if test -z "$2" && test -n "$1"; then 312135c4bbdfSmrg func_error "Could not determine host file name corresponding to" 312235c4bbdfSmrg func_error " '$1'" 312335c4bbdfSmrg func_error "Continuing, but uninstalled executables may not work." 312435c4bbdfSmrg # Fallback: 312535c4bbdfSmrg func_to_host_file_result=$1 312635c4bbdfSmrg fi 31274642e01fSmrg} 312835c4bbdfSmrg# end func_convert_file_check 31294642e01fSmrg 313035c4bbdfSmrg 313135c4bbdfSmrg# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH 313235c4bbdfSmrg# Verify that FROM_PATH (a path in $build format) was converted to $host 313335c4bbdfSmrg# format in TO_PATH. Otherwise, emit an error message, but continue, resetting 313435c4bbdfSmrg# func_to_host_file_result to a simplistic fallback value (see below). 313535c4bbdfSmrgfunc_convert_path_check () 31364642e01fSmrg{ 313735c4bbdfSmrg $debug_cmd 313835c4bbdfSmrg 313935c4bbdfSmrg if test -z "$4" && test -n "$3"; then 314035c4bbdfSmrg func_error "Could not determine the host path corresponding to" 314135c4bbdfSmrg func_error " '$3'" 314235c4bbdfSmrg func_error "Continuing, but uninstalled executables may not work." 314335c4bbdfSmrg # Fallback. This is a deliberately simplistic "conversion" and 314435c4bbdfSmrg # should not be "improved". See libtool.info. 314535c4bbdfSmrg if test "x$1" != "x$2"; then 314635c4bbdfSmrg lt_replace_pathsep_chars="s|$1|$2|g" 314735c4bbdfSmrg func_to_host_path_result=`echo "$3" | 314835c4bbdfSmrg $SED -e "$lt_replace_pathsep_chars"` 314935c4bbdfSmrg else 315035c4bbdfSmrg func_to_host_path_result=$3 315135c4bbdfSmrg fi 315235c4bbdfSmrg fi 315335c4bbdfSmrg} 315435c4bbdfSmrg# end func_convert_path_check 31556747b715Smrg 315635c4bbdfSmrg 315735c4bbdfSmrg# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG 315835c4bbdfSmrg# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT 315935c4bbdfSmrg# and appending REPL if ORIG matches BACKPAT. 316035c4bbdfSmrgfunc_convert_path_front_back_pathsep () 316135c4bbdfSmrg{ 316235c4bbdfSmrg $debug_cmd 316335c4bbdfSmrg 316435c4bbdfSmrg case $4 in 316535c4bbdfSmrg $1 ) func_to_host_path_result=$3$func_to_host_path_result 3166475c125cSmrg ;; 316735c4bbdfSmrg esac 316835c4bbdfSmrg case $4 in 316935c4bbdfSmrg $2 ) func_append func_to_host_path_result "$3" 3170475c125cSmrg ;; 3171475c125cSmrg esac 317235c4bbdfSmrg} 317335c4bbdfSmrg# end func_convert_path_front_back_pathsep 31746747b715Smrg 3175475c125cSmrg 317635c4bbdfSmrg################################################## 317735c4bbdfSmrg# $build to $host FILE NAME CONVERSION FUNCTIONS # 317835c4bbdfSmrg################################################## 317935c4bbdfSmrg# invoked via '$to_host_file_cmd ARG' 318035c4bbdfSmrg# 318135c4bbdfSmrg# In each case, ARG is the path to be converted from $build to $host format. 318235c4bbdfSmrg# Result will be available in $func_to_host_file_result. 31834642e01fSmrg 31844642e01fSmrg 318535c4bbdfSmrg# func_to_host_file ARG 318635c4bbdfSmrg# Converts the file name ARG from $build format to $host format. Return result 318735c4bbdfSmrg# in func_to_host_file_result. 318835c4bbdfSmrgfunc_to_host_file () 318935c4bbdfSmrg{ 319035c4bbdfSmrg $debug_cmd 319135c4bbdfSmrg 319235c4bbdfSmrg $to_host_file_cmd "$1" 319335c4bbdfSmrg} 319435c4bbdfSmrg# end func_to_host_file 319535c4bbdfSmrg 319635c4bbdfSmrg 319735c4bbdfSmrg# func_to_tool_file ARG LAZY 319835c4bbdfSmrg# converts the file name ARG from $build format to toolchain format. Return 319935c4bbdfSmrg# result in func_to_tool_file_result. If the conversion in use is listed 320035c4bbdfSmrg# in (the comma separated) LAZY, no conversion takes place. 320135c4bbdfSmrgfunc_to_tool_file () 320235c4bbdfSmrg{ 320335c4bbdfSmrg $debug_cmd 320435c4bbdfSmrg 320535c4bbdfSmrg case ,$2, in 320635c4bbdfSmrg *,"$to_tool_file_cmd",*) 320735c4bbdfSmrg func_to_tool_file_result=$1 320805b261ecSmrg ;; 320905b261ecSmrg *) 321035c4bbdfSmrg $to_tool_file_cmd "$1" 321135c4bbdfSmrg func_to_tool_file_result=$func_to_host_file_result 32124642e01fSmrg ;; 32134642e01fSmrg esac 321435c4bbdfSmrg} 321535c4bbdfSmrg# end func_to_tool_file 321605b261ecSmrg 321735c4bbdfSmrg 321835c4bbdfSmrg# func_convert_file_noop ARG 321935c4bbdfSmrg# Copy ARG to func_to_host_file_result. 322035c4bbdfSmrgfunc_convert_file_noop () 322135c4bbdfSmrg{ 322235c4bbdfSmrg func_to_host_file_result=$1 3223475c125cSmrg} 322435c4bbdfSmrg# end func_convert_file_noop 32254642e01fSmrg 322635c4bbdfSmrg 322735c4bbdfSmrg# func_convert_file_msys_to_w32 ARG 322835c4bbdfSmrg# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic 322935c4bbdfSmrg# conversion to w32 is not available inside the cwrapper. Returns result in 323035c4bbdfSmrg# func_to_host_file_result. 323135c4bbdfSmrgfunc_convert_file_msys_to_w32 () 3232475c125cSmrg{ 323335c4bbdfSmrg $debug_cmd 32344642e01fSmrg 323535c4bbdfSmrg func_to_host_file_result=$1 323635c4bbdfSmrg if test -n "$1"; then 323735c4bbdfSmrg func_convert_core_msys_to_w32 "$1" 323835c4bbdfSmrg func_to_host_file_result=$func_convert_core_msys_to_w32_result 3239475c125cSmrg fi 324035c4bbdfSmrg func_convert_file_check "$1" "$func_to_host_file_result" 3241475c125cSmrg} 324235c4bbdfSmrg# end func_convert_file_msys_to_w32 32434642e01fSmrg 324405b261ecSmrg 324535c4bbdfSmrg# func_convert_file_cygwin_to_w32 ARG 324635c4bbdfSmrg# Convert file name ARG from Cygwin to w32 format. Returns result in 324735c4bbdfSmrg# func_to_host_file_result. 324835c4bbdfSmrgfunc_convert_file_cygwin_to_w32 () 324935c4bbdfSmrg{ 325035c4bbdfSmrg $debug_cmd 32514642e01fSmrg 325235c4bbdfSmrg func_to_host_file_result=$1 325335c4bbdfSmrg if test -n "$1"; then 325435c4bbdfSmrg # because $build is cygwin, we call "the" cygpath in $PATH; no need to use 325535c4bbdfSmrg # LT_CYGPATH in this case. 325635c4bbdfSmrg func_to_host_file_result=`cygpath -m "$1"` 3257475c125cSmrg fi 325835c4bbdfSmrg func_convert_file_check "$1" "$func_to_host_file_result" 325935c4bbdfSmrg} 326035c4bbdfSmrg# end func_convert_file_cygwin_to_w32 32614642e01fSmrg 3262475c125cSmrg 326335c4bbdfSmrg# func_convert_file_nix_to_w32 ARG 326435c4bbdfSmrg# Convert file name ARG from *nix to w32 format. Requires a wine environment 326535c4bbdfSmrg# and a working winepath. Returns result in func_to_host_file_result. 326635c4bbdfSmrgfunc_convert_file_nix_to_w32 () 326735c4bbdfSmrg{ 326835c4bbdfSmrg $debug_cmd 3269475c125cSmrg 327035c4bbdfSmrg func_to_host_file_result=$1 327135c4bbdfSmrg if test -n "$1"; then 327235c4bbdfSmrg func_convert_core_file_wine_to_w32 "$1" 327335c4bbdfSmrg func_to_host_file_result=$func_convert_core_file_wine_to_w32_result 3274475c125cSmrg fi 327535c4bbdfSmrg func_convert_file_check "$1" "$func_to_host_file_result" 3276475c125cSmrg} 327735c4bbdfSmrg# end func_convert_file_nix_to_w32 327805b261ecSmrg 327905b261ecSmrg 328035c4bbdfSmrg# func_convert_file_msys_to_cygwin ARG 328135c4bbdfSmrg# Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 328235c4bbdfSmrg# Returns result in func_to_host_file_result. 328335c4bbdfSmrgfunc_convert_file_msys_to_cygwin () 32844642e01fSmrg{ 328535c4bbdfSmrg $debug_cmd 328605b261ecSmrg 328735c4bbdfSmrg func_to_host_file_result=$1 328835c4bbdfSmrg if test -n "$1"; then 328935c4bbdfSmrg func_convert_core_msys_to_w32 "$1" 329035c4bbdfSmrg func_cygpath -u "$func_convert_core_msys_to_w32_result" 329135c4bbdfSmrg func_to_host_file_result=$func_cygpath_result 329235c4bbdfSmrg fi 329335c4bbdfSmrg func_convert_file_check "$1" "$func_to_host_file_result" 32944642e01fSmrg} 329535c4bbdfSmrg# end func_convert_file_msys_to_cygwin 329605b261ecSmrg 329705b261ecSmrg 329835c4bbdfSmrg# func_convert_file_nix_to_cygwin ARG 329935c4bbdfSmrg# Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed 330035c4bbdfSmrg# in a wine environment, working winepath, and LT_CYGPATH set. Returns result 330135c4bbdfSmrg# in func_to_host_file_result. 330235c4bbdfSmrgfunc_convert_file_nix_to_cygwin () 33034642e01fSmrg{ 330435c4bbdfSmrg $debug_cmd 330535c4bbdfSmrg 330635c4bbdfSmrg func_to_host_file_result=$1 330735c4bbdfSmrg if test -n "$1"; then 330835c4bbdfSmrg # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. 330935c4bbdfSmrg func_convert_core_file_wine_to_w32 "$1" 331035c4bbdfSmrg func_cygpath -u "$func_convert_core_file_wine_to_w32_result" 331135c4bbdfSmrg func_to_host_file_result=$func_cygpath_result 331235c4bbdfSmrg fi 331335c4bbdfSmrg func_convert_file_check "$1" "$func_to_host_file_result" 33144642e01fSmrg} 331535c4bbdfSmrg# end func_convert_file_nix_to_cygwin 331605b261ecSmrg 331735c4bbdfSmrg 331835c4bbdfSmrg############################################# 331935c4bbdfSmrg# $build to $host PATH CONVERSION FUNCTIONS # 332035c4bbdfSmrg############################################# 332135c4bbdfSmrg# invoked via '$to_host_path_cmd ARG' 332235c4bbdfSmrg# 332335c4bbdfSmrg# In each case, ARG is the path to be converted from $build to $host format. 332435c4bbdfSmrg# The result will be available in $func_to_host_path_result. 332535c4bbdfSmrg# 332635c4bbdfSmrg# Path separators are also converted from $build format to $host format. If 332735c4bbdfSmrg# ARG begins or ends with a path separator character, it is preserved (but 332835c4bbdfSmrg# converted to $host format) on output. 332935c4bbdfSmrg# 333035c4bbdfSmrg# All path conversion functions are named using the following convention: 333135c4bbdfSmrg# file name conversion function : func_convert_file_X_to_Y () 333235c4bbdfSmrg# path conversion function : func_convert_path_X_to_Y () 333335c4bbdfSmrg# where, for any given $build/$host combination the 'X_to_Y' value is the 333435c4bbdfSmrg# same. If conversion functions are added for new $build/$host combinations, 333535c4bbdfSmrg# the two new functions must follow this pattern, or func_init_to_host_path_cmd 333635c4bbdfSmrg# will break. 333735c4bbdfSmrg 333835c4bbdfSmrg 333935c4bbdfSmrg# func_init_to_host_path_cmd 334035c4bbdfSmrg# Ensures that function "pointer" variable $to_host_path_cmd is set to the 334135c4bbdfSmrg# appropriate value, based on the value of $to_host_file_cmd. 334235c4bbdfSmrgto_host_path_cmd= 334335c4bbdfSmrgfunc_init_to_host_path_cmd () 33444642e01fSmrg{ 334535c4bbdfSmrg $debug_cmd 334635c4bbdfSmrg 334735c4bbdfSmrg if test -z "$to_host_path_cmd"; then 334835c4bbdfSmrg func_stripname 'func_convert_file_' '' "$to_host_file_cmd" 334935c4bbdfSmrg to_host_path_cmd=func_convert_path_$func_stripname_result 335035c4bbdfSmrg fi 33514642e01fSmrg} 33524642e01fSmrg 335335c4bbdfSmrg 335435c4bbdfSmrg# func_to_host_path ARG 335535c4bbdfSmrg# Converts the path ARG from $build format to $host format. Return result 335635c4bbdfSmrg# in func_to_host_path_result. 335735c4bbdfSmrgfunc_to_host_path () 33584642e01fSmrg{ 335935c4bbdfSmrg $debug_cmd 336035c4bbdfSmrg 336135c4bbdfSmrg func_init_to_host_path_cmd 336235c4bbdfSmrg $to_host_path_cmd "$1" 33634642e01fSmrg} 336435c4bbdfSmrg# end func_to_host_path 33654642e01fSmrg 33664642e01fSmrg 336735c4bbdfSmrg# func_convert_path_noop ARG 336835c4bbdfSmrg# Copy ARG to func_to_host_path_result. 336935c4bbdfSmrgfunc_convert_path_noop () 33704642e01fSmrg{ 337135c4bbdfSmrg func_to_host_path_result=$1 33724642e01fSmrg} 337335c4bbdfSmrg# end func_convert_path_noop 33744642e01fSmrg 33754642e01fSmrg 337635c4bbdfSmrg# func_convert_path_msys_to_w32 ARG 337735c4bbdfSmrg# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic 337835c4bbdfSmrg# conversion to w32 is not available inside the cwrapper. Returns result in 337935c4bbdfSmrg# func_to_host_path_result. 338035c4bbdfSmrgfunc_convert_path_msys_to_w32 () 33814642e01fSmrg{ 338235c4bbdfSmrg $debug_cmd 338335c4bbdfSmrg 338435c4bbdfSmrg func_to_host_path_result=$1 338535c4bbdfSmrg if test -n "$1"; then 338635c4bbdfSmrg # Remove leading and trailing path separator characters from ARG. MSYS 338735c4bbdfSmrg # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; 338835c4bbdfSmrg # and winepath ignores them completely. 338935c4bbdfSmrg func_stripname : : "$1" 339035c4bbdfSmrg func_to_host_path_tmp1=$func_stripname_result 339135c4bbdfSmrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 339235c4bbdfSmrg func_to_host_path_result=$func_convert_core_msys_to_w32_result 339335c4bbdfSmrg func_convert_path_check : ";" \ 339435c4bbdfSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 339535c4bbdfSmrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 339635c4bbdfSmrg fi 33974642e01fSmrg} 339835c4bbdfSmrg# end func_convert_path_msys_to_w32 33994642e01fSmrg 34004642e01fSmrg 340135c4bbdfSmrg# func_convert_path_cygwin_to_w32 ARG 340235c4bbdfSmrg# Convert path ARG from Cygwin to w32 format. Returns result in 340335c4bbdfSmrg# func_to_host_file_result. 340435c4bbdfSmrgfunc_convert_path_cygwin_to_w32 () 34054642e01fSmrg{ 340635c4bbdfSmrg $debug_cmd 340735c4bbdfSmrg 340835c4bbdfSmrg func_to_host_path_result=$1 340935c4bbdfSmrg if test -n "$1"; then 341035c4bbdfSmrg # See func_convert_path_msys_to_w32: 341135c4bbdfSmrg func_stripname : : "$1" 341235c4bbdfSmrg func_to_host_path_tmp1=$func_stripname_result 341335c4bbdfSmrg func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` 341435c4bbdfSmrg func_convert_path_check : ";" \ 341535c4bbdfSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 341635c4bbdfSmrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 341735c4bbdfSmrg fi 34186747b715Smrg} 341935c4bbdfSmrg# end func_convert_path_cygwin_to_w32 34206747b715Smrg 34216747b715Smrg 342235c4bbdfSmrg# func_convert_path_nix_to_w32 ARG 342335c4bbdfSmrg# Convert path ARG from *nix to w32 format. Requires a wine environment and 342435c4bbdfSmrg# a working winepath. Returns result in func_to_host_file_result. 342535c4bbdfSmrgfunc_convert_path_nix_to_w32 () 342635c4bbdfSmrg{ 342735c4bbdfSmrg $debug_cmd 34286747b715Smrg 342935c4bbdfSmrg func_to_host_path_result=$1 343035c4bbdfSmrg if test -n "$1"; then 343135c4bbdfSmrg # See func_convert_path_msys_to_w32: 343235c4bbdfSmrg func_stripname : : "$1" 343335c4bbdfSmrg func_to_host_path_tmp1=$func_stripname_result 343435c4bbdfSmrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 343535c4bbdfSmrg func_to_host_path_result=$func_convert_core_path_wine_to_w32_result 343635c4bbdfSmrg func_convert_path_check : ";" \ 343735c4bbdfSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 343835c4bbdfSmrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 343935c4bbdfSmrg fi 344035c4bbdfSmrg} 344135c4bbdfSmrg# end func_convert_path_nix_to_w32 344235c4bbdfSmrg 344335c4bbdfSmrg 344435c4bbdfSmrg# func_convert_path_msys_to_cygwin ARG 344535c4bbdfSmrg# Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 344635c4bbdfSmrg# Returns result in func_to_host_file_result. 344735c4bbdfSmrgfunc_convert_path_msys_to_cygwin () 34486747b715Smrg{ 344935c4bbdfSmrg $debug_cmd 34506747b715Smrg 345135c4bbdfSmrg func_to_host_path_result=$1 345235c4bbdfSmrg if test -n "$1"; then 345335c4bbdfSmrg # See func_convert_path_msys_to_w32: 345435c4bbdfSmrg func_stripname : : "$1" 345535c4bbdfSmrg func_to_host_path_tmp1=$func_stripname_result 345635c4bbdfSmrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 345735c4bbdfSmrg func_cygpath -u -p "$func_convert_core_msys_to_w32_result" 345835c4bbdfSmrg func_to_host_path_result=$func_cygpath_result 345935c4bbdfSmrg func_convert_path_check : : \ 346035c4bbdfSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 346135c4bbdfSmrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 346235c4bbdfSmrg fi 346335c4bbdfSmrg} 346435c4bbdfSmrg# end func_convert_path_msys_to_cygwin 34656747b715Smrg 34666747b715Smrg 346735c4bbdfSmrg# func_convert_path_nix_to_cygwin ARG 346835c4bbdfSmrg# Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a 346935c4bbdfSmrg# a wine environment, working winepath, and LT_CYGPATH set. Returns result in 347035c4bbdfSmrg# func_to_host_file_result. 347135c4bbdfSmrgfunc_convert_path_nix_to_cygwin () 347235c4bbdfSmrg{ 347335c4bbdfSmrg $debug_cmd 34746747b715Smrg 347535c4bbdfSmrg func_to_host_path_result=$1 347635c4bbdfSmrg if test -n "$1"; then 347735c4bbdfSmrg # Remove leading and trailing path separator characters from 347835c4bbdfSmrg # ARG. msys behavior is inconsistent here, cygpath turns them 347935c4bbdfSmrg # into '.;' and ';.', and winepath ignores them completely. 348035c4bbdfSmrg func_stripname : : "$1" 348135c4bbdfSmrg func_to_host_path_tmp1=$func_stripname_result 348235c4bbdfSmrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 348335c4bbdfSmrg func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" 348435c4bbdfSmrg func_to_host_path_result=$func_cygpath_result 348535c4bbdfSmrg func_convert_path_check : : \ 348635c4bbdfSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 348735c4bbdfSmrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 348835c4bbdfSmrg fi 348935c4bbdfSmrg} 349035c4bbdfSmrg# end func_convert_path_nix_to_cygwin 34916747b715Smrg 349235c4bbdfSmrg 349335c4bbdfSmrg# func_dll_def_p FILE 349435c4bbdfSmrg# True iff FILE is a Windows DLL '.def' file. 349535c4bbdfSmrg# Keep in sync with _LT_DLL_DEF_P in libtool.m4 349635c4bbdfSmrgfunc_dll_def_p () 349735c4bbdfSmrg{ 349835c4bbdfSmrg $debug_cmd 349935c4bbdfSmrg 350035c4bbdfSmrg func_dll_def_p_tmp=`$SED -n \ 350135c4bbdfSmrg -e 's/^[ ]*//' \ 350235c4bbdfSmrg -e '/^\(;.*\)*$/d' \ 350335c4bbdfSmrg -e 's/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p' \ 350435c4bbdfSmrg -e q \ 350535c4bbdfSmrg "$1"` 350635c4bbdfSmrg test DEF = "$func_dll_def_p_tmp" 35076747b715Smrg} 35086747b715Smrg 350935c4bbdfSmrg 35104642e01fSmrg# func_mode_compile arg... 35114642e01fSmrgfunc_mode_compile () 35124642e01fSmrg{ 351335c4bbdfSmrg $debug_cmd 351435c4bbdfSmrg 35154642e01fSmrg # Get the compilation command and the source file. 35164642e01fSmrg base_compile= 351735c4bbdfSmrg srcfile=$nonopt # always keep a non-empty value in "srcfile" 35184642e01fSmrg suppress_opt=yes 35194642e01fSmrg suppress_output= 35204642e01fSmrg arg_mode=normal 35214642e01fSmrg libobj= 35224642e01fSmrg later= 35234642e01fSmrg pie_flag= 35244642e01fSmrg 35254642e01fSmrg for arg 35264642e01fSmrg do 35274642e01fSmrg case $arg_mode in 35284642e01fSmrg arg ) 35294642e01fSmrg # do not "continue". Instead, add this to base_compile 353035c4bbdfSmrg lastarg=$arg 35314642e01fSmrg arg_mode=normal 35324642e01fSmrg ;; 35334642e01fSmrg 35344642e01fSmrg target ) 353535c4bbdfSmrg libobj=$arg 35364642e01fSmrg arg_mode=normal 35374642e01fSmrg continue 35384642e01fSmrg ;; 35394642e01fSmrg 35404642e01fSmrg normal ) 35414642e01fSmrg # Accept any command-line options. 35424642e01fSmrg case $arg in 35434642e01fSmrg -o) 35444642e01fSmrg test -n "$libobj" && \ 354535c4bbdfSmrg func_fatal_error "you cannot specify '-o' more than once" 35464642e01fSmrg arg_mode=target 35474642e01fSmrg continue 35484642e01fSmrg ;; 35494642e01fSmrg 35504642e01fSmrg -pie | -fpie | -fPIE) 355135c4bbdfSmrg func_append pie_flag " $arg" 35524642e01fSmrg continue 35534642e01fSmrg ;; 35544642e01fSmrg 35554642e01fSmrg -shared | -static | -prefer-pic | -prefer-non-pic) 355635c4bbdfSmrg func_append later " $arg" 35574642e01fSmrg continue 35584642e01fSmrg ;; 35594642e01fSmrg 35604642e01fSmrg -no-suppress) 356105b261ecSmrg suppress_opt=no 356205b261ecSmrg continue 356305b261ecSmrg ;; 356405b261ecSmrg 356505b261ecSmrg -Xcompiler) 356605b261ecSmrg arg_mode=arg # the next one goes into the "base_compile" arg list 356705b261ecSmrg continue # The current "srcfile" will either be retained or 356805b261ecSmrg ;; # replaced later. I would guess that would be a bug. 356905b261ecSmrg 357005b261ecSmrg -Wc,*) 35714642e01fSmrg func_stripname '-Wc,' '' "$arg" 35724642e01fSmrg args=$func_stripname_result 357305b261ecSmrg lastarg= 357435c4bbdfSmrg save_ifs=$IFS; IFS=, 35754642e01fSmrg for arg in $args; do 357635c4bbdfSmrg IFS=$save_ifs 357735c4bbdfSmrg func_append_quoted lastarg "$arg" 357805b261ecSmrg done 357935c4bbdfSmrg IFS=$save_ifs 35804642e01fSmrg func_stripname ' ' '' "$lastarg" 35814642e01fSmrg lastarg=$func_stripname_result 358205b261ecSmrg 358305b261ecSmrg # Add the arguments to base_compile. 358435c4bbdfSmrg func_append base_compile " $lastarg" 358505b261ecSmrg continue 358605b261ecSmrg ;; 358705b261ecSmrg 35884642e01fSmrg *) 358905b261ecSmrg # Accept the current argument as the source file. 359005b261ecSmrg # The previous "srcfile" becomes the current argument. 359105b261ecSmrg # 359235c4bbdfSmrg lastarg=$srcfile 359335c4bbdfSmrg srcfile=$arg 359405b261ecSmrg ;; 359505b261ecSmrg esac # case $arg 359605b261ecSmrg ;; 359705b261ecSmrg esac # case $arg_mode 359805b261ecSmrg 359905b261ecSmrg # Aesthetically quote the previous argument. 360035c4bbdfSmrg func_append_quoted base_compile "$lastarg" 360105b261ecSmrg done # for arg 360205b261ecSmrg 360305b261ecSmrg case $arg_mode in 360405b261ecSmrg arg) 36054642e01fSmrg func_fatal_error "you must specify an argument for -Xcompile" 360605b261ecSmrg ;; 360705b261ecSmrg target) 360835c4bbdfSmrg func_fatal_error "you must specify a target with '-o'" 360905b261ecSmrg ;; 361005b261ecSmrg *) 361105b261ecSmrg # Get the name of the library object. 36124642e01fSmrg test -z "$libobj" && { 36134642e01fSmrg func_basename "$srcfile" 361435c4bbdfSmrg libobj=$func_basename_result 36154642e01fSmrg } 361605b261ecSmrg ;; 361705b261ecSmrg esac 361805b261ecSmrg 361905b261ecSmrg # Recognize several different file suffixes. 362005b261ecSmrg # If the user specifies -o file.o, it is replaced with file.lo 362105b261ecSmrg case $libobj in 36224642e01fSmrg *.[cCFSifmso] | \ 36234642e01fSmrg *.ada | *.adb | *.ads | *.asm | \ 36244642e01fSmrg *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ 362535c4bbdfSmrg *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup) 36264642e01fSmrg func_xform "$libobj" 36274642e01fSmrg libobj=$func_xform_result 36284642e01fSmrg ;; 362905b261ecSmrg esac 363005b261ecSmrg 363105b261ecSmrg case $libobj in 36324642e01fSmrg *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; 363305b261ecSmrg *) 363435c4bbdfSmrg func_fatal_error "cannot determine name of library object from '$libobj'" 363505b261ecSmrg ;; 363605b261ecSmrg esac 363705b261ecSmrg 363805b261ecSmrg func_infer_tag $base_compile 363905b261ecSmrg 364005b261ecSmrg for arg in $later; do 364105b261ecSmrg case $arg in 36424642e01fSmrg -shared) 364335c4bbdfSmrg test yes = "$build_libtool_libs" \ 364435c4bbdfSmrg || func_fatal_configuration "cannot build a shared library" 36454642e01fSmrg build_old_libs=no 36464642e01fSmrg continue 36474642e01fSmrg ;; 36484642e01fSmrg 364905b261ecSmrg -static) 36504642e01fSmrg build_libtool_libs=no 365105b261ecSmrg build_old_libs=yes 365205b261ecSmrg continue 365305b261ecSmrg ;; 365405b261ecSmrg 365505b261ecSmrg -prefer-pic) 365605b261ecSmrg pic_mode=yes 365705b261ecSmrg continue 365805b261ecSmrg ;; 365905b261ecSmrg 366005b261ecSmrg -prefer-non-pic) 366105b261ecSmrg pic_mode=no 366205b261ecSmrg continue 366305b261ecSmrg ;; 366405b261ecSmrg esac 366505b261ecSmrg done 366605b261ecSmrg 3667c82838c1Smrg func_quote_arg pretty "$libobj" 3668c82838c1Smrg test "X$libobj" != "X$func_quote_arg_result" \ 36694642e01fSmrg && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ 367035c4bbdfSmrg && func_warning "libobj name '$libobj' may not contain shell special characters." 36714642e01fSmrg func_dirname_and_basename "$obj" "/" "" 367235c4bbdfSmrg objname=$func_basename_result 367335c4bbdfSmrg xdir=$func_dirname_result 367435c4bbdfSmrg lobj=$xdir$objdir/$objname 367505b261ecSmrg 36764642e01fSmrg test -z "$base_compile" && \ 36774642e01fSmrg func_fatal_help "you must specify a compilation command" 367805b261ecSmrg 367905b261ecSmrg # Delete any leftover library objects. 368035c4bbdfSmrg if test yes = "$build_old_libs"; then 368105b261ecSmrg removelist="$obj $lobj $libobj ${libobj}T" 368205b261ecSmrg else 368305b261ecSmrg removelist="$lobj $libobj ${libobj}T" 368405b261ecSmrg fi 368505b261ecSmrg 368605b261ecSmrg # On Cygwin there's no "real" PIC flag so we must build both object types 368705b261ecSmrg case $host_os in 36884642e01fSmrg cygwin* | mingw* | pw32* | os2* | cegcc*) 368905b261ecSmrg pic_mode=default 369005b261ecSmrg ;; 369105b261ecSmrg esac 369235c4bbdfSmrg if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then 369305b261ecSmrg # non-PIC code in shared libraries is not supported 369405b261ecSmrg pic_mode=default 369505b261ecSmrg fi 369605b261ecSmrg 369705b261ecSmrg # Calculate the filename of the output object if compiler does 369805b261ecSmrg # not support -o with -c 369935c4bbdfSmrg if test no = "$compiler_c_o"; then 370035c4bbdfSmrg output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext 370135c4bbdfSmrg lockfile=$output_obj.lock 370205b261ecSmrg else 370305b261ecSmrg output_obj= 370405b261ecSmrg need_locks=no 370505b261ecSmrg lockfile= 370605b261ecSmrg fi 370705b261ecSmrg 370805b261ecSmrg # Lock this critical section if it is needed 370905b261ecSmrg # We use this script file to make the link, it avoids creating a new file 371035c4bbdfSmrg if test yes = "$need_locks"; then 37114642e01fSmrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 37124642e01fSmrg func_echo "Waiting for $lockfile to be removed" 371305b261ecSmrg sleep 2 371405b261ecSmrg done 371535c4bbdfSmrg elif test warn = "$need_locks"; then 371605b261ecSmrg if test -f "$lockfile"; then 37174642e01fSmrg $ECHO "\ 371805b261ecSmrg*** ERROR, $lockfile exists and contains: 371905b261ecSmrg`cat $lockfile 2>/dev/null` 372005b261ecSmrg 372105b261ecSmrgThis indicates that another process is trying to use the same 372205b261ecSmrgtemporary object file, and libtool could not work around it because 372335c4bbdfSmrgyour compiler does not support '-c' and '-o' together. If you 372405b261ecSmrgrepeat this compilation, it may succeed, by chance, but you had better 372505b261ecSmrgavoid parallel builds (make -j) in this platform, or get a better 372605b261ecSmrgcompiler." 372705b261ecSmrg 37284642e01fSmrg $opt_dry_run || $RM $removelist 372905b261ecSmrg exit $EXIT_FAILURE 373005b261ecSmrg fi 373135c4bbdfSmrg func_append removelist " $output_obj" 37324642e01fSmrg $ECHO "$srcfile" > "$lockfile" 373305b261ecSmrg fi 373405b261ecSmrg 37354642e01fSmrg $opt_dry_run || $RM $removelist 373635c4bbdfSmrg func_append removelist " $lockfile" 37374642e01fSmrg trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 37384642e01fSmrg 373935c4bbdfSmrg func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 374035c4bbdfSmrg srcfile=$func_to_tool_file_result 3741c82838c1Smrg func_quote_arg pretty "$srcfile" 3742c82838c1Smrg qsrcfile=$func_quote_arg_result 374305b261ecSmrg 374405b261ecSmrg # Only build a PIC object if we are building libtool libraries. 374535c4bbdfSmrg if test yes = "$build_libtool_libs"; then 374605b261ecSmrg # Without this assignment, base_compile gets emptied. 374705b261ecSmrg fbsd_hideous_sh_bug=$base_compile 374805b261ecSmrg 374935c4bbdfSmrg if test no != "$pic_mode"; then 375005b261ecSmrg command="$base_compile $qsrcfile $pic_flag" 375105b261ecSmrg else 375205b261ecSmrg # Don't build PIC code 375305b261ecSmrg command="$base_compile $qsrcfile" 375405b261ecSmrg fi 375505b261ecSmrg 37564642e01fSmrg func_mkdir_p "$xdir$objdir" 375705b261ecSmrg 375805b261ecSmrg if test -z "$output_obj"; then 375905b261ecSmrg # Place PIC objects in $objdir 376035c4bbdfSmrg func_append command " -o $lobj" 376105b261ecSmrg fi 376205b261ecSmrg 37634642e01fSmrg func_show_eval_locale "$command" \ 37644642e01fSmrg 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' 376505b261ecSmrg 376635c4bbdfSmrg if test warn = "$need_locks" && 376705b261ecSmrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 37684642e01fSmrg $ECHO "\ 376905b261ecSmrg*** ERROR, $lockfile contains: 377005b261ecSmrg`cat $lockfile 2>/dev/null` 377105b261ecSmrg 377205b261ecSmrgbut it should contain: 377305b261ecSmrg$srcfile 377405b261ecSmrg 377505b261ecSmrgThis indicates that another process is trying to use the same 377605b261ecSmrgtemporary object file, and libtool could not work around it because 377735c4bbdfSmrgyour compiler does not support '-c' and '-o' together. If you 377805b261ecSmrgrepeat this compilation, it may succeed, by chance, but you had better 377905b261ecSmrgavoid parallel builds (make -j) in this platform, or get a better 378005b261ecSmrgcompiler." 378105b261ecSmrg 37824642e01fSmrg $opt_dry_run || $RM $removelist 378305b261ecSmrg exit $EXIT_FAILURE 378405b261ecSmrg fi 378505b261ecSmrg 378605b261ecSmrg # Just move the object if needed, then go on to compile the next one 378705b261ecSmrg if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then 37884642e01fSmrg func_show_eval '$MV "$output_obj" "$lobj"' \ 37894642e01fSmrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 379005b261ecSmrg fi 379105b261ecSmrg 379205b261ecSmrg # Allow error messages only from the first compilation. 379335c4bbdfSmrg if test yes = "$suppress_opt"; then 37944642e01fSmrg suppress_output=' >/dev/null 2>&1' 379505b261ecSmrg fi 379605b261ecSmrg fi 379705b261ecSmrg 379805b261ecSmrg # Only build a position-dependent object if we build old libraries. 379935c4bbdfSmrg if test yes = "$build_old_libs"; then 380035c4bbdfSmrg if test yes != "$pic_mode"; then 380105b261ecSmrg # Don't build PIC code 38024642e01fSmrg command="$base_compile $qsrcfile$pie_flag" 380305b261ecSmrg else 380405b261ecSmrg command="$base_compile $qsrcfile $pic_flag" 380505b261ecSmrg fi 380635c4bbdfSmrg if test yes = "$compiler_c_o"; then 380735c4bbdfSmrg func_append command " -o $obj" 380805b261ecSmrg fi 380905b261ecSmrg 381005b261ecSmrg # Suppress compiler output if we already did a PIC compilation. 381135c4bbdfSmrg func_append command "$suppress_output" 38124642e01fSmrg func_show_eval_locale "$command" \ 38134642e01fSmrg '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 381405b261ecSmrg 381535c4bbdfSmrg if test warn = "$need_locks" && 381605b261ecSmrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 38174642e01fSmrg $ECHO "\ 381805b261ecSmrg*** ERROR, $lockfile contains: 381905b261ecSmrg`cat $lockfile 2>/dev/null` 382005b261ecSmrg 382105b261ecSmrgbut it should contain: 382205b261ecSmrg$srcfile 382305b261ecSmrg 382405b261ecSmrgThis indicates that another process is trying to use the same 382505b261ecSmrgtemporary object file, and libtool could not work around it because 382635c4bbdfSmrgyour compiler does not support '-c' and '-o' together. If you 382705b261ecSmrgrepeat this compilation, it may succeed, by chance, but you had better 382805b261ecSmrgavoid parallel builds (make -j) in this platform, or get a better 382905b261ecSmrgcompiler." 383005b261ecSmrg 38314642e01fSmrg $opt_dry_run || $RM $removelist 383205b261ecSmrg exit $EXIT_FAILURE 383305b261ecSmrg fi 383405b261ecSmrg 383505b261ecSmrg # Just move the object if needed 383605b261ecSmrg if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then 38374642e01fSmrg func_show_eval '$MV "$output_obj" "$obj"' \ 38384642e01fSmrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 383905b261ecSmrg fi 384005b261ecSmrg fi 384105b261ecSmrg 38424642e01fSmrg $opt_dry_run || { 38434642e01fSmrg func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" 384405b261ecSmrg 38454642e01fSmrg # Unlock the critical section if it was locked 384635c4bbdfSmrg if test no != "$need_locks"; then 38474642e01fSmrg removelist=$lockfile 38484642e01fSmrg $RM "$lockfile" 38494642e01fSmrg fi 38504642e01fSmrg } 385105b261ecSmrg 385205b261ecSmrg exit $EXIT_SUCCESS 38534642e01fSmrg} 385405b261ecSmrg 38554642e01fSmrg$opt_help || { 385635c4bbdfSmrg test compile = "$opt_mode" && func_mode_compile ${1+"$@"} 38574642e01fSmrg} 385805b261ecSmrg 38594642e01fSmrgfunc_mode_help () 38604642e01fSmrg{ 38614642e01fSmrg # We need to display help for each of the modes. 386235c4bbdfSmrg case $opt_mode in 38634642e01fSmrg "") 38644642e01fSmrg # Generic help is extracted from the usage comments 38654642e01fSmrg # at the start of this file. 38664642e01fSmrg func_help 38674642e01fSmrg ;; 386805b261ecSmrg 38694642e01fSmrg clean) 38704642e01fSmrg $ECHO \ 38714642e01fSmrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... 387205b261ecSmrg 38734642e01fSmrgRemove files from the build directory. 387405b261ecSmrg 38754642e01fSmrgRM is the name of the program to use to delete files associated with each FILE 387635c4bbdfSmrg(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 38774642e01fSmrgto RM. 387805b261ecSmrg 38794642e01fSmrgIf FILE is a libtool library, object or program, all the files associated 38804642e01fSmrgwith it are deleted. Otherwise, only FILE itself is deleted using RM." 38814642e01fSmrg ;; 388205b261ecSmrg 38834642e01fSmrg compile) 38844642e01fSmrg $ECHO \ 38854642e01fSmrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE 388605b261ecSmrg 38874642e01fSmrgCompile a source file into a libtool library object. 388805b261ecSmrg 38894642e01fSmrgThis mode accepts the following additional options: 389005b261ecSmrg 38914642e01fSmrg -o OUTPUT-FILE set the output file name to OUTPUT-FILE 38924642e01fSmrg -no-suppress do not suppress compiler output for multiple passes 38936747b715Smrg -prefer-pic try to build PIC objects only 38946747b715Smrg -prefer-non-pic try to build non-PIC objects only 389535c4bbdfSmrg -shared do not build a '.o' file suitable for static linking 389635c4bbdfSmrg -static only build a '.o' file suitable for static linking 3897c82838c1Smrg -Wc,FLAG 3898c82838c1Smrg -Xcompiler FLAG pass FLAG directly to the compiler 389905b261ecSmrg 390035c4bbdfSmrgCOMPILE-COMMAND is a command to be used in creating a 'standard' object file 39014642e01fSmrgfrom the given SOURCEFILE. 390205b261ecSmrg 39034642e01fSmrgThe output file name is determined by removing the directory component from 390435c4bbdfSmrgSOURCEFILE, then substituting the C source code suffix '.c' with the 390535c4bbdfSmrglibrary object suffix, '.lo'." 39064642e01fSmrg ;; 390705b261ecSmrg 39084642e01fSmrg execute) 39094642e01fSmrg $ECHO \ 39104642e01fSmrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... 391105b261ecSmrg 39124642e01fSmrgAutomatically set library path, then run a program. 391305b261ecSmrg 39144642e01fSmrgThis mode accepts the following additional options: 391505b261ecSmrg 39164642e01fSmrg -dlopen FILE add the directory containing FILE to the library path 391705b261ecSmrg 391835c4bbdfSmrgThis mode sets the library path environment variable according to '-dlopen' 39194642e01fSmrgflags. 392005b261ecSmrg 39214642e01fSmrgIf any of the ARGS are libtool executable wrappers, then they are translated 39224642e01fSmrginto their corresponding uninstalled binary, and any of their required library 39234642e01fSmrgdirectories are added to the library path. 392405b261ecSmrg 39254642e01fSmrgThen, COMMAND is executed, with ARGS as arguments." 39264642e01fSmrg ;; 392705b261ecSmrg 39284642e01fSmrg finish) 39294642e01fSmrg $ECHO \ 39304642e01fSmrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]... 393105b261ecSmrg 39324642e01fSmrgComplete the installation of libtool libraries. 393305b261ecSmrg 39344642e01fSmrgEach LIBDIR is a directory that contains libtool libraries. 393505b261ecSmrg 39364642e01fSmrgThe commands that this mode executes may require superuser privileges. Use 393735c4bbdfSmrgthe '--dry-run' option if you just want to see what would be executed." 39384642e01fSmrg ;; 393905b261ecSmrg 39404642e01fSmrg install) 39414642e01fSmrg $ECHO \ 39424642e01fSmrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... 394305b261ecSmrg 39444642e01fSmrgInstall executables or libraries. 394505b261ecSmrg 39464642e01fSmrgINSTALL-COMMAND is the installation command. The first component should be 394735c4bbdfSmrgeither the 'install' or 'cp' program. 394805b261ecSmrg 39494642e01fSmrgThe following components of INSTALL-COMMAND are treated specially: 395005b261ecSmrg 39516747b715Smrg -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation 395205b261ecSmrg 39534642e01fSmrgThe rest of the components are interpreted as arguments to that command (only 39544642e01fSmrgBSD-compatible install options are recognized)." 39554642e01fSmrg ;; 395605b261ecSmrg 39574642e01fSmrg link) 39584642e01fSmrg $ECHO \ 39594642e01fSmrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND... 396005b261ecSmrg 39614642e01fSmrgLink object files or libraries together to form another library, or to 39624642e01fSmrgcreate an executable program. 396305b261ecSmrg 39644642e01fSmrgLINK-COMMAND is a command using the C compiler that you would use to create 39654642e01fSmrga program from several object files. 396605b261ecSmrg 39674642e01fSmrgThe following components of LINK-COMMAND are treated specially: 396805b261ecSmrg 39694642e01fSmrg -all-static do not do any dynamic linking at all 39704642e01fSmrg -avoid-version do not add a version suffix if possible 39716747b715Smrg -bindir BINDIR specify path to binaries directory (for systems where 39726747b715Smrg libraries must be found in the PATH setting at runtime) 397335c4bbdfSmrg -dlopen FILE '-dlpreopen' FILE if it cannot be dlopened at runtime 39744642e01fSmrg -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols 39754642e01fSmrg -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) 39764642e01fSmrg -export-symbols SYMFILE 39774642e01fSmrg try to export only the symbols listed in SYMFILE 39784642e01fSmrg -export-symbols-regex REGEX 39794642e01fSmrg try to export only the symbols matching REGEX 39804642e01fSmrg -LLIBDIR search LIBDIR for required installed libraries 39814642e01fSmrg -lNAME OUTPUT-FILE requires the installed library libNAME 39824642e01fSmrg -module build a library that can dlopened 39834642e01fSmrg -no-fast-install disable the fast-install mode 39844642e01fSmrg -no-install link a not-installable executable 39854642e01fSmrg -no-undefined declare that a library does not refer to external symbols 39864642e01fSmrg -o OUTPUT-FILE create OUTPUT-FILE from the specified objects 398735c4bbdfSmrg -objectlist FILE use a list of object files found in FILE to specify objects 398835c4bbdfSmrg -os2dllname NAME force a short DLL name on OS/2 (no effect on other OSes) 39894642e01fSmrg -precious-files-regex REGEX 39904642e01fSmrg don't remove output files matching REGEX 39914642e01fSmrg -release RELEASE specify package release information 39924642e01fSmrg -rpath LIBDIR the created library will eventually be installed in LIBDIR 39934642e01fSmrg -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries 39944642e01fSmrg -shared only do dynamic linking of libtool libraries 39954642e01fSmrg -shrext SUFFIX override the standard shared library file extension 39964642e01fSmrg -static do not do any dynamic linking of uninstalled libtool libraries 39974642e01fSmrg -static-libtool-libs 39984642e01fSmrg do not do any dynamic linking of libtool libraries 39994642e01fSmrg -version-info CURRENT[:REVISION[:AGE]] 40004642e01fSmrg specify library version info [each variable defaults to 0] 40014642e01fSmrg -weak LIBNAME declare that the target provides the LIBNAME interface 40026747b715Smrg -Wc,FLAG 40036747b715Smrg -Xcompiler FLAG pass linker-specific FLAG directly to the compiler 4004c82838c1Smrg -Wa,FLAG 4005c82838c1Smrg -Xassembler FLAG pass linker-specific FLAG directly to the assembler 40066747b715Smrg -Wl,FLAG 40076747b715Smrg -Xlinker FLAG pass linker-specific FLAG directly to the linker 40086747b715Smrg -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) 400905b261ecSmrg 401035c4bbdfSmrgAll other options (arguments beginning with '-') are ignored. 401105b261ecSmrg 401235c4bbdfSmrgEvery other argument is treated as a filename. Files ending in '.la' are 40134642e01fSmrgtreated as uninstalled libtool libraries, other files are standard or library 40144642e01fSmrgobject files. 401505b261ecSmrg 401635c4bbdfSmrgIf the OUTPUT-FILE ends in '.la', then a libtool library is created, 401735c4bbdfSmrgonly library objects ('.lo' files) may be specified, and '-rpath' is 40184642e01fSmrgrequired, except when creating a convenience library. 401905b261ecSmrg 402035c4bbdfSmrgIf OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created 402135c4bbdfSmrgusing 'ar' and 'ranlib', or on Windows using 'lib'. 402205b261ecSmrg 402335c4bbdfSmrgIf OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file 40244642e01fSmrgis created, otherwise an executable program is created." 402505b261ecSmrg ;; 402605b261ecSmrg 40274642e01fSmrg uninstall) 40284642e01fSmrg $ECHO \ 40294642e01fSmrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... 403005b261ecSmrg 40314642e01fSmrgRemove libraries from an installation directory. 403205b261ecSmrg 40334642e01fSmrgRM is the name of the program to use to delete files associated with each FILE 403435c4bbdfSmrg(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 40354642e01fSmrgto RM. 403605b261ecSmrg 40374642e01fSmrgIf FILE is a libtool library, all the files associated with it are deleted. 40384642e01fSmrgOtherwise, only FILE itself is deleted using RM." 40394642e01fSmrg ;; 404005b261ecSmrg 40414642e01fSmrg *) 404235c4bbdfSmrg func_fatal_help "invalid operation mode '$opt_mode'" 40434642e01fSmrg ;; 40444642e01fSmrg esac 404505b261ecSmrg 40466747b715Smrg echo 404735c4bbdfSmrg $ECHO "Try '$progname --help' for more information about other modes." 40484642e01fSmrg} 404905b261ecSmrg 40506747b715Smrg# Now that we've collected a possible --mode arg, show help if necessary 40516747b715Smrgif $opt_help; then 405235c4bbdfSmrg if test : = "$opt_help"; then 40536747b715Smrg func_mode_help 40546747b715Smrg else 40556747b715Smrg { 40566747b715Smrg func_help noexit 405735c4bbdfSmrg for opt_mode in compile link execute install finish uninstall clean; do 40586747b715Smrg func_mode_help 40596747b715Smrg done 406035c4bbdfSmrg } | $SED -n '1p; 2,$s/^Usage:/ or: /p' 40616747b715Smrg { 40626747b715Smrg func_help noexit 406335c4bbdfSmrg for opt_mode in compile link execute install finish uninstall clean; do 40646747b715Smrg echo 40656747b715Smrg func_mode_help 40666747b715Smrg done 40676747b715Smrg } | 406835c4bbdfSmrg $SED '1d 40696747b715Smrg /^When reporting/,/^Report/{ 40706747b715Smrg H 40716747b715Smrg d 40726747b715Smrg } 40736747b715Smrg $x 40746747b715Smrg /information about other modes/d 40756747b715Smrg /more detailed .*MODE/d 40766747b715Smrg s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' 40776747b715Smrg fi 40786747b715Smrg exit $? 40796747b715Smrgfi 408005b261ecSmrg 408105b261ecSmrg 40824642e01fSmrg# func_mode_execute arg... 40834642e01fSmrgfunc_mode_execute () 40844642e01fSmrg{ 408535c4bbdfSmrg $debug_cmd 408635c4bbdfSmrg 40874642e01fSmrg # The first argument is the command name. 408835c4bbdfSmrg cmd=$nonopt 40894642e01fSmrg test -z "$cmd" && \ 40904642e01fSmrg func_fatal_help "you must specify a COMMAND" 409105b261ecSmrg 40924642e01fSmrg # Handle -dlopen flags immediately. 409335c4bbdfSmrg for file in $opt_dlopen; do 40944642e01fSmrg test -f "$file" \ 409535c4bbdfSmrg || func_fatal_help "'$file' is not a file" 409605b261ecSmrg 40974642e01fSmrg dir= 40984642e01fSmrg case $file in 40994642e01fSmrg *.la) 410035c4bbdfSmrg func_resolve_sysroot "$file" 410135c4bbdfSmrg file=$func_resolve_sysroot_result 410235c4bbdfSmrg 41034642e01fSmrg # Check to see that this really is a libtool archive. 41044642e01fSmrg func_lalib_unsafe_p "$file" \ 410535c4bbdfSmrg || func_fatal_help "'$lib' is not a valid libtool archive" 410605b261ecSmrg 41074642e01fSmrg # Read the libtool library. 41084642e01fSmrg dlname= 41094642e01fSmrg library_names= 41104642e01fSmrg func_source "$file" 411105b261ecSmrg 41124642e01fSmrg # Skip this library if it cannot be dlopened. 41134642e01fSmrg if test -z "$dlname"; then 41144642e01fSmrg # Warn if it was a shared library. 41154642e01fSmrg test -n "$library_names" && \ 411635c4bbdfSmrg func_warning "'$file' was not linked with '-export-dynamic'" 41174642e01fSmrg continue 41184642e01fSmrg fi 411905b261ecSmrg 41204642e01fSmrg func_dirname "$file" "" "." 412135c4bbdfSmrg dir=$func_dirname_result 412205b261ecSmrg 41234642e01fSmrg if test -f "$dir/$objdir/$dlname"; then 412435c4bbdfSmrg func_append dir "/$objdir" 41254642e01fSmrg else 41264642e01fSmrg if test ! -f "$dir/$dlname"; then 412735c4bbdfSmrg func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'" 41284642e01fSmrg fi 41294642e01fSmrg fi 413005b261ecSmrg ;; 413105b261ecSmrg 41324642e01fSmrg *.lo) 41334642e01fSmrg # Just add the directory containing the .lo file. 41344642e01fSmrg func_dirname "$file" "" "." 413535c4bbdfSmrg dir=$func_dirname_result 413605b261ecSmrg ;; 413705b261ecSmrg 41384642e01fSmrg *) 413935c4bbdfSmrg func_warning "'-dlopen' is ignored for non-libtool libraries and objects" 414005b261ecSmrg continue 414105b261ecSmrg ;; 41424642e01fSmrg esac 414305b261ecSmrg 41444642e01fSmrg # Get the absolute pathname. 41454642e01fSmrg absdir=`cd "$dir" && pwd` 414635c4bbdfSmrg test -n "$absdir" && dir=$absdir 414705b261ecSmrg 41484642e01fSmrg # Now add the directory to shlibpath_var. 41494642e01fSmrg if eval "test -z \"\$$shlibpath_var\""; then 41504642e01fSmrg eval "$shlibpath_var=\"\$dir\"" 41514642e01fSmrg else 41524642e01fSmrg eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" 41534642e01fSmrg fi 41544642e01fSmrg done 415505b261ecSmrg 41564642e01fSmrg # This variable tells wrapper scripts just to set shlibpath_var 41574642e01fSmrg # rather than running their programs. 415835c4bbdfSmrg libtool_execute_magic=$magic 415905b261ecSmrg 41604642e01fSmrg # Check if any of the arguments is a wrapper script. 41614642e01fSmrg args= 41624642e01fSmrg for file 41634642e01fSmrg do 41644642e01fSmrg case $file in 41656747b715Smrg -* | *.la | *.lo ) ;; 41664642e01fSmrg *) 41674642e01fSmrg # Do a test to see if this is really a libtool program. 41684642e01fSmrg if func_ltwrapper_script_p "$file"; then 41694642e01fSmrg func_source "$file" 41704642e01fSmrg # Transform arg to wrapped name. 417135c4bbdfSmrg file=$progdir/$program 41724642e01fSmrg elif func_ltwrapper_executable_p "$file"; then 41734642e01fSmrg func_ltwrapper_scriptname "$file" 41744642e01fSmrg func_source "$func_ltwrapper_scriptname_result" 41754642e01fSmrg # Transform arg to wrapped name. 417635c4bbdfSmrg file=$progdir/$program 41774642e01fSmrg fi 41784642e01fSmrg ;; 41794642e01fSmrg esac 41804642e01fSmrg # Quote arguments (to preserve shell metacharacters). 418135c4bbdfSmrg func_append_quoted args "$file" 41824642e01fSmrg done 418305b261ecSmrg 418435c4bbdfSmrg if $opt_dry_run; then 418535c4bbdfSmrg # Display what would be done. 418635c4bbdfSmrg if test -n "$shlibpath_var"; then 418735c4bbdfSmrg eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" 418835c4bbdfSmrg echo "export $shlibpath_var" 418935c4bbdfSmrg fi 419035c4bbdfSmrg $ECHO "$cmd$args" 419135c4bbdfSmrg exit $EXIT_SUCCESS 419235c4bbdfSmrg else 41934642e01fSmrg if test -n "$shlibpath_var"; then 41944642e01fSmrg # Export the shlibpath_var. 41954642e01fSmrg eval "export $shlibpath_var" 41964642e01fSmrg fi 419705b261ecSmrg 41984642e01fSmrg # Restore saved environment variables 41994642e01fSmrg for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 42004642e01fSmrg do 42014642e01fSmrg eval "if test \"\${save_$lt_var+set}\" = set; then 42024642e01fSmrg $lt_var=\$save_$lt_var; export $lt_var 420305b261ecSmrg else 42044642e01fSmrg $lt_unset $lt_var 42054642e01fSmrg fi" 42064642e01fSmrg done 420705b261ecSmrg 42084642e01fSmrg # Now prepare to actually exec the command. 420935c4bbdfSmrg exec_cmd=\$cmd$args 42104642e01fSmrg fi 42114642e01fSmrg} 421205b261ecSmrg 421335c4bbdfSmrgtest execute = "$opt_mode" && func_mode_execute ${1+"$@"} 421405b261ecSmrg 421505b261ecSmrg 42164642e01fSmrg# func_mode_finish arg... 42174642e01fSmrgfunc_mode_finish () 42184642e01fSmrg{ 421935c4bbdfSmrg $debug_cmd 422035c4bbdfSmrg 422135c4bbdfSmrg libs= 422235c4bbdfSmrg libdirs= 42234642e01fSmrg admincmds= 422405b261ecSmrg 422535c4bbdfSmrg for opt in "$nonopt" ${1+"$@"} 422635c4bbdfSmrg do 422735c4bbdfSmrg if test -d "$opt"; then 422835c4bbdfSmrg func_append libdirs " $opt" 422935c4bbdfSmrg 423035c4bbdfSmrg elif test -f "$opt"; then 423135c4bbdfSmrg if func_lalib_unsafe_p "$opt"; then 423235c4bbdfSmrg func_append libs " $opt" 423335c4bbdfSmrg else 423435c4bbdfSmrg func_warning "'$opt' is not a valid libtool archive" 423535c4bbdfSmrg fi 423635c4bbdfSmrg 423735c4bbdfSmrg else 423835c4bbdfSmrg func_fatal_error "invalid argument '$opt'" 423935c4bbdfSmrg fi 424035c4bbdfSmrg done 424135c4bbdfSmrg 424235c4bbdfSmrg if test -n "$libs"; then 424335c4bbdfSmrg if test -n "$lt_sysroot"; then 424435c4bbdfSmrg sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` 424535c4bbdfSmrg sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" 424635c4bbdfSmrg else 424735c4bbdfSmrg sysroot_cmd= 424835c4bbdfSmrg fi 4249475c125cSmrg 425035c4bbdfSmrg # Remove sysroot references 425135c4bbdfSmrg if $opt_dry_run; then 425235c4bbdfSmrg for lib in $libs; do 425335c4bbdfSmrg echo "removing references to $lt_sysroot and '=' prefixes from $lib" 425435c4bbdfSmrg done 425535c4bbdfSmrg else 425635c4bbdfSmrg tmpdir=`func_mktempdir` 425735c4bbdfSmrg for lib in $libs; do 425835c4bbdfSmrg $SED -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ 425935c4bbdfSmrg > $tmpdir/tmp-la 426035c4bbdfSmrg mv -f $tmpdir/tmp-la $lib 426135c4bbdfSmrg done 426235c4bbdfSmrg ${RM}r "$tmpdir" 426335c4bbdfSmrg fi 426435c4bbdfSmrg fi 426535c4bbdfSmrg 426635c4bbdfSmrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 42674642e01fSmrg for libdir in $libdirs; do 42684642e01fSmrg if test -n "$finish_cmds"; then 42694642e01fSmrg # Do each command in the finish commands. 42704642e01fSmrg func_execute_cmds "$finish_cmds" 'admincmds="$admincmds 42714642e01fSmrg'"$cmd"'"' 427205b261ecSmrg fi 42734642e01fSmrg if test -n "$finish_eval"; then 42744642e01fSmrg # Do the single finish_eval. 42754642e01fSmrg eval cmds=\"$finish_eval\" 427635c4bbdfSmrg $opt_dry_run || eval "$cmds" || func_append admincmds " 42774642e01fSmrg $cmds" 42784642e01fSmrg fi 42794642e01fSmrg done 42804642e01fSmrg fi 428105b261ecSmrg 42824642e01fSmrg # Exit here if they wanted silent mode. 428335c4bbdfSmrg $opt_quiet && exit $EXIT_SUCCESS 428405b261ecSmrg 428535c4bbdfSmrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 428635c4bbdfSmrg echo "----------------------------------------------------------------------" 428735c4bbdfSmrg echo "Libraries have been installed in:" 428835c4bbdfSmrg for libdir in $libdirs; do 428935c4bbdfSmrg $ECHO " $libdir" 429035c4bbdfSmrg done 429135c4bbdfSmrg echo 429235c4bbdfSmrg echo "If you ever happen to want to link against installed libraries" 429335c4bbdfSmrg echo "in a given directory, LIBDIR, you must either use libtool, and" 429435c4bbdfSmrg echo "specify the full pathname of the library, or use the '-LLIBDIR'" 429535c4bbdfSmrg echo "flag during linking and do at least one of the following:" 429635c4bbdfSmrg if test -n "$shlibpath_var"; then 429735c4bbdfSmrg echo " - add LIBDIR to the '$shlibpath_var' environment variable" 429835c4bbdfSmrg echo " during execution" 429935c4bbdfSmrg fi 430035c4bbdfSmrg if test -n "$runpath_var"; then 430135c4bbdfSmrg echo " - add LIBDIR to the '$runpath_var' environment variable" 430235c4bbdfSmrg echo " during linking" 430335c4bbdfSmrg fi 430435c4bbdfSmrg if test -n "$hardcode_libdir_flag_spec"; then 430535c4bbdfSmrg libdir=LIBDIR 430635c4bbdfSmrg eval flag=\"$hardcode_libdir_flag_spec\" 43074642e01fSmrg 430835c4bbdfSmrg $ECHO " - use the '$flag' linker flag" 430935c4bbdfSmrg fi 431035c4bbdfSmrg if test -n "$admincmds"; then 431135c4bbdfSmrg $ECHO " - have your system administrator run these commands:$admincmds" 431235c4bbdfSmrg fi 431335c4bbdfSmrg if test -f /etc/ld.so.conf; then 431435c4bbdfSmrg echo " - have your system administrator add LIBDIR to '/etc/ld.so.conf'" 431535c4bbdfSmrg fi 431635c4bbdfSmrg echo 4317475c125cSmrg 431835c4bbdfSmrg echo "See any operating system documentation about shared libraries for" 431935c4bbdfSmrg case $host in 432035c4bbdfSmrg solaris2.[6789]|solaris2.1[0-9]) 432135c4bbdfSmrg echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" 432235c4bbdfSmrg echo "pages." 432335c4bbdfSmrg ;; 432435c4bbdfSmrg *) 432535c4bbdfSmrg echo "more information, such as the ld(1) and ld.so(8) manual pages." 432635c4bbdfSmrg ;; 432735c4bbdfSmrg esac 432835c4bbdfSmrg echo "----------------------------------------------------------------------" 432935c4bbdfSmrg fi 43304642e01fSmrg exit $EXIT_SUCCESS 43314642e01fSmrg} 43324642e01fSmrg 433335c4bbdfSmrgtest finish = "$opt_mode" && func_mode_finish ${1+"$@"} 43344642e01fSmrg 43354642e01fSmrg 43364642e01fSmrg# func_mode_install arg... 43374642e01fSmrgfunc_mode_install () 43384642e01fSmrg{ 433935c4bbdfSmrg $debug_cmd 434035c4bbdfSmrg 43414642e01fSmrg # There may be an optional sh(1) argument at the beginning of 43424642e01fSmrg # install_prog (especially on Windows NT). 434335c4bbdfSmrg if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" || 43444642e01fSmrg # Allow the use of GNU shtool's install command. 434535c4bbdfSmrg case $nonopt in *shtool*) :;; *) false;; esac 434635c4bbdfSmrg then 43474642e01fSmrg # Aesthetically quote it. 4348c82838c1Smrg func_quote_arg pretty "$nonopt" 4349c82838c1Smrg install_prog="$func_quote_arg_result " 43504642e01fSmrg arg=$1 43514642e01fSmrg shift 43524642e01fSmrg else 43534642e01fSmrg install_prog= 43544642e01fSmrg arg=$nonopt 43554642e01fSmrg fi 43564642e01fSmrg 43574642e01fSmrg # The real first argument should be the name of the installation program. 43584642e01fSmrg # Aesthetically quote it. 4359c82838c1Smrg func_quote_arg pretty "$arg" 4360c82838c1Smrg func_append install_prog "$func_quote_arg_result" 43616747b715Smrg install_shared_prog=$install_prog 43626747b715Smrg case " $install_prog " in 43636747b715Smrg *[\\\ /]cp\ *) install_cp=: ;; 43646747b715Smrg *) install_cp=false ;; 43656747b715Smrg esac 43664642e01fSmrg 43674642e01fSmrg # We need to accept at least all the BSD install flags. 43684642e01fSmrg dest= 43694642e01fSmrg files= 43704642e01fSmrg opts= 43714642e01fSmrg prev= 43724642e01fSmrg install_type= 437335c4bbdfSmrg isdir=false 43744642e01fSmrg stripme= 43756747b715Smrg no_mode=: 43764642e01fSmrg for arg 43774642e01fSmrg do 43786747b715Smrg arg2= 43794642e01fSmrg if test -n "$dest"; then 438035c4bbdfSmrg func_append files " $dest" 43814642e01fSmrg dest=$arg 43824642e01fSmrg continue 43834642e01fSmrg fi 43844642e01fSmrg 43854642e01fSmrg case $arg in 438635c4bbdfSmrg -d) isdir=: ;; 43874642e01fSmrg -f) 43886747b715Smrg if $install_cp; then :; else 43896747b715Smrg prev=$arg 43906747b715Smrg fi 43914642e01fSmrg ;; 43924642e01fSmrg -g | -m | -o) 43934642e01fSmrg prev=$arg 43944642e01fSmrg ;; 43954642e01fSmrg -s) 43964642e01fSmrg stripme=" -s" 43974642e01fSmrg continue 43984642e01fSmrg ;; 43994642e01fSmrg -*) 44004642e01fSmrg ;; 44014642e01fSmrg *) 44024642e01fSmrg # If the previous option needed an argument, then skip it. 44034642e01fSmrg if test -n "$prev"; then 440435c4bbdfSmrg if test X-m = "X$prev" && test -n "$install_override_mode"; then 44056747b715Smrg arg2=$install_override_mode 44066747b715Smrg no_mode=false 44076747b715Smrg fi 440805b261ecSmrg prev= 440905b261ecSmrg else 44104642e01fSmrg dest=$arg 44114642e01fSmrg continue 441205b261ecSmrg fi 441305b261ecSmrg ;; 44144642e01fSmrg esac 441505b261ecSmrg 44164642e01fSmrg # Aesthetically quote the argument. 4417c82838c1Smrg func_quote_arg pretty "$arg" 4418c82838c1Smrg func_append install_prog " $func_quote_arg_result" 44196747b715Smrg if test -n "$arg2"; then 4420c82838c1Smrg func_quote_arg pretty "$arg2" 44216747b715Smrg fi 4422c82838c1Smrg func_append install_shared_prog " $func_quote_arg_result" 44234642e01fSmrg done 442405b261ecSmrg 44254642e01fSmrg test -z "$install_prog" && \ 44264642e01fSmrg func_fatal_help "you must specify an install program" 442705b261ecSmrg 44284642e01fSmrg test -n "$prev" && \ 442935c4bbdfSmrg func_fatal_help "the '$prev' option requires an argument" 443005b261ecSmrg 44316747b715Smrg if test -n "$install_override_mode" && $no_mode; then 44326747b715Smrg if $install_cp; then :; else 4433c82838c1Smrg func_quote_arg pretty "$install_override_mode" 4434c82838c1Smrg func_append install_shared_prog " -m $func_quote_arg_result" 44356747b715Smrg fi 44366747b715Smrg fi 44376747b715Smrg 44384642e01fSmrg if test -z "$files"; then 44394642e01fSmrg if test -z "$dest"; then 44404642e01fSmrg func_fatal_help "no file or destination specified" 44414642e01fSmrg else 44424642e01fSmrg func_fatal_help "you must specify a destination" 44434642e01fSmrg fi 444405b261ecSmrg fi 444505b261ecSmrg 44464642e01fSmrg # Strip any trailing slash from the destination. 44474642e01fSmrg func_stripname '' '/' "$dest" 44484642e01fSmrg dest=$func_stripname_result 444905b261ecSmrg 44504642e01fSmrg # Check to see that the destination is a directory. 445135c4bbdfSmrg test -d "$dest" && isdir=: 445235c4bbdfSmrg if $isdir; then 445335c4bbdfSmrg destdir=$dest 44544642e01fSmrg destname= 445505b261ecSmrg else 44564642e01fSmrg func_dirname_and_basename "$dest" "" "." 445735c4bbdfSmrg destdir=$func_dirname_result 445835c4bbdfSmrg destname=$func_basename_result 445905b261ecSmrg 44604642e01fSmrg # Not a directory, so check to see that there is only one file specified. 44614642e01fSmrg set dummy $files; shift 44624642e01fSmrg test "$#" -gt 1 && \ 446335c4bbdfSmrg func_fatal_help "'$dest' is not a directory" 446405b261ecSmrg fi 44654642e01fSmrg case $destdir in 44664642e01fSmrg [\\/]* | [A-Za-z]:[\\/]*) ;; 446705b261ecSmrg *) 44684642e01fSmrg for file in $files; do 44694642e01fSmrg case $file in 44704642e01fSmrg *.lo) ;; 44714642e01fSmrg *) 447235c4bbdfSmrg func_fatal_help "'$destdir' must be an absolute directory name" 44734642e01fSmrg ;; 44744642e01fSmrg esac 44754642e01fSmrg done 447605b261ecSmrg ;; 447705b261ecSmrg esac 447805b261ecSmrg 44794642e01fSmrg # This variable tells wrapper scripts just to set variables rather 44804642e01fSmrg # than running their programs. 448135c4bbdfSmrg libtool_install_magic=$magic 448205b261ecSmrg 44834642e01fSmrg staticlibs= 44844642e01fSmrg future_libdirs= 44854642e01fSmrg current_libdirs= 44864642e01fSmrg for file in $files; do 448705b261ecSmrg 44884642e01fSmrg # Do each installation. 44894642e01fSmrg case $file in 44904642e01fSmrg *.$libext) 44914642e01fSmrg # Do the static libraries later. 449235c4bbdfSmrg func_append staticlibs " $file" 44934642e01fSmrg ;; 44944642e01fSmrg 44954642e01fSmrg *.la) 449635c4bbdfSmrg func_resolve_sysroot "$file" 449735c4bbdfSmrg file=$func_resolve_sysroot_result 449835c4bbdfSmrg 44994642e01fSmrg # Check to see that this really is a libtool archive. 45004642e01fSmrg func_lalib_unsafe_p "$file" \ 450135c4bbdfSmrg || func_fatal_help "'$file' is not a valid libtool archive" 45024642e01fSmrg 45034642e01fSmrg library_names= 45044642e01fSmrg old_library= 45054642e01fSmrg relink_command= 45064642e01fSmrg func_source "$file" 45074642e01fSmrg 45084642e01fSmrg # Add the libdir to current_libdirs if it is the destination. 45094642e01fSmrg if test "X$destdir" = "X$libdir"; then 45104642e01fSmrg case "$current_libdirs " in 45114642e01fSmrg *" $libdir "*) ;; 451235c4bbdfSmrg *) func_append current_libdirs " $libdir" ;; 451305b261ecSmrg esac 45144642e01fSmrg else 45154642e01fSmrg # Note the libdir as a future libdir. 45164642e01fSmrg case "$future_libdirs " in 45174642e01fSmrg *" $libdir "*) ;; 451835c4bbdfSmrg *) func_append future_libdirs " $libdir" ;; 45194642e01fSmrg esac 45204642e01fSmrg fi 452105b261ecSmrg 45224642e01fSmrg func_dirname "$file" "/" "" 452335c4bbdfSmrg dir=$func_dirname_result 452435c4bbdfSmrg func_append dir "$objdir" 45254642e01fSmrg 45264642e01fSmrg if test -n "$relink_command"; then 45274642e01fSmrg # Determine the prefix the user has applied to our future dir. 45286747b715Smrg inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` 45294642e01fSmrg 45304642e01fSmrg # Don't allow the user to place us outside of our expected 45314642e01fSmrg # location b/c this prevents finding dependent libraries that 45324642e01fSmrg # are installed to the same prefix. 45334642e01fSmrg # At present, this check doesn't affect windows .dll's that 45344642e01fSmrg # are installed into $libdir/../bin (currently, that works fine) 45354642e01fSmrg # but it's something to keep an eye on. 45364642e01fSmrg test "$inst_prefix_dir" = "$destdir" && \ 453735c4bbdfSmrg func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir" 45384642e01fSmrg 45394642e01fSmrg if test -n "$inst_prefix_dir"; then 45404642e01fSmrg # Stick the inst_prefix_dir data into the link command. 45416747b715Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` 45424642e01fSmrg else 45436747b715Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` 45444642e01fSmrg fi 45454642e01fSmrg 454635c4bbdfSmrg func_warning "relinking '$file'" 45474642e01fSmrg func_show_eval "$relink_command" \ 454835c4bbdfSmrg 'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"' 45494642e01fSmrg fi 45504642e01fSmrg 45514642e01fSmrg # See the names of the shared library. 45524642e01fSmrg set dummy $library_names; shift 45534642e01fSmrg if test -n "$1"; then 455435c4bbdfSmrg realname=$1 45554642e01fSmrg shift 45564642e01fSmrg 455735c4bbdfSmrg srcname=$realname 455835c4bbdfSmrg test -n "$relink_command" && srcname=${realname}T 45594642e01fSmrg 45604642e01fSmrg # Install the shared library and build the symlinks. 45616747b715Smrg func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ 45624642e01fSmrg 'exit $?' 456335c4bbdfSmrg tstripme=$stripme 45644642e01fSmrg case $host_os in 45654642e01fSmrg cygwin* | mingw* | pw32* | cegcc*) 45664642e01fSmrg case $realname in 45674642e01fSmrg *.dll.a) 456835c4bbdfSmrg tstripme= 456935c4bbdfSmrg ;; 457035c4bbdfSmrg esac 457135c4bbdfSmrg ;; 457235c4bbdfSmrg os2*) 457335c4bbdfSmrg case $realname in 457435c4bbdfSmrg *_dll.a) 457535c4bbdfSmrg tstripme= 45764642e01fSmrg ;; 45774642e01fSmrg esac 457805b261ecSmrg ;; 457905b261ecSmrg esac 45804642e01fSmrg if test -n "$tstripme" && test -n "$striplib"; then 45814642e01fSmrg func_show_eval "$striplib $destdir/$realname" 'exit $?' 458205b261ecSmrg fi 45834642e01fSmrg 45844642e01fSmrg if test "$#" -gt 0; then 45854642e01fSmrg # Delete the old symlinks, and create new ones. 458635c4bbdfSmrg # Try 'ln -sf' first, because the 'ln' binary might depend on 45874642e01fSmrg # the symlink we replace! Solaris /bin/ln does not understand -f, 45884642e01fSmrg # so we also need to try rm && ln -s. 45894642e01fSmrg for linkname 45904642e01fSmrg do 45914642e01fSmrg test "$linkname" != "$realname" \ 45924642e01fSmrg && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" 459305b261ecSmrg done 459405b261ecSmrg fi 459505b261ecSmrg 45964642e01fSmrg # Do each command in the postinstall commands. 459735c4bbdfSmrg lib=$destdir/$realname 45984642e01fSmrg func_execute_cmds "$postinstall_cmds" 'exit $?' 459905b261ecSmrg fi 460005b261ecSmrg 46014642e01fSmrg # Install the pseudo-library for information purposes. 46024642e01fSmrg func_basename "$file" 460335c4bbdfSmrg name=$func_basename_result 460435c4bbdfSmrg instname=$dir/${name}i 46054642e01fSmrg func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' 460605b261ecSmrg 46074642e01fSmrg # Maybe install the static library, too. 460835c4bbdfSmrg test -n "$old_library" && func_append staticlibs " $dir/$old_library" 46094642e01fSmrg ;; 461005b261ecSmrg 46114642e01fSmrg *.lo) 46124642e01fSmrg # Install (i.e. copy) a libtool object. 461305b261ecSmrg 46144642e01fSmrg # Figure out destination file name, if it wasn't already specified. 46154642e01fSmrg if test -n "$destname"; then 461635c4bbdfSmrg destfile=$destdir/$destname 46174642e01fSmrg else 46184642e01fSmrg func_basename "$file" 461935c4bbdfSmrg destfile=$func_basename_result 462035c4bbdfSmrg destfile=$destdir/$destfile 46214642e01fSmrg fi 46224642e01fSmrg 46234642e01fSmrg # Deduce the name of the destination old-style object file. 46244642e01fSmrg case $destfile in 46254642e01fSmrg *.lo) 46264642e01fSmrg func_lo2o "$destfile" 46274642e01fSmrg staticdest=$func_lo2o_result 46284642e01fSmrg ;; 46294642e01fSmrg *.$objext) 463035c4bbdfSmrg staticdest=$destfile 46314642e01fSmrg destfile= 46324642e01fSmrg ;; 46334642e01fSmrg *) 463435c4bbdfSmrg func_fatal_help "cannot copy a libtool object to '$destfile'" 46354642e01fSmrg ;; 463605b261ecSmrg esac 463705b261ecSmrg 46384642e01fSmrg # Install the libtool object if requested. 46394642e01fSmrg test -n "$destfile" && \ 46404642e01fSmrg func_show_eval "$install_prog $file $destfile" 'exit $?' 46414642e01fSmrg 46424642e01fSmrg # Install the old object if enabled. 464335c4bbdfSmrg if test yes = "$build_old_libs"; then 46444642e01fSmrg # Deduce the name of the old-style object file. 46454642e01fSmrg func_lo2o "$file" 46464642e01fSmrg staticobj=$func_lo2o_result 46474642e01fSmrg func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' 464805b261ecSmrg fi 46494642e01fSmrg exit $EXIT_SUCCESS 46504642e01fSmrg ;; 465105b261ecSmrg 46524642e01fSmrg *) 46534642e01fSmrg # Figure out destination file name, if it wasn't already specified. 46544642e01fSmrg if test -n "$destname"; then 465535c4bbdfSmrg destfile=$destdir/$destname 46564642e01fSmrg else 46574642e01fSmrg func_basename "$file" 465835c4bbdfSmrg destfile=$func_basename_result 465935c4bbdfSmrg destfile=$destdir/$destfile 46604642e01fSmrg fi 466105b261ecSmrg 46624642e01fSmrg # If the file is missing, and there is a .exe on the end, strip it 46634642e01fSmrg # because it is most likely a libtool script we actually want to 46644642e01fSmrg # install 466535c4bbdfSmrg stripped_ext= 46664642e01fSmrg case $file in 46674642e01fSmrg *.exe) 46684642e01fSmrg if test ! -f "$file"; then 46694642e01fSmrg func_stripname '' '.exe' "$file" 46704642e01fSmrg file=$func_stripname_result 467135c4bbdfSmrg stripped_ext=.exe 46724642e01fSmrg fi 46734642e01fSmrg ;; 46744642e01fSmrg esac 467505b261ecSmrg 46764642e01fSmrg # Do a test to see if this is really a libtool program. 46774642e01fSmrg case $host in 46784642e01fSmrg *cygwin* | *mingw*) 46794642e01fSmrg if func_ltwrapper_executable_p "$file"; then 46804642e01fSmrg func_ltwrapper_scriptname "$file" 46814642e01fSmrg wrapper=$func_ltwrapper_scriptname_result 46824642e01fSmrg else 46834642e01fSmrg func_stripname '' '.exe' "$file" 46844642e01fSmrg wrapper=$func_stripname_result 46854642e01fSmrg fi 46864642e01fSmrg ;; 46874642e01fSmrg *) 46884642e01fSmrg wrapper=$file 46894642e01fSmrg ;; 46904642e01fSmrg esac 46914642e01fSmrg if func_ltwrapper_script_p "$wrapper"; then 46924642e01fSmrg notinst_deplibs= 46934642e01fSmrg relink_command= 469405b261ecSmrg 46954642e01fSmrg func_source "$wrapper" 46964642e01fSmrg 46974642e01fSmrg # Check the variables that should have been set. 46984642e01fSmrg test -z "$generated_by_libtool_version" && \ 469935c4bbdfSmrg func_fatal_error "invalid libtool wrapper script '$wrapper'" 47004642e01fSmrg 470135c4bbdfSmrg finalize=: 47024642e01fSmrg for lib in $notinst_deplibs; do 47034642e01fSmrg # Check to see that each library is installed. 47044642e01fSmrg libdir= 47054642e01fSmrg if test -f "$lib"; then 47064642e01fSmrg func_source "$lib" 47074642e01fSmrg fi 470835c4bbdfSmrg libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'` 47094642e01fSmrg if test -n "$libdir" && test ! -f "$libfile"; then 471035c4bbdfSmrg func_warning "'$lib' has not been installed in '$libdir'" 471135c4bbdfSmrg finalize=false 47124642e01fSmrg fi 47134642e01fSmrg done 47144642e01fSmrg 47154642e01fSmrg relink_command= 47164642e01fSmrg func_source "$wrapper" 47174642e01fSmrg 47184642e01fSmrg outputname= 471935c4bbdfSmrg if test no = "$fast_install" && test -n "$relink_command"; then 47204642e01fSmrg $opt_dry_run || { 472135c4bbdfSmrg if $finalize; then 47224642e01fSmrg tmpdir=`func_mktempdir` 47234642e01fSmrg func_basename "$file$stripped_ext" 472435c4bbdfSmrg file=$func_basename_result 472535c4bbdfSmrg outputname=$tmpdir/$file 47264642e01fSmrg # Replace the output file specification. 47276747b715Smrg relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` 47284642e01fSmrg 472935c4bbdfSmrg $opt_quiet || { 4730c82838c1Smrg func_quote_arg expand,pretty "$relink_command" 4731c82838c1Smrg eval "func_echo $func_quote_arg_result" 47324642e01fSmrg } 47334642e01fSmrg if eval "$relink_command"; then : 47344642e01fSmrg else 473535c4bbdfSmrg func_error "error: relink '$file' with the above command before installing it" 47364642e01fSmrg $opt_dry_run || ${RM}r "$tmpdir" 47374642e01fSmrg continue 47384642e01fSmrg fi 473935c4bbdfSmrg file=$outputname 47404642e01fSmrg else 474135c4bbdfSmrg func_warning "cannot relink '$file'" 47424642e01fSmrg fi 47434642e01fSmrg } 474405b261ecSmrg else 47454642e01fSmrg # Install the binary that we compiled earlier. 47466747b715Smrg file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` 474705b261ecSmrg fi 47484642e01fSmrg fi 474905b261ecSmrg 47504642e01fSmrg # remove .exe since cygwin /usr/bin/install will append another 47514642e01fSmrg # one anyway 47524642e01fSmrg case $install_prog,$host in 47534642e01fSmrg */usr/bin/install*,*cygwin*) 47544642e01fSmrg case $file:$destfile in 47554642e01fSmrg *.exe:*.exe) 47564642e01fSmrg # this is ok 47574642e01fSmrg ;; 47584642e01fSmrg *.exe:*) 47594642e01fSmrg destfile=$destfile.exe 47604642e01fSmrg ;; 47614642e01fSmrg *:*.exe) 47624642e01fSmrg func_stripname '' '.exe' "$destfile" 47634642e01fSmrg destfile=$func_stripname_result 47644642e01fSmrg ;; 47654642e01fSmrg esac 476605b261ecSmrg ;; 476705b261ecSmrg esac 47684642e01fSmrg func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' 47694642e01fSmrg $opt_dry_run || if test -n "$outputname"; then 47704642e01fSmrg ${RM}r "$tmpdir" 47714642e01fSmrg fi 47724642e01fSmrg ;; 47734642e01fSmrg esac 47744642e01fSmrg done 477505b261ecSmrg 47764642e01fSmrg for file in $staticlibs; do 47774642e01fSmrg func_basename "$file" 477835c4bbdfSmrg name=$func_basename_result 47794642e01fSmrg 47804642e01fSmrg # Set up the ranlib parameters. 478135c4bbdfSmrg oldlib=$destdir/$name 478235c4bbdfSmrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 478335c4bbdfSmrg tool_oldlib=$func_to_tool_file_result 47844642e01fSmrg 47854642e01fSmrg func_show_eval "$install_prog \$file \$oldlib" 'exit $?' 47864642e01fSmrg 47874642e01fSmrg if test -n "$stripme" && test -n "$old_striplib"; then 478835c4bbdfSmrg func_show_eval "$old_striplib $tool_oldlib" 'exit $?' 47894642e01fSmrg fi 47904642e01fSmrg 47914642e01fSmrg # Do each command in the postinstall commands. 47924642e01fSmrg func_execute_cmds "$old_postinstall_cmds" 'exit $?' 47934642e01fSmrg done 47944642e01fSmrg 47954642e01fSmrg test -n "$future_libdirs" && \ 479635c4bbdfSmrg func_warning "remember to run '$progname --finish$future_libdirs'" 47974642e01fSmrg 47984642e01fSmrg if test -n "$current_libdirs"; then 47994642e01fSmrg # Maybe just do a dry run. 48004642e01fSmrg $opt_dry_run && current_libdirs=" -n$current_libdirs" 480135c4bbdfSmrg exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs' 48024642e01fSmrg else 48034642e01fSmrg exit $EXIT_SUCCESS 48044642e01fSmrg fi 48054642e01fSmrg} 48064642e01fSmrg 480735c4bbdfSmrgtest install = "$opt_mode" && func_mode_install ${1+"$@"} 48084642e01fSmrg 48094642e01fSmrg 48104642e01fSmrg# func_generate_dlsyms outputname originator pic_p 48114642e01fSmrg# Extract symbols from dlprefiles and create ${outputname}S.o with 48124642e01fSmrg# a dlpreopen symbol table. 48134642e01fSmrgfunc_generate_dlsyms () 48144642e01fSmrg{ 481535c4bbdfSmrg $debug_cmd 481635c4bbdfSmrg 481735c4bbdfSmrg my_outputname=$1 481835c4bbdfSmrg my_originator=$2 481935c4bbdfSmrg my_pic_p=${3-false} 482035c4bbdfSmrg my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'` 48214642e01fSmrg my_dlsyms= 48224642e01fSmrg 482335c4bbdfSmrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 48244642e01fSmrg if test -n "$NM" && test -n "$global_symbol_pipe"; then 482535c4bbdfSmrg my_dlsyms=${my_outputname}S.c 48264642e01fSmrg else 48274642e01fSmrg func_error "not configured to extract global symbols from dlpreopened files" 48284642e01fSmrg fi 48294642e01fSmrg fi 48304642e01fSmrg 48314642e01fSmrg if test -n "$my_dlsyms"; then 48324642e01fSmrg case $my_dlsyms in 48334642e01fSmrg "") ;; 48344642e01fSmrg *.c) 48354642e01fSmrg # Discover the nlist of each of the dlfiles. 483635c4bbdfSmrg nlist=$output_objdir/$my_outputname.nm 48374642e01fSmrg 48384642e01fSmrg func_show_eval "$RM $nlist ${nlist}S ${nlist}T" 48394642e01fSmrg 48404642e01fSmrg # Parse the name list into a source file. 48414642e01fSmrg func_verbose "creating $output_objdir/$my_dlsyms" 48424642e01fSmrg 48434642e01fSmrg $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ 484435c4bbdfSmrg/* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */ 484535c4bbdfSmrg/* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */ 48464642e01fSmrg 48474642e01fSmrg#ifdef __cplusplus 48484642e01fSmrgextern \"C\" { 48494642e01fSmrg#endif 48504642e01fSmrg 485135c4bbdfSmrg#if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) 48526747b715Smrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\" 48536747b715Smrg#endif 48546747b715Smrg 485535c4bbdfSmrg/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ 485635c4bbdfSmrg#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE 485735c4bbdfSmrg/* DATA imports from DLLs on WIN32 can't be const, because runtime 485835c4bbdfSmrg relocations are performed -- see ld's documentation on pseudo-relocs. */ 485935c4bbdfSmrg# define LT_DLSYM_CONST 486035c4bbdfSmrg#elif defined __osf__ 486135c4bbdfSmrg/* This system does not cope well with relocations in const data. */ 486235c4bbdfSmrg# define LT_DLSYM_CONST 486335c4bbdfSmrg#else 486435c4bbdfSmrg# define LT_DLSYM_CONST const 486535c4bbdfSmrg#endif 486635c4bbdfSmrg 486735c4bbdfSmrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 486835c4bbdfSmrg 48694642e01fSmrg/* External symbol declarations for the compiler. */\ 48704642e01fSmrg" 48714642e01fSmrg 487235c4bbdfSmrg if test yes = "$dlself"; then 487335c4bbdfSmrg func_verbose "generating symbol list for '$output'" 48744642e01fSmrg 48754642e01fSmrg $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" 48764642e01fSmrg 48774642e01fSmrg # Add our own program objects to the symbol list. 48786747b715Smrg progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` 48794642e01fSmrg for progfile in $progfiles; do 488035c4bbdfSmrg func_to_tool_file "$progfile" func_convert_file_msys_to_w32 488135c4bbdfSmrg func_verbose "extracting global C symbols from '$func_to_tool_file_result'" 488235c4bbdfSmrg $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" 48834642e01fSmrg done 48844642e01fSmrg 48854642e01fSmrg if test -n "$exclude_expsyms"; then 48864642e01fSmrg $opt_dry_run || { 48874642e01fSmrg eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' 48884642e01fSmrg eval '$MV "$nlist"T "$nlist"' 48894642e01fSmrg } 489005b261ecSmrg fi 48914642e01fSmrg 48924642e01fSmrg if test -n "$export_symbols_regex"; then 48934642e01fSmrg $opt_dry_run || { 48944642e01fSmrg eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' 48954642e01fSmrg eval '$MV "$nlist"T "$nlist"' 48964642e01fSmrg } 48974642e01fSmrg fi 48984642e01fSmrg 48994642e01fSmrg # Prepare the list of exported symbols 49004642e01fSmrg if test -z "$export_symbols"; then 490135c4bbdfSmrg export_symbols=$output_objdir/$outputname.exp 49024642e01fSmrg $opt_dry_run || { 49034642e01fSmrg $RM $export_symbols 490435c4bbdfSmrg eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' 49054642e01fSmrg case $host in 49064642e01fSmrg *cygwin* | *mingw* | *cegcc* ) 49074642e01fSmrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 49084642e01fSmrg eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' 49094642e01fSmrg ;; 49104642e01fSmrg esac 49114642e01fSmrg } 491205b261ecSmrg else 49134642e01fSmrg $opt_dry_run || { 491435c4bbdfSmrg eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' 49154642e01fSmrg eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' 49164642e01fSmrg eval '$MV "$nlist"T "$nlist"' 49174642e01fSmrg case $host in 49186747b715Smrg *cygwin* | *mingw* | *cegcc* ) 49194642e01fSmrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 49204642e01fSmrg eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' 49214642e01fSmrg ;; 49224642e01fSmrg esac 49234642e01fSmrg } 492405b261ecSmrg fi 49254642e01fSmrg fi 492605b261ecSmrg 49274642e01fSmrg for dlprefile in $dlprefiles; do 492835c4bbdfSmrg func_verbose "extracting global C symbols from '$dlprefile'" 49294642e01fSmrg func_basename "$dlprefile" 493035c4bbdfSmrg name=$func_basename_result 493135c4bbdfSmrg case $host in 493235c4bbdfSmrg *cygwin* | *mingw* | *cegcc* ) 493335c4bbdfSmrg # if an import library, we need to obtain dlname 493435c4bbdfSmrg if func_win32_import_lib_p "$dlprefile"; then 493535c4bbdfSmrg func_tr_sh "$dlprefile" 493635c4bbdfSmrg eval "curr_lafile=\$libfile_$func_tr_sh_result" 493735c4bbdfSmrg dlprefile_dlbasename= 493835c4bbdfSmrg if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then 493935c4bbdfSmrg # Use subshell, to avoid clobbering current variable values 494035c4bbdfSmrg dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` 494135c4bbdfSmrg if test -n "$dlprefile_dlname"; then 494235c4bbdfSmrg func_basename "$dlprefile_dlname" 494335c4bbdfSmrg dlprefile_dlbasename=$func_basename_result 494435c4bbdfSmrg else 494535c4bbdfSmrg # no lafile. user explicitly requested -dlpreopen <import library>. 494635c4bbdfSmrg $sharedlib_from_linklib_cmd "$dlprefile" 494735c4bbdfSmrg dlprefile_dlbasename=$sharedlib_from_linklib_result 494835c4bbdfSmrg fi 494935c4bbdfSmrg fi 495035c4bbdfSmrg $opt_dry_run || { 495135c4bbdfSmrg if test -n "$dlprefile_dlbasename"; then 495235c4bbdfSmrg eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' 495335c4bbdfSmrg else 495435c4bbdfSmrg func_warning "Could not compute DLL name from $name" 495535c4bbdfSmrg eval '$ECHO ": $name " >> "$nlist"' 495635c4bbdfSmrg fi 495735c4bbdfSmrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 495835c4bbdfSmrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | 495935c4bbdfSmrg $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" 496035c4bbdfSmrg } 496135c4bbdfSmrg else # not an import lib 496235c4bbdfSmrg $opt_dry_run || { 496335c4bbdfSmrg eval '$ECHO ": $name " >> "$nlist"' 496435c4bbdfSmrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 496535c4bbdfSmrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 496635c4bbdfSmrg } 496735c4bbdfSmrg fi 496835c4bbdfSmrg ;; 496935c4bbdfSmrg *) 497035c4bbdfSmrg $opt_dry_run || { 497135c4bbdfSmrg eval '$ECHO ": $name " >> "$nlist"' 497235c4bbdfSmrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 497335c4bbdfSmrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 497435c4bbdfSmrg } 497535c4bbdfSmrg ;; 497635c4bbdfSmrg esac 49774642e01fSmrg done 49784642e01fSmrg 49794642e01fSmrg $opt_dry_run || { 49804642e01fSmrg # Make sure we have at least an empty file. 49814642e01fSmrg test -f "$nlist" || : > "$nlist" 49824642e01fSmrg 49834642e01fSmrg if test -n "$exclude_expsyms"; then 49844642e01fSmrg $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T 49854642e01fSmrg $MV "$nlist"T "$nlist" 498605b261ecSmrg fi 49874642e01fSmrg 49884642e01fSmrg # Try sorting and uniquifying the output. 49894642e01fSmrg if $GREP -v "^: " < "$nlist" | 49904642e01fSmrg if sort -k 3 </dev/null >/dev/null 2>&1; then 49914642e01fSmrg sort -k 3 49924642e01fSmrg else 49934642e01fSmrg sort +2 49944642e01fSmrg fi | 49954642e01fSmrg uniq > "$nlist"S; then 49964642e01fSmrg : 499705b261ecSmrg else 49984642e01fSmrg $GREP -v "^: " < "$nlist" > "$nlist"S 499905b261ecSmrg fi 500005b261ecSmrg 50014642e01fSmrg if test -f "$nlist"S; then 50024642e01fSmrg eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' 500305b261ecSmrg else 50046747b715Smrg echo '/* NONE */' >> "$output_objdir/$my_dlsyms" 500505b261ecSmrg fi 500605b261ecSmrg 500735c4bbdfSmrg func_show_eval '$RM "${nlist}I"' 500835c4bbdfSmrg if test -n "$global_symbol_to_import"; then 500935c4bbdfSmrg eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I' 501035c4bbdfSmrg fi 501135c4bbdfSmrg 50126747b715Smrg echo >> "$output_objdir/$my_dlsyms" "\ 501305b261ecSmrg 50144642e01fSmrg/* The mapping between symbol names and symbols. */ 50154642e01fSmrgtypedef struct { 50164642e01fSmrg const char *name; 50174642e01fSmrg void *address; 50184642e01fSmrg} lt_dlsymlist; 501935c4bbdfSmrgextern LT_DLSYM_CONST lt_dlsymlist 502035c4bbdfSmrglt_${my_prefix}_LTX_preloaded_symbols[];\ 5021475c125cSmrg" 502235c4bbdfSmrg 502335c4bbdfSmrg if test -s "$nlist"I; then 5024475c125cSmrg echo >> "$output_objdir/$my_dlsyms" "\ 502535c4bbdfSmrgstatic void lt_syminit(void) 502635c4bbdfSmrg{ 502735c4bbdfSmrg LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols; 502835c4bbdfSmrg for (; symbol->name; ++symbol) 502935c4bbdfSmrg {" 503035c4bbdfSmrg $SED 's/.*/ if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms" 5031475c125cSmrg echo >> "$output_objdir/$my_dlsyms" "\ 503235c4bbdfSmrg } 503335c4bbdfSmrg}" 503435c4bbdfSmrg fi 5035475c125cSmrg echo >> "$output_objdir/$my_dlsyms" "\ 503635c4bbdfSmrgLT_DLSYM_CONST lt_dlsymlist 50374642e01fSmrglt_${my_prefix}_LTX_preloaded_symbols[] = 503835c4bbdfSmrg{ {\"$my_originator\", (void *) 0}," 503935c4bbdfSmrg 504035c4bbdfSmrg if test -s "$nlist"I; then 504135c4bbdfSmrg echo >> "$output_objdir/$my_dlsyms" "\ 504235c4bbdfSmrg {\"@INIT@\", (void *) <_syminit}," 504335c4bbdfSmrg fi 504405b261ecSmrg 50454642e01fSmrg case $need_lib_prefix in 50464642e01fSmrg no) 50474642e01fSmrg eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" 50484642e01fSmrg ;; 50494642e01fSmrg *) 50504642e01fSmrg eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" 50514642e01fSmrg ;; 50524642e01fSmrg esac 50536747b715Smrg echo >> "$output_objdir/$my_dlsyms" "\ 50544642e01fSmrg {0, (void *) 0} 50554642e01fSmrg}; 505605b261ecSmrg 50574642e01fSmrg/* This works around a problem in FreeBSD linker */ 50584642e01fSmrg#ifdef FREEBSD_WORKAROUND 50594642e01fSmrgstatic const void *lt_preloaded_setup() { 50604642e01fSmrg return lt_${my_prefix}_LTX_preloaded_symbols; 50614642e01fSmrg} 50624642e01fSmrg#endif 50634642e01fSmrg 50644642e01fSmrg#ifdef __cplusplus 50654642e01fSmrg} 50664642e01fSmrg#endif\ 50674642e01fSmrg" 50684642e01fSmrg } # !$opt_dry_run 50694642e01fSmrg 50704642e01fSmrg pic_flag_for_symtable= 50714642e01fSmrg case "$compile_command " in 50724642e01fSmrg *" -static "*) ;; 50734642e01fSmrg *) 50744642e01fSmrg case $host in 50754642e01fSmrg # compiling the symbol table file with pic_flag works around 50764642e01fSmrg # a FreeBSD bug that causes programs to crash when -lm is 50774642e01fSmrg # linked before any other PIC object. But we must not use 50784642e01fSmrg # pic_flag when linking with -static. The problem exists in 50794642e01fSmrg # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. 508035c4bbdfSmrg *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) 50814642e01fSmrg pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; 50824642e01fSmrg *-*-hpux*) 50834642e01fSmrg pic_flag_for_symtable=" $pic_flag" ;; 50844642e01fSmrg *) 508535c4bbdfSmrg $my_pic_p && pic_flag_for_symtable=" $pic_flag" 50864642e01fSmrg ;; 50874642e01fSmrg esac 50884642e01fSmrg ;; 50894642e01fSmrg esac 50904642e01fSmrg symtab_cflags= 50914642e01fSmrg for arg in $LTCFLAGS; do 50924642e01fSmrg case $arg in 50934642e01fSmrg -pie | -fpie | -fPIE) ;; 509435c4bbdfSmrg *) func_append symtab_cflags " $arg" ;; 50954642e01fSmrg esac 50964642e01fSmrg done 509705b261ecSmrg 50984642e01fSmrg # Now compile the dynamic symbol file. 50994642e01fSmrg func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' 510005b261ecSmrg 51014642e01fSmrg # Clean up the generated files. 510235c4bbdfSmrg func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"' 510305b261ecSmrg 51044642e01fSmrg # Transform the symbol file into the correct name. 510535c4bbdfSmrg symfileobj=$output_objdir/${my_outputname}S.$objext 51064642e01fSmrg case $host in 51074642e01fSmrg *cygwin* | *mingw* | *cegcc* ) 51084642e01fSmrg if test -f "$output_objdir/$my_outputname.def"; then 51096747b715Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 51106747b715Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 51114642e01fSmrg else 51126747b715Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 51136747b715Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 511405b261ecSmrg fi 51154642e01fSmrg ;; 51164642e01fSmrg *) 51176747b715Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 51186747b715Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 51194642e01fSmrg ;; 51204642e01fSmrg esac 51214642e01fSmrg ;; 51224642e01fSmrg *) 512335c4bbdfSmrg func_fatal_error "unknown suffix for '$my_dlsyms'" 51244642e01fSmrg ;; 51254642e01fSmrg esac 51264642e01fSmrg else 51274642e01fSmrg # We keep going just in case the user didn't refer to 51284642e01fSmrg # lt_preloaded_symbols. The linker will fail if global_symbol_pipe 51294642e01fSmrg # really was required. 513005b261ecSmrg 51314642e01fSmrg # Nullify the symbol file. 51326747b715Smrg compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` 51336747b715Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` 51344642e01fSmrg fi 51354642e01fSmrg} 513605b261ecSmrg 513735c4bbdfSmrg# func_cygming_gnu_implib_p ARG 513835c4bbdfSmrg# This predicate returns with zero status (TRUE) if 513935c4bbdfSmrg# ARG is a GNU/binutils-style import library. Returns 514035c4bbdfSmrg# with nonzero status (FALSE) otherwise. 514135c4bbdfSmrgfunc_cygming_gnu_implib_p () 514235c4bbdfSmrg{ 514335c4bbdfSmrg $debug_cmd 514435c4bbdfSmrg 514535c4bbdfSmrg func_to_tool_file "$1" func_convert_file_msys_to_w32 514635c4bbdfSmrg 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)$'` 514735c4bbdfSmrg test -n "$func_cygming_gnu_implib_tmp" 514835c4bbdfSmrg} 514935c4bbdfSmrg 515035c4bbdfSmrg# func_cygming_ms_implib_p ARG 515135c4bbdfSmrg# This predicate returns with zero status (TRUE) if 515235c4bbdfSmrg# ARG is an MS-style import library. Returns 515335c4bbdfSmrg# with nonzero status (FALSE) otherwise. 515435c4bbdfSmrgfunc_cygming_ms_implib_p () 515535c4bbdfSmrg{ 515635c4bbdfSmrg $debug_cmd 515735c4bbdfSmrg 515835c4bbdfSmrg func_to_tool_file "$1" func_convert_file_msys_to_w32 515935c4bbdfSmrg func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` 516035c4bbdfSmrg test -n "$func_cygming_ms_implib_tmp" 516135c4bbdfSmrg} 516235c4bbdfSmrg 51634642e01fSmrg# func_win32_libid arg 51644642e01fSmrg# return the library type of file 'arg' 51654642e01fSmrg# 51664642e01fSmrg# Need a lot of goo to handle *both* DLLs and import libs 51674642e01fSmrg# Has to be a shell function in order to 'eat' the argument 51684642e01fSmrg# that is supplied when $file_magic_command is called. 51696747b715Smrg# Despite the name, also deal with 64 bit binaries. 51704642e01fSmrgfunc_win32_libid () 51714642e01fSmrg{ 517235c4bbdfSmrg $debug_cmd 517335c4bbdfSmrg 517435c4bbdfSmrg win32_libid_type=unknown 51754642e01fSmrg win32_fileres=`file -L $1 2>/dev/null` 51764642e01fSmrg case $win32_fileres in 51774642e01fSmrg *ar\ archive\ import\ library*) # definitely import 51784642e01fSmrg win32_libid_type="x86 archive import" 51794642e01fSmrg ;; 51804642e01fSmrg *ar\ archive*) # could be an import, or static 51816747b715Smrg # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. 51824642e01fSmrg if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | 51836747b715Smrg $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then 518435c4bbdfSmrg case $nm_interface in 518535c4bbdfSmrg "MS dumpbin") 518635c4bbdfSmrg if func_cygming_ms_implib_p "$1" || 518735c4bbdfSmrg func_cygming_gnu_implib_p "$1" 518835c4bbdfSmrg then 518935c4bbdfSmrg win32_nmres=import 519035c4bbdfSmrg else 519135c4bbdfSmrg win32_nmres= 519235c4bbdfSmrg fi 519335c4bbdfSmrg ;; 519435c4bbdfSmrg *) 519535c4bbdfSmrg func_to_tool_file "$1" func_convert_file_msys_to_w32 519635c4bbdfSmrg win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | 519735c4bbdfSmrg $SED -n -e ' 51984642e01fSmrg 1,100{ 51994642e01fSmrg / I /{ 520035c4bbdfSmrg s|.*|import| 52014642e01fSmrg p 52024642e01fSmrg q 52034642e01fSmrg } 52044642e01fSmrg }'` 520535c4bbdfSmrg ;; 520635c4bbdfSmrg esac 52074642e01fSmrg case $win32_nmres in 52084642e01fSmrg import*) win32_libid_type="x86 archive import";; 52094642e01fSmrg *) win32_libid_type="x86 archive static";; 52104642e01fSmrg esac 52114642e01fSmrg fi 52124642e01fSmrg ;; 52134642e01fSmrg *DLL*) 52144642e01fSmrg win32_libid_type="x86 DLL" 52154642e01fSmrg ;; 52164642e01fSmrg *executable*) # but shell scripts are "executable" too... 52174642e01fSmrg case $win32_fileres in 52184642e01fSmrg *MS\ Windows\ PE\ Intel*) 52194642e01fSmrg win32_libid_type="x86 DLL" 52204642e01fSmrg ;; 52214642e01fSmrg esac 52224642e01fSmrg ;; 52234642e01fSmrg esac 52244642e01fSmrg $ECHO "$win32_libid_type" 52254642e01fSmrg} 522605b261ecSmrg 522735c4bbdfSmrg# func_cygming_dll_for_implib ARG 522835c4bbdfSmrg# 522935c4bbdfSmrg# Platform-specific function to extract the 523035c4bbdfSmrg# name of the DLL associated with the specified 523135c4bbdfSmrg# import library ARG. 523235c4bbdfSmrg# Invoked by eval'ing the libtool variable 523335c4bbdfSmrg# $sharedlib_from_linklib_cmd 523435c4bbdfSmrg# Result is available in the variable 523535c4bbdfSmrg# $sharedlib_from_linklib_result 523635c4bbdfSmrgfunc_cygming_dll_for_implib () 523735c4bbdfSmrg{ 523835c4bbdfSmrg $debug_cmd 523935c4bbdfSmrg 524035c4bbdfSmrg sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` 524135c4bbdfSmrg} 524235c4bbdfSmrg 524335c4bbdfSmrg# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs 524435c4bbdfSmrg# 524535c4bbdfSmrg# The is the core of a fallback implementation of a 524635c4bbdfSmrg# platform-specific function to extract the name of the 524735c4bbdfSmrg# DLL associated with the specified import library LIBNAME. 524835c4bbdfSmrg# 524935c4bbdfSmrg# SECTION_NAME is either .idata$6 or .idata$7, depending 525035c4bbdfSmrg# on the platform and compiler that created the implib. 525135c4bbdfSmrg# 525235c4bbdfSmrg# Echos the name of the DLL associated with the 525335c4bbdfSmrg# specified import library. 525435c4bbdfSmrgfunc_cygming_dll_for_implib_fallback_core () 525535c4bbdfSmrg{ 525635c4bbdfSmrg $debug_cmd 525735c4bbdfSmrg 525835c4bbdfSmrg match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` 525935c4bbdfSmrg $OBJDUMP -s --section "$1" "$2" 2>/dev/null | 526035c4bbdfSmrg $SED '/^Contents of section '"$match_literal"':/{ 526135c4bbdfSmrg # Place marker at beginning of archive member dllname section 526235c4bbdfSmrg s/.*/====MARK====/ 526335c4bbdfSmrg p 526435c4bbdfSmrg d 526535c4bbdfSmrg } 526635c4bbdfSmrg # These lines can sometimes be longer than 43 characters, but 526735c4bbdfSmrg # are always uninteresting 526835c4bbdfSmrg /:[ ]*file format pe[i]\{,1\}-/d 526935c4bbdfSmrg /^In archive [^:]*:/d 527035c4bbdfSmrg # Ensure marker is printed 527135c4bbdfSmrg /^====MARK====/p 527235c4bbdfSmrg # Remove all lines with less than 43 characters 527335c4bbdfSmrg /^.\{43\}/!d 527435c4bbdfSmrg # From remaining lines, remove first 43 characters 527535c4bbdfSmrg s/^.\{43\}//' | 527635c4bbdfSmrg $SED -n ' 527735c4bbdfSmrg # Join marker and all lines until next marker into a single line 527835c4bbdfSmrg /^====MARK====/ b para 527935c4bbdfSmrg H 528035c4bbdfSmrg $ b para 528135c4bbdfSmrg b 528235c4bbdfSmrg :para 528335c4bbdfSmrg x 528435c4bbdfSmrg s/\n//g 528535c4bbdfSmrg # Remove the marker 528635c4bbdfSmrg s/^====MARK====// 528735c4bbdfSmrg # Remove trailing dots and whitespace 528835c4bbdfSmrg s/[\. \t]*$// 528935c4bbdfSmrg # Print 529035c4bbdfSmrg /./p' | 529135c4bbdfSmrg # we now have a list, one entry per line, of the stringified 529235c4bbdfSmrg # contents of the appropriate section of all members of the 529335c4bbdfSmrg # archive that possess that section. Heuristic: eliminate 529435c4bbdfSmrg # all those that have a first or second character that is 529535c4bbdfSmrg # a '.' (that is, objdump's representation of an unprintable 529635c4bbdfSmrg # character.) This should work for all archives with less than 529735c4bbdfSmrg # 0x302f exports -- but will fail for DLLs whose name actually 529835c4bbdfSmrg # begins with a literal '.' or a single character followed by 529935c4bbdfSmrg # a '.'. 530035c4bbdfSmrg # 530135c4bbdfSmrg # Of those that remain, print the first one. 530235c4bbdfSmrg $SED -e '/^\./d;/^.\./d;q' 530335c4bbdfSmrg} 530435c4bbdfSmrg 530535c4bbdfSmrg# func_cygming_dll_for_implib_fallback ARG 530635c4bbdfSmrg# Platform-specific function to extract the 530735c4bbdfSmrg# name of the DLL associated with the specified 530835c4bbdfSmrg# import library ARG. 530935c4bbdfSmrg# 531035c4bbdfSmrg# This fallback implementation is for use when $DLLTOOL 531135c4bbdfSmrg# does not support the --identify-strict option. 531235c4bbdfSmrg# Invoked by eval'ing the libtool variable 531335c4bbdfSmrg# $sharedlib_from_linklib_cmd 531435c4bbdfSmrg# Result is available in the variable 531535c4bbdfSmrg# $sharedlib_from_linklib_result 531635c4bbdfSmrgfunc_cygming_dll_for_implib_fallback () 531735c4bbdfSmrg{ 531835c4bbdfSmrg $debug_cmd 531935c4bbdfSmrg 532035c4bbdfSmrg if func_cygming_gnu_implib_p "$1"; then 532135c4bbdfSmrg # binutils import library 532235c4bbdfSmrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` 532335c4bbdfSmrg elif func_cygming_ms_implib_p "$1"; then 532435c4bbdfSmrg # ms-generated import library 532535c4bbdfSmrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` 532635c4bbdfSmrg else 532735c4bbdfSmrg # unknown 532835c4bbdfSmrg sharedlib_from_linklib_result= 532935c4bbdfSmrg fi 533035c4bbdfSmrg} 533105b261ecSmrg 533205b261ecSmrg 53334642e01fSmrg# func_extract_an_archive dir oldlib 53344642e01fSmrgfunc_extract_an_archive () 53354642e01fSmrg{ 533635c4bbdfSmrg $debug_cmd 533735c4bbdfSmrg 533835c4bbdfSmrg f_ex_an_ar_dir=$1; shift 533935c4bbdfSmrg f_ex_an_ar_oldlib=$1 534035c4bbdfSmrg if test yes = "$lock_old_archive_extraction"; then 53416747b715Smrg lockfile=$f_ex_an_ar_oldlib.lock 53426747b715Smrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 53436747b715Smrg func_echo "Waiting for $lockfile to be removed" 53446747b715Smrg sleep 2 53456747b715Smrg done 53466747b715Smrg fi 53476747b715Smrg func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ 53486747b715Smrg 'stat=$?; rm -f "$lockfile"; exit $stat' 534935c4bbdfSmrg if test yes = "$lock_old_archive_extraction"; then 53506747b715Smrg $opt_dry_run || rm -f "$lockfile" 53516747b715Smrg fi 53524642e01fSmrg if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then 53534642e01fSmrg : 53544642e01fSmrg else 53554642e01fSmrg func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 53564642e01fSmrg fi 53574642e01fSmrg} 535805b261ecSmrg 535905b261ecSmrg 53604642e01fSmrg# func_extract_archives gentop oldlib ... 53614642e01fSmrgfunc_extract_archives () 53624642e01fSmrg{ 536335c4bbdfSmrg $debug_cmd 536435c4bbdfSmrg 536535c4bbdfSmrg my_gentop=$1; shift 53664642e01fSmrg my_oldlibs=${1+"$@"} 536735c4bbdfSmrg my_oldobjs= 536835c4bbdfSmrg my_xlib= 536935c4bbdfSmrg my_xabs= 537035c4bbdfSmrg my_xdir= 537105b261ecSmrg 53724642e01fSmrg for my_xlib in $my_oldlibs; do 53734642e01fSmrg # Extract the objects. 53744642e01fSmrg case $my_xlib in 537535c4bbdfSmrg [\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;; 53764642e01fSmrg *) my_xabs=`pwd`"/$my_xlib" ;; 53774642e01fSmrg esac 53784642e01fSmrg func_basename "$my_xlib" 537935c4bbdfSmrg my_xlib=$func_basename_result 53804642e01fSmrg my_xlib_u=$my_xlib 53814642e01fSmrg while :; do 53824642e01fSmrg case " $extracted_archives " in 53834642e01fSmrg *" $my_xlib_u "*) 53844642e01fSmrg func_arith $extracted_serial + 1 53854642e01fSmrg extracted_serial=$func_arith_result 53864642e01fSmrg my_xlib_u=lt$extracted_serial-$my_xlib ;; 53874642e01fSmrg *) break ;; 53884642e01fSmrg esac 53894642e01fSmrg done 53904642e01fSmrg extracted_archives="$extracted_archives $my_xlib_u" 539135c4bbdfSmrg my_xdir=$my_gentop/$my_xlib_u 539205b261ecSmrg 53934642e01fSmrg func_mkdir_p "$my_xdir" 539405b261ecSmrg 53954642e01fSmrg case $host in 53964642e01fSmrg *-darwin*) 53974642e01fSmrg func_verbose "Extracting $my_xabs" 53984642e01fSmrg # Do not bother doing anything if just a dry run 53994642e01fSmrg $opt_dry_run || { 54004642e01fSmrg darwin_orig_dir=`pwd` 54014642e01fSmrg cd $my_xdir || exit $? 54024642e01fSmrg darwin_archive=$my_xabs 54034642e01fSmrg darwin_curdir=`pwd` 540435c4bbdfSmrg func_basename "$darwin_archive" 540535c4bbdfSmrg darwin_base_archive=$func_basename_result 54064642e01fSmrg darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` 54074642e01fSmrg if test -n "$darwin_arches"; then 54084642e01fSmrg darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` 54094642e01fSmrg darwin_arch= 54104642e01fSmrg func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" 541135c4bbdfSmrg for darwin_arch in $darwin_arches; do 541235c4bbdfSmrg func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch" 541335c4bbdfSmrg $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive" 541435c4bbdfSmrg cd "unfat-$$/$darwin_base_archive-$darwin_arch" 541535c4bbdfSmrg func_extract_an_archive "`pwd`" "$darwin_base_archive" 54164642e01fSmrg cd "$darwin_curdir" 541735c4bbdfSmrg $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" 54184642e01fSmrg done # $darwin_arches 54194642e01fSmrg ## Okay now we've a bunch of thin objects, gotta fatten them up :) 542035c4bbdfSmrg darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$sed_basename" | sort -u` 54214642e01fSmrg darwin_file= 54224642e01fSmrg darwin_files= 54234642e01fSmrg for darwin_file in $darwin_filelist; do 54246747b715Smrg darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` 54254642e01fSmrg $LIPO -create -output "$darwin_file" $darwin_files 54264642e01fSmrg done # $darwin_filelist 54274642e01fSmrg $RM -rf unfat-$$ 54284642e01fSmrg cd "$darwin_orig_dir" 542905b261ecSmrg else 54304642e01fSmrg cd $darwin_orig_dir 54314642e01fSmrg func_extract_an_archive "$my_xdir" "$my_xabs" 54324642e01fSmrg fi # $darwin_arches 54334642e01fSmrg } # !$opt_dry_run 54344642e01fSmrg ;; 54354642e01fSmrg *) 54364642e01fSmrg func_extract_an_archive "$my_xdir" "$my_xabs" 54374642e01fSmrg ;; 54384642e01fSmrg esac 54396747b715Smrg my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` 54404642e01fSmrg done 544105b261ecSmrg 544235c4bbdfSmrg func_extract_archives_result=$my_oldobjs 54434642e01fSmrg} 544405b261ecSmrg 544505b261ecSmrg 54466747b715Smrg# func_emit_wrapper [arg=no] 54476747b715Smrg# 54486747b715Smrg# Emit a libtool wrapper script on stdout. 54496747b715Smrg# Don't directly open a file because we may want to 54506747b715Smrg# incorporate the script contents within a cygwin/mingw 54516747b715Smrg# wrapper executable. Must ONLY be called from within 54526747b715Smrg# func_mode_link because it depends on a number of variables 54536747b715Smrg# set therein. 54544642e01fSmrg# 54556747b715Smrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR 54566747b715Smrg# variable will take. If 'yes', then the emitted script 545735c4bbdfSmrg# will assume that the directory where it is stored is 54586747b715Smrg# the $objdir directory. This is a cygwin/mingw-specific 54596747b715Smrg# behavior. 54606747b715Smrgfunc_emit_wrapper () 54614642e01fSmrg{ 54626747b715Smrg func_emit_wrapper_arg1=${1-no} 546305b261ecSmrg 54644642e01fSmrg $ECHO "\ 54654642e01fSmrg#! $SHELL 546605b261ecSmrg 54674642e01fSmrg# $output - temporary wrapper script for $objdir/$outputname 546835c4bbdfSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 54694642e01fSmrg# 54704642e01fSmrg# The $output program cannot be directly executed until all the libtool 54714642e01fSmrg# libraries that it depends on are installed. 54724642e01fSmrg# 54734642e01fSmrg# This wrapper script should never be moved out of the build directory. 54744642e01fSmrg# If it is, it will not operate correctly. 547505b261ecSmrg 54764642e01fSmrg# Sed substitution that helps us do robust quoting. It backslashifies 54774642e01fSmrg# metacharacters that are still active within double-quoted strings. 54784642e01fSmrgsed_quote_subst='$sed_quote_subst' 547905b261ecSmrg 54804642e01fSmrg# Be Bourne compatible 54814642e01fSmrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then 54824642e01fSmrg emulate sh 54834642e01fSmrg NULLCMD=: 54844642e01fSmrg # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which 54854642e01fSmrg # is contrary to our usage. Disable this feature. 54864642e01fSmrg alias -g '\${1+\"\$@\"}'='\"\$@\"' 54874642e01fSmrg setopt NO_GLOB_SUBST 54884642e01fSmrgelse 54894642e01fSmrg case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac 54904642e01fSmrgfi 54914642e01fSmrgBIN_SH=xpg4; export BIN_SH # for Tru64 54924642e01fSmrgDUALCASE=1; export DUALCASE # for MKS sh 549305b261ecSmrg 54944642e01fSmrg# The HP-UX ksh and POSIX shell print the target directory to stdout 54954642e01fSmrg# if CDPATH is set. 54964642e01fSmrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 549705b261ecSmrg 54984642e01fSmrgrelink_command=\"$relink_command\" 549905b261ecSmrg 55004642e01fSmrg# This environment variable determines our operation mode. 55014642e01fSmrgif test \"\$libtool_install_magic\" = \"$magic\"; then 55024642e01fSmrg # install mode needs the following variables: 55034642e01fSmrg generated_by_libtool_version='$macro_version' 55044642e01fSmrg notinst_deplibs='$notinst_deplibs' 55054642e01fSmrgelse 55064642e01fSmrg # When we are sourced in execute mode, \$file and \$ECHO are already set. 55074642e01fSmrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 55086747b715Smrg file=\"\$0\"" 55096747b715Smrg 5510c82838c1Smrg func_quote_arg pretty "$ECHO" 5511c82838c1Smrg qECHO=$func_quote_arg_result 55126747b715Smrg $ECHO "\ 55136747b715Smrg 55146747b715Smrg# A function that is used when there is no print builtin or printf. 55156747b715Smrgfunc_fallback_echo () 55166747b715Smrg{ 55176747b715Smrg eval 'cat <<_LTECHO_EOF 55186747b715Smrg\$1 55196747b715Smrg_LTECHO_EOF' 55206747b715Smrg} 5521c82838c1Smrg ECHO=$qECHO 55226747b715Smrg fi 55236747b715Smrg 55246747b715Smrg# Very basic option parsing. These options are (a) specific to 55256747b715Smrg# the libtool wrapper, (b) are identical between the wrapper 552635c4bbdfSmrg# /script/ and the wrapper /executable/ that is used only on 55276747b715Smrg# windows platforms, and (c) all begin with the string "--lt-" 552835c4bbdfSmrg# (application programs are unlikely to have options that match 55296747b715Smrg# this pattern). 55306747b715Smrg# 55316747b715Smrg# There are only two supported options: --lt-debug and 55326747b715Smrg# --lt-dump-script. There is, deliberately, no --lt-help. 55336747b715Smrg# 55346747b715Smrg# The first argument to this parsing function should be the 55356747b715Smrg# script's $0 value, followed by "$@". 55366747b715Smrglt_option_debug= 55376747b715Smrgfunc_parse_lt_options () 55386747b715Smrg{ 55396747b715Smrg lt_script_arg0=\$0 55406747b715Smrg shift 55416747b715Smrg for lt_opt 55426747b715Smrg do 55436747b715Smrg case \"\$lt_opt\" in 55446747b715Smrg --lt-debug) lt_option_debug=1 ;; 55456747b715Smrg --lt-dump-script) 55466747b715Smrg lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` 55476747b715Smrg test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. 55486747b715Smrg lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` 55496747b715Smrg cat \"\$lt_dump_D/\$lt_dump_F\" 55506747b715Smrg exit 0 55516747b715Smrg ;; 55526747b715Smrg --lt-*) 55536747b715Smrg \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 55546747b715Smrg exit 1 55556747b715Smrg ;; 55566747b715Smrg esac 55576747b715Smrg done 55586747b715Smrg 55596747b715Smrg # Print the debug banner immediately: 55606747b715Smrg if test -n \"\$lt_option_debug\"; then 556135c4bbdfSmrg echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2 55626747b715Smrg fi 55636747b715Smrg} 55646747b715Smrg 55656747b715Smrg# Used when --lt-debug. Prints its arguments to stdout 55666747b715Smrg# (redirection is the responsibility of the caller) 55676747b715Smrgfunc_lt_dump_args () 55686747b715Smrg{ 55696747b715Smrg lt_dump_args_N=1; 55706747b715Smrg for lt_arg 55716747b715Smrg do 557235c4bbdfSmrg \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\" 55736747b715Smrg lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` 55746747b715Smrg done 55756747b715Smrg} 55766747b715Smrg 55776747b715Smrg# Core function for launching the target application 55786747b715Smrgfunc_exec_program_core () 55796747b715Smrg{ 55804642e01fSmrg" 55816747b715Smrg case $host in 55826747b715Smrg # Backslashes separate directories on plain windows 55836747b715Smrg *-*-mingw | *-*-os2* | *-cegcc*) 55846747b715Smrg $ECHO "\ 55856747b715Smrg if test -n \"\$lt_option_debug\"; then 558635c4bbdfSmrg \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2 55876747b715Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 55886747b715Smrg fi 55896747b715Smrg exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} 55906747b715Smrg" 55916747b715Smrg ;; 55926747b715Smrg 55936747b715Smrg *) 55946747b715Smrg $ECHO "\ 55956747b715Smrg if test -n \"\$lt_option_debug\"; then 559635c4bbdfSmrg \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2 55976747b715Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 55986747b715Smrg fi 55996747b715Smrg exec \"\$progdir/\$program\" \${1+\"\$@\"} 56006747b715Smrg" 56016747b715Smrg ;; 56026747b715Smrg esac 56036747b715Smrg $ECHO "\ 56046747b715Smrg \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 56056747b715Smrg exit 1 56066747b715Smrg} 56076747b715Smrg 56086747b715Smrg# A function to encapsulate launching the target application 56096747b715Smrg# Strips options in the --lt-* namespace from \$@ and 56106747b715Smrg# launches target application with the remaining arguments. 56116747b715Smrgfunc_exec_program () 56126747b715Smrg{ 561335c4bbdfSmrg case \" \$* \" in 561435c4bbdfSmrg *\\ --lt-*) 561535c4bbdfSmrg for lt_wr_arg 561635c4bbdfSmrg do 561735c4bbdfSmrg case \$lt_wr_arg in 561835c4bbdfSmrg --lt-*) ;; 561935c4bbdfSmrg *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; 562035c4bbdfSmrg esac 562135c4bbdfSmrg shift 562235c4bbdfSmrg done ;; 562335c4bbdfSmrg esac 56246747b715Smrg func_exec_program_core \${1+\"\$@\"} 56256747b715Smrg} 56266747b715Smrg 56276747b715Smrg # Parse options 56286747b715Smrg func_parse_lt_options \"\$0\" \${1+\"\$@\"} 562905b261ecSmrg 56304642e01fSmrg # Find the directory that this script lives in. 56316747b715Smrg thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` 56324642e01fSmrg test \"x\$thisdir\" = \"x\$file\" && thisdir=. 563305b261ecSmrg 56344642e01fSmrg # Follow symbolic links until we get to the real thisdir. 56356747b715Smrg file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` 56364642e01fSmrg while test -n \"\$file\"; do 56376747b715Smrg destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` 563805b261ecSmrg 56394642e01fSmrg # If there was a directory component, then change thisdir. 56404642e01fSmrg if test \"x\$destdir\" != \"x\$file\"; then 56414642e01fSmrg case \"\$destdir\" in 56424642e01fSmrg [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; 56434642e01fSmrg *) thisdir=\"\$thisdir/\$destdir\" ;; 564405b261ecSmrg esac 56454642e01fSmrg fi 564605b261ecSmrg 56476747b715Smrg file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` 56486747b715Smrg file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` 56494642e01fSmrg done 565005b261ecSmrg 56514642e01fSmrg # Usually 'no', except on cygwin/mingw when embedded into 56524642e01fSmrg # the cwrapper. 56536747b715Smrg WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 56544642e01fSmrg if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then 56554642e01fSmrg # special case for '.' 56564642e01fSmrg if test \"\$thisdir\" = \".\"; then 56574642e01fSmrg thisdir=\`pwd\` 56584642e01fSmrg fi 56594642e01fSmrg # remove .libs from thisdir 56604642e01fSmrg case \"\$thisdir\" in 56616747b715Smrg *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; 56624642e01fSmrg $objdir ) thisdir=. ;; 56634642e01fSmrg esac 56644642e01fSmrg fi 56654642e01fSmrg 56664642e01fSmrg # Try to get the absolute directory name. 56674642e01fSmrg absdir=\`cd \"\$thisdir\" && pwd\` 56684642e01fSmrg test -n \"\$absdir\" && thisdir=\"\$absdir\" 56694642e01fSmrg" 56704642e01fSmrg 567135c4bbdfSmrg if test yes = "$fast_install"; then 56724642e01fSmrg $ECHO "\ 56734642e01fSmrg program=lt-'$outputname'$exeext 56744642e01fSmrg progdir=\"\$thisdir/$objdir\" 56754642e01fSmrg 56764642e01fSmrg if test ! -f \"\$progdir/\$program\" || 567735c4bbdfSmrg { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\ 56784642e01fSmrg test \"X\$file\" != \"X\$progdir/\$program\"; }; then 56794642e01fSmrg 56804642e01fSmrg file=\"\$\$-\$program\" 56814642e01fSmrg 56824642e01fSmrg if test ! -d \"\$progdir\"; then 56834642e01fSmrg $MKDIR \"\$progdir\" 56844642e01fSmrg else 56854642e01fSmrg $RM \"\$progdir/\$file\" 56864642e01fSmrg fi" 56874642e01fSmrg 56884642e01fSmrg $ECHO "\ 56894642e01fSmrg 56904642e01fSmrg # relink executable if necessary 56914642e01fSmrg if test -n \"\$relink_command\"; then 56924642e01fSmrg if relink_command_output=\`eval \$relink_command 2>&1\`; then : 56934642e01fSmrg else 569435c4bbdfSmrg \$ECHO \"\$relink_command_output\" >&2 56954642e01fSmrg $RM \"\$progdir/\$file\" 56964642e01fSmrg exit 1 569705b261ecSmrg fi 56984642e01fSmrg fi 569905b261ecSmrg 57004642e01fSmrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || 57014642e01fSmrg { $RM \"\$progdir/\$program\"; 57024642e01fSmrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } 57034642e01fSmrg $RM \"\$progdir/\$file\" 57044642e01fSmrg fi" 57054642e01fSmrg else 57064642e01fSmrg $ECHO "\ 57074642e01fSmrg program='$outputname' 57084642e01fSmrg progdir=\"\$thisdir/$objdir\" 57094642e01fSmrg" 571005b261ecSmrg fi 571105b261ecSmrg 57124642e01fSmrg $ECHO "\ 571305b261ecSmrg 57144642e01fSmrg if test -f \"\$progdir/\$program\"; then" 571505b261ecSmrg 571635c4bbdfSmrg # fixup the dll searchpath if we need to. 571735c4bbdfSmrg # 571835c4bbdfSmrg # Fix the DLL searchpath if we need to. Do this before prepending 571935c4bbdfSmrg # to shlibpath, because on Windows, both are PATH and uninstalled 572035c4bbdfSmrg # libraries must come first. 572135c4bbdfSmrg if test -n "$dllsearchpath"; then 572235c4bbdfSmrg $ECHO "\ 572335c4bbdfSmrg # Add the dll search path components to the executable PATH 572435c4bbdfSmrg PATH=$dllsearchpath:\$PATH 572535c4bbdfSmrg" 572635c4bbdfSmrg fi 572735c4bbdfSmrg 57284642e01fSmrg # Export our shlibpath_var if we have one. 572935c4bbdfSmrg if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 57304642e01fSmrg $ECHO "\ 57314642e01fSmrg # Add our own library path to $shlibpath_var 57324642e01fSmrg $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" 573305b261ecSmrg 57344642e01fSmrg # Some systems cannot cope with colon-terminated $shlibpath_var 57354642e01fSmrg # The second colon is a workaround for a bug in BeOS R4 sed 57366747b715Smrg $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` 57374642e01fSmrg 57384642e01fSmrg export $shlibpath_var 57394642e01fSmrg" 574005b261ecSmrg fi 574105b261ecSmrg 57424642e01fSmrg $ECHO "\ 57434642e01fSmrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 57444642e01fSmrg # Run the actual program with our arguments. 57456747b715Smrg func_exec_program \${1+\"\$@\"} 57464642e01fSmrg fi 57474642e01fSmrg else 57484642e01fSmrg # The program doesn't exist. 574935c4bbdfSmrg \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2 57504642e01fSmrg \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 57516747b715Smrg \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 57524642e01fSmrg exit 1 57534642e01fSmrg fi 57544642e01fSmrgfi\ 57554642e01fSmrg" 57564642e01fSmrg} 575705b261ecSmrg 575805b261ecSmrg 57594642e01fSmrg# func_emit_cwrapperexe_src 57604642e01fSmrg# emit the source code for a wrapper executable on stdout 57614642e01fSmrg# Must ONLY be called from within func_mode_link because 57624642e01fSmrg# it depends on a number of variable set therein. 57634642e01fSmrgfunc_emit_cwrapperexe_src () 57644642e01fSmrg{ 57654642e01fSmrg cat <<EOF 576605b261ecSmrg 57674642e01fSmrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname 576835c4bbdfSmrg Generated by $PROGRAM (GNU $PACKAGE) $VERSION 576905b261ecSmrg 57704642e01fSmrg The $output program cannot be directly executed until all the libtool 57714642e01fSmrg libraries that it depends on are installed. 577205b261ecSmrg 57734642e01fSmrg This wrapper executable should never be moved out of the build directory. 57744642e01fSmrg If it is, it will not operate correctly. 57754642e01fSmrg*/ 57764642e01fSmrgEOF 57774642e01fSmrg cat <<"EOF" 57786747b715Smrg#ifdef _MSC_VER 57796747b715Smrg# define _CRT_SECURE_NO_DEPRECATE 1 57806747b715Smrg#endif 57814642e01fSmrg#include <stdio.h> 57824642e01fSmrg#include <stdlib.h> 57834642e01fSmrg#ifdef _MSC_VER 57844642e01fSmrg# include <direct.h> 57854642e01fSmrg# include <process.h> 57864642e01fSmrg# include <io.h> 57874642e01fSmrg#else 57884642e01fSmrg# include <unistd.h> 57894642e01fSmrg# include <stdint.h> 57904642e01fSmrg# ifdef __CYGWIN__ 57914642e01fSmrg# include <io.h> 57926747b715Smrg# endif 57936747b715Smrg#endif 57946747b715Smrg#include <malloc.h> 57956747b715Smrg#include <stdarg.h> 57966747b715Smrg#include <assert.h> 57976747b715Smrg#include <string.h> 57986747b715Smrg#include <ctype.h> 57996747b715Smrg#include <errno.h> 58006747b715Smrg#include <fcntl.h> 58016747b715Smrg#include <sys/stat.h> 58026747b715Smrg 580335c4bbdfSmrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 580435c4bbdfSmrg 58056747b715Smrg/* declarations of non-ANSI functions */ 580635c4bbdfSmrg#if defined __MINGW32__ 58076747b715Smrg# ifdef __STRICT_ANSI__ 58086747b715Smrgint _putenv (const char *); 58096747b715Smrg# endif 581035c4bbdfSmrg#elif defined __CYGWIN__ 58116747b715Smrg# ifdef __STRICT_ANSI__ 58124642e01fSmrgchar *realpath (const char *, char *); 58134642e01fSmrgint putenv (char *); 58144642e01fSmrgint setenv (const char *, const char *, int); 58154642e01fSmrg# endif 581635c4bbdfSmrg/* #elif defined other_platform || defined ... */ 58176747b715Smrg#endif 58186747b715Smrg 58196747b715Smrg/* portability defines, excluding path handling macros */ 582035c4bbdfSmrg#if defined _MSC_VER 58216747b715Smrg# define setmode _setmode 58226747b715Smrg# define stat _stat 58236747b715Smrg# define chmod _chmod 58246747b715Smrg# define getcwd _getcwd 58256747b715Smrg# define putenv _putenv 58266747b715Smrg# define S_IXUSR _S_IEXEC 582735c4bbdfSmrg#elif defined __MINGW32__ 58286747b715Smrg# define setmode _setmode 58296747b715Smrg# define stat _stat 58306747b715Smrg# define chmod _chmod 58316747b715Smrg# define getcwd _getcwd 58326747b715Smrg# define putenv _putenv 583335c4bbdfSmrg#elif defined __CYGWIN__ 58346747b715Smrg# define HAVE_SETENV 58356747b715Smrg# define FOPEN_WB "wb" 583635c4bbdfSmrg/* #elif defined other platforms ... */ 58374642e01fSmrg#endif 583805b261ecSmrg 583935c4bbdfSmrg#if defined PATH_MAX 58404642e01fSmrg# define LT_PATHMAX PATH_MAX 584135c4bbdfSmrg#elif defined MAXPATHLEN 58424642e01fSmrg# define LT_PATHMAX MAXPATHLEN 58434642e01fSmrg#else 58444642e01fSmrg# define LT_PATHMAX 1024 58454642e01fSmrg#endif 584605b261ecSmrg 58474642e01fSmrg#ifndef S_IXOTH 58484642e01fSmrg# define S_IXOTH 0 58494642e01fSmrg#endif 58504642e01fSmrg#ifndef S_IXGRP 58514642e01fSmrg# define S_IXGRP 0 58524642e01fSmrg#endif 585305b261ecSmrg 58546747b715Smrg/* path handling portability macros */ 58554642e01fSmrg#ifndef DIR_SEPARATOR 58564642e01fSmrg# define DIR_SEPARATOR '/' 58574642e01fSmrg# define PATH_SEPARATOR ':' 58584642e01fSmrg#endif 585905b261ecSmrg 586035c4bbdfSmrg#if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \ 586135c4bbdfSmrg defined __OS2__ 58624642e01fSmrg# define HAVE_DOS_BASED_FILE_SYSTEM 58634642e01fSmrg# define FOPEN_WB "wb" 58644642e01fSmrg# ifndef DIR_SEPARATOR_2 58654642e01fSmrg# define DIR_SEPARATOR_2 '\\' 58664642e01fSmrg# endif 58674642e01fSmrg# ifndef PATH_SEPARATOR_2 58684642e01fSmrg# define PATH_SEPARATOR_2 ';' 58694642e01fSmrg# endif 58704642e01fSmrg#endif 587105b261ecSmrg 58724642e01fSmrg#ifndef DIR_SEPARATOR_2 58734642e01fSmrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) 58744642e01fSmrg#else /* DIR_SEPARATOR_2 */ 58754642e01fSmrg# define IS_DIR_SEPARATOR(ch) \ 58764642e01fSmrg (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) 58774642e01fSmrg#endif /* DIR_SEPARATOR_2 */ 587805b261ecSmrg 58794642e01fSmrg#ifndef PATH_SEPARATOR_2 58804642e01fSmrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) 58814642e01fSmrg#else /* PATH_SEPARATOR_2 */ 58824642e01fSmrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) 58834642e01fSmrg#endif /* PATH_SEPARATOR_2 */ 588405b261ecSmrg 58854642e01fSmrg#ifndef FOPEN_WB 58864642e01fSmrg# define FOPEN_WB "w" 58874642e01fSmrg#endif 58884642e01fSmrg#ifndef _O_BINARY 58894642e01fSmrg# define _O_BINARY 0 58904642e01fSmrg#endif 589105b261ecSmrg 58924642e01fSmrg#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) 58934642e01fSmrg#define XFREE(stale) do { \ 589435c4bbdfSmrg if (stale) { free (stale); stale = 0; } \ 58954642e01fSmrg} while (0) 589605b261ecSmrg 589735c4bbdfSmrg#if defined LT_DEBUGWRAPPER 58986747b715Smrgstatic int lt_debug = 1; 58994642e01fSmrg#else 59006747b715Smrgstatic int lt_debug = 0; 59014642e01fSmrg#endif 590205b261ecSmrg 59036747b715Smrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ 590405b261ecSmrg 59054642e01fSmrgvoid *xmalloc (size_t num); 59064642e01fSmrgchar *xstrdup (const char *string); 59074642e01fSmrgconst char *base_name (const char *name); 59084642e01fSmrgchar *find_executable (const char *wrapper); 59094642e01fSmrgchar *chase_symlinks (const char *pathspec); 59104642e01fSmrgint make_executable (const char *path); 59114642e01fSmrgint check_executable (const char *path); 59124642e01fSmrgchar *strendzap (char *str, const char *pat); 59136747b715Smrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...); 59146747b715Smrgvoid lt_fatal (const char *file, int line, const char *message, ...); 59156747b715Smrgstatic const char *nonnull (const char *s); 59166747b715Smrgstatic const char *nonempty (const char *s); 59174642e01fSmrgvoid lt_setenv (const char *name, const char *value); 59184642e01fSmrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end); 59194642e01fSmrgvoid lt_update_exe_path (const char *name, const char *value); 59204642e01fSmrgvoid lt_update_lib_path (const char *name, const char *value); 59216747b715Smrgchar **prepare_spawn (char **argv); 59226747b715Smrgvoid lt_dump_script (FILE *f); 59234642e01fSmrgEOF 59244642e01fSmrg 59254642e01fSmrg cat <<EOF 592635c4bbdfSmrg#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5) 592735c4bbdfSmrg# define externally_visible volatile 592835c4bbdfSmrg#else 592935c4bbdfSmrg# define externally_visible __attribute__((externally_visible)) volatile 593035c4bbdfSmrg#endif 593135c4bbdfSmrgexternally_visible const char * MAGIC_EXE = "$magic_exe"; 59324642e01fSmrgconst char * LIB_PATH_VARNAME = "$shlibpath_var"; 59334642e01fSmrgEOF 593405b261ecSmrg 593535c4bbdfSmrg if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 593635c4bbdfSmrg func_to_host_path "$temp_rpath" 59374642e01fSmrg cat <<EOF 593835c4bbdfSmrgconst char * LIB_PATH_VALUE = "$func_to_host_path_result"; 59394642e01fSmrgEOF 59404642e01fSmrg else 59414642e01fSmrg cat <<"EOF" 59424642e01fSmrgconst char * LIB_PATH_VALUE = ""; 59434642e01fSmrgEOF 594405b261ecSmrg fi 594505b261ecSmrg 59464642e01fSmrg if test -n "$dllsearchpath"; then 594735c4bbdfSmrg func_to_host_path "$dllsearchpath:" 59484642e01fSmrg cat <<EOF 59494642e01fSmrgconst char * EXE_PATH_VARNAME = "PATH"; 595035c4bbdfSmrgconst char * EXE_PATH_VALUE = "$func_to_host_path_result"; 595105b261ecSmrgEOF 595205b261ecSmrg else 59534642e01fSmrg cat <<"EOF" 59544642e01fSmrgconst char * EXE_PATH_VARNAME = ""; 59554642e01fSmrgconst char * EXE_PATH_VALUE = ""; 59564642e01fSmrgEOF 595705b261ecSmrg fi 59584642e01fSmrg 595935c4bbdfSmrg if test yes = "$fast_install"; then 59604642e01fSmrg cat <<EOF 59614642e01fSmrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */ 59624642e01fSmrgEOF 596305b261ecSmrg else 59644642e01fSmrg cat <<EOF 59654642e01fSmrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */ 59664642e01fSmrgEOF 596705b261ecSmrg fi 596805b261ecSmrg 596905b261ecSmrg 59704642e01fSmrg cat <<"EOF" 597105b261ecSmrg 59724642e01fSmrg#define LTWRAPPER_OPTION_PREFIX "--lt-" 597305b261ecSmrg 59744642e01fSmrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX; 59754642e01fSmrgstatic const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script"; 59766747b715Smrgstatic const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug"; 597705b261ecSmrg 59784642e01fSmrgint 59794642e01fSmrgmain (int argc, char *argv[]) 59804642e01fSmrg{ 59814642e01fSmrg char **newargz; 59824642e01fSmrg int newargc; 59834642e01fSmrg char *tmp_pathspec; 59844642e01fSmrg char *actual_cwrapper_path; 59854642e01fSmrg char *actual_cwrapper_name; 59864642e01fSmrg char *target_name; 59874642e01fSmrg char *lt_argv_zero; 598835c4bbdfSmrg int rval = 127; 598905b261ecSmrg 59904642e01fSmrg int i; 599105b261ecSmrg 59924642e01fSmrg program_name = (char *) xstrdup (base_name (argv[0])); 599335c4bbdfSmrg newargz = XMALLOC (char *, (size_t) argc + 1); 599405b261ecSmrg 59956747b715Smrg /* very simple arg parsing; don't want to rely on getopt 59966747b715Smrg * also, copy all non cwrapper options to newargz, except 59976747b715Smrg * argz[0], which is handled differently 59986747b715Smrg */ 59996747b715Smrg newargc=0; 60004642e01fSmrg for (i = 1; i < argc; i++) 60014642e01fSmrg { 600235c4bbdfSmrg if (STREQ (argv[i], dumpscript_opt)) 60034642e01fSmrg { 60044642e01fSmrgEOF 600535c4bbdfSmrg case $host in 60064642e01fSmrg *mingw* | *cygwin* ) 60074642e01fSmrg # make stdout use "unix" line endings 60084642e01fSmrg echo " setmode(1,_O_BINARY);" 60094642e01fSmrg ;; 60104642e01fSmrg esac 601105b261ecSmrg 60124642e01fSmrg cat <<"EOF" 60136747b715Smrg lt_dump_script (stdout); 60144642e01fSmrg return 0; 60154642e01fSmrg } 601635c4bbdfSmrg if (STREQ (argv[i], debug_opt)) 60176747b715Smrg { 60186747b715Smrg lt_debug = 1; 60196747b715Smrg continue; 60206747b715Smrg } 602135c4bbdfSmrg if (STREQ (argv[i], ltwrapper_option_prefix)) 60226747b715Smrg { 60236747b715Smrg /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX 60246747b715Smrg namespace, but it is not one of the ones we know about and 60256747b715Smrg have already dealt with, above (inluding dump-script), then 60266747b715Smrg report an error. Otherwise, targets might begin to believe 60276747b715Smrg they are allowed to use options in the LTWRAPPER_OPTION_PREFIX 60286747b715Smrg namespace. The first time any user complains about this, we'll 60296747b715Smrg need to make LTWRAPPER_OPTION_PREFIX a configure-time option 60306747b715Smrg or a configure.ac-settable value. 60316747b715Smrg */ 60326747b715Smrg lt_fatal (__FILE__, __LINE__, 60336747b715Smrg "unrecognized %s option: '%s'", 60346747b715Smrg ltwrapper_option_prefix, argv[i]); 60356747b715Smrg } 60366747b715Smrg /* otherwise ... */ 60376747b715Smrg newargz[++newargc] = xstrdup (argv[i]); 60384642e01fSmrg } 60396747b715Smrg newargz[++newargc] = NULL; 60406747b715Smrg 60416747b715SmrgEOF 60426747b715Smrg cat <<EOF 60436747b715Smrg /* The GNU banner must be the first non-error debug message */ 604435c4bbdfSmrg lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE) $VERSION\n"); 60456747b715SmrgEOF 60466747b715Smrg cat <<"EOF" 60476747b715Smrg lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]); 60486747b715Smrg lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name); 604905b261ecSmrg 60504642e01fSmrg tmp_pathspec = find_executable (argv[0]); 60514642e01fSmrg if (tmp_pathspec == NULL) 60526747b715Smrg lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]); 60536747b715Smrg lt_debugprintf (__FILE__, __LINE__, 60546747b715Smrg "(main) found exe (before symlink chase) at: %s\n", 60556747b715Smrg tmp_pathspec); 60564642e01fSmrg 60574642e01fSmrg actual_cwrapper_path = chase_symlinks (tmp_pathspec); 60586747b715Smrg lt_debugprintf (__FILE__, __LINE__, 60596747b715Smrg "(main) found exe (after symlink chase) at: %s\n", 60606747b715Smrg actual_cwrapper_path); 60614642e01fSmrg XFREE (tmp_pathspec); 60624642e01fSmrg 60636747b715Smrg actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path)); 60644642e01fSmrg strendzap (actual_cwrapper_path, actual_cwrapper_name); 60654642e01fSmrg 60664642e01fSmrg /* wrapper name transforms */ 60674642e01fSmrg strendzap (actual_cwrapper_name, ".exe"); 60684642e01fSmrg tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1); 60694642e01fSmrg XFREE (actual_cwrapper_name); 60704642e01fSmrg actual_cwrapper_name = tmp_pathspec; 60714642e01fSmrg tmp_pathspec = 0; 60724642e01fSmrg 60734642e01fSmrg /* target_name transforms -- use actual target program name; might have lt- prefix */ 60744642e01fSmrg target_name = xstrdup (base_name (TARGET_PROGRAM_NAME)); 60754642e01fSmrg strendzap (target_name, ".exe"); 60764642e01fSmrg tmp_pathspec = lt_extend_str (target_name, ".exe", 1); 60774642e01fSmrg XFREE (target_name); 60784642e01fSmrg target_name = tmp_pathspec; 60794642e01fSmrg tmp_pathspec = 0; 60804642e01fSmrg 60816747b715Smrg lt_debugprintf (__FILE__, __LINE__, 60826747b715Smrg "(main) libtool target name: %s\n", 60836747b715Smrg target_name); 60844642e01fSmrgEOF 608505b261ecSmrg 60864642e01fSmrg cat <<EOF 60874642e01fSmrg newargz[0] = 60884642e01fSmrg XMALLOC (char, (strlen (actual_cwrapper_path) + 60894642e01fSmrg strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1)); 60904642e01fSmrg strcpy (newargz[0], actual_cwrapper_path); 60914642e01fSmrg strcat (newargz[0], "$objdir"); 60924642e01fSmrg strcat (newargz[0], "/"); 60934642e01fSmrgEOF 609405b261ecSmrg 60954642e01fSmrg cat <<"EOF" 60964642e01fSmrg /* stop here, and copy so we don't have to do this twice */ 60974642e01fSmrg tmp_pathspec = xstrdup (newargz[0]); 609805b261ecSmrg 60994642e01fSmrg /* do NOT want the lt- prefix here, so use actual_cwrapper_name */ 61004642e01fSmrg strcat (newargz[0], actual_cwrapper_name); 610105b261ecSmrg 61024642e01fSmrg /* DO want the lt- prefix here if it exists, so use target_name */ 61034642e01fSmrg lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1); 61044642e01fSmrg XFREE (tmp_pathspec); 61054642e01fSmrg tmp_pathspec = NULL; 61064642e01fSmrgEOF 610705b261ecSmrg 61084642e01fSmrg case $host_os in 61094642e01fSmrg mingw*) 61104642e01fSmrg cat <<"EOF" 61114642e01fSmrg { 61124642e01fSmrg char* p; 61134642e01fSmrg while ((p = strchr (newargz[0], '\\')) != NULL) 61144642e01fSmrg { 61154642e01fSmrg *p = '/'; 61164642e01fSmrg } 61174642e01fSmrg while ((p = strchr (lt_argv_zero, '\\')) != NULL) 61184642e01fSmrg { 61194642e01fSmrg *p = '/'; 61204642e01fSmrg } 61214642e01fSmrg } 61224642e01fSmrgEOF 61234642e01fSmrg ;; 61244642e01fSmrg esac 612505b261ecSmrg 61264642e01fSmrg cat <<"EOF" 61274642e01fSmrg XFREE (target_name); 61284642e01fSmrg XFREE (actual_cwrapper_path); 61294642e01fSmrg XFREE (actual_cwrapper_name); 613005b261ecSmrg 61314642e01fSmrg lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */ 61324642e01fSmrg lt_setenv ("DUALCASE", "1"); /* for MSK sh */ 613335c4bbdfSmrg /* Update the DLL searchpath. EXE_PATH_VALUE ($dllsearchpath) must 613435c4bbdfSmrg be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath) 613535c4bbdfSmrg because on Windows, both *_VARNAMEs are PATH but uninstalled 613635c4bbdfSmrg libraries must come first. */ 6137475c125cSmrg lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE); 613835c4bbdfSmrg lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE); 613905b261ecSmrg 61406747b715Smrg lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n", 61416747b715Smrg nonnull (lt_argv_zero)); 61424642e01fSmrg for (i = 0; i < newargc; i++) 61434642e01fSmrg { 61446747b715Smrg lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n", 61456747b715Smrg i, nonnull (newargz[i])); 61464642e01fSmrg } 614705b261ecSmrg 61484642e01fSmrgEOF 614905b261ecSmrg 61504642e01fSmrg case $host_os in 61514642e01fSmrg mingw*) 61524642e01fSmrg cat <<"EOF" 61534642e01fSmrg /* execv doesn't actually work on mingw as expected on unix */ 61546747b715Smrg newargz = prepare_spawn (newargz); 615535c4bbdfSmrg rval = (int) _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz); 61564642e01fSmrg if (rval == -1) 61574642e01fSmrg { 61584642e01fSmrg /* failed to start process */ 61596747b715Smrg lt_debugprintf (__FILE__, __LINE__, 61606747b715Smrg "(main) failed to launch target \"%s\": %s\n", 61616747b715Smrg lt_argv_zero, nonnull (strerror (errno))); 61624642e01fSmrg return 127; 61634642e01fSmrg } 61644642e01fSmrg return rval; 61654642e01fSmrgEOF 61664642e01fSmrg ;; 61674642e01fSmrg *) 61684642e01fSmrg cat <<"EOF" 61694642e01fSmrg execv (lt_argv_zero, newargz); 61704642e01fSmrg return rval; /* =127, but avoids unused variable warning */ 61714642e01fSmrgEOF 61724642e01fSmrg ;; 61734642e01fSmrg esac 617405b261ecSmrg 61754642e01fSmrg cat <<"EOF" 61764642e01fSmrg} 617705b261ecSmrg 61784642e01fSmrgvoid * 61794642e01fSmrgxmalloc (size_t num) 61804642e01fSmrg{ 61814642e01fSmrg void *p = (void *) malloc (num); 61824642e01fSmrg if (!p) 61836747b715Smrg lt_fatal (__FILE__, __LINE__, "memory exhausted"); 618405b261ecSmrg 61854642e01fSmrg return p; 61864642e01fSmrg} 618705b261ecSmrg 61884642e01fSmrgchar * 61894642e01fSmrgxstrdup (const char *string) 61904642e01fSmrg{ 61914642e01fSmrg return string ? strcpy ((char *) xmalloc (strlen (string) + 1), 61924642e01fSmrg string) : NULL; 61934642e01fSmrg} 619405b261ecSmrg 61954642e01fSmrgconst char * 61964642e01fSmrgbase_name (const char *name) 61974642e01fSmrg{ 61984642e01fSmrg const char *base; 619905b261ecSmrg 620035c4bbdfSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 62014642e01fSmrg /* Skip over the disk name in MSDOS pathnames. */ 62024642e01fSmrg if (isalpha ((unsigned char) name[0]) && name[1] == ':') 62034642e01fSmrg name += 2; 62044642e01fSmrg#endif 620505b261ecSmrg 62064642e01fSmrg for (base = name; *name; name++) 62074642e01fSmrg if (IS_DIR_SEPARATOR (*name)) 62084642e01fSmrg base = name + 1; 62094642e01fSmrg return base; 62104642e01fSmrg} 621105b261ecSmrg 62124642e01fSmrgint 62134642e01fSmrgcheck_executable (const char *path) 62144642e01fSmrg{ 62154642e01fSmrg struct stat st; 621605b261ecSmrg 62176747b715Smrg lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n", 62186747b715Smrg nonempty (path)); 62194642e01fSmrg if ((!path) || (!*path)) 62204642e01fSmrg return 0; 622105b261ecSmrg 62224642e01fSmrg if ((stat (path, &st) >= 0) 62234642e01fSmrg && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) 62244642e01fSmrg return 1; 62254642e01fSmrg else 62264642e01fSmrg return 0; 62274642e01fSmrg} 622805b261ecSmrg 62294642e01fSmrgint 62304642e01fSmrgmake_executable (const char *path) 62314642e01fSmrg{ 62324642e01fSmrg int rval = 0; 62334642e01fSmrg struct stat st; 623405b261ecSmrg 62356747b715Smrg lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", 62366747b715Smrg nonempty (path)); 62374642e01fSmrg if ((!path) || (!*path)) 62384642e01fSmrg return 0; 623905b261ecSmrg 62404642e01fSmrg if (stat (path, &st) >= 0) 62414642e01fSmrg { 62424642e01fSmrg rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); 62434642e01fSmrg } 62444642e01fSmrg return rval; 62454642e01fSmrg} 624605b261ecSmrg 62474642e01fSmrg/* Searches for the full path of the wrapper. Returns 62484642e01fSmrg newly allocated full path name if found, NULL otherwise 62494642e01fSmrg Does not chase symlinks, even on platforms that support them. 62504642e01fSmrg*/ 62514642e01fSmrgchar * 62524642e01fSmrgfind_executable (const char *wrapper) 62534642e01fSmrg{ 62544642e01fSmrg int has_slash = 0; 62554642e01fSmrg const char *p; 62564642e01fSmrg const char *p_next; 62574642e01fSmrg /* static buffer for getcwd */ 62584642e01fSmrg char tmp[LT_PATHMAX + 1]; 625935c4bbdfSmrg size_t tmp_len; 62604642e01fSmrg char *concat_name; 626105b261ecSmrg 62626747b715Smrg lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", 62636747b715Smrg nonempty (wrapper)); 626405b261ecSmrg 62654642e01fSmrg if ((wrapper == NULL) || (*wrapper == '\0')) 62664642e01fSmrg return NULL; 626705b261ecSmrg 62684642e01fSmrg /* Absolute path? */ 626935c4bbdfSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 62704642e01fSmrg if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') 62714642e01fSmrg { 62724642e01fSmrg concat_name = xstrdup (wrapper); 62734642e01fSmrg if (check_executable (concat_name)) 62744642e01fSmrg return concat_name; 62754642e01fSmrg XFREE (concat_name); 62764642e01fSmrg } 62774642e01fSmrg else 62784642e01fSmrg { 62794642e01fSmrg#endif 62804642e01fSmrg if (IS_DIR_SEPARATOR (wrapper[0])) 62814642e01fSmrg { 62824642e01fSmrg concat_name = xstrdup (wrapper); 62834642e01fSmrg if (check_executable (concat_name)) 62844642e01fSmrg return concat_name; 62854642e01fSmrg XFREE (concat_name); 62864642e01fSmrg } 628735c4bbdfSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 62884642e01fSmrg } 62894642e01fSmrg#endif 629005b261ecSmrg 62914642e01fSmrg for (p = wrapper; *p; p++) 62924642e01fSmrg if (*p == '/') 62934642e01fSmrg { 62944642e01fSmrg has_slash = 1; 62954642e01fSmrg break; 62964642e01fSmrg } 62974642e01fSmrg if (!has_slash) 62984642e01fSmrg { 62994642e01fSmrg /* no slashes; search PATH */ 63004642e01fSmrg const char *path = getenv ("PATH"); 63014642e01fSmrg if (path != NULL) 63024642e01fSmrg { 63034642e01fSmrg for (p = path; *p; p = p_next) 63044642e01fSmrg { 63054642e01fSmrg const char *q; 63064642e01fSmrg size_t p_len; 63074642e01fSmrg for (q = p; *q; q++) 63084642e01fSmrg if (IS_PATH_SEPARATOR (*q)) 63094642e01fSmrg break; 631035c4bbdfSmrg p_len = (size_t) (q - p); 63114642e01fSmrg p_next = (*q == '\0' ? q : q + 1); 63124642e01fSmrg if (p_len == 0) 63134642e01fSmrg { 63144642e01fSmrg /* empty path: current directory */ 63154642e01fSmrg if (getcwd (tmp, LT_PATHMAX) == NULL) 63166747b715Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 63176747b715Smrg nonnull (strerror (errno))); 63184642e01fSmrg tmp_len = strlen (tmp); 63194642e01fSmrg concat_name = 63204642e01fSmrg XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 63214642e01fSmrg memcpy (concat_name, tmp, tmp_len); 63224642e01fSmrg concat_name[tmp_len] = '/'; 63234642e01fSmrg strcpy (concat_name + tmp_len + 1, wrapper); 63244642e01fSmrg } 63254642e01fSmrg else 63264642e01fSmrg { 63274642e01fSmrg concat_name = 63284642e01fSmrg XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); 63294642e01fSmrg memcpy (concat_name, p, p_len); 63304642e01fSmrg concat_name[p_len] = '/'; 63314642e01fSmrg strcpy (concat_name + p_len + 1, wrapper); 63324642e01fSmrg } 63334642e01fSmrg if (check_executable (concat_name)) 63344642e01fSmrg return concat_name; 63354642e01fSmrg XFREE (concat_name); 63364642e01fSmrg } 63374642e01fSmrg } 63384642e01fSmrg /* not found in PATH; assume curdir */ 63394642e01fSmrg } 63404642e01fSmrg /* Relative path | not found in path: prepend cwd */ 63414642e01fSmrg if (getcwd (tmp, LT_PATHMAX) == NULL) 63426747b715Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 63436747b715Smrg nonnull (strerror (errno))); 63444642e01fSmrg tmp_len = strlen (tmp); 63454642e01fSmrg concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 63464642e01fSmrg memcpy (concat_name, tmp, tmp_len); 63474642e01fSmrg concat_name[tmp_len] = '/'; 63484642e01fSmrg strcpy (concat_name + tmp_len + 1, wrapper); 634905b261ecSmrg 63504642e01fSmrg if (check_executable (concat_name)) 63514642e01fSmrg return concat_name; 63524642e01fSmrg XFREE (concat_name); 63534642e01fSmrg return NULL; 63544642e01fSmrg} 635505b261ecSmrg 63564642e01fSmrgchar * 63574642e01fSmrgchase_symlinks (const char *pathspec) 63584642e01fSmrg{ 63594642e01fSmrg#ifndef S_ISLNK 63604642e01fSmrg return xstrdup (pathspec); 63614642e01fSmrg#else 63624642e01fSmrg char buf[LT_PATHMAX]; 63634642e01fSmrg struct stat s; 63644642e01fSmrg char *tmp_pathspec = xstrdup (pathspec); 63654642e01fSmrg char *p; 63664642e01fSmrg int has_symlinks = 0; 63674642e01fSmrg while (strlen (tmp_pathspec) && !has_symlinks) 63684642e01fSmrg { 63696747b715Smrg lt_debugprintf (__FILE__, __LINE__, 63706747b715Smrg "checking path component for symlinks: %s\n", 63716747b715Smrg tmp_pathspec); 63724642e01fSmrg if (lstat (tmp_pathspec, &s) == 0) 63734642e01fSmrg { 63744642e01fSmrg if (S_ISLNK (s.st_mode) != 0) 63754642e01fSmrg { 63764642e01fSmrg has_symlinks = 1; 63774642e01fSmrg break; 63784642e01fSmrg } 637905b261ecSmrg 63804642e01fSmrg /* search backwards for last DIR_SEPARATOR */ 63814642e01fSmrg p = tmp_pathspec + strlen (tmp_pathspec) - 1; 63824642e01fSmrg while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 63834642e01fSmrg p--; 63844642e01fSmrg if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 63854642e01fSmrg { 63864642e01fSmrg /* no more DIR_SEPARATORS left */ 63874642e01fSmrg break; 63884642e01fSmrg } 63894642e01fSmrg *p = '\0'; 63904642e01fSmrg } 63914642e01fSmrg else 63924642e01fSmrg { 63936747b715Smrg lt_fatal (__FILE__, __LINE__, 63946747b715Smrg "error accessing file \"%s\": %s", 63956747b715Smrg tmp_pathspec, nonnull (strerror (errno))); 63964642e01fSmrg } 63974642e01fSmrg } 63984642e01fSmrg XFREE (tmp_pathspec); 639905b261ecSmrg 64004642e01fSmrg if (!has_symlinks) 64014642e01fSmrg { 64024642e01fSmrg return xstrdup (pathspec); 64034642e01fSmrg } 640405b261ecSmrg 64054642e01fSmrg tmp_pathspec = realpath (pathspec, buf); 64064642e01fSmrg if (tmp_pathspec == 0) 64074642e01fSmrg { 64086747b715Smrg lt_fatal (__FILE__, __LINE__, 64096747b715Smrg "could not follow symlinks for %s", pathspec); 64104642e01fSmrg } 64114642e01fSmrg return xstrdup (tmp_pathspec); 64124642e01fSmrg#endif 64134642e01fSmrg} 641405b261ecSmrg 64154642e01fSmrgchar * 64164642e01fSmrgstrendzap (char *str, const char *pat) 64174642e01fSmrg{ 64184642e01fSmrg size_t len, patlen; 641905b261ecSmrg 64204642e01fSmrg assert (str != NULL); 64214642e01fSmrg assert (pat != NULL); 642205b261ecSmrg 64234642e01fSmrg len = strlen (str); 64244642e01fSmrg patlen = strlen (pat); 642505b261ecSmrg 64264642e01fSmrg if (patlen <= len) 64274642e01fSmrg { 64284642e01fSmrg str += len - patlen; 642935c4bbdfSmrg if (STREQ (str, pat)) 64304642e01fSmrg *str = '\0'; 64314642e01fSmrg } 64324642e01fSmrg return str; 64334642e01fSmrg} 643405b261ecSmrg 64356747b715Smrgvoid 64366747b715Smrglt_debugprintf (const char *file, int line, const char *fmt, ...) 64376747b715Smrg{ 64386747b715Smrg va_list args; 64396747b715Smrg if (lt_debug) 64406747b715Smrg { 64416747b715Smrg (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); 64426747b715Smrg va_start (args, fmt); 64436747b715Smrg (void) vfprintf (stderr, fmt, args); 64446747b715Smrg va_end (args); 64456747b715Smrg } 64466747b715Smrg} 64476747b715Smrg 64484642e01fSmrgstatic void 64496747b715Smrglt_error_core (int exit_status, const char *file, 64506747b715Smrg int line, const char *mode, 64514642e01fSmrg const char *message, va_list ap) 64524642e01fSmrg{ 64536747b715Smrg fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); 64544642e01fSmrg vfprintf (stderr, message, ap); 64554642e01fSmrg fprintf (stderr, ".\n"); 645605b261ecSmrg 64574642e01fSmrg if (exit_status >= 0) 64584642e01fSmrg exit (exit_status); 64594642e01fSmrg} 646005b261ecSmrg 64614642e01fSmrgvoid 64626747b715Smrglt_fatal (const char *file, int line, const char *message, ...) 64634642e01fSmrg{ 64644642e01fSmrg va_list ap; 64654642e01fSmrg va_start (ap, message); 64666747b715Smrg lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); 64674642e01fSmrg va_end (ap); 64684642e01fSmrg} 646905b261ecSmrg 64706747b715Smrgstatic const char * 64716747b715Smrgnonnull (const char *s) 64726747b715Smrg{ 64736747b715Smrg return s ? s : "(null)"; 64746747b715Smrg} 64756747b715Smrg 64766747b715Smrgstatic const char * 64776747b715Smrgnonempty (const char *s) 64786747b715Smrg{ 64796747b715Smrg return (s && !*s) ? "(empty)" : nonnull (s); 64806747b715Smrg} 64816747b715Smrg 64824642e01fSmrgvoid 64834642e01fSmrglt_setenv (const char *name, const char *value) 64844642e01fSmrg{ 64856747b715Smrg lt_debugprintf (__FILE__, __LINE__, 64866747b715Smrg "(lt_setenv) setting '%s' to '%s'\n", 64876747b715Smrg nonnull (name), nonnull (value)); 64884642e01fSmrg { 64894642e01fSmrg#ifdef HAVE_SETENV 64904642e01fSmrg /* always make a copy, for consistency with !HAVE_SETENV */ 64914642e01fSmrg char *str = xstrdup (value); 64924642e01fSmrg setenv (name, str, 1); 64934642e01fSmrg#else 649435c4bbdfSmrg size_t len = strlen (name) + 1 + strlen (value) + 1; 64954642e01fSmrg char *str = XMALLOC (char, len); 64964642e01fSmrg sprintf (str, "%s=%s", name, value); 64974642e01fSmrg if (putenv (str) != EXIT_SUCCESS) 64984642e01fSmrg { 64994642e01fSmrg XFREE (str); 65004642e01fSmrg } 65014642e01fSmrg#endif 65024642e01fSmrg } 65034642e01fSmrg} 650405b261ecSmrg 65054642e01fSmrgchar * 65064642e01fSmrglt_extend_str (const char *orig_value, const char *add, int to_end) 65074642e01fSmrg{ 65084642e01fSmrg char *new_value; 65094642e01fSmrg if (orig_value && *orig_value) 65104642e01fSmrg { 651135c4bbdfSmrg size_t orig_value_len = strlen (orig_value); 651235c4bbdfSmrg size_t add_len = strlen (add); 65134642e01fSmrg new_value = XMALLOC (char, add_len + orig_value_len + 1); 65144642e01fSmrg if (to_end) 65154642e01fSmrg { 65164642e01fSmrg strcpy (new_value, orig_value); 65174642e01fSmrg strcpy (new_value + orig_value_len, add); 65184642e01fSmrg } 65194642e01fSmrg else 65204642e01fSmrg { 65214642e01fSmrg strcpy (new_value, add); 65224642e01fSmrg strcpy (new_value + add_len, orig_value); 65234642e01fSmrg } 65244642e01fSmrg } 65254642e01fSmrg else 65264642e01fSmrg { 65274642e01fSmrg new_value = xstrdup (add); 65284642e01fSmrg } 65294642e01fSmrg return new_value; 65304642e01fSmrg} 653105b261ecSmrg 65324642e01fSmrgvoid 65334642e01fSmrglt_update_exe_path (const char *name, const char *value) 65344642e01fSmrg{ 65356747b715Smrg lt_debugprintf (__FILE__, __LINE__, 65366747b715Smrg "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", 65376747b715Smrg nonnull (name), nonnull (value)); 653805b261ecSmrg 65394642e01fSmrg if (name && *name && value && *value) 65404642e01fSmrg { 65414642e01fSmrg char *new_value = lt_extend_str (getenv (name), value, 0); 65424642e01fSmrg /* some systems can't cope with a ':'-terminated path #' */ 654335c4bbdfSmrg size_t len = strlen (new_value); 654435c4bbdfSmrg while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1])) 65454642e01fSmrg { 654635c4bbdfSmrg new_value[--len] = '\0'; 65474642e01fSmrg } 65484642e01fSmrg lt_setenv (name, new_value); 65494642e01fSmrg XFREE (new_value); 65504642e01fSmrg } 65514642e01fSmrg} 655205b261ecSmrg 65534642e01fSmrgvoid 65544642e01fSmrglt_update_lib_path (const char *name, const char *value) 65554642e01fSmrg{ 65566747b715Smrg lt_debugprintf (__FILE__, __LINE__, 65576747b715Smrg "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", 65586747b715Smrg nonnull (name), nonnull (value)); 655905b261ecSmrg 65604642e01fSmrg if (name && *name && value && *value) 65614642e01fSmrg { 65624642e01fSmrg char *new_value = lt_extend_str (getenv (name), value, 0); 65634642e01fSmrg lt_setenv (name, new_value); 65644642e01fSmrg XFREE (new_value); 65654642e01fSmrg } 65664642e01fSmrg} 656705b261ecSmrg 65686747b715SmrgEOF 65696747b715Smrg case $host_os in 65706747b715Smrg mingw*) 65716747b715Smrg cat <<"EOF" 65726747b715Smrg 65736747b715Smrg/* Prepares an argument vector before calling spawn(). 65746747b715Smrg Note that spawn() does not by itself call the command interpreter 65756747b715Smrg (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : 65766747b715Smrg ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); 65776747b715Smrg GetVersionEx(&v); 65786747b715Smrg v.dwPlatformId == VER_PLATFORM_WIN32_NT; 65796747b715Smrg }) ? "cmd.exe" : "command.com"). 65806747b715Smrg Instead it simply concatenates the arguments, separated by ' ', and calls 65816747b715Smrg CreateProcess(). We must quote the arguments since Win32 CreateProcess() 65826747b715Smrg interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a 65836747b715Smrg special way: 65846747b715Smrg - Space and tab are interpreted as delimiters. They are not treated as 65856747b715Smrg delimiters if they are surrounded by double quotes: "...". 65866747b715Smrg - Unescaped double quotes are removed from the input. Their only effect is 65876747b715Smrg that within double quotes, space and tab are treated like normal 65886747b715Smrg characters. 65896747b715Smrg - Backslashes not followed by double quotes are not special. 65906747b715Smrg - But 2*n+1 backslashes followed by a double quote become 65916747b715Smrg n backslashes followed by a double quote (n >= 0): 65926747b715Smrg \" -> " 65936747b715Smrg \\\" -> \" 65946747b715Smrg \\\\\" -> \\" 65956747b715Smrg */ 65966747b715Smrg#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" 65976747b715Smrg#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" 65986747b715Smrgchar ** 65996747b715Smrgprepare_spawn (char **argv) 66006747b715Smrg{ 66016747b715Smrg size_t argc; 66026747b715Smrg char **new_argv; 66036747b715Smrg size_t i; 66046747b715Smrg 66056747b715Smrg /* Count number of arguments. */ 66066747b715Smrg for (argc = 0; argv[argc] != NULL; argc++) 66076747b715Smrg ; 66086747b715Smrg 66096747b715Smrg /* Allocate new argument vector. */ 66106747b715Smrg new_argv = XMALLOC (char *, argc + 1); 66116747b715Smrg 66126747b715Smrg /* Put quoted arguments into the new argument vector. */ 66136747b715Smrg for (i = 0; i < argc; i++) 66146747b715Smrg { 66156747b715Smrg const char *string = argv[i]; 66166747b715Smrg 66176747b715Smrg if (string[0] == '\0') 66186747b715Smrg new_argv[i] = xstrdup ("\"\""); 66196747b715Smrg else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) 66206747b715Smrg { 66216747b715Smrg int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); 66226747b715Smrg size_t length; 66236747b715Smrg unsigned int backslashes; 66246747b715Smrg const char *s; 66256747b715Smrg char *quoted_string; 66266747b715Smrg char *p; 66276747b715Smrg 66286747b715Smrg length = 0; 66296747b715Smrg backslashes = 0; 66306747b715Smrg if (quote_around) 66316747b715Smrg length++; 66326747b715Smrg for (s = string; *s != '\0'; s++) 66336747b715Smrg { 66346747b715Smrg char c = *s; 66356747b715Smrg if (c == '"') 66366747b715Smrg length += backslashes + 1; 66376747b715Smrg length++; 66386747b715Smrg if (c == '\\') 66396747b715Smrg backslashes++; 66406747b715Smrg else 66416747b715Smrg backslashes = 0; 66426747b715Smrg } 66436747b715Smrg if (quote_around) 66446747b715Smrg length += backslashes + 1; 66456747b715Smrg 66466747b715Smrg quoted_string = XMALLOC (char, length + 1); 66476747b715Smrg 66486747b715Smrg p = quoted_string; 66496747b715Smrg backslashes = 0; 66506747b715Smrg if (quote_around) 66516747b715Smrg *p++ = '"'; 66526747b715Smrg for (s = string; *s != '\0'; s++) 66536747b715Smrg { 66546747b715Smrg char c = *s; 66556747b715Smrg if (c == '"') 66566747b715Smrg { 66576747b715Smrg unsigned int j; 66586747b715Smrg for (j = backslashes + 1; j > 0; j--) 66596747b715Smrg *p++ = '\\'; 66606747b715Smrg } 66616747b715Smrg *p++ = c; 66626747b715Smrg if (c == '\\') 66636747b715Smrg backslashes++; 66646747b715Smrg else 66656747b715Smrg backslashes = 0; 66666747b715Smrg } 66676747b715Smrg if (quote_around) 66686747b715Smrg { 66696747b715Smrg unsigned int j; 66706747b715Smrg for (j = backslashes; j > 0; j--) 66716747b715Smrg *p++ = '\\'; 66726747b715Smrg *p++ = '"'; 66736747b715Smrg } 66746747b715Smrg *p = '\0'; 66756747b715Smrg 66766747b715Smrg new_argv[i] = quoted_string; 66776747b715Smrg } 66786747b715Smrg else 66796747b715Smrg new_argv[i] = (char *) string; 66806747b715Smrg } 66816747b715Smrg new_argv[argc] = NULL; 66826747b715Smrg 66836747b715Smrg return new_argv; 66846747b715Smrg} 66856747b715SmrgEOF 66866747b715Smrg ;; 66876747b715Smrg esac 66886747b715Smrg 66896747b715Smrg cat <<"EOF" 66906747b715Smrgvoid lt_dump_script (FILE* f) 66916747b715Smrg{ 66926747b715SmrgEOF 66936747b715Smrg func_emit_wrapper yes | 669435c4bbdfSmrg $SED -n -e ' 669535c4bbdfSmrgs/^\(.\{79\}\)\(..*\)/\1\ 669635c4bbdfSmrg\2/ 669735c4bbdfSmrgh 669835c4bbdfSmrgs/\([\\"]\)/\\\1/g 669935c4bbdfSmrgs/$/\\n/ 670035c4bbdfSmrgs/\([^\n]*\).*/ fputs ("\1", f);/p 670135c4bbdfSmrgg 670235c4bbdfSmrgD' 67036747b715Smrg cat <<"EOF" 67046747b715Smrg} 67054642e01fSmrgEOF 67064642e01fSmrg} 67074642e01fSmrg# end: func_emit_cwrapperexe_src 670805b261ecSmrg 67096747b715Smrg# func_win32_import_lib_p ARG 67106747b715Smrg# True if ARG is an import lib, as indicated by $file_magic_cmd 67116747b715Smrgfunc_win32_import_lib_p () 67126747b715Smrg{ 671335c4bbdfSmrg $debug_cmd 671435c4bbdfSmrg 67156747b715Smrg case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in 67166747b715Smrg *import*) : ;; 67176747b715Smrg *) false ;; 67186747b715Smrg esac 67196747b715Smrg} 67206747b715Smrg 672135c4bbdfSmrg# func_suncc_cstd_abi 672235c4bbdfSmrg# !!ONLY CALL THIS FOR SUN CC AFTER $compile_command IS FULLY EXPANDED!! 672335c4bbdfSmrg# Several compiler flags select an ABI that is incompatible with the 672435c4bbdfSmrg# Cstd library. Avoid specifying it if any are in CXXFLAGS. 672535c4bbdfSmrgfunc_suncc_cstd_abi () 672635c4bbdfSmrg{ 672735c4bbdfSmrg $debug_cmd 672835c4bbdfSmrg 672935c4bbdfSmrg case " $compile_command " in 673035c4bbdfSmrg *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*) 673135c4bbdfSmrg suncc_use_cstd_abi=no 673235c4bbdfSmrg ;; 673335c4bbdfSmrg *) 673435c4bbdfSmrg suncc_use_cstd_abi=yes 673535c4bbdfSmrg ;; 673635c4bbdfSmrg esac 673735c4bbdfSmrg} 673835c4bbdfSmrg 67394642e01fSmrg# func_mode_link arg... 67404642e01fSmrgfunc_mode_link () 67414642e01fSmrg{ 674235c4bbdfSmrg $debug_cmd 674335c4bbdfSmrg 67444642e01fSmrg case $host in 67454642e01fSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 67464642e01fSmrg # It is impossible to link a dll without this setting, and 67474642e01fSmrg # we shouldn't force the makefile maintainer to figure out 674835c4bbdfSmrg # what system we are compiling for in order to pass an extra 67494642e01fSmrg # flag for every libtool invocation. 67504642e01fSmrg # allow_undefined=no 675105b261ecSmrg 67524642e01fSmrg # FIXME: Unfortunately, there are problems with the above when trying 675335c4bbdfSmrg # to make a dll that has undefined symbols, in which case not 67544642e01fSmrg # even a static library is built. For now, we need to specify 67554642e01fSmrg # -no-undefined on the libtool link line when we can be certain 67564642e01fSmrg # that all symbols are satisfied, otherwise we get a static library. 67574642e01fSmrg allow_undefined=yes 67584642e01fSmrg ;; 67594642e01fSmrg *) 67604642e01fSmrg allow_undefined=yes 67614642e01fSmrg ;; 67624642e01fSmrg esac 67634642e01fSmrg libtool_args=$nonopt 67644642e01fSmrg base_compile="$nonopt $@" 67654642e01fSmrg compile_command=$nonopt 67664642e01fSmrg finalize_command=$nonopt 676705b261ecSmrg 67684642e01fSmrg compile_rpath= 67694642e01fSmrg finalize_rpath= 67704642e01fSmrg compile_shlibpath= 67714642e01fSmrg finalize_shlibpath= 67724642e01fSmrg convenience= 67734642e01fSmrg old_convenience= 67744642e01fSmrg deplibs= 67754642e01fSmrg old_deplibs= 67764642e01fSmrg compiler_flags= 67774642e01fSmrg linker_flags= 67784642e01fSmrg dllsearchpath= 67794642e01fSmrg lib_search_path=`pwd` 67804642e01fSmrg inst_prefix_dir= 67814642e01fSmrg new_inherited_linker_flags= 678205b261ecSmrg 67834642e01fSmrg avoid_version=no 67846747b715Smrg bindir= 67854642e01fSmrg dlfiles= 67864642e01fSmrg dlprefiles= 67874642e01fSmrg dlself=no 67884642e01fSmrg export_dynamic=no 67894642e01fSmrg export_symbols= 67904642e01fSmrg export_symbols_regex= 67914642e01fSmrg generated= 67924642e01fSmrg libobjs= 67934642e01fSmrg ltlibs= 67944642e01fSmrg module=no 67954642e01fSmrg no_install=no 67964642e01fSmrg objs= 679735c4bbdfSmrg os2dllname= 67984642e01fSmrg non_pic_objects= 67994642e01fSmrg precious_files_regex= 68004642e01fSmrg prefer_static_libs=no 680135c4bbdfSmrg preload=false 68024642e01fSmrg prev= 68034642e01fSmrg prevarg= 68044642e01fSmrg release= 68054642e01fSmrg rpath= 68064642e01fSmrg xrpath= 68074642e01fSmrg perm_rpath= 68084642e01fSmrg temp_rpath= 68094642e01fSmrg thread_safe=no 68104642e01fSmrg vinfo= 68114642e01fSmrg vinfo_number=no 68124642e01fSmrg weak_libs= 681335c4bbdfSmrg single_module=$wl-single_module 68144642e01fSmrg func_infer_tag $base_compile 681505b261ecSmrg 68164642e01fSmrg # We need to know -static, to get the right output filenames. 68174642e01fSmrg for arg 68184642e01fSmrg do 68194642e01fSmrg case $arg in 68204642e01fSmrg -shared) 682135c4bbdfSmrg test yes != "$build_libtool_libs" \ 682235c4bbdfSmrg && func_fatal_configuration "cannot build a shared library" 68234642e01fSmrg build_old_libs=no 68244642e01fSmrg break 68254642e01fSmrg ;; 68264642e01fSmrg -all-static | -static | -static-libtool-libs) 68274642e01fSmrg case $arg in 68284642e01fSmrg -all-static) 682935c4bbdfSmrg if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then 68304642e01fSmrg func_warning "complete static linking is impossible in this configuration" 68314642e01fSmrg fi 68324642e01fSmrg if test -n "$link_static_flag"; then 68334642e01fSmrg dlopen_self=$dlopen_self_static 68344642e01fSmrg fi 68354642e01fSmrg prefer_static_libs=yes 68364642e01fSmrg ;; 68374642e01fSmrg -static) 68384642e01fSmrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 68394642e01fSmrg dlopen_self=$dlopen_self_static 68404642e01fSmrg fi 68414642e01fSmrg prefer_static_libs=built 68424642e01fSmrg ;; 68434642e01fSmrg -static-libtool-libs) 68444642e01fSmrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 68454642e01fSmrg dlopen_self=$dlopen_self_static 68464642e01fSmrg fi 68474642e01fSmrg prefer_static_libs=yes 68484642e01fSmrg ;; 68494642e01fSmrg esac 68504642e01fSmrg build_libtool_libs=no 68514642e01fSmrg build_old_libs=yes 68524642e01fSmrg break 68534642e01fSmrg ;; 68544642e01fSmrg esac 68554642e01fSmrg done 685605b261ecSmrg 68574642e01fSmrg # See if our shared archives depend on static archives. 68584642e01fSmrg test -n "$old_archive_from_new_cmds" && build_old_libs=yes 685905b261ecSmrg 68604642e01fSmrg # Go through the arguments, transforming them on the way. 68614642e01fSmrg while test "$#" -gt 0; do 686235c4bbdfSmrg arg=$1 68634642e01fSmrg shift 6864c82838c1Smrg func_quote_arg pretty,unquoted "$arg" 6865c82838c1Smrg qarg=$func_quote_arg_unquoted_result 6866c82838c1Smrg func_append libtool_args " $func_quote_arg_result" 686705b261ecSmrg 68684642e01fSmrg # If the previous option needs an argument, assign it. 68694642e01fSmrg if test -n "$prev"; then 68704642e01fSmrg case $prev in 68714642e01fSmrg output) 68724642e01fSmrg func_append compile_command " @OUTPUT@" 68734642e01fSmrg func_append finalize_command " @OUTPUT@" 68744642e01fSmrg ;; 68754642e01fSmrg esac 687605b261ecSmrg 68774642e01fSmrg case $prev in 68786747b715Smrg bindir) 687935c4bbdfSmrg bindir=$arg 68806747b715Smrg prev= 68816747b715Smrg continue 68826747b715Smrg ;; 68834642e01fSmrg dlfiles|dlprefiles) 688435c4bbdfSmrg $preload || { 68854642e01fSmrg # Add the symbol object into the linking commands. 68864642e01fSmrg func_append compile_command " @SYMFILE@" 68874642e01fSmrg func_append finalize_command " @SYMFILE@" 688835c4bbdfSmrg preload=: 688935c4bbdfSmrg } 68904642e01fSmrg case $arg in 68914642e01fSmrg *.la | *.lo) ;; # We handle these cases below. 68924642e01fSmrg force) 689335c4bbdfSmrg if test no = "$dlself"; then 68944642e01fSmrg dlself=needless 68954642e01fSmrg export_dynamic=yes 68964642e01fSmrg fi 68974642e01fSmrg prev= 68984642e01fSmrg continue 68994642e01fSmrg ;; 69004642e01fSmrg self) 690135c4bbdfSmrg if test dlprefiles = "$prev"; then 69024642e01fSmrg dlself=yes 690335c4bbdfSmrg elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then 69044642e01fSmrg dlself=yes 69054642e01fSmrg else 69064642e01fSmrg dlself=needless 69074642e01fSmrg export_dynamic=yes 69084642e01fSmrg fi 69094642e01fSmrg prev= 69104642e01fSmrg continue 69114642e01fSmrg ;; 69124642e01fSmrg *) 691335c4bbdfSmrg if test dlfiles = "$prev"; then 691435c4bbdfSmrg func_append dlfiles " $arg" 69154642e01fSmrg else 691635c4bbdfSmrg func_append dlprefiles " $arg" 69174642e01fSmrg fi 69184642e01fSmrg prev= 69194642e01fSmrg continue 69204642e01fSmrg ;; 69214642e01fSmrg esac 69224642e01fSmrg ;; 69234642e01fSmrg expsyms) 692435c4bbdfSmrg export_symbols=$arg 69254642e01fSmrg test -f "$arg" \ 692635c4bbdfSmrg || func_fatal_error "symbol file '$arg' does not exist" 69274642e01fSmrg prev= 69284642e01fSmrg continue 69294642e01fSmrg ;; 69304642e01fSmrg expsyms_regex) 693135c4bbdfSmrg export_symbols_regex=$arg 69324642e01fSmrg prev= 69334642e01fSmrg continue 69344642e01fSmrg ;; 69354642e01fSmrg framework) 693605b261ecSmrg case $host in 69374642e01fSmrg *-*-darwin*) 69384642e01fSmrg case "$deplibs " in 69394642e01fSmrg *" $qarg.ltframework "*) ;; 694035c4bbdfSmrg *) func_append deplibs " $qarg.ltframework" # this is fixed later 69414642e01fSmrg ;; 69424642e01fSmrg esac 69434642e01fSmrg ;; 694405b261ecSmrg esac 69454642e01fSmrg prev= 69464642e01fSmrg continue 694705b261ecSmrg ;; 69484642e01fSmrg inst_prefix) 694935c4bbdfSmrg inst_prefix_dir=$arg 695035c4bbdfSmrg prev= 695135c4bbdfSmrg continue 695235c4bbdfSmrg ;; 695335c4bbdfSmrg mllvm) 695435c4bbdfSmrg # Clang does not use LLVM to link, so we can simply discard any 695535c4bbdfSmrg # '-mllvm $arg' options when doing the link step. 69564642e01fSmrg prev= 69574642e01fSmrg continue 695805b261ecSmrg ;; 69594642e01fSmrg objectlist) 69604642e01fSmrg if test -f "$arg"; then 69614642e01fSmrg save_arg=$arg 69624642e01fSmrg moreargs= 69634642e01fSmrg for fil in `cat "$save_arg"` 69644642e01fSmrg do 696535c4bbdfSmrg# func_append moreargs " $fil" 69664642e01fSmrg arg=$fil 69674642e01fSmrg # A libtool-controlled object. 696805b261ecSmrg 69694642e01fSmrg # Check to see that this really is a libtool object. 69704642e01fSmrg if func_lalib_unsafe_p "$arg"; then 69714642e01fSmrg pic_object= 69724642e01fSmrg non_pic_object= 697305b261ecSmrg 69744642e01fSmrg # Read the .lo file 69754642e01fSmrg func_source "$arg" 697605b261ecSmrg 69774642e01fSmrg if test -z "$pic_object" || 69784642e01fSmrg test -z "$non_pic_object" || 697935c4bbdfSmrg test none = "$pic_object" && 698035c4bbdfSmrg test none = "$non_pic_object"; then 698135c4bbdfSmrg func_fatal_error "cannot find name of object for '$arg'" 69824642e01fSmrg fi 698305b261ecSmrg 69844642e01fSmrg # Extract subdirectory from the argument. 69854642e01fSmrg func_dirname "$arg" "/" "" 698635c4bbdfSmrg xdir=$func_dirname_result 698705b261ecSmrg 698835c4bbdfSmrg if test none != "$pic_object"; then 69894642e01fSmrg # Prepend the subdirectory the object is found in. 699035c4bbdfSmrg pic_object=$xdir$pic_object 699105b261ecSmrg 699235c4bbdfSmrg if test dlfiles = "$prev"; then 699335c4bbdfSmrg if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 699435c4bbdfSmrg func_append dlfiles " $pic_object" 69954642e01fSmrg prev= 69964642e01fSmrg continue 69974642e01fSmrg else 69984642e01fSmrg # If libtool objects are unsupported, then we need to preload. 69994642e01fSmrg prev=dlprefiles 70004642e01fSmrg fi 70014642e01fSmrg fi 700205b261ecSmrg 70034642e01fSmrg # CHECK ME: I think I busted this. -Ossama 700435c4bbdfSmrg if test dlprefiles = "$prev"; then 70054642e01fSmrg # Preload the old-style object. 700635c4bbdfSmrg func_append dlprefiles " $pic_object" 70074642e01fSmrg prev= 70084642e01fSmrg fi 700905b261ecSmrg 70104642e01fSmrg # A PIC object. 70114642e01fSmrg func_append libobjs " $pic_object" 701235c4bbdfSmrg arg=$pic_object 70134642e01fSmrg fi 701405b261ecSmrg 70154642e01fSmrg # Non-PIC object. 701635c4bbdfSmrg if test none != "$non_pic_object"; then 70174642e01fSmrg # Prepend the subdirectory the object is found in. 701835c4bbdfSmrg non_pic_object=$xdir$non_pic_object 701905b261ecSmrg 70204642e01fSmrg # A standard non-PIC object 70214642e01fSmrg func_append non_pic_objects " $non_pic_object" 702235c4bbdfSmrg if test -z "$pic_object" || test none = "$pic_object"; then 702335c4bbdfSmrg arg=$non_pic_object 70244642e01fSmrg fi 70254642e01fSmrg else 70264642e01fSmrg # If the PIC object exists, use it instead. 70274642e01fSmrg # $xdir was prepended to $pic_object above. 702835c4bbdfSmrg non_pic_object=$pic_object 70294642e01fSmrg func_append non_pic_objects " $non_pic_object" 70304642e01fSmrg fi 70314642e01fSmrg else 70324642e01fSmrg # Only an error if not doing a dry-run. 70334642e01fSmrg if $opt_dry_run; then 70344642e01fSmrg # Extract subdirectory from the argument. 70354642e01fSmrg func_dirname "$arg" "/" "" 703635c4bbdfSmrg xdir=$func_dirname_result 70374642e01fSmrg 70384642e01fSmrg func_lo2o "$arg" 70394642e01fSmrg pic_object=$xdir$objdir/$func_lo2o_result 70404642e01fSmrg non_pic_object=$xdir$func_lo2o_result 70414642e01fSmrg func_append libobjs " $pic_object" 70424642e01fSmrg func_append non_pic_objects " $non_pic_object" 70434642e01fSmrg else 704435c4bbdfSmrg func_fatal_error "'$arg' is not a valid libtool object" 70454642e01fSmrg fi 70464642e01fSmrg fi 70474642e01fSmrg done 704805b261ecSmrg else 704935c4bbdfSmrg func_fatal_error "link input file '$arg' does not exist" 705005b261ecSmrg fi 70514642e01fSmrg arg=$save_arg 70524642e01fSmrg prev= 70534642e01fSmrg continue 70544642e01fSmrg ;; 705535c4bbdfSmrg os2dllname) 705635c4bbdfSmrg os2dllname=$arg 705735c4bbdfSmrg prev= 705835c4bbdfSmrg continue 705935c4bbdfSmrg ;; 70604642e01fSmrg precious_regex) 706135c4bbdfSmrg precious_files_regex=$arg 70624642e01fSmrg prev= 70634642e01fSmrg continue 70644642e01fSmrg ;; 70654642e01fSmrg release) 706635c4bbdfSmrg release=-$arg 70674642e01fSmrg prev= 70684642e01fSmrg continue 70694642e01fSmrg ;; 70704642e01fSmrg rpath | xrpath) 70714642e01fSmrg # We need an absolute path. 70724642e01fSmrg case $arg in 70734642e01fSmrg [\\/]* | [A-Za-z]:[\\/]*) ;; 70744642e01fSmrg *) 70754642e01fSmrg func_fatal_error "only absolute run-paths are allowed" 70764642e01fSmrg ;; 70774642e01fSmrg esac 707835c4bbdfSmrg if test rpath = "$prev"; then 70794642e01fSmrg case "$rpath " in 70804642e01fSmrg *" $arg "*) ;; 708135c4bbdfSmrg *) func_append rpath " $arg" ;; 70824642e01fSmrg esac 708305b261ecSmrg else 70844642e01fSmrg case "$xrpath " in 70854642e01fSmrg *" $arg "*) ;; 708635c4bbdfSmrg *) func_append xrpath " $arg" ;; 70874642e01fSmrg esac 708805b261ecSmrg fi 70894642e01fSmrg prev= 70904642e01fSmrg continue 70914642e01fSmrg ;; 70924642e01fSmrg shrext) 709335c4bbdfSmrg shrext_cmds=$arg 70944642e01fSmrg prev= 70954642e01fSmrg continue 70964642e01fSmrg ;; 70974642e01fSmrg weak) 709835c4bbdfSmrg func_append weak_libs " $arg" 70994642e01fSmrg prev= 71004642e01fSmrg continue 71014642e01fSmrg ;; 7102c82838c1Smrg xassembler) 7103c82838c1Smrg func_append compiler_flags " -Xassembler $qarg" 7104c82838c1Smrg prev= 7105c82838c1Smrg func_append compile_command " -Xassembler $qarg" 7106c82838c1Smrg func_append finalize_command " -Xassembler $qarg" 7107c82838c1Smrg continue 7108c82838c1Smrg ;; 71094642e01fSmrg xcclinker) 711035c4bbdfSmrg func_append linker_flags " $qarg" 711135c4bbdfSmrg func_append compiler_flags " $qarg" 71124642e01fSmrg prev= 71134642e01fSmrg func_append compile_command " $qarg" 71144642e01fSmrg func_append finalize_command " $qarg" 71154642e01fSmrg continue 71164642e01fSmrg ;; 71174642e01fSmrg xcompiler) 711835c4bbdfSmrg func_append compiler_flags " $qarg" 71194642e01fSmrg prev= 71204642e01fSmrg func_append compile_command " $qarg" 71214642e01fSmrg func_append finalize_command " $qarg" 71224642e01fSmrg continue 71234642e01fSmrg ;; 71244642e01fSmrg xlinker) 712535c4bbdfSmrg func_append linker_flags " $qarg" 712635c4bbdfSmrg func_append compiler_flags " $wl$qarg" 71274642e01fSmrg prev= 71284642e01fSmrg func_append compile_command " $wl$qarg" 71294642e01fSmrg func_append finalize_command " $wl$qarg" 71304642e01fSmrg continue 71314642e01fSmrg ;; 71324642e01fSmrg *) 71334642e01fSmrg eval "$prev=\"\$arg\"" 71344642e01fSmrg prev= 71354642e01fSmrg continue 71364642e01fSmrg ;; 713705b261ecSmrg esac 71384642e01fSmrg fi # test -n "$prev" 713905b261ecSmrg 714035c4bbdfSmrg prevarg=$arg 714105b261ecSmrg 71424642e01fSmrg case $arg in 71434642e01fSmrg -all-static) 71444642e01fSmrg if test -n "$link_static_flag"; then 71454642e01fSmrg # See comment for -static flag below, for more details. 71464642e01fSmrg func_append compile_command " $link_static_flag" 71474642e01fSmrg func_append finalize_command " $link_static_flag" 71484642e01fSmrg fi 71494642e01fSmrg continue 71504642e01fSmrg ;; 715105b261ecSmrg 71524642e01fSmrg -allow-undefined) 71534642e01fSmrg # FIXME: remove this flag sometime in the future. 715435c4bbdfSmrg func_fatal_error "'-allow-undefined' must not be used because it is the default" 71554642e01fSmrg ;; 715605b261ecSmrg 71574642e01fSmrg -avoid-version) 71584642e01fSmrg avoid_version=yes 71594642e01fSmrg continue 71604642e01fSmrg ;; 716105b261ecSmrg 71626747b715Smrg -bindir) 71636747b715Smrg prev=bindir 71646747b715Smrg continue 71656747b715Smrg ;; 71666747b715Smrg 71674642e01fSmrg -dlopen) 71684642e01fSmrg prev=dlfiles 71694642e01fSmrg continue 71704642e01fSmrg ;; 717105b261ecSmrg 71724642e01fSmrg -dlpreopen) 71734642e01fSmrg prev=dlprefiles 71744642e01fSmrg continue 71754642e01fSmrg ;; 717605b261ecSmrg 71774642e01fSmrg -export-dynamic) 71784642e01fSmrg export_dynamic=yes 71794642e01fSmrg continue 71804642e01fSmrg ;; 718105b261ecSmrg 71824642e01fSmrg -export-symbols | -export-symbols-regex) 71834642e01fSmrg if test -n "$export_symbols" || test -n "$export_symbols_regex"; then 71844642e01fSmrg func_fatal_error "more than one -exported-symbols argument is not allowed" 71854642e01fSmrg fi 718635c4bbdfSmrg if test X-export-symbols = "X$arg"; then 71874642e01fSmrg prev=expsyms 71884642e01fSmrg else 71894642e01fSmrg prev=expsyms_regex 71904642e01fSmrg fi 71914642e01fSmrg continue 71924642e01fSmrg ;; 719305b261ecSmrg 71944642e01fSmrg -framework) 71954642e01fSmrg prev=framework 71964642e01fSmrg continue 71974642e01fSmrg ;; 719805b261ecSmrg 71994642e01fSmrg -inst-prefix-dir) 72004642e01fSmrg prev=inst_prefix 72014642e01fSmrg continue 72024642e01fSmrg ;; 720305b261ecSmrg 72044642e01fSmrg # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* 72054642e01fSmrg # so, if we see these flags be careful not to treat them like -L 72064642e01fSmrg -L[A-Z][A-Z]*:*) 72074642e01fSmrg case $with_gcc/$host in 72084642e01fSmrg no/*-*-irix* | /*-*-irix*) 72094642e01fSmrg func_append compile_command " $arg" 72104642e01fSmrg func_append finalize_command " $arg" 72114642e01fSmrg ;; 72124642e01fSmrg esac 72134642e01fSmrg continue 72144642e01fSmrg ;; 721505b261ecSmrg 72164642e01fSmrg -L*) 721735c4bbdfSmrg func_stripname "-L" '' "$arg" 721835c4bbdfSmrg if test -z "$func_stripname_result"; then 72194642e01fSmrg if test "$#" -gt 0; then 722035c4bbdfSmrg func_fatal_error "require no space between '-L' and '$1'" 72214642e01fSmrg else 722235c4bbdfSmrg func_fatal_error "need path for '-L' option" 72234642e01fSmrg fi 72244642e01fSmrg fi 722535c4bbdfSmrg func_resolve_sysroot "$func_stripname_result" 722635c4bbdfSmrg dir=$func_resolve_sysroot_result 72274642e01fSmrg # We need an absolute path. 72284642e01fSmrg case $dir in 72294642e01fSmrg [\\/]* | [A-Za-z]:[\\/]*) ;; 72304642e01fSmrg *) 72314642e01fSmrg absdir=`cd "$dir" && pwd` 72324642e01fSmrg test -z "$absdir" && \ 723335c4bbdfSmrg func_fatal_error "cannot determine absolute directory name of '$dir'" 723435c4bbdfSmrg dir=$absdir 72354642e01fSmrg ;; 72364642e01fSmrg esac 72374642e01fSmrg case "$deplibs " in 723835c4bbdfSmrg *" -L$dir "* | *" $arg "*) 723935c4bbdfSmrg # Will only happen for absolute or sysroot arguments 724035c4bbdfSmrg ;; 72414642e01fSmrg *) 724235c4bbdfSmrg # Preserve sysroot, but never include relative directories 724335c4bbdfSmrg case $dir in 724435c4bbdfSmrg [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; 724535c4bbdfSmrg *) func_append deplibs " -L$dir" ;; 724635c4bbdfSmrg esac 724735c4bbdfSmrg func_append lib_search_path " $dir" 72484642e01fSmrg ;; 72494642e01fSmrg esac 72504642e01fSmrg case $host in 72514642e01fSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 72526747b715Smrg testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` 72534642e01fSmrg case :$dllsearchpath: in 72544642e01fSmrg *":$dir:"*) ;; 72554642e01fSmrg ::) dllsearchpath=$dir;; 725635c4bbdfSmrg *) func_append dllsearchpath ":$dir";; 72574642e01fSmrg esac 72584642e01fSmrg case :$dllsearchpath: in 72594642e01fSmrg *":$testbindir:"*) ;; 72604642e01fSmrg ::) dllsearchpath=$testbindir;; 726135c4bbdfSmrg *) func_append dllsearchpath ":$testbindir";; 72624642e01fSmrg esac 72634642e01fSmrg ;; 72644642e01fSmrg esac 72654642e01fSmrg continue 72664642e01fSmrg ;; 726705b261ecSmrg 72684642e01fSmrg -l*) 726935c4bbdfSmrg if test X-lc = "X$arg" || test X-lm = "X$arg"; then 72704642e01fSmrg case $host in 72716747b715Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) 72724642e01fSmrg # These systems don't actually have a C or math library (as such) 72734642e01fSmrg continue 72744642e01fSmrg ;; 72754642e01fSmrg *-*-os2*) 72764642e01fSmrg # These systems don't actually have a C library (as such) 727735c4bbdfSmrg test X-lc = "X$arg" && continue 72784642e01fSmrg ;; 7279c82838c1Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig* | *-*-midnightbsd*) 72804642e01fSmrg # Do not include libc due to us having libc/libc_r. 728135c4bbdfSmrg test X-lc = "X$arg" && continue 72824642e01fSmrg ;; 72834642e01fSmrg *-*-rhapsody* | *-*-darwin1.[012]) 72844642e01fSmrg # Rhapsody C and math libraries are in the System framework 728535c4bbdfSmrg func_append deplibs " System.ltframework" 72864642e01fSmrg continue 72874642e01fSmrg ;; 72884642e01fSmrg *-*-sco3.2v5* | *-*-sco5v6*) 72894642e01fSmrg # Causes problems with __ctype 729035c4bbdfSmrg test X-lc = "X$arg" && continue 72914642e01fSmrg ;; 72924642e01fSmrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 72934642e01fSmrg # Compiler inserts libc in the correct place for threads to work 729435c4bbdfSmrg test X-lc = "X$arg" && continue 72954642e01fSmrg ;; 72964642e01fSmrg esac 729735c4bbdfSmrg elif test X-lc_r = "X$arg"; then 72984642e01fSmrg case $host in 7299c82838c1Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig* | *-*-midnightbsd*) 73004642e01fSmrg # Do not include libc_r directly, use -pthread flag. 73014642e01fSmrg continue 73024642e01fSmrg ;; 73034642e01fSmrg esac 73044642e01fSmrg fi 730535c4bbdfSmrg func_append deplibs " $arg" 730635c4bbdfSmrg continue 730735c4bbdfSmrg ;; 730835c4bbdfSmrg 730935c4bbdfSmrg -mllvm) 731035c4bbdfSmrg prev=mllvm 73114642e01fSmrg continue 73124642e01fSmrg ;; 731305b261ecSmrg 73144642e01fSmrg -module) 73154642e01fSmrg module=yes 73164642e01fSmrg continue 73174642e01fSmrg ;; 731805b261ecSmrg 73194642e01fSmrg # Tru64 UNIX uses -model [arg] to determine the layout of C++ 73204642e01fSmrg # classes, name mangling, and exception handling. 73214642e01fSmrg # Darwin uses the -arch flag to determine output architecture. 732235c4bbdfSmrg -model|-arch|-isysroot|--sysroot) 732335c4bbdfSmrg func_append compiler_flags " $arg" 73244642e01fSmrg func_append compile_command " $arg" 73254642e01fSmrg func_append finalize_command " $arg" 73264642e01fSmrg prev=xcompiler 73274642e01fSmrg continue 73284642e01fSmrg ;; 7329c82838c1Smrg # Solaris ld rejects as of 11.4. Refer to Oracle bug 22985199. 7330c82838c1Smrg -pthread) 7331c82838c1Smrg case $host in 7332c82838c1Smrg *solaris2*) ;; 7333c82838c1Smrg *) 7334c82838c1Smrg case "$new_inherited_linker_flags " in 7335c82838c1Smrg *" $arg "*) ;; 7336c82838c1Smrg * ) func_append new_inherited_linker_flags " $arg" ;; 7337c82838c1Smrg esac 7338c82838c1Smrg ;; 7339c82838c1Smrg esac 7340c82838c1Smrg continue 7341c82838c1Smrg ;; 7342c82838c1Smrg -mt|-mthreads|-kthread|-Kthread|-pthreads|--thread-safe \ 734335c4bbdfSmrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 734435c4bbdfSmrg func_append compiler_flags " $arg" 73454642e01fSmrg func_append compile_command " $arg" 73464642e01fSmrg func_append finalize_command " $arg" 73474642e01fSmrg case "$new_inherited_linker_flags " in 73484642e01fSmrg *" $arg "*) ;; 734935c4bbdfSmrg * ) func_append new_inherited_linker_flags " $arg" ;; 73504642e01fSmrg esac 73514642e01fSmrg continue 73524642e01fSmrg ;; 735305b261ecSmrg 73544642e01fSmrg -multi_module) 735535c4bbdfSmrg single_module=$wl-multi_module 73564642e01fSmrg continue 73574642e01fSmrg ;; 735805b261ecSmrg 73594642e01fSmrg -no-fast-install) 73604642e01fSmrg fast_install=no 73614642e01fSmrg continue 73624642e01fSmrg ;; 736305b261ecSmrg 73644642e01fSmrg -no-install) 73654642e01fSmrg case $host in 73664642e01fSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) 73674642e01fSmrg # The PATH hackery in wrapper scripts is required on Windows 73684642e01fSmrg # and Darwin in order for the loader to find any dlls it needs. 736935c4bbdfSmrg func_warning "'-no-install' is ignored for $host" 737035c4bbdfSmrg func_warning "assuming '-no-fast-install' instead" 73714642e01fSmrg fast_install=no 73724642e01fSmrg ;; 73734642e01fSmrg *) no_install=yes ;; 73744642e01fSmrg esac 73754642e01fSmrg continue 73764642e01fSmrg ;; 737705b261ecSmrg 73784642e01fSmrg -no-undefined) 73794642e01fSmrg allow_undefined=no 73804642e01fSmrg continue 73814642e01fSmrg ;; 738205b261ecSmrg 73834642e01fSmrg -objectlist) 73844642e01fSmrg prev=objectlist 73854642e01fSmrg continue 73864642e01fSmrg ;; 738705b261ecSmrg 738835c4bbdfSmrg -os2dllname) 738935c4bbdfSmrg prev=os2dllname 739035c4bbdfSmrg continue 739135c4bbdfSmrg ;; 739235c4bbdfSmrg 73934642e01fSmrg -o) prev=output ;; 739405b261ecSmrg 73954642e01fSmrg -precious-files-regex) 73964642e01fSmrg prev=precious_regex 73974642e01fSmrg continue 73984642e01fSmrg ;; 739905b261ecSmrg 74004642e01fSmrg -release) 74014642e01fSmrg prev=release 74024642e01fSmrg continue 74034642e01fSmrg ;; 740405b261ecSmrg 74054642e01fSmrg -rpath) 74064642e01fSmrg prev=rpath 74074642e01fSmrg continue 74084642e01fSmrg ;; 740905b261ecSmrg 74104642e01fSmrg -R) 74114642e01fSmrg prev=xrpath 74124642e01fSmrg continue 74134642e01fSmrg ;; 741405b261ecSmrg 74154642e01fSmrg -R*) 74164642e01fSmrg func_stripname '-R' '' "$arg" 74174642e01fSmrg dir=$func_stripname_result 74184642e01fSmrg # We need an absolute path. 74194642e01fSmrg case $dir in 74204642e01fSmrg [\\/]* | [A-Za-z]:[\\/]*) ;; 742135c4bbdfSmrg =*) 742235c4bbdfSmrg func_stripname '=' '' "$dir" 742335c4bbdfSmrg dir=$lt_sysroot$func_stripname_result 742435c4bbdfSmrg ;; 74254642e01fSmrg *) 74264642e01fSmrg func_fatal_error "only absolute run-paths are allowed" 74274642e01fSmrg ;; 74284642e01fSmrg esac 74294642e01fSmrg case "$xrpath " in 74304642e01fSmrg *" $dir "*) ;; 743135c4bbdfSmrg *) func_append xrpath " $dir" ;; 74324642e01fSmrg esac 74334642e01fSmrg continue 74344642e01fSmrg ;; 743505b261ecSmrg 74364642e01fSmrg -shared) 74374642e01fSmrg # The effects of -shared are defined in a previous loop. 74384642e01fSmrg continue 74394642e01fSmrg ;; 744005b261ecSmrg 74414642e01fSmrg -shrext) 74424642e01fSmrg prev=shrext 74434642e01fSmrg continue 74444642e01fSmrg ;; 744505b261ecSmrg 74464642e01fSmrg -static | -static-libtool-libs) 74474642e01fSmrg # The effects of -static are defined in a previous loop. 74484642e01fSmrg # We used to do the same as -all-static on platforms that 74494642e01fSmrg # didn't have a PIC flag, but the assumption that the effects 74504642e01fSmrg # would be equivalent was wrong. It would break on at least 74514642e01fSmrg # Digital Unix and AIX. 74524642e01fSmrg continue 74534642e01fSmrg ;; 745405b261ecSmrg 74554642e01fSmrg -thread-safe) 74564642e01fSmrg thread_safe=yes 74574642e01fSmrg continue 74584642e01fSmrg ;; 745905b261ecSmrg 74604642e01fSmrg -version-info) 74614642e01fSmrg prev=vinfo 74624642e01fSmrg continue 74634642e01fSmrg ;; 746405b261ecSmrg 74654642e01fSmrg -version-number) 74664642e01fSmrg prev=vinfo 74674642e01fSmrg vinfo_number=yes 74684642e01fSmrg continue 74694642e01fSmrg ;; 747005b261ecSmrg 74714642e01fSmrg -weak) 74724642e01fSmrg prev=weak 74734642e01fSmrg continue 74744642e01fSmrg ;; 747505b261ecSmrg 74764642e01fSmrg -Wc,*) 74774642e01fSmrg func_stripname '-Wc,' '' "$arg" 74784642e01fSmrg args=$func_stripname_result 74794642e01fSmrg arg= 748035c4bbdfSmrg save_ifs=$IFS; IFS=, 74814642e01fSmrg for flag in $args; do 748235c4bbdfSmrg IFS=$save_ifs 7483c82838c1Smrg func_quote_arg pretty "$flag" 7484c82838c1Smrg func_append arg " $func_quote_arg_result" 7485c82838c1Smrg func_append compiler_flags " $func_quote_arg_result" 74864642e01fSmrg done 748735c4bbdfSmrg IFS=$save_ifs 74884642e01fSmrg func_stripname ' ' '' "$arg" 74894642e01fSmrg arg=$func_stripname_result 74904642e01fSmrg ;; 749105b261ecSmrg 74924642e01fSmrg -Wl,*) 74934642e01fSmrg func_stripname '-Wl,' '' "$arg" 74944642e01fSmrg args=$func_stripname_result 74954642e01fSmrg arg= 749635c4bbdfSmrg save_ifs=$IFS; IFS=, 74974642e01fSmrg for flag in $args; do 749835c4bbdfSmrg IFS=$save_ifs 7499c82838c1Smrg func_quote_arg pretty "$flag" 7500c82838c1Smrg func_append arg " $wl$func_quote_arg_result" 7501c82838c1Smrg func_append compiler_flags " $wl$func_quote_arg_result" 7502c82838c1Smrg func_append linker_flags " $func_quote_arg_result" 75034642e01fSmrg done 750435c4bbdfSmrg IFS=$save_ifs 75054642e01fSmrg func_stripname ' ' '' "$arg" 75064642e01fSmrg arg=$func_stripname_result 75074642e01fSmrg ;; 750805b261ecSmrg 7509c82838c1Smrg -Xassembler) 7510c82838c1Smrg prev=xassembler 7511c82838c1Smrg continue 7512c82838c1Smrg ;; 7513c82838c1Smrg 75144642e01fSmrg -Xcompiler) 75154642e01fSmrg prev=xcompiler 75164642e01fSmrg continue 75174642e01fSmrg ;; 751805b261ecSmrg 75194642e01fSmrg -Xlinker) 75204642e01fSmrg prev=xlinker 75214642e01fSmrg continue 75224642e01fSmrg ;; 752305b261ecSmrg 75244642e01fSmrg -XCClinker) 75254642e01fSmrg prev=xcclinker 75264642e01fSmrg continue 75274642e01fSmrg ;; 752805b261ecSmrg 75294642e01fSmrg # -msg_* for osf cc 75304642e01fSmrg -msg_*) 7531c82838c1Smrg func_quote_arg pretty "$arg" 7532c82838c1Smrg arg=$func_quote_arg_result 75334642e01fSmrg ;; 753405b261ecSmrg 75356747b715Smrg # Flags to be passed through unchanged, with rationale: 75366747b715Smrg # -64, -mips[0-9] enable 64-bit mode for the SGI compiler 75376747b715Smrg # -r[0-9][0-9]* specify processor for the SGI compiler 75386747b715Smrg # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler 75396747b715Smrg # +DA*, +DD* enable 64-bit mode for the HP compiler 75406747b715Smrg # -q* compiler args for the IBM compiler 75416747b715Smrg # -m*, -t[45]*, -txscale* architecture-specific flags for GCC 75426747b715Smrg # -F/path path to uninstalled frameworks, gcc on darwin 75436747b715Smrg # -p, -pg, --coverage, -fprofile-* profiling flags for GCC 754435c4bbdfSmrg # -fstack-protector* stack protector flags for GCC 75456747b715Smrg # @file GCC response files 75466747b715Smrg # -tp=* Portland pgcc target processor selection 754735c4bbdfSmrg # --sysroot=* for sysroot support 754835c4bbdfSmrg # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization 75491b5d61b8Smrg # -specs=* GCC specs files 755035c4bbdfSmrg # -stdlib=* select c++ std lib with clang 755125da500fSmrg # -fsanitize=* Clang/GCC memory and address sanitizer 755225da500fSmrg # -fuse-ld=* Linker select flags for GCC 7553c82838c1Smrg # -Wa,* Pass flags directly to the assembler 75544642e01fSmrg -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ 755535c4bbdfSmrg -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ 75561b5d61b8Smrg -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*| \ 755758cf2af7Smrg -specs=*|-fsanitize=*|-fuse-ld=*|-Wa,*) 7558c82838c1Smrg func_quote_arg pretty "$arg" 7559c82838c1Smrg arg=$func_quote_arg_result 75604642e01fSmrg func_append compile_command " $arg" 75614642e01fSmrg func_append finalize_command " $arg" 756235c4bbdfSmrg func_append compiler_flags " $arg" 75634642e01fSmrg continue 75644642e01fSmrg ;; 756505b261ecSmrg 756635c4bbdfSmrg -Z*) 756735c4bbdfSmrg if test os2 = "`expr $host : '.*\(os2\)'`"; then 756835c4bbdfSmrg # OS/2 uses -Zxxx to specify OS/2-specific options 756935c4bbdfSmrg compiler_flags="$compiler_flags $arg" 757035c4bbdfSmrg func_append compile_command " $arg" 757135c4bbdfSmrg func_append finalize_command " $arg" 757235c4bbdfSmrg case $arg in 757335c4bbdfSmrg -Zlinker | -Zstack) 757435c4bbdfSmrg prev=xcompiler 757535c4bbdfSmrg ;; 757635c4bbdfSmrg esac 757735c4bbdfSmrg continue 757835c4bbdfSmrg else 757935c4bbdfSmrg # Otherwise treat like 'Some other compiler flag' below 7580c82838c1Smrg func_quote_arg pretty "$arg" 7581c82838c1Smrg arg=$func_quote_arg_result 758235c4bbdfSmrg fi 758335c4bbdfSmrg ;; 758435c4bbdfSmrg 75854642e01fSmrg # Some other compiler flag. 75864642e01fSmrg -* | +*) 7587c82838c1Smrg func_quote_arg pretty "$arg" 7588c82838c1Smrg arg=$func_quote_arg_result 75894642e01fSmrg ;; 759005b261ecSmrg 75914642e01fSmrg *.$objext) 75924642e01fSmrg # A standard object. 759335c4bbdfSmrg func_append objs " $arg" 75944642e01fSmrg ;; 759505b261ecSmrg 75964642e01fSmrg *.lo) 75974642e01fSmrg # A libtool-controlled object. 759805b261ecSmrg 75994642e01fSmrg # Check to see that this really is a libtool object. 76004642e01fSmrg if func_lalib_unsafe_p "$arg"; then 76014642e01fSmrg pic_object= 76024642e01fSmrg non_pic_object= 760305b261ecSmrg 76044642e01fSmrg # Read the .lo file 76054642e01fSmrg func_source "$arg" 760605b261ecSmrg 76074642e01fSmrg if test -z "$pic_object" || 76084642e01fSmrg test -z "$non_pic_object" || 760935c4bbdfSmrg test none = "$pic_object" && 761035c4bbdfSmrg test none = "$non_pic_object"; then 761135c4bbdfSmrg func_fatal_error "cannot find name of object for '$arg'" 76124642e01fSmrg fi 761305b261ecSmrg 76144642e01fSmrg # Extract subdirectory from the argument. 76154642e01fSmrg func_dirname "$arg" "/" "" 761635c4bbdfSmrg xdir=$func_dirname_result 761705b261ecSmrg 761835c4bbdfSmrg test none = "$pic_object" || { 76194642e01fSmrg # Prepend the subdirectory the object is found in. 762035c4bbdfSmrg pic_object=$xdir$pic_object 762105b261ecSmrg 762235c4bbdfSmrg if test dlfiles = "$prev"; then 762335c4bbdfSmrg if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 762435c4bbdfSmrg func_append dlfiles " $pic_object" 76254642e01fSmrg prev= 76264642e01fSmrg continue 76274642e01fSmrg else 76284642e01fSmrg # If libtool objects are unsupported, then we need to preload. 76294642e01fSmrg prev=dlprefiles 76304642e01fSmrg fi 76314642e01fSmrg fi 763205b261ecSmrg 76334642e01fSmrg # CHECK ME: I think I busted this. -Ossama 763435c4bbdfSmrg if test dlprefiles = "$prev"; then 76354642e01fSmrg # Preload the old-style object. 763635c4bbdfSmrg func_append dlprefiles " $pic_object" 76374642e01fSmrg prev= 76384642e01fSmrg fi 763905b261ecSmrg 76404642e01fSmrg # A PIC object. 76414642e01fSmrg func_append libobjs " $pic_object" 764235c4bbdfSmrg arg=$pic_object 764335c4bbdfSmrg } 764405b261ecSmrg 76454642e01fSmrg # Non-PIC object. 764635c4bbdfSmrg if test none != "$non_pic_object"; then 76474642e01fSmrg # Prepend the subdirectory the object is found in. 764835c4bbdfSmrg non_pic_object=$xdir$non_pic_object 764905b261ecSmrg 76504642e01fSmrg # A standard non-PIC object 76514642e01fSmrg func_append non_pic_objects " $non_pic_object" 765235c4bbdfSmrg if test -z "$pic_object" || test none = "$pic_object"; then 765335c4bbdfSmrg arg=$non_pic_object 76544642e01fSmrg fi 76554642e01fSmrg else 76564642e01fSmrg # If the PIC object exists, use it instead. 76574642e01fSmrg # $xdir was prepended to $pic_object above. 765835c4bbdfSmrg non_pic_object=$pic_object 76594642e01fSmrg func_append non_pic_objects " $non_pic_object" 76604642e01fSmrg fi 76614642e01fSmrg else 76624642e01fSmrg # Only an error if not doing a dry-run. 76634642e01fSmrg if $opt_dry_run; then 76644642e01fSmrg # Extract subdirectory from the argument. 76654642e01fSmrg func_dirname "$arg" "/" "" 766635c4bbdfSmrg xdir=$func_dirname_result 76674642e01fSmrg 76684642e01fSmrg func_lo2o "$arg" 76694642e01fSmrg pic_object=$xdir$objdir/$func_lo2o_result 76704642e01fSmrg non_pic_object=$xdir$func_lo2o_result 76714642e01fSmrg func_append libobjs " $pic_object" 76724642e01fSmrg func_append non_pic_objects " $non_pic_object" 76734642e01fSmrg else 767435c4bbdfSmrg func_fatal_error "'$arg' is not a valid libtool object" 76754642e01fSmrg fi 76764642e01fSmrg fi 76774642e01fSmrg ;; 76784642e01fSmrg 76794642e01fSmrg *.$libext) 76804642e01fSmrg # An archive. 768135c4bbdfSmrg func_append deplibs " $arg" 768235c4bbdfSmrg func_append old_deplibs " $arg" 76834642e01fSmrg continue 76844642e01fSmrg ;; 76854642e01fSmrg 76864642e01fSmrg *.la) 76874642e01fSmrg # A libtool-controlled library. 76884642e01fSmrg 768935c4bbdfSmrg func_resolve_sysroot "$arg" 769035c4bbdfSmrg if test dlfiles = "$prev"; then 76914642e01fSmrg # This library was specified with -dlopen. 769235c4bbdfSmrg func_append dlfiles " $func_resolve_sysroot_result" 76934642e01fSmrg prev= 769435c4bbdfSmrg elif test dlprefiles = "$prev"; then 76954642e01fSmrg # The library was specified with -dlpreopen. 769635c4bbdfSmrg func_append dlprefiles " $func_resolve_sysroot_result" 76974642e01fSmrg prev= 76984642e01fSmrg else 769935c4bbdfSmrg func_append deplibs " $func_resolve_sysroot_result" 77004642e01fSmrg fi 77014642e01fSmrg continue 77024642e01fSmrg ;; 77034642e01fSmrg 77044642e01fSmrg # Some other compiler argument. 77054642e01fSmrg *) 77064642e01fSmrg # Unknown arguments in both finalize_command and compile_command need 77074642e01fSmrg # to be aesthetically quoted because they are evaled later. 7708c82838c1Smrg func_quote_arg pretty "$arg" 7709c82838c1Smrg arg=$func_quote_arg_result 77104642e01fSmrg ;; 77114642e01fSmrg esac # arg 77124642e01fSmrg 77134642e01fSmrg # Now actually substitute the argument into the commands. 77144642e01fSmrg if test -n "$arg"; then 77154642e01fSmrg func_append compile_command " $arg" 77164642e01fSmrg func_append finalize_command " $arg" 77174642e01fSmrg fi 77184642e01fSmrg done # argument parsing loop 77194642e01fSmrg 77204642e01fSmrg test -n "$prev" && \ 772135c4bbdfSmrg func_fatal_help "the '$prevarg' option requires an argument" 77224642e01fSmrg 772335c4bbdfSmrg if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then 77244642e01fSmrg eval arg=\"$export_dynamic_flag_spec\" 77254642e01fSmrg func_append compile_command " $arg" 77264642e01fSmrg func_append finalize_command " $arg" 77274642e01fSmrg fi 77284642e01fSmrg 77294642e01fSmrg oldlibs= 77304642e01fSmrg # calculate the name of the file, without its directory 77314642e01fSmrg func_basename "$output" 773235c4bbdfSmrg outputname=$func_basename_result 773335c4bbdfSmrg libobjs_save=$libobjs 77344642e01fSmrg 77354642e01fSmrg if test -n "$shlibpath_var"; then 77364642e01fSmrg # get the directories listed in $shlibpath_var 773735c4bbdfSmrg eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\` 77384642e01fSmrg else 77394642e01fSmrg shlib_search_path= 77404642e01fSmrg fi 77414642e01fSmrg eval sys_lib_search_path=\"$sys_lib_search_path_spec\" 77424642e01fSmrg eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" 77434642e01fSmrg 774435c4bbdfSmrg # Definition is injected by LT_CONFIG during libtool generation. 774535c4bbdfSmrg func_munge_path_list sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH" 774635c4bbdfSmrg 77474642e01fSmrg func_dirname "$output" "/" "" 774835c4bbdfSmrg output_objdir=$func_dirname_result$objdir 774935c4bbdfSmrg func_to_tool_file "$output_objdir/" 775035c4bbdfSmrg tool_output_objdir=$func_to_tool_file_result 77514642e01fSmrg # Create the object directory. 77524642e01fSmrg func_mkdir_p "$output_objdir" 77534642e01fSmrg 77544642e01fSmrg # Determine the type of output 77554642e01fSmrg case $output in 77564642e01fSmrg "") 77574642e01fSmrg func_fatal_help "you must specify an output file" 77584642e01fSmrg ;; 77594642e01fSmrg *.$libext) linkmode=oldlib ;; 77604642e01fSmrg *.lo | *.$objext) linkmode=obj ;; 77614642e01fSmrg *.la) linkmode=lib ;; 77624642e01fSmrg *) linkmode=prog ;; # Anything else should be a program. 77634642e01fSmrg esac 77644642e01fSmrg 77654642e01fSmrg specialdeplibs= 77664642e01fSmrg 77674642e01fSmrg libs= 77684642e01fSmrg # Find all interdependent deplibs by searching for libraries 77694642e01fSmrg # that are linked more than once (e.g. -la -lb -la) 77704642e01fSmrg for deplib in $deplibs; do 777135c4bbdfSmrg if $opt_preserve_dup_deps; then 77724642e01fSmrg case "$libs " in 777335c4bbdfSmrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 77744642e01fSmrg esac 77754642e01fSmrg fi 777635c4bbdfSmrg func_append libs " $deplib" 77774642e01fSmrg done 77784642e01fSmrg 777935c4bbdfSmrg if test lib = "$linkmode"; then 77804642e01fSmrg libs="$predeps $libs $compiler_lib_search_path $postdeps" 77814642e01fSmrg 77824642e01fSmrg # Compute libraries that are listed more than once in $predeps 77834642e01fSmrg # $postdeps and mark them as special (i.e., whose duplicates are 77844642e01fSmrg # not to be eliminated). 77854642e01fSmrg pre_post_deps= 77864642e01fSmrg if $opt_duplicate_compiler_generated_deps; then 77874642e01fSmrg for pre_post_dep in $predeps $postdeps; do 77884642e01fSmrg case "$pre_post_deps " in 778935c4bbdfSmrg *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; 77904642e01fSmrg esac 779135c4bbdfSmrg func_append pre_post_deps " $pre_post_dep" 77924642e01fSmrg done 77934642e01fSmrg fi 77944642e01fSmrg pre_post_deps= 77954642e01fSmrg fi 77964642e01fSmrg 77974642e01fSmrg deplibs= 77984642e01fSmrg newdependency_libs= 77994642e01fSmrg newlib_search_path= 78004642e01fSmrg need_relink=no # whether we're linking any uninstalled libtool libraries 78014642e01fSmrg notinst_deplibs= # not-installed libtool libraries 78024642e01fSmrg notinst_path= # paths that contain not-installed libtool libraries 78034642e01fSmrg 78044642e01fSmrg case $linkmode in 78054642e01fSmrg lib) 78064642e01fSmrg passes="conv dlpreopen link" 78074642e01fSmrg for file in $dlfiles $dlprefiles; do 78084642e01fSmrg case $file in 78094642e01fSmrg *.la) ;; 78104642e01fSmrg *) 781135c4bbdfSmrg func_fatal_help "libraries can '-dlopen' only libtool libraries: $file" 78124642e01fSmrg ;; 78134642e01fSmrg esac 78144642e01fSmrg done 78154642e01fSmrg ;; 78164642e01fSmrg prog) 78174642e01fSmrg compile_deplibs= 78184642e01fSmrg finalize_deplibs= 781935c4bbdfSmrg alldeplibs=false 78204642e01fSmrg newdlfiles= 78214642e01fSmrg newdlprefiles= 78224642e01fSmrg passes="conv scan dlopen dlpreopen link" 78234642e01fSmrg ;; 78244642e01fSmrg *) passes="conv" 78254642e01fSmrg ;; 78264642e01fSmrg esac 78274642e01fSmrg 78284642e01fSmrg for pass in $passes; do 78294642e01fSmrg # The preopen pass in lib mode reverses $deplibs; put it back here 78304642e01fSmrg # so that -L comes before libs that need it for instance... 783135c4bbdfSmrg if test lib,link = "$linkmode,$pass"; then 78324642e01fSmrg ## FIXME: Find the place where the list is rebuilt in the wrong 78334642e01fSmrg ## order, and fix it there properly 78344642e01fSmrg tmp_deplibs= 78354642e01fSmrg for deplib in $deplibs; do 78364642e01fSmrg tmp_deplibs="$deplib $tmp_deplibs" 78374642e01fSmrg done 783835c4bbdfSmrg deplibs=$tmp_deplibs 78394642e01fSmrg fi 78404642e01fSmrg 784135c4bbdfSmrg if test lib,link = "$linkmode,$pass" || 784235c4bbdfSmrg test prog,scan = "$linkmode,$pass"; then 784335c4bbdfSmrg libs=$deplibs 78444642e01fSmrg deplibs= 78454642e01fSmrg fi 784635c4bbdfSmrg if test prog = "$linkmode"; then 78474642e01fSmrg case $pass in 784835c4bbdfSmrg dlopen) libs=$dlfiles ;; 784935c4bbdfSmrg dlpreopen) libs=$dlprefiles ;; 7850c82838c1Smrg link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; 78514642e01fSmrg esac 78524642e01fSmrg fi 785335c4bbdfSmrg if test lib,dlpreopen = "$linkmode,$pass"; then 78544642e01fSmrg # Collect and forward deplibs of preopened libtool libs 78554642e01fSmrg for lib in $dlprefiles; do 78564642e01fSmrg # Ignore non-libtool-libs 78574642e01fSmrg dependency_libs= 785835c4bbdfSmrg func_resolve_sysroot "$lib" 78594642e01fSmrg case $lib in 786035c4bbdfSmrg *.la) func_source "$func_resolve_sysroot_result" ;; 78614642e01fSmrg esac 78624642e01fSmrg 78634642e01fSmrg # Collect preopened libtool deplibs, except any this library 78644642e01fSmrg # has declared as weak libs 78654642e01fSmrg for deplib in $dependency_libs; do 78666747b715Smrg func_basename "$deplib" 78676747b715Smrg deplib_base=$func_basename_result 78684642e01fSmrg case " $weak_libs " in 78694642e01fSmrg *" $deplib_base "*) ;; 787035c4bbdfSmrg *) func_append deplibs " $deplib" ;; 78714642e01fSmrg esac 78724642e01fSmrg done 78734642e01fSmrg done 787435c4bbdfSmrg libs=$dlprefiles 78754642e01fSmrg fi 787635c4bbdfSmrg if test dlopen = "$pass"; then 78774642e01fSmrg # Collect dlpreopened libraries 787835c4bbdfSmrg save_deplibs=$deplibs 78794642e01fSmrg deplibs= 78804642e01fSmrg fi 78814642e01fSmrg 78824642e01fSmrg for deplib in $libs; do 78834642e01fSmrg lib= 788435c4bbdfSmrg found=false 78854642e01fSmrg case $deplib in 788635c4bbdfSmrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 788735c4bbdfSmrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 788835c4bbdfSmrg if test prog,link = "$linkmode,$pass"; then 78894642e01fSmrg compile_deplibs="$deplib $compile_deplibs" 78904642e01fSmrg finalize_deplibs="$deplib $finalize_deplibs" 78914642e01fSmrg else 789235c4bbdfSmrg func_append compiler_flags " $deplib" 789335c4bbdfSmrg if test lib = "$linkmode"; then 78944642e01fSmrg case "$new_inherited_linker_flags " in 78954642e01fSmrg *" $deplib "*) ;; 789635c4bbdfSmrg * ) func_append new_inherited_linker_flags " $deplib" ;; 78974642e01fSmrg esac 78984642e01fSmrg fi 78994642e01fSmrg fi 79004642e01fSmrg continue 79014642e01fSmrg ;; 79024642e01fSmrg -l*) 790335c4bbdfSmrg if test lib != "$linkmode" && test prog != "$linkmode"; then 790435c4bbdfSmrg func_warning "'-l' is ignored for archives/objects" 79054642e01fSmrg continue 79064642e01fSmrg fi 79074642e01fSmrg func_stripname '-l' '' "$deplib" 79084642e01fSmrg name=$func_stripname_result 790935c4bbdfSmrg if test lib = "$linkmode"; then 79104642e01fSmrg searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" 79114642e01fSmrg else 79124642e01fSmrg searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" 79134642e01fSmrg fi 79144642e01fSmrg for searchdir in $searchdirs; do 79154642e01fSmrg for search_ext in .la $std_shrext .so .a; do 79164642e01fSmrg # Search the libtool library 791735c4bbdfSmrg lib=$searchdir/lib$name$search_ext 79184642e01fSmrg if test -f "$lib"; then 791935c4bbdfSmrg if test .la = "$search_ext"; then 792035c4bbdfSmrg found=: 79214642e01fSmrg else 792235c4bbdfSmrg found=false 79234642e01fSmrg fi 79244642e01fSmrg break 2 79254642e01fSmrg fi 79264642e01fSmrg done 79274642e01fSmrg done 792835c4bbdfSmrg if $found; then 792935c4bbdfSmrg # deplib is a libtool library 79304642e01fSmrg # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, 79314642e01fSmrg # We need to do some special things here, and not later. 793235c4bbdfSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 79334642e01fSmrg case " $predeps $postdeps " in 79344642e01fSmrg *" $deplib "*) 79354642e01fSmrg if func_lalib_p "$lib"; then 79364642e01fSmrg library_names= 79374642e01fSmrg old_library= 79384642e01fSmrg func_source "$lib" 79394642e01fSmrg for l in $old_library $library_names; do 794035c4bbdfSmrg ll=$l 79414642e01fSmrg done 794235c4bbdfSmrg if test "X$ll" = "X$old_library"; then # only static version available 794335c4bbdfSmrg found=false 79444642e01fSmrg func_dirname "$lib" "" "." 794535c4bbdfSmrg ladir=$func_dirname_result 79464642e01fSmrg lib=$ladir/$old_library 794735c4bbdfSmrg if test prog,link = "$linkmode,$pass"; then 79484642e01fSmrg compile_deplibs="$deplib $compile_deplibs" 79494642e01fSmrg finalize_deplibs="$deplib $finalize_deplibs" 79504642e01fSmrg else 79514642e01fSmrg deplibs="$deplib $deplibs" 795235c4bbdfSmrg test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 79534642e01fSmrg fi 79544642e01fSmrg continue 79554642e01fSmrg fi 79564642e01fSmrg fi 79574642e01fSmrg ;; 79584642e01fSmrg *) ;; 79594642e01fSmrg esac 79604642e01fSmrg fi 796135c4bbdfSmrg else 796235c4bbdfSmrg # deplib doesn't seem to be a libtool library 796335c4bbdfSmrg if test prog,link = "$linkmode,$pass"; then 796435c4bbdfSmrg compile_deplibs="$deplib $compile_deplibs" 796535c4bbdfSmrg finalize_deplibs="$deplib $finalize_deplibs" 796635c4bbdfSmrg else 796735c4bbdfSmrg deplibs="$deplib $deplibs" 796835c4bbdfSmrg test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 796935c4bbdfSmrg fi 797035c4bbdfSmrg continue 79714642e01fSmrg fi 79724642e01fSmrg ;; # -l 79734642e01fSmrg *.ltframework) 797435c4bbdfSmrg if test prog,link = "$linkmode,$pass"; then 79754642e01fSmrg compile_deplibs="$deplib $compile_deplibs" 79764642e01fSmrg finalize_deplibs="$deplib $finalize_deplibs" 79774642e01fSmrg else 79784642e01fSmrg deplibs="$deplib $deplibs" 797935c4bbdfSmrg if test lib = "$linkmode"; then 79804642e01fSmrg case "$new_inherited_linker_flags " in 79814642e01fSmrg *" $deplib "*) ;; 798235c4bbdfSmrg * ) func_append new_inherited_linker_flags " $deplib" ;; 79834642e01fSmrg esac 79844642e01fSmrg fi 79854642e01fSmrg fi 79864642e01fSmrg continue 79874642e01fSmrg ;; 79884642e01fSmrg -L*) 79894642e01fSmrg case $linkmode in 79904642e01fSmrg lib) 79914642e01fSmrg deplibs="$deplib $deplibs" 799235c4bbdfSmrg test conv = "$pass" && continue 79934642e01fSmrg newdependency_libs="$deplib $newdependency_libs" 79944642e01fSmrg func_stripname '-L' '' "$deplib" 799535c4bbdfSmrg func_resolve_sysroot "$func_stripname_result" 799635c4bbdfSmrg func_append newlib_search_path " $func_resolve_sysroot_result" 79974642e01fSmrg ;; 79984642e01fSmrg prog) 799935c4bbdfSmrg if test conv = "$pass"; then 80004642e01fSmrg deplibs="$deplib $deplibs" 80014642e01fSmrg continue 80024642e01fSmrg fi 800335c4bbdfSmrg if test scan = "$pass"; then 80044642e01fSmrg deplibs="$deplib $deplibs" 80054642e01fSmrg else 80064642e01fSmrg compile_deplibs="$deplib $compile_deplibs" 80074642e01fSmrg finalize_deplibs="$deplib $finalize_deplibs" 80084642e01fSmrg fi 80094642e01fSmrg func_stripname '-L' '' "$deplib" 801035c4bbdfSmrg func_resolve_sysroot "$func_stripname_result" 801135c4bbdfSmrg func_append newlib_search_path " $func_resolve_sysroot_result" 80124642e01fSmrg ;; 80134642e01fSmrg *) 801435c4bbdfSmrg func_warning "'-L' is ignored for archives/objects" 80154642e01fSmrg ;; 80164642e01fSmrg esac # linkmode 80174642e01fSmrg continue 80184642e01fSmrg ;; # -L 80194642e01fSmrg -R*) 802035c4bbdfSmrg if test link = "$pass"; then 80214642e01fSmrg func_stripname '-R' '' "$deplib" 802235c4bbdfSmrg func_resolve_sysroot "$func_stripname_result" 802335c4bbdfSmrg dir=$func_resolve_sysroot_result 80244642e01fSmrg # Make sure the xrpath contains only unique directories. 80254642e01fSmrg case "$xrpath " in 80264642e01fSmrg *" $dir "*) ;; 802735c4bbdfSmrg *) func_append xrpath " $dir" ;; 80284642e01fSmrg esac 80294642e01fSmrg fi 80304642e01fSmrg deplibs="$deplib $deplibs" 80314642e01fSmrg continue 80324642e01fSmrg ;; 803335c4bbdfSmrg *.la) 803435c4bbdfSmrg func_resolve_sysroot "$deplib" 803535c4bbdfSmrg lib=$func_resolve_sysroot_result 803635c4bbdfSmrg ;; 80374642e01fSmrg *.$libext) 803835c4bbdfSmrg if test conv = "$pass"; then 80394642e01fSmrg deplibs="$deplib $deplibs" 80404642e01fSmrg continue 80414642e01fSmrg fi 80424642e01fSmrg case $linkmode in 80434642e01fSmrg lib) 80444642e01fSmrg # Linking convenience modules into shared libraries is allowed, 80454642e01fSmrg # but linking other static libraries is non-portable. 80464642e01fSmrg case " $dlpreconveniencelibs " in 80474642e01fSmrg *" $deplib "*) ;; 80484642e01fSmrg *) 804935c4bbdfSmrg valid_a_lib=false 80504642e01fSmrg case $deplibs_check_method in 80514642e01fSmrg match_pattern*) 80524642e01fSmrg set dummy $deplibs_check_method; shift 80534642e01fSmrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 80546747b715Smrg if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ 80554642e01fSmrg | $EGREP "$match_pattern_regex" > /dev/null; then 805635c4bbdfSmrg valid_a_lib=: 80574642e01fSmrg fi 80584642e01fSmrg ;; 80594642e01fSmrg pass_all) 806035c4bbdfSmrg valid_a_lib=: 80614642e01fSmrg ;; 80624642e01fSmrg esac 806335c4bbdfSmrg if $valid_a_lib; then 806435c4bbdfSmrg echo 806535c4bbdfSmrg $ECHO "*** Warning: Linking the shared library $output against the" 806635c4bbdfSmrg $ECHO "*** static library $deplib is not portable!" 806735c4bbdfSmrg deplibs="$deplib $deplibs" 806835c4bbdfSmrg else 80696747b715Smrg echo 80704642e01fSmrg $ECHO "*** Warning: Trying to link with static lib archive $deplib." 80716747b715Smrg echo "*** I have the capability to make that library automatically link in when" 80726747b715Smrg echo "*** you link to this library. But I can only do this if you have a" 80736747b715Smrg echo "*** shared version of the library, which you do not appear to have" 80746747b715Smrg echo "*** because the file extensions .$libext of this argument makes me believe" 80756747b715Smrg echo "*** that it is just a static archive that I should not use here." 80764642e01fSmrg fi 80774642e01fSmrg ;; 80784642e01fSmrg esac 80794642e01fSmrg continue 80804642e01fSmrg ;; 80814642e01fSmrg prog) 808235c4bbdfSmrg if test link != "$pass"; then 80834642e01fSmrg deplibs="$deplib $deplibs" 80844642e01fSmrg else 80854642e01fSmrg compile_deplibs="$deplib $compile_deplibs" 80864642e01fSmrg finalize_deplibs="$deplib $finalize_deplibs" 80874642e01fSmrg fi 80884642e01fSmrg continue 80894642e01fSmrg ;; 80904642e01fSmrg esac # linkmode 80914642e01fSmrg ;; # *.$libext 80924642e01fSmrg *.lo | *.$objext) 809335c4bbdfSmrg if test conv = "$pass"; then 80944642e01fSmrg deplibs="$deplib $deplibs" 809535c4bbdfSmrg elif test prog = "$linkmode"; then 809635c4bbdfSmrg if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then 80974642e01fSmrg # If there is no dlopen support or we're linking statically, 80984642e01fSmrg # we need to preload. 809935c4bbdfSmrg func_append newdlprefiles " $deplib" 81004642e01fSmrg compile_deplibs="$deplib $compile_deplibs" 81014642e01fSmrg finalize_deplibs="$deplib $finalize_deplibs" 81024642e01fSmrg else 810335c4bbdfSmrg func_append newdlfiles " $deplib" 81044642e01fSmrg fi 81054642e01fSmrg fi 81064642e01fSmrg continue 81074642e01fSmrg ;; 81084642e01fSmrg %DEPLIBS%) 810935c4bbdfSmrg alldeplibs=: 81104642e01fSmrg continue 81114642e01fSmrg ;; 81124642e01fSmrg esac # case $deplib 81134642e01fSmrg 811435c4bbdfSmrg $found || test -f "$lib" \ 811535c4bbdfSmrg || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'" 81164642e01fSmrg 81174642e01fSmrg # Check to see that this really is a libtool archive. 81184642e01fSmrg func_lalib_unsafe_p "$lib" \ 811935c4bbdfSmrg || func_fatal_error "'$lib' is not a valid libtool archive" 81204642e01fSmrg 81214642e01fSmrg func_dirname "$lib" "" "." 812235c4bbdfSmrg ladir=$func_dirname_result 81234642e01fSmrg 81244642e01fSmrg dlname= 81254642e01fSmrg dlopen= 81264642e01fSmrg dlpreopen= 81274642e01fSmrg libdir= 81284642e01fSmrg library_names= 81294642e01fSmrg old_library= 81304642e01fSmrg inherited_linker_flags= 81314642e01fSmrg # If the library was installed with an old release of libtool, 81324642e01fSmrg # it will not redefine variables installed, or shouldnotlink 81334642e01fSmrg installed=yes 81344642e01fSmrg shouldnotlink=no 81354642e01fSmrg avoidtemprpath= 81364642e01fSmrg 81374642e01fSmrg 81384642e01fSmrg # Read the .la file 81394642e01fSmrg func_source "$lib" 81404642e01fSmrg 81414642e01fSmrg # Convert "-framework foo" to "foo.ltframework" 81424642e01fSmrg if test -n "$inherited_linker_flags"; then 81436747b715Smrg tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` 81444642e01fSmrg for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do 81454642e01fSmrg case " $new_inherited_linker_flags " in 81464642e01fSmrg *" $tmp_inherited_linker_flag "*) ;; 814735c4bbdfSmrg *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; 81484642e01fSmrg esac 81494642e01fSmrg done 81504642e01fSmrg fi 81516747b715Smrg dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 815235c4bbdfSmrg if test lib,link = "$linkmode,$pass" || 815335c4bbdfSmrg test prog,scan = "$linkmode,$pass" || 815435c4bbdfSmrg { test prog != "$linkmode" && test lib != "$linkmode"; }; then 815535c4bbdfSmrg test -n "$dlopen" && func_append dlfiles " $dlopen" 815635c4bbdfSmrg test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" 81574642e01fSmrg fi 81584642e01fSmrg 815935c4bbdfSmrg if test conv = "$pass"; then 81604642e01fSmrg # Only check for convenience libraries 81614642e01fSmrg deplibs="$lib $deplibs" 81624642e01fSmrg if test -z "$libdir"; then 81634642e01fSmrg if test -z "$old_library"; then 816435c4bbdfSmrg func_fatal_error "cannot find name of link library for '$lib'" 81654642e01fSmrg fi 81664642e01fSmrg # It is a libtool convenience library, so add in its objects. 816735c4bbdfSmrg func_append convenience " $ladir/$objdir/$old_library" 816835c4bbdfSmrg func_append old_convenience " $ladir/$objdir/$old_library" 816935c4bbdfSmrg elif test prog != "$linkmode" && test lib != "$linkmode"; then 817035c4bbdfSmrg func_fatal_error "'$lib' is not a convenience library" 81714642e01fSmrg fi 8172c82838c1Smrg tmp_libs= 8173c82838c1Smrg for deplib in $dependency_libs; do 8174c82838c1Smrg deplibs="$deplib $deplibs" 8175c82838c1Smrg if $opt_preserve_dup_deps; then 8176c82838c1Smrg case "$tmp_libs " in 8177c82838c1Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 8178c82838c1Smrg esac 8179c82838c1Smrg fi 8180c82838c1Smrg func_append tmp_libs " $deplib" 8181c82838c1Smrg done 81824642e01fSmrg continue 81834642e01fSmrg fi # $pass = conv 81844642e01fSmrg 81854642e01fSmrg 81864642e01fSmrg # Get the name of the library we link against. 81874642e01fSmrg linklib= 818835c4bbdfSmrg if test -n "$old_library" && 818935c4bbdfSmrg { test yes = "$prefer_static_libs" || 819035c4bbdfSmrg test built,no = "$prefer_static_libs,$installed"; }; then 819135c4bbdfSmrg linklib=$old_library 819235c4bbdfSmrg else 819335c4bbdfSmrg for l in $old_library $library_names; do 819435c4bbdfSmrg linklib=$l 819535c4bbdfSmrg done 819635c4bbdfSmrg fi 81974642e01fSmrg if test -z "$linklib"; then 819835c4bbdfSmrg func_fatal_error "cannot find name of link library for '$lib'" 81994642e01fSmrg fi 82004642e01fSmrg 82014642e01fSmrg # This library was specified with -dlopen. 820235c4bbdfSmrg if test dlopen = "$pass"; then 820335c4bbdfSmrg test -z "$libdir" \ 820435c4bbdfSmrg && func_fatal_error "cannot -dlopen a convenience library: '$lib'" 82054642e01fSmrg if test -z "$dlname" || 820635c4bbdfSmrg test yes != "$dlopen_support" || 820735c4bbdfSmrg test no = "$build_libtool_libs" 820835c4bbdfSmrg then 82094642e01fSmrg # If there is no dlname, no dlopen support or we're linking 82104642e01fSmrg # statically, we need to preload. We also need to preload any 82114642e01fSmrg # dependent libraries so libltdl's deplib preloader doesn't 82124642e01fSmrg # bomb out in the load deplibs phase. 821335c4bbdfSmrg func_append dlprefiles " $lib $dependency_libs" 82144642e01fSmrg else 821535c4bbdfSmrg func_append newdlfiles " $lib" 82164642e01fSmrg fi 82174642e01fSmrg continue 82184642e01fSmrg fi # $pass = dlopen 82194642e01fSmrg 82204642e01fSmrg # We need an absolute path. 82214642e01fSmrg case $ladir in 822235c4bbdfSmrg [\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;; 82234642e01fSmrg *) 82244642e01fSmrg abs_ladir=`cd "$ladir" && pwd` 82254642e01fSmrg if test -z "$abs_ladir"; then 822635c4bbdfSmrg func_warning "cannot determine absolute directory name of '$ladir'" 82274642e01fSmrg func_warning "passing it literally to the linker, although it might fail" 822835c4bbdfSmrg abs_ladir=$ladir 82294642e01fSmrg fi 82304642e01fSmrg ;; 82314642e01fSmrg esac 82324642e01fSmrg func_basename "$lib" 823335c4bbdfSmrg laname=$func_basename_result 82344642e01fSmrg 82354642e01fSmrg # Find the relevant object directory and library name. 823635c4bbdfSmrg if test yes = "$installed"; then 823735c4bbdfSmrg if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then 823835c4bbdfSmrg func_warning "library '$lib' was moved." 823935c4bbdfSmrg dir=$ladir 824035c4bbdfSmrg absdir=$abs_ladir 824135c4bbdfSmrg libdir=$abs_ladir 82424642e01fSmrg else 824335c4bbdfSmrg dir=$lt_sysroot$libdir 824435c4bbdfSmrg absdir=$lt_sysroot$libdir 82454642e01fSmrg fi 824635c4bbdfSmrg test yes = "$hardcode_automatic" && avoidtemprpath=yes 82474642e01fSmrg else 82484642e01fSmrg if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then 824935c4bbdfSmrg dir=$ladir 825035c4bbdfSmrg absdir=$abs_ladir 82514642e01fSmrg # Remove this search path later 825235c4bbdfSmrg func_append notinst_path " $abs_ladir" 82534642e01fSmrg else 825435c4bbdfSmrg dir=$ladir/$objdir 825535c4bbdfSmrg absdir=$abs_ladir/$objdir 82564642e01fSmrg # Remove this search path later 825735c4bbdfSmrg func_append notinst_path " $abs_ladir" 82584642e01fSmrg fi 82594642e01fSmrg fi # $installed = yes 82604642e01fSmrg func_stripname 'lib' '.la' "$laname" 82614642e01fSmrg name=$func_stripname_result 82624642e01fSmrg 82634642e01fSmrg # This library was specified with -dlpreopen. 826435c4bbdfSmrg if test dlpreopen = "$pass"; then 826535c4bbdfSmrg if test -z "$libdir" && test prog = "$linkmode"; then 826635c4bbdfSmrg func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'" 8267475c125cSmrg fi 826835c4bbdfSmrg case $host in 826935c4bbdfSmrg # special handling for platforms with PE-DLLs. 827035c4bbdfSmrg *cygwin* | *mingw* | *cegcc* ) 827135c4bbdfSmrg # Linker will automatically link against shared library if both 827235c4bbdfSmrg # static and shared are present. Therefore, ensure we extract 827335c4bbdfSmrg # symbols from the import library if a shared library is present 827435c4bbdfSmrg # (otherwise, the dlopen module name will be incorrect). We do 827535c4bbdfSmrg # this by putting the import library name into $newdlprefiles. 827635c4bbdfSmrg # We recover the dlopen module name by 'saving' the la file 827735c4bbdfSmrg # name in a special purpose variable, and (later) extracting the 827835c4bbdfSmrg # dlname from the la file. 827935c4bbdfSmrg if test -n "$dlname"; then 828035c4bbdfSmrg func_tr_sh "$dir/$linklib" 828135c4bbdfSmrg eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" 828235c4bbdfSmrg func_append newdlprefiles " $dir/$linklib" 828335c4bbdfSmrg else 828435c4bbdfSmrg func_append newdlprefiles " $dir/$old_library" 828535c4bbdfSmrg # Keep a list of preopened convenience libraries to check 828635c4bbdfSmrg # that they are being used correctly in the link pass. 828735c4bbdfSmrg test -z "$libdir" && \ 828835c4bbdfSmrg func_append dlpreconveniencelibs " $dir/$old_library" 828935c4bbdfSmrg fi 829035c4bbdfSmrg ;; 829135c4bbdfSmrg * ) 829235c4bbdfSmrg # Prefer using a static library (so that no silly _DYNAMIC symbols 829335c4bbdfSmrg # are required to link). 829435c4bbdfSmrg if test -n "$old_library"; then 829535c4bbdfSmrg func_append newdlprefiles " $dir/$old_library" 829635c4bbdfSmrg # Keep a list of preopened convenience libraries to check 829735c4bbdfSmrg # that they are being used correctly in the link pass. 829835c4bbdfSmrg test -z "$libdir" && \ 829935c4bbdfSmrg func_append dlpreconveniencelibs " $dir/$old_library" 830035c4bbdfSmrg # Otherwise, use the dlname, so that lt_dlopen finds it. 830135c4bbdfSmrg elif test -n "$dlname"; then 830235c4bbdfSmrg func_append newdlprefiles " $dir/$dlname" 830335c4bbdfSmrg else 830435c4bbdfSmrg func_append newdlprefiles " $dir/$linklib" 830535c4bbdfSmrg fi 830635c4bbdfSmrg ;; 830735c4bbdfSmrg esac 83084642e01fSmrg fi # $pass = dlpreopen 83094642e01fSmrg 83104642e01fSmrg if test -z "$libdir"; then 83114642e01fSmrg # Link the convenience library 831235c4bbdfSmrg if test lib = "$linkmode"; then 83134642e01fSmrg deplibs="$dir/$old_library $deplibs" 831435c4bbdfSmrg elif test prog,link = "$linkmode,$pass"; then 83154642e01fSmrg compile_deplibs="$dir/$old_library $compile_deplibs" 83164642e01fSmrg finalize_deplibs="$dir/$old_library $finalize_deplibs" 83174642e01fSmrg else 83184642e01fSmrg deplibs="$lib $deplibs" # used for prog,scan pass 83194642e01fSmrg fi 83204642e01fSmrg continue 83214642e01fSmrg fi 83224642e01fSmrg 83234642e01fSmrg 832435c4bbdfSmrg if test prog = "$linkmode" && test link != "$pass"; then 832535c4bbdfSmrg func_append newlib_search_path " $ladir" 83264642e01fSmrg deplibs="$lib $deplibs" 83274642e01fSmrg 832835c4bbdfSmrg linkalldeplibs=false 832935c4bbdfSmrg if test no != "$link_all_deplibs" || test -z "$library_names" || 833035c4bbdfSmrg test no = "$build_libtool_libs"; then 833135c4bbdfSmrg linkalldeplibs=: 83324642e01fSmrg fi 83334642e01fSmrg 83344642e01fSmrg tmp_libs= 83354642e01fSmrg for deplib in $dependency_libs; do 83364642e01fSmrg case $deplib in 83374642e01fSmrg -L*) func_stripname '-L' '' "$deplib" 833835c4bbdfSmrg func_resolve_sysroot "$func_stripname_result" 833935c4bbdfSmrg func_append newlib_search_path " $func_resolve_sysroot_result" 83404642e01fSmrg ;; 83414642e01fSmrg esac 83424642e01fSmrg # Need to link against all dependency_libs? 834335c4bbdfSmrg if $linkalldeplibs; then 83444642e01fSmrg deplibs="$deplib $deplibs" 83454642e01fSmrg else 83464642e01fSmrg # Need to hardcode shared library paths 83474642e01fSmrg # or/and link against static libraries 83484642e01fSmrg newdependency_libs="$deplib $newdependency_libs" 83494642e01fSmrg fi 835035c4bbdfSmrg if $opt_preserve_dup_deps; then 83514642e01fSmrg case "$tmp_libs " in 835235c4bbdfSmrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 83534642e01fSmrg esac 83544642e01fSmrg fi 835535c4bbdfSmrg func_append tmp_libs " $deplib" 83564642e01fSmrg done # for deplib 83574642e01fSmrg continue 83584642e01fSmrg fi # $linkmode = prog... 83594642e01fSmrg 836035c4bbdfSmrg if test prog,link = "$linkmode,$pass"; then 83614642e01fSmrg if test -n "$library_names" && 836235c4bbdfSmrg { { test no = "$prefer_static_libs" || 836335c4bbdfSmrg test built,yes = "$prefer_static_libs,$installed"; } || 83644642e01fSmrg test -z "$old_library"; }; then 83654642e01fSmrg # We need to hardcode the library path 836635c4bbdfSmrg if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then 83674642e01fSmrg # Make sure the rpath contains only unique directories. 836835c4bbdfSmrg case $temp_rpath: in 83694642e01fSmrg *"$absdir:"*) ;; 837035c4bbdfSmrg *) func_append temp_rpath "$absdir:" ;; 83714642e01fSmrg esac 83724642e01fSmrg fi 83734642e01fSmrg 83744642e01fSmrg # Hardcode the library path. 83754642e01fSmrg # Skip directories that are in the system default run-time 83764642e01fSmrg # search path. 83774642e01fSmrg case " $sys_lib_dlsearch_path " in 83784642e01fSmrg *" $absdir "*) ;; 83794642e01fSmrg *) 83804642e01fSmrg case "$compile_rpath " in 83814642e01fSmrg *" $absdir "*) ;; 838235c4bbdfSmrg *) func_append compile_rpath " $absdir" ;; 83834642e01fSmrg esac 83844642e01fSmrg ;; 83854642e01fSmrg esac 83864642e01fSmrg case " $sys_lib_dlsearch_path " in 83874642e01fSmrg *" $libdir "*) ;; 83884642e01fSmrg *) 83894642e01fSmrg case "$finalize_rpath " in 83904642e01fSmrg *" $libdir "*) ;; 839135c4bbdfSmrg *) func_append finalize_rpath " $libdir" ;; 83924642e01fSmrg esac 83934642e01fSmrg ;; 83944642e01fSmrg esac 83954642e01fSmrg fi # $linkmode,$pass = prog,link... 83964642e01fSmrg 839735c4bbdfSmrg if $alldeplibs && 839835c4bbdfSmrg { test pass_all = "$deplibs_check_method" || 839935c4bbdfSmrg { test yes = "$build_libtool_libs" && 84004642e01fSmrg test -n "$library_names"; }; }; then 84014642e01fSmrg # We only need to search for static libraries 84024642e01fSmrg continue 84034642e01fSmrg fi 84044642e01fSmrg fi 84054642e01fSmrg 84064642e01fSmrg link_static=no # Whether the deplib will be linked statically 84074642e01fSmrg use_static_libs=$prefer_static_libs 840835c4bbdfSmrg if test built = "$use_static_libs" && test yes = "$installed"; then 84094642e01fSmrg use_static_libs=no 84104642e01fSmrg fi 84114642e01fSmrg if test -n "$library_names" && 841235c4bbdfSmrg { test no = "$use_static_libs" || test -z "$old_library"; }; then 84134642e01fSmrg case $host in 841435c4bbdfSmrg *cygwin* | *mingw* | *cegcc* | *os2*) 84154642e01fSmrg # No point in relinking DLLs because paths are not encoded 841635c4bbdfSmrg func_append notinst_deplibs " $lib" 84174642e01fSmrg need_relink=no 84184642e01fSmrg ;; 84194642e01fSmrg *) 842035c4bbdfSmrg if test no = "$installed"; then 842135c4bbdfSmrg func_append notinst_deplibs " $lib" 84224642e01fSmrg need_relink=yes 84234642e01fSmrg fi 84244642e01fSmrg ;; 84254642e01fSmrg esac 84264642e01fSmrg # This is a shared library 84274642e01fSmrg 84284642e01fSmrg # Warn about portability, can't link against -module's on some 84294642e01fSmrg # systems (darwin). Don't bleat about dlopened modules though! 843035c4bbdfSmrg dlopenmodule= 84314642e01fSmrg for dlpremoduletest in $dlprefiles; do 84324642e01fSmrg if test "X$dlpremoduletest" = "X$lib"; then 843335c4bbdfSmrg dlopenmodule=$dlpremoduletest 84344642e01fSmrg break 84354642e01fSmrg fi 84364642e01fSmrg done 843735c4bbdfSmrg if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then 84386747b715Smrg echo 843935c4bbdfSmrg if test prog = "$linkmode"; then 84404642e01fSmrg $ECHO "*** Warning: Linking the executable $output against the loadable module" 84414642e01fSmrg else 84424642e01fSmrg $ECHO "*** Warning: Linking the shared library $output against the loadable module" 84434642e01fSmrg fi 84444642e01fSmrg $ECHO "*** $linklib is not portable!" 84454642e01fSmrg fi 844635c4bbdfSmrg if test lib = "$linkmode" && 844735c4bbdfSmrg test yes = "$hardcode_into_libs"; then 84484642e01fSmrg # Hardcode the library path. 84494642e01fSmrg # Skip directories that are in the system default run-time 84504642e01fSmrg # search path. 84514642e01fSmrg case " $sys_lib_dlsearch_path " in 84524642e01fSmrg *" $absdir "*) ;; 84534642e01fSmrg *) 84544642e01fSmrg case "$compile_rpath " in 84554642e01fSmrg *" $absdir "*) ;; 845635c4bbdfSmrg *) func_append compile_rpath " $absdir" ;; 84574642e01fSmrg esac 84584642e01fSmrg ;; 84594642e01fSmrg esac 84604642e01fSmrg case " $sys_lib_dlsearch_path " in 84614642e01fSmrg *" $libdir "*) ;; 84624642e01fSmrg *) 84634642e01fSmrg case "$finalize_rpath " in 84644642e01fSmrg *" $libdir "*) ;; 846535c4bbdfSmrg *) func_append finalize_rpath " $libdir" ;; 84664642e01fSmrg esac 84674642e01fSmrg ;; 84684642e01fSmrg esac 84694642e01fSmrg fi 84704642e01fSmrg 84714642e01fSmrg if test -n "$old_archive_from_expsyms_cmds"; then 84724642e01fSmrg # figure out the soname 84734642e01fSmrg set dummy $library_names 84744642e01fSmrg shift 847535c4bbdfSmrg realname=$1 84764642e01fSmrg shift 84774642e01fSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 84784642e01fSmrg # use dlname if we got it. it's perfectly good, no? 84794642e01fSmrg if test -n "$dlname"; then 848035c4bbdfSmrg soname=$dlname 84814642e01fSmrg elif test -n "$soname_spec"; then 84824642e01fSmrg # bleh windows 84834642e01fSmrg case $host in 848435c4bbdfSmrg *cygwin* | mingw* | *cegcc* | *os2*) 84854642e01fSmrg func_arith $current - $age 84864642e01fSmrg major=$func_arith_result 848735c4bbdfSmrg versuffix=-$major 84884642e01fSmrg ;; 84894642e01fSmrg esac 84904642e01fSmrg eval soname=\"$soname_spec\" 84914642e01fSmrg else 849235c4bbdfSmrg soname=$realname 84934642e01fSmrg fi 84944642e01fSmrg 84954642e01fSmrg # Make a new name for the extract_expsyms_cmds to use 849635c4bbdfSmrg soroot=$soname 84974642e01fSmrg func_basename "$soroot" 849835c4bbdfSmrg soname=$func_basename_result 84994642e01fSmrg func_stripname 'lib' '.dll' "$soname" 85004642e01fSmrg newlib=libimp-$func_stripname_result.a 85014642e01fSmrg 85024642e01fSmrg # If the library has no export list, then create one now 85034642e01fSmrg if test -f "$output_objdir/$soname-def"; then : 85044642e01fSmrg else 850535c4bbdfSmrg func_verbose "extracting exported symbol list from '$soname'" 85064642e01fSmrg func_execute_cmds "$extract_expsyms_cmds" 'exit $?' 85074642e01fSmrg fi 85084642e01fSmrg 85094642e01fSmrg # Create $newlib 85104642e01fSmrg if test -f "$output_objdir/$newlib"; then :; else 851135c4bbdfSmrg func_verbose "generating import library for '$soname'" 85124642e01fSmrg func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' 85134642e01fSmrg fi 85144642e01fSmrg # make sure the library variables are pointing to the new library 85154642e01fSmrg dir=$output_objdir 85164642e01fSmrg linklib=$newlib 85174642e01fSmrg fi # test -n "$old_archive_from_expsyms_cmds" 85184642e01fSmrg 851935c4bbdfSmrg if test prog = "$linkmode" || test relink != "$opt_mode"; then 85204642e01fSmrg add_shlibpath= 85214642e01fSmrg add_dir= 85224642e01fSmrg add= 85234642e01fSmrg lib_linked=yes 85244642e01fSmrg case $hardcode_action in 85254642e01fSmrg immediate | unsupported) 852635c4bbdfSmrg if test no = "$hardcode_direct"; then 852735c4bbdfSmrg add=$dir/$linklib 85284642e01fSmrg case $host in 852935c4bbdfSmrg *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;; 853035c4bbdfSmrg *-*-sysv4*uw2*) add_dir=-L$dir ;; 85314642e01fSmrg *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ 853235c4bbdfSmrg *-*-unixware7*) add_dir=-L$dir ;; 85334642e01fSmrg *-*-darwin* ) 853435c4bbdfSmrg # if the lib is a (non-dlopened) module then we cannot 85354642e01fSmrg # link against it, someone is ignoring the earlier warnings 85364642e01fSmrg if /usr/bin/file -L $add 2> /dev/null | 853735c4bbdfSmrg $GREP ": [^:]* bundle" >/dev/null; then 85384642e01fSmrg if test "X$dlopenmodule" != "X$lib"; then 85394642e01fSmrg $ECHO "*** Warning: lib $linklib is a module, not a shared library" 854035c4bbdfSmrg if test -z "$old_library"; then 85416747b715Smrg echo 85426747b715Smrg echo "*** And there doesn't seem to be a static archive available" 85436747b715Smrg echo "*** The link will probably fail, sorry" 85444642e01fSmrg else 854535c4bbdfSmrg add=$dir/$old_library 85464642e01fSmrg fi 85474642e01fSmrg elif test -n "$old_library"; then 854835c4bbdfSmrg add=$dir/$old_library 85494642e01fSmrg fi 85504642e01fSmrg fi 85514642e01fSmrg esac 855235c4bbdfSmrg elif test no = "$hardcode_minus_L"; then 85534642e01fSmrg case $host in 855435c4bbdfSmrg *-*-sunos*) add_shlibpath=$dir ;; 85554642e01fSmrg esac 855635c4bbdfSmrg add_dir=-L$dir 855735c4bbdfSmrg add=-l$name 855835c4bbdfSmrg elif test no = "$hardcode_shlibpath_var"; then 855935c4bbdfSmrg add_shlibpath=$dir 856035c4bbdfSmrg add=-l$name 85614642e01fSmrg else 85624642e01fSmrg lib_linked=no 85634642e01fSmrg fi 85644642e01fSmrg ;; 85654642e01fSmrg relink) 856635c4bbdfSmrg if test yes = "$hardcode_direct" && 856735c4bbdfSmrg test no = "$hardcode_direct_absolute"; then 856835c4bbdfSmrg add=$dir/$linklib 856935c4bbdfSmrg elif test yes = "$hardcode_minus_L"; then 857035c4bbdfSmrg add_dir=-L$absdir 85714642e01fSmrg # Try looking first in the location we're being installed to. 85724642e01fSmrg if test -n "$inst_prefix_dir"; then 85734642e01fSmrg case $libdir in 85744642e01fSmrg [\\/]*) 857535c4bbdfSmrg func_append add_dir " -L$inst_prefix_dir$libdir" 85764642e01fSmrg ;; 85774642e01fSmrg esac 85784642e01fSmrg fi 857935c4bbdfSmrg add=-l$name 858035c4bbdfSmrg elif test yes = "$hardcode_shlibpath_var"; then 858135c4bbdfSmrg add_shlibpath=$dir 858235c4bbdfSmrg add=-l$name 85834642e01fSmrg else 85844642e01fSmrg lib_linked=no 85854642e01fSmrg fi 85864642e01fSmrg ;; 85874642e01fSmrg *) lib_linked=no ;; 85884642e01fSmrg esac 85894642e01fSmrg 859035c4bbdfSmrg if test yes != "$lib_linked"; then 85914642e01fSmrg func_fatal_configuration "unsupported hardcode properties" 85924642e01fSmrg fi 85934642e01fSmrg 85944642e01fSmrg if test -n "$add_shlibpath"; then 85954642e01fSmrg case :$compile_shlibpath: in 85964642e01fSmrg *":$add_shlibpath:"*) ;; 859735c4bbdfSmrg *) func_append compile_shlibpath "$add_shlibpath:" ;; 85984642e01fSmrg esac 85994642e01fSmrg fi 860035c4bbdfSmrg if test prog = "$linkmode"; then 86014642e01fSmrg test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" 86024642e01fSmrg test -n "$add" && compile_deplibs="$add $compile_deplibs" 86034642e01fSmrg else 86044642e01fSmrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 86054642e01fSmrg test -n "$add" && deplibs="$add $deplibs" 860635c4bbdfSmrg if test yes != "$hardcode_direct" && 860735c4bbdfSmrg test yes != "$hardcode_minus_L" && 860835c4bbdfSmrg test yes = "$hardcode_shlibpath_var"; then 86094642e01fSmrg case :$finalize_shlibpath: in 86104642e01fSmrg *":$libdir:"*) ;; 861135c4bbdfSmrg *) func_append finalize_shlibpath "$libdir:" ;; 86124642e01fSmrg esac 86134642e01fSmrg fi 86144642e01fSmrg fi 86154642e01fSmrg fi 86164642e01fSmrg 861735c4bbdfSmrg if test prog = "$linkmode" || test relink = "$opt_mode"; then 86184642e01fSmrg add_shlibpath= 86194642e01fSmrg add_dir= 86204642e01fSmrg add= 86214642e01fSmrg # Finalize command for both is simple: just hardcode it. 862235c4bbdfSmrg if test yes = "$hardcode_direct" && 862335c4bbdfSmrg test no = "$hardcode_direct_absolute"; then 862435c4bbdfSmrg add=$libdir/$linklib 862535c4bbdfSmrg elif test yes = "$hardcode_minus_L"; then 862635c4bbdfSmrg add_dir=-L$libdir 862735c4bbdfSmrg add=-l$name 862835c4bbdfSmrg elif test yes = "$hardcode_shlibpath_var"; then 86294642e01fSmrg case :$finalize_shlibpath: in 86304642e01fSmrg *":$libdir:"*) ;; 863135c4bbdfSmrg *) func_append finalize_shlibpath "$libdir:" ;; 86324642e01fSmrg esac 863335c4bbdfSmrg add=-l$name 863435c4bbdfSmrg elif test yes = "$hardcode_automatic"; then 86354642e01fSmrg if test -n "$inst_prefix_dir" && 863635c4bbdfSmrg test -f "$inst_prefix_dir$libdir/$linklib"; then 863735c4bbdfSmrg add=$inst_prefix_dir$libdir/$linklib 86384642e01fSmrg else 863935c4bbdfSmrg add=$libdir/$linklib 86404642e01fSmrg fi 86414642e01fSmrg else 86424642e01fSmrg # We cannot seem to hardcode it, guess we'll fake it. 864335c4bbdfSmrg add_dir=-L$libdir 86444642e01fSmrg # Try looking first in the location we're being installed to. 86454642e01fSmrg if test -n "$inst_prefix_dir"; then 86464642e01fSmrg case $libdir in 86474642e01fSmrg [\\/]*) 864835c4bbdfSmrg func_append add_dir " -L$inst_prefix_dir$libdir" 86494642e01fSmrg ;; 86504642e01fSmrg esac 86514642e01fSmrg fi 865235c4bbdfSmrg add=-l$name 86534642e01fSmrg fi 86544642e01fSmrg 865535c4bbdfSmrg if test prog = "$linkmode"; then 86564642e01fSmrg test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" 86574642e01fSmrg test -n "$add" && finalize_deplibs="$add $finalize_deplibs" 86584642e01fSmrg else 86594642e01fSmrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 86604642e01fSmrg test -n "$add" && deplibs="$add $deplibs" 86614642e01fSmrg fi 86624642e01fSmrg fi 866335c4bbdfSmrg elif test prog = "$linkmode"; then 86644642e01fSmrg # Here we assume that one of hardcode_direct or hardcode_minus_L 86654642e01fSmrg # is not unsupported. This is valid on all known static and 86664642e01fSmrg # shared platforms. 866735c4bbdfSmrg if test unsupported != "$hardcode_direct"; then 866835c4bbdfSmrg test -n "$old_library" && linklib=$old_library 86694642e01fSmrg compile_deplibs="$dir/$linklib $compile_deplibs" 86704642e01fSmrg finalize_deplibs="$dir/$linklib $finalize_deplibs" 86714642e01fSmrg else 86724642e01fSmrg compile_deplibs="-l$name -L$dir $compile_deplibs" 86734642e01fSmrg finalize_deplibs="-l$name -L$dir $finalize_deplibs" 86744642e01fSmrg fi 867535c4bbdfSmrg elif test yes = "$build_libtool_libs"; then 86764642e01fSmrg # Not a shared library 867735c4bbdfSmrg if test pass_all != "$deplibs_check_method"; then 86784642e01fSmrg # We're trying link a shared library against a static one 86794642e01fSmrg # but the system doesn't support it. 86804642e01fSmrg 86814642e01fSmrg # Just print a warning and add the library to dependency_libs so 86824642e01fSmrg # that the program can be linked against the static library. 86836747b715Smrg echo 868435c4bbdfSmrg $ECHO "*** Warning: This system cannot link to static lib archive $lib." 86856747b715Smrg echo "*** I have the capability to make that library automatically link in when" 86866747b715Smrg echo "*** you link to this library. But I can only do this if you have a" 86876747b715Smrg echo "*** shared version of the library, which you do not appear to have." 868835c4bbdfSmrg if test yes = "$module"; then 86896747b715Smrg echo "*** But as you try to build a module library, libtool will still create " 86906747b715Smrg echo "*** a static module, that should work as long as the dlopening application" 86916747b715Smrg echo "*** is linked with the -dlopen flag to resolve symbols at runtime." 86924642e01fSmrg if test -z "$global_symbol_pipe"; then 86936747b715Smrg echo 86946747b715Smrg echo "*** However, this would only work if libtool was able to extract symbol" 869535c4bbdfSmrg echo "*** lists from a program, using 'nm' or equivalent, but libtool could" 86966747b715Smrg echo "*** not find such a program. So, this module is probably useless." 869735c4bbdfSmrg echo "*** 'nm' from GNU binutils and a full rebuild may help." 86984642e01fSmrg fi 869935c4bbdfSmrg if test no = "$build_old_libs"; then 87004642e01fSmrg build_libtool_libs=module 87014642e01fSmrg build_old_libs=yes 87024642e01fSmrg else 87034642e01fSmrg build_libtool_libs=no 87044642e01fSmrg fi 87054642e01fSmrg fi 87064642e01fSmrg else 87074642e01fSmrg deplibs="$dir/$old_library $deplibs" 87084642e01fSmrg link_static=yes 87094642e01fSmrg fi 87104642e01fSmrg fi # link shared/static library? 87114642e01fSmrg 871235c4bbdfSmrg if test lib = "$linkmode"; then 87134642e01fSmrg if test -n "$dependency_libs" && 871435c4bbdfSmrg { test yes != "$hardcode_into_libs" || 871535c4bbdfSmrg test yes = "$build_old_libs" || 871635c4bbdfSmrg test yes = "$link_static"; }; then 87174642e01fSmrg # Extract -R from dependency_libs 87184642e01fSmrg temp_deplibs= 87194642e01fSmrg for libdir in $dependency_libs; do 87204642e01fSmrg case $libdir in 87214642e01fSmrg -R*) func_stripname '-R' '' "$libdir" 87224642e01fSmrg temp_xrpath=$func_stripname_result 87234642e01fSmrg case " $xrpath " in 87244642e01fSmrg *" $temp_xrpath "*) ;; 872535c4bbdfSmrg *) func_append xrpath " $temp_xrpath";; 87264642e01fSmrg esac;; 872735c4bbdfSmrg *) func_append temp_deplibs " $libdir";; 87284642e01fSmrg esac 87294642e01fSmrg done 873035c4bbdfSmrg dependency_libs=$temp_deplibs 87314642e01fSmrg fi 87324642e01fSmrg 873335c4bbdfSmrg func_append newlib_search_path " $absdir" 87344642e01fSmrg # Link against this library 873535c4bbdfSmrg test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs" 87364642e01fSmrg # ... and its dependency_libs 87374642e01fSmrg tmp_libs= 87384642e01fSmrg for deplib in $dependency_libs; do 87394642e01fSmrg newdependency_libs="$deplib $newdependency_libs" 874035c4bbdfSmrg case $deplib in 874135c4bbdfSmrg -L*) func_stripname '-L' '' "$deplib" 874235c4bbdfSmrg func_resolve_sysroot "$func_stripname_result";; 874335c4bbdfSmrg *) func_resolve_sysroot "$deplib" ;; 874435c4bbdfSmrg esac 874535c4bbdfSmrg if $opt_preserve_dup_deps; then 87464642e01fSmrg case "$tmp_libs " in 874735c4bbdfSmrg *" $func_resolve_sysroot_result "*) 874835c4bbdfSmrg func_append specialdeplibs " $func_resolve_sysroot_result" ;; 87494642e01fSmrg esac 87504642e01fSmrg fi 875135c4bbdfSmrg func_append tmp_libs " $func_resolve_sysroot_result" 87524642e01fSmrg done 87534642e01fSmrg 875435c4bbdfSmrg if test no != "$link_all_deplibs"; then 87554642e01fSmrg # Add the search paths of all dependency libraries 87564642e01fSmrg for deplib in $dependency_libs; do 87574642e01fSmrg path= 87584642e01fSmrg case $deplib in 875935c4bbdfSmrg -L*) path=$deplib ;; 87604642e01fSmrg *.la) 876135c4bbdfSmrg func_resolve_sysroot "$deplib" 876235c4bbdfSmrg deplib=$func_resolve_sysroot_result 87634642e01fSmrg func_dirname "$deplib" "" "." 876435c4bbdfSmrg dir=$func_dirname_result 87654642e01fSmrg # We need an absolute path. 87664642e01fSmrg case $dir in 876735c4bbdfSmrg [\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;; 87684642e01fSmrg *) 87694642e01fSmrg absdir=`cd "$dir" && pwd` 87704642e01fSmrg if test -z "$absdir"; then 877135c4bbdfSmrg func_warning "cannot determine absolute directory name of '$dir'" 877235c4bbdfSmrg absdir=$dir 87734642e01fSmrg fi 87744642e01fSmrg ;; 87754642e01fSmrg esac 87764642e01fSmrg if $GREP "^installed=no" $deplib > /dev/null; then 87774642e01fSmrg case $host in 87784642e01fSmrg *-*-darwin*) 87794642e01fSmrg depdepl= 878035c4bbdfSmrg eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` 878135c4bbdfSmrg if test -n "$deplibrary_names"; then 878235c4bbdfSmrg for tmp in $deplibrary_names; do 87834642e01fSmrg depdepl=$tmp 87844642e01fSmrg done 878535c4bbdfSmrg if test -f "$absdir/$objdir/$depdepl"; then 878635c4bbdfSmrg depdepl=$absdir/$objdir/$depdepl 878735c4bbdfSmrg darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 87884642e01fSmrg if test -z "$darwin_install_name"; then 878935c4bbdfSmrg darwin_install_name=`$OTOOL64 -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 87904642e01fSmrg fi 879135c4bbdfSmrg func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl" 879235c4bbdfSmrg func_append linker_flags " -dylib_file $darwin_install_name:$depdepl" 87934642e01fSmrg path= 87944642e01fSmrg fi 87954642e01fSmrg fi 87964642e01fSmrg ;; 87974642e01fSmrg *) 879835c4bbdfSmrg path=-L$absdir/$objdir 87994642e01fSmrg ;; 88004642e01fSmrg esac 88014642e01fSmrg else 880235c4bbdfSmrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` 88034642e01fSmrg test -z "$libdir" && \ 880435c4bbdfSmrg func_fatal_error "'$deplib' is not a valid libtool archive" 88054642e01fSmrg test "$absdir" != "$libdir" && \ 880635c4bbdfSmrg func_warning "'$deplib' seems to be moved" 88074642e01fSmrg 880835c4bbdfSmrg path=-L$absdir 88094642e01fSmrg fi 88104642e01fSmrg ;; 88114642e01fSmrg esac 88124642e01fSmrg case " $deplibs " in 88134642e01fSmrg *" $path "*) ;; 88144642e01fSmrg *) deplibs="$path $deplibs" ;; 88154642e01fSmrg esac 88164642e01fSmrg done 88174642e01fSmrg fi # link_all_deplibs != no 88184642e01fSmrg fi # linkmode = lib 88194642e01fSmrg done # for deplib in $libs 882035c4bbdfSmrg if test link = "$pass"; then 882135c4bbdfSmrg if test prog = "$linkmode"; then 88224642e01fSmrg compile_deplibs="$new_inherited_linker_flags $compile_deplibs" 88234642e01fSmrg finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" 88244642e01fSmrg else 88256747b715Smrg compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 88264642e01fSmrg fi 88274642e01fSmrg fi 882835c4bbdfSmrg dependency_libs=$newdependency_libs 882935c4bbdfSmrg if test dlpreopen = "$pass"; then 88304642e01fSmrg # Link the dlpreopened libraries before other libraries 88314642e01fSmrg for deplib in $save_deplibs; do 88324642e01fSmrg deplibs="$deplib $deplibs" 88334642e01fSmrg done 88344642e01fSmrg fi 883535c4bbdfSmrg if test dlopen != "$pass"; then 883635c4bbdfSmrg test conv = "$pass" || { 88374642e01fSmrg # Make sure lib_search_path contains only unique directories. 88384642e01fSmrg lib_search_path= 88394642e01fSmrg for dir in $newlib_search_path; do 88404642e01fSmrg case "$lib_search_path " in 88414642e01fSmrg *" $dir "*) ;; 884235c4bbdfSmrg *) func_append lib_search_path " $dir" ;; 88434642e01fSmrg esac 88444642e01fSmrg done 88454642e01fSmrg newlib_search_path= 884635c4bbdfSmrg } 88474642e01fSmrg 884835c4bbdfSmrg if test prog,link = "$linkmode,$pass"; then 88494642e01fSmrg vars="compile_deplibs finalize_deplibs" 885035c4bbdfSmrg else 885135c4bbdfSmrg vars=deplibs 88524642e01fSmrg fi 88534642e01fSmrg for var in $vars dependency_libs; do 88544642e01fSmrg # Add libraries to $var in reverse order 88554642e01fSmrg eval tmp_libs=\"\$$var\" 88564642e01fSmrg new_libs= 88574642e01fSmrg for deplib in $tmp_libs; do 88584642e01fSmrg # FIXME: Pedantically, this is the right thing to do, so 88594642e01fSmrg # that some nasty dependency loop isn't accidentally 88604642e01fSmrg # broken: 88614642e01fSmrg #new_libs="$deplib $new_libs" 88624642e01fSmrg # Pragmatically, this seems to cause very few problems in 88634642e01fSmrg # practice: 88644642e01fSmrg case $deplib in 88654642e01fSmrg -L*) new_libs="$deplib $new_libs" ;; 88664642e01fSmrg -R*) ;; 88674642e01fSmrg *) 88684642e01fSmrg # And here is the reason: when a library appears more 88694642e01fSmrg # than once as an explicit dependence of a library, or 88704642e01fSmrg # is implicitly linked in more than once by the 88714642e01fSmrg # compiler, it is considered special, and multiple 88724642e01fSmrg # occurrences thereof are not removed. Compare this 88734642e01fSmrg # with having the same library being listed as a 88744642e01fSmrg # dependency of multiple other libraries: in this case, 88754642e01fSmrg # we know (pedantically, we assume) the library does not 88764642e01fSmrg # need to be listed more than once, so we keep only the 88774642e01fSmrg # last copy. This is not always right, but it is rare 88784642e01fSmrg # enough that we require users that really mean to play 88794642e01fSmrg # such unportable linking tricks to link the library 88804642e01fSmrg # using -Wl,-lname, so that libtool does not consider it 88814642e01fSmrg # for duplicate removal. 88824642e01fSmrg case " $specialdeplibs " in 88834642e01fSmrg *" $deplib "*) new_libs="$deplib $new_libs" ;; 88844642e01fSmrg *) 88854642e01fSmrg case " $new_libs " in 88864642e01fSmrg *" $deplib "*) ;; 88874642e01fSmrg *) new_libs="$deplib $new_libs" ;; 88884642e01fSmrg esac 88894642e01fSmrg ;; 88904642e01fSmrg esac 88914642e01fSmrg ;; 88924642e01fSmrg esac 88934642e01fSmrg done 88944642e01fSmrg tmp_libs= 88954642e01fSmrg for deplib in $new_libs; do 88964642e01fSmrg case $deplib in 88974642e01fSmrg -L*) 88984642e01fSmrg case " $tmp_libs " in 88994642e01fSmrg *" $deplib "*) ;; 890035c4bbdfSmrg *) func_append tmp_libs " $deplib" ;; 89014642e01fSmrg esac 89024642e01fSmrg ;; 890335c4bbdfSmrg *) func_append tmp_libs " $deplib" ;; 89044642e01fSmrg esac 89054642e01fSmrg done 89064642e01fSmrg eval $var=\"$tmp_libs\" 89074642e01fSmrg done # for var 89084642e01fSmrg fi 890935c4bbdfSmrg 891035c4bbdfSmrg # Add Sun CC postdeps if required: 891135c4bbdfSmrg test CXX = "$tagname" && { 891235c4bbdfSmrg case $host_os in 891335c4bbdfSmrg linux*) 8914c82838c1Smrg case `$CC -V 2>&1 | $SED 5q` in 891535c4bbdfSmrg *Sun\ C*) # Sun C++ 5.9 891635c4bbdfSmrg func_suncc_cstd_abi 891735c4bbdfSmrg 891835c4bbdfSmrg if test no != "$suncc_use_cstd_abi"; then 891935c4bbdfSmrg func_append postdeps ' -library=Cstd -library=Crun' 892035c4bbdfSmrg fi 892135c4bbdfSmrg ;; 892235c4bbdfSmrg esac 892335c4bbdfSmrg ;; 892435c4bbdfSmrg 892535c4bbdfSmrg solaris*) 892635c4bbdfSmrg func_cc_basename "$CC" 892735c4bbdfSmrg case $func_cc_basename_result in 892835c4bbdfSmrg CC* | sunCC*) 892935c4bbdfSmrg func_suncc_cstd_abi 893035c4bbdfSmrg 893135c4bbdfSmrg if test no != "$suncc_use_cstd_abi"; then 893235c4bbdfSmrg func_append postdeps ' -library=Cstd -library=Crun' 893335c4bbdfSmrg fi 893435c4bbdfSmrg ;; 893535c4bbdfSmrg esac 893635c4bbdfSmrg ;; 893735c4bbdfSmrg esac 893835c4bbdfSmrg } 893935c4bbdfSmrg 89404642e01fSmrg # Last step: remove runtime libs from dependency_libs 89414642e01fSmrg # (they stay in deplibs) 89424642e01fSmrg tmp_libs= 894335c4bbdfSmrg for i in $dependency_libs; do 89444642e01fSmrg case " $predeps $postdeps $compiler_lib_search_path " in 89454642e01fSmrg *" $i "*) 894635c4bbdfSmrg i= 89474642e01fSmrg ;; 89484642e01fSmrg esac 894935c4bbdfSmrg if test -n "$i"; then 895035c4bbdfSmrg func_append tmp_libs " $i" 89514642e01fSmrg fi 89524642e01fSmrg done 89534642e01fSmrg dependency_libs=$tmp_libs 89544642e01fSmrg done # for pass 895535c4bbdfSmrg if test prog = "$linkmode"; then 895635c4bbdfSmrg dlfiles=$newdlfiles 89574642e01fSmrg fi 895835c4bbdfSmrg if test prog = "$linkmode" || test lib = "$linkmode"; then 895935c4bbdfSmrg dlprefiles=$newdlprefiles 89604642e01fSmrg fi 89614642e01fSmrg 89624642e01fSmrg case $linkmode in 89634642e01fSmrg oldlib) 896435c4bbdfSmrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 896535c4bbdfSmrg func_warning "'-dlopen' is ignored for archives" 89664642e01fSmrg fi 89674642e01fSmrg 89684642e01fSmrg case " $deplibs" in 89694642e01fSmrg *\ -l* | *\ -L*) 897035c4bbdfSmrg func_warning "'-l' and '-L' are ignored for archives" ;; 89714642e01fSmrg esac 89724642e01fSmrg 89734642e01fSmrg test -n "$rpath" && \ 897435c4bbdfSmrg func_warning "'-rpath' is ignored for archives" 89754642e01fSmrg 89764642e01fSmrg test -n "$xrpath" && \ 897735c4bbdfSmrg func_warning "'-R' is ignored for archives" 89784642e01fSmrg 89794642e01fSmrg test -n "$vinfo" && \ 898035c4bbdfSmrg func_warning "'-version-info/-version-number' is ignored for archives" 89814642e01fSmrg 89824642e01fSmrg test -n "$release" && \ 898335c4bbdfSmrg func_warning "'-release' is ignored for archives" 89844642e01fSmrg 89854642e01fSmrg test -n "$export_symbols$export_symbols_regex" && \ 898635c4bbdfSmrg func_warning "'-export-symbols' is ignored for archives" 89874642e01fSmrg 89884642e01fSmrg # Now set the variables for building old libraries. 89894642e01fSmrg build_libtool_libs=no 899035c4bbdfSmrg oldlibs=$output 899135c4bbdfSmrg func_append objs "$old_deplibs" 89924642e01fSmrg ;; 89934642e01fSmrg 89944642e01fSmrg lib) 899535c4bbdfSmrg # Make sure we only generate libraries of the form 'libNAME.la'. 89964642e01fSmrg case $outputname in 89974642e01fSmrg lib*) 89984642e01fSmrg func_stripname 'lib' '.la' "$outputname" 89994642e01fSmrg name=$func_stripname_result 90004642e01fSmrg eval shared_ext=\"$shrext_cmds\" 90014642e01fSmrg eval libname=\"$libname_spec\" 90024642e01fSmrg ;; 90034642e01fSmrg *) 900435c4bbdfSmrg test no = "$module" \ 900535c4bbdfSmrg && func_fatal_help "libtool library '$output' must begin with 'lib'" 90064642e01fSmrg 900735c4bbdfSmrg if test no != "$need_lib_prefix"; then 90084642e01fSmrg # Add the "lib" prefix for modules if required 90094642e01fSmrg func_stripname '' '.la' "$outputname" 90104642e01fSmrg name=$func_stripname_result 90114642e01fSmrg eval shared_ext=\"$shrext_cmds\" 90124642e01fSmrg eval libname=\"$libname_spec\" 90134642e01fSmrg else 90144642e01fSmrg func_stripname '' '.la' "$outputname" 90154642e01fSmrg libname=$func_stripname_result 90164642e01fSmrg fi 90174642e01fSmrg ;; 90184642e01fSmrg esac 90194642e01fSmrg 90204642e01fSmrg if test -n "$objs"; then 902135c4bbdfSmrg if test pass_all != "$deplibs_check_method"; then 902235c4bbdfSmrg func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs" 90234642e01fSmrg else 90246747b715Smrg echo 90254642e01fSmrg $ECHO "*** Warning: Linking the shared library $output against the non-libtool" 90264642e01fSmrg $ECHO "*** objects $objs is not portable!" 902735c4bbdfSmrg func_append libobjs " $objs" 90284642e01fSmrg fi 90294642e01fSmrg fi 90304642e01fSmrg 903135c4bbdfSmrg test no = "$dlself" \ 903235c4bbdfSmrg || func_warning "'-dlopen self' is ignored for libtool libraries" 90334642e01fSmrg 90344642e01fSmrg set dummy $rpath 90354642e01fSmrg shift 903635c4bbdfSmrg test 1 -lt "$#" \ 903735c4bbdfSmrg && func_warning "ignoring multiple '-rpath's for a libtool library" 90384642e01fSmrg 903935c4bbdfSmrg install_libdir=$1 90404642e01fSmrg 90414642e01fSmrg oldlibs= 90424642e01fSmrg if test -z "$rpath"; then 904335c4bbdfSmrg if test yes = "$build_libtool_libs"; then 90444642e01fSmrg # Building a libtool convenience library. 904535c4bbdfSmrg # Some compilers have problems with a '.al' extension so 90464642e01fSmrg # convenience libraries should have the same extension an 90474642e01fSmrg # archive normally would. 90484642e01fSmrg oldlibs="$output_objdir/$libname.$libext $oldlibs" 90494642e01fSmrg build_libtool_libs=convenience 90504642e01fSmrg build_old_libs=yes 90514642e01fSmrg fi 90524642e01fSmrg 90534642e01fSmrg test -n "$vinfo" && \ 905435c4bbdfSmrg func_warning "'-version-info/-version-number' is ignored for convenience libraries" 90554642e01fSmrg 90564642e01fSmrg test -n "$release" && \ 905735c4bbdfSmrg func_warning "'-release' is ignored for convenience libraries" 90584642e01fSmrg else 90594642e01fSmrg 90604642e01fSmrg # Parse the version information argument. 906135c4bbdfSmrg save_ifs=$IFS; IFS=: 90624642e01fSmrg set dummy $vinfo 0 0 0 90634642e01fSmrg shift 906435c4bbdfSmrg IFS=$save_ifs 90654642e01fSmrg 90664642e01fSmrg test -n "$7" && \ 906735c4bbdfSmrg func_fatal_help "too many parameters to '-version-info'" 90684642e01fSmrg 90694642e01fSmrg # convert absolute version numbers to libtool ages 90704642e01fSmrg # this retains compatibility with .la files and attempts 90714642e01fSmrg # to make the code below a bit more comprehensible 90724642e01fSmrg 90734642e01fSmrg case $vinfo_number in 90744642e01fSmrg yes) 907535c4bbdfSmrg number_major=$1 907635c4bbdfSmrg number_minor=$2 907735c4bbdfSmrg number_revision=$3 90784642e01fSmrg # 90794642e01fSmrg # There are really only two kinds -- those that 90804642e01fSmrg # use the current revision as the major version 90814642e01fSmrg # and those that subtract age and use age as 90824642e01fSmrg # a minor version. But, then there is irix 908335c4bbdfSmrg # that has an extra 1 added just for fun 90844642e01fSmrg # 90854642e01fSmrg case $version_type in 908635c4bbdfSmrg # correct linux to gnu/linux during the next big refactor 9087c82838c1Smrg darwin|freebsd-elf|linux|midnightbsd-elf|osf|windows|none) 90884642e01fSmrg func_arith $number_major + $number_minor 90894642e01fSmrg current=$func_arith_result 909035c4bbdfSmrg age=$number_minor 909135c4bbdfSmrg revision=$number_revision 90924642e01fSmrg ;; 909335c4bbdfSmrg freebsd-aout|qnx|sunos) 909435c4bbdfSmrg current=$number_major 909535c4bbdfSmrg revision=$number_minor 909635c4bbdfSmrg age=0 90974642e01fSmrg ;; 90984642e01fSmrg irix|nonstopux) 90994642e01fSmrg func_arith $number_major + $number_minor 91004642e01fSmrg current=$func_arith_result 910135c4bbdfSmrg age=$number_minor 910235c4bbdfSmrg revision=$number_minor 91034642e01fSmrg lt_irix_increment=no 91044642e01fSmrg ;; 91054642e01fSmrg esac 91064642e01fSmrg ;; 91074642e01fSmrg no) 910835c4bbdfSmrg current=$1 910935c4bbdfSmrg revision=$2 911035c4bbdfSmrg age=$3 91114642e01fSmrg ;; 91124642e01fSmrg esac 91134642e01fSmrg 91144642e01fSmrg # Check that each of the things are valid numbers. 91154642e01fSmrg case $current in 91164642e01fSmrg 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]) ;; 91174642e01fSmrg *) 911835c4bbdfSmrg func_error "CURRENT '$current' must be a nonnegative integer" 911935c4bbdfSmrg func_fatal_error "'$vinfo' is not valid version information" 91204642e01fSmrg ;; 91214642e01fSmrg esac 91224642e01fSmrg 91234642e01fSmrg case $revision in 91244642e01fSmrg 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]) ;; 91254642e01fSmrg *) 912635c4bbdfSmrg func_error "REVISION '$revision' must be a nonnegative integer" 912735c4bbdfSmrg func_fatal_error "'$vinfo' is not valid version information" 91284642e01fSmrg ;; 91294642e01fSmrg esac 91304642e01fSmrg 91314642e01fSmrg case $age in 91324642e01fSmrg 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]) ;; 91334642e01fSmrg *) 913435c4bbdfSmrg func_error "AGE '$age' must be a nonnegative integer" 913535c4bbdfSmrg func_fatal_error "'$vinfo' is not valid version information" 91364642e01fSmrg ;; 91374642e01fSmrg esac 91384642e01fSmrg 91394642e01fSmrg if test "$age" -gt "$current"; then 914035c4bbdfSmrg func_error "AGE '$age' is greater than the current interface number '$current'" 914135c4bbdfSmrg func_fatal_error "'$vinfo' is not valid version information" 91424642e01fSmrg fi 91434642e01fSmrg 91444642e01fSmrg # Calculate the version variables. 91454642e01fSmrg major= 91464642e01fSmrg versuffix= 91474642e01fSmrg verstring= 91484642e01fSmrg case $version_type in 91494642e01fSmrg none) ;; 91504642e01fSmrg 91514642e01fSmrg darwin) 91524642e01fSmrg # Like Linux, but with the current version available in 91534642e01fSmrg # verstring for coding it into the library header 91544642e01fSmrg func_arith $current - $age 91554642e01fSmrg major=.$func_arith_result 915635c4bbdfSmrg versuffix=$major.$age.$revision 91574642e01fSmrg # Darwin ld doesn't like 0 for these options... 91584642e01fSmrg func_arith $current + 1 91594642e01fSmrg minor_current=$func_arith_result 916035c4bbdfSmrg xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" 91614642e01fSmrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 916235c4bbdfSmrg # On Darwin other compilers 916335c4bbdfSmrg case $CC in 916435c4bbdfSmrg nagfor*) 916535c4bbdfSmrg verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" 916635c4bbdfSmrg ;; 916735c4bbdfSmrg *) 916835c4bbdfSmrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 916935c4bbdfSmrg ;; 917035c4bbdfSmrg esac 91714642e01fSmrg ;; 91724642e01fSmrg 91734642e01fSmrg freebsd-aout) 917435c4bbdfSmrg major=.$current 917535c4bbdfSmrg versuffix=.$current.$revision 91764642e01fSmrg ;; 91774642e01fSmrg 9178c82838c1Smrg freebsd-elf | midnightbsd-elf) 917935c4bbdfSmrg func_arith $current - $age 918035c4bbdfSmrg major=.$func_arith_result 918135c4bbdfSmrg versuffix=$major.$age.$revision 91824642e01fSmrg ;; 91834642e01fSmrg 91844642e01fSmrg irix | nonstopux) 918535c4bbdfSmrg if test no = "$lt_irix_increment"; then 91864642e01fSmrg func_arith $current - $age 91874642e01fSmrg else 91884642e01fSmrg func_arith $current - $age + 1 91894642e01fSmrg fi 91904642e01fSmrg major=$func_arith_result 91914642e01fSmrg 91924642e01fSmrg case $version_type in 91934642e01fSmrg nonstopux) verstring_prefix=nonstopux ;; 91944642e01fSmrg *) verstring_prefix=sgi ;; 91954642e01fSmrg esac 919635c4bbdfSmrg verstring=$verstring_prefix$major.$revision 91974642e01fSmrg 91984642e01fSmrg # Add in all the interfaces that we are compatible with. 91994642e01fSmrg loop=$revision 920035c4bbdfSmrg while test 0 -ne "$loop"; do 92014642e01fSmrg func_arith $revision - $loop 92024642e01fSmrg iface=$func_arith_result 92034642e01fSmrg func_arith $loop - 1 92044642e01fSmrg loop=$func_arith_result 920535c4bbdfSmrg verstring=$verstring_prefix$major.$iface:$verstring 92064642e01fSmrg done 92074642e01fSmrg 920835c4bbdfSmrg # Before this point, $major must not contain '.'. 92094642e01fSmrg major=.$major 921035c4bbdfSmrg versuffix=$major.$revision 92114642e01fSmrg ;; 92124642e01fSmrg 921335c4bbdfSmrg linux) # correct to gnu/linux during the next big refactor 92144642e01fSmrg func_arith $current - $age 92154642e01fSmrg major=.$func_arith_result 921635c4bbdfSmrg versuffix=$major.$age.$revision 92174642e01fSmrg ;; 92184642e01fSmrg 92194642e01fSmrg osf) 92204642e01fSmrg func_arith $current - $age 92214642e01fSmrg major=.$func_arith_result 922235c4bbdfSmrg versuffix=.$current.$age.$revision 922335c4bbdfSmrg verstring=$current.$age.$revision 92244642e01fSmrg 92254642e01fSmrg # Add in all the interfaces that we are compatible with. 92264642e01fSmrg loop=$age 922735c4bbdfSmrg while test 0 -ne "$loop"; do 92284642e01fSmrg func_arith $current - $loop 92294642e01fSmrg iface=$func_arith_result 92304642e01fSmrg func_arith $loop - 1 92314642e01fSmrg loop=$func_arith_result 923235c4bbdfSmrg verstring=$verstring:$iface.0 92334642e01fSmrg done 92344642e01fSmrg 92354642e01fSmrg # Make executables depend on our current version. 923635c4bbdfSmrg func_append verstring ":$current.0" 92374642e01fSmrg ;; 92384642e01fSmrg 92394642e01fSmrg qnx) 924035c4bbdfSmrg major=.$current 924135c4bbdfSmrg versuffix=.$current 924235c4bbdfSmrg ;; 924335c4bbdfSmrg 924435c4bbdfSmrg sco) 924535c4bbdfSmrg major=.$current 924635c4bbdfSmrg versuffix=.$current 92474642e01fSmrg ;; 92484642e01fSmrg 92494642e01fSmrg sunos) 925035c4bbdfSmrg major=.$current 925135c4bbdfSmrg versuffix=.$current.$revision 92524642e01fSmrg ;; 92534642e01fSmrg 92544642e01fSmrg windows) 92554642e01fSmrg # Use '-' rather than '.', since we only want one 925635c4bbdfSmrg # extension on DOS 8.3 file systems. 92574642e01fSmrg func_arith $current - $age 92584642e01fSmrg major=$func_arith_result 925935c4bbdfSmrg versuffix=-$major 92604642e01fSmrg ;; 92614642e01fSmrg 92624642e01fSmrg *) 926335c4bbdfSmrg func_fatal_configuration "unknown library version type '$version_type'" 92644642e01fSmrg ;; 92654642e01fSmrg esac 92664642e01fSmrg 92674642e01fSmrg # Clear the version info if we defaulted, and they specified a release. 92684642e01fSmrg if test -z "$vinfo" && test -n "$release"; then 92694642e01fSmrg major= 92704642e01fSmrg case $version_type in 92714642e01fSmrg darwin) 92724642e01fSmrg # we can't check for "0.0" in archive_cmds due to quoting 92734642e01fSmrg # problems, so we reset it completely 92744642e01fSmrg verstring= 92754642e01fSmrg ;; 92764642e01fSmrg *) 927735c4bbdfSmrg verstring=0.0 92784642e01fSmrg ;; 92794642e01fSmrg esac 928035c4bbdfSmrg if test no = "$need_version"; then 92814642e01fSmrg versuffix= 92824642e01fSmrg else 928335c4bbdfSmrg versuffix=.0.0 92844642e01fSmrg fi 92854642e01fSmrg fi 92864642e01fSmrg 92874642e01fSmrg # Remove version info from name if versioning should be avoided 928835c4bbdfSmrg if test yes,no = "$avoid_version,$need_version"; then 92894642e01fSmrg major= 92904642e01fSmrg versuffix= 929135c4bbdfSmrg verstring= 92924642e01fSmrg fi 92934642e01fSmrg 92944642e01fSmrg # Check to see if the archive will have undefined symbols. 929535c4bbdfSmrg if test yes = "$allow_undefined"; then 929635c4bbdfSmrg if test unsupported = "$allow_undefined_flag"; then 929735c4bbdfSmrg if test yes = "$build_old_libs"; then 929835c4bbdfSmrg func_warning "undefined symbols not allowed in $host shared libraries; building static only" 929935c4bbdfSmrg build_libtool_libs=no 930035c4bbdfSmrg else 930135c4bbdfSmrg func_fatal_error "can't build $host shared library unless -no-undefined is specified" 930235c4bbdfSmrg fi 93034642e01fSmrg fi 93044642e01fSmrg else 93054642e01fSmrg # Don't allow undefined symbols. 930635c4bbdfSmrg allow_undefined_flag=$no_undefined_flag 93074642e01fSmrg fi 93084642e01fSmrg 93094642e01fSmrg fi 93104642e01fSmrg 931135c4bbdfSmrg func_generate_dlsyms "$libname" "$libname" : 931235c4bbdfSmrg func_append libobjs " $symfileobj" 931335c4bbdfSmrg test " " = "$libobjs" && libobjs= 93144642e01fSmrg 931535c4bbdfSmrg if test relink != "$opt_mode"; then 93164642e01fSmrg # Remove our outputs, but don't remove object files since they 93174642e01fSmrg # may have been created when compiling PIC objects. 93184642e01fSmrg removelist= 93194642e01fSmrg tempremovelist=`$ECHO "$output_objdir/*"` 93204642e01fSmrg for p in $tempremovelist; do 93214642e01fSmrg case $p in 93224642e01fSmrg *.$objext | *.gcno) 93234642e01fSmrg ;; 932435c4bbdfSmrg $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/$libname$release.*) 932535c4bbdfSmrg if test -n "$precious_files_regex"; then 93264642e01fSmrg if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 93274642e01fSmrg then 93284642e01fSmrg continue 93294642e01fSmrg fi 93304642e01fSmrg fi 933135c4bbdfSmrg func_append removelist " $p" 93324642e01fSmrg ;; 93334642e01fSmrg *) ;; 93344642e01fSmrg esac 93354642e01fSmrg done 93364642e01fSmrg test -n "$removelist" && \ 93374642e01fSmrg func_show_eval "${RM}r \$removelist" 93384642e01fSmrg fi 93394642e01fSmrg 93404642e01fSmrg # Now set the variables for building old libraries. 934135c4bbdfSmrg if test yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; then 934235c4bbdfSmrg func_append oldlibs " $output_objdir/$libname.$libext" 93434642e01fSmrg 93444642e01fSmrg # Transform .lo files to .o files. 934535c4bbdfSmrg oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; $lo2o" | $NL2SP` 93464642e01fSmrg fi 93474642e01fSmrg 93484642e01fSmrg # Eliminate all temporary directories. 93494642e01fSmrg #for path in $notinst_path; do 93506747b715Smrg # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` 93516747b715Smrg # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` 93526747b715Smrg # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` 93534642e01fSmrg #done 93544642e01fSmrg 93554642e01fSmrg if test -n "$xrpath"; then 93564642e01fSmrg # If the user specified any rpath flags, then add them. 93574642e01fSmrg temp_xrpath= 93584642e01fSmrg for libdir in $xrpath; do 935935c4bbdfSmrg func_replace_sysroot "$libdir" 936035c4bbdfSmrg func_append temp_xrpath " -R$func_replace_sysroot_result" 93614642e01fSmrg case "$finalize_rpath " in 93624642e01fSmrg *" $libdir "*) ;; 936335c4bbdfSmrg *) func_append finalize_rpath " $libdir" ;; 93644642e01fSmrg esac 93654642e01fSmrg done 936635c4bbdfSmrg if test yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; then 93674642e01fSmrg dependency_libs="$temp_xrpath $dependency_libs" 93684642e01fSmrg fi 93694642e01fSmrg fi 93704642e01fSmrg 93714642e01fSmrg # Make sure dlfiles contains only unique files that won't be dlpreopened 937235c4bbdfSmrg old_dlfiles=$dlfiles 93734642e01fSmrg dlfiles= 93744642e01fSmrg for lib in $old_dlfiles; do 93754642e01fSmrg case " $dlprefiles $dlfiles " in 93764642e01fSmrg *" $lib "*) ;; 937735c4bbdfSmrg *) func_append dlfiles " $lib" ;; 93784642e01fSmrg esac 93794642e01fSmrg done 93804642e01fSmrg 93814642e01fSmrg # Make sure dlprefiles contains only unique files 938235c4bbdfSmrg old_dlprefiles=$dlprefiles 93834642e01fSmrg dlprefiles= 93844642e01fSmrg for lib in $old_dlprefiles; do 93854642e01fSmrg case "$dlprefiles " in 93864642e01fSmrg *" $lib "*) ;; 938735c4bbdfSmrg *) func_append dlprefiles " $lib" ;; 93884642e01fSmrg esac 93894642e01fSmrg done 93904642e01fSmrg 939135c4bbdfSmrg if test yes = "$build_libtool_libs"; then 93924642e01fSmrg if test -n "$rpath"; then 93934642e01fSmrg case $host in 93946747b715Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) 93954642e01fSmrg # these systems don't actually have a c library (as such)! 93964642e01fSmrg ;; 93974642e01fSmrg *-*-rhapsody* | *-*-darwin1.[012]) 93984642e01fSmrg # Rhapsody C library is in the System framework 939935c4bbdfSmrg func_append deplibs " System.ltframework" 94004642e01fSmrg ;; 94014642e01fSmrg *-*-netbsd*) 94024642e01fSmrg # Don't link with libc until the a.out ld.so is fixed. 94034642e01fSmrg ;; 9404c82838c1Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-midnightbsd*) 94054642e01fSmrg # Do not include libc due to us having libc/libc_r. 94064642e01fSmrg ;; 94074642e01fSmrg *-*-sco3.2v5* | *-*-sco5v6*) 94084642e01fSmrg # Causes problems with __ctype 94094642e01fSmrg ;; 94104642e01fSmrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 94114642e01fSmrg # Compiler inserts libc in the correct place for threads to work 94124642e01fSmrg ;; 94134642e01fSmrg *) 94144642e01fSmrg # Add libc to deplibs on all other systems if necessary. 941535c4bbdfSmrg if test yes = "$build_libtool_need_lc"; then 941635c4bbdfSmrg func_append deplibs " -lc" 94174642e01fSmrg fi 94184642e01fSmrg ;; 94194642e01fSmrg esac 94204642e01fSmrg fi 94214642e01fSmrg 94224642e01fSmrg # Transform deplibs into only deplibs that can be linked in shared. 94234642e01fSmrg name_save=$name 94244642e01fSmrg libname_save=$libname 94254642e01fSmrg release_save=$release 94264642e01fSmrg versuffix_save=$versuffix 94274642e01fSmrg major_save=$major 94284642e01fSmrg # I'm not sure if I'm treating the release correctly. I think 94294642e01fSmrg # release should show up in the -l (ie -lgmp5) so we don't want to 94304642e01fSmrg # add it in twice. Is that correct? 943135c4bbdfSmrg release= 943235c4bbdfSmrg versuffix= 943335c4bbdfSmrg major= 94344642e01fSmrg newdeplibs= 94354642e01fSmrg droppeddeps=no 94364642e01fSmrg case $deplibs_check_method in 94374642e01fSmrg pass_all) 94384642e01fSmrg # Don't check for shared/static. Everything works. 94394642e01fSmrg # This might be a little naive. We might want to check 94404642e01fSmrg # whether the library exists or not. But this is on 94414642e01fSmrg # osf3 & osf4 and I'm not really sure... Just 94424642e01fSmrg # implementing what was already the behavior. 94434642e01fSmrg newdeplibs=$deplibs 94444642e01fSmrg ;; 94454642e01fSmrg test_compile) 94464642e01fSmrg # This code stresses the "libraries are programs" paradigm to its 94474642e01fSmrg # limits. Maybe even breaks it. We compile a program, linking it 94484642e01fSmrg # against the deplibs as a proxy for the library. Then we can check 94494642e01fSmrg # whether they linked in statically or dynamically with ldd. 94504642e01fSmrg $opt_dry_run || $RM conftest.c 94514642e01fSmrg cat > conftest.c <<EOF 94524642e01fSmrg int main() { return 0; } 94534642e01fSmrgEOF 94544642e01fSmrg $opt_dry_run || $RM conftest 94554642e01fSmrg if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then 94564642e01fSmrg ldd_output=`ldd conftest` 94574642e01fSmrg for i in $deplibs; do 94584642e01fSmrg case $i in 94594642e01fSmrg -l*) 94604642e01fSmrg func_stripname -l '' "$i" 94614642e01fSmrg name=$func_stripname_result 946235c4bbdfSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 94634642e01fSmrg case " $predeps $postdeps " in 94644642e01fSmrg *" $i "*) 946535c4bbdfSmrg func_append newdeplibs " $i" 946635c4bbdfSmrg i= 94674642e01fSmrg ;; 94684642e01fSmrg esac 94694642e01fSmrg fi 947035c4bbdfSmrg if test -n "$i"; then 94714642e01fSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 94724642e01fSmrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 94734642e01fSmrg set dummy $deplib_matches; shift 94744642e01fSmrg deplib_match=$1 947535c4bbdfSmrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then 947635c4bbdfSmrg func_append newdeplibs " $i" 94774642e01fSmrg else 94784642e01fSmrg droppeddeps=yes 94796747b715Smrg echo 94804642e01fSmrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 94816747b715Smrg echo "*** I have the capability to make that library automatically link in when" 94826747b715Smrg echo "*** you link to this library. But I can only do this if you have a" 94836747b715Smrg echo "*** shared version of the library, which I believe you do not have" 94846747b715Smrg echo "*** because a test_compile did reveal that the linker did not use it for" 94856747b715Smrg echo "*** its dynamic dependency list that programs get resolved with at runtime." 94864642e01fSmrg fi 94874642e01fSmrg fi 94884642e01fSmrg ;; 94894642e01fSmrg *) 949035c4bbdfSmrg func_append newdeplibs " $i" 94914642e01fSmrg ;; 94924642e01fSmrg esac 94934642e01fSmrg done 94944642e01fSmrg else 94954642e01fSmrg # Error occurred in the first compile. Let's try to salvage 94964642e01fSmrg # the situation: Compile a separate program for each library. 94974642e01fSmrg for i in $deplibs; do 94984642e01fSmrg case $i in 94994642e01fSmrg -l*) 95004642e01fSmrg func_stripname -l '' "$i" 95014642e01fSmrg name=$func_stripname_result 95024642e01fSmrg $opt_dry_run || $RM conftest 95034642e01fSmrg if $LTCC $LTCFLAGS -o conftest conftest.c $i; then 95044642e01fSmrg ldd_output=`ldd conftest` 950535c4bbdfSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 95064642e01fSmrg case " $predeps $postdeps " in 95074642e01fSmrg *" $i "*) 950835c4bbdfSmrg func_append newdeplibs " $i" 950935c4bbdfSmrg i= 95104642e01fSmrg ;; 95114642e01fSmrg esac 95124642e01fSmrg fi 951335c4bbdfSmrg if test -n "$i"; then 95144642e01fSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 95154642e01fSmrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 95164642e01fSmrg set dummy $deplib_matches; shift 95174642e01fSmrg deplib_match=$1 951835c4bbdfSmrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then 951935c4bbdfSmrg func_append newdeplibs " $i" 95204642e01fSmrg else 95214642e01fSmrg droppeddeps=yes 95226747b715Smrg echo 95234642e01fSmrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 95246747b715Smrg echo "*** I have the capability to make that library automatically link in when" 95256747b715Smrg echo "*** you link to this library. But I can only do this if you have a" 95266747b715Smrg echo "*** shared version of the library, which you do not appear to have" 95276747b715Smrg echo "*** because a test_compile did reveal that the linker did not use this one" 95286747b715Smrg echo "*** as a dynamic dependency that programs can get resolved with at runtime." 95294642e01fSmrg fi 95304642e01fSmrg fi 95314642e01fSmrg else 95324642e01fSmrg droppeddeps=yes 95336747b715Smrg echo 95344642e01fSmrg $ECHO "*** Warning! Library $i is needed by this library but I was not able to" 95356747b715Smrg echo "*** make it link in! You will probably need to install it or some" 95366747b715Smrg echo "*** library that it depends on before this library will be fully" 95376747b715Smrg echo "*** functional. Installing it before continuing would be even better." 95384642e01fSmrg fi 95394642e01fSmrg ;; 95404642e01fSmrg *) 954135c4bbdfSmrg func_append newdeplibs " $i" 95424642e01fSmrg ;; 95434642e01fSmrg esac 95444642e01fSmrg done 95454642e01fSmrg fi 95464642e01fSmrg ;; 95474642e01fSmrg file_magic*) 95484642e01fSmrg set dummy $deplibs_check_method; shift 95494642e01fSmrg file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 95504642e01fSmrg for a_deplib in $deplibs; do 95514642e01fSmrg case $a_deplib in 95524642e01fSmrg -l*) 95534642e01fSmrg func_stripname -l '' "$a_deplib" 95544642e01fSmrg name=$func_stripname_result 955535c4bbdfSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 95564642e01fSmrg case " $predeps $postdeps " in 95574642e01fSmrg *" $a_deplib "*) 955835c4bbdfSmrg func_append newdeplibs " $a_deplib" 955935c4bbdfSmrg a_deplib= 95604642e01fSmrg ;; 95614642e01fSmrg esac 95624642e01fSmrg fi 956335c4bbdfSmrg if test -n "$a_deplib"; then 95644642e01fSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 956535c4bbdfSmrg if test -n "$file_magic_glob"; then 956635c4bbdfSmrg libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob` 956735c4bbdfSmrg else 956835c4bbdfSmrg libnameglob=$libname 956935c4bbdfSmrg fi 957035c4bbdfSmrg test yes = "$want_nocaseglob" && nocaseglob=`shopt -p nocaseglob` 95714642e01fSmrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 957235c4bbdfSmrg if test yes = "$want_nocaseglob"; then 957335c4bbdfSmrg shopt -s nocaseglob 957435c4bbdfSmrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 957535c4bbdfSmrg $nocaseglob 957635c4bbdfSmrg else 957735c4bbdfSmrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 957835c4bbdfSmrg fi 95794642e01fSmrg for potent_lib in $potential_libs; do 95804642e01fSmrg # Follow soft links. 95814642e01fSmrg if ls -lLd "$potent_lib" 2>/dev/null | 95824642e01fSmrg $GREP " -> " >/dev/null; then 95834642e01fSmrg continue 95844642e01fSmrg fi 95854642e01fSmrg # The statement above tries to avoid entering an 95864642e01fSmrg # endless loop below, in case of cyclic links. 95874642e01fSmrg # We might still enter an endless loop, since a link 95884642e01fSmrg # loop can be closed while we follow links, 95894642e01fSmrg # but so what? 959035c4bbdfSmrg potlib=$potent_lib 95914642e01fSmrg while test -h "$potlib" 2>/dev/null; do 959235c4bbdfSmrg potliblink=`ls -ld $potlib | $SED 's/.* -> //'` 95934642e01fSmrg case $potliblink in 959435c4bbdfSmrg [\\/]* | [A-Za-z]:[\\/]*) potlib=$potliblink;; 959535c4bbdfSmrg *) potlib=`$ECHO "$potlib" | $SED 's|[^/]*$||'`"$potliblink";; 95964642e01fSmrg esac 95974642e01fSmrg done 95984642e01fSmrg if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | 95994642e01fSmrg $SED -e 10q | 96004642e01fSmrg $EGREP "$file_magic_regex" > /dev/null; then 960135c4bbdfSmrg func_append newdeplibs " $a_deplib" 960235c4bbdfSmrg a_deplib= 96034642e01fSmrg break 2 96044642e01fSmrg fi 96054642e01fSmrg done 96064642e01fSmrg done 96074642e01fSmrg fi 960835c4bbdfSmrg if test -n "$a_deplib"; then 96094642e01fSmrg droppeddeps=yes 96106747b715Smrg echo 96114642e01fSmrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 96126747b715Smrg echo "*** I have the capability to make that library automatically link in when" 96136747b715Smrg echo "*** you link to this library. But I can only do this if you have a" 96146747b715Smrg echo "*** shared version of the library, which you do not appear to have" 96156747b715Smrg echo "*** because I did check the linker path looking for a file starting" 961635c4bbdfSmrg if test -z "$potlib"; then 96174642e01fSmrg $ECHO "*** with $libname but no candidates were found. (...for file magic test)" 96184642e01fSmrg else 96194642e01fSmrg $ECHO "*** with $libname and none of the candidates passed a file format test" 96204642e01fSmrg $ECHO "*** using a file magic. Last file checked: $potlib" 96214642e01fSmrg fi 96224642e01fSmrg fi 96234642e01fSmrg ;; 96244642e01fSmrg *) 96254642e01fSmrg # Add a -L argument. 962635c4bbdfSmrg func_append newdeplibs " $a_deplib" 96274642e01fSmrg ;; 96284642e01fSmrg esac 96294642e01fSmrg done # Gone through all deplibs. 96304642e01fSmrg ;; 96314642e01fSmrg match_pattern*) 96324642e01fSmrg set dummy $deplibs_check_method; shift 96334642e01fSmrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 96344642e01fSmrg for a_deplib in $deplibs; do 96354642e01fSmrg case $a_deplib in 96364642e01fSmrg -l*) 96374642e01fSmrg func_stripname -l '' "$a_deplib" 96384642e01fSmrg name=$func_stripname_result 963935c4bbdfSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 96404642e01fSmrg case " $predeps $postdeps " in 96414642e01fSmrg *" $a_deplib "*) 964235c4bbdfSmrg func_append newdeplibs " $a_deplib" 964335c4bbdfSmrg a_deplib= 96444642e01fSmrg ;; 96454642e01fSmrg esac 96464642e01fSmrg fi 964735c4bbdfSmrg if test -n "$a_deplib"; then 96484642e01fSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 96494642e01fSmrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 96504642e01fSmrg potential_libs=`ls $i/$libname[.-]* 2>/dev/null` 96514642e01fSmrg for potent_lib in $potential_libs; do 965235c4bbdfSmrg potlib=$potent_lib # see symlink-check above in file_magic test 96536747b715Smrg if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ 96544642e01fSmrg $EGREP "$match_pattern_regex" > /dev/null; then 965535c4bbdfSmrg func_append newdeplibs " $a_deplib" 965635c4bbdfSmrg a_deplib= 96574642e01fSmrg break 2 96584642e01fSmrg fi 96594642e01fSmrg done 96604642e01fSmrg done 96614642e01fSmrg fi 966235c4bbdfSmrg if test -n "$a_deplib"; then 96634642e01fSmrg droppeddeps=yes 96646747b715Smrg echo 96654642e01fSmrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 96666747b715Smrg echo "*** I have the capability to make that library automatically link in when" 96676747b715Smrg echo "*** you link to this library. But I can only do this if you have a" 96686747b715Smrg echo "*** shared version of the library, which you do not appear to have" 96696747b715Smrg echo "*** because I did check the linker path looking for a file starting" 967035c4bbdfSmrg if test -z "$potlib"; then 96714642e01fSmrg $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" 96724642e01fSmrg else 96734642e01fSmrg $ECHO "*** with $libname and none of the candidates passed a file format test" 96744642e01fSmrg $ECHO "*** using a regex pattern. Last file checked: $potlib" 96754642e01fSmrg fi 96764642e01fSmrg fi 96774642e01fSmrg ;; 96784642e01fSmrg *) 96794642e01fSmrg # Add a -L argument. 968035c4bbdfSmrg func_append newdeplibs " $a_deplib" 96814642e01fSmrg ;; 96824642e01fSmrg esac 96834642e01fSmrg done # Gone through all deplibs. 96844642e01fSmrg ;; 96854642e01fSmrg none | unknown | *) 968635c4bbdfSmrg newdeplibs= 96876747b715Smrg tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` 968835c4bbdfSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 968935c4bbdfSmrg for i in $predeps $postdeps; do 96904642e01fSmrg # can't use Xsed below, because $i might contain '/' 969135c4bbdfSmrg tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s|$i||"` 96924642e01fSmrg done 96934642e01fSmrg fi 96946747b715Smrg case $tmp_deplibs in 96956747b715Smrg *[!\ \ ]*) 96966747b715Smrg echo 969735c4bbdfSmrg if test none = "$deplibs_check_method"; then 96986747b715Smrg echo "*** Warning: inter-library dependencies are not supported in this platform." 96994642e01fSmrg else 97006747b715Smrg echo "*** Warning: inter-library dependencies are not known to be supported." 97014642e01fSmrg fi 97026747b715Smrg echo "*** All declared inter-library dependencies are being dropped." 97034642e01fSmrg droppeddeps=yes 97046747b715Smrg ;; 97056747b715Smrg esac 97064642e01fSmrg ;; 97074642e01fSmrg esac 97084642e01fSmrg versuffix=$versuffix_save 97094642e01fSmrg major=$major_save 97104642e01fSmrg release=$release_save 97114642e01fSmrg libname=$libname_save 97124642e01fSmrg name=$name_save 97134642e01fSmrg 97144642e01fSmrg case $host in 97154642e01fSmrg *-*-rhapsody* | *-*-darwin1.[012]) 97164642e01fSmrg # On Rhapsody replace the C library with the System framework 97176747b715Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` 97184642e01fSmrg ;; 97194642e01fSmrg esac 97204642e01fSmrg 972135c4bbdfSmrg if test yes = "$droppeddeps"; then 972235c4bbdfSmrg if test yes = "$module"; then 97236747b715Smrg echo 97246747b715Smrg echo "*** Warning: libtool could not satisfy all declared inter-library" 97254642e01fSmrg $ECHO "*** dependencies of module $libname. Therefore, libtool will create" 97266747b715Smrg echo "*** a static module, that should work as long as the dlopening" 97276747b715Smrg echo "*** application is linked with the -dlopen flag." 97284642e01fSmrg if test -z "$global_symbol_pipe"; then 97296747b715Smrg echo 97306747b715Smrg echo "*** However, this would only work if libtool was able to extract symbol" 973135c4bbdfSmrg echo "*** lists from a program, using 'nm' or equivalent, but libtool could" 97326747b715Smrg echo "*** not find such a program. So, this module is probably useless." 973335c4bbdfSmrg echo "*** 'nm' from GNU binutils and a full rebuild may help." 97344642e01fSmrg fi 973535c4bbdfSmrg if test no = "$build_old_libs"; then 973635c4bbdfSmrg oldlibs=$output_objdir/$libname.$libext 97374642e01fSmrg build_libtool_libs=module 97384642e01fSmrg build_old_libs=yes 97394642e01fSmrg else 97404642e01fSmrg build_libtool_libs=no 97414642e01fSmrg fi 97424642e01fSmrg else 97436747b715Smrg echo "*** The inter-library dependencies that have been dropped here will be" 97446747b715Smrg echo "*** automatically added whenever a program is linked with this library" 97456747b715Smrg echo "*** or is declared to -dlopen it." 97464642e01fSmrg 974735c4bbdfSmrg if test no = "$allow_undefined"; then 97486747b715Smrg echo 97496747b715Smrg echo "*** Since this library must not contain undefined symbols," 97506747b715Smrg echo "*** because either the platform does not support them or" 97516747b715Smrg echo "*** it was explicitly requested with -no-undefined," 97526747b715Smrg echo "*** libtool will only create a static version of it." 975335c4bbdfSmrg if test no = "$build_old_libs"; then 975435c4bbdfSmrg oldlibs=$output_objdir/$libname.$libext 97554642e01fSmrg build_libtool_libs=module 97564642e01fSmrg build_old_libs=yes 97574642e01fSmrg else 97584642e01fSmrg build_libtool_libs=no 97594642e01fSmrg fi 97604642e01fSmrg fi 97614642e01fSmrg fi 97624642e01fSmrg fi 97634642e01fSmrg # Done checking deplibs! 97644642e01fSmrg deplibs=$newdeplibs 97654642e01fSmrg fi 97664642e01fSmrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 97674642e01fSmrg case $host in 97684642e01fSmrg *-*-darwin*) 97696747b715Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 97706747b715Smrg new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 97716747b715Smrg deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 97724642e01fSmrg ;; 97734642e01fSmrg esac 97744642e01fSmrg 97754642e01fSmrg # move library search paths that coincide with paths to not yet 97764642e01fSmrg # installed libraries to the beginning of the library search list 97774642e01fSmrg new_libs= 97784642e01fSmrg for path in $notinst_path; do 97794642e01fSmrg case " $new_libs " in 97804642e01fSmrg *" -L$path/$objdir "*) ;; 97814642e01fSmrg *) 97824642e01fSmrg case " $deplibs " in 97834642e01fSmrg *" -L$path/$objdir "*) 978435c4bbdfSmrg func_append new_libs " -L$path/$objdir" ;; 97854642e01fSmrg esac 97864642e01fSmrg ;; 97874642e01fSmrg esac 97884642e01fSmrg done 97894642e01fSmrg for deplib in $deplibs; do 97904642e01fSmrg case $deplib in 97914642e01fSmrg -L*) 97924642e01fSmrg case " $new_libs " in 97934642e01fSmrg *" $deplib "*) ;; 979435c4bbdfSmrg *) func_append new_libs " $deplib" ;; 97954642e01fSmrg esac 97964642e01fSmrg ;; 979735c4bbdfSmrg *) func_append new_libs " $deplib" ;; 97984642e01fSmrg esac 97994642e01fSmrg done 980035c4bbdfSmrg deplibs=$new_libs 98014642e01fSmrg 98024642e01fSmrg # All the library-specific variables (install_libdir is set above). 98034642e01fSmrg library_names= 98044642e01fSmrg old_library= 98054642e01fSmrg dlname= 98064642e01fSmrg 98074642e01fSmrg # Test again, we may have decided not to build it any more 980835c4bbdfSmrg if test yes = "$build_libtool_libs"; then 980935c4bbdfSmrg # Remove $wl instances when linking with ld. 981035c4bbdfSmrg # FIXME: should test the right _cmds variable. 981135c4bbdfSmrg case $archive_cmds in 981235c4bbdfSmrg *\$LD\ *) wl= ;; 981335c4bbdfSmrg esac 981435c4bbdfSmrg if test yes = "$hardcode_into_libs"; then 98154642e01fSmrg # Hardcode the library paths 98164642e01fSmrg hardcode_libdirs= 98174642e01fSmrg dep_rpath= 981835c4bbdfSmrg rpath=$finalize_rpath 981935c4bbdfSmrg test relink = "$opt_mode" || rpath=$compile_rpath$rpath 98204642e01fSmrg for libdir in $rpath; do 98214642e01fSmrg if test -n "$hardcode_libdir_flag_spec"; then 98224642e01fSmrg if test -n "$hardcode_libdir_separator"; then 982335c4bbdfSmrg func_replace_sysroot "$libdir" 982435c4bbdfSmrg libdir=$func_replace_sysroot_result 98254642e01fSmrg if test -z "$hardcode_libdirs"; then 982635c4bbdfSmrg hardcode_libdirs=$libdir 98274642e01fSmrg else 98284642e01fSmrg # Just accumulate the unique libdirs. 98294642e01fSmrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 98304642e01fSmrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 98314642e01fSmrg ;; 98324642e01fSmrg *) 983335c4bbdfSmrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 98344642e01fSmrg ;; 98354642e01fSmrg esac 98364642e01fSmrg fi 98374642e01fSmrg else 98384642e01fSmrg eval flag=\"$hardcode_libdir_flag_spec\" 983935c4bbdfSmrg func_append dep_rpath " $flag" 98404642e01fSmrg fi 98414642e01fSmrg elif test -n "$runpath_var"; then 98424642e01fSmrg case "$perm_rpath " in 98434642e01fSmrg *" $libdir "*) ;; 984435c4bbdfSmrg *) func_append perm_rpath " $libdir" ;; 98454642e01fSmrg esac 98464642e01fSmrg fi 98474642e01fSmrg done 98484642e01fSmrg # Substitute the hardcoded libdirs into the rpath. 98494642e01fSmrg if test -n "$hardcode_libdir_separator" && 98504642e01fSmrg test -n "$hardcode_libdirs"; then 985135c4bbdfSmrg libdir=$hardcode_libdirs 985235c4bbdfSmrg eval "dep_rpath=\"$hardcode_libdir_flag_spec\"" 98534642e01fSmrg fi 98544642e01fSmrg if test -n "$runpath_var" && test -n "$perm_rpath"; then 98554642e01fSmrg # We should set the runpath_var. 98564642e01fSmrg rpath= 98574642e01fSmrg for dir in $perm_rpath; do 985835c4bbdfSmrg func_append rpath "$dir:" 98594642e01fSmrg done 98604642e01fSmrg eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" 98614642e01fSmrg fi 98624642e01fSmrg test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" 98634642e01fSmrg fi 986405b261ecSmrg 986535c4bbdfSmrg shlibpath=$finalize_shlibpath 986635c4bbdfSmrg test relink = "$opt_mode" || shlibpath=$compile_shlibpath$shlibpath 98674642e01fSmrg if test -n "$shlibpath"; then 98684642e01fSmrg eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" 98694642e01fSmrg fi 987005b261ecSmrg 98714642e01fSmrg # Get the real and link names of the library. 98724642e01fSmrg eval shared_ext=\"$shrext_cmds\" 98734642e01fSmrg eval library_names=\"$library_names_spec\" 98744642e01fSmrg set dummy $library_names 98754642e01fSmrg shift 987635c4bbdfSmrg realname=$1 98774642e01fSmrg shift 987805b261ecSmrg 98794642e01fSmrg if test -n "$soname_spec"; then 98804642e01fSmrg eval soname=\"$soname_spec\" 98814642e01fSmrg else 988235c4bbdfSmrg soname=$realname 98834642e01fSmrg fi 98844642e01fSmrg if test -z "$dlname"; then 98854642e01fSmrg dlname=$soname 98864642e01fSmrg fi 988705b261ecSmrg 988835c4bbdfSmrg lib=$output_objdir/$realname 98894642e01fSmrg linknames= 98904642e01fSmrg for link 98914642e01fSmrg do 989235c4bbdfSmrg func_append linknames " $link" 98934642e01fSmrg done 989405b261ecSmrg 98954642e01fSmrg # Use standard objects if they are pic 98966747b715Smrg test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` 98974642e01fSmrg test "X$libobjs" = "X " && libobjs= 989805b261ecSmrg 98994642e01fSmrg delfiles= 99004642e01fSmrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 99014642e01fSmrg $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" 990235c4bbdfSmrg export_symbols=$output_objdir/$libname.uexp 990335c4bbdfSmrg func_append delfiles " $export_symbols" 99044642e01fSmrg fi 990505b261ecSmrg 99064642e01fSmrg orig_export_symbols= 99074642e01fSmrg case $host_os in 99084642e01fSmrg cygwin* | mingw* | cegcc*) 99094642e01fSmrg if test -n "$export_symbols" && test -z "$export_symbols_regex"; then 99104642e01fSmrg # exporting using user supplied symfile 991135c4bbdfSmrg func_dll_def_p "$export_symbols" || { 99124642e01fSmrg # and it's NOT already a .def file. Must figure out 99134642e01fSmrg # which of the given symbols are data symbols and tag 99144642e01fSmrg # them as such. So, trigger use of export_symbols_cmds. 99154642e01fSmrg # export_symbols gets reassigned inside the "prepare 99164642e01fSmrg # the list of exported symbols" if statement, so the 99174642e01fSmrg # include_expsyms logic still works. 991835c4bbdfSmrg orig_export_symbols=$export_symbols 99194642e01fSmrg export_symbols= 99204642e01fSmrg always_export_symbols=yes 992135c4bbdfSmrg } 99224642e01fSmrg fi 99234642e01fSmrg ;; 99244642e01fSmrg esac 992505b261ecSmrg 99264642e01fSmrg # Prepare the list of exported symbols 99274642e01fSmrg if test -z "$export_symbols"; then 992835c4bbdfSmrg if test yes = "$always_export_symbols" || test -n "$export_symbols_regex"; then 992935c4bbdfSmrg func_verbose "generating symbol list for '$libname.la'" 993035c4bbdfSmrg export_symbols=$output_objdir/$libname.exp 99314642e01fSmrg $opt_dry_run || $RM $export_symbols 99324642e01fSmrg cmds=$export_symbols_cmds 993335c4bbdfSmrg save_ifs=$IFS; IFS='~' 993435c4bbdfSmrg for cmd1 in $cmds; do 993535c4bbdfSmrg IFS=$save_ifs 993635c4bbdfSmrg # Take the normal branch if the nm_file_list_spec branch 993735c4bbdfSmrg # doesn't work or if tool conversion is not needed. 993835c4bbdfSmrg case $nm_file_list_spec~$to_tool_file_cmd in 993935c4bbdfSmrg *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) 994035c4bbdfSmrg try_normal_branch=yes 994135c4bbdfSmrg eval cmd=\"$cmd1\" 994235c4bbdfSmrg func_len " $cmd" 994335c4bbdfSmrg len=$func_len_result 994435c4bbdfSmrg ;; 994535c4bbdfSmrg *) 994635c4bbdfSmrg try_normal_branch=no 994735c4bbdfSmrg ;; 994835c4bbdfSmrg esac 994935c4bbdfSmrg if test yes = "$try_normal_branch" \ 995035c4bbdfSmrg && { test "$len" -lt "$max_cmd_len" \ 995135c4bbdfSmrg || test "$max_cmd_len" -le -1; } 995235c4bbdfSmrg then 995335c4bbdfSmrg func_show_eval "$cmd" 'exit $?' 995435c4bbdfSmrg skipped_export=false 995535c4bbdfSmrg elif test -n "$nm_file_list_spec"; then 995635c4bbdfSmrg func_basename "$output" 995735c4bbdfSmrg output_la=$func_basename_result 995835c4bbdfSmrg save_libobjs=$libobjs 995935c4bbdfSmrg save_output=$output 996035c4bbdfSmrg output=$output_objdir/$output_la.nm 996135c4bbdfSmrg func_to_tool_file "$output" 996235c4bbdfSmrg libobjs=$nm_file_list_spec$func_to_tool_file_result 996335c4bbdfSmrg func_append delfiles " $output" 996435c4bbdfSmrg func_verbose "creating $NM input file list: $output" 996535c4bbdfSmrg for obj in $save_libobjs; do 996635c4bbdfSmrg func_to_tool_file "$obj" 996735c4bbdfSmrg $ECHO "$func_to_tool_file_result" 996835c4bbdfSmrg done > "$output" 996935c4bbdfSmrg eval cmd=\"$cmd1\" 99704642e01fSmrg func_show_eval "$cmd" 'exit $?' 997135c4bbdfSmrg output=$save_output 997235c4bbdfSmrg libobjs=$save_libobjs 99734642e01fSmrg skipped_export=false 99744642e01fSmrg else 99754642e01fSmrg # The command line is too long to execute in one step. 99764642e01fSmrg func_verbose "using reloadable object file for export list..." 99774642e01fSmrg skipped_export=: 99784642e01fSmrg # Break out early, otherwise skipped_export may be 99794642e01fSmrg # set to false by a later but shorter cmd. 99804642e01fSmrg break 99814642e01fSmrg fi 99824642e01fSmrg done 998335c4bbdfSmrg IFS=$save_ifs 998435c4bbdfSmrg if test -n "$export_symbols_regex" && test : != "$skipped_export"; then 99854642e01fSmrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 99864642e01fSmrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 99874642e01fSmrg fi 99884642e01fSmrg fi 998905b261ecSmrg fi 999005b261ecSmrg 99914642e01fSmrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 999235c4bbdfSmrg tmp_export_symbols=$export_symbols 999335c4bbdfSmrg test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols 99946747b715Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 99954642e01fSmrg fi 999605b261ecSmrg 999735c4bbdfSmrg if test : != "$skipped_export" && test -n "$orig_export_symbols"; then 99984642e01fSmrg # The given exports_symbols file has to be filtered, so filter it. 999935c4bbdfSmrg func_verbose "filter symbol list for '$libname.la' to tag DATA exports" 100004642e01fSmrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 1000135c4bbdfSmrg # 's' commands, which not all seds can handle. GNU sed should be fine 100024642e01fSmrg # though. Also, the filter scales superlinearly with the number of 100034642e01fSmrg # global variables. join(1) would be nice here, but unfortunately 100044642e01fSmrg # isn't a blessed tool. 100054642e01fSmrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 1000635c4bbdfSmrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 100074642e01fSmrg export_symbols=$output_objdir/$libname.def 100084642e01fSmrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 100094642e01fSmrg fi 1001005b261ecSmrg 100114642e01fSmrg tmp_deplibs= 100124642e01fSmrg for test_deplib in $deplibs; do 100134642e01fSmrg case " $convenience " in 100144642e01fSmrg *" $test_deplib "*) ;; 100154642e01fSmrg *) 1001635c4bbdfSmrg func_append tmp_deplibs " $test_deplib" 100174642e01fSmrg ;; 100184642e01fSmrg esac 100194642e01fSmrg done 1002035c4bbdfSmrg deplibs=$tmp_deplibs 1002105b261ecSmrg 100224642e01fSmrg if test -n "$convenience"; then 100234642e01fSmrg if test -n "$whole_archive_flag_spec" && 1002435c4bbdfSmrg test yes = "$compiler_needs_object" && 100254642e01fSmrg test -z "$libobjs"; then 100264642e01fSmrg # extract the archives, so we have objects to list. 100274642e01fSmrg # TODO: could optimize this to just extract one archive. 100284642e01fSmrg whole_archive_flag_spec= 100294642e01fSmrg fi 100304642e01fSmrg if test -n "$whole_archive_flag_spec"; then 100314642e01fSmrg save_libobjs=$libobjs 100324642e01fSmrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 100334642e01fSmrg test "X$libobjs" = "X " && libobjs= 100344642e01fSmrg else 1003535c4bbdfSmrg gentop=$output_objdir/${outputname}x 1003635c4bbdfSmrg func_append generated " $gentop" 1003705b261ecSmrg 100384642e01fSmrg func_extract_archives $gentop $convenience 1003935c4bbdfSmrg func_append libobjs " $func_extract_archives_result" 100404642e01fSmrg test "X$libobjs" = "X " && libobjs= 100414642e01fSmrg fi 1004205b261ecSmrg fi 1004305b261ecSmrg 1004435c4bbdfSmrg if test yes = "$thread_safe" && test -n "$thread_safe_flag_spec"; then 100454642e01fSmrg eval flag=\"$thread_safe_flag_spec\" 1004635c4bbdfSmrg func_append linker_flags " $flag" 1004705b261ecSmrg fi 1004805b261ecSmrg 100494642e01fSmrg # Make a backup of the uninstalled library when relinking 1005035c4bbdfSmrg if test relink = "$opt_mode"; then 100514642e01fSmrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? 100524642e01fSmrg fi 1005305b261ecSmrg 100544642e01fSmrg # Do each of the archive commands. 1005535c4bbdfSmrg if test yes = "$module" && test -n "$module_cmds"; then 100564642e01fSmrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 100574642e01fSmrg eval test_cmds=\"$module_expsym_cmds\" 100584642e01fSmrg cmds=$module_expsym_cmds 100594642e01fSmrg else 100604642e01fSmrg eval test_cmds=\"$module_cmds\" 100614642e01fSmrg cmds=$module_cmds 100624642e01fSmrg fi 1006305b261ecSmrg else 100644642e01fSmrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 100654642e01fSmrg eval test_cmds=\"$archive_expsym_cmds\" 100664642e01fSmrg cmds=$archive_expsym_cmds 100674642e01fSmrg else 100684642e01fSmrg eval test_cmds=\"$archive_cmds\" 100694642e01fSmrg cmds=$archive_cmds 100704642e01fSmrg fi 1007105b261ecSmrg fi 1007205b261ecSmrg 1007335c4bbdfSmrg if test : != "$skipped_export" && 100744642e01fSmrg func_len " $test_cmds" && 100754642e01fSmrg len=$func_len_result && 100764642e01fSmrg test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 100774642e01fSmrg : 100784642e01fSmrg else 100794642e01fSmrg # The command line is too long to link in one step, link piecewise 100804642e01fSmrg # or, if using GNU ld and skipped_export is not :, use a linker 100814642e01fSmrg # script. 1008205b261ecSmrg 100834642e01fSmrg # Save the value of $output and $libobjs because we want to 100844642e01fSmrg # use them later. If we have whole_archive_flag_spec, we 100854642e01fSmrg # want to use save_libobjs as it was before 100864642e01fSmrg # whole_archive_flag_spec was expanded, because we can't 100874642e01fSmrg # assume the linker understands whole_archive_flag_spec. 100884642e01fSmrg # This may have to be revisited, in case too many 100894642e01fSmrg # convenience libraries get linked in and end up exceeding 100904642e01fSmrg # the spec. 100914642e01fSmrg if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then 100924642e01fSmrg save_libobjs=$libobjs 100934642e01fSmrg fi 100944642e01fSmrg save_output=$output 100956747b715Smrg func_basename "$output" 100966747b715Smrg output_la=$func_basename_result 1009705b261ecSmrg 100984642e01fSmrg # Clear the reloadable object creation command queue and 100994642e01fSmrg # initialize k to one. 101004642e01fSmrg test_cmds= 101014642e01fSmrg concat_cmds= 101024642e01fSmrg objlist= 101034642e01fSmrg last_robj= 101044642e01fSmrg k=1 101054642e01fSmrg 1010635c4bbdfSmrg if test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then 1010735c4bbdfSmrg output=$output_objdir/$output_la.lnkscript 101084642e01fSmrg func_verbose "creating GNU ld script: $output" 101096747b715Smrg echo 'INPUT (' > $output 101104642e01fSmrg for obj in $save_libobjs 1011105b261ecSmrg do 1011235c4bbdfSmrg func_to_tool_file "$obj" 1011335c4bbdfSmrg $ECHO "$func_to_tool_file_result" >> $output 101144642e01fSmrg done 101156747b715Smrg echo ')' >> $output 1011635c4bbdfSmrg func_append delfiles " $output" 1011735c4bbdfSmrg func_to_tool_file "$output" 1011835c4bbdfSmrg output=$func_to_tool_file_result 1011935c4bbdfSmrg elif test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then 1012035c4bbdfSmrg output=$output_objdir/$output_la.lnk 101214642e01fSmrg func_verbose "creating linker input file list: $output" 101224642e01fSmrg : > $output 101234642e01fSmrg set x $save_libobjs 101244642e01fSmrg shift 101254642e01fSmrg firstobj= 1012635c4bbdfSmrg if test yes = "$compiler_needs_object"; then 101274642e01fSmrg firstobj="$1 " 101284642e01fSmrg shift 101294642e01fSmrg fi 101304642e01fSmrg for obj 101314642e01fSmrg do 1013235c4bbdfSmrg func_to_tool_file "$obj" 1013335c4bbdfSmrg $ECHO "$func_to_tool_file_result" >> $output 101344642e01fSmrg done 1013535c4bbdfSmrg func_append delfiles " $output" 1013635c4bbdfSmrg func_to_tool_file "$output" 1013735c4bbdfSmrg output=$firstobj\"$file_list_spec$func_to_tool_file_result\" 101384642e01fSmrg else 101394642e01fSmrg if test -n "$save_libobjs"; then 101404642e01fSmrg func_verbose "creating reloadable object files..." 1014135c4bbdfSmrg output=$output_objdir/$output_la-$k.$objext 101424642e01fSmrg eval test_cmds=\"$reload_cmds\" 101434642e01fSmrg func_len " $test_cmds" 101444642e01fSmrg len0=$func_len_result 101454642e01fSmrg len=$len0 101464642e01fSmrg 101474642e01fSmrg # Loop over the list of objects to be linked. 101484642e01fSmrg for obj in $save_libobjs 101494642e01fSmrg do 101504642e01fSmrg func_len " $obj" 101514642e01fSmrg func_arith $len + $func_len_result 101524642e01fSmrg len=$func_arith_result 1015335c4bbdfSmrg if test -z "$objlist" || 101544642e01fSmrg test "$len" -lt "$max_cmd_len"; then 101554642e01fSmrg func_append objlist " $obj" 101564642e01fSmrg else 101574642e01fSmrg # The command $test_cmds is almost too long, add a 101584642e01fSmrg # command to the queue. 1015935c4bbdfSmrg if test 1 -eq "$k"; then 101604642e01fSmrg # The first file doesn't have a previous command to add. 101616747b715Smrg reload_objs=$objlist 101626747b715Smrg eval concat_cmds=\"$reload_cmds\" 101634642e01fSmrg else 101644642e01fSmrg # All subsequent reloadable object files will link in 101654642e01fSmrg # the last one created. 101666747b715Smrg reload_objs="$objlist $last_robj" 101676747b715Smrg eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" 101684642e01fSmrg fi 1016935c4bbdfSmrg last_robj=$output_objdir/$output_la-$k.$objext 101704642e01fSmrg func_arith $k + 1 101714642e01fSmrg k=$func_arith_result 1017235c4bbdfSmrg output=$output_objdir/$output_la-$k.$objext 101736747b715Smrg objlist=" $obj" 101744642e01fSmrg func_len " $last_robj" 101754642e01fSmrg func_arith $len0 + $func_len_result 101764642e01fSmrg len=$func_arith_result 101774642e01fSmrg fi 101784642e01fSmrg done 101794642e01fSmrg # Handle the remaining objects by creating one last 101804642e01fSmrg # reloadable object file. All subsequent reloadable object 101814642e01fSmrg # files will link in the last one created. 101824642e01fSmrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 101836747b715Smrg reload_objs="$objlist $last_robj" 1018435c4bbdfSmrg eval concat_cmds=\"\$concat_cmds$reload_cmds\" 101854642e01fSmrg if test -n "$last_robj"; then 1018635c4bbdfSmrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 101874642e01fSmrg fi 1018835c4bbdfSmrg func_append delfiles " $output" 1018905b261ecSmrg 101904642e01fSmrg else 101914642e01fSmrg output= 101924642e01fSmrg fi 1019305b261ecSmrg 1019435c4bbdfSmrg ${skipped_export-false} && { 1019535c4bbdfSmrg func_verbose "generating symbol list for '$libname.la'" 1019635c4bbdfSmrg export_symbols=$output_objdir/$libname.exp 101974642e01fSmrg $opt_dry_run || $RM $export_symbols 101984642e01fSmrg libobjs=$output 101994642e01fSmrg # Append the command to create the export file. 102004642e01fSmrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 102014642e01fSmrg eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" 102024642e01fSmrg if test -n "$last_robj"; then 102034642e01fSmrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 102044642e01fSmrg fi 1020535c4bbdfSmrg } 1020605b261ecSmrg 102074642e01fSmrg test -n "$save_libobjs" && 102084642e01fSmrg func_verbose "creating a temporary reloadable object file: $output" 1020905b261ecSmrg 102104642e01fSmrg # Loop through the commands generated above and execute them. 1021135c4bbdfSmrg save_ifs=$IFS; IFS='~' 102124642e01fSmrg for cmd in $concat_cmds; do 1021335c4bbdfSmrg IFS=$save_ifs 1021435c4bbdfSmrg $opt_quiet || { 10215c82838c1Smrg func_quote_arg expand,pretty "$cmd" 10216c82838c1Smrg eval "func_echo $func_quote_arg_result" 102174642e01fSmrg } 102184642e01fSmrg $opt_dry_run || eval "$cmd" || { 102194642e01fSmrg lt_exit=$? 102204642e01fSmrg 102214642e01fSmrg # Restore the uninstalled library and exit 1022235c4bbdfSmrg if test relink = "$opt_mode"; then 102234642e01fSmrg ( cd "$output_objdir" && \ 102244642e01fSmrg $RM "${realname}T" && \ 102254642e01fSmrg $MV "${realname}U" "$realname" ) 102264642e01fSmrg fi 1022705b261ecSmrg 102284642e01fSmrg exit $lt_exit 102294642e01fSmrg } 102304642e01fSmrg done 1023135c4bbdfSmrg IFS=$save_ifs 1023205b261ecSmrg 102334642e01fSmrg if test -n "$export_symbols_regex" && ${skipped_export-false}; then 102344642e01fSmrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 102354642e01fSmrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 1023605b261ecSmrg fi 1023705b261ecSmrg fi 1023805b261ecSmrg 1023935c4bbdfSmrg ${skipped_export-false} && { 102404642e01fSmrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 1024135c4bbdfSmrg tmp_export_symbols=$export_symbols 1024235c4bbdfSmrg test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols 102436747b715Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 102444642e01fSmrg fi 1024505b261ecSmrg 102464642e01fSmrg if test -n "$orig_export_symbols"; then 102474642e01fSmrg # The given exports_symbols file has to be filtered, so filter it. 1024835c4bbdfSmrg func_verbose "filter symbol list for '$libname.la' to tag DATA exports" 102494642e01fSmrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 1025035c4bbdfSmrg # 's' commands, which not all seds can handle. GNU sed should be fine 102514642e01fSmrg # though. Also, the filter scales superlinearly with the number of 102524642e01fSmrg # global variables. join(1) would be nice here, but unfortunately 102534642e01fSmrg # isn't a blessed tool. 102544642e01fSmrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 1025535c4bbdfSmrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 102564642e01fSmrg export_symbols=$output_objdir/$libname.def 102574642e01fSmrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 102584642e01fSmrg fi 1025935c4bbdfSmrg } 1026005b261ecSmrg 102614642e01fSmrg libobjs=$output 102624642e01fSmrg # Restore the value of output. 102634642e01fSmrg output=$save_output 1026405b261ecSmrg 102654642e01fSmrg if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then 102664642e01fSmrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 102674642e01fSmrg test "X$libobjs" = "X " && libobjs= 102684642e01fSmrg fi 102694642e01fSmrg # Expand the library linking commands again to reset the 102704642e01fSmrg # value of $libobjs for piecewise linking. 1027105b261ecSmrg 102724642e01fSmrg # Do each of the archive commands. 1027335c4bbdfSmrg if test yes = "$module" && test -n "$module_cmds"; then 102744642e01fSmrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 102754642e01fSmrg cmds=$module_expsym_cmds 102764642e01fSmrg else 102774642e01fSmrg cmds=$module_cmds 1027805b261ecSmrg fi 1027905b261ecSmrg else 102804642e01fSmrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 102814642e01fSmrg cmds=$archive_expsym_cmds 102824642e01fSmrg else 102834642e01fSmrg cmds=$archive_cmds 102844642e01fSmrg fi 1028505b261ecSmrg fi 102864642e01fSmrg fi 1028705b261ecSmrg 102884642e01fSmrg if test -n "$delfiles"; then 102894642e01fSmrg # Append the command to remove temporary files to $cmds. 102904642e01fSmrg eval cmds=\"\$cmds~\$RM $delfiles\" 102914642e01fSmrg fi 1029205b261ecSmrg 102934642e01fSmrg # Add any objects from preloaded convenience libraries 102944642e01fSmrg if test -n "$dlprefiles"; then 1029535c4bbdfSmrg gentop=$output_objdir/${outputname}x 1029635c4bbdfSmrg func_append generated " $gentop" 1029705b261ecSmrg 102984642e01fSmrg func_extract_archives $gentop $dlprefiles 1029935c4bbdfSmrg func_append libobjs " $func_extract_archives_result" 103004642e01fSmrg test "X$libobjs" = "X " && libobjs= 103014642e01fSmrg fi 1030205b261ecSmrg 1030335c4bbdfSmrg save_ifs=$IFS; IFS='~' 103044642e01fSmrg for cmd in $cmds; do 1030535c4bbdfSmrg IFS=$sp$nl 103064642e01fSmrg eval cmd=\"$cmd\" 1030735c4bbdfSmrg IFS=$save_ifs 1030835c4bbdfSmrg $opt_quiet || { 10309c82838c1Smrg func_quote_arg expand,pretty "$cmd" 10310c82838c1Smrg eval "func_echo $func_quote_arg_result" 103114642e01fSmrg } 103124642e01fSmrg $opt_dry_run || eval "$cmd" || { 103134642e01fSmrg lt_exit=$? 1031405b261ecSmrg 103154642e01fSmrg # Restore the uninstalled library and exit 1031635c4bbdfSmrg if test relink = "$opt_mode"; then 103174642e01fSmrg ( cd "$output_objdir" && \ 103184642e01fSmrg $RM "${realname}T" && \ 103194642e01fSmrg $MV "${realname}U" "$realname" ) 103204642e01fSmrg fi 1032105b261ecSmrg 103224642e01fSmrg exit $lt_exit 103234642e01fSmrg } 103244642e01fSmrg done 1032535c4bbdfSmrg IFS=$save_ifs 1032605b261ecSmrg 103274642e01fSmrg # Restore the uninstalled library and exit 1032835c4bbdfSmrg if test relink = "$opt_mode"; then 103294642e01fSmrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? 1033005b261ecSmrg 103314642e01fSmrg if test -n "$convenience"; then 103324642e01fSmrg if test -z "$whole_archive_flag_spec"; then 103334642e01fSmrg func_show_eval '${RM}r "$gentop"' 103344642e01fSmrg fi 103354642e01fSmrg fi 1033605b261ecSmrg 103374642e01fSmrg exit $EXIT_SUCCESS 103384642e01fSmrg fi 103394642e01fSmrg 103404642e01fSmrg # Create links to the real library. 103414642e01fSmrg for linkname in $linknames; do 103424642e01fSmrg if test "$realname" != "$linkname"; then 103434642e01fSmrg func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' 1034405b261ecSmrg fi 1034505b261ecSmrg done 1034605b261ecSmrg 103474642e01fSmrg # If -module or -export-dynamic was specified, set the dlname. 1034835c4bbdfSmrg if test yes = "$module" || test yes = "$export_dynamic"; then 103494642e01fSmrg # On all known operating systems, these are identical. 1035035c4bbdfSmrg dlname=$soname 103514642e01fSmrg fi 103524642e01fSmrg fi 1035305b261ecSmrg ;; 1035405b261ecSmrg 103554642e01fSmrg obj) 1035635c4bbdfSmrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 1035735c4bbdfSmrg func_warning "'-dlopen' is ignored for objects" 103584642e01fSmrg fi 1035905b261ecSmrg 103604642e01fSmrg case " $deplibs" in 103614642e01fSmrg *\ -l* | *\ -L*) 1036235c4bbdfSmrg func_warning "'-l' and '-L' are ignored for objects" ;; 1036305b261ecSmrg esac 1036405b261ecSmrg 103654642e01fSmrg test -n "$rpath" && \ 1036635c4bbdfSmrg func_warning "'-rpath' is ignored for objects" 103674642e01fSmrg 103684642e01fSmrg test -n "$xrpath" && \ 1036935c4bbdfSmrg func_warning "'-R' is ignored for objects" 1037005b261ecSmrg 103714642e01fSmrg test -n "$vinfo" && \ 1037235c4bbdfSmrg func_warning "'-version-info' is ignored for objects" 1037305b261ecSmrg 103744642e01fSmrg test -n "$release" && \ 1037535c4bbdfSmrg func_warning "'-release' is ignored for objects" 103764642e01fSmrg 103774642e01fSmrg case $output in 103784642e01fSmrg *.lo) 103794642e01fSmrg test -n "$objs$old_deplibs" && \ 1038035c4bbdfSmrg func_fatal_error "cannot build library object '$output' from non-libtool objects" 103814642e01fSmrg 103824642e01fSmrg libobj=$output 103834642e01fSmrg func_lo2o "$libobj" 103844642e01fSmrg obj=$func_lo2o_result 1038505b261ecSmrg ;; 1038605b261ecSmrg *) 103874642e01fSmrg libobj= 1038835c4bbdfSmrg obj=$output 1038905b261ecSmrg ;; 1039005b261ecSmrg esac 1039105b261ecSmrg 103924642e01fSmrg # Delete the old objects. 103934642e01fSmrg $opt_dry_run || $RM $obj $libobj 1039405b261ecSmrg 103954642e01fSmrg # Objects from convenience libraries. This assumes 103964642e01fSmrg # single-version convenience libraries. Whenever we create 103974642e01fSmrg # different ones for PIC/non-PIC, this we'll have to duplicate 103984642e01fSmrg # the extraction. 103994642e01fSmrg reload_conv_objs= 104004642e01fSmrg gentop= 1040135c4bbdfSmrg # if reload_cmds runs $LD directly, get rid of -Wl from 1040235c4bbdfSmrg # whole_archive_flag_spec and hope we can get by with turning comma 1040335c4bbdfSmrg # into space. 1040435c4bbdfSmrg case $reload_cmds in 1040535c4bbdfSmrg *\$LD[\ \$]*) wl= ;; 1040635c4bbdfSmrg esac 104074642e01fSmrg if test -n "$convenience"; then 104084642e01fSmrg if test -n "$whole_archive_flag_spec"; then 104094642e01fSmrg eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" 1041035c4bbdfSmrg test -n "$wl" || tmp_whole_archive_flags=`$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` 1041135c4bbdfSmrg reload_conv_objs=$reload_objs\ $tmp_whole_archive_flags 104124642e01fSmrg else 1041335c4bbdfSmrg gentop=$output_objdir/${obj}x 1041435c4bbdfSmrg func_append generated " $gentop" 1041505b261ecSmrg 104164642e01fSmrg func_extract_archives $gentop $convenience 104174642e01fSmrg reload_conv_objs="$reload_objs $func_extract_archives_result" 104184642e01fSmrg fi 1041905b261ecSmrg fi 1042005b261ecSmrg 1042135c4bbdfSmrg # If we're not building shared, we need to use non_pic_objs 1042235c4bbdfSmrg test yes = "$build_libtool_libs" || libobjs=$non_pic_objects 1042335c4bbdfSmrg 104244642e01fSmrg # Create the old-style object. 1042535c4bbdfSmrg reload_objs=$objs$old_deplibs' '`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; /\.lib$/d; $lo2o" | $NL2SP`' '$reload_conv_objs 1042605b261ecSmrg 1042735c4bbdfSmrg output=$obj 104284642e01fSmrg func_execute_cmds "$reload_cmds" 'exit $?' 1042905b261ecSmrg 104304642e01fSmrg # Exit if we aren't doing a library object file. 104314642e01fSmrg if test -z "$libobj"; then 104324642e01fSmrg if test -n "$gentop"; then 104334642e01fSmrg func_show_eval '${RM}r "$gentop"' 104344642e01fSmrg fi 104354642e01fSmrg 104364642e01fSmrg exit $EXIT_SUCCESS 1043705b261ecSmrg fi 104384642e01fSmrg 1043935c4bbdfSmrg test yes = "$build_libtool_libs" || { 104404642e01fSmrg if test -n "$gentop"; then 104414642e01fSmrg func_show_eval '${RM}r "$gentop"' 104424642e01fSmrg fi 104434642e01fSmrg 104444642e01fSmrg # Create an invalid libtool object if no PIC, so that we don't 104454642e01fSmrg # accidentally link it into a program. 104464642e01fSmrg # $show "echo timestamp > $libobj" 104474642e01fSmrg # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? 104484642e01fSmrg exit $EXIT_SUCCESS 1044935c4bbdfSmrg } 104504642e01fSmrg 1045135c4bbdfSmrg if test -n "$pic_flag" || test default != "$pic_mode"; then 104524642e01fSmrg # Only do commands if we really have different PIC objects. 104534642e01fSmrg reload_objs="$libobjs $reload_conv_objs" 1045435c4bbdfSmrg output=$libobj 104554642e01fSmrg func_execute_cmds "$reload_cmds" 'exit $?' 104564642e01fSmrg fi 104574642e01fSmrg 104584642e01fSmrg if test -n "$gentop"; then 104594642e01fSmrg func_show_eval '${RM}r "$gentop"' 104604642e01fSmrg fi 104614642e01fSmrg 104624642e01fSmrg exit $EXIT_SUCCESS 1046305b261ecSmrg ;; 1046405b261ecSmrg 104654642e01fSmrg prog) 104664642e01fSmrg case $host in 104674642e01fSmrg *cygwin*) func_stripname '' '.exe' "$output" 104684642e01fSmrg output=$func_stripname_result.exe;; 104694642e01fSmrg esac 104704642e01fSmrg test -n "$vinfo" && \ 1047135c4bbdfSmrg func_warning "'-version-info' is ignored for programs" 1047205b261ecSmrg 104734642e01fSmrg test -n "$release" && \ 1047435c4bbdfSmrg func_warning "'-release' is ignored for programs" 1047505b261ecSmrg 1047635c4bbdfSmrg $preload \ 1047735c4bbdfSmrg && test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \ 1047835c4bbdfSmrg && func_warning "'LT_INIT([dlopen])' not used. Assuming no dlopen support." 104794642e01fSmrg 104804642e01fSmrg case $host in 104814642e01fSmrg *-*-rhapsody* | *-*-darwin1.[012]) 104824642e01fSmrg # On Rhapsody replace the C library is the System framework 104836747b715Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` 104846747b715Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` 1048505b261ecSmrg ;; 104864642e01fSmrg esac 1048705b261ecSmrg 104884642e01fSmrg case $host in 104894642e01fSmrg *-*-darwin*) 104904642e01fSmrg # Don't allow lazy linking, it breaks C++ global constructors 104914642e01fSmrg # But is supposedly fixed on 10.4 or later (yay!). 1049235c4bbdfSmrg if test CXX = "$tagname"; then 104934642e01fSmrg case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 104944642e01fSmrg 10.[0123]) 1049535c4bbdfSmrg func_append compile_command " $wl-bind_at_load" 1049635c4bbdfSmrg func_append finalize_command " $wl-bind_at_load" 104974642e01fSmrg ;; 104984642e01fSmrg esac 1049905b261ecSmrg fi 105004642e01fSmrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 105016747b715Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 105026747b715Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 105034642e01fSmrg ;; 105044642e01fSmrg esac 1050505b261ecSmrg 1050605b261ecSmrg 105074642e01fSmrg # move library search paths that coincide with paths to not yet 105084642e01fSmrg # installed libraries to the beginning of the library search list 105094642e01fSmrg new_libs= 105104642e01fSmrg for path in $notinst_path; do 105114642e01fSmrg case " $new_libs " in 105124642e01fSmrg *" -L$path/$objdir "*) ;; 105134642e01fSmrg *) 105144642e01fSmrg case " $compile_deplibs " in 105154642e01fSmrg *" -L$path/$objdir "*) 1051635c4bbdfSmrg func_append new_libs " -L$path/$objdir" ;; 1051705b261ecSmrg esac 105184642e01fSmrg ;; 105194642e01fSmrg esac 105204642e01fSmrg done 105214642e01fSmrg for deplib in $compile_deplibs; do 105224642e01fSmrg case $deplib in 105234642e01fSmrg -L*) 105244642e01fSmrg case " $new_libs " in 105254642e01fSmrg *" $deplib "*) ;; 1052635c4bbdfSmrg *) func_append new_libs " $deplib" ;; 1052705b261ecSmrg esac 105284642e01fSmrg ;; 1052935c4bbdfSmrg *) func_append new_libs " $deplib" ;; 105304642e01fSmrg esac 105314642e01fSmrg done 1053235c4bbdfSmrg compile_deplibs=$new_libs 1053305b261ecSmrg 1053405b261ecSmrg 1053535c4bbdfSmrg func_append compile_command " $compile_deplibs" 1053635c4bbdfSmrg func_append finalize_command " $finalize_deplibs" 1053705b261ecSmrg 105384642e01fSmrg if test -n "$rpath$xrpath"; then 105394642e01fSmrg # If the user specified any rpath flags, then add them. 105404642e01fSmrg for libdir in $rpath $xrpath; do 105414642e01fSmrg # This is the magic to use -rpath. 105424642e01fSmrg case "$finalize_rpath " in 105434642e01fSmrg *" $libdir "*) ;; 1054435c4bbdfSmrg *) func_append finalize_rpath " $libdir" ;; 105454642e01fSmrg esac 105464642e01fSmrg done 105474642e01fSmrg fi 1054805b261ecSmrg 105494642e01fSmrg # Now hardcode the library paths 105504642e01fSmrg rpath= 105514642e01fSmrg hardcode_libdirs= 105524642e01fSmrg for libdir in $compile_rpath $finalize_rpath; do 105534642e01fSmrg if test -n "$hardcode_libdir_flag_spec"; then 105544642e01fSmrg if test -n "$hardcode_libdir_separator"; then 105554642e01fSmrg if test -z "$hardcode_libdirs"; then 1055635c4bbdfSmrg hardcode_libdirs=$libdir 105574642e01fSmrg else 105584642e01fSmrg # Just accumulate the unique libdirs. 105594642e01fSmrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 105604642e01fSmrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 105614642e01fSmrg ;; 105624642e01fSmrg *) 1056335c4bbdfSmrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 105644642e01fSmrg ;; 105654642e01fSmrg esac 105664642e01fSmrg fi 1056705b261ecSmrg else 105684642e01fSmrg eval flag=\"$hardcode_libdir_flag_spec\" 1056935c4bbdfSmrg func_append rpath " $flag" 1057005b261ecSmrg fi 105714642e01fSmrg elif test -n "$runpath_var"; then 105724642e01fSmrg case "$perm_rpath " in 105734642e01fSmrg *" $libdir "*) ;; 1057435c4bbdfSmrg *) func_append perm_rpath " $libdir" ;; 105754642e01fSmrg esac 105764642e01fSmrg fi 105774642e01fSmrg case $host in 105784642e01fSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 1057935c4bbdfSmrg testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'` 105804642e01fSmrg case :$dllsearchpath: in 105814642e01fSmrg *":$libdir:"*) ;; 105824642e01fSmrg ::) dllsearchpath=$libdir;; 1058335c4bbdfSmrg *) func_append dllsearchpath ":$libdir";; 105844642e01fSmrg esac 105854642e01fSmrg case :$dllsearchpath: in 105864642e01fSmrg *":$testbindir:"*) ;; 105874642e01fSmrg ::) dllsearchpath=$testbindir;; 1058835c4bbdfSmrg *) func_append dllsearchpath ":$testbindir";; 105894642e01fSmrg esac 105904642e01fSmrg ;; 105914642e01fSmrg esac 105924642e01fSmrg done 105934642e01fSmrg # Substitute the hardcoded libdirs into the rpath. 105944642e01fSmrg if test -n "$hardcode_libdir_separator" && 105954642e01fSmrg test -n "$hardcode_libdirs"; then 1059635c4bbdfSmrg libdir=$hardcode_libdirs 105974642e01fSmrg eval rpath=\" $hardcode_libdir_flag_spec\" 105984642e01fSmrg fi 1059935c4bbdfSmrg compile_rpath=$rpath 1060005b261ecSmrg 106014642e01fSmrg rpath= 106024642e01fSmrg hardcode_libdirs= 106034642e01fSmrg for libdir in $finalize_rpath; do 106044642e01fSmrg if test -n "$hardcode_libdir_flag_spec"; then 106054642e01fSmrg if test -n "$hardcode_libdir_separator"; then 106064642e01fSmrg if test -z "$hardcode_libdirs"; then 1060735c4bbdfSmrg hardcode_libdirs=$libdir 106084642e01fSmrg else 106094642e01fSmrg # Just accumulate the unique libdirs. 106104642e01fSmrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 106114642e01fSmrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 106124642e01fSmrg ;; 106134642e01fSmrg *) 1061435c4bbdfSmrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 106154642e01fSmrg ;; 106164642e01fSmrg esac 106174642e01fSmrg fi 1061805b261ecSmrg else 106194642e01fSmrg eval flag=\"$hardcode_libdir_flag_spec\" 1062035c4bbdfSmrg func_append rpath " $flag" 1062105b261ecSmrg fi 106224642e01fSmrg elif test -n "$runpath_var"; then 106234642e01fSmrg case "$finalize_perm_rpath " in 106244642e01fSmrg *" $libdir "*) ;; 1062535c4bbdfSmrg *) func_append finalize_perm_rpath " $libdir" ;; 106264642e01fSmrg esac 1062705b261ecSmrg fi 106284642e01fSmrg done 106294642e01fSmrg # Substitute the hardcoded libdirs into the rpath. 106304642e01fSmrg if test -n "$hardcode_libdir_separator" && 106314642e01fSmrg test -n "$hardcode_libdirs"; then 1063235c4bbdfSmrg libdir=$hardcode_libdirs 106334642e01fSmrg eval rpath=\" $hardcode_libdir_flag_spec\" 106344642e01fSmrg fi 1063535c4bbdfSmrg finalize_rpath=$rpath 1063605b261ecSmrg 1063735c4bbdfSmrg if test -n "$libobjs" && test yes = "$build_old_libs"; then 106384642e01fSmrg # Transform all the library objects into standard objects. 106396747b715Smrg compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 106406747b715Smrg finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 106414642e01fSmrg fi 1064205b261ecSmrg 1064335c4bbdfSmrg func_generate_dlsyms "$outputname" "@PROGRAM@" false 1064405b261ecSmrg 106454642e01fSmrg # template prelinking step 106464642e01fSmrg if test -n "$prelink_cmds"; then 106474642e01fSmrg func_execute_cmds "$prelink_cmds" 'exit $?' 106484642e01fSmrg fi 1064905b261ecSmrg 1065035c4bbdfSmrg wrappers_required=: 106514642e01fSmrg case $host in 106526747b715Smrg *cegcc* | *mingw32ce*) 106536747b715Smrg # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. 1065435c4bbdfSmrg wrappers_required=false 106556747b715Smrg ;; 106564642e01fSmrg *cygwin* | *mingw* ) 1065735c4bbdfSmrg test yes = "$build_libtool_libs" || wrappers_required=false 106584642e01fSmrg ;; 106594642e01fSmrg *) 1066035c4bbdfSmrg if test no = "$need_relink" || test yes != "$build_libtool_libs"; then 1066135c4bbdfSmrg wrappers_required=false 106624642e01fSmrg fi 106634642e01fSmrg ;; 106644642e01fSmrg esac 1066535c4bbdfSmrg $wrappers_required || { 106664642e01fSmrg # Replace the output file specification. 106676747b715Smrg compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 1066835c4bbdfSmrg link_command=$compile_command$compile_rpath 1066905b261ecSmrg 106704642e01fSmrg # We have no uninstalled library dependencies, so finalize right now. 106714642e01fSmrg exit_status=0 106724642e01fSmrg func_show_eval "$link_command" 'exit_status=$?' 1067305b261ecSmrg 1067435c4bbdfSmrg if test -n "$postlink_cmds"; then 1067535c4bbdfSmrg func_to_tool_file "$output" 1067635c4bbdfSmrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 1067735c4bbdfSmrg func_execute_cmds "$postlink_cmds" 'exit $?' 1067835c4bbdfSmrg fi 1067935c4bbdfSmrg 106804642e01fSmrg # Delete the generated files. 1068135c4bbdfSmrg if test -f "$output_objdir/${outputname}S.$objext"; then 1068235c4bbdfSmrg func_show_eval '$RM "$output_objdir/${outputname}S.$objext"' 1068305b261ecSmrg fi 1068405b261ecSmrg 106854642e01fSmrg exit $exit_status 1068635c4bbdfSmrg } 1068705b261ecSmrg 106884642e01fSmrg if test -n "$compile_shlibpath$finalize_shlibpath"; then 106894642e01fSmrg compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" 106904642e01fSmrg fi 106914642e01fSmrg if test -n "$finalize_shlibpath"; then 106924642e01fSmrg finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" 106934642e01fSmrg fi 1069405b261ecSmrg 106954642e01fSmrg compile_var= 106964642e01fSmrg finalize_var= 106974642e01fSmrg if test -n "$runpath_var"; then 106984642e01fSmrg if test -n "$perm_rpath"; then 106994642e01fSmrg # We should set the runpath_var. 107004642e01fSmrg rpath= 107014642e01fSmrg for dir in $perm_rpath; do 1070235c4bbdfSmrg func_append rpath "$dir:" 107034642e01fSmrg done 107044642e01fSmrg compile_var="$runpath_var=\"$rpath\$$runpath_var\" " 1070505b261ecSmrg fi 107064642e01fSmrg if test -n "$finalize_perm_rpath"; then 107074642e01fSmrg # We should set the runpath_var. 107084642e01fSmrg rpath= 107094642e01fSmrg for dir in $finalize_perm_rpath; do 1071035c4bbdfSmrg func_append rpath "$dir:" 107114642e01fSmrg done 107124642e01fSmrg finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " 1071305b261ecSmrg fi 107144642e01fSmrg fi 1071505b261ecSmrg 1071635c4bbdfSmrg if test yes = "$no_install"; then 107174642e01fSmrg # We don't need to create a wrapper script. 1071835c4bbdfSmrg link_command=$compile_var$compile_command$compile_rpath 107194642e01fSmrg # Replace the output file specification. 107206747b715Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 107214642e01fSmrg # Delete the old output file. 107224642e01fSmrg $opt_dry_run || $RM $output 107234642e01fSmrg # Link the executable and exit 107244642e01fSmrg func_show_eval "$link_command" 'exit $?' 1072535c4bbdfSmrg 1072635c4bbdfSmrg if test -n "$postlink_cmds"; then 1072735c4bbdfSmrg func_to_tool_file "$output" 1072835c4bbdfSmrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 1072935c4bbdfSmrg func_execute_cmds "$postlink_cmds" 'exit $?' 1073035c4bbdfSmrg fi 1073135c4bbdfSmrg 1073205b261ecSmrg exit $EXIT_SUCCESS 107334642e01fSmrg fi 1073405b261ecSmrg 1073535c4bbdfSmrg case $hardcode_action,$fast_install in 1073635c4bbdfSmrg relink,*) 1073735c4bbdfSmrg # Fast installation is not supported 1073835c4bbdfSmrg link_command=$compile_var$compile_command$compile_rpath 1073935c4bbdfSmrg relink_command=$finalize_var$finalize_command$finalize_rpath 107404642e01fSmrg 1074135c4bbdfSmrg func_warning "this platform does not like uninstalled shared libraries" 1074235c4bbdfSmrg func_warning "'$output' will be relinked during installation" 1074335c4bbdfSmrg ;; 1074435c4bbdfSmrg *,yes) 1074535c4bbdfSmrg link_command=$finalize_var$compile_command$finalize_rpath 1074635c4bbdfSmrg relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` 1074735c4bbdfSmrg ;; 1074835c4bbdfSmrg *,no) 1074935c4bbdfSmrg link_command=$compile_var$compile_command$compile_rpath 1075035c4bbdfSmrg relink_command=$finalize_var$finalize_command$finalize_rpath 1075135c4bbdfSmrg ;; 1075235c4bbdfSmrg *,needless) 1075335c4bbdfSmrg link_command=$finalize_var$compile_command$finalize_rpath 1075435c4bbdfSmrg relink_command= 1075535c4bbdfSmrg ;; 1075635c4bbdfSmrg esac 1075705b261ecSmrg 107584642e01fSmrg # Replace the output file specification. 107596747b715Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` 1076005b261ecSmrg 107614642e01fSmrg # Delete the old output files. 107624642e01fSmrg $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname 1076305b261ecSmrg 107644642e01fSmrg func_show_eval "$link_command" 'exit $?' 1076505b261ecSmrg 1076635c4bbdfSmrg if test -n "$postlink_cmds"; then 1076735c4bbdfSmrg func_to_tool_file "$output_objdir/$outputname" 1076835c4bbdfSmrg 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'` 1076935c4bbdfSmrg func_execute_cmds "$postlink_cmds" 'exit $?' 1077035c4bbdfSmrg fi 1077135c4bbdfSmrg 107724642e01fSmrg # Now create the wrapper script. 107734642e01fSmrg func_verbose "creating $output" 1077405b261ecSmrg 107754642e01fSmrg # Quote the relink command for shipping. 107764642e01fSmrg if test -n "$relink_command"; then 107774642e01fSmrg # Preserve any variables that may affect compiler behavior 107784642e01fSmrg for var in $variables_saved_for_relink; do 107794642e01fSmrg if eval test -z \"\${$var+set}\"; then 107804642e01fSmrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 107814642e01fSmrg elif eval var_value=\$$var; test -z "$var_value"; then 107824642e01fSmrg relink_command="$var=; export $var; $relink_command" 1078305b261ecSmrg else 10784c82838c1Smrg func_quote_arg pretty "$var_value" 10785c82838c1Smrg relink_command="$var=$func_quote_arg_result; export $var; $relink_command" 1078605b261ecSmrg fi 107874642e01fSmrg done 10788c82838c1Smrg func_quote eval cd "`pwd`" 10789c82838c1Smrg func_quote_arg pretty,unquoted "($func_quote_result; $relink_command)" 10790c82838c1Smrg relink_command=$func_quote_arg_unquoted_result 107914642e01fSmrg fi 107924642e01fSmrg 107934642e01fSmrg # Only actually do things if not in dry run mode. 107944642e01fSmrg $opt_dry_run || { 107954642e01fSmrg # win32 will think the script is a binary if it has 107964642e01fSmrg # a .exe suffix, so we strip it off here. 107974642e01fSmrg case $output in 107984642e01fSmrg *.exe) func_stripname '' '.exe' "$output" 107994642e01fSmrg output=$func_stripname_result ;; 108004642e01fSmrg esac 108014642e01fSmrg # test for cygwin because mv fails w/o .exe extensions 108024642e01fSmrg case $host in 108034642e01fSmrg *cygwin*) 108044642e01fSmrg exeext=.exe 108054642e01fSmrg func_stripname '' '.exe' "$outputname" 108064642e01fSmrg outputname=$func_stripname_result ;; 108074642e01fSmrg *) exeext= ;; 1080805b261ecSmrg esac 108094642e01fSmrg case $host in 108104642e01fSmrg *cygwin* | *mingw* ) 108114642e01fSmrg func_dirname_and_basename "$output" "" "." 108124642e01fSmrg output_name=$func_basename_result 108134642e01fSmrg output_path=$func_dirname_result 1081435c4bbdfSmrg cwrappersource=$output_path/$objdir/lt-$output_name.c 1081535c4bbdfSmrg cwrapper=$output_path/$output_name.exe 108164642e01fSmrg $RM $cwrappersource $cwrapper 108174642e01fSmrg trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 108184642e01fSmrg 108194642e01fSmrg func_emit_cwrapperexe_src > $cwrappersource 108204642e01fSmrg 108214642e01fSmrg # The wrapper executable is built using the $host compiler, 108224642e01fSmrg # because it contains $host paths and files. If cross- 108234642e01fSmrg # compiling, it, like the target executable, must be 108244642e01fSmrg # executed on the $host or under an emulation environment. 108254642e01fSmrg $opt_dry_run || { 108264642e01fSmrg $LTCC $LTCFLAGS -o $cwrapper $cwrappersource 108274642e01fSmrg $STRIP $cwrapper 108284642e01fSmrg } 1082905b261ecSmrg 108304642e01fSmrg # Now, create the wrapper script for func_source use: 108314642e01fSmrg func_ltwrapper_scriptname $cwrapper 108324642e01fSmrg $RM $func_ltwrapper_scriptname_result 108334642e01fSmrg trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 108344642e01fSmrg $opt_dry_run || { 108354642e01fSmrg # note: this script will not be executed, so do not chmod. 1083635c4bbdfSmrg if test "x$build" = "x$host"; then 108374642e01fSmrg $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result 108384642e01fSmrg else 108394642e01fSmrg func_emit_wrapper no > $func_ltwrapper_scriptname_result 108404642e01fSmrg fi 108414642e01fSmrg } 108424642e01fSmrg ;; 108434642e01fSmrg * ) 108444642e01fSmrg $RM $output 108454642e01fSmrg trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 1084605b261ecSmrg 108474642e01fSmrg func_emit_wrapper no > $output 108484642e01fSmrg chmod +x $output 108494642e01fSmrg ;; 108504642e01fSmrg esac 108514642e01fSmrg } 108524642e01fSmrg exit $EXIT_SUCCESS 108534642e01fSmrg ;; 108544642e01fSmrg esac 1085505b261ecSmrg 108564642e01fSmrg # See if we need to build an old-fashioned archive. 108574642e01fSmrg for oldlib in $oldlibs; do 1085805b261ecSmrg 1085935c4bbdfSmrg case $build_libtool_libs in 1086035c4bbdfSmrg convenience) 1086135c4bbdfSmrg oldobjs="$libobjs_save $symfileobj" 1086235c4bbdfSmrg addlibs=$convenience 108634642e01fSmrg build_libtool_libs=no 1086435c4bbdfSmrg ;; 1086535c4bbdfSmrg module) 1086635c4bbdfSmrg oldobjs=$libobjs_save 1086735c4bbdfSmrg addlibs=$old_convenience 1086835c4bbdfSmrg build_libtool_libs=no 1086935c4bbdfSmrg ;; 1087035c4bbdfSmrg *) 108714642e01fSmrg oldobjs="$old_deplibs $non_pic_objects" 1087235c4bbdfSmrg $preload && test -f "$symfileobj" \ 1087335c4bbdfSmrg && func_append oldobjs " $symfileobj" 1087435c4bbdfSmrg addlibs=$old_convenience 1087535c4bbdfSmrg ;; 1087635c4bbdfSmrg esac 1087705b261ecSmrg 108784642e01fSmrg if test -n "$addlibs"; then 1087935c4bbdfSmrg gentop=$output_objdir/${outputname}x 1088035c4bbdfSmrg func_append generated " $gentop" 1088105b261ecSmrg 108824642e01fSmrg func_extract_archives $gentop $addlibs 1088335c4bbdfSmrg func_append oldobjs " $func_extract_archives_result" 108844642e01fSmrg fi 1088505b261ecSmrg 108864642e01fSmrg # Do each command in the archive commands. 1088735c4bbdfSmrg if test -n "$old_archive_from_new_cmds" && test yes = "$build_libtool_libs"; then 108884642e01fSmrg cmds=$old_archive_from_new_cmds 108894642e01fSmrg else 1089005b261ecSmrg 108914642e01fSmrg # Add any objects from preloaded convenience libraries 108924642e01fSmrg if test -n "$dlprefiles"; then 1089335c4bbdfSmrg gentop=$output_objdir/${outputname}x 1089435c4bbdfSmrg func_append generated " $gentop" 1089505b261ecSmrg 108964642e01fSmrg func_extract_archives $gentop $dlprefiles 1089735c4bbdfSmrg func_append oldobjs " $func_extract_archives_result" 108984642e01fSmrg fi 1089905b261ecSmrg 109004642e01fSmrg # POSIX demands no paths to be encoded in archives. We have 109014642e01fSmrg # to avoid creating archives with duplicate basenames if we 109024642e01fSmrg # might have to extract them afterwards, e.g., when creating a 109034642e01fSmrg # static archive out of a convenience library, or when linking 109044642e01fSmrg # the entirety of a libtool archive into another (currently 109054642e01fSmrg # not supported by libtool). 109064642e01fSmrg if (for obj in $oldobjs 109074642e01fSmrg do 109084642e01fSmrg func_basename "$obj" 109094642e01fSmrg $ECHO "$func_basename_result" 109104642e01fSmrg done | sort | sort -uc >/dev/null 2>&1); then 109114642e01fSmrg : 109124642e01fSmrg else 109136747b715Smrg echo "copying selected object files to avoid basename conflicts..." 1091435c4bbdfSmrg gentop=$output_objdir/${outputname}x 1091535c4bbdfSmrg func_append generated " $gentop" 109164642e01fSmrg func_mkdir_p "$gentop" 109174642e01fSmrg save_oldobjs=$oldobjs 109184642e01fSmrg oldobjs= 109194642e01fSmrg counter=1 109204642e01fSmrg for obj in $save_oldobjs 109214642e01fSmrg do 109224642e01fSmrg func_basename "$obj" 1092335c4bbdfSmrg objbase=$func_basename_result 109244642e01fSmrg case " $oldobjs " in 109254642e01fSmrg " ") oldobjs=$obj ;; 109264642e01fSmrg *[\ /]"$objbase "*) 109274642e01fSmrg while :; do 109284642e01fSmrg # Make sure we don't pick an alternate name that also 109294642e01fSmrg # overlaps. 109304642e01fSmrg newobj=lt$counter-$objbase 109314642e01fSmrg func_arith $counter + 1 109324642e01fSmrg counter=$func_arith_result 109334642e01fSmrg case " $oldobjs " in 109344642e01fSmrg *[\ /]"$newobj "*) ;; 109354642e01fSmrg *) if test ! -f "$gentop/$newobj"; then break; fi ;; 109364642e01fSmrg esac 109374642e01fSmrg done 109384642e01fSmrg func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" 1093935c4bbdfSmrg func_append oldobjs " $gentop/$newobj" 109404642e01fSmrg ;; 1094135c4bbdfSmrg *) func_append oldobjs " $obj" ;; 109424642e01fSmrg esac 1094305b261ecSmrg done 1094405b261ecSmrg fi 1094535c4bbdfSmrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 1094635c4bbdfSmrg tool_oldlib=$func_to_tool_file_result 109474642e01fSmrg eval cmds=\"$old_archive_cmds\" 1094805b261ecSmrg 109494642e01fSmrg func_len " $cmds" 109504642e01fSmrg len=$func_len_result 109514642e01fSmrg if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 109524642e01fSmrg cmds=$old_archive_cmds 1095335c4bbdfSmrg elif test -n "$archiver_list_spec"; then 1095435c4bbdfSmrg func_verbose "using command file archive linking..." 1095535c4bbdfSmrg for obj in $oldobjs 1095635c4bbdfSmrg do 1095735c4bbdfSmrg func_to_tool_file "$obj" 1095835c4bbdfSmrg $ECHO "$func_to_tool_file_result" 1095935c4bbdfSmrg done > $output_objdir/$libname.libcmd 1096035c4bbdfSmrg func_to_tool_file "$output_objdir/$libname.libcmd" 1096135c4bbdfSmrg oldobjs=" $archiver_list_spec$func_to_tool_file_result" 1096235c4bbdfSmrg cmds=$old_archive_cmds 109634642e01fSmrg else 109644642e01fSmrg # the command line is too long to link in one step, link in parts 109654642e01fSmrg func_verbose "using piecewise archive linking..." 109664642e01fSmrg save_RANLIB=$RANLIB 109674642e01fSmrg RANLIB=: 109684642e01fSmrg objlist= 109694642e01fSmrg concat_cmds= 109704642e01fSmrg save_oldobjs=$oldobjs 109714642e01fSmrg oldobjs= 109724642e01fSmrg # Is there a better way of finding the last object in the list? 109734642e01fSmrg for obj in $save_oldobjs 109744642e01fSmrg do 109754642e01fSmrg last_oldobj=$obj 109764642e01fSmrg done 109774642e01fSmrg eval test_cmds=\"$old_archive_cmds\" 109784642e01fSmrg func_len " $test_cmds" 109794642e01fSmrg len0=$func_len_result 109804642e01fSmrg len=$len0 109814642e01fSmrg for obj in $save_oldobjs 109824642e01fSmrg do 109834642e01fSmrg func_len " $obj" 109844642e01fSmrg func_arith $len + $func_len_result 109854642e01fSmrg len=$func_arith_result 109864642e01fSmrg func_append objlist " $obj" 109874642e01fSmrg if test "$len" -lt "$max_cmd_len"; then 109884642e01fSmrg : 109894642e01fSmrg else 109904642e01fSmrg # the above command should be used before it gets too long 109914642e01fSmrg oldobjs=$objlist 1099235c4bbdfSmrg if test "$obj" = "$last_oldobj"; then 109934642e01fSmrg RANLIB=$save_RANLIB 109944642e01fSmrg fi 109954642e01fSmrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 1099635c4bbdfSmrg eval concat_cmds=\"\$concat_cmds$old_archive_cmds\" 109974642e01fSmrg objlist= 109984642e01fSmrg len=$len0 109994642e01fSmrg fi 110004642e01fSmrg done 110014642e01fSmrg RANLIB=$save_RANLIB 110024642e01fSmrg oldobjs=$objlist 1100335c4bbdfSmrg if test -z "$oldobjs"; then 110044642e01fSmrg eval cmds=\"\$concat_cmds\" 110054642e01fSmrg else 110064642e01fSmrg eval cmds=\"\$concat_cmds~\$old_archive_cmds\" 110074642e01fSmrg fi 110084642e01fSmrg fi 110094642e01fSmrg fi 110104642e01fSmrg func_execute_cmds "$cmds" 'exit $?' 1101105b261ecSmrg done 1101205b261ecSmrg 110134642e01fSmrg test -n "$generated" && \ 110144642e01fSmrg func_show_eval "${RM}r$generated" 1101505b261ecSmrg 110164642e01fSmrg # Now create the libtool archive. 110174642e01fSmrg case $output in 110184642e01fSmrg *.la) 110194642e01fSmrg old_library= 1102035c4bbdfSmrg test yes = "$build_old_libs" && old_library=$libname.$libext 110214642e01fSmrg func_verbose "creating $output" 1102205b261ecSmrg 110234642e01fSmrg # Preserve any variables that may affect compiler behavior 110244642e01fSmrg for var in $variables_saved_for_relink; do 110254642e01fSmrg if eval test -z \"\${$var+set}\"; then 110264642e01fSmrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 110274642e01fSmrg elif eval var_value=\$$var; test -z "$var_value"; then 110284642e01fSmrg relink_command="$var=; export $var; $relink_command" 1102905b261ecSmrg else 11030c82838c1Smrg func_quote_arg pretty,unquoted "$var_value" 11031c82838c1Smrg relink_command="$var=$func_quote_arg_unquoted_result; export $var; $relink_command" 1103205b261ecSmrg fi 110334642e01fSmrg done 110344642e01fSmrg # Quote the link command for shipping. 11035c82838c1Smrg func_quote eval cd "`pwd`" 11036c82838c1Smrg relink_command="($func_quote_result; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" 11037c82838c1Smrg func_quote_arg pretty,unquoted "$relink_command" 11038c82838c1Smrg relink_command=$func_quote_arg_unquoted_result 1103935c4bbdfSmrg if test yes = "$hardcode_automatic"; then 110404642e01fSmrg relink_command= 110414642e01fSmrg fi 1104205b261ecSmrg 110434642e01fSmrg # Only create the output if not a dry run. 110444642e01fSmrg $opt_dry_run || { 110454642e01fSmrg for installed in no yes; do 1104635c4bbdfSmrg if test yes = "$installed"; then 110474642e01fSmrg if test -z "$install_libdir"; then 110484642e01fSmrg break 110494642e01fSmrg fi 1105035c4bbdfSmrg output=$output_objdir/${outputname}i 110514642e01fSmrg # Replace all uninstalled libtool libraries with the installed ones 110524642e01fSmrg newdependency_libs= 110534642e01fSmrg for deplib in $dependency_libs; do 110544642e01fSmrg case $deplib in 110554642e01fSmrg *.la) 110564642e01fSmrg func_basename "$deplib" 1105735c4bbdfSmrg name=$func_basename_result 1105835c4bbdfSmrg func_resolve_sysroot "$deplib" 1105935c4bbdfSmrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` 110604642e01fSmrg test -z "$libdir" && \ 1106135c4bbdfSmrg func_fatal_error "'$deplib' is not a valid libtool archive" 1106235c4bbdfSmrg func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" 1106335c4bbdfSmrg ;; 1106435c4bbdfSmrg -L*) 1106535c4bbdfSmrg func_stripname -L '' "$deplib" 1106635c4bbdfSmrg func_replace_sysroot "$func_stripname_result" 1106735c4bbdfSmrg func_append newdependency_libs " -L$func_replace_sysroot_result" 110686747b715Smrg ;; 1106935c4bbdfSmrg -R*) 1107035c4bbdfSmrg func_stripname -R '' "$deplib" 1107135c4bbdfSmrg func_replace_sysroot "$func_stripname_result" 1107235c4bbdfSmrg func_append newdependency_libs " -R$func_replace_sysroot_result" 1107335c4bbdfSmrg ;; 1107435c4bbdfSmrg *) func_append newdependency_libs " $deplib" ;; 110754642e01fSmrg esac 110764642e01fSmrg done 1107735c4bbdfSmrg dependency_libs=$newdependency_libs 110784642e01fSmrg newdlfiles= 110794642e01fSmrg 110804642e01fSmrg for lib in $dlfiles; do 110814642e01fSmrg case $lib in 110824642e01fSmrg *.la) 110834642e01fSmrg func_basename "$lib" 1108435c4bbdfSmrg name=$func_basename_result 1108535c4bbdfSmrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 110864642e01fSmrg test -z "$libdir" && \ 1108735c4bbdfSmrg func_fatal_error "'$lib' is not a valid libtool archive" 1108835c4bbdfSmrg func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" 110894642e01fSmrg ;; 1109035c4bbdfSmrg *) func_append newdlfiles " $lib" ;; 110914642e01fSmrg esac 110924642e01fSmrg done 1109335c4bbdfSmrg dlfiles=$newdlfiles 110944642e01fSmrg newdlprefiles= 110954642e01fSmrg for lib in $dlprefiles; do 110964642e01fSmrg case $lib in 110974642e01fSmrg *.la) 110984642e01fSmrg # Only pass preopened files to the pseudo-archive (for 110994642e01fSmrg # eventual linking with the app. that links it) if we 111004642e01fSmrg # didn't already link the preopened objects directly into 111014642e01fSmrg # the library: 111024642e01fSmrg func_basename "$lib" 1110335c4bbdfSmrg name=$func_basename_result 1110435c4bbdfSmrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 111054642e01fSmrg test -z "$libdir" && \ 1110635c4bbdfSmrg func_fatal_error "'$lib' is not a valid libtool archive" 1110735c4bbdfSmrg func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" 111084642e01fSmrg ;; 111094642e01fSmrg esac 111104642e01fSmrg done 1111135c4bbdfSmrg dlprefiles=$newdlprefiles 111124642e01fSmrg else 111134642e01fSmrg newdlfiles= 111144642e01fSmrg for lib in $dlfiles; do 111154642e01fSmrg case $lib in 1111635c4bbdfSmrg [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; 111174642e01fSmrg *) abs=`pwd`"/$lib" ;; 111184642e01fSmrg esac 1111935c4bbdfSmrg func_append newdlfiles " $abs" 111204642e01fSmrg done 1112135c4bbdfSmrg dlfiles=$newdlfiles 111224642e01fSmrg newdlprefiles= 111234642e01fSmrg for lib in $dlprefiles; do 111244642e01fSmrg case $lib in 1112535c4bbdfSmrg [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; 111264642e01fSmrg *) abs=`pwd`"/$lib" ;; 111274642e01fSmrg esac 1112835c4bbdfSmrg func_append newdlprefiles " $abs" 111294642e01fSmrg done 1113035c4bbdfSmrg dlprefiles=$newdlprefiles 111314642e01fSmrg fi 111324642e01fSmrg $RM $output 111334642e01fSmrg # place dlname in correct position for cygwin 111346747b715Smrg # In fact, it would be nice if we could use this code for all target 111356747b715Smrg # systems that can't hard-code library paths into their executables 111366747b715Smrg # and that have no shared library path variable independent of PATH, 111376747b715Smrg # but it turns out we can't easily determine that from inspecting 111386747b715Smrg # libtool variables, so we have to hard-code the OSs to which it 111396747b715Smrg # applies here; at the moment, that means platforms that use the PE 111406747b715Smrg # object format with DLL files. See the long comment at the top of 111416747b715Smrg # tests/bindir.at for full details. 111424642e01fSmrg tdlname=$dlname 111434642e01fSmrg case $host,$output,$installed,$module,$dlname in 111446747b715Smrg *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) 111456747b715Smrg # If a -bindir argument was supplied, place the dll there. 1114635c4bbdfSmrg if test -n "$bindir"; then 111476747b715Smrg func_relative_path "$install_libdir" "$bindir" 1114835c4bbdfSmrg tdlname=$func_relative_path_result/$dlname 111496747b715Smrg else 111506747b715Smrg # Otherwise fall back on heuristic. 111516747b715Smrg tdlname=../bin/$dlname 111526747b715Smrg fi 111536747b715Smrg ;; 111544642e01fSmrg esac 111554642e01fSmrg $ECHO > $output "\ 111564642e01fSmrg# $outputname - a libtool library file 1115735c4bbdfSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 111584642e01fSmrg# 111594642e01fSmrg# Please DO NOT delete this file! 111604642e01fSmrg# It is necessary for linking the library. 1116105b261ecSmrg 111624642e01fSmrg# The name that we can dlopen(3). 111634642e01fSmrgdlname='$tdlname' 1116405b261ecSmrg 111654642e01fSmrg# Names of this library. 111664642e01fSmrglibrary_names='$library_names' 1116705b261ecSmrg 111684642e01fSmrg# The name of the static archive. 111694642e01fSmrgold_library='$old_library' 1117005b261ecSmrg 1117135c4bbdfSmrg# Linker flags that cannot go in dependency_libs. 111724642e01fSmrginherited_linker_flags='$new_inherited_linker_flags' 1117305b261ecSmrg 111744642e01fSmrg# Libraries that this one depends upon. 111754642e01fSmrgdependency_libs='$dependency_libs' 1117605b261ecSmrg 111774642e01fSmrg# Names of additional weak libraries provided by this library 111784642e01fSmrgweak_library_names='$weak_libs' 1117905b261ecSmrg 111804642e01fSmrg# Version information for $libname. 111814642e01fSmrgcurrent=$current 111824642e01fSmrgage=$age 111834642e01fSmrgrevision=$revision 1118405b261ecSmrg 111854642e01fSmrg# Is this an already installed library? 111864642e01fSmrginstalled=$installed 1118705b261ecSmrg 111884642e01fSmrg# Should we warn about portability when linking against -modules? 111894642e01fSmrgshouldnotlink=$module 1119005b261ecSmrg 111914642e01fSmrg# Files to dlopen/dlpreopen 111924642e01fSmrgdlopen='$dlfiles' 111934642e01fSmrgdlpreopen='$dlprefiles' 1119405b261ecSmrg 111954642e01fSmrg# Directory that this library needs to be installed in: 111964642e01fSmrglibdir='$install_libdir'" 1119735c4bbdfSmrg if test no,yes = "$installed,$need_relink"; then 111984642e01fSmrg $ECHO >> $output "\ 111994642e01fSmrgrelink_command=\"$relink_command\"" 112004642e01fSmrg fi 112014642e01fSmrg done 112024642e01fSmrg } 1120305b261ecSmrg 112044642e01fSmrg # Do a symbolic link so that the libtool archive can be found in 112054642e01fSmrg # LD_LIBRARY_PATH before the program is installed. 112064642e01fSmrg func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' 112074642e01fSmrg ;; 112084642e01fSmrg esac 112094642e01fSmrg exit $EXIT_SUCCESS 112104642e01fSmrg} 1121105b261ecSmrg 1121235c4bbdfSmrgif test link = "$opt_mode" || test relink = "$opt_mode"; then 1121335c4bbdfSmrg func_mode_link ${1+"$@"} 1121435c4bbdfSmrgfi 1121505b261ecSmrg 1121605b261ecSmrg 112174642e01fSmrg# func_mode_uninstall arg... 112184642e01fSmrgfunc_mode_uninstall () 112194642e01fSmrg{ 1122035c4bbdfSmrg $debug_cmd 1122135c4bbdfSmrg 1122235c4bbdfSmrg RM=$nonopt 1122305b261ecSmrg files= 1122435c4bbdfSmrg rmforce=false 1122505b261ecSmrg exit_status=0 1122605b261ecSmrg 1122705b261ecSmrg # This variable tells wrapper scripts just to set variables rather 1122805b261ecSmrg # than running their programs. 1122935c4bbdfSmrg libtool_install_magic=$magic 1123005b261ecSmrg 1123105b261ecSmrg for arg 1123205b261ecSmrg do 1123305b261ecSmrg case $arg in 1123435c4bbdfSmrg -f) func_append RM " $arg"; rmforce=: ;; 1123535c4bbdfSmrg -*) func_append RM " $arg" ;; 1123635c4bbdfSmrg *) func_append files " $arg" ;; 1123705b261ecSmrg esac 1123805b261ecSmrg done 1123905b261ecSmrg 112404642e01fSmrg test -z "$RM" && \ 112414642e01fSmrg func_fatal_help "you must specify an RM program" 1124205b261ecSmrg 1124305b261ecSmrg rmdirs= 1124405b261ecSmrg 1124505b261ecSmrg for file in $files; do 112464642e01fSmrg func_dirname "$file" "" "." 1124735c4bbdfSmrg dir=$func_dirname_result 1124835c4bbdfSmrg if test . = "$dir"; then 1124935c4bbdfSmrg odir=$objdir 1125005b261ecSmrg else 1125135c4bbdfSmrg odir=$dir/$objdir 1125205b261ecSmrg fi 112534642e01fSmrg func_basename "$file" 1125435c4bbdfSmrg name=$func_basename_result 1125535c4bbdfSmrg test uninstall = "$opt_mode" && odir=$dir 1125605b261ecSmrg 1125735c4bbdfSmrg # Remember odir for removal later, being careful to avoid duplicates 1125835c4bbdfSmrg if test clean = "$opt_mode"; then 1125905b261ecSmrg case " $rmdirs " in 1126035c4bbdfSmrg *" $odir "*) ;; 1126135c4bbdfSmrg *) func_append rmdirs " $odir" ;; 1126205b261ecSmrg esac 1126305b261ecSmrg fi 1126405b261ecSmrg 1126505b261ecSmrg # Don't error if the file doesn't exist and rm -f was used. 112664642e01fSmrg if { test -L "$file"; } >/dev/null 2>&1 || 112674642e01fSmrg { test -h "$file"; } >/dev/null 2>&1 || 112684642e01fSmrg test -f "$file"; then 1126905b261ecSmrg : 1127005b261ecSmrg elif test -d "$file"; then 1127105b261ecSmrg exit_status=1 1127205b261ecSmrg continue 1127335c4bbdfSmrg elif $rmforce; then 1127405b261ecSmrg continue 1127505b261ecSmrg fi 1127605b261ecSmrg 1127735c4bbdfSmrg rmfiles=$file 1127805b261ecSmrg 1127905b261ecSmrg case $name in 1128005b261ecSmrg *.la) 1128105b261ecSmrg # Possibly a libtool archive, so verify it. 112824642e01fSmrg if func_lalib_p "$file"; then 112834642e01fSmrg func_source $dir/$name 1128405b261ecSmrg 1128505b261ecSmrg # Delete the libtool libraries and symlinks. 1128605b261ecSmrg for n in $library_names; do 1128735c4bbdfSmrg func_append rmfiles " $odir/$n" 1128805b261ecSmrg done 1128935c4bbdfSmrg test -n "$old_library" && func_append rmfiles " $odir/$old_library" 1129005b261ecSmrg 1129135c4bbdfSmrg case $opt_mode in 1129205b261ecSmrg clean) 1129335c4bbdfSmrg case " $library_names " in 1129405b261ecSmrg *" $dlname "*) ;; 1129535c4bbdfSmrg *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; 1129605b261ecSmrg esac 1129735c4bbdfSmrg test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" 1129805b261ecSmrg ;; 1129905b261ecSmrg uninstall) 1130005b261ecSmrg if test -n "$library_names"; then 1130105b261ecSmrg # Do each command in the postuninstall commands. 1130235c4bbdfSmrg func_execute_cmds "$postuninstall_cmds" '$rmforce || exit_status=1' 1130305b261ecSmrg fi 1130405b261ecSmrg 1130505b261ecSmrg if test -n "$old_library"; then 1130605b261ecSmrg # Do each command in the old_postuninstall commands. 1130735c4bbdfSmrg func_execute_cmds "$old_postuninstall_cmds" '$rmforce || exit_status=1' 1130805b261ecSmrg fi 1130905b261ecSmrg # FIXME: should reinstall the best remaining shared library. 1131005b261ecSmrg ;; 1131105b261ecSmrg esac 1131205b261ecSmrg fi 1131305b261ecSmrg ;; 1131405b261ecSmrg 1131505b261ecSmrg *.lo) 1131605b261ecSmrg # Possibly a libtool object, so verify it. 113174642e01fSmrg if func_lalib_p "$file"; then 1131805b261ecSmrg 1131905b261ecSmrg # Read the .lo file 113204642e01fSmrg func_source $dir/$name 1132105b261ecSmrg 1132205b261ecSmrg # Add PIC object to the list of files to remove. 1132335c4bbdfSmrg if test -n "$pic_object" && test none != "$pic_object"; then 1132435c4bbdfSmrg func_append rmfiles " $dir/$pic_object" 1132505b261ecSmrg fi 1132605b261ecSmrg 1132705b261ecSmrg # Add non-PIC object to the list of files to remove. 1132835c4bbdfSmrg if test -n "$non_pic_object" && test none != "$non_pic_object"; then 1132935c4bbdfSmrg func_append rmfiles " $dir/$non_pic_object" 1133005b261ecSmrg fi 1133105b261ecSmrg fi 1133205b261ecSmrg ;; 1133305b261ecSmrg 1133405b261ecSmrg *) 1133535c4bbdfSmrg if test clean = "$opt_mode"; then 1133605b261ecSmrg noexename=$name 1133705b261ecSmrg case $file in 1133805b261ecSmrg *.exe) 113394642e01fSmrg func_stripname '' '.exe' "$file" 113404642e01fSmrg file=$func_stripname_result 113414642e01fSmrg func_stripname '' '.exe' "$name" 113424642e01fSmrg noexename=$func_stripname_result 1134305b261ecSmrg # $file with .exe has already been added to rmfiles, 1134405b261ecSmrg # add $file without .exe 1134535c4bbdfSmrg func_append rmfiles " $file" 1134605b261ecSmrg ;; 1134705b261ecSmrg esac 1134805b261ecSmrg # Do a test to see if this is a libtool program. 113494642e01fSmrg if func_ltwrapper_p "$file"; then 113504642e01fSmrg if func_ltwrapper_executable_p "$file"; then 113514642e01fSmrg func_ltwrapper_scriptname "$file" 113524642e01fSmrg relink_command= 113534642e01fSmrg func_source $func_ltwrapper_scriptname_result 1135435c4bbdfSmrg func_append rmfiles " $func_ltwrapper_scriptname_result" 113554642e01fSmrg else 113564642e01fSmrg relink_command= 113574642e01fSmrg func_source $dir/$noexename 113584642e01fSmrg fi 1135905b261ecSmrg 1136005b261ecSmrg # note $name still contains .exe if it was in $file originally 1136105b261ecSmrg # as does the version of $file that was added into $rmfiles 1136235c4bbdfSmrg func_append rmfiles " $odir/$name $odir/${name}S.$objext" 1136335c4bbdfSmrg if test yes = "$fast_install" && test -n "$relink_command"; then 1136435c4bbdfSmrg func_append rmfiles " $odir/lt-$name" 1136505b261ecSmrg fi 1136635c4bbdfSmrg if test "X$noexename" != "X$name"; then 1136735c4bbdfSmrg func_append rmfiles " $odir/lt-$noexename.c" 1136805b261ecSmrg fi 1136905b261ecSmrg fi 1137005b261ecSmrg fi 1137105b261ecSmrg ;; 1137205b261ecSmrg esac 113734642e01fSmrg func_show_eval "$RM $rmfiles" 'exit_status=1' 1137405b261ecSmrg done 1137505b261ecSmrg 1137635c4bbdfSmrg # Try to remove the $objdir's in the directories where we deleted files 1137705b261ecSmrg for dir in $rmdirs; do 1137805b261ecSmrg if test -d "$dir"; then 113794642e01fSmrg func_show_eval "rmdir $dir >/dev/null 2>&1" 1138005b261ecSmrg fi 1138105b261ecSmrg done 1138205b261ecSmrg 1138305b261ecSmrg exit $exit_status 113844642e01fSmrg} 1138505b261ecSmrg 1138635c4bbdfSmrgif test uninstall = "$opt_mode" || test clean = "$opt_mode"; then 1138735c4bbdfSmrg func_mode_uninstall ${1+"$@"} 1138835c4bbdfSmrgfi 1138905b261ecSmrg 1139035c4bbdfSmrgtest -z "$opt_mode" && { 1139135c4bbdfSmrg help=$generic_help 113924642e01fSmrg func_fatal_help "you must specify a MODE" 113934642e01fSmrg} 113944642e01fSmrg 113954642e01fSmrgtest -z "$exec_cmd" && \ 1139635c4bbdfSmrg func_fatal_help "invalid operation mode '$opt_mode'" 1139705b261ecSmrg 1139805b261ecSmrgif test -n "$exec_cmd"; then 113994642e01fSmrg eval exec "$exec_cmd" 1140005b261ecSmrg exit $EXIT_FAILURE 1140105b261ecSmrgfi 1140205b261ecSmrg 114034642e01fSmrgexit $exit_status 1140405b261ecSmrg 1140505b261ecSmrg 1140605b261ecSmrg# The TAGs below are defined such that we never get into a situation 1140735c4bbdfSmrg# where we disable both kinds of libraries. Given conflicting 1140805b261ecSmrg# choices, we go for a static library, that is the most portable, 1140905b261ecSmrg# since we can't tell whether shared libraries were disabled because 1141005b261ecSmrg# the user asked for that or because the platform doesn't support 1141105b261ecSmrg# them. This is particularly important on AIX, because we don't 1141205b261ecSmrg# support having both static and shared libraries enabled at the same 1141305b261ecSmrg# time on that platform, so we default to a shared-only configuration. 1141405b261ecSmrg# If a disable-shared tag is given, we'll fallback to a static-only 1141505b261ecSmrg# configuration. But we'll never go from static-only to shared-only. 1141605b261ecSmrg 1141705b261ecSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared 114184642e01fSmrgbuild_libtool_libs=no 114194642e01fSmrgbuild_old_libs=yes 1142005b261ecSmrg# ### END LIBTOOL TAG CONFIG: disable-shared 1142105b261ecSmrg 1142205b261ecSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static 114234642e01fSmrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` 1142405b261ecSmrg# ### END LIBTOOL TAG CONFIG: disable-static 1142505b261ecSmrg 1142605b261ecSmrg# Local Variables: 1142705b261ecSmrg# mode:shell-script 1142805b261ecSmrg# sh-indentation:2 1142905b261ecSmrg# End: 11430